Skip to content

Commit

Permalink
0.11.1 (#1676)
Browse files Browse the repository at this point in the history
* Initial support of PHP 7.3 (#1674)

* Initial support of PHP 7.3

* Prepare Travis CI config to use PHP 7.3

* Remove useles clang testing

* Cleaned up Travis CI config

* Disable opcache for php 7.3

* Do not run valgrind tests for php 7.3

* Skip some tests for PHP 7.3

* Fixed require to return FAILURE when failed opening file

* Added missed return FAILURE to the zephir_memory_restore_stack

* Correct test for #1439

- Fixed yet anoter segfault for PHP 7.3

/cc @niden

* Add print debug trace on Travis

* Avoid the same trait name

refs: 151f5db
/cc @danhunsaker

* Fixed array handling for PHP 7.3

* Add zephir_ensure_array function

* Correct Zephir Core documentation

* Added backwards compatibility for GC API change in PHP 7.3

* Cleaned up native array tests

* Getting Core Dumps of Failed TravisCI Builds

* The RAND_RANGE() macro has been removed since PHP 7.3

* Cleaning up

- Simplified ZEPHIRPATH constant by removing trailing slash
- Added required extensions to the composer.json
- Minor tweaks and clening up
- Cleaned up the ArrayIndex class

* Refactor test ExitDieTest

* Introduced Zephir TestCase

* Speed up memcheck

* Move all fixtures to the common place

* Disable default system allocators for PHP 7.3

* Bump version

* Disable memcheck for php 7.3

* Disable opcache on Travis CI

* Minor Zephir Core corrections related to the Win32 build

* Use Zend Memory Allocator by default

* Added custom phpunit runner

* Skip some tests on unstable PHP version

* Refactor build process

* Debug PHPUnit

* Debug PHPUnit (2)

* Debug PHPUnit (3)

* Debug PHPUnit (4)

* Move fixtures to the common place

* Cleaned up CIs scripts

* Move fixtures to the common place (2)

* Cleaned up Travis CI script

* Use separated config for PHP 7.3 - 7.4

* Fix code style

* Simplified testing process

* Add PHP 7.4 to build matrix

* Enable code coverage report (#1675)

* Enable code coverage report

* Correct ExitDieTest

* Correct ExitDieTest (2)

* Bump version

* Fixed AppVeyor config
  • Loading branch information
sergeyklay authored Oct 19, 2018
1 parent ea79bd7 commit ab3551d
Show file tree
Hide file tree
Showing 84 changed files with 1,336 additions and 760 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
composer.lock
vendor/
build/

phpunit.xml
phpcs.xml

# Ignore for all projects based on Zephir
.temp/
Expand Down Expand Up @@ -52,6 +54,3 @@ runtime/run-tests.php
runtime/a.zep
runtime/index.php
runtime/parser.out

coverage.xml
clover.xml
149 changes: 54 additions & 95 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,43 @@
language: php

dist: trusty
# Change to `true' to enable debug mode
sudo: false

language: php
php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- master
- '7.3'
- '7.2'
- '7.1'
- '7.0'
- '5.6'

git:
depth: 1

compiler:
- gcc
- clang
addons:
apt:
packages:
- gdb
- lcov

env:
global:
- LD_LIBRARY_PATH="$TRAVIS_BUILD_DIR/build/lib":$LD_LIBRARY_PATH
- LIBRARY_PATH="$TRAVIS_BUILD_DIR/build/lib":$LIBRARY_PATH
- C_INCLUDE_PATH="$TRAVIS_BUILD_DIR/build/include"
- CFLAGS="-g3 -O0 -Wall -fvisibility=hidden"
- USE_ZEND_ALLOC=0
- ZEND_DONT_UNLOAD_MODULES=1
- REPORT_EXIT_STATUS=1
- PATH="${HOME}/bin:${PATH}"
- RE2C_VERSION="1.0.3"
- RE2C_VERSION="1.1.1"
- ZEPHIR_PARSER_VERSION="v1.1.2"
matrix:
- CC="gcc"
- CC="clang"
- DEFAULT_ZFLAGS="-Wnonexistent-function -Wnonexistent-class -Wunused-variable"
- DEFAULT_COMPOSER_FLAGS="--no-interaction --no-ansi --no-progress --no-suggest"
- REPORT_COVERAGE=1

matrix:
fast_finish: true
allow_failures:
- php: nightly
exclude:
- env: CC="gcc"
compiler: clang
- env: CC="clang"
compiler: gcc
include:
- env: CC="gcc"
php: nightly
compiler: gcc
- env: CC="clang"
php: nightly
compiler: clang
- env: CPPFLAGS=-DZEPHIR_RELEASE CC=gcc
php: '7.1'
- env: CPPFLAGS=-DZEPHIR_RELEASE CC=clang
php: '7.1'
- env: CPPFLAGS=-DZEPHIR_RELEASE CC=gcc
php: '7.2'
- env: CPPFLAGS=-DZEPHIR_RELEASE CC=clang
php: '7.2'
# There is still memory leaks
# and other issues like https://github.com/sebastianbergmann/phpunit/pull/3359
- php: 'master'

cache:
apt: true
Expand All @@ -71,74 +51,53 @@ cache:

before_install:
- if [[ ! -z "${GH_TOKEN}" ]]; then composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"; fi;
- $CC --version
- export PHP_MAJOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 1)"
- export PHP_MINOR="$(`phpenv which php` -r 'echo phpversion();' | cut -d '.' -f 2)"
- ulimit -c unlimited -S
- phpenv config-add ./unit-tests/ci/999-default.ini

install:
- composer install --prefer-source --no-suggest
- bash ./unit-tests/ci/install-re2c $RE2C_VERSION
- bash ./unit-tests/ci/install_zephir_parser.sh
- travis_retry composer install $DEFAULT_COMPOSER_FLAGS
- travis_retry gem install coveralls-lcov
- ./unit-tests/ci/install-re2c.sh $RE2C_VERSION
- ./unit-tests/ci/install-zephir-parser.sh
- ./install

before_script:
- $(phpenv which php) compiler.php help
- $(phpenv which php) compiler.php generate -Wnonexistent-function -Wnonexistent-class -Wunused-variable
- $(phpenv which php) compiler.php stubs
- $(phpenv which php) compiler.php api
- |
(
set -e
cd ext
$(phpenv which phpize)
./configure --silent --with-php-config=$(phpenv which php-config) --enable-test
make -j"$(getconf _NPROCESSORS_ONLN)"
make --silent install
)
#- ls -1 `$(phpenv which php-config) --extension-dir`
#- phpenv versions
- ulimit -c unlimited || true
# Uncomment to setting core dump
#- echo '/tmp/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern &> /dev/null
#- sudo chmod +s $(which gdb)
- ./unit-tests/ci/install-test-ext.sh

script:
- echo -e 'variables_order=EGPCS\nenable_dl=true' >> "$(phpenv root)/versions/$(phpenv version-name)/etc/php.ini"
- vendor/bin/phpcs --standard=PSR2 --report=emacs --extensions=php --warning-severity=0 Library/ unit-tests/Extension/ unit-tests/Zephir/
- | # Tests and coverage
./unit-tests/phpunit \
--not-exit \
-c phpunit.xml.dist \
--debug \
unit-tests/
- | # Check for memory leaks
valgrind \
--read-var-info=yes \
--error-exitcode=1 \
--fullpath-after= \
--track-origins=yes \
--leak-check=full \
--num-callers=20 \
--run-libc-freeres=no \
./unit-tests/phpunit \
--not-exit \
-c phpunit.xml.dist \
--no-coverage \
unit-tests/
- $(phpenv which php) unit-tests/microbench.php
- ./unit-tests/ci/run-unit-tests.sh

jobs:
include:
- stage: Static Code Analysis
php: 7.2
script:
- vendor/bin/phpcs
- stage: Compiller testing
php: 7.2
compiler: clang
env:
- CC=clang
- REPORT_COVERAGE=0
before_script:
- ./unit-tests/ci/install-test-ext.sh
script:
- ./unit-tests/ci/run-unit-tests.sh
- stage: Benchmark
php: 7.2
before_script:
- ./unit-tests/ci/install-test-ext.sh
script:
- phpenv config-rm xdebug.ini || true
- $(phpenv which php) -d extension=ext/modules/test.so unit-tests/microbench.php

after_success:
- if [[ ! -z "${CODECOV_TOKEN}" ]]; then bash <(curl -s https://codecov.io/bash); fi;
- ./unit-tests/ci/after-success.sh

after_failure:
# Uncomment to debug core dump
# - ./unit-tests/ci/after_failure.sh
- $(phpenv which php) -v
- $(phpenv which php) -m
- $(phpenv which php) -i
- ./unit-tests/ci/after-failure.sh

addons:
apt:
packages:
- valgrind
- gdb
notifications:
email: false
36 changes: 18 additions & 18 deletions Library/Backends/ZendEngine2/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,9 @@ protected function assignHelper($macro, $variableName, $value, CompilationContex
$copyStr = '';
if ($doCopy === true) {
$copyStr = ', 1';
} else if ($doCopy === false) {
} elseif ($doCopy === false) {
$copyStr = ', 0';
} else if (isset($doCopy)) {
} elseif (isset($doCopy)) {
$copyStr = ', ' . $doCopy;
}

Expand All @@ -644,9 +644,9 @@ protected function returnHelper($macro, $value, CompilationContext $context, $us
$copyStr = '';
if ($doCopy === true) {
$copyStr = ', 1';
} else if ($doCopy === false) {
} elseif ($doCopy === false) {
$copyStr = ', 0';
} else if (isset($doCopy)) {
} elseif (isset($doCopy)) {
$copyStr = ', ' . $doCopy;
}

Expand Down Expand Up @@ -736,7 +736,7 @@ public function addArrayEntry(Variable $variable, $key, $value, CompilationConte
$keyType = 'assoc';
if (!isset($key)) {
$keyType = 'append';
} else if ($key instanceof CompiledExpression) {
} elseif ($key instanceof CompiledExpression) {
$typeKey = $key->getType();
if ($typeKey == 'variable') {
$var = $context->symbolTable->getVariableForRead($key->getCode(), $context);
Expand Down Expand Up @@ -788,7 +788,7 @@ public function addArrayEntry(Variable $variable, $key, $value, CompilationConte
} else {
$valueStr = 'SL("' . $value->getCode() . '")';
}
} else if ($type == 'zval') {
} elseif ($type == 'zval') {
$valueStr = $this->getVariableCode($value);
} else {
$valueStr = $value->getCode();
Expand All @@ -797,7 +797,7 @@ public function addArrayEntry(Variable $variable, $key, $value, CompilationConte

if ($keyType == 'assoc') {
$output = 'add_assoc_' . $type . '_ex(' . $this->getVariableCode($variable) . ', ' . $keyStr . ', ' . $valueStr . $doCopy . ');';
} else if ($keyType == 'append') {
} elseif ($keyType == 'append') {
$output = 'zephir_array_append(' . $this->getVariableCodePointer($variable) . ', ' . $this->resolveValue($value, $context) . ', PH_SEPARATE, "' . Compiler::getShortUserPath($statement['file']) . '", ' . $statement['line'] . ');';
} else {
$output = 'add_index_' . $type . '(' . $this->getVariableCode($variable) . ', ' . $keyStr . ', '. $valueStr . $doCopy . ');';
Expand Down Expand Up @@ -832,7 +832,7 @@ public function updateArray(Variable $symbolVariable, $key, $value, CompilationC
default:
throw new CompilerException('updateArray: Found a variable with unsupported type ' . $key->getType());
}
} else if ($key instanceof CompiledExpression) {
} elseif ($key instanceof CompiledExpression) {
switch ($key->getType()) {
case 'string':
$compilationContext->codePrinter->output('zephir_array_update_string(' . $this->getVariableCodePointer($symbolVariable) . ', SL("' . $key->getCode() . '"), ' . $value . ', ' . $flags . ');');
Expand Down Expand Up @@ -924,7 +924,7 @@ public function arrayIsset(Variable $var, $resolvedExpr, $expression, Compilatio

if ($resolvedExpr->getType() == 'int' || $resolvedExpr->getType() == 'long') {
return new CompiledExpression('bool', 'zephir_array_isset_long(' . $this->getVariableCode($var) . ', ' . $this->getVariableCode($resolvedExpr) . ')', $expression);
} else if ($resolvedExpr->getType() == 'variable' || $resolvedExpr->getType() == 'string') {
} elseif ($resolvedExpr->getType() == 'variable' || $resolvedExpr->getType() == 'string') {
return new CompiledExpression('bool', 'zephir_array_isset(' . $this->getVariableCode($var) . ', ' . $this->getVariableCode($resolvedExpr) . ')', $expression);
}

Expand All @@ -938,7 +938,7 @@ public function arrayIssetFetch(Variable $target, Variable $var, $resolvedExpr,
if (!($resolvedExpr instanceof Variable)) {
if ($resolvedExpr->getType() == 'string') {
return new CompiledExpression('bool', 'zephir_array_isset_string_fetch(' . $code . ', SS("' . $resolvedExpr->getCode() . '"), '. $flags . ' TSRMLS_CC)', $expression);
} else if (in_array($resolvedExpr->getType(), array('int', 'uint', 'long'))) {
} elseif (in_array($resolvedExpr->getType(), array('int', 'uint', 'long'))) {
return new CompiledExpression('bool', 'zephir_array_isset_long_fetch(' . $code . ', ' . $resolvedExpr->getCode() . ', ' . $flags . ' TSRMLS_CC)', $expression);
} else {
$resolvedExpr = $context->symbolTable->getVariableForRead($resolvedExpr->getCode(), $context);
Expand All @@ -947,7 +947,7 @@ public function arrayIssetFetch(Variable $target, Variable $var, $resolvedExpr,

if ($resolvedExpr->getType() == 'int' || $resolvedExpr->getType() == 'long') {
return new CompiledExpression('bool', 'zephir_array_isset_long_fetch(' . $code . ', ' . $this->getVariableCode($resolvedExpr) . ', ' . $flags . ' TSRMLS_CC)', $expression);
} else if ($resolvedExpr->getType() == 'variable' || $resolvedExpr->getType() == 'string') {
} elseif ($resolvedExpr->getType() == 'variable' || $resolvedExpr->getType() == 'string') {
return new CompiledExpression('bool', 'zephir_array_isset_fetch(' . $code . ', ' . $this->getVariableCode($resolvedExpr) . ', ' . $flags . ' TSRMLS_CC)', $expression);
}
throw new CompilerException('arrayIssetFetch [' . $resolvedExpr->getType() . ']', $expression);
Expand Down Expand Up @@ -1133,17 +1133,17 @@ public function resolveValue($value, CompilationContext $context, $usePointer =
{
if ($value == 'null') {
$value = ($usePointer ? '&' : '') . 'ZEPHIR_GLOBAL(global_null)';
} else if ($value == 'true') {
} elseif ($value == 'true') {
$value = ($usePointer ? '&' : '') . 'ZEPHIR_GLOBAL(global_true)';
} else if ($value == 'false') {
} elseif ($value == 'false') {
$value = ($usePointer ? '&' : '') . 'ZEPHIR_GLOBAL(global_false)';
} else if ($value instanceof GlobalConstant) {
} elseif ($value instanceof GlobalConstant) {
return ($usePointer ? '&' : '') . $value->getName();
} else if ($value instanceof CompiledExpression) {
} elseif ($value instanceof CompiledExpression) {
if ($value->getType() == 'array') {
$var = $context->symbolTable->getVariableForWrite($value->getCode(), $context, null);
$value = $usePointer ? $this->getVariableCodePointer($var) : $this->getVariableCode($var);
} else if ($value->getType() == 'variable') {
} elseif ($value->getType() == 'variable') {
$value = $context->symbolTable->getVariableForWrite($value->getCode(), $context);
} else {
return $value->getCode();
Expand Down Expand Up @@ -1206,7 +1206,7 @@ public function callMethod($symbolVariable, Variable $variable, $methodName, $ca
}
if (!isset($symbolVariable)) {
$context->codePrinter->output('ZEPHIR_' . $macro . '(NULL, ' . $variable->getName() . ', ' . $methodName . ', ' . $cachePointer . $paramStr . ');');
} else if ($symbolVariable->getName() == 'return_value') {
} elseif ($symbolVariable->getName() == 'return_value') {
$context->codePrinter->output('ZEPHIR_RETURN_' . $macro . '(' . $variable->getName() . ', ' . $methodName . ', ' . $cachePointer . $paramStr . ');');
} else {
$context->codePrinter->output('ZEPHIR_' . $macro . '(&' . $symbolVariable->getName() . ', ' . $variable->getName() . ', ' . $methodName . ', ' . $cachePointer . $paramStr . ');');
Expand All @@ -1218,7 +1218,7 @@ public function callDynamicFunction($symbolVariable, Variable $variable, Compila
$paramStr = $params != null ? ', ' . join(', ', $params) : '';
if (!isset($symbolVariable)) {
$context->codePrinter->output('ZEPHIR_CALL_ZVAL_FUNCTION(NULL, ' . $this->getVariableCode($variable) . ', ' . $cache . ', ' . $cacheSlot . $paramStr . ');');
} else if ($symbolVariable->getName() == 'return_value') {
} elseif ($symbolVariable->getName() == 'return_value') {
$context->codePrinter->output('ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(' . $this->getVariableCode($variable) . ', ' . $cache . ', ' . $cacheSlot . $paramStr . ');');
} else {
$context->codePrinter->output('ZEPHIR_CALL_ZVAL_FUNCTION(' . $this->getVariableCodePointer($symbolVariable) . ', ' . $this->getVariableCode($variable) . ', ' . $cache . ', ' . $cacheSlot . $paramStr . ');');
Expand Down
12 changes: 6 additions & 6 deletions Library/Backends/ZendEngine3/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public function addArrayEntry(Variable $variable, $key, $value, CompilationConte

if (!isset($key)) {
$keyType = 'append';
} else if ($key instanceof CompiledExpression) {
} elseif ($key instanceof CompiledExpression) {
$typeKey = $key->getType();
if ($typeKey == 'variable') {
$var = $context->symbolTable->getVariableForRead($key->getCode(), $context);
Expand Down Expand Up @@ -468,15 +468,15 @@ public function addArrayEntry(Variable $variable, $key, $value, CompilationConte
} else {
$valueStr = 'SL("' . $value->getCode() . '")';
}
} else if ($type == 'zval') {
} elseif ($type == 'zval') {
$valueStr = $this->getVariableCode($value);
} else {
$valueStr = $value->getCode();
}

if ($keyType == 'assoc') {
$output = 'add_assoc_' . $type . '_ex(' . $this->getVariableCode($variable) . ', ' . $keyStr . ', ' . $valueStr . ');';
} else if ($keyType == 'append') {
} elseif ($keyType == 'append') {
$output = 'zephir_array_append(' . $this->getVariableCode($variable) . ', ' . $this->resolveValue($value, $context) . ', PH_SEPARATE, "' . Compiler::getShortUserPath($statement['file']) . '", ' . $statement['line'] . ');';
} else {
$output = 'add_index_' . $type . '(' . $this->getVariableCode($variable) . ', ' . $keyStr . ', '. $valueStr . ');';
Expand Down Expand Up @@ -635,7 +635,7 @@ public function resolveValue($value, CompilationContext $context, $usePointer =
if ($value instanceof CompiledExpression) {
if ($value->getType() == 'array') {
$value = $context->symbolTable->getVariableForWrite($value->getCode(), $context, null);
} else if ($value->getType() == 'variable') {
} elseif ($value->getType() == 'variable') {
$value = $context->symbolTable->getVariableForWrite($value->getCode(), $context);
} else {
return $value->getCode();
Expand Down Expand Up @@ -679,7 +679,7 @@ public function callMethod($symbolVariable, Variable $variable, $methodName, $ca
}
if (!isset($symbolVariable)) {
$context->codePrinter->output('ZEPHIR_' . $macro . '(NULL, ' . $this->getVariableCode($variable) . ', ' . $methodName . ', ' . $cachePointer . $paramStr . ');');
} else if ($symbolVariable->getName() == 'return_value') {
} elseif ($symbolVariable->getName() == 'return_value') {
$context->codePrinter->output('ZEPHIR_RETURN_' . $macro . '(' . $this->getVariableCode($variable) . ', ' . $methodName . ', ' . $cachePointer . $paramStr . ');');
} else {
$symbol = $this->getVariableCode($symbolVariable);
Expand Down Expand Up @@ -731,7 +731,7 @@ public function forStatement(Variable $exprVariable, $keyVariable, $variable, $d
if (isset($keyVariable) && isset($variable)) {
$macro = 'ZEND_HASH_' . $reverse . 'FOREACH_KEY_VAL';
$codePrinter->output($macro . '(Z_ARRVAL_P(' . $this->getVariableCode($exprVariable) . '), ' . $arrayNumKey->getName() . ', ' . $arrayStrKey->getName() . ', ' . $tempVariable->getName() . ')');
} else if (isset($keyVariable)) {
} elseif (isset($keyVariable)) {
$macro = 'ZEND_HASH_' . $reverse . 'FOREACH_KEY';
$codePrinter->output($macro . '(Z_ARRVAL_P(' . $this->getVariableCode($exprVariable) . '), ' . $arrayNumKey->getName() . ', ' . $arrayStrKey->getName() . ')');
} else {
Expand Down
Loading

0 comments on commit ab3551d

Please sign in to comment.