diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ce5c28..24814d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,26 +22,32 @@ jobs: # See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix strategy: + # 8.6 is built from php-src master, so a failure there should not cancel + # the other versions. fail-fast: false matrix: - include: - # NOTE: If this is not quoted, the yaml parser will convert 8.0 to the number 8, - # and the docker image `php:8` is the latest minor version of php 8.x (8.1). - - PHP_VERSION: '7.2' - - PHP_VERSION: '7.3' - - PHP_VERSION: '7.4' - - PHP_VERSION: '8.0' - - PHP_VERSION: '8.1' - - PHP_VERSION: '8.2' - - PHP_VERSION: '8.3' - - PHP_VERSION: '8.4' - - PHP_VERSION: '8.5' + # NOTE: Quoted so the yaml parser does not turn e.g. 8.0 into the number 8. + PHP_VERSION: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6'] # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - # Runs a single command using the runners shell - - name: Build and test in docker - run: bash ci/test_dockerized.sh ${{ matrix.PHP_VERSION }} + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.PHP_VERSION }} + tools: pecl + + - name: Build + run: | + phpize + EXTRA_CFLAGS='-Wall -Wextra -Wno-unused-parameter' ./configure + make -j2 + + - name: Test + run: NO_INTERACTION=1 REPORT_EXIT_STATUS=1 make test TESTS="--show-diff" + + - name: Verify package.xml is valid + run: pecl package diff --git a/ci/Dockerfile b/ci/Dockerfile deleted file mode 100644 index 1a6343b..0000000 --- a/ci/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -ARG PHP_VERSION -FROM php:$PHP_VERSION -WORKDIR /php-ast -ADD *.c *.h *.php config.m4 config.w32 package.xml LICENSE README.md ./ - -# Assume compilation will be the time consuming step. -# Add tests after compiling so that it's faster to update tests and re-run them locally. -# -# Use the same CFLAGS used to build the docker image but also check for warnings (this will emit warnings but not fail the build) -RUN phpize && EXTRA_CFLAGS='-Wall -Wextra -Wno-unused-parameter' ./configure && make -j2 && make install -RUN docker-php-ext-enable ast -ADD tests ./tests -ADD ci ./ci diff --git a/ci/test_dockerized.sh b/ci/test_dockerized.sh deleted file mode 100755 index e9ce09b..0000000 --- a/ci/test_dockerized.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -if [ $# != 1 ]; then - echo "Usage: $0 PHP_VERSION" 1>&2 - echo "e.g. $0 8.0 or $0 8.0-alpine" 1>&2 - echo "The PHP_VERSION is the version of the php docker image to use" 1>&2 - exit 1 -fi -# -x Exit immediately if any command fails -# -e Echo all commands being executed. -# -u fail for undefined variables -set -xeu -PHP_VERSION=$1 -# uppercase is not allowed in image names, only in tags -DOCKER_IMAGE=php-ast-test-runner:$PHP_VERSION -docker build --build-arg="PHP_VERSION=$PHP_VERSION" --tag="$DOCKER_IMAGE" -f ci/Dockerfile . -docker run --rm $DOCKER_IMAGE ci/test_inner.sh diff --git a/ci/test_inner.sh b/ci/test_inner.sh deleted file mode 100755 index 47be172..0000000 --- a/ci/test_inner.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -# -x Exit immediately if any command fails -# -e Echo all commands being executed. -# -u fail for undefined variables -set -xeu -echo "Run tests in docker" -REPORT_EXIT_STATUS=1 php ./run-tests.php -P -q --show-diff -echo "Test that package.xml is valid" -pecl package diff --git a/php_ast.h b/php_ast.h index efecc21..06756ed 100644 --- a/php_ast.h +++ b/php_ast.h @@ -99,6 +99,15 @@ extern ast_str_globals str_globals; # define ZEND_AST_CLONE 0x1fc #endif +#if PHP_VERSION_ID >= 80600 +/* ZEND_AST_METHOD_REFERENCE was renamed to ZEND_AST_TRAIT_METHOD_REFERENCE. */ +# define ZEND_AST_METHOD_REFERENCE ZEND_AST_TRAIT_METHOD_REFERENCE +/* The _throw() ZPP variants were removed; plain ZPP now always throws. + * ZEND_PARSE_PARAMS_THROW is gone, so a flag of 0 yields the throwing default. */ +# define ZEND_PARSE_PARAMS_THROW 0 +# define zend_parse_parameters_throw zend_parse_parameters +#endif + /* Pretend it still exists */ # define ZEND_AST_LIST ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 1) diff --git a/tests/php86_param_doc_comments.phpt b/tests/php86_param_doc_comments.phpt new file mode 100644 index 0000000..ae11fd1 --- /dev/null +++ b/tests/php86_param_doc_comments.phpt @@ -0,0 +1,105 @@ +--TEST-- +Doc comments on function/method parameters (PHP 8.6+) +--SKIPIF-- +=8.6 only'); ?> +--FILE-- +p = $value; } + } +} +PHP; + +echo ast_dump(ast\parse_code($code, $version=120)), "\n"; +--EXPECT-- +AST_STMT_LIST + 0: AST_FUNC_DECL + name: "f" + docComment: null + params: AST_PARAM_LIST + 0: AST_PARAM + type: AST_TYPE + flags: TYPE_LONG (4) + name: "a" + default: null + attributes: null + docComment: "/** doc for $a */" + hooks: null + 1: AST_PARAM + type: null + name: "b" + default: null + attributes: null + docComment: null + hooks: null + 2: AST_PARAM + type: AST_TYPE + flags: TYPE_STRING (6) + name: "c" + default: "x" + attributes: null + docComment: "/** doc for $c */" + hooks: null + stmts: AST_STMT_LIST + returnType: null + attributes: null + __declId: 0 + 1: AST_CLASS + name: "C" + docComment: null + extends: null + implements: null + stmts: AST_STMT_LIST + 0: AST_PROP_GROUP + flags: MODIFIER_PUBLIC (1) + type: AST_TYPE + flags: TYPE_STRING (6) + props: AST_PROP_DECL + 0: AST_PROP_ELEM + name: "p" + default: null + docComment: null + hooks: AST_STMT_LIST + 0: AST_PROPERTY_HOOK + name: "set" + docComment: null + params: AST_PARAM_LIST + 0: AST_PARAM + type: AST_TYPE + flags: TYPE_STRING (6) + name: "value" + default: null + attributes: null + docComment: "/** doc for $value */" + hooks: null + stmts: AST_STMT_LIST + 0: AST_ASSIGN + var: AST_PROP + expr: AST_VAR + name: "this" + prop: "p" + expr: AST_VAR + name: "value" + attributes: null + __declId: 1 + attributes: null + attributes: null + type: null + __declId: 2