diff --git a/Library/AliasManager.php b/Library/AliasManager.php index 2cbf27c343..f500aa7886 100644 --- a/Library/AliasManager.php +++ b/Library/AliasManager.php @@ -1,5 +1,7 @@ implicitAlias($alias['name']); @@ -115,10 +117,10 @@ public function isAliasPresentFor(string $className): bool { $extractAlias = $this->implicitAlias($className); - $isClassDeclarated = \in_array($className, $this->aliases); + $isClassDeclared = \in_array($className, $this->aliases); $classAlias = array_flip($this->aliases)[$className] ?? null; - return $isClassDeclarated && $classAlias !== $extractAlias; + return $isClassDeclared && $classAlias !== $extractAlias; } /** diff --git a/Library/ArgInfoDefinition.php b/Library/ArgInfoDefinition.php index 9eda6c693f..81796cc5ff 100644 --- a/Library/ArgInfoDefinition.php +++ b/Library/ArgInfoDefinition.php @@ -1,5 +1,7 @@ returnByRef = $returnByRef; } - public function setBooleanDefinition($definition) + public function setBooleanDefinition(string $definition): void { - $this->booleanDefinition = (string) $definition; + $this->booleanDefinition = $definition; } - public function setRichFormat($flag) + public function setRichFormat(bool $flag): void { - $this->richFormat = (bool) $flag; + $this->richFormat = $flag; } /** @@ -88,7 +99,7 @@ public function setRichFormat($flag) * * @throws Exception */ - public function render() + public function render(): void { if ($this->richFormat && $this->functionLike->isReturnTypesHintDetermined() && @@ -152,7 +163,7 @@ public function render() } } - private function richRenderStart() + private function richRenderStart(): void { if (\array_key_exists('object', $this->functionLike->getReturnTypes())) { $class = 'NULL'; @@ -209,7 +220,7 @@ private function richRenderStart() ); } - private function renderEnd() + private function renderEnd(): void { $flag = $this->richFormat ? '1' : '0'; @@ -317,12 +328,12 @@ private function renderEnd() } } - private function hasParameters() + private function hasParameters(): bool { return null !== $this->parameters && \count($this->parameters->getParameters()) > 0; } - private function allowNull($parameter) + private function allowNull(array $parameter): bool { if (!isset($parameter['default']) || !\is_array($parameter['default'])) { return false; @@ -335,12 +346,12 @@ private function allowNull($parameter) return false; } - private function passByReference($parameter) + private function passByReference(array $parameter) { return isset($parameter['reference']) ? $parameter['reference'] : 0; } - private function getReturnType() + private function getReturnType(): string { if ($this->functionLike->areReturnTypesIntCompatible()) { return 'IS_LONG'; diff --git a/Library/ClassDefinition.php b/Library/ClassDefinition.php index 4a3284671b..210a791bfe 100644 --- a/Library/ClassDefinition.php +++ b/Library/ClassDefinition.php @@ -1338,7 +1338,7 @@ public function compile(CompilationContext $compilationContext) $method->isReturnTypesHintDetermined() && $method->areReturnTypesCompatible(); - if ($richFormat || $method->hasParameters() || version_compare(PHP_VERSION, '8.0.0', '>=')) { + if ($richFormat || $method->hasParameters()) { $codePrinter->output( sprintf( // TODO: Rename to ZEND_ME @@ -1351,9 +1351,22 @@ public function compile(CompilationContext $compilationContext) ) ); } else { + $codePrinter->output('#if PHP_VERSION_ID >= 80000'); $codePrinter->output( sprintf( - // TODO: Rename to ZEND_ME + // TODO: Rename to ZEND_ME + "\tPHP_ME(%s_%s, %s, %s, %s)", + $this->getCNamespace(), + $this->getName(), + $method->getName(), + $method->getArgInfoName($this), + $method->getModifiers() + ) + ); + $codePrinter->output('#else'); + $codePrinter->output( + sprintf( + // TODO: Rename to ZEND_ME "\tPHP_ME(%s_%s, %s, NULL, %s)", $this->getCNamespace(), $this->getName(), @@ -1361,6 +1374,7 @@ public function compile(CompilationContext $compilationContext) $method->getModifiers() ) ); + $codePrinter->output('#endif'); } } } else { diff --git a/Library/ClassMethod.php b/Library/ClassMethod.php index 8d3b651c76..84f30610c4 100644 --- a/Library/ClassMethod.php +++ b/Library/ClassMethod.php @@ -2456,7 +2456,7 @@ public function isReturnTypesHintDetermined() * * @return bool */ - public function areReturnTypesCompatible() + public function areReturnTypesCompatible(): bool { // void if ($this->isVoid()) { diff --git a/Library/Optimizers/FunctionCall/FunctionExistsOptimizer.php b/Library/Optimizers/FunctionCall/FunctionExistsOptimizer.php index c4f6ffedaa..ace5a2b80e 100644 --- a/Library/Optimizers/FunctionCall/FunctionExistsOptimizer.php +++ b/Library/Optimizers/FunctionCall/FunctionExistsOptimizer.php @@ -11,12 +11,14 @@ namespace Zephir\Optimizers\FunctionCall; -use function Zephir\add_slashes; use Zephir\Call; use Zephir\CompilationContext; use Zephir\CompiledExpression; use Zephir\Optimizers\OptimizerAbstract; +use function count; +use function Zephir\add_slashes; + /** * FunctionExistsOptimizer. * @@ -33,11 +35,11 @@ class FunctionExistsOptimizer extends OptimizerAbstract */ public function optimize(array $expression, Call $call, CompilationContext $context) { - if (!isset($expression['parameters']) || 1 != \count($expression['parameters'])) { + if (!isset($expression['parameters']) || 1 !== count($expression['parameters'])) { return false; } - if ('string' == $expression['parameters'][0]['parameter']['type']) { + if ('string' === $expression['parameters'][0]['parameter']['type']) { $str = add_slashes($expression['parameters'][0]['parameter']['value']); unset($expression['parameters'][0]); } @@ -55,7 +57,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont return new CompiledExpression( 'bool', - '(zephir_function_exists('.$resolvedParams[0].') == SUCCESS)', + '(zephir_function_exists('.$resolvedParams[0].') == SUCCESS)', $expression ); } diff --git a/Library/Types.php b/Library/Types.php index f46dd9d37c..e699e0b27a 100644 --- a/Library/Types.php +++ b/Library/Types.php @@ -119,12 +119,12 @@ public function getReturnTypeAnnotation(ClassMethod $method, array $returnTypes return static::T_MIXED.$nullableType; } - if ($isTypeHinted && !$isBasicTypes && !$isDynamic) { + if ($isTypeHinted && !$isBasicTypes && !$isDynamic && !$isNullable) { return implode('|', array_keys($returnTypes)); } if ($isTypeHinted && $isProcessedReturnType) { - $withoutNullable = array_filter(array_values($returnTypes), static function ($ret) { + $withoutNullable = array_filter(array_keys($returnTypes), static function ($ret) { if ($ret !== static::T_NULL) { return $ret; } @@ -347,13 +347,12 @@ private function isNullable(array $types): bool * * @param array $types - Return types from parser * @param array $allowedTypes - Allowed return types - * + * @param bool $isNullable * @return bool */ private function areReturnTypesCompatible(array $types, array $allowedTypes, bool $isNullable = false): bool { $result = null; - $areEquals = false; if ($isNullable) { $allowedTypes[] = static::T_NULL; diff --git a/composer.lock b/composer.lock index 0d527b1e2d..155fd42602 100755 --- a/composer.lock +++ b/composer.lock @@ -224,24 +224,26 @@ }, { "name": "laminas/laminas-zendframework-bridge", - "version": "1.1.1", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-zendframework-bridge.git", - "reference": "6ede70583e101030bcace4dcddd648f760ddf642" + "reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6ede70583e101030bcace4dcddd648f760ddf642", - "reference": "6ede70583e101030bcace4dcddd648f760ddf642", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/6cccbddfcfc742eb02158d6137ca5687d92cee32", + "reference": "6cccbddfcfc742eb02158d6137ca5687d92cee32", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0 || ^8.0" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3", - "squizlabs/php_codesniffer": "^3.5" + "psalm/plugin-phpunit": "^0.15.1", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.6" }, "type": "library", "extra": { @@ -280,7 +282,7 @@ "type": "community_bridge" } ], - "time": "2020-09-14T14:23:00+00:00" + "time": "2021-02-25T21:54:58+00:00" }, { "name": "league/flysystem", @@ -770,27 +772,22 @@ }, { "name": "psr/container", - "version": "1.0.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.2.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -803,7 +800,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common Container Interface (PHP FIG PSR-11)", @@ -817,9 +814,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container/tree/1.1.1" }, - "time": "2017-02-14T16:28:37+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "psr/log", @@ -1234,16 +1231,16 @@ }, { "name": "symfony/debug", - "version": "v4.4.19", + "version": "v4.4.20", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "af4987aa4a5630e9615be9d9c3ed1b0f24ca449c" + "reference": "157bbec4fd773bae53c5483c50951a5530a2cc16" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/af4987aa4a5630e9615be9d9c3ed1b0f24ca449c", - "reference": "af4987aa4a5630e9615be9d9c3ed1b0f24ca449c", + "url": "https://api.github.com/repos/symfony/debug/zipball/157bbec4fd773bae53c5483c50951a5530a2cc16", + "reference": "157bbec4fd773bae53c5483c50951a5530a2cc16", "shasum": "" }, "require": { @@ -1283,7 +1280,7 @@ "description": "Provides tools to ease debugging PHP code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/debug/tree/v4.4.19" + "source": "https://github.com/symfony/debug/tree/v4.4.20" }, "funding": [ { @@ -1299,7 +1296,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" + "time": "2021-01-28T16:54:48+00:00" }, { "name": "symfony/dependency-injection", @@ -1779,16 +1776,16 @@ }, { "name": "symfony/http-foundation", - "version": "v4.4.19", + "version": "v4.4.20", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "8888741b633f6c3d1e572b7735ad2cae3e03f9c5" + "reference": "02d968647fe61b2f419a8dc70c468a9d30a48d3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8888741b633f6c3d1e572b7735ad2cae3e03f9c5", - "reference": "8888741b633f6c3d1e572b7735ad2cae3e03f9c5", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/02d968647fe61b2f419a8dc70c468a9d30a48d3a", + "reference": "02d968647fe61b2f419a8dc70c468a9d30a48d3a", "shasum": "" }, "require": { @@ -1827,7 +1824,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v4.4.19" + "source": "https://github.com/symfony/http-foundation/tree/v4.4.20" }, "funding": [ { @@ -1843,7 +1840,7 @@ "type": "tidelift" } ], - "time": "2021-01-27T09:09:26+00:00" + "time": "2021-02-25T17:11:33+00:00" }, { "name": "symfony/http-kernel", @@ -1949,16 +1946,16 @@ }, { "name": "symfony/mime", - "version": "v5.2.2", + "version": "v5.2.4", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "37bade585ea100d235c031b258eff93b5b6bb9a9" + "reference": "5155d2fe14ef1eb150e3bdbbc1ec1455df95e9cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/37bade585ea100d235c031b258eff93b5b6bb9a9", - "reference": "37bade585ea100d235c031b258eff93b5b6bb9a9", + "url": "https://api.github.com/repos/symfony/mime/zipball/5155d2fe14ef1eb150e3bdbbc1ec1455df95e9cd", + "reference": "5155d2fe14ef1eb150e3bdbbc1ec1455df95e9cd", "shasum": "" }, "require": { @@ -2011,7 +2008,7 @@ "mime-type" ], "support": { - "source": "https://github.com/symfony/mime/tree/v5.2.2" + "source": "https://github.com/symfony/mime/tree/v5.2.4" }, "funding": [ { @@ -2027,7 +2024,7 @@ "type": "tidelift" } ], - "time": "2021-01-25T14:08:25+00:00" + "time": "2021-02-15T18:55:04+00:00" }, { "name": "symfony/monolog-bridge", @@ -2177,16 +2174,16 @@ }, { "name": "symfony/polyfill-apcu", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-apcu.git", - "reference": "3b3944f40987b9d3f9b9147f86c32df87d9f3505" + "reference": "bc9974e74f8c05f4ceb500b1e0603e36be7d8223" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/3b3944f40987b9d3f9b9147f86c32df87d9f3505", - "reference": "3b3944f40987b9d3f9b9147f86c32df87d9f3505", + "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/bc9974e74f8c05f4ceb500b1e0603e36be7d8223", + "reference": "bc9974e74f8c05f4ceb500b1e0603e36be7d8223", "shasum": "" }, "require": { @@ -2234,7 +2231,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-apcu/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-apcu/tree/v1.22.1" }, "funding": [ { @@ -2250,11 +2247,11 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -2313,7 +2310,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1" }, "funding": [ { @@ -2333,16 +2330,16 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44" + "reference": "2d63434d922daf7da8dd863e7907e67ee3031483" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44", - "reference": "0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/2d63434d922daf7da8dd863e7907e67ee3031483", + "reference": "2d63434d922daf7da8dd863e7907e67ee3031483", "shasum": "" }, "require": { @@ -2400,7 +2397,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.22.1" }, "funding": [ { @@ -2416,20 +2413,20 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "6e971c891537eb617a00bb07a43d182a6915faba" + "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/6e971c891537eb617a00bb07a43d182a6915faba", - "reference": "6e971c891537eb617a00bb07a43d182a6915faba", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/43a0283138253ed1d48d352ab6d0bdb3f809f248", + "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248", "shasum": "" }, "require": { @@ -2484,7 +2481,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.22.1" }, "funding": [ { @@ -2500,20 +2497,20 @@ "type": "tidelift" } ], - "time": "2021-01-07T17:09:11+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13" + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/5232de97ee3b75b0360528dae24e73db49566ab1", + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1", "shasum": "" }, "require": { @@ -2564,7 +2561,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.22.1" }, "funding": [ { @@ -2580,7 +2577,7 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-php56", @@ -2652,7 +2649,7 @@ }, { "name": "symfony/polyfill-php72", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", @@ -2708,7 +2705,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.22.1" }, "funding": [ { @@ -2728,7 +2725,7 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", @@ -2791,7 +2788,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.22.1" }, "funding": [ { @@ -3341,16 +3338,16 @@ }, { "name": "phar-io/version", - "version": "3.0.4", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "e4782611070e50613683d2b9a57730e9a3ba5451" + "reference": "bae7c545bef187884426f042434e561ab1ddb182" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451", - "reference": "e4782611070e50613683d2b9a57730e9a3ba5451", + "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", + "reference": "bae7c545bef187884426f042434e561ab1ddb182", "shasum": "" }, "require": { @@ -3386,9 +3383,9 @@ "description": "Library for handling version information and constraints", "support": { "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.0.4" + "source": "https://github.com/phar-io/version/tree/3.1.0" }, - "time": "2020-12-13T23:18:30+00:00" + "time": "2021-02-23T14:00:09+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -3935,16 +3932,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.1", + "version": "9.5.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360" + "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7bdf4085de85a825f4424eae52c99a1cec2f360", - "reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f661659747f2f87f9e72095bb207bceb0f151cb4", + "reference": "f661659747f2f87f9e72095bb207bceb0f151cb4", "shasum": "" }, "require": { @@ -4022,7 +4019,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.1" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.2" }, "funding": [ { @@ -4034,7 +4031,7 @@ "type": "github" } ], - "time": "2021-01-17T07:42:25+00:00" + "time": "2021-02-02T14:45:58+00:00" }, { "name": "sebastian/cli-parser", diff --git a/kernels/ZendEngine3/fcall.h b/kernels/ZendEngine3/fcall.h index 3a238bf6b5..d5cde64421 100755 --- a/kernels/ZendEngine3/fcall.h +++ b/kernels/ZendEngine3/fcall.h @@ -69,9 +69,6 @@ typedef enum _zephir_call_type { } \ else { ZEPHIR_SET_THIS_EXPLICIT_NULL(); } \ - -#if PHP_VERSION_ID >= 70100 - #define ZEPHIR_BACKUP_SCOPE() \ zend_class_entry *old_scope = EG(fake_scope); \ zend_execute_data *old_call = execute_data; \ @@ -97,36 +94,6 @@ typedef enum _zephir_call_type { EG(fake_scope) = _scope; \ zephir_set_called_scope(EG(current_execute_data), _scope_called); \ -#else - -#define ZEPHIR_BACKUP_SCOPE() \ - zend_class_entry *old_scope = EG(scope); \ - zend_execute_data *old_call = execute_data; \ - zend_execute_data *old_execute_data = EG(current_execute_data), new_execute_data; \ - if (!EG(current_execute_data)) { \ - memset(&new_execute_data, 0, sizeof(zend_execute_data)); \ - execute_data = EG(current_execute_data) = &new_execute_data; \ - } else { \ - new_execute_data = *EG(current_execute_data); \ - new_execute_data.prev_execute_data = EG(current_execute_data); \ - new_execute_data.call = NULL; \ - new_execute_data.opline = NULL; \ - new_execute_data.func = NULL; \ - execute_data = EG(current_execute_data) = &new_execute_data; \ - } -// TODO(serghei): Deprecated -#define ZEPHIR_RESTORE_SCOPE() \ - EG(scope) = old_scope; \ - execute_data = old_call; \ - EG(current_execute_data) = old_execute_data; - -// TODO(serghei): Deprecated -#define ZEPHIR_SET_SCOPE(_scope, _scope_called) \ - EG(scope) = _scope; \ - EG(current_execute_data)->called_scope = _scope_called; - -#endif - /* End internal calls */ #define ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(func_name, cache, cache_slot, ...) \ diff --git a/kernels/ZendEngine3/main.c b/kernels/ZendEngine3/main.c index 0472cde55b..8014a65145 100755 --- a/kernels/ZendEngine3/main.c +++ b/kernels/ZendEngine3/main.c @@ -238,7 +238,6 @@ int zephir_fast_count_int(zval *value) } if (Z_TYPE_P(value) == IS_OBJECT) { - zval retval; if (Z_OBJ_HT_P(value)->count_elements) { @@ -275,20 +274,6 @@ int zephir_fast_count_int(zval *value) return 1; } -/** - * Check if a function exists using explicit function length - * - * TODO: Deprecated. Will be removed in future - */ -int zephir_function_quick_exists_ex(const char *function_name, size_t function_len) -{ - if (zend_hash_str_exists(CG(function_table), function_name, function_len)) { - return SUCCESS; - } - - return FAILURE; -} - /** * Check if a function exists * @@ -297,7 +282,7 @@ int zephir_function_quick_exists_ex(const char *function_name, size_t function_l */ int zephir_function_exists(const zval *function_name) { - if (zend_hash_str_exists(CG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name))) { + if (zend_hash_str_exists(CG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)) != NULL) { return SUCCESS; } @@ -307,13 +292,17 @@ int zephir_function_exists(const zval *function_name) /** * Check if a function exists using explicit function length * - * TODO: Deprecated. Will be removed in future + * TODO: Check if make sense to merge all logic of IS_STRING inside zephir_function_exists() function. * @param function_name * @param function_len strlen(function_name) + 1 */ int zephir_function_exists_ex(const char *function_name, unsigned int function_len) { - return zephir_function_quick_exists_ex(function_name, function_len); + if (zend_hash_str_exists(CG(function_table), function_name, function_len) != NULL) { + return SUCCESS; + } + + return FAILURE; } /** @@ -433,7 +422,7 @@ int zephir_declare_class_constant(zend_class_entry *ce, const char *name, size_t } return SUCCESS; -#elif PHP_VERSION_ID >= 70200 +#else int ret; zend_string *key; @@ -450,20 +439,6 @@ int zephir_declare_class_constant(zend_class_entry *ce, const char *name, size_t } return ret; -#elif PHP_VERSION_ID >= 70100 - int ret; - - zend_string *key = zend_string_init(name, name_length, ce->type & ZEND_INTERNAL_CLASS); - ret = zend_declare_class_constant_ex(ce, key, value, ZEND_ACC_PUBLIC, NULL); - zend_string_release(key); - return ret; -#else - if (Z_CONSTANT_P(value)) { - ce->ce_flags &= ~ZEND_ACC_CONSTANTS_UPDATED; - } - ZVAL_NEW_PERSISTENT_REF(value, value); - return zend_hash_str_update(&ce->constants_table, name, name_length, value) ? - SUCCESS : FAILURE; #endif } @@ -538,8 +513,7 @@ int zephir_is_php_version(unsigned int id) return ((php_major + php_minor + php_release) == id ? 1 : 0); } -void -zephir_get_args(zval *return_value) +void zephir_get_args(zval *return_value) { zend_execute_data *ex = EG(current_execute_data); uint32_t arg_count = ZEND_CALL_NUM_ARGS(ex); @@ -582,8 +556,7 @@ zephir_get_args(zval *return_value) } } -void -zephir_get_arg(zval *return_value, zend_long idx) +void zephir_get_arg(zval *return_value, zend_long idx) { zend_execute_data *ex = EG(current_execute_data); uint32_t arg_count; @@ -595,11 +568,9 @@ zephir_get_arg(zval *return_value, zend_long idx) } arg_count = ZEND_CALL_NUM_ARGS(ex); -#if PHP_VERSION_ID >= 70100 - if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) { - RETURN_FALSE; - } -#endif + if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) { + RETURN_FALSE; + } if (UNEXPECTED((zend_ulong)idx >= arg_count)) { zend_error(E_WARNING, "func_get_arg(): Argument " ZEND_LONG_FMT " not passed to function", idx); diff --git a/kernels/ZendEngine3/math.c b/kernels/ZendEngine3/math.c index 8f137a1dca..437a2596c7 100755 --- a/kernels/ZendEngine3/math.c +++ b/kernels/ZendEngine3/math.c @@ -181,11 +181,8 @@ void zephir_round(zval *return_value, zval *op1, zval *op2, zval *op3) } } -zend_long -zephir_mt_rand(zend_long min, zend_long max) +zend_long zephir_mt_rand(zend_long min, zend_long max) { - zend_long number; - if (max < min) { php_error_docref(NULL, E_WARNING, "max(" ZEND_LONG_FMT ") is smaller than min(" ZEND_LONG_FMT ")", max, min); return 0; @@ -195,20 +192,7 @@ zephir_mt_rand(zend_long min, zend_long max) php_mt_srand(GENERATE_SEED()); } - number = (zend_long) (php_mt_rand() >> 1); - - /** - * The RAND_RANGE() macro has been removed since PHP 7.3. - * php_mt_rand_range() should be used instead. - * However, php_mt_rand_range() has been present since PHP 7.1. - */ -#if PHP_VERSION_ID < 70100 - RAND_RANGE(number, min, max, PHP_MT_RAND_MAX); -#else - number = php_mt_rand_range(min, max); -#endif - - return number; + return php_mt_rand_range(min, max); } double zephir_ldexp(zval *value, zval *expval) diff --git a/kernels/ZendEngine3/object.h b/kernels/ZendEngine3/object.h index aba6a67374..6a24e728be 100755 --- a/kernels/ZendEngine3/object.h +++ b/kernels/ZendEngine3/object.h @@ -19,13 +19,8 @@ #include "kernel/main.h" /* Working with scopes */ -#if PHP_VERSION_ID >= 70100 # define zephir_get_scope(e) ((e) ? zend_get_executed_scope() : EG(fake_scope)) # define zephir_set_scope(s) EG(fake_scope) = (s) -#else -# define zephir_get_scope(e) EG(scope) -# define zephir_set_scope(s) EG(scope) = (s) -#endif /** Class Retrieving/Checking */ int zephir_class_exists(zval *class_name, int autoload); diff --git a/kernels/ZendEngine3/require.c b/kernels/ZendEngine3/require.c index 034c201b49..2bab5554c5 100755 --- a/kernels/ZendEngine3/require.c +++ b/kernels/ZendEngine3/require.c @@ -45,19 +45,10 @@ int zephir_require_ret(zval *return_value_ptr, const char *require_path) } #endif -#if PHP_VERSION_ID < 70400 - file_handle.filename = require_path; - file_handle.free_filename = 0; - file_handle.type = ZEND_HANDLE_FILENAME; - file_handle.opened_path = NULL; - file_handle.handle.fp = NULL; -#else - ret = php_stream_open_for_zend_ex(require_path, &file_handle, USE_PATH|STREAM_OPEN_FOR_INCLUDE); - - if (ret != SUCCESS) { - return FAILURE; - } -#endif + ret = php_stream_open_for_zend_ex(require_path, &file_handle, USE_PATH|STREAM_OPEN_FOR_INCLUDE); + if (ret != SUCCESS) { + return FAILURE; + } new_op_array = zend_compile_file(&file_handle, ZEND_REQUIRE); if (new_op_array) { diff --git a/kernels/ZendEngine3/string.c b/kernels/ZendEngine3/string.c index 1582c8ca5e..dd5ba9d432 100755 --- a/kernels/ZendEngine3/string.c +++ b/kernels/ZendEngine3/string.c @@ -1289,11 +1289,7 @@ void zephir_addslashes(zval *return_value, zval *str) } } -#if PHP_VERSION_ID < 70300 - ZVAL_STR(return_value, php_addslashes(Z_STR_P(str), 0)); -#else - ZVAL_STR(return_value, php_addslashes(Z_STR_P(str))); -#endif + ZVAL_STR(return_value, php_addslashes(Z_STR_P(str))); if (UNEXPECTED(use_copy)) { zval_dtor(©); diff --git a/tests/fixtures/protodir/connectionexception.h b/tests/fixtures/protodir/connectionexception.h index 74707df2f5..d086be4bec 100644 --- a/tests/fixtures/protodir/connectionexception.h +++ b/tests/fixtures/protodir/connectionexception.h @@ -5,7 +5,14 @@ ZEPHIR_INIT_CLASS(ProtoDir_ConnectionException); PHP_METHOD(ProtoDir_ConnectionException, getRequest); +ZEND_BEGIN_ARG_INFO_EX(arginfo_protodir_connectionexception_getrequest, 0, 0, 0) +ZEND_END_ARG_INFO() + ZEPHIR_INIT_FUNCS(protodir_connectionexception_method_entry) { +#if PHP_VERSION_ID >= 80000 + PHP_ME(ProtoDir_ConnectionException, getRequest, arginfo_protodir_connectionexception_getrequest, ZEND_ACC_PUBLIC) +#else PHP_ME(ProtoDir_ConnectionException, getRequest, NULL, ZEND_ACC_PUBLIC) +#endif PHP_FE_END }; diff --git a/tests/fixtures/stubs/issues/expected/Issue_2092.zep.php b/tests/fixtures/stubs/issues/expected/Issue_2092.zep.php index f0ae42aca6..0880df66d4 100644 --- a/tests/fixtures/stubs/issues/expected/Issue_2092.zep.php +++ b/tests/fixtures/stubs/issues/expected/Issue_2092.zep.php @@ -15,7 +15,7 @@ class Issue_2092 * Expects: * return \Stubs\Events\ManagerInterface|null * - * @return \Stubs\Events\ManagerInterface|null + * @return ManagerInterface|null */ public function getInternalEventsManager(): ?ManagerInterface { diff --git a/tests/fixtures/typehints/expected_retval3.h b/tests/fixtures/typehints/expected_retval3.h index ef0284b822..aab4e0635f 100644 --- a/tests/fixtures/typehints/expected_retval3.h +++ b/tests/fixtures/typehints/expected_retval3.h @@ -113,13 +113,33 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_typehints_retval_retval_static_object_or_scalar, ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(typehints_retval_method_entry) { +#if PHP_VERSION_ID >= 80000 PHP_ME(TypeHints_RetVal, getMyVar, arginfo_typehints_retval_getmyvar, ZEND_ACC_PUBLIC) +#else + PHP_ME(TypeHints_RetVal, getMyVar, NULL, ZEND_ACC_PUBLIC) +#endif PHP_ME(TypeHints_RetVal, getMyString, arginfo_typehints_retval_getmystring, ZEND_ACC_PUBLIC) PHP_ME(TypeHints_RetVal, getMyArray, arginfo_typehints_retval_getmyarray, ZEND_ACC_PUBLIC) +#if PHP_VERSION_ID >= 80000 PHP_ME(TypeHints_RetVal, retval_var_var, arginfo_typehints_retval_retval_var_var, ZEND_ACC_PUBLIC) +#else + PHP_ME(TypeHints_RetVal, retval_var_var, NULL, ZEND_ACC_PUBLIC) +#endif +#if PHP_VERSION_ID >= 80000 PHP_ME(TypeHints_RetVal, retval_var_var_builit_1, arginfo_typehints_retval_retval_var_var_builit_1, ZEND_ACC_PUBLIC) +#else + PHP_ME(TypeHints_RetVal, retval_var_var_builit_1, NULL, ZEND_ACC_PUBLIC) +#endif +#if PHP_VERSION_ID >= 80000 PHP_ME(TypeHints_RetVal, retval_var_var_builit_2, arginfo_typehints_retval_retval_var_var_builit_2, ZEND_ACC_PUBLIC) +#else + PHP_ME(TypeHints_RetVal, retval_var_var_builit_2, NULL, ZEND_ACC_PUBLIC) +#endif +#if PHP_VERSION_ID >= 80000 PHP_ME(TypeHints_RetVal, retval_var, arginfo_typehints_retval_retval_var, ZEND_ACC_PUBLIC) +#else + PHP_ME(TypeHints_RetVal, retval_var, NULL, ZEND_ACC_PUBLIC) +#endif PHP_ME(TypeHints_RetVal, retval_string, arginfo_typehints_retval_retval_string, ZEND_ACC_PUBLIC) PHP_ME(TypeHints_RetVal, retval_boolean, arginfo_typehints_retval_retval_boolean, ZEND_ACC_PUBLIC) PHP_ME(TypeHints_RetVal, retval_int, arginfo_typehints_retval_retval_int, ZEND_ACC_PUBLIC) @@ -138,7 +158,15 @@ ZEPHIR_INIT_FUNCS(typehints_retval_method_entry) { PHP_ME(TypeHints_RetVal, retval_nullable_boolean, arginfo_typehints_retval_retval_nullable_boolean, ZEND_ACC_PUBLIC) PHP_ME(TypeHints_RetVal, retval_nullable_char, arginfo_typehints_retval_retval_nullable_char, ZEND_ACC_PUBLIC) PHP_ME(TypeHints_RetVal, retval_nullable_array, arginfo_typehints_retval_retval_nullable_array, ZEND_ACC_PUBLIC) +#if PHP_VERSION_ID >= 80000 PHP_ME(TypeHints_RetVal, retval_object_or_scalar, arginfo_typehints_retval_retval_object_or_scalar, ZEND_ACC_PUBLIC) +#else + PHP_ME(TypeHints_RetVal, retval_object_or_scalar, NULL, ZEND_ACC_PUBLIC) +#endif +#if PHP_VERSION_ID >= 80000 PHP_ME(TypeHints_RetVal, retval_static_object_or_scalar, arginfo_typehints_retval_retval_static_object_or_scalar, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#else + PHP_ME(TypeHints_RetVal, retval_static_object_or_scalar, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) +#endif PHP_FE_END };