diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | REFLECTION | 254 | ||||
-rw-r--r-- | php-ast.spec | 182 |
3 files changed, 440 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..91b0fd5 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../common/Makefile + diff --git a/REFLECTION b/REFLECTION new file mode 100644 index 0000000..aa0f5ab --- /dev/null +++ b/REFLECTION @@ -0,0 +1,254 @@ +Extension [ <persistent> extension #74 ast version 0.1.0-dev ] { + + - Constants [169] { + Constant [ integer ast\AST_FUNC_DECL ] { 66 } + Constant [ integer ast\AST_CLOSURE ] { 67 } + Constant [ integer ast\AST_METHOD ] { 68 } + Constant [ integer ast\AST_CLASS ] { 69 } + Constant [ integer ast\AST_ARG_LIST ] { 128 } + Constant [ integer ast\AST_LIST ] { 129 } + Constant [ integer ast\AST_ARRAY ] { 130 } + Constant [ integer ast\AST_ENCAPS_LIST ] { 131 } + Constant [ integer ast\AST_EXPR_LIST ] { 132 } + Constant [ integer ast\AST_STMT_LIST ] { 133 } + Constant [ integer ast\AST_IF ] { 134 } + Constant [ integer ast\AST_SWITCH_LIST ] { 135 } + Constant [ integer ast\AST_CATCH_LIST ] { 136 } + Constant [ integer ast\AST_PARAM_LIST ] { 137 } + Constant [ integer ast\AST_CLOSURE_USES ] { 138 } + Constant [ integer ast\AST_PROP_DECL ] { 139 } + Constant [ integer ast\AST_CONST_DECL ] { 140 } + Constant [ integer ast\AST_CLASS_CONST_DECL ] { 141 } + Constant [ integer ast\AST_NAME_LIST ] { 142 } + Constant [ integer ast\AST_TRAIT_ADAPTATIONS ] { 143 } + Constant [ integer ast\AST_USE ] { 144 } + Constant [ integer ast\AST_MAGIC_CONST ] { 0 } + Constant [ integer ast\AST_TYPE ] { 1 } + Constant [ integer ast\AST_VAR ] { 256 } + Constant [ integer ast\AST_CONST ] { 257 } + Constant [ integer ast\AST_UNPACK ] { 258 } + Constant [ integer ast\AST_UNARY_PLUS ] { 259 } + Constant [ integer ast\AST_UNARY_MINUS ] { 260 } + Constant [ integer ast\AST_CAST ] { 261 } + Constant [ integer ast\AST_EMPTY ] { 262 } + Constant [ integer ast\AST_ISSET ] { 263 } + Constant [ integer ast\AST_SILENCE ] { 264 } + Constant [ integer ast\AST_SHELL_EXEC ] { 265 } + Constant [ integer ast\AST_CLONE ] { 266 } + Constant [ integer ast\AST_EXIT ] { 267 } + Constant [ integer ast\AST_PRINT ] { 268 } + Constant [ integer ast\AST_INCLUDE_OR_EVAL ] { 269 } + Constant [ integer ast\AST_UNARY_OP ] { 270 } + Constant [ integer ast\AST_PRE_INC ] { 271 } + Constant [ integer ast\AST_PRE_DEC ] { 272 } + Constant [ integer ast\AST_POST_INC ] { 273 } + Constant [ integer ast\AST_POST_DEC ] { 274 } + Constant [ integer ast\AST_YIELD_FROM ] { 275 } + Constant [ integer ast\AST_GLOBAL ] { 276 } + Constant [ integer ast\AST_UNSET ] { 277 } + Constant [ integer ast\AST_RETURN ] { 278 } + Constant [ integer ast\AST_LABEL ] { 279 } + Constant [ integer ast\AST_REF ] { 280 } + Constant [ integer ast\AST_HALT_COMPILER ] { 281 } + Constant [ integer ast\AST_ECHO ] { 282 } + Constant [ integer ast\AST_THROW ] { 283 } + Constant [ integer ast\AST_GOTO ] { 284 } + Constant [ integer ast\AST_BREAK ] { 285 } + Constant [ integer ast\AST_CONTINUE ] { 286 } + Constant [ integer ast\AST_DIM ] { 512 } + Constant [ integer ast\AST_PROP ] { 513 } + Constant [ integer ast\AST_STATIC_PROP ] { 514 } + Constant [ integer ast\AST_CALL ] { 515 } + Constant [ integer ast\AST_CLASS_CONST ] { 516 } + Constant [ integer ast\AST_ASSIGN ] { 517 } + Constant [ integer ast\AST_ASSIGN_REF ] { 518 } + Constant [ integer ast\AST_ASSIGN_OP ] { 519 } + Constant [ integer ast\AST_BINARY_OP ] { 520 } + Constant [ integer ast\AST_GREATER ] { 521 } + Constant [ integer ast\AST_GREATER_EQUAL ] { 522 } + Constant [ integer ast\AST_AND ] { 523 } + Constant [ integer ast\AST_OR ] { 524 } + Constant [ integer ast\AST_ARRAY_ELEM ] { 525 } + Constant [ integer ast\AST_NEW ] { 526 } + Constant [ integer ast\AST_INSTANCEOF ] { 527 } + Constant [ integer ast\AST_YIELD ] { 528 } + Constant [ integer ast\AST_COALESCE ] { 529 } + Constant [ integer ast\AST_STATIC ] { 530 } + Constant [ integer ast\AST_WHILE ] { 531 } + Constant [ integer ast\AST_DO_WHILE ] { 532 } + Constant [ integer ast\AST_IF_ELEM ] { 533 } + Constant [ integer ast\AST_SWITCH ] { 534 } + Constant [ integer ast\AST_SWITCH_CASE ] { 535 } + Constant [ integer ast\AST_DECLARE ] { 536 } + Constant [ integer ast\AST_CONST_ELEM ] { 537 } + Constant [ integer ast\AST_USE_TRAIT ] { 538 } + Constant [ integer ast\AST_TRAIT_PRECEDENCE ] { 539 } + Constant [ integer ast\AST_METHOD_REFERENCE ] { 540 } + Constant [ integer ast\AST_NAMESPACE ] { 541 } + Constant [ integer ast\AST_USE_ELEM ] { 542 } + Constant [ integer ast\AST_TRAIT_ALIAS ] { 543 } + Constant [ integer ast\AST_GROUP_USE ] { 544 } + Constant [ integer ast\AST_METHOD_CALL ] { 768 } + Constant [ integer ast\AST_STATIC_CALL ] { 769 } + Constant [ integer ast\AST_CONDITIONAL ] { 770 } + Constant [ integer ast\AST_TRY ] { 771 } + Constant [ integer ast\AST_CATCH ] { 772 } + Constant [ integer ast\AST_PARAM ] { 773 } + Constant [ integer ast\AST_PROP_ELEM ] { 774 } + Constant [ integer ast\AST_FOR ] { 1024 } + Constant [ integer ast\AST_FOREACH ] { 1025 } + Constant [ integer ast\AST_NAME ] { 2048 } + Constant [ integer ast\AST_CLOSURE_VAR ] { 2049 } + Constant [ integer ast\flags\NAME_FQ ] { 0 } + Constant [ integer ast\flags\NAME_NOT_FQ ] { 1 } + Constant [ integer ast\flags\NAME_RELATIVE ] { 2 } + Constant [ integer ast\flags\MODIFIER_PUBLIC ] { 256 } + Constant [ integer ast\flags\MODIFIER_PROTECTED ] { 512 } + Constant [ integer ast\flags\MODIFIER_PRIVATE ] { 1024 } + Constant [ integer ast\flags\MODIFIER_STATIC ] { 1 } + Constant [ integer ast\flags\MODIFIER_ABSTRACT ] { 2 } + Constant [ integer ast\flags\MODIFIER_FINAL ] { 4 } + Constant [ integer ast\flags\RETURNS_REF ] { 67108864 } + Constant [ integer ast\flags\CLASS_ABSTRACT ] { 32 } + Constant [ integer ast\flags\CLASS_FINAL ] { 4 } + Constant [ integer ast\flags\CLASS_TRAIT ] { 128 } + Constant [ integer ast\flags\CLASS_INTERFACE ] { 64 } + Constant [ integer ast\flags\CLASS_ANONYMOUS ] { 256 } + Constant [ integer ast\flags\PARAM_REF ] { 1 } + Constant [ integer ast\flags\PARAM_VARIADIC ] { 2 } + Constant [ integer ast\flags\TYPE_NULL ] { 1 } + Constant [ integer ast\flags\TYPE_BOOL ] { 13 } + Constant [ integer ast\flags\TYPE_LONG ] { 4 } + Constant [ integer ast\flags\TYPE_DOUBLE ] { 5 } + Constant [ integer ast\flags\TYPE_STRING ] { 6 } + Constant [ integer ast\flags\TYPE_ARRAY ] { 7 } + Constant [ integer ast\flags\TYPE_OBJECT ] { 8 } + Constant [ integer ast\flags\TYPE_CALLABLE ] { 14 } + Constant [ integer ast\flags\UNARY_BOOL_NOT ] { 13 } + Constant [ integer ast\flags\UNARY_BITWISE_NOT ] { 12 } + Constant [ integer ast\flags\UNARY_SILENCE ] { 260 } + Constant [ integer ast\flags\UNARY_PLUS ] { 261 } + Constant [ integer ast\flags\UNARY_MINUS ] { 262 } + Constant [ integer ast\flags\BINARY_BOOL_AND ] { 259 } + Constant [ integer ast\flags\BINARY_BOOL_OR ] { 258 } + Constant [ integer ast\flags\BINARY_BOOL_XOR ] { 14 } + Constant [ integer ast\flags\BINARY_BITWISE_OR ] { 9 } + Constant [ integer ast\flags\BINARY_BITWISE_AND ] { 10 } + Constant [ integer ast\flags\BINARY_BITWISE_XOR ] { 11 } + Constant [ integer ast\flags\BINARY_CONCAT ] { 8 } + Constant [ integer ast\flags\BINARY_ADD ] { 1 } + Constant [ integer ast\flags\BINARY_SUB ] { 2 } + Constant [ integer ast\flags\BINARY_MUL ] { 3 } + Constant [ integer ast\flags\BINARY_DIV ] { 4 } + Constant [ integer ast\flags\BINARY_MOD ] { 5 } + Constant [ integer ast\flags\BINARY_POW ] { 166 } + Constant [ integer ast\flags\BINARY_SHIFT_LEFT ] { 6 } + Constant [ integer ast\flags\BINARY_SHIFT_RIGHT ] { 7 } + Constant [ integer ast\flags\BINARY_IS_IDENTICAL ] { 15 } + Constant [ integer ast\flags\BINARY_IS_NOT_IDENTICAL ] { 16 } + Constant [ integer ast\flags\BINARY_IS_EQUAL ] { 17 } + Constant [ integer ast\flags\BINARY_IS_NOT_EQUAL ] { 18 } + Constant [ integer ast\flags\BINARY_IS_SMALLER ] { 19 } + Constant [ integer ast\flags\BINARY_IS_SMALLER_OR_EQUAL ] { 20 } + Constant [ integer ast\flags\BINARY_IS_GREATER ] { 256 } + Constant [ integer ast\flags\BINARY_IS_GREATER_OR_EQUAL ] { 257 } + Constant [ integer ast\flags\BINARY_SPACESHIP ] { 170 } + Constant [ integer ast\flags\ASSIGN_BITWISE_OR ] { 31 } + Constant [ integer ast\flags\ASSIGN_BITWISE_AND ] { 32 } + Constant [ integer ast\flags\ASSIGN_BITWISE_XOR ] { 33 } + Constant [ integer ast\flags\ASSIGN_CONCAT ] { 30 } + Constant [ integer ast\flags\ASSIGN_ADD ] { 23 } + Constant [ integer ast\flags\ASSIGN_SUB ] { 24 } + Constant [ integer ast\flags\ASSIGN_MUL ] { 25 } + Constant [ integer ast\flags\ASSIGN_DIV ] { 26 } + Constant [ integer ast\flags\ASSIGN_MOD ] { 27 } + Constant [ integer ast\flags\ASSIGN_POW ] { 167 } + Constant [ integer ast\flags\ASSIGN_SHIFT_LEFT ] { 28 } + Constant [ integer ast\flags\ASSIGN_SHIFT_RIGHT ] { 29 } + Constant [ integer ast\flags\EXEC_EVAL ] { 1 } + Constant [ integer ast\flags\EXEC_INCLUDE ] { 2 } + Constant [ integer ast\flags\EXEC_INCLUDE_ONCE ] { 4 } + Constant [ integer ast\flags\EXEC_REQUIRE ] { 8 } + Constant [ integer ast\flags\EXEC_REQUIRE_ONCE ] { 16 } + } + + - Functions { + Function [ <internal:ast> function ast\parse_file ] { + + - Parameters [2] { + Parameter #0 [ <required> $filename ] + Parameter #1 [ <optional> $version ] + } + } + Function [ <internal:ast> function ast\parse_code ] { + + - Parameters [3] { + Parameter #0 [ <required> $code ] + Parameter #1 [ <optional> $version ] + Parameter #2 [ <optional> $filename ] + } + } + Function [ <internal:ast> function ast\get_kind_name ] { + + - Parameters [1] { + Parameter #0 [ <required> $kind ] + } + } + Function [ <internal:ast> function ast\kind_uses_flags ] { + + - Parameters [1] { + Parameter #0 [ <required> $kind ] + } + } + } + + - Classes [2] { + Class [ <internal:ast> class ast\Node ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ <default> public $kind ] + Property [ <default> public $flags ] + Property [ <default> public $lineno ] + Property [ <default> public $children ] + } + + - Methods [0] { + } + } + + Class [ <internal:ast> class ast\Node\Decl extends ast\Node ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [7] { + Property [ <default> public $kind ] + Property [ <default> public $flags ] + Property [ <default> public $lineno ] + Property [ <default> public $children ] + Property [ <default> public $endLineno ] + Property [ <default> public $name ] + Property [ <default> public $docComment ] + } + + - Methods [0] { + } + } + } +} + diff --git a/php-ast.spec b/php-ast.spec new file mode 100644 index 0000000..fc53e2f --- /dev/null +++ b/php-ast.spec @@ -0,0 +1,182 @@ +# remirepo spec file for php-ast +# +# Copyright (c) 2015 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# +%{?scl: %scl_package php-ast} +%{!?php_inidir: %global php_inidir %{_sysconfdir}/php.d} +%{!?__php: %global __php %{_bindir}/php} + +%global gh_commit ac969d783a2cd33bca5b75ec647900f3abe23da3 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner nikic +%global gh_project php-ast +%global gh_date 20151021 +%global pecl_name ast +%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} +%global ini_name 40-%{pecl_name}.ini + +Summary: Abstract Syntax Tree +Name: %{?scl_prefix}php-ast +Version: 0.1.0 +%if 0%{?gh_date:1} +Release: 0.1.%{gh_date}git%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +%else +Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +%endif +License: PHP +Group: Development/Languages +URL: https://github.com/%{gh_owner}/%{gh_project} +Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{gh_short}.tar.gz + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +BuildRequires: %{?scl_prefix}php-devel > 7 + +Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} +Requires: %{?scl_prefix}php(api) = %{php_core_api} +%{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}} + +%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} +%if "%{php_version}" > "7.0" +Obsoletes: php70u-%{pecl_name} <= %{version} +Obsoletes: php70w-%{pecl_name} <= %{version} +%endif +%endif + +%if 0%{?fedora} < 20 && 0%{?rhel} < 7 +# Filter shared private +%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$} +%{?filter_setup} +%endif + + +%description +This extension exposes the abstract syntax tree generated by PHP 7. + +This extension is experimental and the representation of the syntax tree is not final. + +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection (%{scl} by %{?scl_vendor}%{!?scl_vendor:rh})}. + + +%prep +%setup -qc +mv %{gh_project}-%{gh_commit} NTS + +cd NTS + +# When this file is removed, fix description +[ -f EXPERIMENTAL ] || exit 1 + +# Fix +sed -e '/PHP_AST_VERSION/s/0.1.0/0.1.0-dev/' -i php_ast.h + +# Sanity check, really often broken +extver=$(sed -n '/#define PHP_AST_VERSION/{s/.* "//;s/".*$//;p}' php_ast.h) +if test "x${extver}" != "x%{version}%{?gh_date:-dev}"; then + : Error: Upstream extension version is ${extver}, expecting %{version}%{?gh_date:-dev}. + exit 1 +fi +cd .. + +%if %{with_zts} +# duplicate for ZTS build +cp -pr NTS ZTS +%endif + +# Drop in the bit of configuration +cat << 'EOF' | tee %{ini_name} +; Enable '%{summary}' extension module +extension = %{pecl_name}.so +EOF + + +%build +cd NTS +%{_bindir}/phpize +%configure \ + --with-php-config=%{_bindir}/php-config \ + --enable-ast +make %{?_smp_mflags} + +%if %{with_zts} +cd ../ZTS +%{_bindir}/zts-phpize +%configure \ + --with-php-config=%{_bindir}/zts-php-config \ + --enable-ast +make %{?_smp_mflags} +%endif + + +%install +rm -rf %{buildroot} +# Install the NTS stuff +make -C NTS install INSTALL_ROOT=%{buildroot} +install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} + +%if %{with_zts} +# Install the ZTS stuff +make -C ZTS install INSTALL_ROOT=%{buildroot} +install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name} +%endif + + + +%check +cd NTS +: Minimal load test for NTS extension +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ + --modules | grep %{pecl_name} + +: Upstream test suite for NTS extension +TEST_PHP_EXECUTABLE=%{__php} \ +TEST_PHP_ARGS="-n -d error_reporting=32759 -d extension_dir=$PWD/modules -d extension=%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=0 \ +%{__php} -n run-tests.php --show-diff || : ignore + +%if %{with_zts} +cd ../ZTS +: Minimal load test for ZTS extension +%{__ztsphp} --no-php-ini \ + --define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \ + --modules | grep %{pecl_name} + +: Upstream test suite for ZTS extension +TEST_PHP_EXECUTABLE=%{__ztsphp} \ +TEST_PHP_ARGS="-n -d error_reporting=32759 -d extension_dir=$PWD/modules -d extension=%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=0 \ +%{__ztsphp} -n run-tests.php --show-diff +%endif + + +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%{!?_licensedir:%global license %%doc} +%license NTS/LICENSE +%doc NTS/EXPERIMENTAL +%doc NTS/README.md +%doc NTS/generate_ast_data.php +%doc NTS/util.php + +%config(noreplace) %{php_inidir}/%{ini_name} +%{php_extdir}/%{pecl_name}.so + +%if %{with_zts} +%config(noreplace) %{php_ztsinidir}/%{ini_name} +%{php_ztsextdir}/%{pecl_name}.so +%endif + + +%changelog +* Wed Oct 28 2015 Remi Collet <remi@fedoraproject.org> - 0.1.0-0.1.20151021gitac969d7 +- new package, version 0.1.0dev
\ No newline at end of file |