From 8ad3733a0365af6002f0731d08d48d6d35f60347 Mon Sep 17 00:00:00 2001 From: Anton Vasiliev <1695147@gmail.com> Date: Fri, 6 Dec 2024 21:45:04 +0000 Subject: [PATCH] #2440 - Mass code cleanup --- src/Backend/Backend.php | 68 +------------------ src/Backend/FcallManager.php | 6 +- src/Backend/FcallManagerInterface.php | 6 -- src/Backend/VariablesManager.php | 6 -- src/Cache/SlotsCache.php | 4 -- src/Class/Definition/Definition.php | 59 +++++++--------- src/Class/Method/Method.php | 10 +-- src/Class/Method/Parameters.php | 3 - src/Class/Property.php | 7 +- src/Code/ArgInfoDefinition.php | 2 +- src/Code/Builder/Struct.php | 9 --- src/Code/Printer.php | 2 - src/CompilerFile.php | 61 ++++------------- src/Console/Application.php | 26 ------- src/Console/Command/AbstractCommand.php | 3 - .../Command/DevelopmentModeAwareTrait.php | 4 -- src/Console/Command/InitCommand.php | 7 -- src/Console/Command/ListCommand.php | 7 +- src/Documentation/DocblockParser.php | 2 +- src/Documentation/File/NamespaceFile.php | 15 ---- src/Documentation/File/Sitemap.php | 15 ---- src/Documentation/NamespaceAccessor.php | 21 ++---- src/FunctionDefinition.php | 2 + 23 files changed, 57 insertions(+), 288 deletions(-) diff --git a/src/Backend/Backend.php b/src/Backend/Backend.php index 07c5d459e..cdc71ecf4 100644 --- a/src/Backend/Backend.php +++ b/src/Backend/Backend.php @@ -13,7 +13,6 @@ namespace Zephir\Backend; -use Zephir\Class\Definition\Definition; use Zephir\Class\Method\Method; use Zephir\Code\Printer; use Zephir\CompilationContext; @@ -512,7 +511,7 @@ public function assignArrayMulti( ): void { [$keys, $offsetItems, $numberParams] = $this->resolveOffsetExprs($offsetExprs, $compilationContext); - $symbol = $this->resolveValue($symbolVariable, $compilationContext, true); + $symbol = $this->resolveValue($symbolVariable, $compilationContext); $varCode = $this->getVariableCode($variable); $compilationContext->codePrinter->output( sprintf( @@ -617,14 +616,6 @@ public function assignStaticPropertyArrayMulti( ); } - /** - * @param Variable $variable - * @param string|Variable|null $value - * @param CompilationContext $context - * @param bool $useCodePrinter - * - * @return string - */ public function assignString( Variable $variable, $value, @@ -642,10 +633,6 @@ public function assignString( /** * Assigns a zval to another. - * - * @param Variable $variable - * @param string $code - * @param CompilationContext $context */ public function assignZval(Variable $variable, $code, CompilationContext $context): void { @@ -998,15 +985,6 @@ public function fetchGlobal(Variable $globalVar, CompilationContext $compilation return $output; } - /** - * @param Variable $symbolVariable - * @param Variable $variableVariable - * @param Variable|string $property - * @param bool $readOnly - * @param CompilationContext $context - * - * @return void - */ public function fetchProperty( Variable $symbolVariable, Variable $variableVariable, @@ -1048,12 +1026,6 @@ public function fetchProperty( } /** - * @param Variable $symbolVariable - * @param Definition $classDefinition - * @param $property - * @param bool $readOnly - * @param CompilationContext $context - * * @throws Exception */ public function fetchStaticProperty( @@ -1376,12 +1348,6 @@ public function getInternalKernelPath(): string return $this->kernelsPath; } - /** - * @param Method $method - * @param CompilationContext $context - * - * @return string - */ public function getInternalSignature(Method $method, CompilationContext $context): string { if ($method->isInitializer() && !$method->isStatic()) { @@ -1426,12 +1392,6 @@ public function getInternalSignature(Method $method, CompilationContext $context return "void {$method->getInternalName()}({$signaturePattern})"; } - /** - * @param string $type - * @param CompilationContext $compilationContext - * - * @return Variable - */ public function getScalarTempVariable( string $type, CompilationContext $compilationContext, @@ -1553,12 +1513,6 @@ public function getTypeDefinition($type): array } /** - * @param Variable $variableVariable - * @param string $operator - * @param string $value - * - * @return string - * * @throws CompilerException */ public function getTypeofCondition( @@ -1763,7 +1717,7 @@ public function onPreInitVar(Method $method): string return ''; } - public function propertyIsset(Variable $var, $key) + public function propertyIsset(Variable $var, $key): CompiledExpression { return new CompiledExpression( 'bool', @@ -1773,11 +1727,6 @@ public function propertyIsset(Variable $var, $key) } /** - * @param $value - * @param CompilationContext $context - * - * @return bool|string|Variable - * * @throws CompilerException */ public function resolveValue($value, CompilationContext $context): Variable | bool | string @@ -1920,14 +1869,6 @@ public function updateArray( } } - /** - * @param Variable $variable - * @param string|Variable $property - * @param mixed $value - * @param CompilationContext $context - * - * @return void - */ public function updateProperty(Variable $variable, $property, $value, CompilationContext $context): void { $value = $this->resolveValue($value, $context); @@ -2040,11 +1981,6 @@ protected function returnHelper( /** * Resolve expressions. * - * @param CompiledExpression[]|string[] $offsetExprs - * @param CompilationContext $compilationContext - * - * @return array - * * @throws CompilerException */ private function resolveOffsetExprs(array $offsetExprs, CompilationContext $compilationContext): array diff --git a/src/Backend/FcallManager.php b/src/Backend/FcallManager.php index 8283db4b2..8166309f8 100644 --- a/src/Backend/FcallManager.php +++ b/src/Backend/FcallManager.php @@ -137,11 +137,7 @@ public function genFcallCode(): void } /** - * @param bool $static - * @param int $doReturn tri-state: 0 -> no return value, 1 -> do return, 2 -> do return to given variable - * @param int $paramCount - * - * @return string + * tri-state: 0 -> no return value, 1 -> do return, 2 -> do return to given variable */ public function getMacro(bool $static, int $doReturn, int $paramCount): string { diff --git a/src/Backend/FcallManagerInterface.php b/src/Backend/FcallManagerInterface.php index 8b7751461..9b6148020 100644 --- a/src/Backend/FcallManagerInterface.php +++ b/src/Backend/FcallManagerInterface.php @@ -19,12 +19,6 @@ public function genFcallCode(): void; /** * Resolve internal fcall attributes to a suitable macro and ensure that it's generated during compilation. - * - * @param bool $static - * @param int $doReturn tri-state: 0 -> no return value, 1 -> do return, 2 -> do return to given variable - * @param int $paramCount - * - * @return string */ public function getMacro(bool $static, int $doReturn, int $paramCount): string; } diff --git a/src/Backend/VariablesManager.php b/src/Backend/VariablesManager.php index 876fa2128..47d1b243b 100644 --- a/src/Backend/VariablesManager.php +++ b/src/Backend/VariablesManager.php @@ -39,12 +39,6 @@ class VariablesManager * Shouldn't called directly. * * TODO: Figure out why it never reached during generation. - * - * @param Variable $variable - * @param array $value - * @param Context $context - * - * @return void */ public function initializeDefaults(Variable $variable, array $value, Context $context): void { diff --git a/src/Cache/SlotsCache.php b/src/Cache/SlotsCache.php index 7e5374b5b..903f787c6 100644 --- a/src/Cache/SlotsCache.php +++ b/src/Cache/SlotsCache.php @@ -51,10 +51,6 @@ public static function getExistingMethodSlot(Method $method): int /** * Returns or creates a cache slot for a function. - * - * @param string $functionName - * - * @return int */ public static function getFunctionSlot(string $functionName): int { diff --git a/src/Class/Definition/Definition.php b/src/Class/Definition/Definition.php index fe63ae005..65655a83a 100644 --- a/src/Class/Definition/Definition.php +++ b/src/Class/Definition/Definition.php @@ -58,70 +58,62 @@ final class Definition extends AbstractDefinition * Contains "abstract" in the definition */ protected bool $abstract = false; - /** - * @var AliasManager|null - */ + protected ?AliasManager $aliasManager = null; - /** - * @var Compiler - */ + protected Compiler $compiler; /** * @var Constant[] */ protected array $constants = []; - /** - * @var int - */ + protected int $dependencyRank = 0; - /** - * @var string - */ + protected string $docBlock = ''; + /** * Name of inherited class */ protected ?string $extendsClass = null; + /** * Definition object of inherited class */ protected ?AbstractDefinition $extendsClassDefinition = null; + /** * When class is from external dependency */ protected bool $external = false; + /** * Contains "final" in the definition */ protected bool $final = false; - /** - * @var array - */ + protected array $implementedInterfaceDefinitions = []; + /** * List of implemented interfaces of current class */ protected array $interfaces = []; - /** - * @var bool - */ + protected bool $isBundled = false; + /** * @var Method[] */ protected array $methods = []; - /** - * @var array - */ + protected array $originalNode = []; - /** - * @var Docblock|null - */ + protected ?Docblock $parsedDocblock = null; + /** * @var Property[] */ protected array $properties = []; + /** * Class short name * @@ -130,14 +122,17 @@ final class Definition extends AbstractDefinition * @see Definition::name */ protected string $shortName; + /** * Definition type */ protected string $type = self::TYPE_CLASS; - public function __construct(protected string $namespace, string $name, ?string $shortName = null) - { - $this->name = $name; + public function __construct( + protected string $namespace, + protected string $name, + ?string $shortName = null, + ) { $this->shortName = $shortName ?: $name; } @@ -888,7 +883,7 @@ public function getExtendsClass(): ?string */ public function getExtendsClassDefinition(): ?AbstractDefinition { - if (!$this->extendsClassDefinition && $this->extendsClass && $this->compiler) { + if (!$this->extendsClassDefinition && $this->extendsClass) { $this->setExtendsClassDefinition($this->compiler->getClassDefinition($this->extendsClass)); } @@ -1060,10 +1055,6 @@ public function getProperties(): array /** * Returns a method definition by its name. - * - * @param string $propertyName - * - * @return Property|null */ public function getProperty(string $propertyName): ?Property { @@ -1139,10 +1130,6 @@ public function hasConstant(string $name): bool /** * Checks if the class implements a specific name. - * - * @param string $methodName - * - * @return bool */ public function hasMethod(string $methodName): bool { diff --git a/src/Class/Method/Method.php b/src/Class/Method/Method.php index e4faee774..77bce3ee4 100644 --- a/src/Class/Method/Method.php +++ b/src/Class/Method/Method.php @@ -58,11 +58,12 @@ class Method { public bool $optimizable = true; + /** * Call Gatherer Pass. */ protected ?CallGathererPass $callGathererPass = null; - protected ?Definition $classDefinition = null; + /** * Whether the method is abstract or not. */ @@ -130,9 +131,9 @@ class Method protected bool $void = false; public function __construct( - Definition $classDefinition, - protected array $visibility, - protected string $name, + protected ?Definition $classDefinition = null, + protected array $visibility = [], + protected string $name = '', protected ?Parameters $parameters = null, protected ?StatementsBlock $statements = null, protected ?string $docblock = null, @@ -140,7 +141,6 @@ public function __construct( protected ?array $expression = [], array $staticVariables = [], ) { - $this->classDefinition = $classDefinition; $this->staticVariables = $staticVariables; $this->checkVisibility($visibility, $name, $expression); diff --git a/src/Class/Method/Parameters.php b/src/Class/Method/Parameters.php index 1ce191374..06a124ff3 100644 --- a/src/Class/Method/Parameters.php +++ b/src/Class/Method/Parameters.php @@ -52,9 +52,6 @@ public function __construct(private array $parameters) } } - /** - * @return int - */ public function count(): int { return count($this->parameters); diff --git a/src/Class/Property.php b/src/Class/Property.php index f205195b4..1b545e859 100644 --- a/src/Class/Property.php +++ b/src/Class/Property.php @@ -239,17 +239,12 @@ public function isStatic(): bool /** * Declare class property with default value. * - * @param CompilationContext $compilationContext - * @param string $type - * @param $value - * * @throws Exception * @throws CompilerException */ - protected function declareProperty(CompilationContext $compilationContext, $type, $value): void + protected function declareProperty(CompilationContext $compilationContext, string $type, $value): void { $codePrinter = $compilationContext->codePrinter; - if (is_object($value)) { return; } diff --git a/src/Code/ArgInfoDefinition.php b/src/Code/ArgInfoDefinition.php index 9c6c9ebc4..fa0649925 100644 --- a/src/Code/ArgInfoDefinition.php +++ b/src/Code/ArgInfoDefinition.php @@ -197,7 +197,7 @@ private function renderEnd(): void $flag = $this->richFormat ? '1' : '0'; foreach ($this->parameters->getParameters() as $parameter) { - switch ("{$flag}:" . $parameter['data-type']) { + switch ("$flag:" . $parameter['data-type']) { case '0:array': case '1:array': if (!isset($parameter['default'])) { diff --git a/src/Code/Builder/Struct.php b/src/Code/Builder/Struct.php index 7128eb4e5..0d8a52938 100644 --- a/src/Code/Builder/Struct.php +++ b/src/Code/Builder/Struct.php @@ -57,9 +57,6 @@ public function __toString(): string } /** - * @param string $field - * @param string $type - * * @throws InvalidArgumentException */ public function addProperty(string $field, string $type): void @@ -74,12 +71,6 @@ public function addProperty(string $field, string $type): void /** * Returns the C code that initializes the extension global. * - * @param string $name - * @param array $global - * @param string $namespace - * - * @return string - * * @throws RuntimeException * @throws InvalidArgumentException */ diff --git a/src/Code/Printer.php b/src/Code/Printer.php index becefca80..6562b0bb8 100644 --- a/src/Code/Printer.php +++ b/src/Code/Printer.php @@ -135,8 +135,6 @@ public function outputNoIndent(string $code): void /** * Add code to the output at the beginning. - * - * @param string $code */ public function preOutput(string $code): void { diff --git a/src/CompilerFile.php b/src/CompilerFile.php index 5f7a48ee7..56af953f2 100644 --- a/src/CompilerFile.php +++ b/src/CompilerFile.php @@ -263,10 +263,8 @@ public function checkDependencies(Compiler $compiler): void /** * Compiles the file. * - * @param Compiler $compiler - * @param StringsManager $stringsManager - * - * @throws CompilerException + * @throws Exception + * @throws ReflectionException */ public function compile(Compiler $compiler, StringsManager $stringsManager): void { @@ -310,8 +308,7 @@ public function compile(Compiler $compiler, StringsManager $stringsManager): voi /** * Headers manager. */ - $headersManager = new HeadersManager(); - $compilationContext->headersManager = $headersManager; + $compilationContext->headersManager = new HeadersManager(); /** * Main code-printer for the file. @@ -432,14 +429,12 @@ public function compileComment(CompilationContext $compilationContext, $topState /** * Compiles a function. * - * @param CompilationContext $compilationContext - * @param FunctionDefinition $functionDefinition - * * @throws Exception + * @throws ReflectionException */ public function compileFunction( CompilationContext $compilationContext, - FunctionDefinition $functionDefinition + FunctionDefinition $functionDefinition, ): void { /** Make sure we do not produce calls like ZEPHIR_CALL_SELF */ $bakClassDefinition = $compilationContext->classDefinition; @@ -491,12 +486,7 @@ public function genIR(Compiler $compiler): array return $ir; } - /** - * {@inheritdoc} - * - * @return Definition - */ - public function getClassDefinition() + public function getClassDefinition(): ?Definition { $this->classDefinition->setAliasManager($this->aliasManager); @@ -505,8 +495,6 @@ public function getClassDefinition() /** * Returns the path to the compiled file. - * - * @return string */ public function getCompiledFile(): string { @@ -515,17 +503,12 @@ public function getCompiledFile(): string /** * Returns the path to the source file. - * - * @return string */ public function getFilePath(): string { return $this->filePath; } - /** - * @return bool - */ public function isExternal(): bool { return $this->external; @@ -724,14 +707,13 @@ public function preCompile(Compiler $compiler): void /** * Creates a definition for a class. - * - * @param CompilationContext $compilationContext - * @param string $namespace - * @param array $topStatement - * @param array $docblock */ - public function preCompileClass(CompilationContext $compilationContext, $namespace, $topStatement, $docblock): void - { + public function preCompileClass( + CompilationContext $compilationContext, + string $namespace, + array $topStatement, + ?array $docblock = null, + ): void { $classDefinition = new Definition($namespace, $topStatement['name']); $classDefinition->setIsExternal($this->external); @@ -838,12 +820,8 @@ public function preCompileClass(CompilationContext $compilationContext, $namespa /** * Creates a definition for an interface. - * - * @param string $namespace - * @param array $topStatement - * @param array $docblock */ - public function preCompileInterface($namespace, $topStatement, $docblock): void + public function preCompileInterface(string $namespace, array $topStatement, ?array $docblock = null): void { $classDefinition = new Definition($namespace, $topStatement['name']); $classDefinition->setIsExternal($this->external); @@ -857,7 +835,7 @@ public function preCompileInterface($namespace, $topStatement, $docblock): void $classDefinition->setType(Definition::TYPE_INTERFACE); - if (is_array($docblock)) { + if ($docblock !== null) { $classDefinition->setDocBlock($docblock['value']); } @@ -901,17 +879,11 @@ public function preCompileInterface($namespace, $topStatement, $docblock): void $this->classDefinition = $classDefinition; } - /** - * @param string $className - */ public function setClassName(string $className): void { $this->className = $className; } - /** - * @param string $filePath - */ public function setFilePath(string $filePath): void { $this->filePath = $filePath; @@ -919,8 +891,6 @@ public function setFilePath(string $filePath): void /** * Sets if the class belongs to an external dependency or not. - * - * @param bool $external */ public function setIsExternal($external): void { @@ -964,9 +934,6 @@ protected function getFullName(string $name): string /** * Creates the property shortcuts. * - * @param array $property - * @param Definition $classDefinition - * * @throws CompilerException */ protected function processShortcuts(array $property, Definition $classDefinition): void diff --git a/src/Console/Application.php b/src/Console/Application.php index f33529b24..1b3ed24ff 100644 --- a/src/Console/Application.php +++ b/src/Console/Application.php @@ -50,18 +50,10 @@ public function __construct() $dispatcher = new EventDispatcher(); $dispatcher->addListener(ConsoleEvents::ERROR, [new ErrorListener(), 'onCommandError']); - $this->setDispatcher($dispatcher); } /** - * {@inheritdoc} - * - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int - * * @throws Exception|Throwable */ public function doRun(InputInterface $input, OutputInterface $output): int @@ -109,21 +101,11 @@ public function doRun(InputInterface $input, OutputInterface $output): int } } - /** - * {@inheritdoc} - * - * @return string - */ public function getHelp(): string { return Zephir::LOGO . parent::getHelp(); } - /** - * {@inheritdoc} - * - * @return string The long application version - */ public function getLongVersion(): string { $version = explode('-', $this->getVersion()); @@ -142,8 +124,6 @@ public function getLongVersion(): string /** * Get Version Number - * - * @return string The application version */ public function getVerNum(): string { @@ -155,8 +135,6 @@ public function getVerNum(): string /** * Gets the application version as integer. - * - * @return string The application version */ public function getVersion(): string { @@ -170,8 +148,6 @@ public function getVersion(): string } /** - * {@inheritdoc} - * * @return Command[] An array of default Command instances */ protected function getDefaultCommands(): array @@ -180,8 +156,6 @@ protected function getDefaultCommands(): array } /** - * {@inheritdoc} - * * @return InputDefinition An InputDefinition instance */ protected function getDefaultInputDefinition(): InputDefinition diff --git a/src/Console/Command/AbstractCommand.php b/src/Console/Command/AbstractCommand.php index 25b8afcda..9ac5e57f1 100644 --- a/src/Console/Command/AbstractCommand.php +++ b/src/Console/Command/AbstractCommand.php @@ -19,9 +19,6 @@ abstract class AbstractCommand extends Command { use RemoveOptionsTrait; - /** - * @param bool $mergeArgs - */ public function mergeApplicationDefinition(bool $mergeArgs = true): void { parent::mergeApplicationDefinition($mergeArgs); diff --git a/src/Console/Command/DevelopmentModeAwareTrait.php b/src/Console/Command/DevelopmentModeAwareTrait.php index c9054ac07..c447bff93 100644 --- a/src/Console/Command/DevelopmentModeAwareTrait.php +++ b/src/Console/Command/DevelopmentModeAwareTrait.php @@ -21,10 +21,6 @@ trait DevelopmentModeAwareTrait { /** * Checks if the development mode is enabled. - * - * @param InputInterface $input - * - * @return bool */ protected function isDevelopmentModeEnabled(InputInterface $input): bool { diff --git a/src/Console/Command/InitCommand.php b/src/Console/Command/InitCommand.php index 503136b8d..11ccfa6f8 100644 --- a/src/Console/Command/InitCommand.php +++ b/src/Console/Command/InitCommand.php @@ -111,13 +111,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int /** * Copies the base kernel to the extension destination. - * - * @param string $src - * @param string $dst - * @param string|null $pattern - * @param string $callback - * - * @return void */ private function recursiveProcess(string $src, string $dst, ?string $pattern = null, string $callback = 'copy'): void { diff --git a/src/Console/Command/ListCommand.php b/src/Console/Command/ListCommand.php index 4e43e5fc3..a764fc963 100644 --- a/src/Console/Command/ListCommand.php +++ b/src/Console/Command/ListCommand.php @@ -24,12 +24,7 @@ final class ListCommand extends Command { use RemoveOptionsTrait; - /** - * {@inheritdoc} - * - * @param bool $mergeArgs - */ - public function mergeApplicationDefinition($mergeArgs = true): void + public function mergeApplicationDefinition(bool $mergeArgs = true): void { parent::mergeApplicationDefinition($mergeArgs); diff --git a/src/Documentation/DocblockParser.php b/src/Documentation/DocblockParser.php index b2a27a528..c294d1cae 100644 --- a/src/Documentation/DocblockParser.php +++ b/src/Documentation/DocblockParser.php @@ -184,7 +184,7 @@ public function parse() * * @return Annotation */ - private function __createAnnotation($name, $string) + private function __createAnnotation(string $name, string $string) { switch ($name) { case 'link': diff --git a/src/Documentation/File/NamespaceFile.php b/src/Documentation/File/NamespaceFile.php index c5fba5bfc..d6c872d02 100644 --- a/src/Documentation/File/NamespaceFile.php +++ b/src/Documentation/File/NamespaceFile.php @@ -23,11 +23,6 @@ public function __construct(protected NamespaceHelper $namespaceHelper) { } - /** - * {@inheritdoc} - * - * @return array - */ public function getData(): array { return [ @@ -37,21 +32,11 @@ public function getData(): array ]; } - /** - * {@inheritdoc} - * - * @return string - */ public function getOutputFile(): string { return Documentation::namespaceUrl($this->namespaceHelper->getFullNamespace()); } - /** - * {@inheritdoc} - * - * @return string - */ public function getTemplateName(): string { return 'namespace.phtml'; diff --git a/src/Documentation/File/Sitemap.php b/src/Documentation/File/Sitemap.php index 60ceb086a..14e25b6fe 100644 --- a/src/Documentation/File/Sitemap.php +++ b/src/Documentation/File/Sitemap.php @@ -34,11 +34,6 @@ public function __construct($baseDir, $baseUrl, $classList, $namespaceList) $this->baseDir = $baseDir; } - /** - * {@inheritdoc} - * - * @return array - */ public function getData(): array { return [ @@ -48,21 +43,11 @@ public function getData(): array ]; } - /** - * {@inheritdoc} - * - * @return string - */ public function getOutputFile(): string { return 'sitemap.xml'; } - /** - * {@inheritdoc} - * - * @return string - */ public function getTemplateName(): string { return $this->baseDir . '/Api/sitemap.php'; diff --git a/src/Documentation/NamespaceAccessor.php b/src/Documentation/NamespaceAccessor.php index ddd0cd39e..dba8a424b 100644 --- a/src/Documentation/NamespaceAccessor.php +++ b/src/Documentation/NamespaceAccessor.php @@ -13,25 +13,16 @@ namespace Zephir\Documentation; -use Zephir\CompilerFile; - use function explode; class NamespaceAccessor { - protected $byNamespace; - /** - * @var CompilerFile[] - */ - protected $classes; - protected $namespaceTree; + protected array $byNamespace = []; - /** - * @param CompilerFile[] $files - */ - public function __construct($files) + protected array $namespaceTree = []; + + public function __construct(protected array $classes) { - $this->classes = $files; } public function build(): void @@ -80,12 +71,12 @@ public function build(): void /** * @return NamespaceHelper[] */ - public function getByNamespace() + public function getByNamespace(): array { return $this->byNamespace; } - public function getNamespaceTree() + public function getNamespaceTree(): array { return $this->namespaceTree; } diff --git a/src/FunctionDefinition.php b/src/FunctionDefinition.php index 2dfaef610..b3a373d25 100644 --- a/src/FunctionDefinition.php +++ b/src/FunctionDefinition.php @@ -34,6 +34,8 @@ public function __construct( ?array $returnType = null, protected ?array $expression = [], ) { + parent::__construct(null, [], $name, $parameters, $statements); + $this->setReturnTypes($returnType); }