Skip to content

Commit d2220a4

Browse files
DanielEScherzerkocsismate
authored andcommitted
gen_stub: inline single-use static SimpleType constructors
The following one-line methods, only used in `SimpleType::fromValue()`, were inlined: * `SimpleType::bool()` * `SimpleType::int()` * `SimpleType::float()` * `SimpleType::string()` * `SimpleType::array()` * `SimpleType::object()` Doing so removes an unneeded level of indirection and helps simplify the class.
1 parent c2ecb71 commit d2220a4

File tree

1 file changed

+6
-36
lines changed

1 file changed

+6
-36
lines changed

build/gen_stub.php

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,17 @@ public static function fromValue($value): SimpleType
306306
case "NULL":
307307
return SimpleType::null();
308308
case "boolean":
309-
return SimpleType::bool();
309+
return new SimpleType("bool", true);
310310
case "integer":
311-
return SimpleType::int();
311+
return new SimpleType("int", true);
312312
case "double":
313-
return SimpleType::float();
313+
return new SimpleType("float", true);
314314
case "string":
315-
return SimpleType::string();
315+
return new SimpleType("string", true);
316316
case "array":
317-
return SimpleType::array();
317+
return new SimpleType("array", true);
318318
case "object":
319-
return SimpleType::object();
319+
return new SimpleType("object", true);
320320
default:
321321
throw new Exception("Type \"" . gettype($value) . "\" cannot be inferred based on value");
322322
}
@@ -327,36 +327,6 @@ public static function null(): SimpleType
327327
return new SimpleType("null", true);
328328
}
329329

330-
public static function bool(): SimpleType
331-
{
332-
return new SimpleType("bool", true);
333-
}
334-
335-
public static function int(): SimpleType
336-
{
337-
return new SimpleType("int", true);
338-
}
339-
340-
public static function float(): SimpleType
341-
{
342-
return new SimpleType("float", true);
343-
}
344-
345-
public static function string(): SimpleType
346-
{
347-
return new SimpleType("string", true);
348-
}
349-
350-
public static function array(): SimpleType
351-
{
352-
return new SimpleType("array", true);
353-
}
354-
355-
public static function object(): SimpleType
356-
{
357-
return new SimpleType("object", true);
358-
}
359-
360330
protected function __construct(string $name, bool $isBuiltin) {
361331
$this->name = $name;
362332
$this->isBuiltin = $isBuiltin;

0 commit comments

Comments
 (0)