diff --git a/Library/Cache/MethodCache.php b/Library/Cache/MethodCache.php index 66238021c..5b731a1ec 100644 --- a/Library/Cache/MethodCache.php +++ b/Library/Cache/MethodCache.php @@ -17,7 +17,6 @@ use ReflectionException; use Zephir\ClassDefinition; use Zephir\CompilationContext; -use Zephir\MethodCallWarmUp; use Zephir\Passes\CallGathererPass; use Zephir\Variable; @@ -148,13 +147,6 @@ public function get(CompilationContext $compilationContext, string $methodName, $cacheable = false; } - // Recursive methods require warm-up - if ($compilationContext->currentMethod == $method) { - if (!$compilationContext->methodWarmUp) { - $compilationContext->methodWarmUp = new MethodCallWarmUp(); - } - } - if ('this_ptr' != $caller->getName()) { $associatedClass = $caller->getAssociatedClass(); if ($this->isClassCacheable($associatedClass)) { diff --git a/Library/Classes/Entry.php b/Library/Classes/Entry.php index 2b1466cea..47ded83a5 100644 --- a/Library/Classes/Entry.php +++ b/Library/Classes/Entry.php @@ -14,7 +14,6 @@ namespace Zephir\Classes; use ReflectionClass; -use ReflectionException; use Zephir\ClassDefinition; use Zephir\CompilationContext; use Zephir\Exception; @@ -75,7 +74,6 @@ public function __construct(string $className, CompilationContext $compilationCo * @return string * * @throws Exception - * @throws ReflectionException */ public function get(): string { diff --git a/Library/Code/Builder/Struct.php b/Library/Code/Builder/Struct.php index 1d5c9472a..7f62238fb 100644 --- a/Library/Code/Builder/Struct.php +++ b/Library/Code/Builder/Struct.php @@ -86,7 +86,7 @@ public function __toString(): string * * @throws InvalidArgumentException */ - public function addProperty(string $field, array $global) + public function addProperty(string $field, array $global): void { if (!isset($global['type']) || !is_string($global['type'])) { throw new InvalidArgumentException('Property type must be string'); diff --git a/Library/Compiler/FileInterface.php b/Library/Compiler/FileInterface.php index 6485c41d0..588e2d19e 100644 --- a/Library/Compiler/FileInterface.php +++ b/Library/Compiler/FileInterface.php @@ -15,8 +15,6 @@ use Zephir\Compiler; /** - * FileInterface. - * * Provides a common interface for compiler files */ interface FileInterface diff --git a/Library/EventsManager.php b/Library/EventsManager.php index 6db0dff1e..b9c33e126 100644 --- a/Library/EventsManager.php +++ b/Library/EventsManager.php @@ -11,9 +11,6 @@ namespace Zephir; -/** - * Class EventsManager. - */ class EventsManager { /** diff --git a/Library/Expression.php b/Library/Expression.php index 817612f40..8199d1816 100644 --- a/Library/Expression.php +++ b/Library/Expression.php @@ -78,17 +78,10 @@ class Expression protected bool $expecting = true; protected bool $readOnly = false; protected bool $evalMode = false; - protected array $expression = []; protected ?Variable $expectingVariable = null; - /** - * Expression constructor. - * - * @param array $expression - */ - public function __construct(array $expression) + public function __construct(protected array $expression) { - $this->expression = $expression; } /** diff --git a/Library/FunctionCall.php b/Library/FunctionCall.php index e7c9ec1d9..5bd9eee12 100644 --- a/Library/FunctionCall.php +++ b/Library/FunctionCall.php @@ -77,7 +77,7 @@ public function getReflector($funcName) * * @return bool */ - public function isBuiltInFunction($functionName) + public function isBuiltInFunction(string $functionName) { switch ($functionName) { case 'memstr': diff --git a/Library/FunctionDefinition.php b/Library/FunctionDefinition.php index 53116f1c7..814222700 100644 --- a/Library/FunctionDefinition.php +++ b/Library/FunctionDefinition.php @@ -14,17 +14,10 @@ namespace Zephir; /** - * FunctionDefinition. - * * Represents a function */ class FunctionDefinition extends ClassMethod { - /** - * The namespace of the function. - */ - private string $namespace; - /** * Whether the function is declared in a global or namespaced scope. * @@ -35,7 +28,7 @@ class FunctionDefinition extends ClassMethod /** * FunctionDefinition constructor. * - * @param string $namespace + * @param string $namespace The namespace of the function. * @param string $name * @param ClassMethodParameters|null $parameters * @param StatementsBlock|null $statements @@ -43,14 +36,13 @@ class FunctionDefinition extends ClassMethod * @param array|null $expression */ public function __construct( - string $namespace, + private string $namespace, string $name, ClassMethodParameters $parameters = null, StatementsBlock $statements = null, array $returnType = null, array $expression = null ) { - $this->namespace = $namespace; $this->name = $name; $this->parameters = $parameters; $this->statements = $statements; diff --git a/Library/GlobalConstant.php b/Library/GlobalConstant.php index 6a5a330a5..f818b9d2d 100644 --- a/Library/GlobalConstant.php +++ b/Library/GlobalConstant.php @@ -12,23 +12,15 @@ namespace Zephir; /** - * GlobalConstant. + * Creates a new global constant. * * Global constants are allocated one time at extension initialization * and are referenced across the C code saving memory */ class GlobalConstant { - protected $name; - - /** - * Creates a new global constant. - * - * @param string $name - */ - public function __construct($name) + public function __construct(protected string $name) { - $this->name = $name; } /** @@ -36,7 +28,7 @@ public function __construct($name) * * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -46,7 +38,7 @@ public function getName() * * @return bool */ - public function isTemporal() + public function isTemporal(): bool { return false; } diff --git a/Library/HeadersManager.php b/Library/HeadersManager.php index 10d078cd1..c6a7ad9a1 100644 --- a/Library/HeadersManager.php +++ b/Library/HeadersManager.php @@ -12,8 +12,6 @@ namespace Zephir; /** - * Class HeadersManager. - * * Manages the c-headers that must be added to a file */ class HeadersManager diff --git a/Library/MethodCall.php b/Library/MethodCall.php index 2046bc120..d840a8ffe 100644 --- a/Library/MethodCall.php +++ b/Library/MethodCall.php @@ -15,8 +15,6 @@ use Zephir\Exception\CompilerException; /** - * MethodCall. - * * Call methods in a non-static context */ class MethodCall extends Call diff --git a/Library/SymbolTable.php b/Library/SymbolTable.php index 7fe44386e..dbd29a72f 100644 --- a/Library/SymbolTable.php +++ b/Library/SymbolTable.php @@ -16,8 +16,6 @@ use Zephir\Variable\Globals; /** - * Zephir\SymbolTable. - * * A symbol table stores all the variables defined in a method, their data types and default values. */ class SymbolTable @@ -37,22 +35,12 @@ class SymbolTable */ protected $localContext; - /** - * @var CompilationContext - */ - protected $compilationContext; - /** * @var Globals */ protected $globalsManager; - /** - * SymbolTable. - * - * @param CompilationContext $compilationContext - */ - public function __construct(CompilationContext $compilationContext) + public function __construct(protected CompilationContext $compilationContext) { $this->globalsManager = new Globals(); @@ -85,7 +73,7 @@ public function resolveVariableToBranch($name, CompilationContext $compilationCo do { $currentId = $currentBranch->getUniqueId(); - if (isset($this->branchVariables[$currentId]) && isset($this->branchVariables[$currentId][$name])) { + if (isset($this->branchVariables[$currentId][$name])) { return $currentBranch; } $currentBranch = $currentBranch->getParentBranch(); @@ -222,7 +210,7 @@ public function getVariable($name, CompilationContext $compilationContext = null public function getVariables() { $ret = []; - foreach ($this->branchVariables as $branchId => $vars) { + foreach ($this->branchVariables as $vars) { foreach ($vars as $var) { $ret[$var->getName()] = $var; } @@ -231,15 +219,6 @@ public function getVariables() return $ret; } - public function getVariablesByBranch($branchId) - { - if (isset($this->branchVariables[$branchId])) { - return $this->branchVariables[$branchId]; - } - - return null; - } - /** * Return a variable in the symbol table, it will be used for a read operation. * diff --git a/Library/Variable.php b/Library/Variable.php index f0abe51c9..95ce6e1c3 100644 --- a/Library/Variable.php +++ b/Library/Variable.php @@ -40,13 +40,6 @@ class Variable implements TypeAwareInterface */ protected $name; - /** - * Branch where the variable was declared. - * - * @var Branch|null - */ - protected $branch; - /** * Branch where the variable was initialized for the first time. */ @@ -164,14 +157,7 @@ class Variable implements TypeAwareInterface 'object' => 1, ]; - /** - * Variable constructor. - * - * @param string $type - * @param string $name - * @param Branch $branch - */ - public function __construct(string $type, string $name, Branch $branch = null) + public function __construct(string $type, string $name, protected ?Branch $branch = null) { $this->globalsManager = new Globals(); @@ -181,7 +167,6 @@ public function __construct(string $type, string $name, Branch $branch = null) $this->type = $type; $this->name = $name; - $this->branch = $branch; } /**