mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
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.
This commit is contained in:
parent
c2ecb71dbb
commit
d2220a407b
1 changed files with 6 additions and 36 deletions
|
@ -306,17 +306,17 @@ class SimpleType {
|
|||
case "NULL":
|
||||
return SimpleType::null();
|
||||
case "boolean":
|
||||
return SimpleType::bool();
|
||||
return new SimpleType("bool", true);
|
||||
case "integer":
|
||||
return SimpleType::int();
|
||||
return new SimpleType("int", true);
|
||||
case "double":
|
||||
return SimpleType::float();
|
||||
return new SimpleType("float", true);
|
||||
case "string":
|
||||
return SimpleType::string();
|
||||
return new SimpleType("string", true);
|
||||
case "array":
|
||||
return SimpleType::array();
|
||||
return new SimpleType("array", true);
|
||||
case "object":
|
||||
return SimpleType::object();
|
||||
return new SimpleType("object", true);
|
||||
default:
|
||||
throw new Exception("Type \"" . gettype($value) . "\" cannot be inferred based on value");
|
||||
}
|
||||
|
@ -327,36 +327,6 @@ class SimpleType {
|
|||
return new SimpleType("null", true);
|
||||
}
|
||||
|
||||
public static function bool(): SimpleType
|
||||
{
|
||||
return new SimpleType("bool", true);
|
||||
}
|
||||
|
||||
public static function int(): SimpleType
|
||||
{
|
||||
return new SimpleType("int", true);
|
||||
}
|
||||
|
||||
public static function float(): SimpleType
|
||||
{
|
||||
return new SimpleType("float", true);
|
||||
}
|
||||
|
||||
public static function string(): SimpleType
|
||||
{
|
||||
return new SimpleType("string", true);
|
||||
}
|
||||
|
||||
public static function array(): SimpleType
|
||||
{
|
||||
return new SimpleType("array", true);
|
||||
}
|
||||
|
||||
public static function object(): SimpleType
|
||||
{
|
||||
return new SimpleType("object", true);
|
||||
}
|
||||
|
||||
protected function __construct(string $name, bool $isBuiltin) {
|
||||
$this->name = $name;
|
||||
$this->isBuiltin = $isBuiltin;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue