Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Apr 30, 2018
2 parents 70e6efe + a958970 commit 19e935b
Show file tree
Hide file tree
Showing 36 changed files with 567 additions and 253 deletions.
31 changes: 24 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ env:
- 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"
- ZEPHIR_PARSER_VERSION="v1.1.1"
- ZEPHIR_PARSER_VERSION="v1.1.2"
matrix:
- CC="gcc"
- CC="clang"
Expand All @@ -48,41 +50,54 @@ matrix:
- 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

cache:
apt: true
ccache: true
timeout: 604800
directories:
- vendor
- $HOME/.ccache
- $HOME/.composer/cache
- $HOME/.local/opt/re2c
- $HOME/.cache/re2c

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)"

install:
- composer --prefer-source install
- composer install --prefer-source --no-suggest
- |
if [ "${PHP_MAJOR}.${PHP_MINOR}" != "5.5" ]; then
composer remove --dev phpunit/phpunit
composer require -q -n --dev --no-progress --prefer-dist --no-suggest "phpunit/phpunit:5.7.*"
fi
- bash ./unit-tests/ci/install-re2c $RE2C_VERSION
- bash ./unit-tests/ci/install_zephir_parser.sh
- ./install

before_script:
#- $CC --version
- $(phpenv which php) compiler.php help
- $(phpenv which php) compiler.php generate
- $(phpenv which php) compiler.php generate -Wnonexistent-function -Wnonexistent-class -Wunused-variable
- $(phpenv which php) compiler.php stubs
- $(phpenv which php) compiler.php api
- (cd ext; $(phpenv which phpize) && ./configure --silent --with-php-config=$(phpenv which php-config) --enable-test && make -j"$(getconf _NPROCESSORS_ONLN)" && make --silent install && phpenv config-add ../unit-tests/ci/test.ini)
#- ls -1 `$(phpenv which php-config) --extension-dir`
#- $(phpenv which php) -m
#- 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)
#- sudo chmod +s $(which gdb)

script:
- echo 'variables_order=EGPCS' >> "$(phpenv root)/versions/$(phpenv version-name)/etc/php.ini"
Expand All @@ -94,6 +109,7 @@ script:
--fullpath-after= \
--track-origins=yes \
--leak-check=full \
--num-callers=20 \
--run-libc-freeres=no \
./unit-tests/phpunit \
--not-exit \
Expand All @@ -108,6 +124,7 @@ after_success:
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

Expand Down
66 changes: 40 additions & 26 deletions Library/ClassMethodParameters.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
<?php

/*
+----------------------------------------------------------------------+
| Zephir Language |
+----------------------------------------------------------------------+
| Copyright (c) 2013-2017 Zephir Team |
+----------------------------------------------------------------------+
| This source file is subject to version 1.0 of the MIT license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zephir-lang.com/license |
| |
| If you did not receive a copy of the MIT license and are unable |
| to obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
+--------------------------------------------------------------------------+
| Zephir |
| Copyright (c) 2013-present Zephir Team (https://zephir-lang.com/) |
| |
| This source file is subject the MIT license, that is bundled with this |
| package in the file LICENSE, and is available through the world-wide-web |
| at the following url: https://zephir-lang.com/license.html |
+--------------------------------------------------------------------------+
*/

namespace Zephir;

use Zephir\Compiler\CompilerException;

/**
* ClassMethodParameters
* Zephir\ClassMethodParameters
*
* Represents the parameters defined in a method
*/
class ClassMethodParameters implements \Countable, \Iterator
class ClassMethodParameters implements \Countable, \Iterator, \ArrayAccess
{
private $_parameters = array();
private $parameters = [];

private $_position = 0;
private $position = 0;

/**
* ClassMethodParameters constructor.
Expand All @@ -50,7 +44,7 @@ public function __construct(array $parameters)
}
}

$this->_parameters = $parameters;
$this->parameters = $parameters;
}

/**
Expand All @@ -60,39 +54,59 @@ public function __construct(array $parameters)
*/
public function getParameters()
{
return $this->_parameters;
return $this->parameters;
}

/**
* @return int
*/
public function count()
{
return count($this->_parameters);
return count($this->parameters);
}

public function rewind()
{
$this->_position = 0;
$this->position = 0;
}

public function key()
{
return $this->_position;
return $this->position;
}

public function valid()
{
return isset($this->_parameters[$this->_position]);
return isset($this->parameters[$this->position]);
}

public function current()
{
return $this->_parameters[$this->_position];
return $this->parameters[$this->position];
}

public function next()
{
$this->_position++;
$this->position++;
}

public function offsetExists($offset)
{
return isset($this->parameters[$offset]);
}

public function offsetGet($offset)
{
return $this->parameters[$offset];
}

public function offsetSet($offset, $value)
{
$this->parameters[$offset] = $value;
}

public function offsetUnset($offset)
{
unset($this->parameters[$offset]);
}
}
11 changes: 5 additions & 6 deletions Library/CompilationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class CompilationContext
public $classDefinition;

/**
* Current method being compiled
* Current method or function that being compiled
*
* @var ClassMethod
* @var ClassMethod|FunctionDefinition
*/
public $currentMethod;

Expand Down Expand Up @@ -128,7 +128,7 @@ class CompilationContext
*
* @var array
*/
public $cycleBlocks = array();
public $cycleBlocks = [];

/**
* The current branch, variables declared in conditional branches
Expand Down Expand Up @@ -201,9 +201,8 @@ class CompilationContext
*/
public function getFullName($className)
{
$namespace = (isset($this->currentMethod) && $this->currentMethod instanceof FunctionDefinition) ?
$this->currentMethod->getNamespace() :
$this->classDefinition->getNamespace();
$isFunction = $this->currentMethod && $this->currentMethod instanceof FunctionDefinition;
$namespace = $isFunction ? $this->currentMethod->getNamespace() : $this->classDefinition->getNamespace();

return Utils::getFullName($className, $namespace, $this->aliasManager);
}
Expand Down
2 changes: 1 addition & 1 deletion Library/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
class Compiler
{
const VERSION = '0.10.8';
const VERSION = '0.10.9';

public $parserCompiled = false;

Expand Down
2 changes: 1 addition & 1 deletion Library/CompilerFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public function preCompile(Compiler $compiler)
if (!$this->_external) {
$expectedPath = strtolower(str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR . $name) . '.zep';
if (strtolower($this->_filePath) != $expectedPath) {
$className = str_replace('\\', '/', $namespace) . '\\' . $name;
$className = $namespace . '\\' . $name;
$message = 'Unexpected class name ' . $className . ' in file: ' . $this->_filePath . ', expected: ' . $expectedPath;
throw new CompilerException($message);
}
Expand Down
Loading

0 comments on commit 19e935b

Please sign in to comment.