mirror of
https://github.com/php/php-src.git
synced 2026-03-26 09:12:14 +01: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:
committed by
Máté Kocsis
parent
c2ecb71dbb
commit
d2220a407b
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user