Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,32 @@ jobs:
# Runs a single command using the runners shell
- name: Build and test in docker
run: bash ci/test_dockerized.sh ${{ matrix.PHP_VERSION }}

# PHP 8.6 has no published `php:8.6` docker image yet, so it cannot be tested
# via the docker matrix above. Use setup-php's nightly build (compiled from
# php-src master) instead. This is allowed to fail since 8.6 is still in
# development.
build-nightly:
runs-on: ubuntu-latest
continue-on-error: true

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to not continue on error. Better to ignore the error than not see it at all.


strategy:
fail-fast: false
matrix:
include:
- PHP_VERSION: '8.6'

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.PHP_VERSION }}

- name: Build and test
run: |
phpize
EXTRA_CFLAGS='-Wall -Wextra -Wno-unused-parameter' ./configure
make -j2
NO_INTERACTION=1 REPORT_EXIT_STATUS=1 make test TESTS="--show-diff"
9 changes: 9 additions & 0 deletions php_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
105 changes: 105 additions & 0 deletions tests/php86_param_doc_comments.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
--TEST--
Doc comments on function/method parameters (PHP 8.6+)
--SKIPIF--
<?php if (PHP_VERSION_ID < 80600) die('skip PHP >=8.6 only'); ?>
--FILE--
<?php

require __DIR__ . '/../util.php';

$code = <<<'PHP'
<?php
function f(
/** doc for $a */
int $a,
$b,
/** doc for $c */
string $c = "x",
) {}

class C {
public string $p {
set(
/** doc for $value */
string $value
) { $this->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
Loading