├── .appveyor.yml ├── .clang-format.example ├── .dockerignore ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE.md └── workflows │ └── main.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── LICENSE.ZEND ├── Makefile.frag ├── PROPERTY_MANIPULATION.md ├── README.md ├── UPGRADING_TO_3.md ├── ci ├── Dockerfile ├── Dockerfile.valgrind ├── g++-32.sh ├── gcc-32.sh ├── generate_php_install_dir.sh ├── get_global_php_version.sh ├── install_php_custom.sh ├── install_php_nts.sh ├── php.ini ├── print_php_int_max.php ├── run-tests-parallel.php ├── run_tests.sh ├── run_tests_with_valgrind.sh ├── test_dockerized.sh ├── test_dockerized_valgrind.sh ├── test_inner.sh ├── test_inner_valgrind.sh └── wipe_travis_cache.sh ├── config.m4 ├── config.w32 ├── package.xml ├── php_runkit7.h ├── php_runkit_hash.h ├── php_runkit_zend_execute_API.h ├── php_runkit_zval.h ├── runkit-api.php ├── runkit.c ├── runkit.h ├── runkit7.stub.php ├── runkit7_arginfo.h ├── runkit_classes.c ├── runkit_common.c ├── runkit_constants.c ├── runkit_functions.c ├── runkit_methods.c ├── runkit_props.c ├── runkit_zend_execute_API.c └── tests ├── _fcgi.inc ├── _fpm_include.inc ├── _fpm_skipif.inc ├── bug10053.phpt ├── bug10300.phpt ├── bug56662.phpt ├── bug56976.phpt ├── bug57249.inc ├── bug57649.inc ├── bug57658.phpt ├── namespaces.phpt ├── runkit_add_magic_methods.phpt ├── runkit_add_magic_serialize_method_ignored_for_common_classes.phpt ├── runkit_add_old_style_ctor.phpt ├── runkit_add_old_style_ctor1.phpt ├── runkit_add_old_style_ctor_by_adopting.phpt ├── runkit_add_old_style_ctor_by_copying.phpt ├── runkit_adopt_emancipate_and_inheritance.phpt ├── runkit_and_superglobals.phpt ├── runkit_arginfo.phpt ├── runkit_class_adopt.phpt ├── runkit_class_adopt_and_properties.phpt ├── runkit_class_emancipate.phpt ├── runkit_class_emancipate_and_reflection.phpt ├── runkit_constant_add.phpt ├── runkit_constant_add_array.phpt ├── runkit_constant_add_array_alias.phpt ├── runkit_constant_add_array_to_class.phpt ├── runkit_constant_add_object_php81.phpt ├── runkit_constant_add_protected.phpt ├── runkit_constant_add_protected_alias.phpt ├── runkit_constant_add_to_class.phpt ├── runkit_constant_redefine.phpt ├── runkit_constant_redefine_in_class.phpt ├── runkit_constant_redefine_protected_across_file.inc ├── runkit_constant_redefine_protected_across_file.phpt ├── runkit_constant_remove.phpt ├── runkit_constant_remove_from_class.phpt ├── runkit_constant_remove_from_class_without_inlining.phpt ├── runkit_constant_remove_from_ns.phpt ├── runkit_constants_manipulations_and_cache.phpt ├── runkit_default_property_add.phpt ├── runkit_default_property_add_and_remove_for_class_with_dynamic_properties.phpt ├── runkit_default_property_add_and_remove_for_class_with_dynamic_properties_overriding_in_objects.phpt ├── runkit_default_property_add_instance.phpt ├── runkit_default_property_add_overriding_objects.phpt ├── runkit_default_property_add_to_subclasses.phpt ├── runkit_default_property_add_to_subclasses_overriding_objects.phpt ├── runkit_default_property_remove.phpt ├── runkit_default_property_remove_and_add_for_class_with_dynamic_properties.phpt ├── runkit_default_property_remove_and_add_for_class_with_dynamic_properties_overriding_objects.phpt ├── runkit_default_property_remove_and_reflection.phpt ├── runkit_default_property_remove_from_subclasses.phpt ├── runkit_default_property_remove_from_subclasses_overriding_objects.phpt ├── runkit_default_property_remove_inheritance.phpt ├── runkit_default_property_remove_inheritance_overriding_objects.phpt ├── runkit_default_property_remove_overriding_objects.phpt ├── runkit_default_property_remove_private_and_inheritance.phpt ├── runkit_default_property_remove_private_and_inheritance_overriding_objects.phpt ├── runkit_default_property_remove_private_shadow_and_inheritance.phpt ├── runkit_default_property_remove_private_shadow_and_inheritance54.phpt ├── runkit_default_property_remove_private_shadow_and_inheritance_overriding_objects.phpt ├── runkit_default_property_remove_simple.phpt ├── runkit_finally.phpt ├── runkit_fpm_internal_function_restore.phpt ├── runkit_function_add.phpt ├── runkit_function_add_alias.phpt ├── runkit_function_add_and_doc_comment.phpt ├── runkit_function_add_closure.phpt ├── runkit_function_add_closure_and_doc_comment.phpt ├── runkit_function_add_closure_and_doc_comment_from_closure.phpt ├── runkit_function_add_return_type.phpt ├── runkit_function_add_return_type_invalid.phpt ├── runkit_function_copy.phpt ├── runkit_function_copy_8.phpt ├── runkit_function_copy_alias.phpt ├── runkit_function_redefine.phpt ├── runkit_function_redefine_alias.phpt ├── runkit_function_redefine_and_doc_comment.phpt ├── runkit_function_redefine_and_reflection.phpt ├── runkit_function_redefine_and_revert.phpt ├── runkit_function_redefine_and_revert_closure.phpt ├── runkit_function_redefine_closure_and_doc_comment.phpt ├── runkit_function_redefine_closure_and_doc_comment_from_closure.phpt ├── runkit_function_redefine_closure_static.phpt ├── runkit_function_redefine_from_anonymous.phpt ├── runkit_function_redefine_using_undef.phpt ├── runkit_function_redefine_var_dump.phpt ├── runkit_function_remove.phpt ├── runkit_function_remove_alias.phpt ├── runkit_function_remove_and_reflection.phpt ├── runkit_function_remove_and_reflection_parameter.phpt ├── runkit_function_rename.phpt ├── runkit_function_rename_alias.phpt ├── runkit_function_rename_and_reflection.phpt ├── runkit_function_rename_corruption.phpt ├── runkit_function_rename_corruption2.phpt ├── runkit_function_rename_internal.phpt ├── runkit_function_rename_large_switch.phpt ├── runkit_function_rename_redefine_add_remove.phpt ├── runkit_function_variadic.phpt ├── runkit_function_variadic_strict.phpt ├── runkit_function_variadic_typed.phpt ├── runkit_functions_returning_by_reference.phpt ├── runkit_method_add.phpt ├── runkit_method_add_7_php8.phpt ├── runkit_method_add_alias.phpt ├── runkit_method_add_and_doc_comment.phpt ├── runkit_method_add_closure.phpt ├── runkit_method_add_closure2.phpt ├── runkit_method_add_closure_and_doc_comment.phpt ├── runkit_method_add_closure_and_doc_comment_from_closure.phpt ├── runkit_method_add_closure_and_flags.phpt ├── runkit_method_add_closure_php80.phpt ├── runkit_method_add_overriding_parent_method.phpt ├── runkit_method_add_php73_bug.phpt ├── runkit_method_add_return_type.phpt ├── runkit_method_add_return_type_invalid.phpt ├── runkit_method_copy.phpt ├── runkit_method_copy_alias.phpt ├── runkit_method_copy_and_doc_comment.phpt ├── runkit_method_copy_and_doc_comment_leak.phpt ├── runkit_method_copy_uninit_read.phpt ├── runkit_method_redefine.phpt ├── runkit_method_redefine_alias.phpt ├── runkit_method_redefine_and_doc_comment.phpt ├── runkit_method_redefine_and_reflection.phpt ├── runkit_method_redefine_and_reflection_with_inheritance.phpt ├── runkit_method_redefine_closure_and_doc_comment.phpt ├── runkit_method_redefine_closure_and_doc_comment_from_closure.phpt ├── runkit_method_redefine_protected.phpt ├── runkit_method_redefine_update_proto.phpt ├── runkit_method_redefine_update_proto2.phpt ├── runkit_method_redefine_with_static_vars.phpt ├── runkit_method_remove.phpt ├── runkit_method_remove_alias.phpt ├── runkit_method_remove_and_reflection.phpt ├── runkit_method_remove_and_reflection_parameter.phpt ├── runkit_method_remove_and_reflection_parameter_with_inheritance.phpt ├── runkit_method_remove_and_reflection_with_inheritance.phpt ├── runkit_method_remove_static.phpt ├── runkit_method_rename.phpt ├── runkit_method_rename_002.phpt ├── runkit_method_rename_alias.phpt ├── runkit_method_rename_and_access.phpt ├── runkit_method_rename_and_reflection.phpt ├── runkit_method_rename_inheritance.phpt ├── runkit_method_rename_repeated.phpt ├── runkit_method_rename_static.phpt ├── runkit_method_variadic.phpt ├── runkit_method_variadic_strict.phpt ├── runkit_method_variadic_typed.phpt ├── runkit_methods_redefining_and_cache.inc ├── runkit_methods_returning_by_reference.phpt ├── runkit_redefine_old_style_ctor.phpt ├── runkit_redefine_old_style_ctor_php8.phpt ├── runkit_remove_magic_call_method.phpt ├── runkit_remove_magic_callstatic_method.phpt ├── runkit_remove_magic_serialize_method.phpt ├── runkit_remove_magic_tostring_method.phpt ├── runkit_remove_magic_tostring_method_php74.phpt ├── runkit_remove_magic_tostring_method_php80.phpt ├── runkit_remove_magic_unserialize_method.phpt ├── runkit_static_property_add.phpt ├── runkit_static_property_add_existing.phpt ├── runkit_static_property_add_single.phpt ├── runkit_static_property_add_to_subclasses.phpt ├── runkit_static_vars.phpt ├── runkit_static_vars_php81.phpt ├── runkit_superglobals.phpt ├── runkit_superglobals_obj.phpt ├── runkit_superglobals_obj_alias.phpt ├── runkit_superglobals_obj_alias_php81.phpt ├── runkit_superglobals_obj_php81.phpt ├── runkit_user_functions_on_shutdown.phpt ├── runkit_zval_inspect.phpt └── runkit_zval_inspect_alias.phpt /.clang-format.example: -------------------------------------------------------------------------------- 1 | # Note: This has a lot of false positives with the macros used for developing PHP modules 2 | BasedOnStyle: LLVM 3 | UseTab: Always 4 | IndentWidth: 8 5 | TabWidth: 8 6 | ColumnLimit: 0 7 | BreakBeforeBraces: Linux 8 | SpacesBeforeTrailingComments: 2 9 | 10 | # I tried ForEachMacros, 11 | # but clang-format 3.8.0 would insert a space before the '(', making the C macro not work. 12 | # ForEachMacros: ['ZEND_HASH_FOREACH_KEY_PTR', 'ZEND_HASH_FOREACH_KEY_VAL_IND', 'ZEND_HASH_FOREACH_PTR', 'ZEND_HASH_FOREACH_STR_KEY', 'ZEND_HASH_FOREACH_STR_KEY_PTR', 'ZEND_HASH_FOREACH_STR_KEY_VAL', 'ZEND_HASH_FOREACH_VAL_IND'] 13 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | **/*.swp 3 | **/*.lo 4 | **/*.la 5 | **/*.tgz 6 | **/*.dep 7 | **/.deps 8 | **/.libs 9 | **/Dockerfile* 10 | **/Makefile 11 | **/Makefile.fragments 12 | **/Makefile.global 13 | **/Makefile.objects 14 | **/acinclude.m4 15 | **/aclocal.m4 16 | **/autom4te.cache 17 | **/build 18 | **/config.cache 19 | **/config.guess 20 | **/config.h 21 | **/config.h.in 22 | **/config.log 23 | **/config.nice 24 | **/config.status 25 | **/config.sub 26 | **/configure 27 | **/configure.in 28 | **/configure.ac 29 | **/conftest 30 | **/conftest.c 31 | **/include 32 | **/install-sh 33 | **/libtool 34 | **/ltmain.sh 35 | **/missing 36 | **/mkinstalldirs 37 | **/modules 38 | **/scan_makefile_in.awk 39 | **/*.dsw 40 | **/*.plg 41 | **/*.opt 42 | **/*.ncb 43 | **/Release 44 | **/Release_inline 45 | **/Debug 46 | **/Release_TS 47 | **/Release_TSDbg 48 | **/Release_TS_inline 49 | **/Debug_TS 50 | **/run-tests.php 51 | **/cscope.out 52 | **/tests/*.out 53 | **/tests/*.php 54 | **/tests/*.mem 55 | **/tests/*.diff 56 | **/tests/*.log 57 | **/tests/*.exp 58 | **/tests/*.sh 59 | **/tmp-php.ini 60 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; 4 space indentation (no size specified) 2 | [*] 3 | charset = utf-8 4 | end_of_line = lf 5 | indent_style = tab 6 | indent_size = 4 7 | [*.phpt] 8 | indent_style = space 9 | [*.xml] 10 | indent_size = 1 11 | indent_style = space 12 | [*.yml] 13 | indent_size = 8 14 | indend_style = space 15 | [*.w32] 16 | charset = utf-8 17 | end_of_line = crlf 18 | indent_style = space 19 | indent_size = 4 20 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | For bug reports, please include: 2 | 3 | 1. `php --version` (full output, including NTS/ZTS) 4 | 5 | 2. Runkit7 version (`echo phpversion('runkit7');`). Make sure that the bug can be reproduced in the latest version on https://pecl.php.net/package/runkit7 (or newer) 6 | 7 | 3. OS version and compiler version 8 | 9 | 4. If possible, a minimal, self-contained snippet reproducing the problem, 10 | or a link to the affected project and steps to reproduce the issue. 11 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # Runs runkit7's tests and verifies that the package can be built. 2 | 3 | name: CI 4 | 5 | # Controls when the action will run. 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: [ master ] 10 | pull_request: 11 | branches: [ master ] 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | # This workflow contains a single job called "build" 19 | build: 20 | # The type of runner that the job will run on 21 | runs-on: ubuntu-latest 22 | 23 | # See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-environment-variables-in-a-matrix 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | include: 28 | # NOTE: If this is not quoted, the yaml parser will convert 7.0 to the number 7, 29 | # and the docker image `php:7` is the latest minor version of php 7.x (7.4). 30 | - PHP_VERSION: '7.2' 31 | PHP_VERSION_FULL: 7.2.34 32 | - PHP_VERSION: '7.3' 33 | PHP_VERSION_FULL: 7.3.32 34 | - PHP_VERSION: '7.4' 35 | PHP_VERSION_FULL: 7.4.30 36 | - PHP_VERSION: '8.0' 37 | PHP_VERSION_FULL: 8.0.30 38 | - PHP_VERSION: '8.1' 39 | PHP_VERSION_FULL: 8.1.23 40 | - PHP_VERSION: '8.2' 41 | PHP_VERSION_FULL: 8.2.10 42 | 43 | # Steps represent a sequence of tasks that will be executed as part of the job 44 | steps: 45 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 46 | - uses: actions/checkout@v4 47 | 48 | # Runs a single command using the runners shell 49 | - name: Build and test in docker 50 | run: bash ci/test_dockerized.sh ${{ matrix.PHP_VERSION }} 51 | 52 | # Note: testing with valgrind fails in anything newer than 7.2. 53 | 54 | # We reuse the php base image because 55 | # 1. It has any necessary dependencies installed for php 7.0-8.0 56 | # 2. It is already downloaded 57 | # 58 | # We need to install valgrind then rebuild php from source with the configure option '--with-valgrind' to avoid valgrind false positives 59 | # because php-src has inline assembly that causes false positives in valgrind when that option isn't used. 60 | # - name: Build and test in docker again with valgrind 61 | # run: bash ci/test_dockerized_valgrind.sh ${{ matrix.PHP_VERSION }} ${{ matrix.PHP_VERSION_FULL }} 62 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # test files 2 | tests/*.diff 3 | tests/*.exp 4 | tests/*.log 5 | tests/*.out 6 | tests/*.php 7 | tests/*.sh 8 | tags 9 | 10 | # built files 11 | *.dep 12 | *.lo 13 | *.dll 14 | *.tgz 15 | *.ac 16 | *.in 17 | *.la 18 | config.* 19 | configure 20 | .deps 21 | .libs 22 | Makefile* 23 | acinclude.m4 24 | aclocal.m4 25 | *.cache 26 | /build 27 | /modules 28 | /.libs 29 | mkinstalldirs 30 | libtool 31 | ltmain.sh 32 | install-sh 33 | missing 34 | run-tests.php 35 | 36 | 37 | # editor files 38 | *.swo 39 | *.swp 40 | *.bak 41 | -------------------------------------------------------------------------------- /Makefile.frag: -------------------------------------------------------------------------------- 1 | install: $(all_targets) $(install_targets) show-install-instructions 2 | 3 | show-install-instructions: 4 | @echo 5 | @$(top_srcdir)/build/shtool echo -n -e %B 6 | @echo " +----------------------------------------------------------------------+" 7 | @echo " | |" 8 | @echo " | UPGRADING NOTICE |" 9 | @echo " | ================ |" 10 | @echo " | |" 11 | @echo " | In runkit7 v3, the name of the installed shared library has been |" 12 | @echo " | changed from \"runkit\" to \"runkit7\". |" 13 | @echo " | (i.e. runkit.so changed to runkit7.so, and php_runkit.dll changed |" 14 | @echo " | to php_runkit7.dll) |" 15 | @echo " | |" 16 | @echo " | - php.ini files WILL NEED TO BE CHANGED TO LOAD RUNKIT7 INSTEAD. |" 17 | @echo " | |" 18 | @echo " | Additionally, the configuration flags used have changed from |" 19 | @echo " | --enable-runkit-feature to --enable-runkit7-feature. |" 20 | @echo " | |" 21 | @echo " | This change was made to comply with PECL's naming/packaging |" 22 | @echo " | guidelines. |" 23 | @echo " | |" 24 | @echo " +----------------------------------------------------------------------+" 25 | @$(top_srcdir)/build/shtool echo -n -e %b 26 | @echo 27 | @echo 28 | 29 | findphp: 30 | @echo $(PHP_EXECUTABLE) 31 | -------------------------------------------------------------------------------- /PROPERTY_MANIPULATION.md: -------------------------------------------------------------------------------- 1 | As of php 7.0, it's possible to modify the defaults of existing properties. 2 | However, adding or removing new properties is no longer feasible for the following reasons. 3 | 4 | 1. The property manipulation code still has bugs, and the "offset" used is in bytes as of php7, but still treated as an index in this code. 5 | 2. As of php7's new zval layout, The only way to "add" a default property would be to realloc() every single one 6 | of the `zend_object`s that are instances of that class (to make room for another property). 7 | This would break php internals and possibly extensions. 8 | A possible other way would be to change the API to `runkit_default_property_modify($className, $propertyName, $value, $flags = TODO)` 9 | (with a precondition $propertyName already existed) 10 | The old way properties of objects were stored was as a pointer to an array. 11 | In php7, it's part of `zend_object` itself, similar to what is described in https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html (1-length, with an UNDEF value at the end) 12 | 3. It should be possible to meet many uses by modifying constructors with `runkit_method_move` and `runkit_method_add`, 13 | or using ReflectionProperty for getting and setting private properties. 14 | https://secure.php.net/manual/en/reflectionproperty.setaccessible.php (sets accessibility only for ReflectionProperty) 15 | https://secure.php.net/manual/en/reflectionproperty.setvalue.php 16 | https://secure.php.net/manual/en/reflectionproperty.getvalue.php 17 | -------------------------------------------------------------------------------- /UPGRADING_TO_3.md: -------------------------------------------------------------------------------- 1 | Upgrading from runkit7 2.x to 3.0 2 | ================================= 3 | 4 | Runkit7 3.0 finishes changing this extension's name from "runkit" to "runkit7". 5 | THIS WILL REQUIRE CHANGES TO YOUR BUILD SCRIPTS AND PHP.INI FILES. 6 | This change was made at the request of PECL admins, to comply with naming and packaging standards. 7 | 8 | - The compiled shared object name has been changed from `runkit.so` to `runkit7.so` (Mac/Linux) and `php_runkit.dll` to `php_runkit7.dll` (Windows) 9 | (php.ini files should be changed to reference `extension=runkit7.so` or `extension=php_runkit7.dll`) 10 | - The configure flag names have been changed from flags such as `--enable-runkit` / `--enable-runkit-modify` to `--enable-runkit7` / `--enable-runkit7-modify` 11 | - Code using `extension_loaded('runkit')` should be changed to `extension_loaded('runkit7')` (as well as uses of ReflectionExtension, etc.) 12 | - The ini options `runkit.superglobal` and `runkit.internal_override` are unaffected. 13 | 14 | Other changes: 15 | - Classkit compatibility functions/constants have been removed. 16 | - The RUNKIT_VERSION constant was removed. (use ReflectionExtension->getVersion()) 17 | -------------------------------------------------------------------------------- /ci/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PHP_VERSION 2 | FROM php:$PHP_VERSION 3 | WORKDIR /code 4 | # Used for running tests in Docker 5 | # RUN apt-get update && apt-get install -y valgrind && apt-get clean 6 | # NOTE: In order to avoid valgrind false positives, this would need to compile php from source and configure php --with-valgrind (php-src's zend_string_equals uses inline assembly that causes false positives) 7 | # - ci/install_php_custom.sh and ci/generate_php_install_dir.sh may be a useful reference for that. 8 | ADD *.sh *.c *.h *.php *.md config.m4 config.w32 package.xml LICENSE* Makefile.frag ./ 9 | 10 | # Assume compilation will be the time consuming step. 11 | # Add tests after compiling so that it's faster to update tests and re-run them locally. 12 | RUN phpize && ./configure && make -j2 && make install 13 | RUN docker-php-ext-enable runkit7 14 | ADD tests ./tests 15 | ADD ci ./ci 16 | -------------------------------------------------------------------------------- /ci/Dockerfile.valgrind: -------------------------------------------------------------------------------- 1 | ARG PHP_VERSION 2 | FROM php:$PHP_VERSION 3 | WORKDIR /code 4 | RUN apt-get update && apt-get install -y valgrind && apt-get clean 5 | 6 | ADD ci/install_php_custom.sh ci/generate_php_install_dir.sh ci/ 7 | ARG PHP_VERSION_FULL 8 | ARG PHP_CONFIGURE_ARGS="--disable-all --enable-zts --enable-debug --enable-cgi --enable-session --enable-json" 9 | ARG CFLAGS="-DZEND_RC_DEBUG=1" 10 | ENV PHP_CONFIGURE_ARGS=$PHP_CONFIGURE_ARGS PHP_CUSTOM_VERSION=$PHP_VERSION_FULL CFLAGS=$CFLAGS 11 | RUN ci/install_php_custom.sh 12 | 13 | # Assume compilation will be the time consuming step. 14 | # Add tests after compiling so that it's faster to update tests and re-run them locally. 15 | # (The ability to use custom install directories is useful for running tests locally outside docker) 16 | # TODO: Reorder 17 | # 18 | # NOTE: php 8.1 has a patch that may avoid the need to recompile php with --enable-valgrind, 19 | # but the PHP_CONFIGURE_ARGS overrides such as --enable-debug may still be useful 20 | RUN ln -nsf $(ci/generate_php_install_dir.sh) /php-valgrind-install 21 | ENV PATH=/php-valgrind-install/bin:$PATH 22 | 23 | # Used for running tests in Docker 24 | # RUN apt-get update && apt-get install -y valgrind && apt-get clean 25 | # NOTE: In order to avoid valgrind false positives, this would need to compile php from source and configure php --with-valgrind (php-src's zend_string_equals uses inline assembly that causes false positives) 26 | # - ci/install_php_custom.sh and ci/generate_php_install_dir.sh may be a useful reference for that. 27 | ADD *.sh *.c *.h *.php *.md config.m4 config.w32 package.xml LICENSE* Makefile.frag ./ 28 | 29 | # Assume compilation will be the time consuming step. 30 | # Add tests after compiling so that it's faster to update tests and re-run them locally. 31 | RUN phpize && ./configure $PHP_CONFIGURE_ARGS && make clean 32 | # RUN docker-php-ext-enable runkit7 33 | ADD tests ./tests 34 | ADD ci ./ci 35 | -------------------------------------------------------------------------------- /ci/g++-32.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec g++ -m32 "$@" 3 | -------------------------------------------------------------------------------- /ci/gcc-32.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | exec gcc -m32 "$@" 3 | -------------------------------------------------------------------------------- /ci/generate_php_install_dir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xeu 2 | # Print a folder name to stdout based on the desired integer width(32 bit or 64 bit) and PHP_CONFIGURE_ARGS. 3 | # This could instead be done by the `source` builtin, but wouldn't work if a different shell (e.g. zsh) was calling bash. 4 | PHP_INSTALL_DIR="$HOME/travis_cache/php-$PHP_CUSTOM_VERSION" 5 | if [ "${USE_32BIT:-0}" = "1" ]; then 6 | PHP_INSTALL_DIR="$PHP_INSTALL_DIR-32bit" 7 | else 8 | PHP_INSTALL_DIR="$PHP_INSTALL_DIR-64bit" 9 | fi 10 | # Generate a unique 4-character suffix based on $PHP_CONFIGURE_ARGS. 11 | HASH=$(echo -n "$PHP_CONFIGURE_ARGS" | sha1sum | cut -c -4) 12 | PHP_INSTALL_DIR="$PHP_INSTALL_DIR-$HASH" 13 | echo -n "$PHP_INSTALL_DIR" 14 | -------------------------------------------------------------------------------- /ci/get_global_php_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | php -r "echo(preg_replace('/-dev|RC.*/','',PHP_VERSION));" 3 | -------------------------------------------------------------------------------- /ci/install_php_custom.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xeu 2 | 3 | # Required env variables: 4 | # PHP_CONFIGURE_ARGS 5 | # PHP_CUSTOM_VERSION (E.g. 7.4.20) 6 | # PHP_INSTALL_DIR (path to installation directory) 7 | 8 | # optional env vars: 9 | # CFLAGS 10 | # CC 11 | # PATH 12 | echo "Attempting to install PHP from source, PHP version '$PHP_CUSTOM_VERSION'/ configure args '$PHP_CONFIGURE_ARGS'" 13 | if [ "x$PHP_CUSTOM_VERSION" = "x" -o "x$PHP_CONFIGURE_ARGS" = "x" ] ; then 14 | echo "Missing php version or configuration arguments"; 15 | exit 1; 16 | fi 17 | PHP_FOLDER="php-$PHP_CUSTOM_VERSION" 18 | PHP_INSTALL_DIR="$(./ci/generate_php_install_dir.sh)" 19 | echo "Downloading $PHP_INSTALL_DIR\n" 20 | if [ -x $PHP_INSTALL_DIR/bin/php ] ; then 21 | echo "PHP $PHP_CUSTOM_VERSION already installed and in cache at $PHP_INSTALL_DIR"; 22 | exit 0 23 | fi 24 | PHP_CUSTOM_NORMAL_VERSION=${PHP_CUSTOM_VERSION//RC[0-9]/} 25 | PHP_CUSTOM_NORMAL_VERSION=${PHP_CUSTOM_NORMAL_VERSION//alpha[0-9]/} 26 | PHP_CUSTOM_NORMAL_VERSION=${PHP_CUSTOM_NORMAL_VERSION//beta[0-9]/} 27 | 28 | # Remove cache if it somehow exists 29 | if [ "x${TRAVIS:-0}" != "x" ]; then 30 | rm -rf $HOME/travis_cache/ 31 | fi 32 | 33 | # Otherwise, put a minimal installation inside of the cache. 34 | if [ "$PHP_CUSTOM_NORMAL_VERSION" == "8.2.0" ] ; then 35 | PHP_CUSTOM_VERSION=8.2.0beta2 36 | PHP_FOLDER="php-$PHP_CUSTOM_VERSION" 37 | 38 | PHP_TAR_FILE="$PHP_FOLDER.tar.bz2" 39 | PHP_TAR_URL=https://downloads.php.net/~sergey/$PHP_TAR_FILE 40 | else 41 | PHP_FOLDER="php-$PHP_CUSTOM_VERSION" 42 | 43 | PHP_TAR_FILE="$PHP_FOLDER.tar.bz2" 44 | PHP_TAR_URL=https://secure.php.net/distributions/$PHP_TAR_FILE 45 | fi 46 | if [ ! -f $PHP_TAR_FILE ]; then 47 | curl --location --verbose $PHP_TAR_URL -o $PHP_TAR_FILE 48 | fi 49 | 50 | tar xjf $PHP_TAR_FILE 51 | 52 | pushd $PHP_FOLDER 53 | ./configure $PHP_CONFIGURE_ARGS --prefix="$PHP_INSTALL_DIR" 54 | make -j5 55 | make install 56 | popd 57 | 58 | echo "PHP $PHP_CUSTOM_VERSION successfully installed and in cache at $HOME/travis_cache/$PHP_FOLDER"; 59 | -------------------------------------------------------------------------------- /ci/install_php_nts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xeu 2 | 3 | echo "Attempting to install NTS PHP, NTS version '$PHP_NTS_VERSION'/ configure args '$PHP_CONFIGURE_ARGS'" 4 | if [[ "x$PHP_NTS_VERSION" = "x" ]]; then 5 | echo "Missing PHP_NTS_VERSION" 6 | exit 1 7 | elif [[ "x$PHP_CONFIGURE_ARGS" = "x" ]] ; then 8 | echo "Missing PHP_CONFIGURE_ARGS" 9 | exit 1 10 | fi 11 | PHP_INSTALL_DIR="$(./ci/generate_php_install_dir.sh)" 12 | echo "Downloading $PHP_INSTALL_DIR\n" 13 | if [[ -x $PHP_INSTALL_DIR/bin/php ]] ; then 14 | echo "PHP $PHP_NTS_VERSION already installed and in cache at $PHP_INSTALL_DIR"; 15 | exit 0 16 | fi 17 | PHP_NTS_NORMAL_VERSION=${PHP_NTS_VERSION//RC[0-9]/} 18 | PHP_NTS_NORMAL_VERSION=${PHP_NTS_NORMAL_VERSION//alpha[0-9]/} 19 | PHP_NTS_NORMAL_VERSION=${PHP_NTS_NORMAL_VERSION//beta[0-9]/} 20 | PHP_FOLDER="php-$PHP_NTS_VERSION" 21 | 22 | # Remove cache if it somehow exists 23 | if [[ "x${TRAVIS:-0}" != "x" ]]; then 24 | rm -rf $HOME/travis_cache/ 25 | fi 26 | # Otherwise, put a minimal installation inside of the cache. 27 | PHP_TAR_FILE="$PHP_FOLDER.tar.bz2" 28 | if [[ "$PHP_NTS_NORMAL_VERSION" == "8.0.0" ]] ; then 29 | GIT_BRANCH=PHP-8.0 30 | curl --location --verbose https://github.com/php/php-src/archive/$GIT_BRANCH.zip -o php-src-$GIT_BRANCH.zip 31 | unzip -q php-src-$GIT_BRANCH.zip 32 | PHP_FOLDER=php-src-$GIT_BRANCH 33 | pushd $PHP_FOLDER 34 | ./buildconf --force 35 | popd 36 | else 37 | curl --location --verbose https://secure.php.net/distributions/$PHP_TAR_FILE -o $PHP_TAR_FILE 38 | tar xjf $PHP_TAR_FILE 39 | fi 40 | 41 | pushd $PHP_FOLDER 42 | ./configure $PHP_CONFIGURE_ARGS --prefix="$PHP_INSTALL_DIR" 43 | make -j5 44 | make install 45 | popd 46 | 47 | echo "PHP $PHP_NTS_VERSION is now installed and in cache at $HOME/travis_cache/$PHP_FOLDER"; 48 | -------------------------------------------------------------------------------- /ci/php.ini: -------------------------------------------------------------------------------- 1 | ; Intentionally left blank. 2 | -------------------------------------------------------------------------------- /ci/print_php_int_max.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | &2 10 | exit 1 11 | fi 12 | 13 | echo "\n\n" 14 | echo "################################################################################" 15 | echo "# Running with valgrind enabled #" 16 | echo "################################################################################\n\n" 17 | yes n | make test 18 | -------------------------------------------------------------------------------- /ci/test_dockerized.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | if [[ $# < 1 || $# > 2 ]]; then 3 | echo "Usage: $0 PHP_VERSION [i386]" 1>&2 4 | echo "e.g. $0 8.0 php" 1>&2 5 | echo "The PHP_VERSION is the version of the php docker image to use" 1>&2 6 | exit 1 7 | fi 8 | # -x Exit immediately if any command fails 9 | # -e Echo all commands being executed. 10 | # -u fail for undefined variables 11 | set -xeu 12 | PHP_VERSION=$1 13 | ARCHITECTURE=${2:-} 14 | 15 | if [[ "$ARCHITECTURE" == i386 ]]; then 16 | PHP_IMAGE="$ARCHITECTURE/php" 17 | DOCKER_IMAGE="runkit7-test-runner:$ARCHITECTURE-$PHP_VERSION" 18 | else 19 | PHP_IMAGE="php" 20 | DOCKER_IMAGE="runkit7-test-runner:$PHP_VERSION" 21 | fi 22 | 23 | docker build --build-arg="PHP_VERSION=$PHP_VERSION" --build-arg="PHP_IMAGE=$PHP_IMAGE" --tag="$DOCKER_IMAGE" -f ci/Dockerfile . 24 | docker run --rm $DOCKER_IMAGE ci/test_inner.sh 25 | -------------------------------------------------------------------------------- /ci/test_dockerized_valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Runs this PECL's unit tests with valgrind and a customizable php build 3 | # TODO: Support overridable PHP_CONFIGURE_ARGS 4 | # 5 | # We reuse the php base image because 6 | # 1. It has any necessary dependencies installed for php 7.0-8.0 7 | # 2. It is already downloaded 8 | # 9 | # We need to install valgrind then rebuild php from source with the configure option '--with-valgrind' to avoid valgrind false positives 10 | # because php-src has inline assembly that causes false positives in valgrind when that option isn't used. 11 | if [[ $# < 2 || $# > 3 ]]; then 12 | echo "Usage: $0 PHP_VERSION PHP_VERSION_FULL [i386]" 1>&2 13 | echo "e.g. $0 8.0 8.0.3" 1>&2 14 | echo "The PHP_VERSION is the version of the php docker image to use" 1>&2 15 | echo "The PHP_VERSION_FULL is the version of the php release to download using ci/install_php_custom.sh" 1>&2 16 | exit 1 17 | fi 18 | # -x Exit immediately if any command fails 19 | # -e Echo all commands being executed. 20 | # -u fail for undefined variables 21 | set -xeu 22 | PHP_VERSION=$1 23 | PHP_VERSION_FULL=$2 24 | ARCHITECTURE=${3:-} 25 | 26 | # NOTE: php 7.3-8.0 (but not 8.1) will fail in valgrind without "--with-valgrind" because php-src uses custom assembly for its implementation of zend_string_equals 27 | # In order to fix those false positives, a different set of images would be needed where (1) valgrind was installed before compiling php, and (2) php was compiled with support for valgrind (--with-valgrind) to avoid false positives 28 | # docker run --rm $DOCKER_IMAGE ci/test_inner_valgrind.sh 29 | if [[ "$ARCHITECTURE" == i386 ]]; then 30 | PHP_IMAGE="$ARCHITECTURE/php" 31 | DOCKER_IMAGE_VALGRIND="runkit7-valgrind-test-runner:$ARCHITECTURE-$PHP_VERSION_FULL" 32 | else 33 | PHP_IMAGE="php" 34 | DOCKER_IMAGE_VALGRIND="runkit7-valgrind-test-runner:$ARCHITECTURE-$PHP_VERSION" 35 | fi 36 | 37 | DOCKER_IMAGE_VALGRIND=runkit7-valgrind-test-runner:$PHP_VERSION_FULL 38 | docker build --build-arg="PHP_IMAGE=$PHP_IMAGE" --build-arg="PHP_VERSION=$PHP_VERSION" --build-arg="PHP_VERSION_FULL=$PHP_VERSION_FULL" --tag="$DOCKER_IMAGE_VALGRIND" -f ci/Dockerfile.valgrind . 39 | docker run --rm $DOCKER_IMAGE_VALGRIND ci/test_inner_valgrind.sh 40 | -------------------------------------------------------------------------------- /ci/test_inner.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -x Exit immediately if any command fails 3 | # -e Echo all commands being executed. 4 | # -u fail for undefined variables 5 | set -xeu 6 | echo "Run tests in docker" 7 | php --version 8 | php --ini 9 | cp ci/run-tests-parallel.php run-tests.php 10 | REPORT_EXIT_STATUS=1 make test TESTS="-j$(nproc) -P -q --show-diff" 11 | echo "Test that package.xml is valid" 12 | pecl package 13 | -------------------------------------------------------------------------------- /ci/test_inner_valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # -x Exit immediately if any command fails 3 | # -e Echo all commands being executed. 4 | # -u fail for undefined variables 5 | set -xeu 6 | echo "Run tests in docker" 7 | php --version 8 | php --ini 9 | cp ci/run-tests-parallel.php run-tests.php 10 | REPORT_EXIT_STATUS=1 make test TESTS="-j$(nproc) -P -q --show-diff -m --show-mem" 11 | echo "Test that package.xml is valid" 12 | pecl package 13 | -------------------------------------------------------------------------------- /ci/wipe_travis_cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -xeu 2 | # Ensure that ~/travis_cache is a folder with 0 files in it. 3 | # This avoids accidentally caching left over files in s3. 4 | CACHE_DIR="$HOME/travis_cache" 5 | if [ -d "$CACHE_DIR" ]; then 6 | if [ find "$CACHE_DIR" -mindepth 1 -print -quit | grep -q . ]; then 7 | echo "$CACHE_DIR was not empty, clearing" 8 | rm -rf $CACHE_DIR; 9 | mkdir "$CACHE_DIR" 10 | fi 11 | else 12 | echo "$CACHE_DIR did not exist, creating an empty directory to cache" 13 | mkdir "$CACHE_DIR" 14 | fi 15 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl config.m4 for extension runkit7 2 | 3 | PHP_ARG_ENABLE(runkit7, whether to enable runkit7 support, 4 | [ --enable-runkit7 Enable runkit7 support], no, yes) 5 | 6 | PHP_ARG_ENABLE(runkit7-modify, whether to enable runtime manipulation of functions/classes/constants, 7 | [ --enable-runkit7-modify Enable runtime manipulation], inherit, no) 8 | 9 | PHP_ARG_ENABLE(runkit7-super, whether to enable registration of user-defined autoglobals, 10 | [ --enable-runkit7-super Enable registration of user-defined autoglobals], inherit, yes) 11 | 12 | if test "$PHP_RUNKIT7" != "no"; then 13 | AC_MSG_CHECKING([if this is built with PHP >= 7.2]) 14 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 15 | #include <$phpincludedir/main/php_version.h> 16 | ]], [[ 17 | #if PHP_VERSION_ID < 70200 18 | #error PHP < 7.2 19 | #endif 20 | ]])],[ 21 | AC_MSG_RESULT([this is PHP 7.2 or newer]) 22 | ],[ 23 | AC_MSG_ERROR([Runkit7 3.x requires PHP 7.2 or newer, phpize was run with PHP < 7.2]); 24 | ]) 25 | if test "$PHP_RUNKIT7_SUPER" = "inherit"; then 26 | PHP_RUNKIT7_SUPER=yes 27 | fi 28 | else 29 | if test "$PHP_RUNKIT7_MODIFY" = "inherit"; then 30 | PHP_RUNKIT7_MODIFY=no 31 | fi 32 | if test "$PHP_RUNKIT7_SUPER" = "inherit"; then 33 | PHP_RUNKIT7_SUPER=no 34 | fi 35 | fi 36 | 37 | if test "$PHP_RUNKIT7" != "no"; then 38 | if test "$PHP_RUNKIT7_MODIFY" != "no"; then 39 | AC_DEFINE(PHP_RUNKIT7_FEATURE_MODIFY, 1, [Whether to export runtime modification features]) 40 | fi 41 | if test "$PHP_RUNKIT7_SUPER" != "no"; then 42 | AC_DEFINE(PHP_RUNKIT7_FEATURE_SUPER, 1, [Whether to export custom autoglobal registration feature]) 43 | fi 44 | PHP_NEW_EXTENSION(runkit7, runkit.c runkit_functions.c runkit_methods.c \ 45 | runkit_constants.c \ 46 | runkit_common.c \ 47 | runkit_zend_execute_API.c \ 48 | runkit_classes.c \ 49 | runkit_props.c \ 50 | , $ext_shared,, -Werror -Wall -Wno-deprecated-declarations -Wno-pedantic) 51 | dnl use Makefile.frag to echo notice about upgrading to runkit7 3.x 52 | PHP_ADD_MAKEFILE_FRAGMENT 53 | fi 54 | -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | // vim:ft=javascript 2 | /* eslint-disable no-undef */ 3 | 4 | ARG_ENABLE("runkit7", "Enable runkit7 support", "no"); 5 | ARG_ENABLE("runkit7-modify", "Enable runtime manipulation", "yes"); 6 | ARG_ENABLE("runkit7-super", "Enable registration of user-defined autoglobals", "yes"); 7 | 8 | if (PHP_RUNKIT7 != "no") { 9 | var dll = get_define('PHPDLL'); 10 | var is_php5 = null != dll.match(/^php5/); 11 | if (is_php5) { 12 | ERROR("Runkit7 supports PHP 7.1 and newer. It does not support PHP 5"); 13 | } 14 | 15 | // TODO: Why isn't HAVE_CONFIG_H being set all of the time? 16 | if (PHP_RUNKIT7_MODIFY != "no") { 17 | // Hackish way to enable these CFLAGS to include the necessary flags 18 | ADD_FLAG('CFLAGS_RUNKIT7', ' /D PHP_RUNKIT7_FEATURE_MODIFY'); 19 | AC_DEFINE("PHP_RUNKIT7_FEATURE_MODIFY", 1, "Runkit Manipulation"); 20 | } 21 | if (PHP_RUNKIT7_SUPER != "no") { 22 | ADD_FLAG('CFLAGS_RUNKIT7', ' /D PHP_RUNKIT7_FEATURE_SUPER'); 23 | AC_DEFINE("PHP_RUNKIT7_FEATURE_SUPER", 1, "Runkit Superglobals"); 24 | } 25 | 26 | AC_DEFINE('HAVE_RUNKIT7', 1); 27 | 28 | PHP_INSTALL_HEADERS('ext/runkit7', 'php_runkit7.h php_runkit_hash.h php_runkit_zend_execute_API.h php_runkit_zval.h runkit.h'); 29 | 30 | EXTENSION("runkit7", "runkit.c " + 31 | "runkit_common.c " + 32 | "runkit_functions.c " + 33 | "runkit_methods.c " + 34 | "runkit_classes.c " + 35 | "runkit_props.c " + 36 | "runkit_constants.c " + 37 | "runkit_zend_execute_API.c "); 38 | } 39 | -------------------------------------------------------------------------------- /php_runkit7.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | Copyright (c) 1997-2006 The PHP Group, (c) 2008-2015 Dmitry Zenovich | 4 | | "runkit7" patches (c) 2015-2020 Tyson Andre | 5 | +----------------------------------------------------------------------+ 6 | | This source file is subject to the new BSD license, | 7 | | that is bundled with this package in the file LICENSE, and is | 8 | | available through the world-wide-web at the following url: | 9 | | http://www.opensource.org/licenses/BSD-3-Clause | 10 | | or at https://github.com/runkit7/runkit7/blob/master/LICENSE | 11 | +----------------------------------------------------------------------+ 12 | | Author: Sara Golemon | 13 | | Modified by Dmitry Zenovich | 14 | | Modified for php7 "runkit7" by Tyson Andre| 15 | +----------------------------------------------------------------------+ 16 | */ 17 | 18 | #ifndef PHP_RUNKIT7_H 19 | #define PHP_RUNKIT7_H 20 | 21 | #ifndef phpext_runkit7_ptr 22 | extern zend_module_entry runkit7_module_entry; 23 | #define phpext_runkit7_ptr &runkit7_module_entry 24 | #endif 25 | #endif /* PHP_RUNKIT7_H */ 26 | -------------------------------------------------------------------------------- /php_runkit_zend_execute_API.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RUNKIT_ZEND_EXECUTE_API_H 2 | #define PHP_RUNKIT_ZEND_EXECUTE_API_H 3 | #include "Zend/zend.h" 4 | int runkit_forward_call_user_function(zend_function *fbc, zend_function *fbc_inner, INTERNAL_FUNCTION_PARAMETERS); 5 | #endif 6 | -------------------------------------------------------------------------------- /php_runkit_zval.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | (c) 2008-2015 Dmitry Zenovich | 4 | | "runkit7" patches (c) 2015-2020 Tyson Andre | 5 | +----------------------------------------------------------------------+ 6 | | This source file is subject to the new BSD license, | 7 | | that is bundled with this package in the file LICENSE, and is | 8 | | available through the world-wide-web at the following url: | 9 | | http://www.opensource.org/licenses/BSD-3-Clause | 10 | | or at https://github.com/runkit7/runkit7/blob/master/LICENSE | 11 | +----------------------------------------------------------------------+ 12 | | Author: Dmitry Zenovich | 13 | | Modified for php7 "runkit7" by Tyson Andre| 14 | +----------------------------------------------------------------------+ 15 | */ 16 | 17 | #ifndef PHP_RUNKIT_ZVAL_H 18 | #define PHP_RUNKIT_ZVAL_H 19 | 20 | /* {{{ php_runkit_zval_resolve_class_constant */ 21 | inline static void php_runkit_zval_resolve_class_constant(zval *p, zend_class_entry *ce) 22 | { 23 | if (Z_CONSTANT_P(p)) { 24 | // TODO: What does this do? 25 | // TODO: Make a copy if (Z_TYPE_FLAGS_P(p) & IS_TYPE_IMMUTABLE) != 0, test this out? 26 | zval_update_constant_ex(p, ce); 27 | } 28 | } 29 | /* }}} */ 30 | 31 | #define PHP_RUNKIT_ZVAL_CONVERT_TO_STRING_IF_NEEDED(val, val_copy) \ 32 | if (Z_TYPE_P(member) != IS_STRING) { \ 33 | val_copy = *val; \ 34 | val = &val_copy; \ 35 | zval_copy_ctor(val); \ 36 | val->RUNKIT_REFCOUNT = 1; \ 37 | convert_to_string(val); \ 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /tests/_fpm_skipif.inc: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /tests/bug10053.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_copy() function 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | c + $naturalNumber; 18 | $thisIsAStrangeVariableWithAVeryLongNameHopeThisWillShowTheError = $delta * $delta; 19 | $objectVarWithLongName = new stdclass; 20 | $objectVarWithLongName->e = $thisIsAStrangeVariableWithAVeryLongNameHopeThisWillShowTheError; 21 | echo "Runkit Method: $naturalNumber\n"; 22 | var_dump($objectVarWithLongName); 23 | } 24 | } 25 | 26 | class runkit_two { 27 | private $b = 27; 28 | private $c = 99; 29 | 30 | } 31 | 32 | $o = new runkit_one(); 33 | $o->runkit_method(1); 34 | 35 | runkit7_method_copy('runkit_two','runkit_method','runkit_one'); 36 | 37 | $o->runkit_method(2); 38 | 39 | $o2 = new runkit_two(); 40 | $o2->runkit_method(3); 41 | runkit7_method_remove('runkit_one','runkit_method'); 42 | if (method_exists('runkit_one','runkit_method')) { 43 | echo "Runkit Method still exists in Runkit One!\n"; 44 | } 45 | $o2->runkit_method(4); 46 | ?> 47 | --EXPECT-- 48 | Runkit Method: 1 49 | object(stdClass)#2 (1) { 50 | ["e"]=> 51 | int(4) 52 | } 53 | Runkit Method: 2 54 | object(stdClass)#2 (1) { 55 | ["e"]=> 56 | int(9) 57 | } 58 | Runkit Method: 3 59 | object(stdClass)#3 (1) { 60 | ["e"]=> 61 | int(10404) 62 | } 63 | Runkit Method: 4 64 | object(stdClass)#3 (1) { 65 | ["e"]=> 66 | int(10609) 67 | } 68 | -------------------------------------------------------------------------------- /tests/bug10300.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug #10300 Segfault when copying __call() 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL 7 | display_errors=on 8 | --FILE-- 9 | test(); 25 | ?> 26 | --EXPECT-- 27 | 28 | -------------------------------------------------------------------------------- /tests/bug56662.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug#56662 - Wrong access level with RUNKIT7_ACC_PUBLIC 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | public method x ] { 19 | @@ %sbug56662.php(3) : runkit runtime-created method 1 - 1 20 | } 21 | 22 | Method [ public method x ] { 23 | @@ %sbug56662.php 6 - 6 24 | } 25 | 26 | Method [ public method x ] { 27 | @@ %sbug56662.php(9) : eval()'d code 1 - 1 28 | } 29 | -------------------------------------------------------------------------------- /tests/bug56976.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Bug#56976 - Failure adding __call method 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | foo(); 25 | 26 | --EXPECT-- 27 | bool(true) 28 | bool(true) 29 | In ParentClass::__call() 30 | ParentClass::foo 31 | -------------------------------------------------------------------------------- /tests/bug57249.inc: -------------------------------------------------------------------------------- 1 | 5 | --FILE-- 6 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | bar(); 31 | $foo->o(); 32 | $foo->q(); 33 | 34 | runkit7_method_remove('Test\Foo', 'n'); 35 | runkit7_method_remove('\Test\Foo', 's'); 36 | $foo->n(); 37 | ?> 38 | --EXPECTF-- 39 | Mocked 40 | New mocked 41 | New 42 | 43 | Fatal error: Uncaught Error: Call to undefined method Test\Foo::n() in %s:%d 44 | Stack trace: 45 | #0 {main} 46 | thrown in %s on line %d 47 | -------------------------------------------------------------------------------- /tests/runkit_add_magic_serialize_method_ignored_for_common_classes.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | adding magic serialize method to common class should be ignored 3 | --SKIPIF-- 4 | 6 | --FILE-- 7 | serialize(); 18 | Test::unserialize($s1); 19 | ?> 20 | --EXPECT-- 21 | step2 22 | serialize 23 | unserialize 24 | -------------------------------------------------------------------------------- /tests/runkit_add_old_style_ctor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | add old-style parent ctor 3 | --SKIPIF-- 4 | = 80000) print "skip php >= 8.0"; 7 | ?> 8 | --FILE-- 9 | 34 | --EXPECT-- 35 | string(15) "new constructor" 36 | string(15) "new constructor" 37 | string(15) "new constructor" 38 | after removing 39 | ==DONE== 40 | -------------------------------------------------------------------------------- /tests/runkit_add_old_style_ctor1.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | add old-style parent ctor (existing ctor) 3 | --SKIPIF-- 4 | = 80000) print "skip php >= 8.0\n"; 7 | ?> 8 | --FILE-- 9 | 49 | --EXPECTF-- 50 | Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor in %s on line %d 51 | 52 | Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor in %s on line %d 53 | string(15) "new constructor" 54 | string(13) "foo_test ctor" 55 | string(13) "foo_test ctor" 56 | string(15) "new constructor" 57 | string(20) "test_grandchild ctor" 58 | after removing 59 | string(13) "foo_test ctor" 60 | string(13) "foo_test ctor" 61 | string(20) "test_grandchild ctor" 62 | ==DONE== 63 | -------------------------------------------------------------------------------- /tests/runkit_add_old_style_ctor_by_adopting.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | add old-style parent ctor by adoptting 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 35 | --EXPECT-- 36 | string(15) "new constructor" 37 | string(15) "new constructor" 38 | string(15) "new constructor" 39 | after emancipation 40 | -------------------------------------------------------------------------------- /tests/runkit_add_old_style_ctor_by_copying.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | add old-style parent ctor by copying 3 | --SKIPIF-- 4 | = 80000) print "skip php >= 8.0\n"; 7 | ?> 8 | --FILE-- 9 | 37 | --EXPECT-- 38 | string(15) "new constructor" 39 | string(15) "new constructor" 40 | string(15) "new constructor" 41 | after removing 42 | ==DONE== 43 | -------------------------------------------------------------------------------- /tests/runkit_adopt_emancipate_and_inheritance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_class_adopt, runkit_class_emancipate and inheritance 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | runkit.superglobal=_POST,_REQUEST,my 11 | --POST-- 12 | TEST=test 13 | --FILE-- 14 | 5 | --FILE-- 6 | 37 | --EXPECT-- 38 | array(1) { 39 | [0]=> 40 | string(3) "two" 41 | } 42 | array(2) { 43 | [0]=> 44 | string(5) "three" 45 | [1]=> 46 | string(3) "two" 47 | } 48 | array(2) { 49 | [0]=> 50 | string(3) "one" 51 | [1]=> 52 | string(3) "two" 53 | } 54 | array(3) { 55 | [0]=> 56 | string(3) "one" 57 | [1]=> 58 | string(5) "three" 59 | [2]=> 60 | string(3) "two" 61 | } 62 | -------------------------------------------------------------------------------- /tests/runkit_class_adopt_and_properties.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_class_adopt() function and properties issues 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | t); 18 | return 1; 19 | } 20 | } 21 | 22 | class B extends C { 23 | public function foo() { 24 | return 1 + $this->to_be_mocked(); 25 | } 26 | } 27 | $r = new B(); 28 | runkit_class_emancipate('B'); 29 | runkit_class_adopt('B', "A"); 30 | $o = new B(); 31 | $o->foo(); 32 | $r->foo(); 33 | runkit_class_emancipate('B'); 34 | $s = new B(); 35 | print_r($o); 36 | print_r($r); 37 | print_r($s); 38 | ?> 39 | --EXPECTF-- 40 | int(1) 41 | int(1) 42 | B Object 43 | ( 44 | ) 45 | B Object 46 | ( 47 | ) 48 | B Object 49 | ( 50 | ) 51 | -------------------------------------------------------------------------------- /tests/runkit_class_emancipate.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_class_emancipate() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 42 | --EXPECT-- 43 | array(2) { 44 | [0]=> 45 | string(3) "one" 46 | [1]=> 47 | string(3) "two" 48 | } 49 | array(3) { 50 | [0]=> 51 | string(3) "one" 52 | [1]=> 53 | string(5) "three" 54 | [2]=> 55 | string(3) "two" 56 | } 57 | array(1) { 58 | [0]=> 59 | string(3) "two" 60 | } 61 | array(2) { 62 | [0]=> 63 | string(5) "three" 64 | [1]=> 65 | string(3) "two" 66 | } 67 | array(1) { 68 | [0]=> 69 | string(3) "one" 70 | } 71 | -------------------------------------------------------------------------------- /tests/runkit_class_emancipate_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_class_emancipate() function with reflection and inheritance 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMethod('runkitMethod')); 24 | echo 'No exception!'; 25 | } catch (ReflectionException $e) { 26 | } 27 | 28 | try { 29 | var_dump($reflObject->getMethod('runkitMethod')); 30 | echo 'No exception!'; 31 | } catch (ReflectionException $e) { 32 | } 33 | var_dump($reflClass->getParentClass()); 34 | var_dump($reflMethod); 35 | $reflMethod->invoke($obj, $obj); 36 | ?> 37 | --EXPECTF-- 38 | bool(false) 39 | object(ReflectionMethod)#%d (2) { 40 | ["name"]=> 41 | string(28) "__method_removed_by_runkit__" 42 | ["class"]=> 43 | string(11) "RunkitClass" 44 | } 45 | 46 | Fatal error: RunkitClass::__method_removed_by_runkit__(): A method removed by runkit7 was somehow invoked in %s on line %d 47 | -------------------------------------------------------------------------------- /tests/runkit_constant_add.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_add() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | BAR 12 | -------------------------------------------------------------------------------- /tests/runkit_constant_add_array.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_add() function can add simple arrays 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | "BAR"]]); 11 | var_export(FOO); 12 | ?> 13 | --EXPECT-- 14 | array ( 15 | 0 => 'BAR', 16 | ) 17 | array ( 18 | 0 => 19 | array ( 20 | 'key' => 'BAR', 21 | ), 22 | ) 23 | -------------------------------------------------------------------------------- /tests/runkit_constant_add_array_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_constant_add() function can add simple arrays 3 | --INI-- 4 | error_reporting=E_ALL 5 | --SKIPIF-- 6 | 7 | --FILE-- 8 | "BAR"]]); 13 | var_dump(FOO); 14 | ?> 15 | --EXPECTF-- 16 | Deprecated: Function runkit_constant_add() is deprecated in %srunkit_constant_add_array_alias.php on line 2 17 | array(1) { 18 | [0]=> 19 | string(3) "BAR" 20 | } 21 | 22 | 23 | Deprecated: Function runkit_constant_redefine() is deprecated in %srunkit_constant_add_array_alias.php on line 5 24 | array(1) { 25 | [0]=> 26 | array(1) { 27 | ["key"]=> 28 | string(3) "BAR" 29 | } 30 | } -------------------------------------------------------------------------------- /tests/runkit_constant_add_array_to_class.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_add() function can add simple arrays to classes 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | "BAR"]]); 12 | var_export(A::FOO); 13 | ?> 14 | --EXPECT-- 15 | array ( 16 | 0 => 'BAR', 17 | ) 18 | array ( 19 | 0 => 20 | array ( 21 | 'key' => 'BAR', 22 | ), 23 | ) 24 | -------------------------------------------------------------------------------- /tests/runkit_constant_add_object_php81.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_add() function can add objects in php 8.1+ 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | 'value']); 17 | runkit7_constant_add('Hearts', Suit::Hearts); 18 | runkit7_constant_add('Diamonds', [Suit::Diamonds, Suit::Diamonds]); 19 | runkit7_constant_add('Suit::SpadesAlias', Suit::Spades); 20 | var_dump(Hearts); 21 | var_dump(FOO); 22 | var_dump(Diamonds); 23 | var_dump(Suit::SpadesAlias); 24 | var_dump(runkit7_constant_remove('Diamonds')); 25 | foreach (['Spades', 'SpadesAlias'] as $const_name) { 26 | $rc = new ReflectionClassConstant(Suit::class, $const_name); 27 | printf("Suit::%s: case=%s\n", $const_name, var_export($rc->isEnumCase(), true)); 28 | printf("Suit::%s: public=%s\n", $const_name, var_export($rc->isPublic(), true)); 29 | var_dump(runkit7_constant_remove("Suit::$const_name")); 30 | var_dump($rc); 31 | } 32 | echo "Test redefining not supported\n"; 33 | var_dump(runkit7_constant_redefine('Suit::Hearts', Suit::Diamonds)); 34 | var_dump(Suit::Hearts); 35 | runkit7_constant_redefine('FOO', Suit::Clubs); 36 | var_dump(FOO); 37 | 38 | ?> 39 | --EXPECTF-- 40 | enum(Suit::Hearts) 41 | object(stdClass)#%d (1) { 42 | ["key"]=> 43 | string(5) "value" 44 | } 45 | array(2) { 46 | [0]=> 47 | enum(Suit::Diamonds) 48 | [1]=> 49 | enum(Suit::Diamonds) 50 | } 51 | enum(Suit::Spades) 52 | bool(true) 53 | Suit::Spades: case=true 54 | Suit::Spades: public=true 55 | 56 | Warning: runkit7_constant_remove(): Refusing to remove enum case Suit::Spades in %s on line 21 57 | bool(false) 58 | object(ReflectionClassConstant)#%d (2) { 59 | ["name"]=> 60 | string(6) "Spades" 61 | ["class"]=> 62 | string(4) "Suit" 63 | } 64 | Suit::SpadesAlias: case=false 65 | Suit::SpadesAlias: public=true 66 | bool(true) 67 | object(ReflectionClassConstant)#%d (2) { 68 | ["name"]=> 69 | string(11) "SpadesAlias" 70 | ["class"]=> 71 | string(4) "Suit" 72 | } 73 | Test redefining not supported 74 | 75 | Warning: runkit7_constant_redefine(): Refusing to remove enum case Suit::Hearts in %s on line 25 76 | bool(false) 77 | enum(Suit::Hearts) 78 | enum(Suit::Clubs) -------------------------------------------------------------------------------- /tests/runkit_constant_add_to_class.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_add() function redefines class constants 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 18 | --EXPECT-- 19 | string(14) "TestClass::FOO" 20 | string(14) "TestClass::FOO" 21 | string(3) "bar" 22 | -------------------------------------------------------------------------------- /tests/runkit_constant_redefine.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_redefine() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 12 | --EXPECT-- 13 | The FOO constant 14 | The constant known as FOO 15 | -------------------------------------------------------------------------------- /tests/runkit_constant_redefine_in_class.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_redefine() function redefines class constants 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 20 | --EXPECT-- 21 | string(14) "TestClass::FOO" 22 | string(14) "TestClass::FOO" 23 | string(3) "bar" 24 | --XFAIL-- 25 | Expected to fail because PHP VM inlines class constants as their value 26 | within the same file when it is safe to do so. 27 | -------------------------------------------------------------------------------- /tests/runkit_constant_redefine_protected_across_file.inc: -------------------------------------------------------------------------------- 1 | 7 | --FILE-- 8 | getMessage()); 25 | } 26 | } 27 | access_protected_constant(); 28 | $const = 'TestBaseClass::_FOO'; 29 | var_dump($const, TestClass::get_foo()); 30 | runkit7_constant_redefine($const, 'roh'); 31 | var_dump($const, TestClass::get_foo()); 32 | $x = TestClass::get_foo(); 33 | runkit7_constant_redefine($const, $x); 34 | var_dump($const, TestClass::get_foo()); 35 | runkit7_constant_redefine($const, ['dah']); 36 | var_dump($const, TestClass::get_foo()); 37 | runkit7_constant_redefine($const, 2); 38 | var_dump($const, TestClass::get_foo()); 39 | access_protected_constant(); 40 | // Redefine it as public, and the access should then work. 41 | runkit7_constant_redefine($const, "bar", RUNKIT7_ACC_PUBLIC); 42 | var_dump($const, TestClass::get_foo()); 43 | access_protected_constant(); 44 | // TODO test subclass 45 | ?> 46 | --EXPECTF-- 47 | Caught Error: Cannot access protected const%S TestClass::_FOO 48 | string(19) "TestBaseClass::_FOO" 49 | string(3) "foo" 50 | string(19) "TestBaseClass::_FOO" 51 | string(3) "roh" 52 | string(19) "TestBaseClass::_FOO" 53 | string(3) "roh" 54 | string(19) "TestBaseClass::_FOO" 55 | array(1) { 56 | [0]=> 57 | string(3) "dah" 58 | } 59 | string(19) "TestBaseClass::_FOO" 60 | int(2) 61 | Caught Error: Cannot access protected const%S TestClass::_FOO 62 | string(19) "TestBaseClass::_FOO" 63 | string(3) "bar" 64 | Fetched constant, value='bar' 65 | -------------------------------------------------------------------------------- /tests/runkit_constant_remove.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_remove() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 14 | --EXPECT-- 15 | BAR 16 | BAZ 17 | -------------------------------------------------------------------------------- /tests/runkit_constant_remove_from_class.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_remove() function removes constant from class 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 19 | --EXPECTF-- 20 | string(14) "TestClass::FOO" 21 | string(14) "TestClass::FOO" 22 | 23 | Fatal error: Undefined class constant 'FOO' in %s on line %d 24 | --XFAIL-- 25 | Expected to fail because PHP VM inlines class constants as their value 26 | within the same file when it is safe to do so. 27 | -------------------------------------------------------------------------------- /tests/runkit_constant_remove_from_class_without_inlining.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_remove() function removes constant from class (Easier to do: no inlined constants) 3 | --POST-- 4 | x=1 5 | --SKIPIF-- 6 | 9 | --FILE-- 10 | 29 | --EXPECTF-- 30 | string(14) "TestClass::FOO" 31 | string(14) "TestClass::FOO" 32 | 33 | Fatal error: Uncaught Error: Undefined %Sconstant %sFOO%S in %s:%d 34 | Stack trace: 35 | #0 {main} 36 | thrown in %s on line %d 37 | -------------------------------------------------------------------------------- /tests/runkit_constant_remove_from_ns.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_constant_remove(), runkit7_constant_add(), and namespaces 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | 51 | --EXPECT-- 52 | string(4) "test" 53 | bool(true) 54 | bool(false) 55 | bool(true) 56 | string(5) "test1" 57 | bool(true) 58 | bool(false) 59 | bool(true) 60 | string(5) "test2" 61 | 62 | string(4) "test" 63 | bool(true) 64 | bool(false) 65 | bool(true) 66 | string(5) "test1" 67 | bool(true) 68 | bool(false) 69 | bool(true) 70 | string(5) "test2" 71 | 72 | string(4) "test" 73 | bool(true) 74 | bool(false) 75 | bool(true) 76 | string(5) "test1" 77 | bool(true) 78 | bool(false) 79 | bool(true) 80 | string(5) "test2" 81 | ==DONE== 82 | --XFAIL-- 83 | Expected to fail because PHP VM inlines class constants as their value 84 | within the same file when it is safe to do so. 85 | -------------------------------------------------------------------------------- /tests/runkit_constants_manipulations_and_cache.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test for caching issues on manipulations with constants 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | a($result); 36 | } 37 | echo "" . A . "\n"; 38 | echo "" . RunkitClass::A . "\n"; 39 | } 40 | } 41 | 42 | $t = new Test(); 43 | $t->t(); 44 | --EXPECT-- 45 | 200 46 | 200 47 | --XFAIL-- 48 | Expected to fail because PHP VM inlines class constants as their value 49 | within the same file when it is safe to do so. 50 | -------------------------------------------------------------------------------- /tests/runkit_default_property_add.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() function 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | 1)); 19 | runkit_default_property_add($className, $propName, $value, RUNKIT7_ACC_PUBLIC); 20 | runkit_default_property_add($className, 'privateProperty', "a", RUNKIT7_ACC_PRIVATE); 21 | runkit_default_property_add($className, 'protectedProperty', NULL, RUNKIT7_ACC_PROTECTED); 22 | $obj = new $className(); 23 | runkit_default_property_add($className, 'dynamic', $obj, RUNKIT7_OVERRIDE_OBJECTS); 24 | $value = 10; 25 | print_r(new $className()); 26 | 27 | runkit_default_property_add('stdClass', 'str', 'test'); 28 | 29 | $obj = new stdClass(); 30 | print_r($obj); 31 | ?> 32 | --EXPECTF-- 33 | RunkitClass Object 34 | ( 35 | [constArray] => Array 36 | ( 37 | [a] => 1 38 | ) 39 | 40 | [publicProperty] => 1 41 | [privateProperty%sprivate] => a 42 | [protectedProperty:protected] =>%w 43 | [dynamic] => RunkitClass Object 44 | ( 45 | [constArray] => Array 46 | ( 47 | [a] => 1 48 | ) 49 | 50 | [publicProperty] => 1 51 | [privateProperty%sprivate] => a 52 | [protectedProperty:protected] =>%w 53 | %w[dynamic] => RunkitClass Object 54 | %w*RECURSION*%w 55 | ) 56 | 57 | ) 58 | 59 | Warning: runkit_default_property_add(): Adding properties to internal classes is not allowed in %s on line %d 60 | stdClass Object 61 | ( 62 | ) 63 | -------------------------------------------------------------------------------- /tests/runkit_default_property_add_and_remove_for_class_with_dynamic_properties.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() and runkit_default_property_remove() functions on classes having dynamic properties 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | b = 1; 18 | echo 'b=', $o->b, "\n"; 19 | echo 'd=', $o->d, "\n"; 20 | runkit_default_property_add('A', 'b', 2); 21 | echo 'b=', $o->b, "\n"; 22 | echo 'd=', $o->d, "\n"; 23 | runkit_default_property_remove('A', 'b'); 24 | $o1 = new A; 25 | echo 'b=', $o->b, "\n"; 26 | echo 'b=', @$o1->b, "\n"; 27 | echo 'd=', $o->d, "\n"; 28 | echo 'd=', $o1->d, "\n"; 29 | 30 | echo "\n"; 31 | 32 | $o = new B; 33 | echo 'b=', @$o->b, "\n"; 34 | echo 'd=', $o->d, "\n"; 35 | $o->b = 1; 36 | echo 'b=', $o->b, "\n"; 37 | echo 'd=', $o->d, "\n"; 38 | runkit_default_property_add('A', 'b', 2); 39 | echo 'b=', $o->b, "\n"; 40 | echo 'd=', $o->d, "\n"; 41 | runkit_default_property_remove('A', 'b'); 42 | $o1 = new B; 43 | echo 'b=', $o->b, "\n"; 44 | echo 'b=', @$o1->b, "\n"; 45 | echo 'd=', $o->d, "\n"; 46 | echo 'd=', $o1->d, "\n"; 47 | --EXPECT-- 48 | b=1 49 | d=3 50 | b=1 51 | d=3 52 | b=1 53 | b= 54 | d=3 55 | d=3 56 | 57 | b= 58 | d=3 59 | b=1 60 | d=3 61 | b=1 62 | d=3 63 | b=1 64 | b= 65 | d=3 66 | d=3 67 | -------------------------------------------------------------------------------- /tests/runkit_default_property_add_and_remove_for_class_with_dynamic_properties_overriding_in_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() and runkit_default_property_remove() functions on classes having dynamic properties overriding in objects 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | b = 1; 18 | echo 'b=', $o->b, "\n"; 19 | echo 'd=', $o->d, "\n"; 20 | runkit_default_property_add('A', 'b', 2, RUNKIT7_OVERRIDE_OBJECTS); 21 | echo 'b=', $o->b, "\n"; 22 | echo 'd=', $o->d, "\n"; 23 | runkit_default_property_remove('A', 'b'); 24 | $o1 = new A; 25 | echo 'b=', $o->b, "\n"; 26 | echo 'b=', @$o1->b, "\n"; 27 | echo 'd=', $o->d, "\n"; 28 | echo 'd=', $o1->d, "\n"; 29 | 30 | echo "\n"; 31 | 32 | $o = new B; 33 | echo 'b=', @$o->b, "\n"; 34 | echo 'd=', $o->d, "\n"; 35 | $o->b = 1; 36 | echo 'b=', $o->b, "\n"; 37 | echo 'd=', $o->d, "\n"; 38 | runkit_default_property_add('A', 'b', 2, RUNKIT7_OVERRIDE_OBJECTS); 39 | echo 'b=', $o->b, "\n"; 40 | echo 'd=', $o->d, "\n"; 41 | runkit_default_property_remove('A', 'b'); 42 | $o1 = new B; 43 | echo 'b=', $o->b, "\n"; 44 | echo 'b=', @$o1->b, "\n"; 45 | echo 'd=', $o->d, "\n"; 46 | echo 'd=', $o1->d, "\n"; 47 | runkit_default_property_remove('A', 'd', 1); 48 | $o1 = new B; 49 | echo 'd=', @$o->d, "\n"; 50 | echo 'd=', @$o1->d, "\n"; 51 | --EXPECT-- 52 | b=1 53 | d=3 54 | b=2 55 | d=3 56 | b=2 57 | b= 58 | d=3 59 | d=3 60 | 61 | b= 62 | d=3 63 | b=1 64 | d=3 65 | b=2 66 | d=3 67 | b=2 68 | b= 69 | d=3 70 | d=3 71 | d= 72 | d= 73 | -------------------------------------------------------------------------------- /tests/runkit_default_property_add_instance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() function - instance override 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | 20 | --EXPECTF-- 21 | RunkitClass Object 22 | ( 23 | ) 24 | RunkitClass Object 25 | ( 26 | [theAnswer] => 42 27 | ) 28 | 29 | -------------------------------------------------------------------------------- /tests/runkit_default_property_add_overriding_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() function with overriding objects 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | 1), RUNKIT7_OVERRIDE_OBJECTS); 20 | runkit_default_property_add($className, $propName, $value, RUNKIT7_ACC_PUBLIC | RUNKIT7_OVERRIDE_OBJECTS); 21 | runkit_default_property_add($className, 'privateProperty', "a", RUNKIT7_ACC_PRIVATE | RUNKIT7_OVERRIDE_OBJECTS); 22 | runkit_default_property_add($className, 'protectedProperty', NULL, RUNKIT7_ACC_PROTECTED | RUNKIT7_OVERRIDE_OBJECTS); 23 | runkit_default_property_add($className, 'dynamic', $obj, RUNKIT7_OVERRIDE_OBJECTS); 24 | $value = 10; 25 | print_r($obj); 26 | 27 | $obj = new stdClass(); 28 | runkit_default_property_add('stdClass', 'str', 'test', RUNKIT7_OVERRIDE_OBJECTS); 29 | print_r($obj); 30 | ?> 31 | --EXPECTF-- 32 | RunkitClass Object 33 | ( 34 | [constArray] => Array 35 | ( 36 | [a] => 1 37 | ) 38 | 39 | [publicProperty] => 1 40 | [privateProperty%sprivate] => a 41 | [protectedProperty:protected] =>%w 42 | %w[dynamic] => RunkitClass Object 43 | %w*RECURSION*%w 44 | ) 45 | 46 | Warning: runkit_default_property_add(): Adding properties to internal classes is not allowed in %s on line %d 47 | stdClass Object 48 | ( 49 | ) 50 | -------------------------------------------------------------------------------- /tests/runkit_default_property_add_to_subclasses.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() add properties to subclasses 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | privateProperty = "b";} 14 | public function setProtected() {$this->protectedProperty = 1;} 15 | } 16 | 17 | class RunkitSubClass extends RunkitClass {} 18 | class StdSubClass extends stdClass {} 19 | 20 | $className = 'RunkitClass'; 21 | $propName = 'publicProperty'; 22 | $parentObj = new $className; 23 | runkit_default_property_add($className, 'constArray', array('a'=>1)); 24 | runkit_default_property_add($className, $propName, 1, RUNKIT7_ACC_PUBLIC); 25 | runkit_default_property_add($className, 'privateProperty', "a", RUNKIT7_ACC_PRIVATE); 26 | runkit_default_property_add($className, 'protectedProperty', NULL, RUNKIT7_ACC_PROTECTED); 27 | $obj = new RunkitSubClass; 28 | runkit_default_property_add($className, 'dynamic', $obj); 29 | 30 | $parentObj->constArray = array('b'=>2); 31 | $parentObj->publicProperty = 2; 32 | $parentObj->setPrivate(); 33 | $parentObj->setProtected(); 34 | $parentObj->dynamic = $parentObj; 35 | 36 | print_r($obj); 37 | print_r(new RunkitSubClass); 38 | 39 | runkit_default_property_add('StdSubClass', 'str', 'test'); 40 | 41 | $obj = new StdSubClass(); 42 | print_r($obj); 43 | ?> 44 | --EXPECTF-- 45 | RunkitSubClass Object 46 | ( 47 | [constArray] => Array 48 | ( 49 | [a] => 1 50 | ) 51 | 52 | [publicProperty] => 1 53 | [privateProperty%sprivate] => a 54 | [protectedProperty:protected] =>%w 55 | ) 56 | RunkitSubClass Object 57 | ( 58 | [constArray] => Array 59 | ( 60 | [a] => 1 61 | ) 62 | 63 | [publicProperty] => 1 64 | [privateProperty%sprivate] => a 65 | [protectedProperty:protected] =>%w 66 | [dynamic] => RunkitSubClass Object 67 | ( 68 | [constArray] => Array 69 | ( 70 | [a] => 1 71 | ) 72 | 73 | [publicProperty] => 1 74 | [privateProperty%sprivate] => a 75 | [protectedProperty:protected] =>%w 76 | ) 77 | 78 | ) 79 | StdSubClass Object 80 | ( 81 | [str] => test 82 | ) 83 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() function 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | 41 | --EXPECTF-- 42 | Warning: runkit_default_property_remove(): RunkitClass::publicproperty does not exist in %s on line %d 43 | RunkitClass Object 44 | ( 45 | [publicProperty] => 1 46 | ) 47 | 48 | Warning: runkit_default_property_remove(): Removing properties from internal classes is not allowed in %s on line %d 49 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_and_add_for_class_with_dynamic_properties.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() and runkit_default_property_add() functions on classes having dynamic properties (without overriding objects) 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | c;} 13 | } 14 | class B extends A {} 15 | 16 | $o = new B; 17 | echo $o->getC(), "\n"; 18 | echo $o->b, $o->d, "\n"; 19 | $o->b = 'b'; 20 | echo $o->getC(), "\n"; 21 | echo $o->b, $o->d, "\n"; 22 | echo "remove\n"; 23 | runkit_default_property_remove('A', 'c'); 24 | echo $o->getC(), "\n"; 25 | echo $o->b, $o->d, "\n"; 26 | echo "add public\n"; 27 | runkit_default_property_add('A', 'c', 2); 28 | echo $o->getC(), "\n"; 29 | echo $o->b, $o->d, "\n"; 30 | echo "remove\n"; 31 | runkit_default_property_remove('A', 'c'); 32 | $o1 = new B; 33 | echo $o1->getC(), "\n"; 34 | echo $o->getC(), "\n"; 35 | echo $o->b, $o->d, "\n"; 36 | echo "add private\n"; 37 | runkit_default_property_add('A', 'c', 3, RUNKIT7_ACC_PRIVATE); 38 | echo $o->getC(), "\n"; 39 | echo $o->b, $o->d, "\n"; 40 | echo "remove\n"; 41 | runkit_default_property_remove('A', 'c'); 42 | echo $o->getC(), "\n"; 43 | echo $o->b, $o->d, "\n"; 44 | echo "add public to B\n"; 45 | runkit_default_property_add('B', 'c', 2); 46 | echo $o->getC(), "\n"; 47 | echo $o->b, $o->d, "\n"; 48 | --EXPECTF-- 49 | 1 50 | 51 | Notice: Undefined property: B::$b in %s on line %d 52 | d 53 | 1 54 | bd 55 | remove 56 | 57 | Notice: runkit_default_property_remove(): Making B::c public to remove it from class without objects overriding in %s on line %d 58 | 1 59 | bd 60 | add public 61 | 1 62 | bd 63 | remove 64 | 65 | Notice: Undefined property: B::$c in %s on line %d 66 | 67 | 1 68 | bd 69 | add private 70 | 1 71 | bd 72 | remove 73 | 74 | Notice: runkit_default_property_remove(): Making B::c public to remove it from class without objects overriding in %s on line %d 75 | 1 76 | bd 77 | add public to B 78 | 1 79 | bd 80 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_and_add_for_class_with_dynamic_properties_overriding_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() and runkit_default_property_add() functions on classes having dynamic properties (overriding objects) 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | c;} 13 | } 14 | class B extends A {} 15 | 16 | $o = new B; 17 | echo $o->getC(), "\n"; 18 | echo $o->b, $o->d, "\n"; 19 | $o->b = 'b'; 20 | echo $o->getC(), "\n"; 21 | echo $o->b, $o->d, "\n"; 22 | echo "remove\n"; 23 | runkit_default_property_remove('A', 'c', TRUE); 24 | echo $o->getC(), "\n"; 25 | echo $o->b, $o->d, "\n"; 26 | echo "add public\n"; 27 | runkit_default_property_add('A', 'c', 2, RUNKIT7_OVERRIDE_OBJECTS); 28 | echo $o->getC(), "\n"; 29 | echo $o->b, $o->d, "\n"; 30 | echo "remove\n"; 31 | runkit_default_property_remove('A', 'c', TRUE); 32 | $o1 = new B; 33 | echo $o1->getC(), "\n"; 34 | echo $o->getC(), "\n"; 35 | echo $o->b, $o->d, "\n"; 36 | echo "add private\n"; 37 | runkit_default_property_add('A', 'c', 3, RUNKIT7_ACC_PRIVATE | RUNKIT7_OVERRIDE_OBJECTS); 38 | echo $o->getC(), "\n"; 39 | echo $o->b, $o->d, "\n"; 40 | echo "remove\n"; 41 | runkit_default_property_remove('A', 'c', TRUE); 42 | echo $o->getC(), "\n"; 43 | echo $o->b, $o->d, "\n"; 44 | echo "add public to B\n"; 45 | runkit_default_property_add('B', 'c', 2, RUNKIT7_OVERRIDE_OBJECTS); 46 | echo $o->getC(), "\n"; 47 | echo $o->b, $o->d, "\n"; 48 | --EXPECTF-- 49 | 1 50 | 51 | Notice: Undefined property: B::$b in %s on line %d 52 | d 53 | 1 54 | bd 55 | remove 56 | 57 | Notice: Undefined property: B::$c in %s on line %d 58 | 59 | bd 60 | add public 61 | 2 62 | bd 63 | remove 64 | 65 | Notice: Undefined property: B::$c in %s on line %d 66 | 67 | 68 | Notice: Undefined property: B::$c in %s on line %d 69 | 70 | bd 71 | add private 72 | 3 73 | bd 74 | remove 75 | 76 | Notice: Undefined property: B::$c in %s on line %d 77 | 78 | bd 79 | add public to B 80 | 2 81 | bd 82 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_remove() function with reflection 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | getProperty('publicProperty')); 23 | echo 'No exception!'; 24 | } catch (ReflectionException $e) { 25 | } 26 | 27 | try { 28 | var_dump($reflObject->getProperty('publicProperty')); 29 | echo 'No exception!'; 30 | } catch (ReflectionException $e) { 31 | } 32 | var_dump($reflProp); 33 | $reflProp->setValue($obj, 'test'); 34 | ?> 35 | --EXPECTF-- 36 | object(ReflectionProperty)#%d (2) { 37 | ["name"]=> 38 | string(30) "__property_removed_by_runkit__" 39 | ["class"]=> 40 | string(11) "RunkitClass" 41 | } 42 | 43 | Fatal error:%sInternal error: Failed to retrieve the reflection object in %s on line %d 44 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_from_subclasses.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() remove properties from subclasses 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | 44 | --EXPECTF-- 45 | Warning: runkit_default_property_remove(): RunkitClass::publicproperty does not exist in %s on line %d 46 | 47 | Notice: runkit_default_property_remove(): Making RunkitSubClass::privateProperty public to remove it from class without objects overriding in %s on line %d 48 | 49 | Notice: runkit_default_property_remove(): Making RunkitSubClass::protectedProperty public to remove it from class without objects overriding in %s on line %d 50 | RunkitSubClass Object 51 | ( 52 | [publicProperty] => 1 53 | ) 54 | StdSubClass Object 55 | ( 56 | ) 57 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_from_subclasses_overriding_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() remove properties from subclasses overriding objects 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | 44 | --EXPECTF-- 45 | Warning: runkit_default_property_remove(): RunkitClass::publicproperty does not exist in %s on line %d 46 | RunkitSubClass Object 47 | ( 48 | [publicProperty] => 1 49 | ) 50 | StdSubClass Object 51 | ( 52 | ) 53 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_inheritance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() remove properties with inheritance 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | privateProperty;} 26 | } 27 | class RunkitSubSubClass extends RunkitSubClass { 28 | protected $protectedProperty = "cc"; 29 | } 30 | 31 | ini_set('display_errors', 1); 32 | ini_set('error_reporting', E_ALL); 33 | 34 | $className = 'RunkitClass'; 35 | $obj = new RunkitSubSubClass(); 36 | 37 | runkit_default_property_remove($className, 'publicProperty'); 38 | runkit_default_property_remove($className, 'privateProperty'); 39 | runkit_default_property_remove($className, 'protectedProperty'); 40 | runkit_default_property_remove('RunkitSubClass', 'removedProperty'); 41 | runkit_default_property_remove($className, 'removedProperty'); 42 | print_r(new RunkitClass()); 43 | print_r(new RunkitSubClass()); 44 | print_r($obj); 45 | print_r($obj->getPrivate()); 46 | ?> 47 | --EXPECTF-- 48 | Notice: runkit_default_property_remove(): Making RunkitSubSubClass::privateProperty public to remove it from class without objects overriding in %s on line %d 49 | RunkitClass Object 50 | ( 51 | ) 52 | RunkitSubClass Object 53 | ( 54 | [publicProperty] => 2 55 | [privateProperty%sprivate] => aa 56 | [protectedProperty:protected] => bb 57 | [staticProperty:protected] => ss 58 | ) 59 | RunkitSubSubClass Object 60 | ( 61 | [protectedProperty:protected] => cc 62 | [publicProperty] => 2 63 | [privateProperty%sprivate] => aa 64 | [staticProperty:protected] => ss 65 | [removedProperty] => r 66 | [privateProperty] => a 67 | ) 68 | aa 69 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_inheritance_overriding_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() remove properties with inheritance overriding objects 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | privateProperty;} 26 | } 27 | class RunkitSubSubClass extends RunkitSubClass { 28 | protected $protectedProperty = "cc"; 29 | } 30 | 31 | ini_set('display_errors', 1); 32 | ini_set('error_reporting', E_ALL); 33 | 34 | $className = 'RunkitClass'; 35 | $obj = new RunkitSubSubClass(); 36 | 37 | runkit_default_property_remove($className, 'publicProperty', TRUE); 38 | runkit_default_property_remove($className, 'privateProperty', TRUE); 39 | runkit_default_property_remove($className, 'protectedProperty', TRUE); 40 | runkit_default_property_remove('RunkitSubClass', 'removedProperty', TRUE); 41 | runkit_default_property_remove($className, 'removedProperty', TRUE); 42 | $out = print_r($obj, true); 43 | print $out; 44 | print_r($obj->getPrivate()); 45 | ?> 46 | --EXPECTF-- 47 | RunkitSubSubClass Object 48 | ( 49 | [protectedProperty:protected] => cc 50 | [publicProperty] => 2 51 | [privateProperty%sprivate] => aa 52 | [staticProperty:protected] => ss 53 | ) 54 | aa 55 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_overriding_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() function overriding objects 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | 39 | --EXPECTF-- 40 | Warning: runkit_default_property_remove(): RunkitClass::publicproperty does not exist in %s on line %d 41 | RunkitClass Object 42 | ( 43 | [publicProperty] => 1 44 | ) 45 | 46 | Warning: runkit_default_property_remove(): Removing properties from internal classes is not allowed in %s on line %d 47 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_private_and_inheritance_overriding_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() remove private properties with inheritance overriding objects 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | privateProperty;} 15 | } 16 | 17 | class RunkitSubClass extends RunkitClass { 18 | } 19 | 20 | class RunkitSubSubClass extends RunkitSubClass { 21 | private $privateProperty = "overridden"; 22 | function getPrivate1() {return $this->privateProperty;} 23 | } 24 | 25 | class RunkitSubSubSubClass extends RunkitSubSubClass { 26 | } 27 | 28 | ini_set('display_errors', 1); 29 | ini_set('error_reporting', E_ALL); 30 | 31 | $obj = new RunkitClass(); 32 | $objs = new RunkitSubClass(); 33 | $objss = new RunkitSubSubClass(); 34 | $objsss = new RunkitSubSubSubClass(); 35 | 36 | runkit_default_property_remove('RunkitClass', 'privateProperty', TRUE); 37 | print_r($obj); 38 | print_r($objs); 39 | print_r($objss); 40 | print_r($objsss); 41 | echo $obj->getPrivate(), "\n"; 42 | echo $objs->getPrivate(), "\n"; 43 | echo $objss->getPrivate1(), "\n"; 44 | echo $objsss->getPrivate1(), "\n"; 45 | ?> 46 | --EXPECTF-- 47 | RunkitClass Object 48 | ( 49 | ) 50 | RunkitSubClass Object 51 | ( 52 | ) 53 | RunkitSubSubClass Object 54 | ( 55 | [privateProperty%sprivate] => overridden 56 | ) 57 | RunkitSubSubSubClass Object 58 | ( 59 | [privateProperty%sprivate] => overridden 60 | ) 61 | 62 | Notice: Undefined property: RunkitClass::$privateProperty in %s on line %d 63 | 64 | 65 | Notice: Undefined property: RunkitSubClass::$privateProperty in %s on line %d 66 | 67 | overridden 68 | overridden 69 | 70 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_private_shadow_and_inheritance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() remove private properties with inheritance 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | privateProperty;} 15 | } 16 | 17 | class RunkitSubClass extends RunkitClass { 18 | } 19 | 20 | class RunkitSubSubClass extends RunkitSubClass { 21 | private $privateProperty = "overridden"; 22 | function getPrivate1() {return $this->privateProperty;} 23 | } 24 | 25 | class RunkitSubSubSubClass extends RunkitSubSubClass { 26 | } 27 | 28 | ini_set('display_errors', 1); 29 | ini_set('error_reporting', E_ALL); 30 | 31 | $obj = new RunkitClass(); 32 | $objs = new RunkitSubClass(); 33 | $objss = new RunkitSubSubClass(); 34 | $objsss = new RunkitSubSubSubClass(); 35 | 36 | runkit_default_property_remove('RunkitSubClass', 'privateProperty'); 37 | print_r(new RunkitClass()); 38 | print_r(new RunkitSubClass()); 39 | print_r(new RunkitSubSubClass()); 40 | print_r(new RunkitSubSubSubClass()); 41 | print_r($obj); 42 | print_r($objs); 43 | print_r($objss); 44 | print_r($objsss); 45 | echo $obj->getPrivate(), "\n"; 46 | echo $objs->getPrivate(), "\n"; 47 | echo $objss->getPrivate(), "\n"; 48 | echo $objsss->getPrivate(), "\n"; 49 | ?> 50 | --EXPECTF-- 51 | RunkitClass Object 52 | ( 53 | [privateProperty%sprivate] => original 54 | ) 55 | RunkitSubClass Object 56 | ( 57 | ) 58 | RunkitSubSubClass Object 59 | ( 60 | [privateProperty%sprivate] => overridden 61 | [privateProperty%sprivate] => original 62 | ) 63 | RunkitSubSubSubClass Object 64 | ( 65 | [privateProperty%sprivate] => overridden 66 | [privateProperty%sprivate] => original 67 | ) 68 | RunkitClass Object 69 | ( 70 | [privateProperty%sprivate] => original 71 | ) 72 | RunkitSubClass Object 73 | ( 74 | [privateProperty%sprivate] => original 75 | ) 76 | RunkitSubSubClass Object 77 | ( 78 | [privateProperty%sprivate] => overridden 79 | [privateProperty%sprivate] => original 80 | ) 81 | RunkitSubSubSubClass Object 82 | ( 83 | [privateProperty%sprivate] => overridden 84 | [privateProperty%sprivate] => original 85 | ) 86 | original 87 | original 88 | original 89 | original 90 | 91 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_private_shadow_and_inheritance_overriding_objects.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() remove private properties with inheritance with objects overriding 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | privateProperty;} 15 | } 16 | 17 | class RunkitSubClass extends RunkitClass { 18 | } 19 | 20 | class RunkitSubSubClass extends RunkitSubClass { 21 | private $privateProperty = "overridden"; 22 | function getPrivate1() {return $this->privateProperty;} 23 | } 24 | 25 | class RunkitSubSubSubClass extends RunkitSubSubClass { 26 | } 27 | 28 | ini_set('display_errors', 1); 29 | ini_set('error_reporting', E_ALL); 30 | 31 | $obj = new RunkitClass(); 32 | $objs = new RunkitSubClass(); 33 | $objss = new RunkitSubSubClass(); 34 | $objsss = new RunkitSubSubSubClass(); 35 | 36 | runkit_default_property_remove('RunkitSubClass', 'privateProperty', TRUE); 37 | print_r(new RunkitClass()); 38 | print_r(new RunkitSubClass()); 39 | print_r(new RunkitSubSubClass()); 40 | print_r(new RunkitSubSubSubClass()); 41 | print_r($obj); 42 | print_r($objs); 43 | print_r($objss); 44 | print_r($objsss); 45 | echo $obj->getPrivate(), "\n"; 46 | echo $objs->getPrivate(), "\n"; 47 | echo $objss->getPrivate(), "\n"; 48 | echo $objsss->getPrivate(), "\n"; 49 | ?> 50 | --EXPECTF-- 51 | RunkitClass Object 52 | ( 53 | [privateProperty%sprivate] => original 54 | ) 55 | RunkitSubClass Object 56 | ( 57 | ) 58 | RunkitSubSubClass Object 59 | ( 60 | [privateProperty%sprivate] => overridden 61 | ) 62 | RunkitSubSubSubClass Object 63 | ( 64 | [privateProperty%sprivate] => overridden 65 | ) 66 | RunkitClass Object 67 | ( 68 | [privateProperty%sprivate] => original 69 | ) 70 | RunkitSubClass Object 71 | ( 72 | ) 73 | RunkitSubSubClass Object 74 | ( 75 | [privateProperty%sprivate] => overridden 76 | ) 77 | RunkitSubSubSubClass Object 78 | ( 79 | [privateProperty%sprivate] => overridden 80 | ) 81 | original 82 | 83 | Notice: Undefined property: RunkitSubClass::$privateProperty in %s on line %d 84 | 85 | 86 | Notice: Undefined property: RunkitSubSubClass::$privateProperty in %s on line %d 87 | 88 | 89 | Notice: Undefined property: RunkitSubSubSubClass::$privateProperty in %s on line %d 90 | -------------------------------------------------------------------------------- /tests/runkit_default_property_remove_simple.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_remove() function 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=On 10 | --FILE-- 11 | publicproperty); 23 | printf("%s\n", isset($a->publicproperty)); 24 | runkit_default_property_remove($className, 'publicproperty'); 25 | $b = new RunkitClass(); 26 | printf("%s\n", $b->publicproperty); 27 | printf("%s\n", $a->publicProperty); 28 | --EXPECTF-- 29 | 2 30 | 1 31 | 32 | 1 33 | -------------------------------------------------------------------------------- /tests/runkit_finally.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | copy method with finally 3 | --SKIPIF-- 4 | 7 | --FILE-- 8 | bar(); 26 | 27 | ?> 28 | --EXPECTF-- 29 | test 30 | -------------------------------------------------------------------------------- /tests/runkit_fpm_internal_function_restore.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Test restoring internal functions after renaming and copying under fpm 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 21 | Done 22 | --EXPECTF-- 23 | [%s] NOTICE: fpm is running, pid %d 24 | [%s] NOTICE: ready to handle connections 25 | Test Start 26 | true 27 | A B 28 | C D 29 | Test End 30 | 31 | Request ok 32 | Test Start 33 | true 34 | A B 35 | C D 36 | Test End 37 | 38 | Request ok 39 | Test Start 40 | true 41 | A B 42 | C D 43 | Test End 44 | 45 | Request ok 46 | [%s] NOTICE: Terminating ... 47 | [%s] NOTICE: exiting, bye-bye! 48 | Done 49 | --CLEAN-- 50 | 54 | -------------------------------------------------------------------------------- /tests/runkit_function_add.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_add() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 12 | --EXPECT-- 13 | a is foo 14 | b is bar 15 | c is baz 16 | runkitSample 17 | -------------------------------------------------------------------------------- /tests/runkit_function_add_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_function_add() function 3 | --INI-- 4 | error_reporting=E_ALL 5 | display_errors=on 6 | --SKIPIF-- 7 | 8 | --FILE-- 9 | 15 | --EXPECTF-- 16 | Deprecated: Function runkit_function_add() is deprecated in %srunkit_function_add_alias.php on line 3 17 | a is foo 18 | b is bar 19 | c is baz 20 | runkitSample -------------------------------------------------------------------------------- /tests/runkit_function_add_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_add() function and doc_comment 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getDocComment(), "\n"; 12 | ?> 13 | --EXPECT-- 14 | new doc_comment 15 | -------------------------------------------------------------------------------- /tests/runkit_function_add_closure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function with closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getMessage() !== 'Using $this when not in object context') { 33 | throw $e; 34 | } 35 | printf("(In php7, this is a thrown Error, not a )Notice: Undefined variable: this in %s on line %d\n", $e->getFile(), $e->getLine()); 36 | var_dump(NULL); // Dump null to match --EXPECT-- 37 | } 38 | } 39 | ); 40 | runkit_function('foo', 'bar'); 41 | echo "d after call is $d\n"; 42 | } 43 | } 44 | $g = 'global'; 45 | $t = new test(); 46 | $t->run(); 47 | runkit_function('foo','bar'); 48 | ?> 49 | --EXPECTREGEX-- 50 | a is foo 51 | b is bar 52 | c is use 53 | d is ref_use 54 | g is global 55 | \$this is 56 | .*Notice: Undefined variable: this in .* on line \d+ 57 | NULL 58 | d after call is ref_use modified 59 | a is foo 60 | b is bar 61 | c is use 62 | d is ref_use modified 63 | g is global 64 | \$this is 65 | .*Notice: Undefined variable: this in .* on line \d+ 66 | NULL 67 | -------------------------------------------------------------------------------- /tests/runkit_function_add_closure_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_add() closure and doc_comment 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 14 | ?> 15 | --EXPECT-- 16 | new doc_comment 17 | -------------------------------------------------------------------------------- /tests/runkit_function_add_closure_and_doc_comment_from_closure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_add() closer and doc_comment from closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 16 | ?> 17 | --EXPECT-- 18 | /** new doc_comment */ 19 | -------------------------------------------------------------------------------- /tests/runkit_function_add_return_type.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_add() function should accept valid return types passed in as a string 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getMessage()); 17 | } 18 | ?> 19 | --EXPECTF-- 20 | Returned foo 21 | TypeError: %Srunkit_function()%S must be of%stype string, %s returned 22 | -------------------------------------------------------------------------------- /tests/runkit_function_add_return_type_invalid.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_add() function should detect invalid return types passed in as a string 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | 15 | --EXPECTF-- 16 | Warning: runkit7_function_add(): Return type should match regex %s in %s on line %d 17 | runkit_function_add returned: false 18 | Function exists: false 19 | -------------------------------------------------------------------------------- /tests/runkit_function_copy.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_copy() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | = 5) { 11 | $constArray = array('a'=>1); 12 | } 13 | for ($i = 0; $i < 10; $i++) {} 14 | $sample = "Sample"; 15 | if ($v[0] >= 5 && $constArray != array('a'=>1)) { 16 | echo "FAIL!"; 17 | } 18 | echo "$runkit $sample: $n\n"; 19 | } 20 | 21 | $oldName = 'runkitSample'; 22 | $newName = 'runkitDuplicate'; 23 | 24 | runkitSample(1); 25 | runkit7_function_copy($oldName, $newName); 26 | runkitSample(2); 27 | runkitDuplicate(3); 28 | runkit7_function_remove($oldName); 29 | if (function_exists('runkitSample')) { 30 | echo "runkitSample() still exists!\n"; 31 | } 32 | runkitDuplicate(4); 33 | echo $oldName, "\n"; 34 | echo $newName, "\n"; 35 | ?> 36 | --EXPECT-- 37 | Runkit Sample: 1 38 | Runkit Sample: 2 39 | Runkit Sample: 3 40 | Runkit Sample: 4 41 | runkitSample 42 | runkitDuplicate 43 | -------------------------------------------------------------------------------- /tests/runkit_function_copy_8.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_copy() function for union types 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | = 5) { 14 | $constArray = array('a'=>1); 15 | } 16 | for ($i = 0; $i < 10; $i++) {} 17 | $sample = "Sample"; 18 | if ($v[0] >= 5 && $constArray != array('a'=>1)) { 19 | echo "FAIL!"; 20 | } 21 | echo "$runkit $sample: $n\n"; 22 | } 23 | 24 | $oldName = 'runkitSample'; 25 | $newName = 'runkitDuplicate'; 26 | 27 | runkitSample(1); 28 | runkit7_function_copy($oldName, $newName); 29 | runkitSample(2); 30 | try { 31 | runkitSample([]); 32 | } catch (TypeError $e) { 33 | echo "Caught {$e->getMessage()}\n"; 34 | } 35 | runkitDuplicate(3); 36 | runkit7_function_remove($oldName); 37 | if (function_exists('runkitSample')) { 38 | echo "runkitSample() still exists!\n"; 39 | } 40 | runkitDuplicate(4); 41 | echo $oldName, "\n"; 42 | echo $newName, "\n"; 43 | try { 44 | runkitDuplicate(new stdClass()); 45 | } catch (TypeError $e) { 46 | echo "Caught {$e->getMessage()}\n"; 47 | } 48 | ?> 49 | --EXPECTF-- 50 | Runkit Sample: 1 51 | Runkit Sample: 2 52 | Caught runkitSample(): Argument #1 ($n) must be of type Stringable|string|int, array given, called in %srunkit_function_copy_8.php on line 23 53 | Runkit Sample: 3 54 | Runkit Sample: 4 55 | runkitSample 56 | runkitDuplicate 57 | Caught runkitDuplicate(): Argument #1 ($n) must be of type Stringable|string|int, stdClass given, called in %srunkit_function_copy_8.php on line 36 58 | -------------------------------------------------------------------------------- /tests/runkit_function_copy_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_function_copy() function 3 | --INI-- 4 | error_reporting=E_ALL 5 | display_errors=on 6 | --SKIPIF-- 7 | 8 | --FILE-- 9 | = 5) { 14 | $constArray = array('a'=>1); 15 | } 16 | for ($i = 0; $i < 10; $i++) {} 17 | $sample = "Sample"; 18 | if ($v[0] >= 5 && $constArray != array('a'=>1)) { 19 | echo "FAIL!"; 20 | } 21 | echo "$runkit $sample: $n\n"; 22 | } 23 | 24 | $oldName = 'runkitSample'; 25 | $newName = 'runkitDuplicate'; 26 | 27 | runkitSample(1); 28 | runkit_function_copy($oldName, $newName); 29 | runkitSample(2); 30 | runkitDuplicate(3); 31 | runkit_function_remove($oldName); 32 | if (function_exists('runkitSample')) { 33 | echo "runkitSample() still exists!\n"; 34 | } 35 | runkitDuplicate(4); 36 | echo $oldName, "\n"; 37 | echo $newName, "\n"; 38 | ?> 39 | --EXPECTF-- 40 | Runkit Sample: 1 41 | 42 | Deprecated: Function runkit_function_copy() is deprecated in %srunkit_function_copy_alias.php on line 20 43 | Runkit Sample: 2 44 | Runkit Sample: 3 45 | 46 | Deprecated: Function runkit_function_remove() is deprecated in %srunkit_function_copy_alias.php on line 23 47 | Runkit Sample: 4 48 | runkitSample 49 | runkitDuplicate -------------------------------------------------------------------------------- /tests/runkit_function_redefine.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 20 | --EXPECT-- 21 | a is 1 22 | b is 2 23 | runkitSample 24 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_function_redefine() function 3 | --INI-- 4 | error_reporting=E_ALL 5 | display_errors=on 6 | --SKIPIF-- 7 | 8 | --FILE-- 9 | 23 | --EXPECTF-- 24 | a is 1 25 | 26 | Deprecated: Function runkit_function_redefine() is deprecated in %srunkit_function_redefine_alias.php on line 10 27 | b is 2 28 | runkitSample -------------------------------------------------------------------------------- /tests/runkit_function_redefine_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() function and doc_comment 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getDocComment(), "\n"; 22 | $r2 = new ReflectionFunction('runkitFunction'); 23 | echo $r2->getDocComment(), "\n"; 24 | runkit7_function_redefine('runkitFunction','$b', 'echo "b is $b\n";', NULL, NULL); 25 | $r2 = new ReflectionFunction('runkitFunction'); 26 | echo $r2->getDocComment(), "\n"; 27 | runkit7_function_redefine('runkitFunction','$b', 'echo "b is $b\n";'); 28 | $r2 = new ReflectionFunction('runkitFunction'); 29 | echo $r2->getDocComment(), "\n"; 30 | ?> 31 | --EXPECT-- 32 | new doc_comment1 33 | new doc_comment2 34 | new doc_comment2 35 | new doc_comment2 36 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() function with reflection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | invoke(); 17 | ?> 18 | --EXPECTF-- 19 | object(ReflectionFunction)#%d (1) { 20 | ["name"]=> 21 | string(30) "__function_removed_by_runkit__" 22 | } 23 | 24 | Fatal error: __function_removed_by_runkit__(): A function removed by runkit7 was somehow invoked in %s on line %d 25 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_and_revert.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() and revert 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL 7 | display_errors=on 8 | runkit.internal_override=On 9 | --FILE-- 10 | 28 | --EXPECT-- 29 | bar 30 | new function 31 | bar 32 | Done call 33 | Removed redefined function 34 | calling original sprintf 35 | Done call to copy 36 | before removing sprintf_old:foo 37 | foo 38 | bar 39 | new function 40 | bar 41 | Done call 42 | Removed redefined function 43 | calling original sprintf 44 | Done call to copy 45 | before removing sprintf_old:foo 46 | foo 47 | bar 48 | new function 49 | bar 50 | Done call 51 | Removed redefined function 52 | calling original sprintf 53 | Done call to copy 54 | before removing sprintf_old:foo 55 | foo 56 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_and_revert_closure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() and revert 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL 7 | display_errors=on 8 | runkit.internal_override=On 9 | --FILE-- 10 | 30 | --EXPECT-- 31 | bar 32 | new function 33 | bar 34 | Done call 35 | Removed redefined function 36 | calling original sprintf 37 | Done call to copy 38 | before removing sprintf_old:foo 39 | foo 40 | bar 41 | new function 42 | bar 43 | Done call 44 | Removed redefined function 45 | calling original sprintf 46 | Done call to copy 47 | before removing sprintf_old:foo 48 | foo 49 | bar 50 | new function 51 | bar 52 | Done call 53 | Removed redefined function 54 | calling original sprintf 55 | Done call to copy 56 | before removing sprintf_old:foo 57 | foo 58 | --XFAIL-- 59 | Expected to fail because this bug was just discovered with runkit.internal_override and functions from closures. 60 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_closure_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() closure and doc_comment 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 16 | ?> 17 | --EXPECT-- 18 | new doc_comment 19 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_closure_and_doc_comment_from_closure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() closure and doc_comment from closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 18 | ?> 19 | --EXPECT-- 20 | /** new doc_comment */ 21 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_closure_static.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function with closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | 36 | --EXPECTF-- 37 | a is foo 38 | b is bar 39 | c is use 40 | d is ref_use 41 | g is global 42 | d after call is ref_use modified 43 | a is foo 44 | b is bar 45 | c is use 46 | d is ref_use modified 47 | g is global 48 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_from_anonymous.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() and call from anonymous function 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | runkit.internal_override=On 11 | --FILE-- 12 | 5 | --FILE-- 6 | 22 | --EXPECTF-- 23 | call 24 | var_dump 25 | 26 | %s: Undefined variable%smissing in %s on line %d 27 | NULL 28 | second call 29 | var_dump 30 | 31 | %s: Undefined variable%smissing in %s on line %d 32 | NULL 33 | Done 34 | -------------------------------------------------------------------------------- /tests/runkit_function_redefine_var_dump.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function with closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | run(); 28 | ?> 29 | --EXPECTF-- 30 | undefined is 31 | %s: Undefined variable%sundefined in %s on line %d 32 | NULL 33 | Done 34 | -------------------------------------------------------------------------------- /tests/runkit_function_remove.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_remove() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 20 | --EXPECTF-- 21 | Function Exists 22 | Function Removed 23 | runkitSample 24 | 25 | Fatal error: Uncaught Error: Call to undefined function runkit%sample() in %s:%d 26 | Stack trace: 27 | #0 {main} 28 | thrown in %s on line %d 29 | -------------------------------------------------------------------------------- /tests/runkit_function_remove_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_function_remove() function 3 | --INI-- 4 | error_reporting=E_ALL 5 | --SKIPIF-- 6 | 7 | --FILE-- 8 | 22 | --EXPECTF-- 23 | Function Exists 24 | 25 | Deprecated: Function runkit_function_remove() is deprecated in %srunkit_function_remove_alias.php on line 8 26 | Function Removed 27 | runkitSample 28 | 29 | Fatal error: Uncaught Error: Call to undefined function runkit%sample() in %srunkit_function_remove_alias.php:13 30 | Stack trace: 31 | #0 {main} 32 | thrown in %srunkit_function_remove_alias.php on line 13 -------------------------------------------------------------------------------- /tests/runkit_function_remove_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_remove() function with reflection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | invoke(); 17 | ?> 18 | --EXPECTF-- 19 | object(ReflectionFunction)#%d (1) { 20 | ["name"]=> 21 | string(30) "__function_removed_by_runkit__" 22 | } 23 | 24 | Fatal error: __function_removed_by_runkit__(): A function removed by runkit7 was somehow invoked in %s on line %d 25 | -------------------------------------------------------------------------------- /tests/runkit_function_remove_and_reflection_parameter.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_remove() function with ReflectionParameter 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getParameters(); 13 | $reflParam = $reflParam[0]; 14 | 15 | runkit7_function_remove('runkitFunction'); 16 | 17 | var_dump($reflParam); 18 | try { 19 | var_dump($reflParam->getDeclaringFunction()); 20 | } catch (Error $e) { 21 | echo "\n"; 22 | printf("(No longer a )Fatal error: %s in %s on line %d", $e->getMessage(), $e->getFile(), $e->getLine()); 23 | } 24 | ?> 25 | --EXPECTREGEX-- 26 | object\(ReflectionParameter\)#\d+ \(1\) { 27 | \["name"\]=> 28 | string\(31\) "__parameter_removed_by_runkit__" 29 | } 30 | 31 | .*Fatal error:.*Internal error: Failed to retrieve the reflection object in .* on line \d+ 32 | -------------------------------------------------------------------------------- /tests/runkit_function_rename.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_rename() function 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 24 | --EXPECTF-- 25 | Runkit Sample: 1 26 | Runkit Sample: 2 27 | runkitSample 28 | runkitNewName 29 | 30 | Fatal error: Uncaught Error: Call to undefined function runkit%sample() in %s:%d 31 | Stack trace: 32 | #0 {main} 33 | thrown in %s on line %d 34 | -------------------------------------------------------------------------------- /tests/runkit_function_rename_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_rename() function 3 | --INI-- 4 | error_reporting=E_ALL 5 | display_errors=on 6 | --SKIPIF-- 7 | 8 | --FILE-- 9 | 27 | --EXPECTF-- 28 | Runkit Sample: 1 29 | 30 | Deprecated: Function runkit_function_rename() is deprecated in %srunkit_function_rename_alias.php on line 9 31 | Runkit Sample: 2 32 | runkitSample 33 | runkitNewName 34 | 35 | Fatal error: Uncaught Error: Call to undefined function runkit%sample() in %srunkit_function_rename_alias.php:17 36 | Stack trace: 37 | #0 {main} 38 | thrown in %srunkit_function_rename_alias.php on line 17 -------------------------------------------------------------------------------- /tests/runkit_function_rename_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_rename() function with reflection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | invoke(); 17 | ?> 18 | --EXPECTF-- 19 | object(ReflectionFunction)#%d (1) { 20 | ["name"]=> 21 | string(30) "__function_removed_by_runkit__" 22 | } 23 | 24 | Fatal error: __function_removed_by_runkit__(): A function removed by runkit7 was somehow invoked in %s on line %d 25 | -------------------------------------------------------------------------------- /tests/runkit_function_rename_corruption.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_rename() function corruption prevented when original method is replaced with a substitute. 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 5 | --FILE-- 6 | getMessage(); 27 | } 28 | --EXPECTF-- 29 | Caught Error: Call to undefined function hi() 30 | -------------------------------------------------------------------------------- /tests/runkit_function_rename_internal.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_rename() function on internal functions 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | runkit.internal_override=On 7 | --FILE-- 8 | getMessage(), $e->getFile(), $e->getLine()); 20 | } 21 | ?> 22 | --EXPECTF-- 23 | int(1) 24 | int(1) 25 | 26 | Fatal error: %s var_dump() in %s on line %d 27 | -------------------------------------------------------------------------------- /tests/runkit_function_rename_large_switch.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_rename() function with large switch statements 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 61 | --EXPECT-- 62 | two 63 | three 64 | one 65 | two 66 | three 67 | eight 68 | seven 69 | eight 70 | 1 71 | 1 72 | 1 73 | 8 74 | -------------------------------------------------------------------------------- /tests/runkit_function_rename_redefine_add_remove.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | complex test for renaming, adding and removing with internal functions 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL 7 | display_errors=on 8 | runkit.internal_override=On 9 | --FILE-- 10 | 28 | --EXPECTF-- 29 | %d 30 | a%d 31 | %d 32 | 33 | %d 34 | a%d 35 | %d 36 | -------------------------------------------------------------------------------- /tests/runkit_functions_returning_by_reference.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_function_redefine() & runkit7_function_add() for functions returning a value by reference 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 48 | --EXPECT-- 49 | int(0) 50 | int(0) 51 | int(3) 52 | int(3) 53 | int(3) 54 | int(6) 55 | -------------------------------------------------------------------------------- /tests/runkit_method_add.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | a is foo 19 | b is bar 20 | -------------------------------------------------------------------------------- /tests/runkit_method_add_7_php8.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function for static method 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | 17 | --EXPECT-- 18 | a is foo 19 | b is bar 20 | -------------------------------------------------------------------------------- /tests/runkit_method_add_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_method_add() function 3 | --SKIPIF-- 4 | = 80000) print "skip php >= 8.0"; 7 | ?> 8 | --INI-- 9 | display_errors=on 10 | error_reporting=E_ALL 11 | --FILE-- 12 | 21 | --EXPECT-- 22 | a is foo 23 | b is bar 24 | -------------------------------------------------------------------------------- /tests/runkit_method_add_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function and doc_comment 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getDocComment(), "\n"; 17 | $r2 = new ReflectionMethod('runkit_class', 'runkitMethod'); 18 | echo $r2->getDocComment(), "\n"; 19 | ?> 20 | --EXPECT-- 21 | new doc_comment1 22 | new doc_comment2 23 | -------------------------------------------------------------------------------- /tests/runkit_method_add_closure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function with closure 3 | --SKIPIF-- 4 | = 80000) print "skip php >= 8.0\n"; 7 | ?> 8 | --INI-- 9 | display_errors=on 10 | --FILE-- 11 | getMessage()); 34 | printf("NULL\n"); 35 | } 36 | }); 37 | runkit_class::runkit_method('foo', 'bar'); 38 | echo "d after call is $d\n"; 39 | } 40 | } 41 | $g = 'global'; 42 | $t = new test(); 43 | $t->run(); 44 | $rc = new runkit_class(); 45 | $rc->runkit_method('foo','bar'); 46 | ?> 47 | --EXPECTREGEX-- 48 | a is foo 49 | b is bar 50 | c is use 51 | d is ref_use 52 | g is global 53 | \$this= 54 | (Notice: Undefined variable: this in .* on line [0-9]+|Error: Using \$this when not in object context) 55 | NULL 56 | d after call is ref_use modified 57 | a is foo 58 | b is bar 59 | c is use 60 | d is ref_use modified 61 | g is global 62 | \$this=object\(runkit_class\)#2 \(0\) { 63 | } 64 | -------------------------------------------------------------------------------- /tests/runkit_method_add_closure2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function with closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | add(12, 4);//echo "\n"; 32 | runkit7_method_remove( 33 | 'Example', 34 | 'add' 35 | ); 36 | } 37 | --EXPECT-- 38 | -------------------------------------------------------------------------------- /tests/runkit_method_add_closure_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function with closure and doc_comment 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 17 | $r2 = new ReflectionMethod('runkit_class', 'runkitMethod'); 18 | echo $r2->getDocComment(), "\n"; 19 | ?> 20 | --EXPECT-- 21 | new doc_comment1 22 | new doc_comment2 23 | -------------------------------------------------------------------------------- /tests/runkit_method_add_closure_and_doc_comment_from_closure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function with closure and doc_comment from closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 16 | ?> 17 | --EXPECT-- 18 | /** new doc_comment */ 19 | -------------------------------------------------------------------------------- /tests/runkit_method_add_closure_and_flags.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function with closure and flags 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 18 | $r2 = new ReflectionMethod('runkit_class', 'runkitMethod'); 19 | echo $r2->getDocComment(), "\n"; 20 | $r3 = new ReflectionMethod('runkit_class', 'runkitMethod1'); 21 | echo $r3->getDocComment(), "\n"; 22 | 23 | echo $r2->isPrivate(), "\n"; 24 | echo $r3->isStatic(); 25 | ?> 26 | --EXPECT-- 27 | 28 | 29 | new doc_comment2 30 | 1 31 | 1 32 | -------------------------------------------------------------------------------- /tests/runkit_method_add_closure_php80.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function with closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | run(); 35 | $rc = new runkit_class(); 36 | $rc->runkit_method('foo','bar'); 37 | ?> 38 | --EXPECTREGEX-- 39 | a is foo 40 | b is bar 41 | c is use 42 | d is ref_use 43 | g is global 44 | d after call is ref_use modified 45 | a is foo 46 | b is bar 47 | c is use 48 | d is ref_use modified 49 | g is global 50 | -------------------------------------------------------------------------------- /tests/runkit_method_add_overriding_parent_method.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function 3 | --SKIPIF-- 4 | = 80000) print "skip using parent in class with no parent\n"; 7 | ?> 8 | --INI-- 9 | display_errors=on 10 | error_reporting = E_ALL & ~E_DEPRECATED 11 | --FILE-- 12 | method1(); 41 | runkit7_method_rename('Class2', 'method1', 'method2'); 42 | $c->method2(); 43 | runkit7_method_copy('Class2', 'method3', 'Class0', 'method3'); 44 | $c->method3(); 45 | ?> 46 | --EXPECT-- 47 | method1 48 | method1_new 49 | method1 50 | method1_new 51 | method3 52 | method3_new 53 | -------------------------------------------------------------------------------- /tests/runkit_method_add_return_type.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function should accept valid return types passed in as a string 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getMessage()); 20 | } 21 | ?> 22 | --EXPECTF-- 23 | Returned foo 24 | TypeError: %Srunkit_class::runkit_method()%smust be of%stype string, %s returned 25 | -------------------------------------------------------------------------------- /tests/runkit_method_add_return_type_invalid.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_add() function should detect invalid return types passed in as a string 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | $returnType) { 15 | printf("testing return type %s\n", var_export($returnType, true)); 16 | $methodName = 'runkit_method' . $i; 17 | 18 | $retval = runkit7_method_add('runkit_class', $methodName, 'string $a, $valid=false', 'return $valid ? $a : new stdClass();', RUNKIT7_ACC_STATIC, '/** doc comment */', $returnType); 19 | printf("runkit_method_add returned: %s\n", var_export($retval, true)); 20 | printf("Method exists: %s\n", var_export(method_exists('runkit_class', $methodName), true)); 21 | } 22 | ?> 23 | --EXPECTF-- 24 | testing return type 'string#' 25 | 26 | Warning: runkit7_method_add(): Return type should match regex %s in %s on line 11 27 | runkit_method_add returned: false 28 | Method exists: false 29 | testing return type 'string' 30 | runkit_method_add returned: true 31 | Method exists: true 32 | testing return type '\\stdClass' 33 | runkit_method_add returned: true 34 | Method exists: true 35 | testing return type '\\\\stdClass' 36 | 37 | Warning: runkit7_method_add(): Return type should match regex %s in %s on line 11 38 | runkit_method_add returned: false 39 | Method exists: false 40 | testing return type '\\stdClass\\' 41 | 42 | Warning: runkit7_method_add(): Return type should match regex %s in %s on line 11 43 | runkit_method_add returned: false 44 | Method exists: false 45 | testing return type '\\A2\\Bc' 46 | runkit_method_add returned: true 47 | Method exists: true 48 | testing return type '\\A2\\\\Bc' 49 | 50 | Warning: runkit7_method_add(): Return type should match regex %s in %s on line 11 51 | runkit_method_add returned: false 52 | Method exists: false 53 | testing return type '\\A2\\Bc' . "\0" . '' 54 | 55 | Warning: runkit7_method_add(): Return type should match regex %s in %s on line 11 56 | runkit_method_add returned: false 57 | Method exists: false 58 | testing return type '\\2A\\Bc' 59 | 60 | Warning: runkit7_method_add(): Return type should match regex %s in %s on line 11 61 | runkit_method_add returned: false 62 | Method exists: false 63 | -------------------------------------------------------------------------------- /tests/runkit_method_copy.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_copy() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getDeclaringClass(); 45 | echo $declClass->getName(), "\n"; 46 | echo $reflMethod->getName(), "\n"; 47 | } else { 48 | echo "runkit_two\n"; 49 | echo "runkitMethod\n"; 50 | } 51 | ?> 52 | --EXPECT-- 53 | Runkit Method: 1 54 | Runkit Method: 2 55 | Runkit Method: 3 56 | Runkit Method: 4 57 | Runkit Method: 5 58 | Runkit Method: 6 59 | Runkit Method: 7 60 | Runkit Method: 8 61 | runkit_two 62 | runkitMethod 63 | -------------------------------------------------------------------------------- /tests/runkit_method_copy_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_method_copy() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | error_reporting=E_ALL 8 | --FILE-- 9 | getDeclaringClass(); 46 | echo $declClass->getName(), "\n"; 47 | echo $reflMethod->getName(), "\n"; 48 | } else { 49 | echo "runkit_two\n"; 50 | echo "runkitMethod\n"; 51 | } 52 | ?> 53 | --EXPECTF-- 54 | Runkit Method: 1 55 | 56 | Deprecated: Function runkit_method_copy() is deprecated in %srunkit_method_copy_alias.php on line 18 57 | 58 | Deprecated: Function runkit_method_copy() is deprecated in %srunkit_method_copy_alias.php on line 19 59 | Runkit Method: 2 60 | Runkit Method: 3 61 | Runkit Method: 4 62 | Runkit Method: 5 63 | Runkit Method: 6 64 | 65 | Deprecated: Function runkit_method_remove() is deprecated in %srunkit_method_copy_alias.php on line 25 66 | 67 | Deprecated: Function runkit_method_remove() is deprecated in %srunkit_method_copy_alias.php on line 29 68 | Runkit Method: 7 69 | Runkit Method: 8 70 | runkit_two 71 | runkitMethod -------------------------------------------------------------------------------- /tests/runkit_method_copy_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_copy() function and doc_comment 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getDocComment(), "\n"; 22 | runkit7_method_redefine('runkit_class','runkit_method','', '', NULL, 'new doc_comment'); 23 | $r = new ReflectionMethod('runkit_class', 'runkit_method1'); 24 | echo $r->getDocComment(), "\n"; 25 | $r = new ReflectionMethod('runkit_class', 'runkit_method'); 26 | echo $r->getDocComment(), "\n"; 27 | echo "After redefine\n"; 28 | runkit7_method_redefine('runkit_class','runkit_method','', '', NULL, NULL); 29 | $r = new ReflectionMethod('runkit_class', 'runkit_method'); 30 | echo $r->getDocComment(), "\n"; 31 | echo "After redefine 2\n"; 32 | runkit7_method_redefine('runkit_class','runkit_method','', ''); 33 | $r = new ReflectionMethod('runkit_class', 'runkit_method'); 34 | echo $r->getDocComment(), "\n"; 35 | echo "After redefine 3\n"; 36 | runkit7_method_redefine('runkit_class','runkit_method','', '', NULL, ''); 37 | $r = new ReflectionMethod('runkit_class', 'runkit_method'); 38 | echo $r->getDocComment(), "\n"; 39 | ?> 40 | --EXPECT-- 41 | /** 42 | * old doc_comment 43 | */ 44 | /** 45 | * old doc_comment 46 | */ 47 | new doc_comment 48 | After redefine 49 | new doc_comment 50 | After redefine 2 51 | new doc_comment 52 | After redefine 3 53 | 54 | -------------------------------------------------------------------------------- /tests/runkit_method_copy_and_doc_comment_leak.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_copy() function and doc_comment - test if one call to copy will leak memory 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getDocComment(), "\n"; 19 | echo "After redefine\n"; 20 | runkit7_method_redefine('runkit_class','runkit_method','', '', NULL, 'redefined doc_comment'); 21 | // TODO: Could iterate through all of the ReflectionMethods and update their doc_comments and parameters when adding? 22 | echo $r->getDocComment(), "\n"; 23 | $r2 = new ReflectionMethod('runkit_class', 'runkit_method'); 24 | echo $r2->getDocComment(), "\n"; 25 | ?> 26 | --EXPECT-- 27 | /** old doc_comment */ 28 | After redefine 29 | 30 | redefined doc_comment 31 | -------------------------------------------------------------------------------- /tests/runkit_method_copy_uninit_read.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_copy() causes uninitialized read 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | a[] = "b"; 15 | } 16 | } 17 | 18 | echo "==DONE==\n"; 19 | 20 | ?> 21 | --EXPECT-- 22 | ==DONE== 23 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | 26 | --EXPECT-- 27 | a is foo 28 | b is bar 29 | a is foo 30 | b is bar 31 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_method_redefine() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | error_reporting=E_ALL 8 | --FILE-- 9 | 27 | --EXPECTF-- 28 | a is foo 29 | 30 | Deprecated: Function runkit_method_redefine() is deprecated in %srunkit_method_redefine_alias.php on line 13 31 | b is bar 32 | a is foo 33 | 34 | Deprecated: Function runkit_method_redefine() is deprecated in %srunkit_method_redefine_alias.php on line 16 35 | b is bar -------------------------------------------------------------------------------- /tests/runkit_method_redefine_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function and doc_comment 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | getDocComment(), "\n"; 26 | $r2 = new ReflectionMethod('runkit_class', 'runkitMethod'); 27 | echo $r2->getDocComment(), "\n"; 28 | ?> 29 | --EXPECT-- 30 | new doc_comment1 31 | new doc_comment2 32 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function with reflection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | invoke($obj); 23 | ?> 24 | --EXPECTF-- 25 | object(ReflectionMethod)#%d (2) { 26 | ["name"]=> 27 | string(28) "__method_removed_by_runkit__" 28 | ["class"]=> 29 | string(11) "RunkitClass" 30 | } 31 | 32 | Fatal error: RunkitClass::__method_removed_by_runkit__(): A method removed by runkit7 was somehow invoked in %s on line %d 33 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_and_reflection_with_inheritance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function with reflection and inheritance 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | invoke($obj, $obj); 24 | ?> 25 | --EXPECTF-- 26 | object(ReflectionMethod)#%d (2) { 27 | ["name"]=> 28 | string(28) "__method_removed_by_runkit__" 29 | ["class"]=> 30 | string(11) "RunkitClass" 31 | } 32 | 33 | Fatal error: RunkitClass::__method_removed_by_runkit__(): A method removed by runkit7 was somehow invoked in %s on line %d 34 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_closure_and_doc_comment.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function with closure and doc_comment 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 19 | $r2 = new ReflectionMethod('runkit_class', 'runkitMethod'); 20 | echo $r2->getDocComment(), "\n"; 21 | echo $r2->isPrivate(); 22 | ?> 23 | --EXPECT-- 24 | new doc_comment1 25 | new doc_comment2 26 | 1 27 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_closure_and_doc_comment_from_closure.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function with closure and doc_comment from closure 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | getDocComment(), "\n"; 17 | ?> 18 | --EXPECT-- 19 | /** new doc_comment */ 20 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_protected.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() function for protected methods 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL 7 | display_errors=on 8 | --FILE-- 9 | a} $is $a\n"; 16 | } 17 | public function runkit7_method($a) { 18 | return $this->runkit7_method_int($a); 19 | } 20 | } 21 | $obj = new runkit7_class(); 22 | $obj->runkit7_method('foo'); 23 | runkit7_method_copy('runkit7_class','runkit7_method_old','runkit7_class','runkit7_method_int'); 24 | runkit7_method_redefine('runkit7_class','runkit7_method_int','$b', 'static $is="is"; echo "{$this->b} $is $b\n";'); 25 | $obj->runkit7_method('bar'); 26 | runkit7_method_remove('runkit7_class','runkit7_method_int'); 27 | runkit7_method_copy('runkit7_class','runkit7_method_int','runkit7_class','runkit7_method_old'); 28 | runkit7_method_remove('runkit7_class','runkit7_method_old'); 29 | $obj1 = new runkit7_class(); 30 | $obj1->runkit7_method('foo'); 31 | ?> 32 | --EXPECT-- 33 | a is foo 34 | b is bar 35 | a is foo 36 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_update_proto.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() must also update children methods' prototypes 3 | --SKIPIF-- 4 | 6 | --FILE-- 7 | foo(); 14 | } 15 | } 16 | 17 | class b extends a { 18 | protected function foo() { 19 | } 20 | } 21 | 22 | class c extends b { 23 | function bar() { 24 | $this->test(); 25 | } 26 | } 27 | 28 | runkit7_method_redefine('a', 'foo', '', 'var_dump("new foo()");'); 29 | 30 | $c = new c; 31 | $c->bar(); 32 | 33 | echo "==DONE==\n"; 34 | 35 | ?> 36 | --EXPECT-- 37 | ==DONE== 38 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_update_proto2.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_redefine() must also update method's prototype 3 | --FILE-- 4 | 22 | --EXPECT-- 23 | ==DONE== 24 | -------------------------------------------------------------------------------- /tests/runkit_method_redefine_with_static_vars.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | redefining methods with static variables 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | = 80100 ? 1 : 0); 26 | ?> 27 | --EXPECT-- 28 | 1 29 | 2 30 | -------------------------------------------------------------------------------- /tests/runkit_method_remove.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_remove() function 3 | --SKIPIF-- 4 | = 80000) { print "skip\n"; } 7 | ?> 8 | --INI-- 9 | display_errors=on 10 | --FILE-- 11 | 35 | --EXPECTF-- 36 | Runkit Method 37 | Runkit Method Removed 38 | Runkit Method 39 | Runkit Method Removed 40 | 41 | Fatal error: Uncaught Error: Call to undefined method runkit_class::runkitMethod() in %s:%d 42 | Stack trace: 43 | #0 {main} 44 | thrown in %s on line %d 45 | -------------------------------------------------------------------------------- /tests/runkit_method_remove_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_method_remove() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | error_reporting=E_ALL 8 | --FILE-- 9 | 33 | --EXPECTF-- 34 | Runkit Method 35 | 36 | Deprecated: Function runkit_method_remove() is deprecated in %srunkit_method_remove_alias.php on line 14 37 | Runkit Method Removed 38 | Runkit Method 39 | 40 | Deprecated: Function runkit_method_remove() is deprecated in %srunkit_method_remove_alias.php on line 19 41 | Runkit Method Removed 42 | 43 | Fatal error: Uncaught Error: Call to undefined method runkit_class::runkitMethod() in %srunkit_method_remove_alias.php:23 44 | Stack trace: 45 | #0 {main} 46 | thrown in %srunkit_method_remove_alias.php on line 23 -------------------------------------------------------------------------------- /tests/runkit_method_remove_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_remove() function with reflection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMethod('runkitMethod')); 23 | echo 'No exception!'; 24 | } catch (ReflectionException $e) { 25 | } 26 | 27 | try { 28 | var_dump($reflObject->getMethod('runkitMethod')); 29 | echo 'No exception!'; 30 | } catch (ReflectionException $e) { 31 | } 32 | var_dump($reflMethod); 33 | $reflMethod->invoke($obj); 34 | ?> 35 | --EXPECTF-- 36 | object(ReflectionMethod)#%d (2) { 37 | ["name"]=> 38 | string(28) "__method_removed_by_runkit__" 39 | ["class"]=> 40 | string(11) "RunkitClass" 41 | } 42 | 43 | Fatal error: RunkitClass::__method_removed_by_runkit__(): A method removed by runkit7 was somehow invoked in %s on line %d 44 | -------------------------------------------------------------------------------- /tests/runkit_method_remove_and_reflection_parameter.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_remove() function with ReflectionParameter 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getParameters(); 17 | $reflParam = $reflParam[0]; 18 | 19 | runkit7_method_remove('RunkitClass','runkitMethod'); 20 | 21 | var_dump($reflParam); 22 | try { 23 | var_dump($reflParam->getDeclaringFunction()); 24 | } catch (Error $e) { 25 | echo "\n"; 26 | printf("(No longer a )Fatal error: %s in %s on line %d", $e->getMessage(), $e->getFile(), $e->getLine()); 27 | } 28 | ?> 29 | --EXPECTREGEX-- 30 | object\(ReflectionParameter\)#\d+ \(1\) { 31 | \["name"\]=> 32 | string\(31\) "__parameter_removed_by_runkit__" 33 | } 34 | 35 | .*Fatal error:.*Internal error: Failed to retrieve the reflection object in .* on line \d+ 36 | -------------------------------------------------------------------------------- /tests/runkit_method_remove_and_reflection_parameter_with_inheritance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_remove() function with ReflectionParameter and inheritance 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getParameters(); 18 | $reflParam = $reflParam[0]; 19 | 20 | runkit7_method_remove('RunkitClass','runkitMethod'); 21 | 22 | var_dump($reflParam); 23 | try { 24 | var_dump($reflParam->getDeclaringFunction()); 25 | } catch (Error $e) { 26 | echo "\n"; 27 | printf("(No longer a )Fatal error: %s in %s on line %d", $e->getMessage(), $e->getFile(), $e->getLine()); 28 | } 29 | ?> 30 | --EXPECTREGEX-- 31 | object\(ReflectionParameter\)#\d+ \(1\) { 32 | \["name"\]=> 33 | string\(31\) "__parameter_removed_by_runkit__" 34 | } 35 | 36 | .*Fatal error:.*Internal error: Failed to retrieve the reflection object in .* on line \d+ 37 | -------------------------------------------------------------------------------- /tests/runkit_method_remove_and_reflection_with_inheritance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_remove() function with reflection and inheritance 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMethod('runkitMethod')); 24 | echo 'No exception!'; 25 | } catch (ReflectionException $e) { 26 | } 27 | 28 | try { 29 | var_dump($reflObject->getMethod('runkitMethod')); 30 | echo 'No exception!'; 31 | } catch (ReflectionException $e) { 32 | } 33 | var_dump($reflMethod); 34 | $reflMethod->invoke($obj, $obj); 35 | ?> 36 | --EXPECTF-- 37 | object(ReflectionMethod)#%d (2) { 38 | ["name"]=> 39 | string(28) "__method_removed_by_runkit__" 40 | ["class"]=> 41 | string(11) "RunkitClass" 42 | } 43 | 44 | Fatal error: RunkitClass::__method_removed_by_runkit__(): A method removed by runkit7 was somehow invoked in %s on line %d 45 | -------------------------------------------------------------------------------- /tests/runkit_method_remove_static.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_remove() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | 32 | --EXPECTF-- 33 | Runkit Method 34 | Runkit Method Removed 35 | Runkit Method 36 | Runkit Method Removed 37 | 38 | Fatal error: Uncaught Error: Call to undefined method runkit_class::runkitMethod() in %s:%d 39 | Stack trace: 40 | #0 {main} 41 | thrown in %s on line %d 42 | -------------------------------------------------------------------------------- /tests/runkit_method_rename.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_rename() function 3 | --SKIPIF-- 4 | = 80000) print "skip php >= 8.0"; 7 | ?> 8 | --INI-- 9 | display_errors=on 10 | --FILE-- 11 | 38 | --EXPECTF-- 39 | Runkit Original: a is 1 40 | Runkit Original: a is 2 41 | Runkit Original: a is 3 42 | Runkit Original: a is 4 43 | 44 | Fatal error: Uncaught Error: Call to undefined method runkit_class::runkit%suplicate() in %s:%d 45 | Stack trace: 46 | #0 {main} 47 | thrown in %s on line %d 48 | -------------------------------------------------------------------------------- /tests/runkit_method_rename_002.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Rename children of ancestor methods 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMethods() as $method) { 12 | array_push($methods, $method->getName()); 13 | } 14 | return $methods; 15 | } 16 | 17 | class Ancestor 18 | { 19 | public function __construct(){} 20 | } 21 | 22 | class Descendant extends Ancestor 23 | { 24 | public function someMethod(){} 25 | } 26 | 27 | class AnotherDescendant extends Ancestor 28 | { 29 | public function anotherMethod(){} 30 | } 31 | 32 | runkit7_method_rename('Ancestor', '__construct', 'abcdefghmnoprst'); 33 | print_r(getClassMethods('Descendant')); 34 | print_r(getClassMethods('AnotherDescendant')); 35 | --EXPECT-- 36 | Array 37 | ( 38 | [0] => someMethod 39 | [1] => abcdefghmnoprst 40 | ) 41 | Array 42 | ( 43 | [0] => anotherMethod 44 | [1] => abcdefghmnoprst 45 | ) 46 | -------------------------------------------------------------------------------- /tests/runkit_method_rename_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_method_rename() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | error_reporting=E_ALL 8 | --FILE-- 9 | 36 | --EXPECTF-- 37 | Runkit Original: a is 1 38 | 39 | Deprecated: Function runkit_method_rename() is deprecated in %srunkit_method_rename_alias.php on line 11 40 | Runkit Original: a is 2 41 | 42 | Deprecated: Function runkit_method_rename() is deprecated in %srunkit_method_rename_alias.php on line 16 43 | Runkit Original: a is 3 44 | 45 | Deprecated: Function runkit_method_rename() is deprecated in %srunkit_method_rename_alias.php on line 21 46 | Runkit Original: a is 4 47 | 48 | Fatal error: Uncaught Error: Call to undefined method runkit_class::runkitDuplicate() in %srunkit_method_rename_alias.php:26 49 | Stack trace: 50 | #0 {main} 51 | thrown in %srunkit_method_rename_alias.php on line 26 -------------------------------------------------------------------------------- /tests/runkit_method_rename_and_access.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_rename() function should set method's scope correctly 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | func1();', RUNKIT7_ACC_PUBLIC); 18 | $a = new Test(); 19 | $a->func2(); 20 | 21 | runkit7_method_rename('Test', 'func1', '_func1'); 22 | runkit7_method_redefine('Test', 'func2', '', 'echo "new func2\n"; $this->_func1();', RUNKIT7_ACC_PUBLIC); 23 | $b = new Test(); 24 | $b->func2(); 25 | $a->func2(); 26 | ?> 27 | --EXPECT-- 28 | func2 29 | func1 30 | new func2 31 | func1 32 | new func2 33 | func1 34 | -------------------------------------------------------------------------------- /tests/runkit_method_rename_and_reflection.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_rename() function with reflection 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | getMethod('runkitMethod')); 23 | echo 'No exception!'; 24 | } catch (ReflectionException $e) { 25 | } 26 | 27 | try { 28 | var_dump($reflObject->getMethod('runkitMethod')); 29 | echo 'No exception!'; 30 | } catch (ReflectionException $e) { 31 | } 32 | var_dump($reflMethod); 33 | $reflMethod->invoke($obj); 34 | ?> 35 | --EXPECTF-- 36 | object(ReflectionMethod)#%d (2) { 37 | ["name"]=> 38 | string(28) "__method_removed_by_runkit__" 39 | ["class"]=> 40 | string(11) "RunkitClass" 41 | } 42 | 43 | Fatal error: RunkitClass::__method_removed_by_runkit__(): A method removed by runkit7 was somehow invoked in %s on line %d 44 | -------------------------------------------------------------------------------- /tests/runkit_method_rename_inheritance.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_rename() function and inheritance 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | --FILE-- 8 | 38 | --EXPECTF-- 39 | Runkit Original: a is 1 40 | Runkit Original: a is 2 41 | Runkit Original: a is 3 42 | Runkit Original: a is 4 43 | 44 | Fatal error: Uncaught Error: Call to undefined method runkit_subclass::runkit%suplicate() in %s:%d 45 | Stack trace: 46 | #0 {main} 47 | thrown in %s on line %d 48 | -------------------------------------------------------------------------------- /tests/runkit_method_rename_repeated.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_rename() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | error_reporting = E_ALL & ~E_DEPRECATED 8 | --FILE-- 9 | getReturnType()); 19 | runkit7_method_copy('A', 'testbackup', 'A', 'test'); 20 | runkit7_method_remove('A', 'test'); 21 | var_export((string)(new ReflectionMethod('A', 'testbackup'))->getReturnType()); 22 | runkit7_method_copy('A', 'test', 'A', 'testbackup'); 23 | runkit7_method_remove('A', 'testbackup'); 24 | var_export((string)(new ReflectionMethod('A', 'test'))->getReturnType()); 25 | } 26 | main(); 27 | main(); 28 | main(); 29 | main(); 30 | --EXPECT-- 31 | 'BInstance''BInstance''BInstance''BInstance''BInstance''BInstance''BInstance''BInstance''BInstance''BInstance''BInstance''BInstance' 32 | -------------------------------------------------------------------------------- /tests/runkit_method_rename_static.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_method_rename() function 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | display_errors=on 9 | --FILE-- 10 | 35 | --EXPECTF-- 36 | Runkit Original: a is 1 37 | Runkit Original: a is 2 38 | Runkit Original: a is 3 39 | Runkit Original: a is 4 40 | 41 | Fatal error: Uncaught Error: Call to undefined method runkit_class::runkit%suplicate() in %s:%d 42 | Stack trace: 43 | #0 {main} 44 | thrown in %s on line %d 45 | -------------------------------------------------------------------------------- /tests/runkit_methods_redefining_and_cache.inc: -------------------------------------------------------------------------------- 1 | 5 | --FILE-- 6 | a; 14 | } 15 | } 16 | $code = 'return $this->a;'; 17 | $o = new RunkitClass; 18 | 19 | $b = &$o->f(); 20 | $b = 1; 21 | var_dump($o->a); 22 | 23 | runkit7_method_redefine('RunkitClass', 'f', '', $code); 24 | $c = &$o->f(); 25 | $c = 2; 26 | var_dump($o->a); 27 | 28 | runkit7_method_redefine('RunkitClass', 'f', '', $code, RUNKIT7_ACC_RETURN_REFERENCE); 29 | $r = &$o->f(); 30 | $r = 3; 31 | var_dump($o->a); 32 | 33 | runkit7_method_redefine('RunkitClass', 'f', '', $code, 0); 34 | $d = &$o->f(); 35 | $d = 4; 36 | var_dump($o->a); 37 | 38 | runkit7_method_remove('RunkitClass', 'f'); 39 | runkit7_method_add('RunkitClass', 'f', '', $code); 40 | $d = &$o->f(); 41 | $d = 5; 42 | var_dump($o->a); 43 | 44 | runkit7_method_remove('RunkitClass', 'f'); 45 | runkit7_method_add('RunkitClass', 'f', '', $code, RUNKIT7_ACC_RETURN_REFERENCE); 46 | $d = &$o->f(); 47 | $d = 6; 48 | var_dump($o->a); 49 | ?> 50 | --EXPECT-- 51 | int(0) 52 | int(0) 53 | int(3) 54 | int(3) 55 | int(3) 56 | int(6) 57 | -------------------------------------------------------------------------------- /tests/runkit_redefine_old_style_ctor.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | redefine old-style parent ctor 3 | --SKIPIF-- 4 | = 80000) print "skip php >= 8.0"; 7 | ?> 8 | --FILE-- 9 | test1(); 50 | echo "==DONE==\n"; 51 | ?> 52 | --EXPECTF-- 53 | Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor in %s on line %d 54 | 55 | Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; %s has a deprecated constructor in %s on line %d 56 | string(15) "new constructor" 57 | string(15) "new constructor" 58 | string(15) "new constructor" 59 | string(34) "FOO_test_child_changed constructor" 60 | string(34) "FOO_test_child_changed constructor" 61 | after renaming 62 | string(34) "FOO_test_child_changed constructor" 63 | string(34) "FOO_test_child_changed constructor" 64 | 65 | string(15) "new constructor" 66 | ==DONE== 67 | -------------------------------------------------------------------------------- /tests/runkit_redefine_old_style_ctor_php8.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | redefine old-style parent ctor 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | test1(); 50 | echo "==DONE==\n"; 51 | ?> 52 | --EXPECT-- 53 | after renaming 54 | after construct 55 | string(13) "in test::test" 56 | ==DONE== 57 | -------------------------------------------------------------------------------- /tests/runkit_remove_magic_call_method.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | removing magic __call method 3 | --SKIPIF-- 4 | 6 | --FILE-- 7 | method(); 14 | runkit7_method_remove("Test", "__call"); 15 | $a->method(); 16 | ?> 17 | --EXPECTF-- 18 | __call 19 | Fatal error: Uncaught Error: Call to undefined method Test::method() in %s:%d 20 | Stack trace: 21 | #0 {main} 22 | thrown in %s on line %d 23 | -------------------------------------------------------------------------------- /tests/runkit_remove_magic_callstatic_method.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | removing magic __callstatic method 3 | --SKIPIF-- 4 | 6 | --FILE-- 7 | 16 | --EXPECTF-- 17 | __callstatic 18 | Fatal error: Uncaught Error: Call to undefined method Test::method() in %s:%d 19 | Stack trace: 20 | #0 {main} 21 | thrown in %s on line %d 22 | -------------------------------------------------------------------------------- /tests/runkit_remove_magic_serialize_method.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | removing magic serialize method 3 | --INI-- 4 | ; Suppress Serializable deprecation 5 | error_reporting=E_ALL&~E_DEPRECATED 6 | --SKIPIF-- 7 | 9 | --FILE-- 10 | 20 | --EXPECTF-- 21 | Fatal error: Couldn't find implementation for method Test::serialize in Unknown on line %d 22 | -------------------------------------------------------------------------------- /tests/runkit_remove_magic_tostring_method.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | removing magic __tostring method 3 | --SKIPIF-- 4 | = 70400) print "skip"; 6 | ?> 7 | --FILE-- 8 | 18 | --EXPECTF-- 19 | __tostring 20 | %s fatal error: Method Test::__toString() must return a string value in %s on line %d 21 | -------------------------------------------------------------------------------- /tests/runkit_remove_magic_tostring_method_php74.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | removing magic __tostring method 3 | --SKIPIF-- 4 | = 80000) print "skip"; 7 | ?> 8 | --FILE-- 9 | getMessage()); 19 | } 20 | runkit7_method_remove("Test", "__tostring"); 21 | try { 22 | (string) $a; 23 | } catch (Error $e) { 24 | printf("Caught %s: %s\n", get_class($e), $e->getMessage()); 25 | } 26 | runkit7_method_add("Test", "__tostring", function () { 27 | return 'a valid string'; 28 | }); 29 | $s = (string)$a; 30 | echo "Value: $s\n"; 31 | ?> 32 | --EXPECT-- 33 | __tostring 34 | Caught Error: Method Test::__toString() must return a string value 35 | Caught Error: Object of class Test could not be converted to string 36 | Value: a valid string 37 | -------------------------------------------------------------------------------- /tests/runkit_remove_magic_tostring_method_php80.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | removing magic __tostring method 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | getMessage()); 19 | } 20 | runkit7_method_remove("Test", "__tostring"); 21 | try { 22 | (string) $a; 23 | } catch (Error $e) { 24 | printf("Caught %s: %s\n", get_class($e), $e->getMessage()); 25 | } 26 | runkit7_method_add("Test", "__tostring", function () { 27 | return 'a valid string'; 28 | }); 29 | $s = (string)$a; 30 | echo "Value: $s\n"; 31 | ?> 32 | --EXPECT-- 33 | __tostring 34 | Caught TypeError: Test::__tostring(): Return value must be of type string, none returned 35 | Caught Error: Object of class Test could not be converted to string 36 | Value: a valid string 37 | -------------------------------------------------------------------------------- /tests/runkit_remove_magic_unserialize_method.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | removing magic unserialize method 3 | --INI-- 4 | ; Suppress Serializable deprecation 5 | error_reporting=E_ALL&~E_DEPRECATED 6 | --SKIPIF-- 7 | 9 | --FILE-- 10 | 21 | --EXPECTF-- 22 | Fatal error: Couldn't find implementation for method Test::unserialize in Unknown on line %d 23 | -------------------------------------------------------------------------------- /tests/runkit_static_property_add.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() function for static properties 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | 1), RUNKIT7_ACC_STATIC); 23 | runkit_default_property_add($className, $propName, $value, RUNKIT7_ACC_PUBLIC | RUNKIT7_ACC_STATIC); 24 | runkit_default_property_add($className, 'privateProperty', $value2, RUNKIT7_ACC_PRIVATE | RUNKIT7_ACC_STATIC); 25 | runkit_default_property_add($className, 'protectedProperty', NULL, RUNKIT7_ACC_PROTECTED | RUNKIT7_ACC_STATIC); 26 | $obj = new $className(); 27 | runkit_default_property_add($className, 'dynamic', $obj, RUNKIT7_ACC_STATIC); 28 | $value = 10; 29 | $value2 = "b"; 30 | print_r(RunkitClass::$constArray); 31 | var_dump(RunkitClass::$publicProperty); 32 | var_dump(RunkitClass::getProtected()); 33 | var_dump(RunkitClass::getPrivate()); 34 | print_r(RunkitClass::$dynamic); 35 | var_dump(RunkitClass::$oldProperty); 36 | var_dump($className); 37 | var_dump($propName); 38 | 39 | runkit_default_property_add('stdClass', 'str', 'test'); 40 | var_dump(stdClass::$str); 41 | ?> 42 | --EXPECTF-- 43 | Array 44 | ( 45 | [a] => 1 46 | ) 47 | int(1) 48 | NULL 49 | string(1) "a" 50 | RunkitClass Object 51 | ( 52 | ) 53 | string(3) "old" 54 | string(11) "RunkitClass" 55 | string(14) "publicProperty" 56 | 57 | Warning: runkit_default_property_add(): Adding properties to internal classes is not allowed in %s on line %d 58 | 59 | Fatal error: Uncaught Error: Access to undeclared static property: stdClass::$str in %s:%d 60 | Stack trace: 61 | #0 {main} 62 | thrown in %s on line %d 63 | -------------------------------------------------------------------------------- /tests/runkit_static_property_add_existing.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() function for existing static properties 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | 1), RUNKIT7_ACC_STATIC); 23 | var_dump(RunkitClass::$oldProperty); 24 | runkit_default_property_add('RunkitSubClass', 'oldProperty', array('a'=>1), RUNKIT7_ACC_STATIC); 25 | var_dump(RunkitSubClass::$oldProperty); 26 | runkit_default_property_add('RunkitParent', 'oldProperty', array('a'=>1), RUNKIT7_ACC_STATIC); 27 | var_dump(RunkitParent::$oldProperty); 28 | var_dump(RunkitClass::$oldProperty); 29 | var_dump(RunkitSubClass::$oldProperty); 30 | ?> 31 | --EXPECTF-- 32 | 33 | Warning: runkit_default_property_add(): RunkitClass::$oldProperty already exists in %s on line %d 34 | string(3) "old" 35 | 36 | Warning: runkit_default_property_add(): RunkitSubClass::$oldProperty already exists in %s on line %d 37 | string(3) "old" 38 | 39 | Notice: runkit_default_property_add(): RunkitClass::$oldProperty already exists, not adding in %s on line %d 40 | array(1) { 41 | ["a"]=> 42 | int(1) 43 | } 44 | string(3) "old" 45 | string(3) "old" 46 | -------------------------------------------------------------------------------- /tests/runkit_static_property_add_single.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_default_property_add() function - static override 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | 20 | --EXPECTF-- 21 | true 22 | -------------------------------------------------------------------------------- /tests/runkit_static_property_add_to_subclasses.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_static_property_add() add properties to subclasses 3 | --SKIPIF-- 4 | 7 | --INI-- 8 | error_reporting=E_ALL 9 | display_errors=on 10 | --FILE-- 11 | 1), RUNKIT7_ACC_STATIC); 27 | runkit_default_property_add($className, $propName, $value, RUNKIT7_ACC_PUBLIC | RUNKIT7_ACC_STATIC); 28 | runkit_default_property_add($className, 'privateProperty', "a", RUNKIT7_ACC_PRIVATE | RUNKIT7_ACC_STATIC); 29 | runkit_default_property_add($className, 'protectedProperty', NULL, RUNKIT7_ACC_PROTECTED | RUNKIT7_ACC_STATIC); 30 | $obj = new RunkitSubClass; 31 | runkit_default_property_add($className, 'dynamic', $obj, RUNKIT7_ACC_STATIC); 32 | $value = 10; 33 | 34 | RunkitClass::$constArray = array('b'=>2); 35 | RunkitClass::$publicProperty = 2; 36 | RunkitClass::setPrivate(); 37 | RunkitClass::setProtected(); 38 | RunkitClass::$dynamic = new RunkitClass; 39 | 40 | print_r(RunkitSubClass::$constArray); 41 | echo $propName, "\n"; 42 | var_dump(RunkitSubClass::$publicProperty); 43 | var_dump(RunkitSubClass::getProtected()); 44 | var_dump(RunkitSubClass::$dynamic); 45 | 46 | runkit_default_property_add('StdSubClass', 'str', 'test', RUNKIT7_ACC_STATIC); 47 | 48 | var_dump(StdSubClass::$str); 49 | var_dump(RunkitSubClass::getPrivate()); 50 | ?> 51 | --EXPECTF-- 52 | Array 53 | ( 54 | [b] => 2 55 | ) 56 | publicProperty 57 | int(2) 58 | int(1) 59 | object(RunkitClass)#2 (0) { 60 | } 61 | string(4) "test" 62 | 63 | Fatal error: Access to undeclared static property: RunkitSubClass::$privateProperty in %s on line %d 64 | -------------------------------------------------------------------------------- /tests/runkit_static_vars.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Static Variables in runkit modified functions (php<8.1) 3 | --SKIPIF-- 4 | = 80100) print "skip static variables in methods changed in php 8.1\n"; 7 | ?> 8 | --FILE-- 9 | orig(); 33 | runkit7_method_copy('C', 'copy', 'C', 'orig'); 34 | $c->copy(); 35 | runkit7_method_remove('C', 'orig'); 36 | $c->copy(); 37 | 38 | --EXPECT-- 39 | int(1) 40 | int(2) 41 | int(3) 42 | ==== 43 | int(1) 44 | int(2) 45 | int(3) 46 | -------------------------------------------------------------------------------- /tests/runkit_static_vars_php81.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Static Variables in runkit modified functions (php 8.1+) 3 | --SKIPIF-- 4 | 8 | --FILE-- 9 | orig(); 33 | runkit7_method_copy('C', 'copy', 'C', 'orig'); 34 | $c->copy(); 35 | runkit7_method_remove('C', 'orig'); 36 | $c->copy(); 37 | 38 | --EXPECT-- 39 | int(1) 40 | int(1) 41 | int(2) 42 | ==== 43 | int(1) 44 | int(1) 45 | int(2) 46 | -------------------------------------------------------------------------------- /tests/runkit_superglobals.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit.superglobal setting 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | display_errors=on 7 | runkit.superglobal=foo,bar 8 | --FILE-- 9 | 6 | --INI-- 7 | error_reporting=E_ALL 8 | display_errors=On 9 | runkit.internal_override=On 10 | --FILE-- 11 | property = 'testvalue'; 35 | 36 | $_SESSION['runkittest'] = $o; 37 | --EXPECTF-- 38 | OK 39 | -------------------------------------------------------------------------------- /tests/runkit_zval_inspect.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit7_zval_inspect() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL 7 | display_errors=on 8 | --FILE-- 9 | 14 | --EXPECTF-- 15 | array(2) { 16 | ["address"]=> 17 | string(%d) "%s" 18 | ["type"]=> 19 | int(4) 20 | } 21 | -------------------------------------------------------------------------------- /tests/runkit_zval_inspect_alias.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | runkit_zval_inspect() function 3 | --SKIPIF-- 4 | 5 | --INI-- 6 | error_reporting=E_ALL 7 | display_errors=on 8 | --FILE-- 9 | 14 | --EXPECTF-- 15 | Deprecated: Function runkit_zval_inspect() is deprecated in %srunkit_zval_inspect_alias.php on line 4 16 | array(2) { 17 | ["address"]=> 18 | string(%d) "0x%s" 19 | ["type"]=> 20 | int(4) 21 | } 22 | --------------------------------------------------------------------------------