From 63fe4c18d6dc32da69c5590e450d8ebad4866284 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Mon, 5 Aug 2019 23:36:33 +0300 Subject: [PATCH 01/12] Fixed build-phar.sh script to correct deploy phar file --- .ci/build-phar.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/build-phar.sh b/.ci/build-phar.sh index fff2792ca2..8d7fc8c0f3 100755 --- a/.ci/build-phar.sh +++ b/.ci/build-phar.sh @@ -27,4 +27,4 @@ if [ ! -f "./zephir.phar" ] || [ ! -x "./zephir.phar" ]; then fi mkdir -p "$HOME/bin" -mv "./zephir.phar" "$HOME/bin/zephir" +cp "./zephir.phar" "$HOME/bin/zephir" From 8ee01392bfe8c011f319253374db8329d73568bb Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Mon, 12 Aug 2019 22:26:03 +0300 Subject: [PATCH 02/12] Fixed concatenation support of strings with double Closes: #1893 --- CHANGELOG.md | 3 + Library/Operators/Other/ConcatOperator.php | 146 +++++++++++++++------ ext/test/concat.zep.c | 72 ++++++++++ ext/test/concat.zep.h | 24 ++++ test/concat.zep | 30 +++++ unit-tests/Extension/ConcatTest.php | 26 ++++ 6 files changed, 259 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fff14dc2f..774a12cf83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Fixed +- Fixed concatenation support of strings with double numbers + [#1893](https://github.com/phalcon/zephir/issues/1893) ## [0.12.2] - 2019-08-05 ### Added diff --git a/Library/Operators/Other/ConcatOperator.php b/Library/Operators/Other/ConcatOperator.php index 4338ffedf6..86f22d74bb 100644 --- a/Library/Operators/Other/ConcatOperator.php +++ b/Library/Operators/Other/ConcatOperator.php @@ -14,6 +14,7 @@ use function Zephir\add_slashes; use Zephir\CompilationContext; use Zephir\CompiledExpression; +use Zephir\Exception; use Zephir\Exception\CompilerException; use Zephir\Expression; use Zephir\Operators\BaseOperator; @@ -32,6 +33,8 @@ class ConcatOperator extends BaseOperator * @param CompilationContext $compilationContext * * @return CompiledExpression + * + * @throws CompilerException */ public function compile($expression, CompilationContext $compilationContext) { @@ -58,7 +61,9 @@ public function compile($expression, CompilationContext $compilationContext) $expected->setDynamicTypes('string'); $expectedCode = $compilationContext->backend->getVariableCode($expected); - $compilationContext->codePrinter->output('ZEPHIR_CONCAT_'.strtoupper($optimized[0]).'('.$expectedCode.', '.$optimized[1].');'); + $compilationContext->codePrinter->output( + sprintf('ZEPHIR_CONCAT_%s(%s, %s);', strtoupper($optimized[0]), $expectedCode, $optimized[1]) + ); return new CompiledExpression('variable', $expected->getName(), $expression); } @@ -67,17 +72,7 @@ public function compile($expression, CompilationContext $compilationContext) * If the expression cannot be optimized, fall back to the standard compilation. */ $leftExpr = new Expression($expression['left']); - switch ($expression['left']['type']) { - case 'array-access': - case 'property-access': - $leftExpr->setReadOnly(true); - break; - - default: - $leftExpr->setReadOnly($this->readOnly); - break; - } - $left = $leftExpr->compile($compilationContext); + $left = $this->compileExpression($leftExpr, $compilationContext, $expression['left']['type']); if ('variable' == $left->getType()) { $variableLeft = $compilationContext->symbolTable->getVariableForRead($left->getCode(), $compilationContext, $expression['right']); @@ -85,17 +80,7 @@ public function compile($expression, CompilationContext $compilationContext) } $rightExpr = new Expression($expression['right']); - switch ($expression['left']['type']) { - case 'array-access': - case 'property-access': - $rightExpr->setReadOnly(true); - break; - - default: - $rightExpr->setReadOnly($this->readOnly); - break; - } - $right = $rightExpr->compile($compilationContext); + $right = $this->compileExpression($rightExpr, $compilationContext, $expression['left']['type']); if ('variable' == $right->getType()) { $variableRight = $compilationContext->symbolTable->getVariableForRead($right->getCode(), $compilationContext, $expression['right']); @@ -128,11 +113,12 @@ public function compile($expression, CompilationContext $compilationContext) * @param bool $isFullString * * @return array + * + * @throws CompilerException */ private function _getOptimizedConcat($expression, CompilationContext $compilationContext, &$isFullString) { $originalExpr = $expression; - $isFullString = true; $parts = []; @@ -156,21 +142,15 @@ private function _getOptimizedConcat($expression, CompilationContext $compilatio foreach ($parts as $part) { $expr = new Expression($part); $expr->setStringOperation(true); - switch ($part['type']) { - case 'array-access': - case 'property-access': - $expr->setReadOnly(true); - break; + $compiledExpr = $this->compileExpression($expr, $compilationContext, $part['type']); - default: - $expr->setReadOnly($this->readOnly); - break; - } - - $compiledExpr = $expr->compile($compilationContext); switch ($compiledExpr->getType()) { case 'variable': - $variable = $compilationContext->symbolTable->getVariableForRead($compiledExpr->getCode(), $compilationContext, $originalExpr); + $variable = $compilationContext->symbolTable->getVariableForRead( + $compiledExpr->getCode(), + $compilationContext, + $originalExpr + ); switch ($variable->getType()) { case 'variable': $key .= 'v'; @@ -184,15 +164,44 @@ private function _getOptimizedConcat($expression, CompilationContext $compilatio break; case 'int': + case 'uint': case 'long': + case 'ulong': + $key .= 'v'; + $tempVariable = $compilationContext->symbolTable->getTempLocalVariableForWrite( + 'variable', + $compilationContext + ); + $compilationContext->backend->assignLong( + $tempVariable, + $compiledExpr->getCode(), + $compilationContext + ); + $concatParts[] = $compilationContext->backend->getVariableCode($tempVariable); + break; + + case 'double': $key .= 'v'; - $tempVariable = $compilationContext->symbolTable->getTempLocalVariableForWrite('variable', $compilationContext, $originalExpr); - $compilationContext->backend->assignLong($tempVariable, $compiledExpr->getCode(), $compilationContext); + $tempVariable = $compilationContext->symbolTable->getTempLocalVariableForWrite( + 'variable', + $compilationContext + ); + $compilationContext->backend->assignDouble( + $tempVariable, + $compiledExpr->getCode(), + $compilationContext + ); $concatParts[] = $compilationContext->backend->getVariableCode($tempVariable); break; default: - throw new CompilerException('Variable type: '.$variable->getType().' cannot be used in concat operation', $compiledExpr->getOriginal()); + throw new CompilerException( + sprintf( + 'Variable type: %s cannot be used in concat operation', + $variable->getType() + ), + $compiledExpr->getOriginal() + ); } break; @@ -202,15 +211,48 @@ private function _getOptimizedConcat($expression, CompilationContext $compilatio break; case 'int': + case 'uint': case 'long': + case 'ulong': $key .= 'v'; - $tempVariable = $compilationContext->symbolTable->getTempLocalVariableForWrite('variable', $compilationContext, $originalExpr); - $compilationContext->codePrinter->output('ZVAL_LONG(&'.$tempVariable->getName().', '.$compiledExpr->getCode().');'); + $tempVariable = $compilationContext->symbolTable->getTempLocalVariableForWrite( + 'variable', + $compilationContext + ); + $compilationContext->codePrinter->output( + sprintf( + 'ZVAL_LONG(&%s, %s);', + $tempVariable->getName(), + $compiledExpr->getCode() + ) + ); + $concatParts[] = '&'.$tempVariable->getName(); + break; + + case 'double': + $key .= 'v'; + $tempVariable = $compilationContext->symbolTable->getTempLocalVariableForWrite( + 'variable', + $compilationContext + ); + $compilationContext->codePrinter->output( + sprintf( + 'ZVAL_DOUBLE(&%s, %s);', + $tempVariable->getName(), + $compiledExpr->getCode() + ) + ); $concatParts[] = '&'.$tempVariable->getName(); break; default: - throw new CompilerException('Variable type: '.$compiledExpr->getType().' cannot be used in concat operation', $compiledExpr->getOriginal()); + throw new CompilerException( + sprintf( + 'Variable type: %s cannot be used in concat operation', + $compiledExpr->getType() + ), + $compiledExpr->getOriginal() + ); } } @@ -218,4 +260,24 @@ private function _getOptimizedConcat($expression, CompilationContext $compilatio return [$key, implode(', ', $concatParts)]; } + + private function compileExpression(Expression $expression, CompilationContext $context, $type) + { + try { + switch ($type) { + case 'array-access': + case 'property-access': + $expression->setReadOnly(true); + break; + + default: + $expression->setReadOnly($this->readOnly); + break; + } + + return $expression->compile($context); + } catch (Exception $e) { + throw new CompilerException($e->getMessage(), $expression->getExpression()); + } + } } diff --git a/ext/test/concat.zep.c b/ext/test/concat.zep.c index 3d50a55ec8..c2779152fb 100644 --- a/ext/test/concat.zep.c +++ b/ext/test/concat.zep.c @@ -137,3 +137,75 @@ PHP_METHOD(Test_Concat, testConcat3) { } +/** + * @link https://github.com/phalcon/zephir/issues/1893 + */ +PHP_METHOD(Test_Concat, testConcat4) { + + zval query, _1, _3; + double min = 0, max = 0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *value, value_sub, _0, _2; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &value); + + + + ZEPHIR_INIT_VAR(&query); + ZVAL_STRING(&query, ""); + min = (zephir_safe_div_zval_long(value, 100 TSRMLS_CC) * (double) (25)); + max = (zephir_safe_div_zval_long(value, 100 TSRMLS_CC) * (double) (50)); + ZEPHIR_SINIT_VAR(_0); + ZVAL_DOUBLE(&_0, max); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "SELECT * FROM TEST WHERE value <= ", &_0); + zephir_concat_self(&query, &_1 TSRMLS_CC); + ZEPHIR_SINIT_VAR(_2); + ZVAL_DOUBLE(&_2, min); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_SV(&_3, " AND value >= ", &_2); + zephir_concat_self(&query, &_3 TSRMLS_CC); + RETURN_CTOR(&query); + +} + +/** + * @link https://github.com/phalcon/zephir/issues/1893 + */ +PHP_METHOD(Test_Concat, testConcat5) { + + zval retval, left; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *number_param = NULL, _0; + double number; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&retval); + ZVAL_UNDEF(&left); + + ZEPHIR_MM_GROW(); + zephir_fetch_params(1, 1, 0, &number_param); + + number = zephir_get_doubleval(number_param); + + + ZEPHIR_INIT_VAR(&left); + ZVAL_STRING(&left, "Concatenated string with number "); + ZEPHIR_SINIT_VAR(_0); + ZVAL_DOUBLE(&_0, number); + ZEPHIR_INIT_VAR(&retval); + ZEPHIR_CONCAT_VV(&retval, &left, &_0); + RETURN_CTOR(&retval); + +} + diff --git a/ext/test/concat.zep.h b/ext/test/concat.zep.h index 519c6d2b63..693cf0d346 100644 --- a/ext/test/concat.zep.h +++ b/ext/test/concat.zep.h @@ -8,6 +8,8 @@ PHP_METHOD(Test_Concat, testConcatBySelfProperty); PHP_METHOD(Test_Concat, testConcat1); PHP_METHOD(Test_Concat, testConcat2); PHP_METHOD(Test_Concat, testConcat3); +PHP_METHOD(Test_Concat, testConcat4); +PHP_METHOD(Test_Concat, testConcat5); #if PHP_VERSION_ID >= 70200 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_gettestproperty, 0, 0, IS_STRING, 1) @@ -45,11 +47,33 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_testconcat3, 0, 0, I #endif ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_testconcat4, 0, 1, IS_STRING, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_testconcat4, 0, 1, IS_STRING, NULL, 0) +#endif + ZEND_ARG_INFO(0, value) +ZEND_END_ARG_INFO() + +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_testconcat5, 0, 1, IS_STRING, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_testconcat5, 0, 1, IS_STRING, NULL, 0) +#endif +#if PHP_VERSION_ID >= 70200 + ZEND_ARG_TYPE_INFO(0, number, IS_DOUBLE, 0) +#else + ZEND_ARG_INFO(0, number) +#endif +ZEND_END_ARG_INFO() + ZEPHIR_INIT_FUNCS(test_concat_method_entry) { PHP_ME(Test_Concat, getTestProperty, arginfo_test_concat_gettestproperty, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) PHP_ME(Test_Concat, testConcatBySelfProperty, arginfo_test_concat_testconcatbyselfproperty, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) PHP_ME(Test_Concat, testConcat1, arginfo_test_concat_testconcat1, ZEND_ACC_PUBLIC) PHP_ME(Test_Concat, testConcat2, arginfo_test_concat_testconcat2, ZEND_ACC_PUBLIC) PHP_ME(Test_Concat, testConcat3, arginfo_test_concat_testconcat3, ZEND_ACC_PUBLIC) + PHP_ME(Test_Concat, testConcat4, arginfo_test_concat_testconcat4, ZEND_ACC_PUBLIC) + PHP_ME(Test_Concat, testConcat5, arginfo_test_concat_testconcat5, ZEND_ACC_PUBLIC) PHP_FE_END }; diff --git a/test/concat.zep b/test/concat.zep index 60d4429412..67bb0b0247 100644 --- a/test/concat.zep +++ b/test/concat.zep @@ -44,4 +44,34 @@ class Concat let b .= a; return b; } + + /** + * @link https://github.com/phalcon/zephir/issues/1893 + */ + public function testConcat4(var value) -> string + { + var min, max; + string query = ""; + + let min = value / 100 * 25, + max = value / 100 * 50; + + let query .= "SELECT * FROM TEST WHERE value <= " . max, + query .= " AND value >= " . min; + + return query; + } + + /** + * @link https://github.com/phalcon/zephir/issues/1893 + */ + public function testConcat5(double number) -> string + { + string retval; + string left = "Concatenated string with number "; + + let retval = left . number; + + return retval; + } } diff --git a/unit-tests/Extension/ConcatTest.php b/unit-tests/Extension/ConcatTest.php index 072399d972..210d0ed8d6 100644 --- a/unit-tests/Extension/ConcatTest.php +++ b/unit-tests/Extension/ConcatTest.php @@ -53,4 +53,30 @@ public function shouldConcatenateStringsSimilarToIntegersNumbers() $t = new Concat(); $this->assertSame('21', $t->testConcat3()); } + + /** + * @test + * @issue https://github.com/phalcon/zephir/issues/1893 + */ + public function shouldConcatenateStringWithVarDouble() + { + $t = new Concat(); + $this->assertSame( + /* @lang text */ 'SELECT * FROM TEST WHERE value <= 946.5 AND value >= 473.25', + $t->testConcat4(1893) + ); + } + + /** + * @test + * @issue https://github.com/phalcon/zephir/issues/1893 + */ + public function shouldConcatenateStringWithDouble() + { + $t = new Concat(); + $this->assertSame( + 'Concatenated string with number 18.93000001', + $t->testConcat5(18.93000001) + ); + } } From 8561ce0dc679c68f27a527614c79e8fc75ec432a Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Mon, 12 Aug 2019 22:27:13 +0300 Subject: [PATCH 03/12] Bump version --- Library/Zephir.php | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Zephir.php b/Library/Zephir.php index cb29a73a8c..e66bb89c29 100644 --- a/Library/Zephir.php +++ b/Library/Zephir.php @@ -16,7 +16,7 @@ */ final class Zephir { - const VERSION = '0.12.2-$Id$'; + const VERSION = '0.12.3-$Id$'; const LOGO = <<<'ASCII' _____ __ _ diff --git a/appveyor.yml b/appveyor.yml index 544c310136..ccef663ab3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.12.2-{build} +version: 0.12.3-{build} environment: matrix: From 49fa9bca8a649d712af139badf318a8a31f035e0 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Mon, 12 Aug 2019 22:57:11 +0300 Subject: [PATCH 04/12] Fixed indents --- test/concat.zep | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/concat.zep b/test/concat.zep index 67bb0b0247..17ce3fe547 100644 --- a/test/concat.zep +++ b/test/concat.zep @@ -50,16 +50,16 @@ class Concat */ public function testConcat4(var value) -> string { - var min, max; - string query = ""; + var min, max; + string query = ""; - let min = value / 100 * 25, - max = value / 100 * 50; + let min = value / 100 * 25, + max = value / 100 * 50; - let query .= "SELECT * FROM TEST WHERE value <= " . max, - query .= " AND value >= " . min; + let query .= "SELECT * FROM TEST WHERE value <= " . max, + query .= " AND value >= " . min; - return query; + return query; } /** @@ -67,11 +67,11 @@ class Concat */ public function testConcat5(double number) -> string { - string retval; - string left = "Concatenated string with number "; + string retval; + string left = "Concatenated string with number "; - let retval = left . number; + let retval = left . number; - return retval; + return retval; } } From 99c947ee04091b488bbceebdd48e7f549317124a Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 13 Aug 2019 23:31:25 +0300 Subject: [PATCH 05/12] Remove cache: apt because it's not supported [skip appveyor] See: https://github.com/travis-ci/travis-ci/issues/5876#issuecomment-207661127 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 18d0150b06..63c4bd3664 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,6 @@ matrix: - php: '7.4snapshot' cache: - apt: true timeout: 604800 directories: - $HOME/.composer/cache From 2908305492feca547eb6dae5ab11c833d1ecbdbb Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 14 Aug 2019 00:01:07 +0300 Subject: [PATCH 06/12] Do not use sudo on docker, cleaned up install script [skip appveyor] --- templates/ZendEngine3/install | 41 ++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/templates/ZendEngine3/install b/templates/ZendEngine3/install index 82471e5d13..fe7bc11112 100644 --- a/templates/ZendEngine3/install +++ b/templates/ZendEngine3/install @@ -1,20 +1,45 @@ #!/usr/bin/env bash +# +# This file was generated automatically by Zephir. +# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN +# +# (c) Zephir Team +# +# For the full copyright and license information, please view +# the LICENSE file that was distributed with this source code. export CC="gcc" export CFLAGS="-O2 -Wall -fvisibility=hidden -flto -DZEPHIR_RELEASE=1" -phpize_bin=$(which phpize 2> /dev/null) +IN_DOCKER=0 -if [ -z $(which sudo 2> /dev/null) ]; then - alias sudo="" +if [[ -f /proc/1/cgroup ]] +then + if [[ -f /.dockerenv ]] || grep -Eq '/(lxc|docker)/[[:xdigit:]]{64}' /proc/1/cgroup + then + IN_DOCKER=1 + fi fi +phpize="$(command -v phpize 2> /dev/null)" + +sudo="" +test "$IN_DOCKER" -eq 0 && sudo="$(command -v sudo 2> /dev/null)" + if [ -f Makefile ]; then - sudo make -s clean - sudo ${phpize_bin} --silent --clean + $sudo make -s clean + $sudo "${phpize}" --silent --clean fi -${phpize_bin} --silent +${phpize} --silent + +ZEPHIR_CFLAGS="" +ZEPHIR_LDFLAGS="" + +test -n "$CFLAGS" && ZEPHIR_CFLAGS="CFLAGS=\"$CFLAGS\"" +test -n "$LDFLAGS" && ZEPHIR_LDFLAGS="LDFLAGS=\"$LDFLAGS\"" + +/configure --silent --enable-%PROJECT_LOWER% "$ZEPHIR_CFLAGS" "$ZEPHIR_LDFLAGS" -./configure --silent --enable-%PROJECT_LOWER% -make -s && sudo make -s install +make -s +$sudo make -s install From 94091ed0006861c39a9ad1c8b81ef1a14f05dcb0 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Mon, 26 Aug 2019 00:00:34 +0900 Subject: [PATCH 07/12] Fix #1908 --- CHANGELOG.md | 2 + Library/ArgInfoDefinition.php | 64 ++++++++++++++++++++++++++++++- Library/ClassMethod.php | 12 +++++- Library/Stubs/Generator.php | 9 ++++- ext/install | 41 ++++++++++++++++---- ext/php_test.h | 2 +- ext/test/bench/foo.zep.h | 13 ++++++- ext/test/concat.zep.h | 9 +++++ ext/test/exitdie.zep.h | 18 +++++++++ ext/test/fortytwo.zep.h | 13 ++++++- ext/test/geometry.zep.h | 18 +++++++++ ext/test/globals.zep.h | 45 ++++++++++++++++++++++ ext/test/requires.zep.h | 9 +++++ ext/test/requires/external3.zep.h | 9 +++++ ext/test/scall.zep.h | 13 ++++++- 15 files changed, 261 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 774a12cf83..5669288af5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Fixed concatenation support of strings with double numbers [#1893](https://github.com/phalcon/zephir/issues/1893) +- Fixed 'void' return type hint being ignored + [#1908](https://github.com/phalcon/zephir/issues/1908) ## [0.12.2] - 2019-08-05 ### Added diff --git a/Library/ArgInfoDefinition.php b/Library/ArgInfoDefinition.php index 2190713ea4..846525152e 100644 --- a/Library/ArgInfoDefinition.php +++ b/Library/ArgInfoDefinition.php @@ -96,7 +96,7 @@ public function render() ) { $this->richRenderStart(); - if (false == $this->hasParameters()) { + if (false == $this->hasParameters() && false == $this->functionLike->isVoid()) { $this->codePrinter->output('ZEND_END_ARG_INFO()'); $this->codePrinter->outputBlankLine(); } @@ -156,6 +156,64 @@ private function richRenderStart() return; } + if ($this->functionLike->isVoid()) { + $this->codePrinter->output('#if PHP_VERSION_ID >= 70100'); + $this->codePrinter->output('#if PHP_VERSION_ID >= 70200'); + $this->codePrinter->output( + sprintf( + 'ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(%s, %d, %d, %s, %d)', + $this->name, + (int) $this->returnByRef, + $this->functionLike->getNumberOfRequiredParameters(), + $this->getReturnType(), + (int) $this->functionLike->areReturnTypesNullCompatible() + ) + ); + + $this->codePrinter->output('#else'); + + $this->codePrinter->output( + sprintf( + 'ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(%s, %d, %d, %s, NULL, %d)', + $this->name, + (int) $this->returnByRef, + $this->functionLike->getNumberOfRequiredParameters(), + $this->getReturnType(), + (int) $this->functionLike->areReturnTypesNullCompatible() + ) + ); + + $this->codePrinter->output('#endif'); + + if (false == $this->hasParameters()) { + $this->codePrinter->output('ZEND_END_ARG_INFO()'); + $this->codePrinter->outputBlankLine(); + } + + $this->codePrinter->output('#else'); + + if (true == $this->hasParameters()) { + $this->codePrinter->output( + sprintf( + 'ZEND_BEGIN_ARG_INFO_EX(%s, 0, %d, %d)', + $this->name, + (int) $this->returnByRef, + $this->functionLike->getNumberOfRequiredParameters() + ) + ); + } + + $this->codePrinter->output( + sprintf( + '#define %s NULL', + $this->name + ) + ); + + $this->codePrinter->output('#endif'); + return; + } + $this->codePrinter->output('#if PHP_VERSION_ID >= 70200'); $this->codePrinter->output( sprintf( @@ -357,6 +415,10 @@ private function getReturnType() return 'IS_STRING'; } + if ($this->functionLike->isVoid()) { + return 'IS_VOID'; + } + if (\array_key_exists('array', $this->functionLike->getReturnTypes())) { return 'IS_ARRAY'; } diff --git a/Library/ClassMethod.php b/Library/ClassMethod.php index e4e5a4adc9..a3deeb4f9c 100644 --- a/Library/ClassMethod.php +++ b/Library/ClassMethod.php @@ -2322,7 +2322,7 @@ public function getArgInfoName(ClassDefinition $classDefinition = null) * * Examples: * - * - FALSE: function foo() -> void; + * - TRUE: function foo() -> void; * - TRUE: function foo() -> null; * - TRUE: function foo() -> bool|string|..; * - TRUE: function foo() -> <\stdClass>; @@ -2334,7 +2334,10 @@ public function getArgInfoName(ClassDefinition $classDefinition = null) */ public function isReturnTypesHintDetermined() { - if (0 == \count($this->returnTypes) || $this->isVoid()) { + if ($this->isVoid()) { + return true; + } + if (0 == \count($this->returnTypes)) { return false; } @@ -2376,6 +2379,11 @@ public function isReturnTypesHintDetermined() */ public function areReturnTypesCompatible() { + // void + if ($this->isVoid()) { + return true; + } + // null | T1 | T2 if (\count($this->returnTypes) > 2) { return false; diff --git a/Library/Stubs/Generator.php b/Library/Stubs/Generator.php index d204a45095..bac0dd7209 100644 --- a/Library/Stubs/Generator.php +++ b/Library/Stubs/Generator.php @@ -267,9 +267,16 @@ protected function buildMethod(ClassMethod $method, $isInterface, $indent) } $return = ''; - if (version_compare(PHP_VERSION, '7.0.0', '>=') && $method->hasReturnTypes()) { + if (version_compare(PHP_VERSION, '7.0.0', '>=') && ($method->hasReturnTypes() || $method->isVoid())) { $supported = 0; + if ($method->isVoid()) { + if (version_compare(PHP_VERSION, '7.1.0', '>=')) { + $return = 'void'; + ++$supported; + } + } + if (\array_key_exists('object', $method->getReturnTypes()) && 1 == \count($method->getReturnClassTypes())) { $return = key($method->getReturnClassTypes()); ++$supported; diff --git a/ext/install b/ext/install index d688908d99..7e9beb45ef 100755 --- a/ext/install +++ b/ext/install @@ -1,20 +1,45 @@ #!/usr/bin/env bash +# +# This file was generated automatically by Zephir. +# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN +# +# (c) Zephir Team +# +# For the full copyright and license information, please view +# the LICENSE file that was distributed with this source code. export CC="gcc" export CFLAGS="-O2 -Wall -fvisibility=hidden -flto -DZEPHIR_RELEASE=1" -phpize_bin=$(which phpize 2> /dev/null) +IN_DOCKER=0 -if [ -z $(which sudo 2> /dev/null) ]; then - alias sudo="" +if [[ -f /proc/1/cgroup ]] +then + if [[ -f /.dockerenv ]] || grep -Eq '/(lxc|docker)/[[:xdigit:]]{64}' /proc/1/cgroup + then + IN_DOCKER=1 + fi fi +phpize="$(command -v phpize 2> /dev/null)" + +sudo="" +test "$IN_DOCKER" -eq 0 && sudo="$(command -v sudo 2> /dev/null)" + if [ -f Makefile ]; then - sudo make -s clean - sudo ${phpize_bin} --silent --clean + $sudo make -s clean + $sudo "${phpize}" --silent --clean fi -${phpize_bin} --silent +${phpize} --silent + +ZEPHIR_CFLAGS="" +ZEPHIR_LDFLAGS="" + +test -n "$CFLAGS" && ZEPHIR_CFLAGS="CFLAGS=\"$CFLAGS\"" +test -n "$LDFLAGS" && ZEPHIR_LDFLAGS="LDFLAGS=\"$LDFLAGS\"" + +/configure --silent --enable-test "$ZEPHIR_CFLAGS" "$ZEPHIR_LDFLAGS" -./configure --silent --enable-test -make -s && sudo make -s install +make -s +$sudo make -s install diff --git a/ext/php_test.h b/ext/php_test.h index f56b06d665..33623e1277 100644 --- a/ext/php_test.h +++ b/ext/php_test.h @@ -14,7 +14,7 @@ #define PHP_TEST_VERSION "1.0.0" #define PHP_TEST_EXTNAME "test" #define PHP_TEST_AUTHOR "Zephir Team and contributors" -#define PHP_TEST_ZEPVERSION "0.12.2-$Id$" +#define PHP_TEST_ZEPVERSION "0.12.3-$Id$" #define PHP_TEST_DESCRIPTION "Description test for
Test Extension." typedef struct _zephir_struct_db { diff --git a/ext/test/bench/foo.zep.h b/ext/test/bench/foo.zep.h index d4b95bb46d..f6ae3badf1 100644 --- a/ext/test/bench/foo.zep.h +++ b/ext/test/bench/foo.zep.h @@ -75,6 +75,17 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_test_bench_foo_call, 0, 0, 1) ZEND_ARG_INFO(0, n) ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_bench_foo_staticmethod, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_bench_foo_staticmethod, 0, 0, IS_VOID, NULL, 0) +#endif +ZEND_END_ARG_INFO() + +#else +#define arginfo_test_bench_foo_staticmethod NULL +#endif #if PHP_VERSION_ID >= 70200 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_bench_foo_staticmethod1, 0, 0, _IS_BOOL, 0) #else @@ -109,7 +120,7 @@ ZEPHIR_INIT_FUNCS(test_bench_foo_method_entry) { PHP_ME(Test_Bench_Foo, emptyProp, arginfo_test_bench_foo_emptyprop, ZEND_ACC_PUBLIC) PHP_ME(Test_Bench_Foo, g, NULL, ZEND_ACC_PUBLIC) PHP_ME(Test_Bench_Foo, call, arginfo_test_bench_foo_call, ZEND_ACC_PUBLIC) - PHP_ME(Test_Bench_Foo, staticMethod, NULL, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) + PHP_ME(Test_Bench_Foo, staticMethod, arginfo_test_bench_foo_staticmethod, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) PHP_ME(Test_Bench_Foo, staticMethod1, arginfo_test_bench_foo_staticmethod1, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) PHP_ME(Test_Bench_Foo, scall, arginfo_test_bench_foo_scall, ZEND_ACC_PUBLIC) PHP_ME(Test_Bench_Foo, scallWithReturnTrue, arginfo_test_bench_foo_scallwithreturntrue, ZEND_ACC_PUBLIC) diff --git a/ext/test/concat.zep.h b/ext/test/concat.zep.h index 693cf0d346..e3065a8946 100644 --- a/ext/test/concat.zep.h +++ b/ext/test/concat.zep.h @@ -18,7 +18,16 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_gettestproperty, 0, #endif ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_testconcatbyselfproperty, 0, 1, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_concat_testconcatbyselfproperty, 0, 1, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_concat_testconcatbyselfproperty, 0, 0, 1) +#define arginfo_test_concat_testconcatbyselfproperty NULL +#endif #if PHP_VERSION_ID >= 70200 ZEND_ARG_TYPE_INFO(0, title, IS_STRING, 0) #else diff --git a/ext/test/exitdie.zep.h b/ext/test/exitdie.zep.h index b1c48da591..a40c8aa99d 100644 --- a/ext/test/exitdie.zep.h +++ b/ext/test/exitdie.zep.h @@ -6,11 +6,29 @@ ZEPHIR_INIT_CLASS(Test_ExitDie); PHP_METHOD(Test_ExitDie, testExit); PHP_METHOD(Test_ExitDie, testDie); +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_exitdie_testexit, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_exitdie_testexit, 0, 0, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_exitdie_testexit, 0, 0, 0) +#define arginfo_test_exitdie_testexit NULL +#endif ZEND_ARG_INFO(0, param) ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_exitdie_testdie, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_exitdie_testdie, 0, 0, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_exitdie_testdie, 0, 0, 0) +#define arginfo_test_exitdie_testdie NULL +#endif ZEND_ARG_INFO(0, param) ZEND_END_ARG_INFO() diff --git a/ext/test/fortytwo.zep.h b/ext/test/fortytwo.zep.h index bff28a920b..e138144f9e 100644 --- a/ext/test/fortytwo.zep.h +++ b/ext/test/fortytwo.zep.h @@ -5,7 +5,18 @@ ZEPHIR_INIT_CLASS(Test_FortyTwo); PHP_METHOD(Test_FortyTwo, proof); +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_fortytwo_proof, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_fortytwo_proof, 0, 0, IS_VOID, NULL, 0) +#endif +ZEND_END_ARG_INFO() + +#else +#define arginfo_test_fortytwo_proof NULL +#endif ZEPHIR_INIT_FUNCS(test_fortytwo_method_entry) { - PHP_ME(Test_FortyTwo, proof, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Test_FortyTwo, proof, arginfo_test_fortytwo_proof, ZEND_ACC_PUBLIC) PHP_FE_END }; diff --git a/ext/test/geometry.zep.h b/ext/test/geometry.zep.h index 422549a9f1..87aea0b57f 100644 --- a/ext/test/geometry.zep.h +++ b/ext/test/geometry.zep.h @@ -7,7 +7,16 @@ PHP_METHOD(Test_Geometry, run); PHP_METHOD(Test_Geometry, runOptimize); PHP_METHOD(Test_Geometry, distanceStatic); +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_geometry_run, 0, 2, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_geometry_run, 0, 2, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_geometry_run, 0, 0, 2) +#define arginfo_test_geometry_run NULL +#endif ZEND_ARG_ARRAY_INFO(0, list, 0) #if PHP_VERSION_ID >= 70200 ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) @@ -16,7 +25,16 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_test_geometry_run, 0, 0, 2) #endif ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_geometry_runoptimize, 0, 2, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_geometry_runoptimize, 0, 2, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_geometry_runoptimize, 0, 0, 2) +#define arginfo_test_geometry_runoptimize NULL +#endif ZEND_ARG_ARRAY_INFO(0, list, 0) #if PHP_VERSION_ID >= 70200 ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) diff --git a/ext/test/globals.zep.h b/ext/test/globals.zep.h index 1f96f1fad5..fc57559e94 100644 --- a/ext/test/globals.zep.h +++ b/ext/test/globals.zep.h @@ -17,23 +17,68 @@ PHP_METHOD(Test_Globals, getDefaultGlobals6); PHP_METHOD(Test_Globals, getDefaultGlobals7); PHP_METHOD(Test_Globals, getDefaultGlobalsOrmCacheLevel); +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setboolvalueusingdotnotation, 0, 1, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setboolvalueusingdotnotation, 0, 1, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_globals_setboolvalueusingdotnotation, 0, 0, 1) +#define arginfo_test_globals_setboolvalueusingdotnotation NULL +#endif ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setintvalueusingdotnotation, 0, 1, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setintvalueusingdotnotation, 0, 1, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_globals_setintvalueusingdotnotation, 0, 0, 1) +#define arginfo_test_globals_setintvalueusingdotnotation NULL +#endif ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setcharvalue, 0, 1, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setcharvalue, 0, 1, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_globals_setcharvalue, 0, 0, 1) +#define arginfo_test_globals_setcharvalue NULL +#endif ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setboolvalue, 0, 1, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setboolvalue, 0, 1, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_globals_setboolvalue, 0, 0, 1) +#define arginfo_test_globals_setboolvalue NULL +#endif ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setdefaultglobalsormcachelevel, 0, 1, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_globals_setdefaultglobalsormcachelevel, 0, 1, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_globals_setdefaultglobalsormcachelevel, 0, 0, 1) +#define arginfo_test_globals_setdefaultglobalsormcachelevel NULL +#endif ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() diff --git a/ext/test/requires.zep.h b/ext/test/requires.zep.h index dff53377fc..951ad82147 100644 --- a/ext/test/requires.zep.h +++ b/ext/test/requires.zep.h @@ -21,7 +21,16 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_test_requires_requireexternal3, 0, 0, 1) ZEND_ARG_INFO(0, path) ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_requires_setcontent, 0, 1, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_requires_setcontent, 0, 1, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_requires_setcontent, 0, 0, 1) +#define arginfo_test_requires_setcontent NULL +#endif ZEND_ARG_INFO(0, content) ZEND_END_ARG_INFO() diff --git a/ext/test/requires/external3.zep.h b/ext/test/requires/external3.zep.h index 343e43c87e..bec529ed73 100644 --- a/ext/test/requires/external3.zep.h +++ b/ext/test/requires/external3.zep.h @@ -5,7 +5,16 @@ ZEPHIR_INIT_CLASS(Test_Requires_External3); PHP_METHOD(Test_Requires_External3, req); +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_requires_external3_req, 0, 2, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_requires_external3_req, 0, 2, IS_VOID, NULL, 0) +#endif +#else ZEND_BEGIN_ARG_INFO_EX(arginfo_test_requires_external3_req, 0, 0, 2) +#define arginfo_test_requires_external3_req NULL +#endif ZEND_ARG_INFO(0, path) ZEND_ARG_INFO(0, requires) ZEND_END_ARG_INFO() diff --git a/ext/test/scall.zep.h b/ext/test/scall.zep.h index b44d98c714..b278a90ed8 100644 --- a/ext/test/scall.zep.h +++ b/ext/test/scall.zep.h @@ -154,6 +154,17 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_scall_interpolatedstaticret #endif ZEND_END_ARG_INFO() +#if PHP_VERSION_ID >= 70100 +#if PHP_VERSION_ID >= 70200 +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_scall_interpolatedstaticecho, 0, 0, IS_VOID, 0) +#else +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_test_scall_interpolatedstaticecho, 0, 0, IS_VOID, NULL, 0) +#endif +ZEND_END_ARG_INFO() + +#else +#define arginfo_test_scall_interpolatedstaticecho NULL +#endif ZEPHIR_INIT_FUNCS(test_scall_method_entry) { PHP_ME(Test_Scall, testMethod1, arginfo_test_scall_testmethod1, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC) PHP_ME(Test_Scall, testMethod2, arginfo_test_scall_testmethod2, ZEND_ACC_STATIC|ZEND_ACC_PROTECTED) @@ -182,6 +193,6 @@ ZEPHIR_INIT_FUNCS(test_scall_method_entry) { PHP_ME(Test_Scall, testCall18, arginfo_test_scall_testcall18, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) PHP_ME(Test_Scall, testMethodStatic, arginfo_test_scall_testmethodstatic, ZEND_ACC_STATIC|ZEND_ACC_PROTECTED) PHP_ME(Test_Scall, interpolatedStaticReturn, arginfo_test_scall_interpolatedstaticreturn, ZEND_ACC_PUBLIC) - PHP_ME(Test_Scall, interpolatedStaticEcho, NULL, ZEND_ACC_PUBLIC) + PHP_ME(Test_Scall, interpolatedStaticEcho, arginfo_test_scall_interpolatedstaticecho, ZEND_ACC_PUBLIC) PHP_FE_END }; From 160ff14f7fd5c6270c999ccfc8dcaf1d5720e739 Mon Sep 17 00:00:00 2001 From: JellyBrick Date: Mon, 26 Aug 2019 00:50:06 +0900 Subject: [PATCH 08/12] Fix code style --- Library/ArgInfoDefinition.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/ArgInfoDefinition.php b/Library/ArgInfoDefinition.php index 846525152e..87cd2f2587 100644 --- a/Library/ArgInfoDefinition.php +++ b/Library/ArgInfoDefinition.php @@ -187,7 +187,6 @@ private function richRenderStart() if (false == $this->hasParameters()) { $this->codePrinter->output('ZEND_END_ARG_INFO()'); - $this->codePrinter->outputBlankLine(); } $this->codePrinter->output('#else'); @@ -211,6 +210,8 @@ private function richRenderStart() ); $this->codePrinter->output('#endif'); + $this->codePrinter->outputBlankLine(); + return; } From 1a6d6eaa68a67689eaaf587cb7749aac2c5b8f95 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Thu, 5 Sep 2019 14:04:50 -0400 Subject: [PATCH 09/12] Update README.md --- README.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c3f0a30aae..c47f9f1847 100644 --- a/README.md +++ b/README.md @@ -15,24 +15,36 @@ is a high level **Programming Language** that eases the creation and maintainabi Zephir extensions are exported to C code that can be compiled and optimized by major C compilers such as gcc/clang/vc++. Functionality is exposed to the PHP language. -Documentation -------------- +## Documentation * Official documentation is [located here][1] -Community ---------- +## Community * Follow us on [GitHub][2] and [Facebook][3] * Get Zephir support on [Discord][4] and [Official Forums][5] * Read our [Code of Conduct][6] -Contributing ------------- +## Contributing Zephir is an Open Source, community-driven project. See [CONTRIBUTING.md][7] for details about contributions to this repository. -License -------- +## Sponsors + +Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/phalcon#sponsor)] + + + + + +## Backers + +Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/phalcon#backer)] + + + + + +## License Zephir licensed under the MIT License. See the [LICENSE][8] file for more information. From 1f6962d40e17581b5a0d9a92b32caa186819c889 Mon Sep 17 00:00:00 2001 From: chrysanthemum Date: Sun, 22 Sep 2019 08:43:53 +0800 Subject: [PATCH 10/12] Fix #1915 Update property fix bug: https://github.com/phalcon/zephir/issues/1915 --- kernels/ZendEngine3/object.c | 4 ++- test/properties/propertyupdate.zep | 10 +++++++ .../Properties/PropertyUpdateTest.php | 28 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 test/properties/propertyupdate.zep create mode 100644 unit-tests/Extension/Properties/PropertyUpdateTest.php diff --git a/kernels/ZendEngine3/object.c b/kernels/ZendEngine3/object.c index 62db7801a2..cf6a3d26ea 100644 --- a/kernels/ZendEngine3/object.c +++ b/kernels/ZendEngine3/object.c @@ -750,7 +750,9 @@ int zephir_update_property_array_append(zval *object, char *property, unsigned i zval new_zv; ZVAL_DUP(&new_zv, &tmp); ZVAL_COPY_VALUE(&tmp, &new_zv); - Z_TRY_DELREF(new_zv); + if (Z_REFCOUNT(tmp) > 1) { + Z_TRY_DELREF(new_zv); + } separated = 1; } } diff --git a/test/properties/propertyupdate.zep b/test/properties/propertyupdate.zep new file mode 100644 index 0000000000..3e09e4804f --- /dev/null +++ b/test/properties/propertyupdate.zep @@ -0,0 +1,10 @@ +namespace Test\Properties; + +class PropertyUpdate +{ + public p1; + + public function update1() { + let this->p1[] = "aaa"; + } +} diff --git a/unit-tests/Extension/Properties/PropertyUpdateTest.php b/unit-tests/Extension/Properties/PropertyUpdateTest.php new file mode 100644 index 0000000000..a8eb6b09c3 --- /dev/null +++ b/unit-tests/Extension/Properties/PropertyUpdateTest.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Extension\Properties; + +use PHPUnit\Framework\TestCase; +use Test\Properties\PropertyUpdate; + +class PropertyUpdateTest extends TestCase +{ + public function testUpdate11() + { + // before fixed. Assertion failed: (((ht)->gc.refcount == 1) || ((ht)->u.flags & (1<<6))), function _zend_hash_index_add_or_update_i + $t = new PropertyUpdate(); + $t->p1 = [111]; + $t->update1(); + + $this->assertSame($t->p1, [111, 'aaa']); + } +} From 773abde434378a646f966f2973fb0bea943d4125 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 22 Sep 2019 11:59:44 +0300 Subject: [PATCH 11/12] Fixed code style issue --- Library/Types/AbstractType.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Library/Types/AbstractType.php b/Library/Types/AbstractType.php index ef1efcad31..316a6b9e3d 100644 --- a/Library/Types/AbstractType.php +++ b/Library/Types/AbstractType.php @@ -13,6 +13,8 @@ use Zephir\Call; use Zephir\CompilationContext; +use Zephir\CompiledExpression; +use Zephir\Exception; use Zephir\Exception\CompilerException; use Zephir\Expression; use Zephir\Expression\Builder\BuilderFactory; @@ -35,15 +37,14 @@ abstract class AbstractType * @param Call $call * @param array $expression * - * @throws CompilerException + * @return bool|CompiledExpression * - * @return bool|\Zephir\CompiledExpression + * @throws CompilerException|Exception */ public function invokeMethod( $methodName, $caller, - CompilationContext - $compilationContext, + CompilationContext $compilationContext, Call $call, array $expression ) { From c5226eac3c5925da0c7411a4ea6ebb51c760996f Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Sun, 22 Sep 2019 12:05:26 +0300 Subject: [PATCH 12/12] Bump version --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5669288af5..792ca7b3a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.12.3] - 2019-09-22 ### Fixed - Fixed concatenation support of strings with double numbers [#1893](https://github.com/phalcon/zephir/issues/1893) - Fixed 'void' return type hint being ignored [#1908](https://github.com/phalcon/zephir/issues/1908) +- Fixed updating array properties + [#1915](https://github.com/phalcon/zephir/issues/1915) ## [0.12.2] - 2019-08-05 ### Added @@ -215,7 +218,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed casting resource to int (only ZendEngine 3) [#1524](https://github.com/phalcon/zephir/issues/1524) -[Unreleased]: https://github.com/phalcon/zephir/compare/0.12.2...HEAD +[Unreleased]: https://github.com/phalcon/zephir/compare/0.12.3...HEAD +[0.12.3]: https://github.com/phalcon/zephir/compare/0.12.2...0.12.3 [0.12.2]: https://github.com/phalcon/zephir/compare/0.12.1...0.12.2 [0.12.1]: https://github.com/phalcon/zephir/compare/0.12.0...0.12.1 [0.12.0]: https://github.com/phalcon/zephir/compare/0.11.12...0.12.0