diff --git a/.circleci/config.yml b/.circleci/config.yml index 85c31c71f59ac..78520332dfc7e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ jobs: resource_class: arm.medium docker: - image: cimg/base:current-22.04 - - image: mysql:8 + - image: mysql:8.3 environment: MYSQL_ALLOW_EMPTY_PASSWORD: true MYSQL_ROOT_PASSWORD: '' diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 76d6e61e2be3c..f84b0862e8a0c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -10,7 +10,7 @@ /.github @iluuu1994 @TimWolla /build/gen_stub.php @kocsismate -/ext/bcmath @Girgias +/ext/bcmath @Girgias @nielsdos @SakiTakamachi /ext/curl @adoy /ext/date @derickr /ext/dba @Girgias @@ -37,10 +37,13 @@ /ext/pgsql @devnexen /ext/random @TimWolla @zeriyoshi /ext/session @Girgias +/ext/simplexml @nielsdos /ext/sockets @devnexen /ext/spl @Girgias /ext/standard @bukka +/ext/xml @nielsdos /ext/xmlreader @nielsdos +/ext/xmlwriter @nielsdos /ext/xsl @nielsdos /main @bukka /sapi/fpm @bukka diff --git a/.github/actions/build-libmysqlclient/action.yml b/.github/actions/build-libmysqlclient/action.yml index 80a213ada5652..bab2bc544a128 100644 --- a/.github/actions/build-libmysqlclient/action.yml +++ b/.github/actions/build-libmysqlclient/action.yml @@ -15,10 +15,9 @@ runs: set -x LIBMYSQL=${{ inputs.libmysql }} MYSQL_BASE=${LIBMYSQL%%-linux-*} - MYSQL_VERSION=${MYSQL_BASE#*-} MYSQL_DIR=$HOME/$MYSQL_BASE mkdir -p $MYSQL_DIR - URL=https://cdn.mysql.com/Downloads/MySQL-${MYSQL_VERSION%.*}/$LIBMYSQL + URL=https://downloads.mysql.com/archives/get/p/23/file/$LIBMYSQL wget -nv $URL tar -xf $LIBMYSQL --strip-components=1 -C $MYSQL_DIR PDO_MYSQL=${MYSQL_DIR} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 0ccc1cc03b461..7d32d06726152 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -159,7 +159,7 @@ jobs: image: ubuntu:${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }} services: mysql: - image: mysql:8 + image: mysql:8.3 ports: - 3306:3306 env: @@ -745,7 +745,7 @@ jobs: uses: ./.github/actions/build-libmysqlclient with: configurationParameters: --enable-werror - libmysql: mysql-8.0.35-linux-glibc2.28-x86_64.tar.xz + libmysql: mysql-8.0.36-linux-glibc2.28-x86_64.tar.xz withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }} - name: Test mysql-8.0 uses: ./.github/actions/test-libmysqlclient @@ -824,6 +824,7 @@ jobs: with: key: "${{github.job}}-${{hashFiles('php/main/php_version.h')}}" append-timestamp: false + save: ${{ github.event_name != 'pull_request' }} - name: build PHP run: | cd php diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d07da17547310..d96748acecc3e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -46,7 +46,7 @@ jobs: if: github.repository == 'php/php-src' || github.event_name == 'pull_request' services: mysql: - image: mysql:8 + image: mysql:8.3 ports: - 3306:3306 env: @@ -116,6 +116,7 @@ jobs: # job id, not the job name) key: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}-${{hashFiles('main/php_version.h')}}" append-timestamp: false + save: ${{ github.event_name != 'pull_request' }} - name: ./configure uses: ./.github/actions/configure-x64 with: @@ -170,6 +171,7 @@ jobs: with: key: "${{github.job}}-${{matrix.os}}-${{hashFiles('main/php_version.h')}}" append-timestamp: false + save: ${{ github.event_name != 'pull_request' }} - name: ./configure uses: ./.github/actions/configure-macos with: @@ -246,6 +248,7 @@ jobs: with: key: "${{github.job}}-${{hashFiles('main/php_version.h')}}" append-timestamp: false + save: ${{ github.event_name != 'pull_request' }} - name: ./configure run: | set -x diff --git a/.gitignore b/.gitignore index cf11cd0ac20f9..608cb86294eb3 100644 --- a/.gitignore +++ b/.gitignore @@ -78,7 +78,7 @@ Makefile Makefile.fragments Makefile.objects -# Directories for shared object files and headers generated by `./configure` +# Directories for shared object files generated by `./configure` libs/ modules/ @@ -166,11 +166,6 @@ php # Extensions files # ------------------------------------------------------------------------------ -# Miscellaneous extensions files -/ext/opcache/jit/zend_jit_x86.c -/ext/opcache/jit/zend_jit_arm64.c -/ext/opcache/minilua - # Generated by `cd ext/name && phpize && ./configure` /ext/*/build/ /ext/*/configure.ac diff --git a/CODING_STANDARDS.md b/CODING_STANDARDS.md index 8615892279c92..3924227c914f0 100644 --- a/CODING_STANDARDS.md +++ b/CODING_STANDARDS.md @@ -152,62 +152,74 @@ rewritten to comply with these rules. 1. Method names follow the *studlyCaps* (also referred to as *bumpy case* or *camel caps*) naming convention, with care taken to minimize the letter count. The initial letter of the name is lowercase, and each letter that - starts a new `word` is capitalized: + starts a new "word" is capitalized. - Good: +1. Class names should be descriptive nouns in *PascalCase* and as short as + possible. Each word in the class name should start with a capital letter, + without underscore delimiters. The class name should be prefixed with the + name of the "parent set" (e.g. the name of the extension) if no namespaces + are used. + +1. Abbreviations and acronyms as well as initialisms should be avoided wherever + possible, unless they are much more widely used than the long form (e.g. HTTP + or URL). Abbreviations, acronyms, and initialisms should be treated like + regular words, thus they should be written with an uppercase first character, + followed by lowercase characters. + +1. Diverging from this policy is allowed to keep internal consistency within a + single extension, if the name follows an established, language-agnostic + standard, or for other reasons, if those reasons are properly justified + and voted on as part of the RFC process. + + + Good method names: ```php connect() getData() buildSomeWidget() + performHttpRequest() ``` - Bad: + Bad method names: ```php get_Data() buildsomewidget() getI() + performHTTPRequest() ``` -1. Class names should be descriptive nouns in *PascalCase* and as short as - possible. Each word in the class name should start with a capital letter, - without underscore delimiters. The class name should be prefixed with the - name of the "parent set" (e.g. the name of the extension) if no namespaces - are used. Abbreviations and acronyms as well as initialisms should be - avoided wherever possible, unless they are much more widely used than the - long form (e.g. HTTP or URL). Abbreviations start with a capital letter - followed by lowercase letters, whereas acronyms and initialisms are written - according to their standard notation. Usage of acronyms and initialisms is - not allowed if they are not widely adopted and recognized as such. - - Good: + Good class names: ```php Curl CurlResponse - HTTPStatusCode - URL - BTreeMap // B-tree Map - Id // Identifier - ID // Identity Document + HttpStatusCode + Url + BtreeMap // B-tree Map + UserId // User Identifier Char // Character Intl // Internationalization - Radar // Radio Detecting and Ranging + Ssl\Certificate + Ssl\Crl // Certificate Revocation List + Ssl\CrlUrl ``` - Bad: + Bad class names: ```php curl curl_response - HttpStatusCode - Url - BtreeMap - ID // Identifier + HTTPStatusCode + URL + BTreeMap + UserID // User Identifier CHAR INTL - RADAR // Radio Detecting and Ranging + SSL\Certificate + SSL\CRL + SSL\CRLURL ``` ## Internal function naming conventions diff --git a/EXTENSIONS b/EXTENSIONS index b59ae91c9a8cc..9cf88c94e6c15 100644 --- a/EXTENSIONS +++ b/EXTENSIONS @@ -170,12 +170,14 @@ EXTENSION: dom PRIMARY MAINTAINER: Christian Stocker (2003 - 2011) Rob Richards (2003 - 2012) Marcus Börger (2003 - 2006) + Niels Dossche (2023 - 2024) MAINTENANCE: Maintained STATUS: Working SINCE: 5.0 ------------------------------------------------------------------------------- EXTENSION: simplexml PRIMARY MAINTAINER: Marcus Börger (2003 - 2008) + Niels Dossche (2023 - 2024) MAINTENANCE: Maintained STATUS: Working SINCE: 5.0 @@ -188,30 +190,35 @@ STATUS: Working EXTENSION: xml PRIMARY MAINTAINER: Thies C. Arntzen (1999 - 2002) Rob Richards (2003 - 2013) + Niels Dossche (2023 - 2024) MAINTENANCE: Maintained STATUS: Working ------------------------------------------------------------------------------- EXTENSION: libxml PRIMARY MAINTAINER: Rob Richards (2003 - 2009) Christian Stocker (2004 - 2011) + Niels Dossche (2023 - 2024) MAINTENANCE: Maintained STATUS: Working ------------------------------------------------------------------------------- EXTENSION: xmlreader PRIMARY MAINTAINER: Rob Richards (2004 - 2010) Christian Stocker (2004 - 2004) + Niels Dossche (2023 - 2024) MAINTENANCE: Maintained STATUS: Working ------------------------------------------------------------------------------- EXTENSION: xmlwriter PRIMARY MAINTAINER: Rob Richards (2004 - 2010) Pierre-Alain Joye (2005-2009) + Niels Dossche (2023 - 2024) MAINTENANCE: Maintained STATUS: Working ------------------------------------------------------------------------------- EXTENSION: xsl PRIMARY MAINTAINER: Christian Stocker (2003 - 2011) Rob Richards (2003 - 2010) + Niels Dossche (2023 - 2024) MAINTENANCE: Maintained STATUS: Working SINCE: 5.0 diff --git a/NEWS b/NEWS index c35b3634dbcff..4416ce1008bdd 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.4.0alpha1 +- BCMath: + . [RFC] Add bcfloor, bcceil and bcround to BCMath. (Saki Takamachi) + . Improve performance. (Saki Takamachi, nielsdos) + - Core: . Added zend_call_stack_get implementation for NetBSD, DragonFlyBSD, Solaris and Haiku. (David Carlier) @@ -86,6 +90,7 @@ PHP NEWS . ResourceBundle::get() now has a tentative return type of: ResourceBundle|array|string|int|null . Added the new Grapheme function grapheme_str_split. (youkidearitai) + . Added IntlDateFormatter::parseToCalendar. (David Carlier) - LDAP: . Added LDAP_OPT_X_TLS_PROTOCOL_MAX/LDAP_OPT_X_TLS_PROTOCOL_TLS1_3 @@ -123,6 +128,8 @@ PHP NEWS . Added X509_PURPOSE_OCSP_HELPER and X509_PURPOSE_TIMESTAMP_SIGN constants. (Vincent Jardin) . Bumped minimum required OpenSSL version to 1.1.1. (Ayesh Karunaratne) + . Added compile-time option --with-openssl-legacy-provider to enable legacy + provider. (Adam Saponara) - Output: . Clear output handler status flags during handler initialization. (haszi) @@ -134,7 +141,7 @@ PHP NEWS . Added pcntl_getaffinity/pcntl_setaffinity. (David Carlier) . Updated pcntl_get_signal_handler signal id upper limit to be more in line with platforms limits. (David Carlier) - . Added pcntl_getcpu for Linux/FreeBSD. (David Carlier) + . Added pcntl_getcpu for Linux/FreeBSD/Solaris/Illumos. (David Carlier) . Added pcntl_getqos_class/pcntl_setqos_class for macOs. (David Carlier) . Added SIGCKPT/SIGCKPTEXIT constants for DragonFlyBSD. (David Carlier) @@ -168,6 +175,7 @@ PHP NEWS PDO constructor arguments. (SakiTakamachi) . Fixed native float support with pdo_pgsql query results. (Yurunsoft) . Added class PdoPgsql. (danack, kocsismate) + . Retrieve the memory usage of the query result resource. (KentarouTakeda) - PDO_SQLITE: . Added class PdoSqlite. (danack, kocsismate) @@ -176,6 +184,8 @@ PHP NEWS . Added the possibility to have no conditions for pg_select. (OmarEmaraDev) . Persistent connections support the PGSQL_CONNECT_FORCE_RENEW flag. (David Carlier) + . Added pg_result_memory_size to get the query result memory usage. + (KentarouTakeda) - Phar: . Fixed bug GH-12532 (PharData created from zip has incorrect timestamp). @@ -209,6 +219,8 @@ PHP NEWS (David Carlier) . Updated the socket_create_listen backlog argument default value to SOMAXCONN. (David Carlier) + . Added the SO_NOSIGPIPE constant to control the generation of SIGPIPE for + macOs and FreeBSD. (David Carlier) - SNMP: . Removed the deprecated inet_ntoa call support. (David Carlier) @@ -230,6 +242,9 @@ PHP NEWS . Add support for AEGIS-128L and AEGIS-256 (jedisct1) . Enable AES-GCM on aarch64 with the ARM crypto extensions (jedisct1) +- SPL: + . Implement SeekableIterator for SplObjectStorage. (nielsdos) + - Standard: . Implement GH-12188 (Indication for the int size in phpinfo()). (timwolla) . Partly fix GH-12143 (Incorrect round() result for 0.49999999999999994). diff --git a/UPGRADING b/UPGRADING index 7c93e6f57b659..2507bdd4bec03 100644 --- a/UPGRADING +++ b/UPGRADING @@ -68,6 +68,12 @@ PHP 8.4 UPGRADE NOTES - ODBC: . odbc_fetch_row() returns false when a value less than or equal to 0 is passed for parameter $row. Now, a warning is emitted in this case. + . odbc_connect() and odbc_pconnect() will now return an Odbc\Connection + object rather than a resource. Return value checks using is_resource() + should be replaced with checks for `false`. + . odbc_prepare(), odbc_exec(), and various other functions will now return + an Odbc\Result object rather than a resource. Return value checks using + is_resource() should be replaced with checks for `false`. - Opcache: . The JIT config defaults changed from opcache.jit=tracing and @@ -129,6 +135,17 @@ PHP 8.4 UPGRADE NOTES . Calling simplexml_import_dom() with a non-XML object now throws a TypeError instead of a ValueError. +- SOAP: + . SoapClient::$httpurl is now a Soap\Url object rather than a resource. + Checks using is_resource() (i.e. is_resource($client->httpurl)) should be + replaced with checks for null (i.e. $client->httpurl !== null). + . SoapClient::$sdl is now a Soap\Sdl object rather than a resource. + Checks using is_resource() (i.e. is_resource($client->sdl)) should be + replaced with checks for null (i.e. $client->sdl !== null). + . SoapClient::$typemap is now an array rather than a resource. + Checks using is_resource() (i.e. is_resource($client->typemap)) should be + replaced with checks for null (i.e. $client->typemap !== null). + - SPL: . Out of bounds accesses in SplFixedArray now throw an exception of type OutOfBoundsException instead of RuntimeException. As OutOfBoundsException @@ -257,6 +274,7 @@ PHP 8.4 UPGRADE NOTES . ReflectionClassConstant::__toString() and ReflectionProperty::__toString() now returns the attached doc comments. . ReflectionConstant was introduced. + . ReflectionClassConstant::isDeprecated() was introduced. - Standard: . stream_bucket_make_writeable() and stream_bucket_new() will now return a @@ -321,6 +339,7 @@ PHP 8.4 UPGRADE NOTES 3-parameter signature with a null $row parameter instead. . Calling pg_field_is_null() with 2 arguments is deprecated. Use the 3-parameter signature with a null $row parameter instead. + . Added pg_result_memory_size to get the visibility the memory used by a query result. - Reflection: . Calling ReflectionMethod::__construct() with 1 argument is deprecated. @@ -402,6 +421,10 @@ PHP 8.4 UPGRADE NOTES - PDO_MYSQL: . getAttribute, enabled to get the value of ATTR_FETCH_TABLE_NAMES. +- PDO_PGSQL: + . getAttribute() can now retrieve the memory usage of query results. + PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE was added for this feature. + - PGSQL: . pg_select, the conditions arguments accepts an empty array and is optional. @@ -451,6 +474,10 @@ PHP 8.4 UPGRADE NOTES 6. New Functions ======================================== +- BCMath: + . Added bcfloor(), bcceil(), bcround(). + RFC: https://wiki.php.net/rfc/adding_bcround_bcfloor_bcceil_to_bcmath + - DOM: . Added DOMNode::compareDocumentPosition(). . Added DOMXPath::registerPhpFunctionNS(). @@ -463,6 +490,8 @@ PHP 8.4 UPGRADE NOTES the IANA identifier from a given timezone. . Added grapheme_str_split which allow to support emoji and Variation Selectors. + . Added IntlDateFormatter::parseToCalendar which behaves like + IntlDateFormatter::parse except the time zone is updated. - MBString: . Added mb_trim, mb_ltrim and mb_rtrim functions. @@ -491,6 +520,10 @@ PHP 8.4 UPGRADE NOTES . sodium_crypto_aead_aes256gcm_*() functions are now enabled on aarch64 CPUs with the ARM cryptographic extensions. +- SPL: + . Added seek() method to SplObjectStorage, now it implements + SeekableIterator. + - Standard: . Added the http_get_last_response_headers() and http_clear_last_response_headers() that allows retrieving the same content @@ -507,12 +540,12 @@ PHP 8.4 UPGRADE NOTES - DOM: . Implemented DOM HTML5 parsing and serialization. RFC: https://wiki.php.net/rfc/domdocument_html5_parser. - This RFC adds the new DOM namespace along with new classes and + This RFC adds the new Dom namespace along with new classes and constant aliases. There are two new classes to handle HTML and XML documents: - DOM\HTMLDocument and DOM\XMLDocument. + Dom\HTMLDocument and Dom\XMLDocument. These classes provide a cleaner API to handle HTML and XML documents. - Furthermore, the DOM\HTMLDocument class implements spec-compliant HTML5 + Furthermore, the Dom\HTMLDocument class implements spec-compliant HTML5 parsing and serialization. . Implemented opt-in ext/dom spec compliance RFC. This adds new classes in the DOM namespace that correspond to modern @@ -611,6 +644,7 @@ PHP 8.4 UPGRADE NOTES . SOCK_DCCP (NetBSD only). . TCP_SYNCNT (Linux only). . SO_EXCLBIND (Solaris/Illumos only). + . SO_NOSIGPIPE (macOs and FreeBSD). - Sodium: . SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES @@ -643,10 +677,17 @@ PHP 8.4 UPGRADE NOTES and the line of definition to make them easier to distinguish, for example within stack traces. +* run-tests.php now skips online tests by default. Set the SKIP_ONLINE_TESTS + environment variable to 0, or pass the --online flag to run-tests.php to + execute them. + ======================================== 14. Performance Improvements ======================================== +- BCMath: + . Improved performance of number conversions and operations. + - Core: . Improved the performance of floating point number parsing and formatting in ZTS builds under highly concurrent loads. This affects the `printf()` family @@ -657,6 +698,7 @@ PHP 8.4 UPGRADE NOTES . The performance of DOMNode::C14N() is greatly improved for the case without an xpath query. This can give a time improvement of easily two order of magnitude for documents with tens of thousands of nodes. + . Improved performance and reduce memory consumption of XML serialization. - FTP: . Improved the performance of FTP uploads up to a factor of 10x for large @@ -672,6 +714,9 @@ PHP 8.4 UPGRADE NOTES - MySQLnd: . Improved the performance of MySQLnd quoting. +- SimpleXML: + . Improved performance and reduce memory consumption of XML serialization. + - Standard: . Improved the performance of strpbrk(). . get_browser() is much faster now, up to 1.5x - 2.5x for some test cases. diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 49ca2873b59a2..63cc0e2a21e0c 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -102,6 +102,10 @@ PHP 8.4 INTERNALS UPGRADE NOTES - The configure option --with-oci8 has been removed. - The configure option --with-zlib-dir has been removed. - The configure option --with-kerberos has been removed. + - The configure option --with-openssl-dir has been removed. SSL support in + ext/ftp and ext/mysqlnd is enabled implicitly, when building with + ext/openssl (--with-openssl), or explicitly by using new configure options + --with-ftp-ssl and --with-mysqlnd-ssl. - COOKIE_IO_FUNCTIONS_T symbol has been removed (use cookie_io_functions_t). - HAVE_SOCKADDR_UN_SUN_LEN symbol renamed to HAVE_STRUCT_SOCKADDR_UN_SUN_LEN. - HAVE_UTSNAME_DOMAINNAME symbol renamed to HAVE_STRUCT_UTSNAME_DOMAINNAME. @@ -118,6 +122,7 @@ PHP 8.4 INTERNALS UPGRADE NOTES - Symbol ZEND_FIBER_ASM has been removed. - Symbols HAVE_DLOPEN and HAVE_DLSYM have been removed. - Symbol HAVE_MYSQL has been removed. + - Symbol HAVE_PDO_SQLITELIB has been removed. - M4 macro PHP_DEFINE (atomic includes) removed (use AC_DEFINE and config.h). - M4 macro PHP_WITH_SHARED has been removed (use PHP_ARG_WITH). - M4 macro PHP_STRUCT_FLOCK has been removed (use AC_CHECK_TYPES). @@ -202,6 +207,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES - Added a way to attached private data to a php_libxml_ref_obj. - Added a way to fix a class type onto php_libxml_ref_obj. - Added php_libxml_uses_internal_errors(). + - Added a way to override document handlers (e.g. serialization) with + php_libxml_document_handlers. e. ext/date - Added the php_format_date_ex() API to format instances of php_date_obj. diff --git a/Zend/Optimizer/zend_func_infos.h b/Zend/Optimizer/zend_func_infos.h index 76628104528fe..8ebd9e228728b 100644 --- a/Zend/Optimizer/zend_func_infos.h +++ b/Zend/Optimizer/zend_func_infos.h @@ -27,6 +27,9 @@ static const func_info_t func_infos[] = { F1("bcpowmod", MAY_BE_STRING), F1("bcpow", MAY_BE_STRING), F1("bcsqrt", MAY_BE_STRING), + F1("bcfloor", MAY_BE_STRING), + F1("bcceil", MAY_BE_STRING), + F1("bcround", MAY_BE_STRING), FN("bzopen", MAY_BE_RESOURCE|MAY_BE_FALSE), F1("bzerror", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING), F1("cal_from_jd", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_NULL), @@ -74,8 +77,6 @@ static const func_info_t func_infos[] = { F1("date_sunrise", MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE), F1("date_sunset", MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE), F1("date_sun_info", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_FALSE|MAY_BE_ARRAY_OF_TRUE|MAY_BE_ARRAY_OF_LONG), - FN("dba_popen", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("dba_open", MAY_BE_RESOURCE|MAY_BE_FALSE), FN("dba_key_split", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_FALSE), F1("dba_handlers", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_STRING), FN("dba_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING), @@ -308,31 +309,6 @@ static const func_info_t func_infos[] = { F1("mysqli_stat", MAY_BE_STRING|MAY_BE_FALSE), F1("mysqli_store_result", MAY_BE_OBJECT|MAY_BE_FALSE), F1("mysqli_use_result", MAY_BE_OBJECT|MAY_BE_FALSE), - FN("odbc_prepare", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_exec", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_connect", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_pconnect", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_tables", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_columns", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_gettypeinfo", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_primarykeys", MAY_BE_RESOURCE|MAY_BE_FALSE), -#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) - FN("odbc_procedurecolumns", MAY_BE_RESOURCE|MAY_BE_FALSE), -#endif -#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) - FN("odbc_procedures", MAY_BE_RESOURCE|MAY_BE_FALSE), -#endif -#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35) - FN("odbc_foreignkeys", MAY_BE_RESOURCE|MAY_BE_FALSE), -#endif - FN("odbc_specialcolumns", MAY_BE_RESOURCE|MAY_BE_FALSE), - FN("odbc_statistics", MAY_BE_RESOURCE|MAY_BE_FALSE), -#if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35) - FN("odbc_tableprivileges", MAY_BE_RESOURCE|MAY_BE_FALSE), -#endif -#if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35) - FN("odbc_columnprivileges", MAY_BE_RESOURCE|MAY_BE_FALSE), -#endif F1("opcache_get_status", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE), F1("opcache_get_configuration", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_ANY|MAY_BE_FALSE), F1("openssl_x509_parse", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_STRING|MAY_BE_ARRAY_OF_LONG|MAY_BE_ARRAY_OF_STRING|MAY_BE_ARRAY_OF_ARRAY|MAY_BE_FALSE), diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index 47e79f77dc2cb..db4ab10f7d1d8 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -21,6 +21,7 @@ AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[ _FPU_SETCW(fpu_cw); result = a / b; _FPU_SETCW(fpu_oldcw); + (void)result; ]])],[ac_cfp_have__fpu_setcw=yes],[ac_cfp_have__fpu_setcw=no]) if test "$ac_cfp_have__fpu_setcw" = "yes" ; then AC_DEFINE(HAVE__FPU_SETCW, 1, [whether _FPU_SETCW is present and usable]) @@ -42,6 +43,7 @@ AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[ fpsetprec(FP_PD); result = a / b; fpsetprec(fpu_oldprec); + (void)result; ]])], [ac_cfp_have_fpsetprec=yes], [ac_cfp_have_fpsetprec=no]) if test "$ac_cfp_have_fpsetprec" = "yes" ; then AC_DEFINE(HAVE_FPSETPREC, 1, [whether fpsetprec is present and usable]) @@ -63,6 +65,7 @@ AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[ _controlfp(_PC_53, _MCW_PC); result = a / b; _controlfp(fpu_oldcw, _MCW_PC); + (void)result; ]])], [ac_cfp_have__controlfp=yes], [ac_cfp_have__controlfp=no]) if test "$ac_cfp_have__controlfp" = "yes" ; then AC_DEFINE(HAVE__CONTROLFP, 1, [whether _controlfp is present usable]) @@ -85,6 +88,7 @@ AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[ _controlfp_s(&fpu_cw, _PC_53, _MCW_PC); result = a / b; _controlfp_s(&fpu_cw, fpu_oldcw, _MCW_PC); + (void)result; ]])], [ac_cfp_have__controlfp_s=yes], [ac_cfp_have__controlfp_s=no]) if test "$ac_cfp_have__controlfp_s" = "yes" ; then AC_DEFINE(HAVE__CONTROLFP_S, 1, [whether _controlfp_s is present and usable]) @@ -105,10 +109,9 @@ AC_DEFUN([ZEND_CHECK_FLOAT_PRECISION],[ __asm__ __volatile__ ("fnstcw %0" : "=m" (*&oldcw)); cw = (oldcw & ~0x0 & ~0x300) | 0x200; __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw)); - result = a / b; - __asm__ __volatile__ ("fldcw %0" : : "m" (*&oldcw)); + (void)result; ]])], [ac_cfp_have_fpu_inline_asm_x86=yes], [ac_cfp_have_fpu_inline_asm_x86=no]) if test "$ac_cfp_have_fpu_inline_asm_x86" = "yes" ; then AC_DEFINE(HAVE_FPU_INLINE_ASM_X86, 1, [whether FPU control word can be manipulated by inline assembler]) diff --git a/Zend/tests/attributes/021_attribute_flags_type_is_validated.phpt b/Zend/tests/attributes/021_attribute_flags_type_is_validated.phpt index 01ab29c5efab9..70e4fdb7f338a 100644 --- a/Zend/tests/attributes/021_attribute_flags_type_is_validated.phpt +++ b/Zend/tests/attributes/021_attribute_flags_type_is_validated.phpt @@ -6,6 +6,15 @@ Attribute flags type is validated. #[Attribute("foo")] class A1 { } +#[A1] +class Foo {} + +try { + (new ReflectionClass(Foo::class))->getAttributes()[0]->newInstance(); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + ?> ---EXPECTF-- -Fatal error: Attribute::__construct(): Argument #1 ($flags) must be of type int, string given in %s +--EXPECT-- +Attribute::__construct(): Argument #1 ($flags) must be of type int, string given diff --git a/Zend/tests/attributes/022_attribute_flags_value_is_validated.phpt b/Zend/tests/attributes/022_attribute_flags_value_is_validated.phpt index 72433a9f13930..efaa969af827e 100644 --- a/Zend/tests/attributes/022_attribute_flags_value_is_validated.phpt +++ b/Zend/tests/attributes/022_attribute_flags_value_is_validated.phpt @@ -6,6 +6,15 @@ Attribute flags value is validated. #[Attribute(-1)] class A1 { } +#[A1] +class Foo { } + +try { + var_dump((new ReflectionClass(Foo::class))->getAttributes()[0]->newInstance()); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + ?> ---EXPECTF-- -Fatal error: Invalid attribute flags specified in %s +--EXPECT-- +Invalid attribute flags specified diff --git a/Zend/tests/attributes/023_ast_node_in_validation.phpt b/Zend/tests/attributes/023_ast_node_in_validation.phpt index 332d83fe86f61..063a6b7e815d2 100644 --- a/Zend/tests/attributes/023_ast_node_in_validation.phpt +++ b/Zend/tests/attributes/023_ast_node_in_validation.phpt @@ -6,6 +6,15 @@ Attribute flags value is validated. #[Attribute(Foo::BAR)] class A1 { } +#[A1] +class Bar { } + +try { + var_dump((new ReflectionClass(Bar::class))->getAttributes()[0]->newInstance()); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + ?> ---EXPECTF-- -Fatal error: Class "Foo" not found in %s on line %d +--EXPECT-- +Class "Foo" not found diff --git a/Zend/tests/attributes/032_attribute_validation_scope.phpt b/Zend/tests/attributes/032_attribute_validation_scope.phpt index 039a427254f4d..d157c35929bf2 100644 --- a/Zend/tests/attributes/032_attribute_validation_scope.phpt +++ b/Zend/tests/attributes/032_attribute_validation_scope.phpt @@ -1,9 +1,19 @@ --TEST-- -Validation for "Attribute" does not use a scope when evaluating constant ASTs +Validation for "Attribute" uses the class scope when evaluating constant ASTs --FILE-- getAttributes()[0]->newInstance()); ?> ---EXPECTF-- -Fatal error: Cannot access "parent" when no class scope is active in %s on line %d +--EXPECT-- +object(x)#1 (0) { +} diff --git a/Zend/tests/attributes/033_attribute_flags_type_is_not_validated_at_comp_time.phpt b/Zend/tests/attributes/033_attribute_flags_type_is_not_validated_at_comp_time.phpt new file mode 100644 index 0000000000000..76b29c65ba87b --- /dev/null +++ b/Zend/tests/attributes/033_attribute_flags_type_is_not_validated_at_comp_time.phpt @@ -0,0 +1,12 @@ +--TEST-- +Attribute flags type is not validated at compile time. +--FILE-- + +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/tests/class_alias_002.phpt b/Zend/tests/class_alias_002.phpt index 7a6eb126a920e..16d2d60e3791b 100644 --- a/Zend/tests/class_alias_002.phpt +++ b/Zend/tests/class_alias_002.phpt @@ -9,4 +9,4 @@ class_alias('foo', 'FOO'); ?> --EXPECTF-- -Warning: Cannot declare class FOO, because the name is already in use in %s on line %d +Warning: Cannot redeclare class FOO (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/class_alias_004.phpt b/Zend/tests/class_alias_004.phpt index ea3501ed57ff1..df0d1e537d8b7 100644 --- a/Zend/tests/class_alias_004.phpt +++ b/Zend/tests/class_alias_004.phpt @@ -12,4 +12,4 @@ class_alias('foo', 'test'); ?> --EXPECTF-- -Warning: Cannot declare class test, because the name is already in use in %s on line %d +Warning: Cannot redeclare class test (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/class_alias_010.phpt b/Zend/tests/class_alias_010.phpt index 3e52f5ffc5c46..6dcf9eee63d98 100644 --- a/Zend/tests/class_alias_010.phpt +++ b/Zend/tests/class_alias_010.phpt @@ -11,4 +11,4 @@ class b { } ?> --EXPECTF-- -Warning: Cannot declare interface b, because the name is already in use in %s on line %d +Warning: Cannot redeclare interface b (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/class_alias_019.phpt b/Zend/tests/class_alias_019.phpt index ace349e9bdd9a..4e229f511b12a 100644 --- a/Zend/tests/class_alias_019.phpt +++ b/Zend/tests/class_alias_019.phpt @@ -14,4 +14,4 @@ class_alias('\foo', 'foo'); ?> --EXPECTF-- -Warning: Cannot declare class foo, because the name is already in use in %s on line %d +Warning: Cannot redeclare class foo (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/closure_068.phpt b/Zend/tests/closure_068.phpt new file mode 100644 index 0000000000000..977d3946770ab --- /dev/null +++ b/Zend/tests/closure_068.phpt @@ -0,0 +1,13 @@ +--TEST-- +ReflectionFunction::getShortName() returns the short name for first class callables defined in namespaces. +--FILE-- +getShortName()); +?> +--EXPECT-- +string(3) "foo" diff --git a/Zend/tests/declare_already_in_use.phpt b/Zend/tests/declare_already_in_use.phpt index c7e4ce8d677b7..85395160c5e76 100644 --- a/Zend/tests/declare_already_in_use.phpt +++ b/Zend/tests/declare_already_in_use.phpt @@ -1,5 +1,5 @@ --TEST-- -Cannot declare class, because the name is already in use +Cannot redeclare class --FILE-- --EXPECTF-- -Fatal error: Cannot declare class A, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare class A (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/delayed_early_binding_redeclaration.phpt b/Zend/tests/delayed_early_binding_redeclaration.phpt index 5370b45f52bcc..48fab510c0277 100644 --- a/Zend/tests/delayed_early_binding_redeclaration.phpt +++ b/Zend/tests/delayed_early_binding_redeclaration.phpt @@ -10,4 +10,4 @@ include __DIR__ . '/delayed_early_binding_redeclaration-2.inc'; var_dump(class_exists(Bar::class)); ?> --EXPECTF-- -Fatal error: Cannot declare class Bar, because the name is already in use in %sdelayed_early_binding_redeclaration-2.inc on line %d +Fatal error: Cannot redeclare class Bar (previously declared in %sdelayed_early_binding_redeclaration-1.inc:2) in %sdelayed_early_binding_redeclaration-2.inc on line %d diff --git a/Zend/tests/errmsg_026.phpt b/Zend/tests/errmsg_026.phpt index 2144a0707b231..911b4f811d6cc 100644 --- a/Zend/tests/errmsg_026.phpt +++ b/Zend/tests/errmsg_026.phpt @@ -9,4 +9,4 @@ class stdclass { echo "Done\n"; ?> --EXPECTF-- -Fatal error: Cannot declare class stdclass, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare class stdClass in %s on line %d diff --git a/Zend/tests/function_redecl.phpt b/Zend/tests/function_redecl.phpt index 4c1395472fc6a..1bb683c6859fd 100644 --- a/Zend/tests/function_redecl.phpt +++ b/Zend/tests/function_redecl.phpt @@ -6,4 +6,4 @@ function f() {} function f() {} ?> --EXPECTF-- -Fatal error: Cannot redeclare f() (previously declared in %s:%d) in %s on line %d +Fatal error: Cannot redeclare function f() (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/gh10014.phpt b/Zend/tests/gh10014.phpt index 0870c5631336a..a4adab84c4829 100644 --- a/Zend/tests/gh10014.phpt +++ b/Zend/tests/gh10014.phpt @@ -7,6 +7,8 @@ GH-10014: Incorrect short-circuiting in constant expressions class y { } +(new ReflectionClass(y::class))->getAttributes()[0]->newInstance(); + ?> --EXPECTF-- Warning: Undefined array key 2 in %s on line %d diff --git a/Zend/tests/gh14009_001.phpt b/Zend/tests/gh14009_001.phpt new file mode 100644 index 0000000000000..81325e814c271 --- /dev/null +++ b/Zend/tests/gh14009_001.phpt @@ -0,0 +1,41 @@ +--TEST-- +GH-14009: Traits inherit prototype +--FILE-- +common(); + } +} + +class B extends P { + protected function common() { + echo __METHOD__, "\n"; + } +} + +trait T { + protected function common() { + echo __METHOD__, "\n"; + } +} + +class C extends P { + use T; +} + +$a = new A(); +$a->test(new B()); +$a->test(new C()); + +?> +--EXPECT-- +B::common +T::common diff --git a/Zend/tests/gh14009_002.phpt b/Zend/tests/gh14009_002.phpt new file mode 100644 index 0000000000000..86047e020205e --- /dev/null +++ b/Zend/tests/gh14009_002.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-14009: Traits inherit prototype +--FILE-- + +--EXPECTF-- +Fatal error: Declaration of P::common() must be compatible with T::common(int $param) in %s on line %d diff --git a/Zend/tests/gh14009_003.phpt b/Zend/tests/gh14009_003.phpt new file mode 100644 index 0000000000000..71ee5baa360a6 --- /dev/null +++ b/Zend/tests/gh14009_003.phpt @@ -0,0 +1,19 @@ +--TEST-- +GH-14009: Traits inherit prototype +--FILE-- + +--EXPECT-- diff --git a/Zend/tests/gh14009_004.phpt b/Zend/tests/gh14009_004.phpt new file mode 100644 index 0000000000000..01bad46fedcb7 --- /dev/null +++ b/Zend/tests/gh14009_004.phpt @@ -0,0 +1,37 @@ +--TEST-- +GH-14009: Traits inherit prototype +--FILE-- +test(); + } +} + +D::callTest(new C()); + +?> +--EXPECT-- +B::test diff --git a/Zend/tests/gh14009_005.phpt b/Zend/tests/gh14009_005.phpt new file mode 100644 index 0000000000000..c079bfb832aa8 --- /dev/null +++ b/Zend/tests/gh14009_005.phpt @@ -0,0 +1,38 @@ +--TEST-- +GH-14009: Traits inherit prototype +--FILE-- + ". __CLASS__ . "::" . __METHOD__ . "\n"; + } +} + +class A { + use T; + public function foo() { + $this->test(__METHOD__); + } + public function bar() { + $this->test(__METHOD__); + } +} + +class B extends A { + use T; + public function foo() { + $this->test(__METHOD__); + } +} + +(new A)->foo(); +(new A)->bar(); +(new B)->foo(); +(new B)->bar(); +?> +--EXPECT-- +A::foo -> A::T::test +A::bar -> A::T::test +B::foo -> B::T::test +A::bar -> A::T::test diff --git a/Zend/tests/inter_06.phpt b/Zend/tests/inter_06.phpt index aba8ba4fb4976..1987c24a8b96a 100644 --- a/Zend/tests/inter_06.phpt +++ b/Zend/tests/inter_06.phpt @@ -7,4 +7,4 @@ interface stdClass { } ?> --EXPECTF-- -Fatal error: Cannot declare interface stdClass, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare class stdClass in %s on line %d diff --git a/Zend/tests/interface_constructor_prototype_001.phpt b/Zend/tests/interface_constructor_prototype_001.phpt new file mode 100644 index 0000000000000..67341367ac58f --- /dev/null +++ b/Zend/tests/interface_constructor_prototype_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +Interfaces don't set prototypes to their parent method +--FILE-- + +--EXPECTF-- +Fatal error: Declaration of Test::__construct(int $param) must be compatible with B::__construct(int|float $param) in %s on line %d diff --git a/Zend/tests/interface_constructor_prototype_002.phpt b/Zend/tests/interface_constructor_prototype_002.phpt new file mode 100644 index 0000000000000..76398d2d215b9 --- /dev/null +++ b/Zend/tests/interface_constructor_prototype_002.phpt @@ -0,0 +1,26 @@ +--TEST-- +Interfaces don't set prototypes to their parent method +--XFAIL-- +X::__constructor()'s prototype is set to B::__construct(). Y::__construct() then +uses prototype to verify LSP, but misses A::__construct() which has a stricter +signature. +--FILE-- + +--EXPECTF-- +Fatal error: Declaration of Y::__construct(int $param) must be compatible with A::__construct(int|float $param) in %s on line %d diff --git a/Zend/tests/name_collision_01.phpt b/Zend/tests/name_collision_01.phpt index d6d4ae35db1e6..07d36dd13b255 100644 --- a/Zend/tests/name_collision_01.phpt +++ b/Zend/tests/name_collision_01.phpt @@ -8,4 +8,4 @@ class A { } ?> --EXPECTF-- -Fatal error: Cannot declare class A, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare class A (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/name_collision_02.phpt b/Zend/tests/name_collision_02.phpt index 3baeb45e6f8fe..f740961d55bd1 100644 --- a/Zend/tests/name_collision_02.phpt +++ b/Zend/tests/name_collision_02.phpt @@ -8,4 +8,4 @@ interface A { } ?> --EXPECTF-- -Fatal error: Cannot declare interface A, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare class A (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/name_collision_03.phpt b/Zend/tests/name_collision_03.phpt index 6be45204a55b2..3785b04ce7829 100644 --- a/Zend/tests/name_collision_03.phpt +++ b/Zend/tests/name_collision_03.phpt @@ -8,4 +8,4 @@ trait A { } ?> --EXPECTF-- -Fatal error: Cannot declare trait A, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare class A (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/name_collision_04.phpt b/Zend/tests/name_collision_04.phpt index b391a96744342..a3d5c2995f1bd 100644 --- a/Zend/tests/name_collision_04.phpt +++ b/Zend/tests/name_collision_04.phpt @@ -8,4 +8,4 @@ interface A { } ?> --EXPECTF-- -Fatal error: Cannot declare interface A, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare interface A (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/name_collision_05.phpt b/Zend/tests/name_collision_05.phpt index 87af1f0df9941..00cd046e3be3d 100644 --- a/Zend/tests/name_collision_05.phpt +++ b/Zend/tests/name_collision_05.phpt @@ -8,4 +8,4 @@ trait A { } ?> --EXPECTF-- -Fatal error: Cannot declare trait A, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare interface A (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/name_collision_06.phpt b/Zend/tests/name_collision_06.phpt index cfeeed4a4340b..19dee2eaee4d2 100644 --- a/Zend/tests/name_collision_06.phpt +++ b/Zend/tests/name_collision_06.phpt @@ -8,4 +8,4 @@ trait A { } ?> --EXPECTF-- -Fatal error: Cannot declare trait A, because the name is already in use in %s on line %d +Fatal error: Cannot redeclare trait A (previously declared in %s:%d) in %s on line %d diff --git a/Zend/tests/name_collision_07.phpt b/Zend/tests/name_collision_07.phpt index cb35e88db69cf..6988633b613dd 100644 --- a/Zend/tests/name_collision_07.phpt +++ b/Zend/tests/name_collision_07.phpt @@ -13,4 +13,4 @@ namespace Bazzle { } ?> --EXPECTF-- -Fatal error: Cannot declare class Bazzle\Bar because the name is already in use in %s on line %d +Fatal error: Cannot redeclare class Bazzle\Bar (previously declared as local import) in %s on line %d diff --git a/Zend/tests/name_collision_08.phpt b/Zend/tests/name_collision_08.phpt index 652fa3dbf15ed..8876431a669cc 100644 --- a/Zend/tests/name_collision_08.phpt +++ b/Zend/tests/name_collision_08.phpt @@ -13,4 +13,4 @@ namespace Bazzle { } ?> --EXPECTF-- -Fatal error: Cannot declare function Bazzle\bar because the name is already in use in %s on line %d +Fatal error: Cannot redeclare function Bazzle\bar() (previously declared as local import) in %s on line %d diff --git a/Zend/tests/ns_029.phpt b/Zend/tests/ns_029.phpt index d053a9a33724a..75ee13ad4ce10 100644 --- a/Zend/tests/ns_029.phpt +++ b/Zend/tests/ns_029.phpt @@ -10,4 +10,4 @@ class Foo { new Foo(); ?> --EXPECTF-- -Fatal error: Cannot declare class Foo because the name is already in use in %sns_029.php on line 4 +Fatal error: Cannot redeclare class Foo (previously declared as local import) in %sns_029.php on line 4 diff --git a/Zend/tests/use_function/define_imported.phpt b/Zend/tests/use_function/define_imported.phpt index c542a4d5494b9..abfc1cef5f117 100644 --- a/Zend/tests/use_function/define_imported.phpt +++ b/Zend/tests/use_function/define_imported.phpt @@ -11,4 +11,4 @@ namespace { ?> --EXPECTF-- -Fatal error: Cannot declare function bar because the name is already in use in %s on line %d +Fatal error: Cannot redeclare function bar() (previously declared as local import) in %s on line %d diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 2a16f24250ebe..ae7a06f011761 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -438,6 +438,26 @@ ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char * } /* }}} */ +ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string *new_name, zend_class_entry *old_ce) +{ + if (old_ce->type == ZEND_INTERNAL_CLASS) { + zend_error(type, "Cannot redeclare %s %s", + zend_get_object_type(old_ce), + ZSTR_VAL(new_name)); + } else { + zend_error(type, "Cannot redeclare %s %s (previously declared in %s:%d)", + zend_get_object_type(old_ce), + ZSTR_VAL(new_name), + ZSTR_VAL(old_ce->info.user.filename), + old_ce->info.user.line_start); + } +} + +ZEND_API ZEND_COLD void zend_class_redeclaration_error(int type, zend_class_entry *old_ce) +{ + zend_class_redeclaration_error_ex(type, old_ce->name, old_ce); +} + ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null) /* {{{ */ { zend_class_entry *ce_base = *pce; diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 8e82950e959cf..90556fcde4245 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -838,7 +838,7 @@ ZEND_API void zend_call_known_function( uint32_t param_count, zval *params, HashTable *named_params); static zend_always_inline void zend_call_known_fcc( - zend_fcall_info_cache *fcc, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params) + const zend_fcall_info_cache *fcc, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params) { zend_function *func = fcc->function_handler; /* Need to copy trampolines as they get released after they are called */ @@ -1563,6 +1563,8 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_error_variadic(zend_class_en ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t arg_num, const char *format, ...); ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format, ...); ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format, ...); +ZEND_API ZEND_COLD void zend_class_redeclaration_error(int type, zend_class_entry *old_ce); +ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string *new_name, zend_class_entry *old_ce); #define ZPP_ERROR_OK 0 #define ZPP_ERROR_FAILURE 1 diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index 798dd27b7b648..fb12131bb00f3 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -35,32 +35,36 @@ static zend_object_handlers attributes_object_handlers_sensitive_parameter_value static HashTable internal_attributes; -void validate_attribute(zend_attribute *attr, uint32_t target, zend_class_entry *scope) +uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope) { // TODO: More proper signature validation: Too many args, incorrect arg names. if (attr->argc > 0) { zval flags; - /* As this is run in the middle of compilation, fetch the attribute value without - * specifying a scope. The class is not fully linked yet, and we may seen an - * inconsistent state. */ - if (FAILURE == zend_get_attribute_value(&flags, attr, 0, NULL)) { - return; + if (FAILURE == zend_get_attribute_value(&flags, attr, 0, scope)) { + ZEND_ASSERT(EG(exception)); + return 0; } if (Z_TYPE(flags) != IS_LONG) { - zend_error_noreturn(E_ERROR, + zend_throw_error(NULL, "Attribute::__construct(): Argument #1 ($flags) must be of type int, %s given", zend_zval_value_name(&flags) ); + zval_ptr_dtor(&flags); + return 0; } - if (Z_LVAL(flags) & ~ZEND_ATTRIBUTE_FLAGS) { - zend_error_noreturn(E_ERROR, "Invalid attribute flags specified"); + uint32_t flags_l = Z_LVAL(flags); + if (flags_l & ~ZEND_ATTRIBUTE_FLAGS) { + zend_throw_error(NULL, "Invalid attribute flags specified"); + return 0; } - zval_ptr_dtor(&flags); + return flags_l; } + + return ZEND_ATTRIBUTE_TARGET_ALL; } static void validate_allow_dynamic_properties( @@ -210,6 +214,137 @@ ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, u return SUCCESS; } +static zend_result call_attribute_constructor( + zend_attribute *attr, zend_class_entry *ce, zend_object *obj, + zval *args, uint32_t argc, HashTable *named_params, zend_string *filename) +{ + zend_function *ctor = ce->constructor; + zend_execute_data *call = NULL; + ZEND_ASSERT(ctor != NULL); + + if (!(ctor->common.fn_flags & ZEND_ACC_PUBLIC)) { + zend_throw_error(NULL, "Attribute constructor of class %s must be public", ZSTR_VAL(ce->name)); + return FAILURE; + } + + if (filename) { + /* Set up dummy call frame that makes it look like the attribute was invoked + * from where it occurs in the code. */ + zend_function dummy_func; + zend_op *opline; + + memset(&dummy_func, 0, sizeof(zend_function)); + + call = zend_vm_stack_push_call_frame_ex( + ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_execute_data), sizeof(zval)) + + ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_op), sizeof(zval)) + + ZEND_MM_ALIGNED_SIZE_EX(sizeof(zend_function), sizeof(zval)), + 0, &dummy_func, 0, NULL); + + opline = (zend_op*)(call + 1); + memset(opline, 0, sizeof(zend_op)); + opline->opcode = ZEND_DO_FCALL; + opline->lineno = attr->lineno; + + call->opline = opline; + call->call = NULL; + call->return_value = NULL; + call->func = (zend_function*)(call->opline + 1); + call->prev_execute_data = EG(current_execute_data); + + memset(call->func, 0, sizeof(zend_function)); + call->func->type = ZEND_USER_FUNCTION; + call->func->op_array.fn_flags = + attr->flags & ZEND_ATTRIBUTE_STRICT_TYPES ? ZEND_ACC_STRICT_TYPES : 0; + call->func->op_array.fn_flags |= ZEND_ACC_CALL_VIA_TRAMPOLINE; + call->func->op_array.filename = filename; + + EG(current_execute_data) = call; + } + + zend_call_known_function(ctor, obj, obj->ce, NULL, argc, args, named_params); + + if (filename) { + EG(current_execute_data) = call->prev_execute_data; + zend_vm_stack_free_call_frame(call); + } + + if (EG(exception)) { + zend_object_store_ctor_failed(obj); + return FAILURE; + } + + return SUCCESS; +} + +static void attribute_ctor_cleanup(zval *obj, zval *args, uint32_t argc, HashTable *named_params) +{ + if (obj) { + zval_ptr_dtor(obj); + } + + if (args) { + uint32_t i; + + for (i = 0; i < argc; i++) { + zval_ptr_dtor(&args[i]); + } + + efree(args); + } + + if (named_params) { + zend_array_destroy(named_params); + } +} + +ZEND_API zend_result zend_get_attribute_object(zval *obj, zend_class_entry *attribute_ce, zend_attribute *attribute_data, zend_class_entry *scope, zend_string *filename) +{ + zval *args = NULL; + HashTable *named_params = NULL; + + if (SUCCESS != object_init_ex(obj, attribute_ce)) { + return FAILURE; + } + + uint32_t argc = 0; + if (attribute_data->argc) { + args = emalloc(attribute_data->argc * sizeof(zval)); + + for (uint32_t i = 0; i < attribute_data->argc; i++) { + zval val; + if (FAILURE == zend_get_attribute_value(&val, attribute_data, i, scope)) { + attribute_ctor_cleanup(obj, args, argc, named_params); + return FAILURE; + } + if (attribute_data->args[i].name) { + if (!named_params) { + named_params = zend_new_array(0); + } + zend_hash_add_new(named_params, attribute_data->args[i].name, &val); + } else { + ZVAL_COPY_VALUE(&args[i], &val); + argc++; + } + } + } + + if (attribute_ce->constructor) { + if (FAILURE == call_attribute_constructor(attribute_data, attribute_ce, Z_OBJ_P(obj), args, argc, named_params, filename)) { + attribute_ctor_cleanup(obj, args, argc, named_params); + return FAILURE; + } + } else if (argc || named_params) { + attribute_ctor_cleanup(obj, args, argc, named_params); + zend_throw_error(NULL, "Attribute class %s does not have a constructor, cannot pass arguments", ZSTR_VAL(attribute_ce->name)); + return FAILURE; + } + + attribute_ctor_cleanup(NULL, args, argc, named_params); + + return SUCCESS; +} + static const char *target_names[] = { "class", "function", @@ -359,7 +494,6 @@ void zend_register_attribute_ce(void) zend_ce_attribute = register_class_Attribute(); attr = zend_mark_internal_attribute(zend_ce_attribute); - attr->validator = validate_attribute; zend_ce_return_type_will_change_attribute = register_class_ReturnTypeWillChange(); zend_mark_internal_attribute(zend_ce_return_type_will_change_attribute); diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index f8635aae1d3fa..20a868191c6a4 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -74,6 +74,7 @@ ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zen ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset); ZEND_API zend_result zend_get_attribute_value(zval *ret, zend_attribute *attr, uint32_t i, zend_class_entry *scope); +ZEND_API zend_result zend_get_attribute_object(zval *out, zend_class_entry *attribute_ce, zend_attribute *attribute_data, zend_class_entry *scope, zend_string *filename); ZEND_API zend_string *zend_get_attribute_target_names(uint32_t targets); ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr); @@ -86,6 +87,8 @@ ZEND_API zend_attribute *zend_add_attribute( HashTable **attributes, zend_string *name, uint32_t argc, uint32_t flags, uint32_t offset, uint32_t lineno); +uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope); + END_EXTERN_C() static zend_always_inline zend_attribute *zend_add_class_attribute(zend_class_entry *ce, zend_string *name, uint32_t argc) diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index c92f507a1b2a5..c09331998e36a 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -1152,7 +1152,7 @@ ZEND_FUNCTION(class_alias) if (zend_register_class_alias_ex(ZSTR_VAL(alias_name), ZSTR_LEN(alias_name), ce, false) == SUCCESS) { RETURN_TRUE; } else { - zend_error(E_WARNING, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(alias_name)); + zend_class_redeclaration_error_ex(E_WARNING, alias_name, ce); RETURN_FALSE; } } else { @@ -1650,7 +1650,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (is_sensitive) { zval redacted_arg; object_init_ex(&redacted_arg, zend_ce_sensitive_parameter_value); - zend_call_method_with_1_params(Z_OBJ_P(&redacted_arg), zend_ce_sensitive_parameter_value, &zend_ce_sensitive_parameter_value->constructor, "__construct", NULL, &original_arg); + zend_call_known_function(Z_OBJCE_P(&redacted_arg)->constructor, Z_OBJ_P(&redacted_arg), Z_OBJCE_P(&redacted_arg), NULL, 1, &original_arg, NULL); ZEND_HASH_FILL_SET(&redacted_arg); } else { Z_TRY_ADDREF_P(&original_arg); @@ -1682,7 +1682,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (is_sensitive) { zval redacted_arg; object_init_ex(&redacted_arg, zend_ce_sensitive_parameter_value); - zend_call_method_with_1_params(Z_OBJ_P(&redacted_arg), zend_ce_sensitive_parameter_value, &zend_ce_sensitive_parameter_value->constructor, "__construct", NULL, &original_arg); + zend_call_known_function(Z_OBJCE_P(&redacted_arg)->constructor, Z_OBJ_P(&redacted_arg), Z_OBJCE_P(&redacted_arg), NULL, 1, &original_arg, NULL); ZEND_HASH_FILL_SET(&redacted_arg); } else { Z_TRY_ADDREF_P(&original_arg); @@ -1722,7 +1722,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / if (is_sensitive) { zval redacted_arg; object_init_ex(&redacted_arg, zend_ce_sensitive_parameter_value); - zend_call_method_with_1_params(Z_OBJ_P(&redacted_arg), zend_ce_sensitive_parameter_value, &zend_ce_sensitive_parameter_value->constructor, "__construct", NULL, &original_arg); + zend_call_known_function(Z_OBJCE_P(&redacted_arg)->constructor, Z_OBJ_P(&redacted_arg), Z_OBJCE_P(&redacted_arg), NULL, 1, &original_arg, NULL); ZEND_HASH_FILL_SET(&redacted_arg); } else { Z_TRY_ADDREF_P(&original_arg); diff --git a/Zend/zend_call_stack.c b/Zend/zend_call_stack.c index 97e851012c8e9..cc10a2aa3090e 100644 --- a/Zend/zend_call_stack.c +++ b/Zend/zend_call_stack.c @@ -694,7 +694,7 @@ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) struct rlimit rlim; char path[PATH_MAX]; size_t size; - ssize_t len; + ssize_t len = -1; pid_t pid; int error, fd; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 3cbb0c4f7a1ed..cee7ec4361d69 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -313,9 +313,11 @@ static bool zend_is_not_imported(zend_string *name) { return !FC(imports) || zend_hash_find_ptr_lc(FC(imports), name) == NULL; } -void zend_oparray_context_begin(zend_oparray_context *prev_context) /* {{{ */ +void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_array *op_array) /* {{{ */ { *prev_context = CG(context); + CG(context).prev = CG(context).op_array ? prev_context : NULL; + CG(context).op_array = op_array; CG(context).opcodes_size = INITIAL_OP_ARRAY_SIZE; CG(context).vars_size = 0; CG(context).literals_size = 0; @@ -1217,12 +1219,12 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zen old_function = (zend_function*)Z_PTR_P(zv); if (old_function->type == ZEND_USER_FUNCTION && old_function->op_array.last > 0) { - zend_error_noreturn(error_level, "Cannot redeclare %s() (previously declared in %s:%d)", + zend_error_noreturn(error_level, "Cannot redeclare function %s() (previously declared in %s:%d)", op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name), ZSTR_VAL(old_function->op_array.filename), old_function->op_array.opcodes[0].lineno); } else { - zend_error_noreturn(error_level, "Cannot redeclare %s()", + zend_error_noreturn(error_level, "Cannot redeclare function %s()", op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name)); } } @@ -1260,7 +1262,9 @@ ZEND_API zend_class_entry *zend_bind_class_in_slot( success = zend_hash_add_ptr(EG(class_table), Z_STR_P(lcname), ce) != NULL; } if (UNEXPECTED(!success)) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(ce->name)); + zend_class_entry *old_class = zend_hash_find_ptr(EG(class_table), Z_STR_P(lcname)); + ZEND_ASSERT(old_class); + zend_class_redeclaration_error(E_COMPILE_ERROR, old_class); return NULL; } @@ -1298,7 +1302,7 @@ ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /* if (UNEXPECTED(!zv)) { ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(lcname)); ZEND_ASSERT(ce); - zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(ce->name)); + zend_class_redeclaration_error(E_COMPILE_ERROR, ce); return FAILURE; } @@ -2918,11 +2922,21 @@ static bool is_global_var_fetch(zend_ast *ast) static bool this_guaranteed_exists(void) /* {{{ */ { - zend_op_array *op_array = CG(active_op_array); - /* Instance methods always have a $this. - * This also includes closures that have a scope and use $this. */ - return op_array->scope != NULL - && (op_array->fn_flags & ZEND_ACC_STATIC) == 0; + zend_oparray_context *ctx = &CG(context); + while (ctx) { + /* Instance methods always have a $this. + * This also includes closures that have a scope and use $this. */ + zend_op_array *op_array = ctx->op_array; + if (op_array->fn_flags & ZEND_ACC_STATIC) { + return false; + } else if (op_array->scope) { + return true; + } else if (!(op_array->fn_flags & ZEND_ACC_CLOSURE)) { + return false; + } + ctx = ctx->prev; + } + return false; } /* }}} */ @@ -7752,8 +7766,8 @@ static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_string *import_name = zend_hash_find_ptr_lc(FC(imports_function), unqualified_name); if (import_name && !zend_string_equals_ci(lcname, import_name)) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare function %s " - "because the name is already in use", ZSTR_VAL(name)); + zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare function %s() (previously declared as local import)", + ZSTR_VAL(name)); } } @@ -7867,7 +7881,7 @@ static void zend_compile_func_decl(znode *result, zend_ast *ast, bool toplevel) op_array->fn_flags |= ZEND_ACC_TOP_LEVEL; } - zend_oparray_context_begin(&orig_oparray_context); + zend_oparray_context_begin(&orig_oparray_context, op_array); { /* Push a separator to the loop variable stack */ @@ -8318,8 +8332,8 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel) zend_string *import_name = zend_hash_find_ptr_lc(FC(imports), unqualified_name); if (import_name && !zend_string_equals_ci(lcname, import_name)) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare class %s " - "because the name is already in use", ZSTR_VAL(name)); + zend_error_noreturn(E_COMPILE_ERROR, "Cannot redeclare class %s " + "(previously declared as local import)", ZSTR_VAL(name)); } } diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 8efc57163da86..6a5626492ec73 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -190,6 +190,8 @@ typedef struct _zend_live_range { /* Compilation context that is different for each op array. */ typedef struct _zend_oparray_context { + struct _zend_oparray_context *prev; + zend_op_array *op_array; uint32_t opcodes_size; int vars_size; int literals_size; @@ -802,7 +804,7 @@ void init_compiler(void); void shutdown_compiler(void); void zend_init_compiler_data_structures(void); -void zend_oparray_context_begin(zend_oparray_context *prev_context); +void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_array *op_array); void zend_oparray_context_end(zend_oparray_context *prev_context); void zend_file_context_begin(zend_file_context *prev_context); void zend_file_context_end(zend_file_context *prev_context); diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 491d68714b3c2..137c17ee428cd 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -97,7 +97,7 @@ static zend_function *zend_duplicate_internal_function(zend_function *func, zend zend_function *new_function; if (UNEXPECTED(ce->type & ZEND_INTERNAL_CLASS)) { - new_function = pemalloc(sizeof(zend_internal_function), 1); + new_function = (zend_function *)pemalloc(sizeof(zend_internal_function), 1); memcpy(new_function, func, sizeof(zend_internal_function)); } else { new_function = zend_arena_alloc(&CG(arena), sizeof(zend_internal_function)); @@ -1078,31 +1078,45 @@ static void perform_delayable_implementation_check( } } -/** - * @param check_only Set to false to throw compile errors on incompatible methods, or true to return INHERITANCE_ERROR. - * @param checked Whether the compatibility check has already succeeded in zend_can_early_bind(). - * @param force_mutable Whether we know that child may be modified, i.e. doesn't live in shm. - */ -static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( +#define ZEND_INHERITANCE_LAZY_CHILD_CLONE (1<<0) +#define ZEND_INHERITANCE_CHECK_SILENT (1<<1) /* don't throw errors */ +#define ZEND_INHERITANCE_CHECK_PROTO (1<<2) /* check method prototype (it might be already checked before) */ +#define ZEND_INHERITANCE_CHECK_VISIBILITY (1<<3) +#define ZEND_INHERITANCE_SET_CHILD_CHANGED (1<<4) +#define ZEND_INHERITANCE_SET_CHILD_PROTO (1<<5) +#define ZEND_INHERITANCE_RESET_CHILD_OVERRIDE (1<<6) + +static inheritance_status do_inheritance_check_on_method( zend_function *child, zend_class_entry *child_scope, zend_function *parent, zend_class_entry *parent_scope, - zend_class_entry *ce, zval *child_zv, - bool check_visibility, bool check_only, bool checked, bool force_mutable) /* {{{ */ + zend_class_entry *ce, zval *child_zv, uint32_t flags) /* {{{ */ { uint32_t child_flags; uint32_t parent_flags = parent->common.fn_flags; zend_function *proto; - if (UNEXPECTED((parent_flags & ZEND_ACC_PRIVATE) && !(parent_flags & ZEND_ACC_ABSTRACT) && !(parent_flags & ZEND_ACC_CTOR))) { - if (!check_only) { +#define SEPARATE_METHOD() do { \ + if ((flags & ZEND_INHERITANCE_LAZY_CHILD_CLONE) \ + && child_scope != ce && child->type == ZEND_USER_FUNCTION) { \ + /* op_array wasn't duplicated yet */ \ + zend_function *new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array)); \ + memcpy(new_function, child, sizeof(zend_op_array)); \ + Z_PTR_P(child_zv) = child = new_function; \ + flags &= ~ZEND_INHERITANCE_LAZY_CHILD_CLONE; \ + } \ + } while(0) + + if (UNEXPECTED((parent_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_ABSTRACT|ZEND_ACC_CTOR)) == ZEND_ACC_PRIVATE)) { + if (flags & ZEND_INHERITANCE_SET_CHILD_CHANGED) { + SEPARATE_METHOD(); child->common.fn_flags |= ZEND_ACC_CHANGED; } /* The parent method is private and not an abstract so we don't need to check any inheritance rules */ return INHERITANCE_SUCCESS; } - if (!checked && UNEXPECTED(parent_flags & ZEND_ACC_FINAL)) { - if (check_only) { + if ((flags & ZEND_INHERITANCE_CHECK_PROTO) && UNEXPECTED(parent_flags & ZEND_ACC_FINAL)) { + if (flags & ZEND_INHERITANCE_CHECK_SILENT) { return INHERITANCE_ERROR; } zend_error_at_noreturn(E_COMPILE_ERROR, func_filename(child), func_lineno(child), @@ -1113,8 +1127,9 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( child_flags = child->common.fn_flags; /* You cannot change from static to non static and vice versa. */ - if (!checked && UNEXPECTED((child_flags & ZEND_ACC_STATIC) != (parent_flags & ZEND_ACC_STATIC))) { - if (check_only) { + if ((flags & ZEND_INHERITANCE_CHECK_PROTO) + && UNEXPECTED((child_flags & ZEND_ACC_STATIC) != (parent_flags & ZEND_ACC_STATIC))) { + if (flags & ZEND_INHERITANCE_CHECK_SILENT) { return INHERITANCE_ERROR; } if (child_flags & ZEND_ACC_STATIC) { @@ -1129,8 +1144,9 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( } /* Disallow making an inherited method abstract. */ - if (!checked && UNEXPECTED((child_flags & ZEND_ACC_ABSTRACT) > (parent_flags & ZEND_ACC_ABSTRACT))) { - if (check_only) { + if ((flags & ZEND_INHERITANCE_CHECK_PROTO) + && UNEXPECTED((child_flags & ZEND_ACC_ABSTRACT) > (parent_flags & ZEND_ACC_ABSTRACT))) { + if (flags & ZEND_INHERITANCE_CHECK_SILENT) { return INHERITANCE_ERROR; } zend_error_at_noreturn(E_COMPILE_ERROR, func_filename(child), func_lineno(child), @@ -1138,7 +1154,9 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( ZEND_FN_SCOPE_NAME(parent), ZSTR_VAL(child->common.function_name), ZEND_FN_SCOPE_NAME(child)); } - if (!check_only && (parent_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_CHANGED))) { + if ((flags & ZEND_INHERITANCE_SET_CHILD_CHANGED) + && (parent_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_CHANGED))) { + SEPARATE_METHOD(); child->common.fn_flags |= ZEND_ACC_CHANGED; } @@ -1154,27 +1172,16 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( parent = proto; } - if (!check_only && child->common.prototype != proto && child_zv) { - do { - if (child->common.scope != ce && child->type == ZEND_USER_FUNCTION) { - if (ce->ce_flags & ZEND_ACC_INTERFACE) { - /* Few parent interfaces contain the same method */ - break; - } else { - /* op_array wasn't duplicated yet */ - zend_function *new_function = zend_arena_alloc(&CG(arena), sizeof(zend_op_array)); - memcpy(new_function, child, sizeof(zend_op_array)); - Z_PTR_P(child_zv) = child = new_function; - } - } - child->common.prototype = proto; - } while (0); + if ((flags & ZEND_INHERITANCE_SET_CHILD_PROTO) + && child->common.prototype != proto) { + SEPARATE_METHOD(); + child->common.prototype = proto; } /* Prevent derived classes from restricting access that was available in parent classes (except deriving from non-abstract ctors) */ - if (!checked && check_visibility + if ((flags & ZEND_INHERITANCE_CHECK_VISIBILITY) && (child_flags & ZEND_ACC_PPP_MASK) > (parent_flags & ZEND_ACC_PPP_MASK)) { - if (check_only) { + if (flags & ZEND_INHERITANCE_CHECK_SILENT) { return INHERITANCE_ERROR; } zend_error_at_noreturn(E_COMPILE_ERROR, func_filename(child), func_lineno(child), @@ -1182,30 +1189,26 @@ static zend_always_inline inheritance_status do_inheritance_check_on_method_ex( ZEND_FN_SCOPE_NAME(child), ZSTR_VAL(child->common.function_name), zend_visibility_string(parent_flags), ZEND_FN_SCOPE_NAME(parent), (parent_flags&ZEND_ACC_PUBLIC) ? "" : " or weaker"); } - if (!checked) { - if (check_only) { + if (flags & ZEND_INHERITANCE_CHECK_PROTO) { + if (flags & ZEND_INHERITANCE_CHECK_SILENT) { return zend_do_perform_implementation_check(child, child_scope, parent, parent_scope); } perform_delayable_implementation_check(ce, child, child_scope, parent, parent_scope); } - if (!check_only && (child->common.scope == ce || force_mutable)) { + if ((flags & ZEND_INHERITANCE_RESET_CHILD_OVERRIDE) + && (child->common.fn_flags & ZEND_ACC_OVERRIDE)) { + SEPARATE_METHOD(); child->common.fn_flags &= ~ZEND_ACC_OVERRIDE; } +#undef SEPARATE_METHOD + return INHERITANCE_SUCCESS; } /* }}} */ -static zend_never_inline void do_inheritance_check_on_method( - zend_function *child, zend_class_entry *child_scope, - zend_function *parent, zend_class_entry *parent_scope, - zend_class_entry *ce, zval *child_zv, bool check_visibility) -{ - do_inheritance_check_on_method_ex(child, child_scope, parent, parent_scope, ce, child_zv, check_visibility, 0, 0, /* force_mutable */ false); -} - -static zend_always_inline void do_inherit_method(zend_string *key, zend_function *parent, zend_class_entry *ce, bool is_interface, bool checked) /* {{{ */ +static void do_inherit_method(zend_string *key, zend_function *parent, zend_class_entry *ce, bool is_interface, uint32_t flags) /* {{{ */ { zval *child = zend_hash_find_known_hash(&ce->function_table, key); @@ -1217,15 +1220,8 @@ static zend_always_inline void do_inherit_method(zend_string *key, zend_function return; } - if (checked) { - do_inheritance_check_on_method_ex( - func, func->common.scope, parent, parent->common.scope, ce, child, - /* check_visibility */ 1, 0, checked, /* force_mutable */ false); - } else { - do_inheritance_check_on_method( - func, func->common.scope, parent, parent->common.scope, ce, child, - /* check_visibility */ 1); - } + do_inheritance_check_on_method( + func, func->common.scope, parent, parent->common.scope, ce, child, flags); } else { if (is_interface || (parent->common.fn_flags & (ZEND_ACC_ABSTRACT))) { @@ -1652,16 +1648,18 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par zend_hash_extend(&ce->function_table, zend_hash_num_elements(&ce->function_table) + zend_hash_num_elements(&parent_ce->function_table), 0); + uint32_t flags = + ZEND_INHERITANCE_LAZY_CHILD_CLONE | + ZEND_INHERITANCE_SET_CHILD_CHANGED | + ZEND_INHERITANCE_SET_CHILD_PROTO | + ZEND_INHERITANCE_RESET_CHILD_OVERRIDE; - if (checked) { - ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, func) { - do_inherit_method(key, func, ce, 0, 1); - } ZEND_HASH_FOREACH_END(); - } else { - ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, func) { - do_inherit_method(key, func, ce, 0, 0); - } ZEND_HASH_FOREACH_END(); + if (!checked) { + flags |= ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY; } + ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, func) { + do_inherit_method(key, func, ce, 0, flags); + } ZEND_HASH_FOREACH_END(); } do_inherit_parent_constructor(ce); @@ -1793,13 +1791,27 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry * zend_function *func; zend_string *key; zend_class_constant *c; + uint32_t flags = ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY; + + if (!(ce->ce_flags & ZEND_ACC_INTERFACE)) { + /* We are not setting the prototype of overridden interface methods because of abstract + * constructors. See Zend/tests/interface_constructor_prototype_001.phpt. */ + flags |= + ZEND_INHERITANCE_LAZY_CHILD_CLONE | + ZEND_INHERITANCE_SET_CHILD_PROTO | + ZEND_INHERITANCE_RESET_CHILD_OVERRIDE; + } else { + flags |= + ZEND_INHERITANCE_LAZY_CHILD_CLONE | + ZEND_INHERITANCE_RESET_CHILD_OVERRIDE; + } ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&iface->constants_table, key, c) { do_inherit_iface_constant(key, c, ce, iface); } ZEND_HASH_FOREACH_END(); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&iface->function_table, key, func) { - do_inherit_method(key, func, ce, 1, 0); + do_inherit_method(key, func, ce, 1, flags); } ZEND_HASH_FOREACH_END(); do_implement_interface(ce, iface); @@ -1970,7 +1982,7 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_ */ do_inheritance_check_on_method( existing_fn, fixup_trait_scope(existing_fn, ce), fn, fixup_trait_scope(fn, ce), - ce, NULL, /* check_visibility */ 0); + ce, NULL, ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_RESET_CHILD_OVERRIDE); return; } @@ -2009,9 +2021,12 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_ if (check_inheritance) { /* Inherited members are overridden by members inserted by traits. * Check whether the trait method fulfills the inheritance requirements. */ - do_inheritance_check_on_method_ex( + do_inheritance_check_on_method( fn, fixup_trait_scope(fn, ce), existing_fn, fixup_trait_scope(existing_fn, ce), - ce, NULL, /* check_visibility */ 1, false, false, /* force_mutable */ true); + ce, NULL, + ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY | + ZEND_INHERITANCE_SET_CHILD_CHANGED| ZEND_INHERITANCE_SET_CHILD_PROTO | + ZEND_INHERITANCE_RESET_CHILD_OVERRIDE); } } /* }}} */ @@ -3264,10 +3279,11 @@ static inheritance_status zend_can_early_bind(zend_class_entry *ce, zend_class_e if (zv) { zend_function *child_func = Z_FUNC_P(zv); inheritance_status status = - do_inheritance_check_on_method_ex( + do_inheritance_check_on_method( child_func, child_func->common.scope, parent_func, parent_func->common.scope, - ce, NULL, /* check_visibility */ 1, 1, 0, /* force_mutable */ false); + ce, NULL, + ZEND_INHERITANCE_CHECK_SILENT | ZEND_INHERITANCE_CHECK_PROTO | ZEND_INHERITANCE_CHECK_VISIBILITY); if (UNEXPECTED(status == INHERITANCE_WARNING)) { overall_status = INHERITANCE_WARNING; } else if (UNEXPECTED(status != INHERITANCE_SUCCESS)) { @@ -3331,7 +3347,9 @@ static zend_always_inline bool register_early_bound_ce(zval *delayed_early_bindi return true; } } - zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare %s %s, because the name is already in use", zend_get_object_type(ce), ZSTR_VAL(ce->name)); + zend_class_entry *old_ce = zend_hash_find_ptr(EG(class_table), lcname); + ZEND_ASSERT(old_ce); + zend_class_redeclaration_error(E_COMPILE_ERROR, old_ce); return false; } if (zend_hash_add_ptr(CG(class_table), lcname, ce) != NULL) { diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 054ed7bdc1ef6..ae7e91629db72 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -614,7 +614,7 @@ static zend_op_array *zend_compile(int type) } zend_file_context_begin(&original_file_context); - zend_oparray_context_begin(&original_oparray_context); + zend_oparray_context_begin(&original_oparray_context, op_array); zend_compile_top_stmt(CG(ast)); CG(zend_lineno) = last_lineno; zend_emit_final_return(type == ZEND_USER_FUNCTION); diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 8853d24549fb2..890c19c0ab223 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -122,7 +122,7 @@ static _locale_t current_locale = NULL; #define BLOCKCONV_LOAD(input) \ int8x16_t blconv_operand = vld1q_s8((const int8_t*)(input)); \ - uint8x16_t blconv_mask = vcltq_s8(vaddq_s8(blconv_operand, blconv_offset), blconv_threshold); + uint8x16_t blconv_mask = vcltq_s8(vreinterpretq_s8_u8(vaddq_u8(vreinterpretq_u8_s8(blconv_operand), vreinterpretq_u8_s8(blconv_offset))), blconv_threshold); #define BLOCKCONV_FOUND() vmaxvq_u8(blconv_mask) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index 0dd4e6487a056..af7dcf68ccd7b 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -141,7 +141,7 @@ #if defined(HAVE_LIBDL) && !defined(ZEND_WIN32) -# if __has_feature(address_sanitizer) +# if __has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__) # define __SANITIZE_ADDRESS__ # endif diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 910e2eed250fe..2be7e7d267224 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -424,7 +424,7 @@ static zend_always_inline bool zend_string_starts_with_ci(const zend_string *str } #define zend_string_starts_with_literal_ci(str, prefix) \ - zend_string_starts_with_cstr(str, prefix, strlen(prefix)) + zend_string_starts_with_cstr_ci(str, prefix, strlen(prefix)) /* * DJBX33A (Daniel J. Bernstein, Times 33 with Addition) diff --git a/build/ax_check_compile_flag.m4 b/build/ax_check_compile_flag.m4 index bd753b34d7dc5..68fd43d5ddb09 100644 --- a/build/ax_check_compile_flag.m4 +++ b/build/ax_check_compile_flag.m4 @@ -34,12 +34,12 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 6 +#serial 7 AC_DEFUN([AX_CHECK_COMPILE_FLAG], [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl -AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ +AC_CACHE_CHECK([whether the _AC_LANG compiler accepts $1], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], diff --git a/build/gen_stub.php b/build/gen_stub.php index 657b630c6bf40..2edc7fc10450a 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2584,7 +2584,7 @@ protected function getFieldSynopsisDefaultLinkend(): string { $className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString()); - return "$className.constants." . strtolower(str_replace("_", "-", $this->name->getDeclarationName())); + return "$className.constants." . strtolower(str_replace(["__", "_"], ["", "-"], $this->name->getDeclarationName())); } protected function getFieldSynopsisName(): string @@ -2919,7 +2919,7 @@ protected function getFieldSynopsisDefaultLinkend(): string { $className = str_replace(["\\", "_"], ["-", "-"], $this->name->class->toLowerString()); - return "$className.props." . strtolower(str_replace("_", "-", $this->name->getDeclarationName())); + return "$className.props." . strtolower(str_replace(["__", "_"], ["", "-"], $this->name->getDeclarationName())); } protected function getFieldSynopsisName(): string diff --git a/build/php.m4 b/build/php.m4 index 767040bab71c7..e8794a36335aa 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1819,9 +1819,8 @@ AC_DEFUN([PHP_SETUP_ICU],[ ICU_CFLAGS="$ICU_CFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit" - if test "$PKG_CONFIG icu-io --atleast-version=60"; then - ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1" - fi + AS_IF([$PKG_CONFIG icu-io --atleast-version=60], + [ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"]) ]) dnl @@ -2744,3 +2743,33 @@ AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [ AC_DEFINE_UNQUOTED([PHP_HAVE_AVX512_VBMI_SUPPORTS], [$have_avx512_vbmi_supports], [Whether the compiler supports AVX512 VBMI]) ]) + +dnl +dnl PHP_CHECK_VARIABLE_ATTRIBUTE(attribute) +dnl +dnl Check whether the compiler supports the GNU C variable attribute. +dnl +AC_DEFUN([PHP_CHECK_VARIABLE_ATTRIBUTE], +[AS_VAR_PUSHDEF([php_var], [php_cv_have_variable_attribute_$1]) +AC_CACHE_CHECK([for variable __attribute__(($1))], [php_var], +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([m4_case([$1], + [aligned], + [unsigned char test[32] __attribute__(($1(__alignof__(int))));], + [ + m4_warn([syntax], [Unsupported variable attribute $1, the test may fail]) + int var __attribute__(($1)); + ])], + [])], +dnl By default, compilers may not classify attribute warnings as errors +dnl (-Werror=attributes) when encountering an unknown attribute. Accept the +dnl attribute only if no warnings were generated. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([php_var], [no])], + [AS_VAR_SET([php_var], [yes])])], + [AS_VAR_SET([php_var], [no])]) +]) +AS_VAR_IF([php_var], [yes], + [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_ATTRIBUTE_$1]), [1], + [Define to 1 if the compiler supports the '$1' variable attribute.])]) +AS_VAR_POPDEF([php_var]) +]) diff --git a/configure.ac b/configure.ac index f2cb130c63f37..e640f39265f12 100644 --- a/configure.ac +++ b/configure.ac @@ -356,16 +356,17 @@ test -d /usr/ucblib && PHP_ADD_LIBPATH(/usr/ucblib) dnl First, library checks. dnl ---------------------------------------------------------------------------- -dnl Some systems (OpenServer 5) dislike -lsocket -lnsl, so we try to avoid -lnsl -dnl checks, if we already have the functions which are usually in libnsl. Also, -dnl uClibc will bark at linking with glibc's libnsl. - AC_SEARCH_LIBS([socket], [socket network]) -PHP_CHECK_FUNC(socketpair, socket, network) -PHP_CHECK_FUNC(gethostname, nsl, network) -PHP_CHECK_FUNC(gethostbyaddr, nsl, network) + +AC_CHECK_FUNCS([socketpair],, + [AC_SEARCH_LIBS([socketpair], [socket network], + [AC_DEFINE([HAVE_SOCKETPAIR], [1])])]) + +AC_SEARCH_LIBS([gethostbyaddr], [nsl network]) + AC_SEARCH_LIBS([dlopen], [dl], [AC_DEFINE([HAVE_LIBDL], [1], [Define to 1 if the dl library is available.])]) + AC_SEARCH_LIBS([sin], [m]) case $host_alias in @@ -530,6 +531,7 @@ AC_CACHE_CHECK(whether the compiler supports __alignof__, ac_cv_alignof_exists,[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]],[[ int align = __alignof__(int); + (void)align; ]])],[ ac_cv_alignof_exists=yes ],[ @@ -566,11 +568,21 @@ AS_CASE([$host_alias], [*-*-*android*|*-*-*uclibc*|*-*-*musl*|*openbsd*], [true] fi ]) +dnl Check for __attribute__ ((__aligned__)) support in the compiler. +PHP_CHECK_VARIABLE_ATTRIBUTE([aligned]) + dnl Check for IPv6 support. AC_CACHE_CHECK([for IPv6 support], ac_cv_ipv6_support, [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include #include -#include ]], [[struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;]])], +#include ]], [[ + struct sockaddr_in6 s; + struct in6_addr t = in6addr_any; + int i = AF_INET6; + (void)s; + t.s6_addr[0] = 0; + (void)i; +]])], [ac_cv_ipv6_support=yes], [ac_cv_ipv6_support=no])]) dnl Checks for library functions. @@ -588,6 +600,7 @@ ftok \ funopen \ gai_strerror \ getcwd \ +gethostname \ getloadavg \ getlogin \ getprotobyname \ diff --git a/docs/source/core/data-structures/reference-counting.rst b/docs/source/core/data-structures/reference-counting.rst index 77432f249967f..6895d5d682a80 100644 --- a/docs/source/core/data-structures/reference-counting.rst +++ b/docs/source/core/data-structures/reference-counting.rst @@ -223,6 +223,6 @@ own allocator. Usually, such values are alive for the entire lifetime of the pro being freed at the end of the request. See the `Zend allocator `_ chapter for more information. -The ``GC_PERSISTENT_LOCAL`` flag indicates that a ``CG_PERSISTENT`` value is only accessibly in one +The ``GC_PERSISTENT_LOCAL`` flag indicates that a ``GC_PERSISTENT`` value is only accessible in one thread, and is thus still safe to modify. This flag is only used in debug builds to satisfy an ``assert``. diff --git a/ext/bcmath/bcmath.c b/ext/bcmath/bcmath.c index f53032fabc35c..0258c0cd3a534 100644 --- a/ext/bcmath/bcmath.c +++ b/ext/bcmath/bcmath.c @@ -29,6 +29,16 @@ #include "php_bcmath.h" #include "libbcmath/src/bcmath.h" +/* Always pair SETUP with TEARDOWN, and do so in the outer scope! + * Should not be used when data can escape the function. */ +#define BC_ARENA_SETUP \ + char bc_arena[BC_ARENA_SIZE]; \ + BCG(arena) = bc_arena; + +#define BC_ARENA_TEARDOWN \ + BCG(arena) = NULL; \ + BCG(arena_offset) = 0; + ZEND_DECLARE_MODULE_GLOBALS(bcmath) static PHP_GINIT_FUNCTION(bcmath); static PHP_GSHUTDOWN_FUNCTION(bcmath); @@ -89,6 +99,8 @@ static PHP_GINIT_FUNCTION(bcmath) ZEND_TSRMLS_CACHE_UPDATE(); #endif bcmath_globals->bc_precision = 0; + bcmath_globals->arena = NULL; + bcmath_globals->arena_offset = 0; bc_init_numbers(); } /* }}} */ @@ -99,6 +111,8 @@ static PHP_GSHUTDOWN_FUNCTION(bcmath) _bc_free_num_ex(&bcmath_globals->_zero_, 1); _bc_free_num_ex(&bcmath_globals->_one_, 1); _bc_free_num_ex(&bcmath_globals->_two_, 1); + bcmath_globals->arena = NULL; + bcmath_globals->arena_offset = 0; } /* }}} */ @@ -132,19 +146,9 @@ PHP_MINFO_FUNCTION(bcmath) /* {{{ php_str2num Convert to bc_num detecting scale */ -static zend_result php_str2num(bc_num *num, char *str) +static zend_result php_str2num(bc_num *num, const zend_string *str) { - char *p; - - if (!(p = strchr(str, '.'))) { - if (!bc_str2num(num, str, 0)) { - return FAILURE; - } - - return SUCCESS; - } - - if (!bc_str2num(num, str, strlen(p+1))) { + if (!bc_str2num(num, ZSTR_VAL(str), ZSTR_VAL(str) + ZSTR_LEN(str), 0, true)) { return FAILURE; } @@ -158,7 +162,7 @@ PHP_FUNCTION(bcadd) zend_string *left, *right; zend_long scale_param; bool scale_param_is_null = 1; - bc_num first, second, result; + bc_num first = NULL, second = NULL, result = NULL; int scale; ZEND_PARSE_PARAMETERS_START(2, 3) @@ -177,28 +181,27 @@ PHP_FUNCTION(bcadd) scale = (int) scale_param; } - bc_init_num(&first); - bc_init_num(&second); - bc_init_num(&result); + BC_ARENA_SETUP; - if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) { + if (php_str2num(&first, left) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) { + if (php_str2num(&second, right) == FAILURE) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } - bc_add (first, second, &result, scale); + result = bc_add (first, second, scale); - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); cleanup: { bc_free_num(&first); bc_free_num(&second); bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -209,7 +212,7 @@ PHP_FUNCTION(bcsub) zend_string *left, *right; zend_long scale_param; bool scale_param_is_null = 1; - bc_num first, second, result; + bc_num first = NULL, second = NULL, result = NULL; int scale; ZEND_PARSE_PARAMETERS_START(2, 3) @@ -228,28 +231,27 @@ PHP_FUNCTION(bcsub) scale = (int) scale_param; } - bc_init_num(&first); - bc_init_num(&second); - bc_init_num(&result); + BC_ARENA_SETUP; - if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) { + if (php_str2num(&first, left) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) { + if (php_str2num(&second, right) == FAILURE) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } - bc_sub (first, second, &result, scale); + result = bc_sub (first, second, scale); - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); cleanup: { bc_free_num(&first); bc_free_num(&second); bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -260,7 +262,7 @@ PHP_FUNCTION(bcmul) zend_string *left, *right; zend_long scale_param; bool scale_param_is_null = 1; - bc_num first, second, result; + bc_num first = NULL, second = NULL, result = NULL; int scale; ZEND_PARSE_PARAMETERS_START(2, 3) @@ -279,28 +281,27 @@ PHP_FUNCTION(bcmul) scale = (int) scale_param; } - bc_init_num(&first); - bc_init_num(&second); - bc_init_num(&result); + BC_ARENA_SETUP; - if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) { + if (php_str2num(&first, left) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) { + if (php_str2num(&second, right) == FAILURE) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } - bc_multiply (first, second, &result, scale); + result = bc_multiply (first, second, scale); - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); cleanup: { bc_free_num(&first); bc_free_num(&second); bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -311,7 +312,7 @@ PHP_FUNCTION(bcdiv) zend_string *left, *right; zend_long scale_param; bool scale_param_is_null = 1; - bc_num first, second, result; + bc_num first = NULL, second = NULL, result; int scale = BCG(bc_precision); ZEND_PARSE_PARAMETERS_START(2, 3) @@ -330,16 +331,16 @@ PHP_FUNCTION(bcdiv) scale = (int) scale_param; } - bc_init_num(&first); - bc_init_num(&second); + BC_ARENA_SETUP; + bc_init_num(&result); - if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) { + if (php_str2num(&first, left) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) { + if (php_str2num(&second, right) == FAILURE) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } @@ -349,12 +350,13 @@ PHP_FUNCTION(bcdiv) goto cleanup; } - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); cleanup: { bc_free_num(&first); bc_free_num(&second); bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -365,7 +367,7 @@ PHP_FUNCTION(bcmod) zend_string *left, *right; zend_long scale_param; bool scale_param_is_null = 1; - bc_num first, second, result; + bc_num first = NULL, second = NULL, result; int scale = BCG(bc_precision); ZEND_PARSE_PARAMETERS_START(2, 3) @@ -384,16 +386,16 @@ PHP_FUNCTION(bcmod) scale = (int) scale_param; } - bc_init_num(&first); - bc_init_num(&second); + BC_ARENA_SETUP; + bc_init_num(&result); - if (php_str2num(&first, ZSTR_VAL(left)) == FAILURE) { + if (php_str2num(&first, left) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (php_str2num(&second, ZSTR_VAL(right)) == FAILURE) { + if (php_str2num(&second, right) == FAILURE) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } @@ -403,12 +405,13 @@ PHP_FUNCTION(bcmod) goto cleanup; } - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); cleanup: { bc_free_num(&first); bc_free_num(&second); bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -419,7 +422,7 @@ PHP_FUNCTION(bcpowmod) zend_string *base_str, *exponent_str, *modulus_str; zend_long scale_param; bool scale_param_is_null = 1; - bc_num bc_base, bc_expo, bc_modulus, result; + bc_num bc_base = NULL, bc_expo = NULL, bc_modulus = NULL, result; int scale = BCG(bc_precision); ZEND_PARSE_PARAMETERS_START(3, 4) @@ -439,22 +442,21 @@ PHP_FUNCTION(bcpowmod) scale = (int) scale_param; } - bc_init_num(&bc_base); - bc_init_num(&bc_expo); - bc_init_num(&bc_modulus); + BC_ARENA_SETUP; + bc_init_num(&result); - if (php_str2num(&bc_base, ZSTR_VAL(base_str)) == FAILURE) { + if (php_str2num(&bc_base, base_str) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (php_str2num(&bc_expo, ZSTR_VAL(exponent_str)) == FAILURE) { + if (php_str2num(&bc_expo, exponent_str) == FAILURE) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } - if (php_str2num(&bc_modulus, ZSTR_VAL(modulus_str)) == FAILURE) { + if (php_str2num(&bc_modulus, modulus_str) == FAILURE) { zend_argument_value_error(3, "is not well-formed"); goto cleanup; } @@ -477,7 +479,7 @@ PHP_FUNCTION(bcpowmod) zend_throw_exception_ex(zend_ce_division_by_zero_error, 0, "Modulo by zero"); goto cleanup; case OK: - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); break; EMPTY_SWITCH_DEFAULT_CASE(); } @@ -487,6 +489,7 @@ PHP_FUNCTION(bcpowmod) bc_free_num(&bc_expo); bc_free_num(&bc_modulus); bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -497,7 +500,7 @@ PHP_FUNCTION(bcpow) zend_string *base_str, *exponent_str; zend_long scale_param; bool scale_param_is_null = 1; - bc_num first, bc_exponent, result; + bc_num first = NULL, bc_exponent = NULL, result; int scale = BCG(bc_precision); ZEND_PARSE_PARAMETERS_START(2, 3) @@ -516,16 +519,16 @@ PHP_FUNCTION(bcpow) scale = (int) scale_param; } - bc_init_num(&first); - bc_init_num(&bc_exponent); + BC_ARENA_SETUP; + bc_init_num(&result); - if (php_str2num(&first, ZSTR_VAL(base_str)) == FAILURE) { + if (php_str2num(&first, base_str) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (php_str2num(&bc_exponent, ZSTR_VAL(exponent_str)) == FAILURE) { + if (php_str2num(&bc_exponent, exponent_str) == FAILURE) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } @@ -543,12 +546,13 @@ PHP_FUNCTION(bcpow) bc_raise(first, exponent, &result, scale); - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); cleanup: { bc_free_num(&first); bc_free_num(&bc_exponent); bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -559,7 +563,7 @@ PHP_FUNCTION(bcsqrt) zend_string *left; zend_long scale_param; bool scale_param_is_null = 1; - bc_num result; + bc_num result = NULL; int scale = BCG(bc_precision); ZEND_PARSE_PARAMETERS_START(1, 2) @@ -577,21 +581,22 @@ PHP_FUNCTION(bcsqrt) scale = (int) scale_param; } - bc_init_num(&result); + BC_ARENA_SETUP; - if (php_str2num(&result, ZSTR_VAL(left)) == FAILURE) { + if (php_str2num(&result, left) == FAILURE) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } if (bc_sqrt (&result, scale) != 0) { - RETVAL_STR(bc_num2str_ex(result, scale)); + RETVAL_NEW_STR(bc_num2str_ex(result, scale)); } else { zend_argument_value_error(1, "must be greater than or equal to 0"); } cleanup: { bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ @@ -602,7 +607,7 @@ PHP_FUNCTION(bccomp) zend_string *left, *right; zend_long scale_param; bool scale_param_is_null = 1; - bc_num first, second; + bc_num first = NULL, second = NULL; int scale = BCG(bc_precision); ZEND_PARSE_PARAMETERS_START(2, 3) @@ -621,15 +626,14 @@ PHP_FUNCTION(bccomp) scale = (int) scale_param; } - bc_init_num(&first); - bc_init_num(&second); + BC_ARENA_SETUP; - if (!bc_str2num(&first, ZSTR_VAL(left), scale)) { + if (!bc_str2num(&first, ZSTR_VAL(left), ZSTR_VAL(left) + ZSTR_LEN(left), scale, false)) { zend_argument_value_error(1, "is not well-formed"); goto cleanup; } - if (!bc_str2num(&second, ZSTR_VAL(right), scale)) { + if (!bc_str2num(&second, ZSTR_VAL(right), ZSTR_VAL(right) + ZSTR_LEN(right), scale, false)) { zend_argument_value_error(2, "is not well-formed"); goto cleanup; } @@ -639,6 +643,99 @@ PHP_FUNCTION(bccomp) cleanup: { bc_free_num(&first); bc_free_num(&second); + BC_ARENA_TEARDOWN; + }; +} +/* }}} */ + +/* {{{ floor or ceil */ +static void bcfloor_or_bcceil(INTERNAL_FUNCTION_PARAMETERS, bool is_floor) +{ + zend_string *numstr; + bc_num num = NULL, result = NULL; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(numstr) + ZEND_PARSE_PARAMETERS_END(); + + BC_ARENA_SETUP; + + if (php_str2num(&num, numstr) == FAILURE) { + zend_argument_value_error(1, "is not well-formed"); + goto cleanup; + } + + result = bc_floor_or_ceil(num, is_floor); + RETVAL_NEW_STR(bc_num2str_ex(result, 0)); + + cleanup: { + bc_free_num(&num); + bc_free_num(&result); + BC_ARENA_TEARDOWN; + }; +} +/* }}} */ + +/* {{{ Returns floor of num */ +PHP_FUNCTION(bcfloor) +{ + bcfloor_or_bcceil(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); +} +/* }}} */ + +/* {{{ Returns ceil of num */ +PHP_FUNCTION(bcceil) +{ + bcfloor_or_bcceil(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); +} +/* }}} */ + +/* {{{ Returns num rounded to the digits specified by precision. */ +PHP_FUNCTION(bcround) +{ + zend_string *numstr; + zend_long precision = 0; + zend_long mode = PHP_ROUND_HALF_UP; + bc_num num = NULL, result; + + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(numstr) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(precision) + Z_PARAM_LONG(mode) + ZEND_PARSE_PARAMETERS_END(); + + switch (mode) { + case PHP_ROUND_HALF_UP: + case PHP_ROUND_HALF_DOWN: + case PHP_ROUND_HALF_EVEN: + case PHP_ROUND_HALF_ODD: + case PHP_ROUND_CEILING: + case PHP_ROUND_FLOOR: + case PHP_ROUND_TOWARD_ZERO: + case PHP_ROUND_AWAY_FROM_ZERO: + break; + default: + zend_argument_value_error(3, "must be a valid rounding mode (PHP_ROUND_*)"); + return; + } + + BC_ARENA_SETUP; + + bc_init_num(&result); + + if (php_str2num(&num, numstr) == FAILURE) { + zend_argument_value_error(1, "is not well-formed"); + goto cleanup; + } + + bc_round(num, precision, mode, &result); + RETVAL_NEW_STR(bc_num2str_ex(result, result->n_scale)); + + cleanup: { + bc_free_num(&num); + bc_free_num(&result); + BC_ARENA_TEARDOWN; }; } /* }}} */ diff --git a/ext/bcmath/bcmath.stub.php b/ext/bcmath/bcmath.stub.php index 7335b2c399be2..5f5e60d3804a8 100644 --- a/ext/bcmath/bcmath.stub.php +++ b/ext/bcmath/bcmath.stub.php @@ -29,3 +29,12 @@ function bcsqrt(string $num, ?int $scale = null): string {} function bccomp(string $num1, string $num2, ?int $scale = null): int {} function bcscale(?int $scale = null): int {} + +/** @refcount 1 */ +function bcfloor(string $num): string {} + +/** @refcount 1 */ +function bcceil(string $num): string {} + +/** @refcount 1 */ +function bcround(string $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): string {} diff --git a/ext/bcmath/bcmath_arginfo.h b/ext/bcmath/bcmath_arginfo.h index 858885f70f66a..91ab4fd156477 100644 --- a/ext/bcmath/bcmath_arginfo.h +++ b/ext/bcmath/bcmath_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f28dafc2a279f5421cd0d0e668fde0032e996ebc */ + * Stub hash: cd3d182e13cb0ca22b27c13a8d0a86c20fde5b76 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcadd, 0, 2, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, num1, IS_STRING, 0) @@ -43,6 +43,18 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcscale, 0, 0, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, scale, IS_LONG, 1, "null") ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcfloor, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, num, IS_STRING, 0) +ZEND_END_ARG_INFO() + +#define arginfo_bcceil arginfo_bcfloor + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_bcround, 0, 1, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, num, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, precision, IS_LONG, 0, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "PHP_ROUND_HALF_UP") +ZEND_END_ARG_INFO() + ZEND_FUNCTION(bcadd); ZEND_FUNCTION(bcsub); ZEND_FUNCTION(bcmul); @@ -53,6 +65,9 @@ ZEND_FUNCTION(bcpow); ZEND_FUNCTION(bcsqrt); ZEND_FUNCTION(bccomp); ZEND_FUNCTION(bcscale); +ZEND_FUNCTION(bcfloor); +ZEND_FUNCTION(bcceil); +ZEND_FUNCTION(bcround); static const zend_function_entry ext_functions[] = { ZEND_FE(bcadd, arginfo_bcadd) @@ -65,5 +80,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(bcsqrt, arginfo_bcsqrt) ZEND_FE(bccomp, arginfo_bccomp) ZEND_FE(bcscale, arginfo_bcscale) + ZEND_FE(bcfloor, arginfo_bcfloor) + ZEND_FE(bcceil, arginfo_bcceil) + ZEND_FE(bcround, arginfo_bcround) ZEND_FE_END }; diff --git a/ext/bcmath/config.m4 b/ext/bcmath/config.m4 index ac654aba00770..6938fba3f2d27 100644 --- a/ext/bcmath/config.m4 +++ b/ext/bcmath/config.m4 @@ -6,9 +6,9 @@ PHP_ARG_ENABLE([bcmath], if test "$PHP_BCMATH" != "no"; then PHP_NEW_EXTENSION(bcmath, bcmath.c \ libbcmath/src/add.c libbcmath/src/div.c libbcmath/src/init.c libbcmath/src/neg.c libbcmath/src/raisemod.c libbcmath/src/sub.c \ -libbcmath/src/compare.c libbcmath/src/divmod.c libbcmath/src/int2num.c libbcmath/src/num2long.c libbcmath/src/output.c libbcmath/src/recmul.c \ -libbcmath/src/sqrt.c libbcmath/src/zero.c libbcmath/src/doaddsub.c libbcmath/src/nearzero.c libbcmath/src/num2str.c libbcmath/src/raise.c \ -libbcmath/src/rmzero.c libbcmath/src/str2num.c, +libbcmath/src/compare.c libbcmath/src/divmod.c libbcmath/src/int2num.c libbcmath/src/num2long.c libbcmath/src/recmul.c \ +libbcmath/src/sqrt.c libbcmath/src/zero.c libbcmath/src/doaddsub.c libbcmath/src/floor_or_ceil.c libbcmath/src/nearzero.c libbcmath/src/num2str.c \ +libbcmath/src/raise.c libbcmath/src/rmzero.c libbcmath/src/round.c libbcmath/src/str2num.c libbcmath/src/convert.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) PHP_ADD_BUILD_DIR($ext_builddir/libbcmath/src) AC_DEFINE(HAVE_BCMATH, 1, [Whether you have bcmath]) diff --git a/ext/bcmath/config.w32 b/ext/bcmath/config.w32 index 4f242daa8a5f8..bf5fc719a1077 100644 --- a/ext/bcmath/config.w32 +++ b/ext/bcmath/config.w32 @@ -6,8 +6,9 @@ if (PHP_BCMATH == "yes") { EXTENSION("bcmath", "bcmath.c", null, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_SOURCES("ext/bcmath/libbcmath/src", "add.c div.c init.c neg.c \ raisemod.c sub.c compare.c divmod.c int2num.c \ - num2long.c output.c recmul.c sqrt.c zero.c doaddsub.c \ - nearzero.c num2str.c raise.c rmzero.c str2num.c", "bcmath"); + num2long.c recmul.c sqrt.c zero.c doaddsub.c \ + floor_or_ceil.c nearzero.c num2str.c raise.c rmzero.c str2num.c \ + round.c convert.c", "bcmath"); AC_DEFINE('HAVE_BCMATH', 1, 'Have BCMATH library'); } diff --git a/ext/bcmath/libbcmath/src/add.c b/ext/bcmath/libbcmath/src/add.c index 1e6285a0df19a..c5f1c6cb45f94 100644 --- a/ext/bcmath/libbcmath/src/add.c +++ b/ext/bcmath/libbcmath/src/add.c @@ -39,35 +39,32 @@ N1 is added to N2 and the result placed into RESULT. SCALE_MIN is the minimum scale for the result. */ -void bc_add(bc_num n1, bc_num n2, bc_num *result, size_t scale_min) +bc_num bc_add(bc_num n1, bc_num n2, size_t scale_min) { bc_num sum = NULL; if (n1->n_sign == n2->n_sign) { - sum = _bc_do_add(n1, n2, scale_min); + sum = _bc_do_add(n1, n2); sum->n_sign = n1->n_sign; } else { /* subtraction must be done. */ /* Compare magnitudes. */ - switch (_bc_do_compare(n1, n2, false, false)) { + switch (_bc_do_compare(n1, n2, false)) { case -1: /* n1 is less than n2, subtract n1 from n2. */ - sum = _bc_do_sub(n2, n1, scale_min); + sum = _bc_do_sub(n2, n1); sum->n_sign = n2->n_sign; break; case 0: /* They are equal! return zero with the correct scale! */ sum = bc_new_num (1, MAX(scale_min, MAX(n1->n_scale, n2->n_scale))); - memset(sum->n_value, 0, sum->n_scale + 1); break; case 1: /* n2 is less than n1, subtract n2 from n1. */ - sum = _bc_do_sub(n1, n2, scale_min); + sum = _bc_do_sub(n1, n2); sum->n_sign = n1->n_sign; } } - /* Clean up and return. */ - bc_free_num (result); - *result = sum; + return sum; } diff --git a/ext/bcmath/libbcmath/src/bcmath.h b/ext/bcmath/libbcmath/src/bcmath.h index de51ee7457110..b8e3b4c7fb86a 100644 --- a/ext/bcmath/libbcmath/src/bcmath.h +++ b/ext/bcmath/libbcmath/src/bcmath.h @@ -39,16 +39,11 @@ typedef enum {PLUS, MINUS} sign; typedef struct bc_struct *bc_num; typedef struct bc_struct { - sign n_sign; - size_t n_len; /* The number of digits before the decimal point. */ - size_t n_scale; /* The number of digits after the decimal point. */ - int n_refs; /* The number of pointers to this number. */ - char *n_ptr; /* The pointer to the actual storage. - If NULL, n_value points to the inside of another number - (bc_multiply...) and should not be "freed." */ - char *n_value; /* The number. Not zero char terminated. - May not point to the same place as n_ptr as - in the case of leading zeros generated. */ + size_t n_len; /* The number of digits before the decimal point. */ + size_t n_scale; /* The number of digits after the decimal point. */ + char *n_value; /* The number. Not zero char terminated. */ + unsigned int n_refs; /* The number of pointers to this number. */ + sign n_sign; } bc_struct; #ifdef HAVE_CONFIG_H @@ -58,7 +53,9 @@ typedef struct bc_struct { #include "zend.h" #include #include "zend_string.h" -#include "../../php_bcmath.h" /* Needed for BCG() macro */ + +/* Needed for BCG() macro and PHP_ROUND_XXX */ +#include "../../php_bcmath.h" /* The base used in storing the numbers in n_value above. Currently, this MUST be 10. */ @@ -76,7 +73,6 @@ typedef struct bc_struct { #endif #define MAX(a, b) ((a)>(b)?(a):(b)) #define MIN(a, b) ((a)>(b)?(b):(a)) -#define ODD(a) ((a)&1) #ifndef LONG_MAX #define LONG_MAX 0x7ffffff @@ -89,13 +85,20 @@ void bc_init_numbers(void); bc_num _bc_new_num_ex(size_t length, size_t scale, bool persistent); +bc_num _bc_new_num_nonzeroed_ex(size_t length, size_t scale, bool persistent); + void _bc_free_num_ex(bc_num *num, bool persistent); -bc_num bc_copy_num(bc_num num); +/* Make a copy of a number! Just increments the reference count! */ +static inline bc_num bc_copy_num(bc_num num) +{ + num->n_refs++; + return num; +} void bc_init_num(bc_num *num); -bool bc_str2num(bc_num *num, char *str, size_t scale); +bool bc_str2num(bc_num *num, const char *str, const char *end, size_t scale, bool auto_scale); zend_string *bc_num2str_ex(bc_num num, size_t scale); @@ -113,11 +116,29 @@ bool bc_is_near_zero(bc_num num, size_t scale); bool bc_is_neg(bc_num num); -void bc_add(bc_num n1, bc_num n2, bc_num *result, size_t scale_min); +bc_num bc_add(bc_num n1, bc_num n2, size_t scale_min); + +#define bc_add_ex(n1, n2, result, scale_min) do { \ + bc_num add_ex = bc_add(n1, n2, scale_min); \ + bc_free_num (result); \ + *(result) = add_ex; \ +} while (0) + +bc_num bc_sub(bc_num n1, bc_num n2, size_t scale_min); -void bc_sub(bc_num n1, bc_num n2, bc_num *result, size_t scale_min); +#define bc_sub_ex(n1, n2, result, scale_min) do { \ + bc_num sub_ex = bc_sub(n1, n2, scale_min); \ + bc_free_num (result); \ + *(result) = sub_ex; \ +} while (0) -void bc_multiply(bc_num n1, bc_num n2, bc_num *prod, size_t scale); +bc_num bc_multiply(bc_num n1, bc_num n2, size_t scale); + +#define bc_multiply_ex(n1, n2, result, scale_min) do { \ + bc_num mul_ex = bc_multiply(n1, n2, scale_min); \ + bc_free_num (result); \ + *(result) = mul_ex; \ +} while (0) bool bc_divide(bc_num n1, bc_num n2, bc_num *quot, int scale); @@ -125,6 +146,10 @@ bool bc_modulo(bc_num num1, bc_num num2, bc_num *resul, size_t scale); bool bc_divmod(bc_num num1, bc_num num2, bc_num *quo, bc_num *rem, size_t scale); +bc_num bc_floor_or_ceil(bc_num num, bool is_floor); + +void bc_round(bc_num num, zend_long places, zend_long mode, bc_num *result); + typedef enum { OK, BASE_HAS_FRACTIONAL, @@ -142,11 +167,10 @@ void bc_raise_bc_exponent(bc_num base, bc_num exponent, bc_num *resul, size_t sc bool bc_sqrt(bc_num *num, size_t scale); -void bc_out_num(bc_num num, int o_base, void (* out_char)(char), bool leading_zero); - /* Prototypes needed for external utility routines. */ -#define bc_new_num(length, scale) _bc_new_num_ex((length), (scale), 0) -#define bc_free_num(num) _bc_free_num_ex((num), 0) -#define bc_num2str(num) bc_num2str_ex((num), (num->n_scale)) +#define bc_new_num(length, scale) _bc_new_num_ex((length), (scale), 0) +#define bc_new_num_nonzeroed(length, scale) _bc_new_num_nonzeroed_ex((length), (scale), 0) +#define bc_free_num(num) _bc_free_num_ex((num), 0) +#define bc_num2str(num) bc_num2str_ex((num), (num->n_scale)) #endif diff --git a/ext/bcmath/libbcmath/src/compare.c b/ext/bcmath/libbcmath/src/compare.c index f8b36cb9c3155..9604828e08ccc 100644 --- a/ext/bcmath/libbcmath/src/compare.c +++ b/ext/bcmath/libbcmath/src/compare.c @@ -39,7 +39,7 @@ than N2 and +1 if N1 is greater than N2. If USE_SIGN is false, just compare the magnitudes. */ -int _bc_do_compare(bc_num n1, bc_num n2, bool use_sign, bool ignore_last) +int _bc_do_compare(bc_num n1, bc_num n2, bool use_sign) { char *n1ptr, *n2ptr; @@ -85,9 +85,6 @@ int _bc_do_compare(bc_num n1, bc_num n2, bool use_sign, bool ignore_last) count--; } - if (ignore_last && count == 1 && n1->n_scale == n2->n_scale) { - return (0); - } if (count != 0) { if (*n1ptr > *n2ptr) { /* Magnitude of n1 > n2. */ @@ -141,5 +138,5 @@ int _bc_do_compare(bc_num n1, bc_num n2, bool use_sign, bool ignore_last) /* This is the "user callable" routine to compare numbers N1 and N2. */ int bc_compare(bc_num n1, bc_num n2) { - return _bc_do_compare(n1, n2, true, false); + return _bc_do_compare(n1, n2, true); } diff --git a/ext/bcmath/libbcmath/src/convert.c b/ext/bcmath/libbcmath/src/convert.c new file mode 100644 index 0000000000000..484df2aa50885 --- /dev/null +++ b/ext/bcmath/libbcmath/src/convert.c @@ -0,0 +1,63 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | https://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Niels Dossche | + +----------------------------------------------------------------------+ +*/ + +#include "bcmath.h" +#include "convert.h" +#include "private.h" +#ifdef __SSE2__ +# include +#endif + +char *bc_copy_and_toggle_bcd(char *restrict dest, const char *source, const char *source_end) +{ + const size_t bulk_shift = SWAR_REPEAT('0'); + +#ifdef __SSE2__ + /* SIMD SSE2 bulk shift + copy */ + __m128i shift_vector = _mm_set1_epi8('0'); + while (source + sizeof(__m128i) <= source_end) { + __m128i bytes = _mm_loadu_si128((const __m128i *) source); + bytes = _mm_xor_si128(bytes, shift_vector); + _mm_storeu_si128((__m128i *) dest, bytes); + + source += sizeof(__m128i); + dest += sizeof(__m128i); + } +#endif + + /* Handle sizeof(size_t) (i.e. 4/8) bytes at once. + * We know that adding/subtracting an individual byte cannot overflow, + * so it is possible to add/subtract an entire word of bytes at once + * by using SWAR_REPEAT. */ + while (source + sizeof(size_t) <= source_end) { + size_t bytes; + memcpy(&bytes, source, sizeof(bytes)); + + bytes ^= bulk_shift; + memcpy(dest, &bytes, sizeof(bytes)); + + source += sizeof(size_t); + dest += sizeof(size_t); + } + + while (source < source_end) { + *dest = *source ^ '0'; + dest++; + source++; + } + + return dest; +} diff --git a/ext/bcmath/libbcmath/src/convert.h b/ext/bcmath/libbcmath/src/convert.h new file mode 100644 index 0000000000000..7705bdc6ea06c --- /dev/null +++ b/ext/bcmath/libbcmath/src/convert.h @@ -0,0 +1,22 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | https://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Niels Dossche | + +----------------------------------------------------------------------+ +*/ + +#ifndef BCMATH_CONVERT_H +#define BCMATH_CONVERT_H + +char *bc_copy_and_toggle_bcd(char *restrict dest, const char *source, const char *source_end); + +#endif diff --git a/ext/bcmath/libbcmath/src/div.c b/ext/bcmath/libbcmath/src/div.c index f45188455e7f2..5d3f0439cc0b7 100644 --- a/ext/bcmath/libbcmath/src/div.c +++ b/ext/bcmath/libbcmath/src/div.c @@ -97,7 +97,6 @@ bool bc_divide(bc_num n1, bc_num n2, bc_num *quot, int scale) if (n2->n_scale == 0 && n2->n_len == 1 && *n2->n_value == 1) { qval = bc_new_num (n1->n_len, scale); qval->n_sign = (n1->n_sign == n2->n_sign ? PLUS : MINUS); - memset(&qval->n_value[n1->n_len], 0, scale); memcpy(qval->n_value, n1->n_value, n1->n_len + MIN(n1->n_scale, scale)); bc_free_num (quot); *quot = qval; @@ -146,7 +145,6 @@ bool bc_divide(bc_num n1, bc_num n2, bc_num *quot, int scale) /* Allocate and zero the storage for the quotient. */ qval = bc_new_num (qdigits - scale, scale); - memset(qval->n_value, 0, qdigits); /* Allocate storage for the temporary storage mval. */ mval = (unsigned char *) safe_emalloc(1, len2, 1); diff --git a/ext/bcmath/libbcmath/src/divmod.c b/ext/bcmath/libbcmath/src/divmod.c index d4f9d4d38cfa9..662e5600cb263 100644 --- a/ext/bcmath/libbcmath/src/divmod.c +++ b/ext/bcmath/libbcmath/src/divmod.c @@ -61,8 +61,8 @@ bool bc_divmod(bc_num num1, bc_num num2, bc_num *quot, bc_num *rem, size_t scale if (quot) { quotient = bc_copy_num(temp); } - bc_multiply(temp, num2, &temp, rscale); - bc_sub(num1, temp, rem, rscale); + bc_multiply_ex(temp, num2, &temp, rscale); + bc_sub_ex(num1, temp, rem, rscale); bc_free_num (&temp); if (quot) { diff --git a/ext/bcmath/libbcmath/src/doaddsub.c b/ext/bcmath/libbcmath/src/doaddsub.c index c5eeab94b93fb..c4b2158b88d3a 100644 --- a/ext/bcmath/libbcmath/src/doaddsub.c +++ b/ext/bcmath/libbcmath/src/doaddsub.c @@ -38,86 +38,126 @@ returned. The signs of N1 and N2 are ignored. SCALE_MIN is to set the minimum scale of the result. */ -bc_num _bc_do_add(bc_num n1, bc_num n2, size_t scale_min) +bc_num _bc_do_add(bc_num n1, bc_num n2) { bc_num sum; - size_t sum_scale, sum_digits; + size_t sum_len = MAX(n1->n_len, n2->n_len) + 1; + size_t sum_scale = MAX(n1->n_scale, n2->n_scale); + size_t min_len = MIN (n1->n_len, n2->n_len); + size_t min_scale = MIN(n1->n_scale, n2->n_scale); + size_t min_bytes = min_len + min_scale; char *n1ptr, *n2ptr, *sumptr; - size_t n1bytes, n2bytes; - bool carry; + bool carry = 0; + size_t count; /* Prepare sum. */ - sum_scale = MAX (n1->n_scale, n2->n_scale); - sum_digits = MAX (n1->n_len, n2->n_len) + 1; - sum = bc_new_num (sum_digits, MAX(sum_scale, scale_min)); - - /* Zero extra digits made by scale_min. */ - if (scale_min > sum_scale) { - sumptr = (char *) (sum->n_value + sum_scale + sum_digits); - for (int count = scale_min - sum_scale; count > 0; count--) { - *sumptr++ = 0; - } - } + sum = bc_new_num_nonzeroed(sum_len, sum_scale); /* Start with the fraction part. Initialize the pointers. */ - n1bytes = n1->n_scale; - n2bytes = n2->n_scale; - n1ptr = (char *) (n1->n_value + n1->n_len + n1bytes - 1); - n2ptr = (char *) (n2->n_value + n2->n_len + n2bytes - 1); - sumptr = (char *) (sum->n_value + sum_scale + sum_digits - 1); + n1ptr = (char *) (n1->n_value + n1->n_len + n1->n_scale - 1); + n2ptr = (char *) (n2->n_value + n2->n_len + n2->n_scale - 1); + sumptr = (char *) (sum->n_value + sum_scale + sum_len - 1); /* Add the fraction part. First copy the longer fraction.*/ - if (n1bytes != n2bytes) { - if (n1bytes > n2bytes) { - while (n1bytes > n2bytes) { - *sumptr-- = *n1ptr--; - n1bytes--; - } - } else { - while (n2bytes > n1bytes) { - *sumptr-- = *n2ptr--; - n2bytes--; - } + if (n1->n_scale != min_scale) { + /* n1 has the longer scale */ + for (count = n1->n_scale - min_scale; count > 0; count--) { + *sumptr-- = *n1ptr--; + } + } else { + /* n2 has the longer scale */ + for (count = n2->n_scale - min_scale; count > 0; count--) { + *sumptr-- = *n2ptr--; } } /* Now add the remaining fraction part and equal size integer parts. */ - n1bytes += n1->n_len; - n2bytes += n2->n_len; - carry = 0; - while ((n1bytes > 0) && (n2bytes > 0)) { + count = 0; + /* Uses SIMD to perform calculations at high speed. */ + if (min_bytes >= sizeof(BC_UINT_T)) { + sumptr++; + n1ptr++; + n2ptr++; + while (count + sizeof(BC_UINT_T) <= min_bytes) { + sumptr -= sizeof(BC_UINT_T); + n1ptr -= sizeof(BC_UINT_T); + n2ptr -= sizeof(BC_UINT_T); + + BC_UINT_T n1bytes; + BC_UINT_T n2bytes; + memcpy(&n1bytes, n1ptr, sizeof(n1bytes)); + memcpy(&n2bytes, n2ptr, sizeof(n2bytes)); + +#if BC_LITTLE_ENDIAN + /* Little endian requires changing the order of bytes. */ + n1bytes = BC_BSWAP(n1bytes); + n2bytes = BC_BSWAP(n2bytes); +#endif + + /* + * In order to add 1 to the "next digit" when a carry occurs, adjust it so that it + * overflows when add 10. + * e.g. + * 00001001(9) + 00000001(1) = 00001010(10) to + * 11111111 + 00000001 = 00000000(0) and carry 1 + */ + n1bytes += SWAR_REPEAT(0xF6) + n2bytes + carry; + /* If the most significant bit is 0, a carry has occurred. */ + carry = !(n1bytes & ((BC_UINT_T) 1 << (8 * sizeof(BC_UINT_T) - 1))); + + /* + * The calculation result is a mixture of bytes that have been carried and bytes that have not. + * The most significant bit of each byte is 0 if it is carried forward, and 1 if it is not. + * Using this, subtract the 0xF6 added for adjustment from the byte that has not been carried + * over to return it to the correct value as a decimal number. + */ + BC_UINT_T sum_mask = ((n1bytes & SWAR_REPEAT(0x80)) >> 7) * 0xF6; + n1bytes -= sum_mask; + +#if BC_LITTLE_ENDIAN + /* Little endian requires changing the order of bytes back. */ + n1bytes = BC_BSWAP(n1bytes); +#endif + + memcpy(sumptr, &n1bytes, sizeof(n1bytes)); + + count += sizeof(BC_UINT_T); + } + sumptr--; + n1ptr--; + n2ptr--; + } + + for (; count < min_bytes; count++) { *sumptr = *n1ptr-- + *n2ptr-- + carry; - if (*sumptr > (BASE - 1)) { - carry = 1; + if (*sumptr >= BASE) { *sumptr -= BASE; + carry = 1; } else { carry = 0; } sumptr--; - n1bytes--; - n2bytes--; } /* Now add carry the longer integer part. */ - if (n1bytes == 0) { - n1bytes = n2bytes; - n1ptr = n2ptr; - } - while (n1bytes-- > 0) { - *sumptr = *n1ptr-- + carry; - if (*sumptr > (BASE - 1)) { - carry = true; - *sumptr -= BASE; - } else { - carry = false; + if (n1->n_len != n2->n_len) { + if (n2->n_len > n1->n_len) { + n1ptr = n2ptr; + } + for (count = sum_len - min_len; count > 1; count--) { + *sumptr = *n1ptr-- + carry; + if (*sumptr >= BASE) { + *sumptr -= BASE; + carry = 1; + } else { + carry = 0; + } + sumptr--; } - sumptr--; } /* Set final carry. */ - if (carry) { - *sumptr += 1; - } + *sumptr = carry; /* Adjust sum and return. */ _bc_rm_leading_zeros(sum); @@ -129,38 +169,29 @@ bc_num _bc_do_add(bc_num n1, bc_num n2, size_t scale_min) returned. The signs of N1 and N2 are ignored. Also, N1 is assumed to be larger than N2. SCALE_MIN is the minimum scale of the result. */ -bc_num _bc_do_sub(bc_num n1, bc_num n2, size_t scale_min) +bc_num _bc_do_sub(bc_num n1, bc_num n2) { bc_num diff; - size_t diff_scale, diff_len; - size_t min_scale, min_len; - size_t borrow, count; + /* The caller is guaranteed that n1 is always large. */ + size_t diff_len = EXPECTED(n1->n_len >= n2->n_len) ? n1->n_len : n2->n_len; + size_t diff_scale = MAX(n1->n_scale, n2->n_scale); + /* Same condition as EXPECTED before, but using EXPECTED again will make it slower. */ + size_t min_len = n1->n_len >= n2->n_len ? n2->n_len : n1->n_len; + size_t min_scale = MIN(n1->n_scale, n2->n_scale); + size_t min_bytes = min_len + min_scale; + size_t borrow = 0; + size_t count; int val; char *n1ptr, *n2ptr, *diffptr; /* Allocate temporary storage. */ - diff_len = MAX(n1->n_len, n2->n_len); - diff_scale = MAX(n1->n_scale, n2->n_scale); - min_len = MIN(n1->n_len, n2->n_len); - min_scale = MIN(n1->n_scale, n2->n_scale); - diff = bc_new_num (diff_len, MAX(diff_scale, scale_min)); - - /* Zero extra digits made by scale_min. */ - if (scale_min > diff_scale) { - diffptr = (char *) (diff->n_value + diff_len + diff_scale); - for (count = scale_min - diff_scale; count > 0; count--) { - *diffptr++ = 0; - } - } + diff = bc_new_num_nonzeroed(diff_len, diff_scale); /* Initialize the subtract. */ n1ptr = (char *) (n1->n_value + n1->n_len + n1->n_scale - 1); n2ptr = (char *) (n2->n_value + n2->n_len + n2->n_scale - 1); diffptr = (char *) (diff->n_value + diff_len + diff_scale - 1); - /* Subtract the numbers. */ - borrow = 0; - /* Take care of the longer scaled number. */ if (n1->n_scale != min_scale) { /* n1 has the longer scale */ @@ -182,7 +213,59 @@ bc_num _bc_do_sub(bc_num n1, bc_num n2, size_t scale_min) } /* Now do the equal length scale and integer parts. */ - for (count = 0; count < min_len + min_scale; count++) { + count = 0; + /* Uses SIMD to perform calculations at high speed. */ + if (min_bytes >= sizeof(BC_UINT_T)) { + diffptr++; + n1ptr++; + n2ptr++; + while (count + sizeof(BC_UINT_T) <= min_bytes) { + diffptr -= sizeof(BC_UINT_T); + n1ptr -= sizeof(BC_UINT_T); + n2ptr -= sizeof(BC_UINT_T); + + BC_UINT_T n1bytes; + BC_UINT_T n2bytes; + memcpy(&n1bytes, n1ptr, sizeof(n1bytes)); + memcpy(&n2bytes, n2ptr, sizeof(n2bytes)); + +#if BC_LITTLE_ENDIAN + /* Little endian requires changing the order of bytes. */ + n1bytes = BC_BSWAP(n1bytes); + n2bytes = BC_BSWAP(n2bytes); +#endif + + n1bytes -= n2bytes + borrow; + /* If the most significant bit is 1, a carry down has occurred. */ + bool tmp_borrow = n1bytes & ((BC_UINT_T) 1 << (8 * sizeof(BC_UINT_T) - 1)); + + /* + * Check the most significant bit of each of the bytes, and if it is 1, a carry down has + * occurred. When carrying down occurs, due to the difference between decimal and hexadecimal + * numbers, an extra 6 is added to the lower 4 bits. + * Therefore, for a byte that has been carried down, set all the upper 4 bits to 0 and subtract + * 6 from the lower 4 bits to adjust it to the correct value as a decimal number. + */ + BC_UINT_T borrow_mask = ((n1bytes & SWAR_REPEAT(0x80)) >> 7) * 0x06; + n1bytes = (n1bytes & SWAR_REPEAT(0x0F)) - borrow_mask; + +#if BC_LITTLE_ENDIAN + /* Little endian requires changing the order of bytes back. */ + n1bytes = BC_BSWAP(n1bytes); +#endif + + memcpy(diffptr, &n1bytes, sizeof(n1bytes)); + + borrow = tmp_borrow; + count += sizeof(BC_UINT_T); + } + diffptr--; + n1ptr--; + n2ptr--; + } + + /* Calculate the remaining bytes that are less than the size of BC_UINT_T using a normal loop. */ + for (; count < min_bytes; count++) { val = *n1ptr-- - *n2ptr-- - borrow; if (val < 0) { val += BASE; diff --git a/ext/bcmath/libbcmath/src/floor_or_ceil.c b/ext/bcmath/libbcmath/src/floor_or_ceil.c new file mode 100644 index 0000000000000..b0ff811f0a223 --- /dev/null +++ b/ext/bcmath/libbcmath/src/floor_or_ceil.c @@ -0,0 +1,54 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | https://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Saki Takamachi | + +----------------------------------------------------------------------+ +*/ + +#include "bcmath.h" +#include "private.h" +#include + +bc_num bc_floor_or_ceil(bc_num num, bool is_floor) +{ + /* Initialize result */ + bc_num result = bc_new_num(num->n_len, 0); + result->n_sign = num->n_sign; + + /* copy integer part */ + memcpy(result->n_value, num->n_value, num->n_len); + + /* If the number is positive and we are flooring, then nothing else needs to be done. + * Similarly, if the number is negative and we are ceiling, then nothing else needs to be done. */ + if (num->n_scale == 0 || result->n_sign == (is_floor ? PLUS : MINUS)) { + return result; + } + + /* check fractional part. */ + size_t count = num->n_scale; + const char *nptr = num->n_value + num->n_len; + while ((count > 0) && (*nptr == 0)) { + count--; + nptr++; + } + + /* If all digits past the decimal point are 0 */ + if (count == 0) { + return result; + } + + /* Increment the absolute value of the result by 1 and add sign information */ + bc_num tmp = _bc_do_add(result, BCG(_one_)); + tmp->n_sign = result->n_sign; + bc_free_num(&result); + return tmp; +} diff --git a/ext/bcmath/libbcmath/src/init.c b/ext/bcmath/libbcmath/src/init.c index cef55324689f9..18efc1c39a2b2 100644 --- a/ext/bcmath/libbcmath/src/init.c +++ b/ext/bcmath/libbcmath/src/init.c @@ -35,22 +35,41 @@ #include #include "zend_alloc.h" -/* new_num allocates a number and sets fields to known values. */ -bc_num _bc_new_num_ex(size_t length, size_t scale, bool persistent) +static bc_num _bc_new_num_nonzeroed_ex_internal(size_t length, size_t scale, bool persistent) { - /* PHP Change: malloc() -> pemalloc(), removed free_list code */ - bc_num temp = (bc_num) safe_pemalloc(1, sizeof(bc_struct) + length, scale, persistent); + size_t required_size = zend_safe_address_guarded(1, sizeof(bc_struct) + (ZEND_MM_ALIGNMENT - 1) + length, scale); + required_size &= -ZEND_MM_ALIGNMENT; + bc_num temp; + + if (!persistent && BCG(arena) && required_size <= BC_ARENA_SIZE - BCG(arena_offset)) { + temp = (bc_num) (BCG(arena) + BCG(arena_offset)); + BCG(arena_offset) += required_size; + temp->n_refs = 2; /* prevent freeing */ + } else { + /* PHP Change: malloc() -> pemalloc(), removed free_list code, merged n_ptr and n_value */ + temp = pemalloc(required_size, persistent); + temp->n_refs = 1; + } + temp->n_sign = PLUS; temp->n_len = length; temp->n_scale = scale; - temp->n_refs = 1; - /* PHP Change: malloc() -> pemalloc() */ - temp->n_ptr = (char *) safe_pemalloc(1, length, scale, persistent); - temp->n_value = temp->n_ptr; - memset(temp->n_ptr, 0, length + scale); + temp->n_value = (char *) temp + sizeof(bc_struct); + return temp; +} + +/* new_num allocates a number and sets fields to known values. */ +bc_num _bc_new_num_ex(size_t length, size_t scale, bool persistent) +{ + bc_num temp = _bc_new_num_nonzeroed_ex_internal(length, scale, persistent); + memset(temp->n_value, 0, length + scale); return temp; } +bc_num _bc_new_num_nonzeroed_ex(size_t length, size_t scale, bool persistent) +{ + return _bc_new_num_nonzeroed_ex_internal(length, scale, persistent); +} /* "Frees" a bc_num NUM. Actually decreases reference count and only frees the storage if reference count is zero. */ @@ -61,10 +80,6 @@ void _bc_free_num_ex(bc_num *num, bool persistent) } (*num)->n_refs--; if ((*num)->n_refs == 0) { - if ((*num)->n_ptr) { - /* PHP Change: free() -> pefree(), removed free_list code */ - pefree((*num)->n_ptr, persistent); - } pefree(*num, persistent); } *num = NULL; @@ -83,14 +98,6 @@ void bc_init_numbers(void) } -/* Make a copy of a number! Just increments the reference count! */ -bc_num bc_copy_num(bc_num num) -{ - num->n_refs++; - return num; -} - - /* Initialize a number NUM by making it a copy of zero. */ void bc_init_num(bc_num *num) { diff --git a/ext/bcmath/libbcmath/src/num2str.c b/ext/bcmath/libbcmath/src/num2str.c index 904de2795af31..7679ae5d38701 100644 --- a/ext/bcmath/libbcmath/src/num2str.c +++ b/ext/bcmath/libbcmath/src/num2str.c @@ -30,7 +30,7 @@ *************************************************************************/ #include "bcmath.h" -#include +#include "convert.h" #include "zend_string.h" /* Convert a numbers to a string. Base 10 only.*/ @@ -40,9 +40,10 @@ zend_string *bc_num2str_ex(bc_num num, size_t scale) char *sptr; size_t index; bool signch; + size_t min_scale = MIN(num->n_scale, scale); /* Number of sign chars. */ - signch = num->n_sign != PLUS && !bc_is_zero_for_scale(num, MIN(num->n_scale, scale)); + signch = num->n_sign != PLUS && !bc_is_zero_for_scale(num, min_scale); /* Allocate the string memory. */ if (scale > 0) { str = zend_string_alloc(num->n_len + scale + signch + 1, 0); @@ -56,16 +57,13 @@ zend_string *bc_num2str_ex(bc_num num, size_t scale) /* Load the whole number. */ const char *nptr = num->n_value; - for (index = num->n_len; index > 0; index--) { - *sptr++ = BCD_CHAR(*nptr++); - } + sptr = bc_copy_and_toggle_bcd(sptr, nptr, nptr + num->n_len); + nptr += num->n_len; /* Now the fraction. */ if (scale > 0) { *sptr++ = '.'; - for (index = 0; index < scale && index < num->n_scale; index++) { - *sptr++ = BCD_CHAR(*nptr++); - } + sptr = bc_copy_and_toggle_bcd(sptr, nptr, nptr + min_scale); for (index = num->n_scale; index < scale; index++) { *sptr++ = BCD_CHAR(0); } diff --git a/ext/bcmath/libbcmath/src/output.c b/ext/bcmath/libbcmath/src/output.c deleted file mode 100644 index 47a82d20655e3..0000000000000 --- a/ext/bcmath/libbcmath/src/output.c +++ /dev/null @@ -1,189 +0,0 @@ -/* output.c: bcmath library file. */ -/* - Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc. - Copyright (C) 2000 Philip A. Nelson - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. (LICENSE) - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to: - - The Free Software Foundation, Inc. - 59 Temple Place, Suite 330 - Boston, MA 02111-1307 USA. - - You may contact the author by: - e-mail: philnelson@acm.org - us-mail: Philip A. Nelson - Computer Science Department, 9062 - Western Washington University - Bellingham, WA 98226-9062 - -*************************************************************************/ - -#include "bcmath.h" -#include -#include -#include "zend_alloc.h" - - -/* The following routines provide output for bcd numbers package - using the rules of POSIX bc for output. */ - -/* This structure is used for saving digits in the conversion process. */ -typedef struct stk_rec { - long digit; - struct stk_rec *next; -} stk_rec; - -/* The reference string for digits. */ -static const char ref_str[] = "0123456789ABCDEF"; - - -/* A special output routine for "multi-character digits." Exactly - SIZE characters must be output for the value VAL. If SPACE is - non-zero, we must output one space before the number. OUT_CHAR - is the actual routine for writing the characters. */ - -void bc_out_long(long val, size_t size, bool space, void (*out_char)(char)) -{ - char digits[40]; - size_t len, ix; - - if (space) (*out_char)(' '); - snprintf(digits, sizeof(digits), "%ld", val); - len = strlen(digits); - while (size > len) { - (*out_char)('0'); - size--; - } - for (ix = 0; ix < len; ix++) { - (*out_char)(digits[ix]); - } -} - -/* Output of a bcd number. NUM is written in base O_BASE using OUT_CHAR - as the routine to do the actual output of the characters. */ - -void bc_out_num(bc_num num, int o_base, void (*out_char)(char), bool leading_zero) -{ - char *nptr; - int index, fdigit; - bool pre_space; - stk_rec *digits, *temp; - bc_num int_part, frac_part, base, cur_dig, t_num, max_o_digit; - - /* The negative sign if needed. */ - if (num->n_sign == MINUS) (*out_char)('-'); - - /* Output the number. */ - if (bc_is_zero(num)) { - (*out_char)('0'); - } else { - if (o_base == 10) { - /* The number is in base 10, do it the fast way. */ - nptr = num->n_value; - if (num->n_len > 1 || *nptr != 0) { - for (index = num->n_len; index > 0; index--) { - (*out_char)(BCD_CHAR(*nptr++)); - } - } else { - nptr++; - } - - if (leading_zero && bc_is_zero(num)) { - (*out_char)('0'); - } - - /* Now the fraction. */ - if (num->n_scale > 0) { - (*out_char)('.'); - for (index = 0; index < num->n_scale; index++) { - (*out_char)(BCD_CHAR(*nptr++)); - } - } - } else { - /* special case ... */ - if (leading_zero && bc_is_zero(num)) { - (*out_char)('0'); - } - - /* The number is some other base. */ - digits = NULL; - bc_init_num(&int_part); - bc_divide(num, BCG(_one_), &int_part, 0); - bc_init_num(&frac_part); - bc_init_num(&cur_dig); - bc_init_num(&base); - bc_sub(num, int_part, &frac_part, 0); - /* Make the INT_PART and FRAC_PART positive. */ - int_part->n_sign = PLUS; - frac_part->n_sign = PLUS; - bc_int2num(&base, o_base); - bc_init_num(&max_o_digit); - bc_int2num(&max_o_digit, o_base - 1); - - /* Get the digits of the integer part and push them on a stack. */ - while (!bc_is_zero(int_part)) { - bc_modulo(int_part, base, &cur_dig, 0); - /* PHP Change: malloc() -> emalloc() */ - temp = (stk_rec *) emalloc(sizeof(stk_rec)); - temp->digit = bc_num2long(cur_dig); - temp->next = digits; - digits = temp; - bc_divide(int_part, base, &int_part, 0); - } - - /* Print the digits on the stack. */ - if (digits != NULL) { - /* Output the digits. */ - while (digits != NULL) { - temp = digits; - digits = digits->next; - if (o_base <= 16) { - (*out_char)(ref_str[(int) temp->digit]); - } else { - bc_out_long(temp->digit, max_o_digit->n_len, 1, out_char); - } - efree(temp); - } - } - - /* Get and print the digits of the fraction part. */ - if (num->n_scale > 0) { - (*out_char)('.'); - pre_space = false; - t_num = bc_copy_num(BCG(_one_)); - while (t_num->n_len <= num->n_scale) { - bc_multiply(frac_part, base, &frac_part, num->n_scale); - fdigit = bc_num2long(frac_part); - bc_int2num(&int_part, fdigit); - bc_sub(frac_part, int_part, &frac_part, 0); - if (o_base <= 16) { - (*out_char)(ref_str[fdigit]); - } else { - bc_out_long(fdigit, max_o_digit->n_len, pre_space, out_char); - pre_space = true; - } - bc_multiply(t_num, base, &t_num, 0); - } - bc_free_num (&t_num); - } - - /* Clean up. */ - bc_free_num (&int_part); - bc_free_num (&frac_part); - bc_free_num (&base); - bc_free_num (&cur_dig); - bc_free_num (&max_o_digit); - } - } -} diff --git a/ext/bcmath/libbcmath/src/private.h b/ext/bcmath/libbcmath/src/private.h index 92db802eb4582..6035d73dd716e 100644 --- a/ext/bcmath/libbcmath/src/private.h +++ b/ext/bcmath/libbcmath/src/private.h @@ -34,8 +34,70 @@ #include #include +/* This will be 0x01010101 for 32-bit and 0x0101010101010101 for 64-bit */ +#define SWAR_ONES (~((size_t) 0) / 0xFF) +/* This repeats a byte `x` into an entire 32/64-bit word. + * Example: SWAR_REPEAT(0xAB) will be 0xABABABAB for 32-bit and 0xABABABABABABABAB for 64-bit. */ +#define SWAR_REPEAT(x) (SWAR_ONES * (x)) + +/* Bytes swap */ +#ifdef _MSC_VER +# include +# define BC_BSWAP32(u) _byteswap_ulong(u) +# define BC_BSWAP64(u) _byteswap_uint64(u) +#else +# ifdef __GNUC__ +# define BC_BSWAP32(u) __builtin_bswap32(u) +# define BC_BSWAP64(u) __builtin_bswap64(u) +# elif defined(__has_builtin) +# if __has_builtin(__builtin_bswap32) +# define BC_BSWAP32(u) __builtin_bswap32(u) +# endif // __has_builtin(__builtin_bswap32) +# if __has_builtin(__builtin_bswap64) +# define BC_BSWAP64(u) __builtin_bswap64(u) +# endif // __has_builtin(__builtin_bswap64) +# endif // __GNUC__ +#endif // _MSC_VER +#ifndef BC_BSWAP32 +static inline uint32_t BC_BSWAP32(uint32_t u) +{ + return (((u & 0xff000000) >> 24) + | ((u & 0x00ff0000) >> 8) + | ((u & 0x0000ff00) << 8) + | ((u & 0x000000ff) << 24)); +} +#endif +#ifndef BC_BSWAP64 +static inline uint64_t BC_BSWAP64(uint64_t u) +{ + return (((u & 0xff00000000000000ULL) >> 56) + | ((u & 0x00ff000000000000ULL) >> 40) + | ((u & 0x0000ff0000000000ULL) >> 24) + | ((u & 0x000000ff00000000ULL) >> 8) + | ((u & 0x00000000ff000000ULL) << 8) + | ((u & 0x0000000000ff0000ULL) << 24) + | ((u & 0x000000000000ff00ULL) << 40) + | ((u & 0x00000000000000ffULL) << 56)); +} +#endif + +#if SIZEOF_SIZE_T >= 8 +# define BC_BSWAP(u) BC_BSWAP64(u) +# define BC_UINT_T uint64_t +#else +# define BC_BSWAP(u) BC_BSWAP32(u) +# define BC_UINT_T uint32_t +#endif + +#ifdef WORDS_BIGENDIAN +# define BC_LITTLE_ENDIAN 0 +#else +# define BC_LITTLE_ENDIAN 1 +#endif + + /* routines */ -int _bc_do_compare (bc_num n1, bc_num n2, bool use_sign, bool ignore_last); -bc_num _bc_do_add (bc_num n1, bc_num n2, size_t scale_min); -bc_num _bc_do_sub (bc_num n1, bc_num n2, size_t scale_min); +int _bc_do_compare (bc_num n1, bc_num n2, bool use_sign); +bc_num _bc_do_add (bc_num n1, bc_num n2); +bc_num _bc_do_sub (bc_num n1, bc_num n2); void _bc_rm_leading_zeros (bc_num num); diff --git a/ext/bcmath/libbcmath/src/raise.c b/ext/bcmath/libbcmath/src/raise.c index 61d64ace94744..390f4d6935c6d 100644 --- a/ext/bcmath/libbcmath/src/raise.c +++ b/ext/bcmath/libbcmath/src/raise.c @@ -69,7 +69,7 @@ void bc_raise(bc_num num1, long exponent, bc_num *result, size_t scale) pwrscale = num1->n_scale; while ((exponent & 1) == 0) { pwrscale = 2 * pwrscale; - bc_multiply(power, power, &power, pwrscale); + bc_multiply_ex(power, power, &power, pwrscale); exponent = exponent >> 1; } temp = bc_copy_num(power); @@ -79,10 +79,10 @@ void bc_raise(bc_num num1, long exponent, bc_num *result, size_t scale) /* Do the calculation. */ while (exponent > 0) { pwrscale = 2 * pwrscale; - bc_multiply(power, power, &power, pwrscale); + bc_multiply_ex(power, power, &power, pwrscale); if ((exponent & 1) == 1) { calcscale = pwrscale + calcscale; - bc_multiply(temp, power, &temp, calcscale); + bc_multiply_ex(temp, power, &temp, calcscale); } exponent = exponent >> 1; } diff --git a/ext/bcmath/libbcmath/src/raisemod.c b/ext/bcmath/libbcmath/src/raisemod.c index d4a2d01f3edb9..caf1a090f9807 100644 --- a/ext/bcmath/libbcmath/src/raisemod.c +++ b/ext/bcmath/libbcmath/src/raisemod.c @@ -72,10 +72,10 @@ raise_mod_status bc_raisemod(bc_num base, bc_num expo, bc_num mod, bc_num *resul while (!bc_is_zero(exponent)) { (void) bc_divmod(exponent, BCG(_two_), &exponent, &parity, 0); if (!bc_is_zero(parity)) { - bc_multiply(temp, power, &temp, scale); + bc_multiply_ex(temp, power, &temp, scale); (void) bc_modulo(temp, modulus, &temp, scale); } - bc_multiply(power, power, &power, scale); + bc_multiply_ex(power, power, &power, scale); (void) bc_modulo(power, modulus, &power, scale); } } diff --git a/ext/bcmath/libbcmath/src/recmul.c b/ext/bcmath/libbcmath/src/recmul.c index ec89c461fa188..3b3b696f99d46 100644 --- a/ext/bcmath/libbcmath/src/recmul.c +++ b/ext/bcmath/libbcmath/src/recmul.c @@ -56,7 +56,6 @@ static bc_num new_sub_num(size_t length, size_t scale, char *value) temp->n_len = length; temp->n_scale = scale; temp->n_refs = 1; - temp->n_ptr = NULL; temp->n_value = value; return temp; } @@ -69,7 +68,7 @@ static void _bc_simp_mul(bc_num n1, size_t n1len, bc_num n2, int n2len, bc_num * int prodlen = n1len + n2len + 1; - *prod = bc_new_num (prodlen, 0); + *prod = bc_new_num_nonzeroed(prodlen, 0); n1end = (char *) (n1->n_value + n1len - 1); n2end = (char *) (n2->n_value + n2len - 1); @@ -164,7 +163,7 @@ static void _bc_shift_addsub(bc_num accum, bc_num val, int shift, bool sub) static void _bc_rec_mul(bc_num u, size_t ulen, bc_num v, size_t vlen, bc_num *prod) { bc_num u0, u1, v0, v1; - bc_num m1, m2, m3, d1, d2; + bc_num m1, m2, m3; size_t n; bool m1zero; @@ -204,10 +203,8 @@ static void _bc_rec_mul(bc_num u, size_t ulen, bc_num v, size_t vlen, bc_num *pr /* Calculate sub results ... */ - bc_init_num(&d1); - bc_init_num(&d2); - bc_sub(u1, u0, &d1, 0); - bc_sub(v0, v1, &d2, 0); + bc_num d1 = bc_sub(u1, u0, 0); + bc_num d2 = bc_sub(v0, v1, 0); /* Do recursive multiplies and shifted adds. */ @@ -256,7 +253,7 @@ static void _bc_rec_mul(bc_num u, size_t ulen, bc_num v, size_t vlen, bc_num *pr the result being MIN(N2 scale+N1 scale, MAX (SCALE, N2 scale, N1 scale)). */ -void bc_multiply(bc_num n1, bc_num n2, bc_num *prod, size_t scale) +bc_num bc_multiply(bc_num n1, bc_num n2, size_t scale) { bc_num pval; size_t len1, len2; @@ -273,13 +270,11 @@ void bc_multiply(bc_num n1, bc_num n2, bc_num *prod, size_t scale) /* Assign to prod and clean up the number. */ pval->n_sign = (n1->n_sign == n2->n_sign ? PLUS : MINUS); - pval->n_value = pval->n_ptr; pval->n_len = len2 + len1 + 1 - full_scale; pval->n_scale = prod_scale; _bc_rm_leading_zeros(pval); if (bc_is_zero(pval)) { pval->n_sign = PLUS; } - bc_free_num(prod); - *prod = pval; + return pval; } diff --git a/ext/bcmath/libbcmath/src/round.c b/ext/bcmath/libbcmath/src/round.c new file mode 100644 index 0000000000000..7ece5ef6b85c4 --- /dev/null +++ b/ext/bcmath/libbcmath/src/round.c @@ -0,0 +1,179 @@ +/* + +----------------------------------------------------------------------+ + | Copyright (c) The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | https://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Saki Takamachi | + +----------------------------------------------------------------------+ +*/ + +#include "bcmath.h" +#include "private.h" +#include + +void bc_round(bc_num num, zend_long precision, zend_long mode, bc_num *result) +{ + /* clear result */ + bc_free_num(result); + + /* + * The following cases result in an early return: + * + * - When rounding to an integer part which is larger than the number + * e.g. Rounding 21.123 to 3 digits before the decimal point. + * - When rounding to a greater decimal precision then the number has, the number is unchanged + * e.g. Rounding 21.123 to 4 digits after the decimal point. + * - If the fractional part ends with zeros, the zeros are omitted and the number of digits in num is reduced. + * Meaning we might end up in the previous case. + */ + if (precision < 0 && num->n_len < (size_t) (-(precision + Z_L(1))) + 1) { + *result = bc_copy_num(BCG(_zero_)); + return; + } + /* Just like bcadd('1', '1', 4) becomes '2.0000', it pads with zeros at the end if necessary. */ + if (precision >= 0 && num->n_scale <= precision) { + if (num->n_scale == precision) { + *result = bc_copy_num(num); + } else if(num->n_scale < precision) { + *result = bc_new_num(num->n_len, precision); + (*result)->n_sign = num->n_sign; + memcpy((*result)->n_value, num->n_value, num->n_len + num->n_scale); + } + return; + } + + /* + * If the calculation result is a negative value, there is an early return, + * so no underflow will occur. + */ + size_t rounded_len = num->n_len + precision; + + /* + * Initialize result + * For example, if rounded_len is 0, it means trying to round 50 to 100 or 0. + * If the result of rounding is carried over, it will be added later, so first set it to 0 here. + */ + if (rounded_len == 0) { + *result = bc_copy_num(BCG(_zero_)); + } else { + *result = bc_new_num(num->n_len, precision > 0 ? precision : 0); + memcpy((*result)->n_value, num->n_value, rounded_len); + } + (*result)->n_sign = num->n_sign; + + const char *nptr = num->n_value + rounded_len; + + /* Check cases that can be determined without looping. */ + switch (mode) { + case PHP_ROUND_HALF_UP: + if (*nptr >= 5) { + goto up; + } else if (*nptr < 5) { + return; + } + break; + + case PHP_ROUND_HALF_DOWN: + case PHP_ROUND_HALF_EVEN: + case PHP_ROUND_HALF_ODD: + if (*nptr > 5) { + goto up; + } else if (*nptr < 5) { + return; + } + /* if *nptr == 5, we need to look-up further digits before making a decision. */ + break; + + case PHP_ROUND_CEILING: + if (num->n_sign != PLUS) { + return; + } else if (*nptr > 0) { + goto up; + } + /* if *nptr == 0, a loop is required for judgment. */ + break; + + case PHP_ROUND_FLOOR: + if (num->n_sign != MINUS) { + return; + } else if (*nptr > 0) { + goto up; + } + /* if *nptr == 0, a loop is required for judgment. */ + break; + + case PHP_ROUND_TOWARD_ZERO: + return; + + case PHP_ROUND_AWAY_FROM_ZERO: + if (*nptr > 0) { + goto up; + } + /* if *nptr == 0, a loop is required for judgment. */ + break; + + EMPTY_SWITCH_DEFAULT_CASE() + } + + /* Loop through the remaining digits. */ + size_t count = num->n_len + num->n_scale - rounded_len - 1; + nptr++; + while ((count > 0) && (*nptr == 0)) { + count--; + nptr++; + } + + if (count > 0) { + goto up; + } + + switch (mode) { + case PHP_ROUND_HALF_DOWN: + case PHP_ROUND_CEILING: + case PHP_ROUND_FLOOR: + case PHP_ROUND_AWAY_FROM_ZERO: + return; + + case PHP_ROUND_HALF_EVEN: + if (rounded_len == 0 || num->n_value[rounded_len - 1] % 2 == 0) { + return; + } + break; + + case PHP_ROUND_HALF_ODD: + if (rounded_len != 0 && num->n_value[rounded_len - 1] % 2 == 1) { + return; + } + break; + + EMPTY_SWITCH_DEFAULT_CASE() + } + +up: + { + bc_num tmp; + + if (rounded_len == 0) { + tmp = bc_new_num(num->n_len + 1, 0); + tmp->n_value[0] = 1; + tmp->n_sign = num->n_sign; + } else { + bc_num scaled_one = bc_new_num((*result)->n_len, (*result)->n_scale); + scaled_one->n_value[rounded_len - 1] = 1; + + tmp = _bc_do_add(*result, scaled_one); + tmp->n_sign = (*result)->n_sign; + bc_free_num(&scaled_one); + } + + bc_free_num(result); + *result = tmp; + } +} diff --git a/ext/bcmath/libbcmath/src/sqrt.c b/ext/bcmath/libbcmath/src/sqrt.c index f29f9ce484bad..995bf076b54e7 100644 --- a/ext/bcmath/libbcmath/src/sqrt.c +++ b/ext/bcmath/libbcmath/src/sqrt.c @@ -79,7 +79,7 @@ bool bc_sqrt(bc_num *num, size_t scale) bc_int2num(&guess, 10); bc_int2num(&guess1, (*num)->n_len); - bc_multiply(guess1, point5, &guess1, 0); + bc_multiply_ex(guess1, point5, &guess1, 0); guess1->n_scale = 0; bc_raise_bc_exponent(guess, guess1, &guess, 0); bc_free_num (&guess1); @@ -92,9 +92,9 @@ bool bc_sqrt(bc_num *num, size_t scale) bc_free_num (&guess1); guess1 = bc_copy_num(guess); bc_divide(*num, guess, &guess, cscale); - bc_add(guess, guess1, &guess, 0); - bc_multiply(guess, point5, &guess, cscale); - bc_sub(guess, guess1, &diff, cscale + 1); + bc_add_ex(guess, guess1, &guess, 0); + bc_multiply_ex(guess, point5, &guess, cscale); + bc_sub_ex(guess, guess1, &diff, cscale + 1); if (bc_is_near_zero(diff, cscale)) { if (cscale < rscale + 1) { cscale = MIN (cscale * 3, rscale + 1); diff --git a/ext/bcmath/libbcmath/src/str2num.c b/ext/bcmath/libbcmath/src/str2num.c index cc876285d59c0..a46ae6a2c9d73 100644 --- a/ext/bcmath/libbcmath/src/str2num.c +++ b/ext/bcmath/libbcmath/src/str2num.c @@ -30,25 +30,93 @@ *************************************************************************/ #include "bcmath.h" +#include "convert.h" +#include "private.h" #include #include +#ifdef __SSE2__ +# include +#endif /* Convert strings to bc numbers. Base 10 only.*/ +static const char *bc_count_digits(const char *str, const char *end) +{ + /* Process in bulk */ +#ifdef __SSE2__ + const __m128i offset = _mm_set1_epi8((signed char) (SCHAR_MIN - '0')); + /* we use the less than comparator, so add 1 */ + const __m128i threshold = _mm_set1_epi8(SCHAR_MIN + ('9' + 1 - '0')); + + while (str + sizeof(__m128i) <= end) { + __m128i bytes = _mm_loadu_si128((const __m128i *) str); + /* Wrapping-add the offset to the bytes, such that all bytes below '0' are positive and others are negative. + * More specifically, '0' will be -128 and '9' will be -119. */ + bytes = _mm_add_epi8(bytes, offset); + /* Now mark all bytes that are <= '9', i.e. <= -119, i.e. < -118, i.e. the threshold. */ + bytes = _mm_cmplt_epi8(bytes, threshold); + + int mask = _mm_movemask_epi8(bytes); + if (mask != 0xffff) { + /* At least one of the bytes is not within range. Move to the first offending byte. */ +#ifdef PHP_HAVE_BUILTIN_CTZL + return str + __builtin_ctz(~mask); +#else + break; +#endif + } + + str += sizeof(__m128i); + } +#endif + + while (*str >= '0' && *str <= '9') { + str++; + } -bool bc_str2num(bc_num *num, char *str, size_t scale) + return str; +} + +static inline const char *bc_skip_zero_reverse(const char *scanner, const char *stop) { - size_t digits = 0; - size_t strscale = 0; - char *ptr, *nptr; - size_t trailing_zeros = 0; + /* Check in bulk */ +#ifdef __SSE2__ + const __m128i c_zero_repeat = _mm_set1_epi8('0'); + while (scanner - sizeof(__m128i) >= stop) { + scanner -= sizeof(__m128i); + __m128i bytes = _mm_loadu_si128((const __m128i *) scanner); + /* Checks if all numeric strings are equal to '0'. */ + bytes = _mm_cmpeq_epi8(bytes, c_zero_repeat); + + int mask = _mm_movemask_epi8(bytes); + /* The probability of having 16 trailing 0s in a row is very low, so we use EXPECTED. */ + if (EXPECTED(mask != 0xffff)) { + /* Move the pointer back and check each character in loop. */ + scanner += sizeof(__m128i); + break; + } + } +#endif + + /* Exclude trailing zeros. */ + while (scanner - 1 >= stop && scanner[-1] == '0') { + scanner--; + } + + return scanner; +} + +/* Assumes `num` points to NULL, i.e. does yet not hold a number. */ +bool bc_str2num(bc_num *num, const char *str, const char *end, size_t scale, bool auto_scale) +{ + size_t str_scale = 0; + const char *ptr = str; + const char *fractional_ptr = NULL; + const char *fractional_end = NULL; bool zero_int = false; - /* Prepare num. */ - bc_free_num (num); + ZEND_ASSERT(*num == NULL); /* Check for valid number and count digits. */ - ptr = str; - if ((*ptr == '+') || (*ptr == '-')) { /* Skip Sign */ ptr++; @@ -57,77 +125,87 @@ bool bc_str2num(bc_num *num, char *str, size_t scale) while (*ptr == '0') { ptr++; } + const char *integer_ptr = ptr; /* digits before the decimal point */ - while (*ptr >= '0' && *ptr <= '9') { - ptr++; - digits++; - } + ptr = bc_count_digits(ptr, end); + size_t digits = ptr - integer_ptr; /* decimal point */ - if (*ptr == '.') { - ptr++; + const char *decimal_point = (*ptr == '.') ? ptr : NULL; + + /* If a non-digit and non-decimal-point indicator is in the string, i.e. an invalid character */ + if (UNEXPECTED(!decimal_point && *ptr != '\0')) { + goto fail; } - /* digits after the decimal point */ - while (*ptr >= '0' && *ptr <= '9') { - if (*ptr == '0') { - trailing_zeros++; - } else { - trailing_zeros = 0; + + /* search and validate fractional end if exists */ + if (decimal_point) { + /* search */ + fractional_ptr = fractional_end = decimal_point + 1; + /* For strings that end with a decimal point, such as "012." */ + if (UNEXPECTED(*fractional_ptr == '\0')) { + goto after_fractional; + } + + /* validate */ + fractional_end = bc_count_digits(fractional_ptr, end); + if (UNEXPECTED(*fractional_end != '\0')) { + /* invalid num */ + goto fail; } - ptr++; - strscale++; - } - if (trailing_zeros > 0) { - /* Trailing zeros should not take part in the computation of the overall scale, as it is pointless. */ - strscale = strscale - trailing_zeros; + /* Exclude trailing zeros. */ + fractional_end = bc_skip_zero_reverse(fractional_end, fractional_ptr); + + /* Calculate the length of the fraction excluding trailing zero. */ + str_scale = fractional_end - fractional_ptr; + + /* + * If set the scale manually and it is smaller than the automatically calculated scale, + * adjust it to match the manual setting. + */ + if (str_scale > scale && !auto_scale) { + fractional_end -= str_scale - scale; + str_scale = scale; + } } - if ((*ptr != '\0') || (digits + strscale == 0)) { - *num = bc_copy_num(BCG(_zero_)); - return *ptr == '\0'; + +after_fractional: + + if (digits + str_scale == 0) { + goto zero; } /* Adjust numbers and allocate storage and initialize fields. */ - strscale = MIN(strscale, scale); if (digits == 0) { zero_int = true; digits = 1; } - *num = bc_new_num (digits, strscale); + *num = bc_new_num_nonzeroed(digits, str_scale); + (*num)->n_sign = *str == '-' ? MINUS : PLUS; + char *nptr = (*num)->n_value; - /* Build the whole number. */ - ptr = str; - if (*ptr == '-') { - (*num)->n_sign = MINUS; - ptr++; - } else { - (*num)->n_sign = PLUS; - if (*ptr == '+') ptr++; - } - /* Skip leading zeros. */ - while (*ptr == '0') { - ptr++; - } - nptr = (*num)->n_value; if (zero_int) { *nptr++ = 0; - digits = 0; - } - for (; digits > 0; digits--) { - *nptr++ = CH_VAL(*ptr++); - } - - /* Build the fractional part. */ - if (strscale > 0) { - /* skip the decimal point! */ - ptr++; - for (; strscale > 0; strscale--) { - *nptr++ = CH_VAL(*ptr++); + /* + * If zero_int is true and the str_scale is 0, there is an early return, + * so here str_scale is always greater than 0. + */ + nptr = bc_copy_and_toggle_bcd(nptr, fractional_ptr, fractional_end); + } else { + const char *integer_end = integer_ptr + digits; + nptr = bc_copy_and_toggle_bcd(nptr, integer_ptr, integer_end); + if (str_scale > 0) { + nptr = bc_copy_and_toggle_bcd(nptr, fractional_ptr, fractional_end); } } - if (bc_is_zero(*num)) { - (*num)->n_sign = PLUS; - } + return true; +zero: + *num = bc_copy_num(BCG(_zero_)); return true; + +fail: + *num = bc_copy_num(BCG(_zero_)); + return false; } diff --git a/ext/bcmath/libbcmath/src/sub.c b/ext/bcmath/libbcmath/src/sub.c index d90f1a8858f29..fc6b6b9d8e7b6 100644 --- a/ext/bcmath/libbcmath/src/sub.c +++ b/ext/bcmath/libbcmath/src/sub.c @@ -39,38 +39,35 @@ N2 is subtracted from N1 and the result placed in RESULT. SCALE_MIN is the minimum scale for the result. */ -void bc_sub(bc_num n1, bc_num n2, bc_num *result, size_t scale_min) +bc_num bc_sub(bc_num n1, bc_num n2, size_t scale_min) { bc_num diff = NULL; if (n1->n_sign != n2->n_sign) { - diff = _bc_do_add(n1, n2, scale_min); + diff = _bc_do_add(n1, n2); diff->n_sign = n1->n_sign; } else { /* subtraction must be done. */ /* Compare magnitudes. */ - switch (_bc_do_compare(n1, n2, false, false)) { + switch (_bc_do_compare(n1, n2, false)) { case -1: /* n1 is less than n2, subtract n1 from n2. */ - diff = _bc_do_sub(n2, n1, scale_min); + diff = _bc_do_sub(n2, n1); diff->n_sign = (n2->n_sign == PLUS ? MINUS : PLUS); break; case 0: { /* They are equal! return zero! */ size_t res_scale = MAX (scale_min, MAX(n1->n_scale, n2->n_scale)); diff = bc_new_num (1, res_scale); - memset(diff->n_value, 0, res_scale + 1); break; } case 1: /* n2 is less than n1, subtract n2 from n1. */ - diff = _bc_do_sub(n1, n2, scale_min); + diff = _bc_do_sub(n1, n2); diff->n_sign = n1->n_sign; break; } } - /* Clean up and return. */ - bc_free_num (result); - *result = diff; + return diff; } diff --git a/ext/bcmath/php_bcmath.h b/ext/bcmath/php_bcmath.h index 1045019d64ca9..77ebcbdb39fa6 100644 --- a/ext/bcmath/php_bcmath.h +++ b/ext/bcmath/php_bcmath.h @@ -19,6 +19,7 @@ #include "libbcmath/src/bcmath.h" #include "zend_API.h" +#include "ext/standard/php_math_round_mode.h" extern zend_module_entry bcmath_module_entry; #define phpext_bcmath_ptr &bcmath_module_entry @@ -26,11 +27,15 @@ extern zend_module_entry bcmath_module_entry; #include "php_version.h" #define PHP_BCMATH_VERSION PHP_VERSION +#define BC_ARENA_SIZE 256 + ZEND_BEGIN_MODULE_GLOBALS(bcmath) bc_num _zero_; bc_num _one_; bc_num _two_; int bc_precision; + char *arena; + size_t arena_offset; ZEND_END_MODULE_GLOBALS(bcmath) #if defined(ZTS) && defined(COMPILE_DL_BCMATH) diff --git a/ext/bcmath/tests/bcadd.phpt b/ext/bcmath/tests/bcadd.phpt index 188d8228e5456..fbef355c4fa78 100644 --- a/ext/bcmath/tests/bcadd.phpt +++ b/ext/bcmath/tests/bcadd.phpt @@ -8,7 +8,7 @@ bcmath.scale=0 ', bcceil($num), "\n"; +} +?> +--EXPECT-- + 0 => 0 + 0.00 => 0 + -0 => 0 + -0.00 => 0 + 0.01 => 1 + 0.000000000000000000000000000000000000000001 => 1 + -0.01 => 0 + -0.000000000000000000000000000000000000000001 => 0 + 1 => 1 + 1.0000 => 1 + 1.0001 => 2 + 100000.000000000000000000000000000000000000000001 => 100001 + -1 => -1 + -1.0000 => -1 + -1.0001 => -1 +-100000.000000000000000000000000000000000000000001 => -100000 diff --git a/ext/bcmath/tests/bcceil_error.phpt b/ext/bcmath/tests/bcceil_error.phpt new file mode 100644 index 0000000000000..fd4c51ff6c586 --- /dev/null +++ b/ext/bcmath/tests/bcceil_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +bcceil() function with error +--EXTENSIONS-- +bcmath +--FILE-- +getMessage()."\n"; +} + +try { + bcceil('0.00.1'); +} catch (Throwable $e) { + echo $e->getMessage()."\n"; +} +?> +--EXPECT-- +bcceil(): Argument #1 ($num) is not well-formed +bcceil(): Argument #1 ($num) is not well-formed diff --git a/ext/bcmath/tests/bcfloor.phpt b/ext/bcmath/tests/bcfloor.phpt new file mode 100644 index 0000000000000..d274ef44ba16a --- /dev/null +++ b/ext/bcmath/tests/bcfloor.phpt @@ -0,0 +1,46 @@ +--TEST-- +bcfloor() function +--EXTENSIONS-- +bcmath +--FILE-- + ', bcfloor($num), "\n"; +} +?> +--EXPECT-- + 0 => 0 + 0.00 => 0 + -0 => 0 + -0.00 => 0 + 0.01 => 0 + 0.000000000000000000000000000000000000000001 => 0 + -0.01 => -1 + -0.000000000000000000000000000000000000000001 => -1 + 1 => 1 + 1.0000 => 1 + 1.0001 => 1 + 100000.000000000000000000000000000000000000000001 => 100000 + -1 => -1 + -1.0000 => -1 + -1.0001 => -2 +-100000.000000000000000000000000000000000000000001 => -100001 diff --git a/ext/bcmath/tests/bcfloor_error.phpt b/ext/bcmath/tests/bcfloor_error.phpt new file mode 100644 index 0000000000000..7578a5afe3b8d --- /dev/null +++ b/ext/bcmath/tests/bcfloor_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +bcfloor() function with error +--EXTENSIONS-- +bcmath +--FILE-- +getMessage()."\n"; +} + +try { + bcfloor('0.00.1'); +} catch (Throwable $e) { + echo $e->getMessage()."\n"; +} +?> +--EXPECT-- +bcfloor(): Argument #1 ($num) is not well-formed +bcfloor(): Argument #1 ($num) is not well-formed diff --git a/ext/bcmath/tests/bcround_away_from_zero.phpt b/ext/bcmath/tests/bcround_away_from_zero.phpt new file mode 100644 index 0000000000000..cfaa15002585e --- /dev/null +++ b/ext/bcmath/tests/bcround_away_from_zero.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_AWAY_FROM_ZERO +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 2 + [1.2, 0] => 2 + [1.3, 0] => 2 + [1.4, 0] => 2 + [1.6, 0] => 2 + [1.7, 0] => 2 + [1.8, 0] => 2 + [1.9, 0] => 2 + [-1.1, 0] => -2 + [-1.2, 0] => -2 + [-1.3, 0] => -2 + [-1.4, 0] => -2 + [-1.6, 0] => -2 + [-1.7, 0] => -2 + [-1.8, 0] => -2 + [-1.9, 0] => -2 + +========== minus precision ========== + [50, -2] => 100 + [-50, -2] => -100 + [1230, -1] => 1230 + [1235, -1] => 1240 + [-1230, -1] => -1230 + [-1235, -1] => -1240 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3500 + [3450.0000, -2] => 3500 + [3450.0001, -2] => 3500 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3500 + [-3450.0000, -2] => -3500 + [-3450.0001, -2] => -3500 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1236 + [1235.5, 0] => 1236 + [1235.500001, 0] => 1236 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1236 + [-1235.5, 0] => -1236 +[-1235.500001, 0] => -1236 + [0.0001, 0] => 1 + [0.5, 0] => 1 + [0.5000, 0] => 1 + [0.5001, 0] => 1 + [-0.0001, 0] => -1 + [-0.5, 0] => -1 + [-0.5000, 0] => -1 + [-0.5001, 0] => -1 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.5 + [28.45, 1] => 28.5 + [28.4500001, 1] => 28.5 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.5 + [-28.45, 1] => -28.5 + [-28.4500001, 1] => -28.5 + [153.90, 1] => 153.9 + [153.9000001, 1] => 154.0 + [153.95, 1] => 154.0 + [153.9500001, 1] => 154.0 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -154.0 + [-153.95, 1] => -154.0 +[-153.9500001, 1] => -154.0 + [0.000001, 3] => 0.001 + [0.0005, 3] => 0.001 + [0.000500, 3] => 0.001 + [0.000501, 3] => 0.001 + [-0.000001, 3] => -0.001 + [-0.0005, 3] => -0.001 + [-0.000500, 3] => -0.001 + [-0.000501, 3] => -0.001 diff --git a/ext/bcmath/tests/bcround_ceiling.phpt b/ext/bcmath/tests/bcround_ceiling.phpt new file mode 100644 index 0000000000000..a3f6b50e1f989 --- /dev/null +++ b/ext/bcmath/tests/bcround_ceiling.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_CEILING +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 2 + [1.2, 0] => 2 + [1.3, 0] => 2 + [1.4, 0] => 2 + [1.6, 0] => 2 + [1.7, 0] => 2 + [1.8, 0] => 2 + [1.9, 0] => 2 + [-1.1, 0] => -1 + [-1.2, 0] => -1 + [-1.3, 0] => -1 + [-1.4, 0] => -1 + [-1.6, 0] => -1 + [-1.7, 0] => -1 + [-1.8, 0] => -1 + [-1.9, 0] => -1 + +========== minus precision ========== + [50, -2] => 100 + [-50, -2] => 0 + [1230, -1] => 1230 + [1235, -1] => 1240 + [-1230, -1] => -1230 + [-1235, -1] => -1230 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3500 + [3450.0000, -2] => 3500 + [3450.0001, -2] => 3500 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3400 + [-3450.0000, -2] => -3400 + [-3450.0001, -2] => -3400 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1236 + [1235.5, 0] => 1236 + [1235.500001, 0] => 1236 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1235 + [-1235.5, 0] => -1235 +[-1235.500001, 0] => -1235 + [0.0001, 0] => 1 + [0.5, 0] => 1 + [0.5000, 0] => 1 + [0.5001, 0] => 1 + [-0.0001, 0] => 0 + [-0.5, 0] => 0 + [-0.5000, 0] => 0 + [-0.5001, 0] => 0 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.5 + [28.45, 1] => 28.5 + [28.4500001, 1] => 28.5 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.4 + [-28.45, 1] => -28.4 + [-28.4500001, 1] => -28.4 + [153.90, 1] => 153.9 + [153.9000001, 1] => 154.0 + [153.95, 1] => 154.0 + [153.9500001, 1] => 154.0 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -153.9 + [-153.95, 1] => -153.9 +[-153.9500001, 1] => -153.9 + [0.000001, 3] => 0.001 + [0.0005, 3] => 0.001 + [0.000500, 3] => 0.001 + [0.000501, 3] => 0.001 + [-0.000001, 3] => 0.000 + [-0.0005, 3] => 0.000 + [-0.000500, 3] => 0.000 + [-0.000501, 3] => 0.000 diff --git a/ext/bcmath/tests/bcround_early_return.phpt b/ext/bcmath/tests/bcround_early_return.phpt new file mode 100644 index 0000000000000..372545a22ffa1 --- /dev/null +++ b/ext/bcmath/tests/bcround_early_return.phpt @@ -0,0 +1,99 @@ +--TEST-- +bcround() function with early return +--EXTENSIONS-- +bcmath +--FILE-- + [], + 'PHP_ROUND_HALF_DOWN' => [], + 'PHP_ROUND_HALF_EVEN' => [], + 'PHP_ROUND_HALF_ODD' => [], + 'PHP_ROUND_FLOOR' => [], + 'PHP_ROUND_CEIL' => [], + 'PHP_ROUND_AWAY_FROM_ZERO' => [], + 'PHP_ROUND_TOWARD_ZERO' => [], +]; +foreach ($early_return_cases as [$num, $precision]) { + $result = str_pad("[{$num}, {$precision}]", 33, ' ', STR_PAD_LEFT) . ' => ' . bcround($num, $precision, PHP_ROUND_HALF_UP) . "\n"; + echo $result; + $results['PHP_ROUND_HALF_UP'][] = $result; +} + +echo "\n"; + +foreach ($otherModes as $mode) { + foreach ($early_return_cases as [$num, $precision]) { + $result = str_pad("[{$num}, {$precision}]", 33, ' ', STR_PAD_LEFT) . ' => ' . bcround($num, $precision, constant($mode)) . "\n"; + $results[$mode][] = $result; + } + + if ($results['PHP_ROUND_HALF_UP'] === $results[$mode]) { + echo str_pad($mode, 24, ' ', STR_PAD_LEFT) . ": result is same to PHP_ROUND_HALF_UP\n"; + } else { + echo str_pad($mode, 24, ' ', STR_PAD_LEFT) . ": result is not same to PHP_ROUND_HALF_UP, failed\n"; + } +} +?> +--EXPECT-- + [123, -4] => 0 + [123.123456, -4] => 0 + [123, 1] => 123.0 + [123.5, 1] => 123.5 + [123.5, 2] => 123.50 + [123.0000000000000000000001, 22] => 123.0000000000000000000001 + [123.0000000000000000000001, 23] => 123.00000000000000000000010 + [-123, -4] => 0 + [-123.123456, -4] => 0 + [-123, 1] => -123.0 + [-123.5, 1] => -123.5 + [-123.5, 2] => -123.50 +[-123.0000000000000000000001, 22] => -123.0000000000000000000001 +[-123.0000000000000000000001, 23] => -123.00000000000000000000010 + [0, 0] => 0 + [0.0, 0] => 0 + [0.0000, 0] => 0 + [-0, 0] => 0 + [-0.0, 0] => 0 + [-0.0000, 0] => 0 + + PHP_ROUND_HALF_DOWN: result is same to PHP_ROUND_HALF_UP + PHP_ROUND_HALF_EVEN: result is same to PHP_ROUND_HALF_UP + PHP_ROUND_HALF_ODD: result is same to PHP_ROUND_HALF_UP + PHP_ROUND_FLOOR: result is same to PHP_ROUND_HALF_UP + PHP_ROUND_CEILING: result is same to PHP_ROUND_HALF_UP +PHP_ROUND_AWAY_FROM_ZERO: result is same to PHP_ROUND_HALF_UP + PHP_ROUND_TOWARD_ZERO: result is same to PHP_ROUND_HALF_UP diff --git a/ext/bcmath/tests/bcround_error.phpt b/ext/bcmath/tests/bcround_error.phpt new file mode 100644 index 0000000000000..d411763b49326 --- /dev/null +++ b/ext/bcmath/tests/bcround_error.phpt @@ -0,0 +1,28 @@ +--TEST-- +bcround() function with error +--EXTENSIONS-- +bcmath +--FILE-- +getMessage()."\n"; +} + +try { + bcround('0.00.1'); +} catch (Throwable $e) { + echo $e->getMessage()."\n"; +} + +try { + bcround('0.001', 0, 1000); +} catch (Throwable $e) { + echo $e->getMessage()."\n"; +} +?> +--EXPECT-- +bcround(): Argument #1 ($num) is not well-formed +bcround(): Argument #1 ($num) is not well-formed +bcround(): Argument #3 ($mode) must be a valid rounding mode (PHP_ROUND_*) diff --git a/ext/bcmath/tests/bcround_floor.phpt b/ext/bcmath/tests/bcround_floor.phpt new file mode 100644 index 0000000000000..88d7fcd9dbb29 --- /dev/null +++ b/ext/bcmath/tests/bcround_floor.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_FLOOR +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 1 + [1.2, 0] => 1 + [1.3, 0] => 1 + [1.4, 0] => 1 + [1.6, 0] => 1 + [1.7, 0] => 1 + [1.8, 0] => 1 + [1.9, 0] => 1 + [-1.1, 0] => -2 + [-1.2, 0] => -2 + [-1.3, 0] => -2 + [-1.4, 0] => -2 + [-1.6, 0] => -2 + [-1.7, 0] => -2 + [-1.8, 0] => -2 + [-1.9, 0] => -2 + +========== minus precision ========== + [50, -2] => 0 + [-50, -2] => -100 + [1230, -1] => 1230 + [1235, -1] => 1230 + [-1230, -1] => -1230 + [-1235, -1] => -1240 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3400 + [3450.0000, -2] => 3400 + [3450.0001, -2] => 3400 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3500 + [-3450.0000, -2] => -3500 + [-3450.0001, -2] => -3500 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1235 + [1235.5, 0] => 1235 + [1235.500001, 0] => 1235 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1236 + [-1235.5, 0] => -1236 +[-1235.500001, 0] => -1236 + [0.0001, 0] => 0 + [0.5, 0] => 0 + [0.5000, 0] => 0 + [0.5001, 0] => 0 + [-0.0001, 0] => -1 + [-0.5, 0] => -1 + [-0.5000, 0] => -1 + [-0.5001, 0] => -1 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.4 + [28.45, 1] => 28.4 + [28.4500001, 1] => 28.4 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.5 + [-28.45, 1] => -28.5 + [-28.4500001, 1] => -28.5 + [153.90, 1] => 153.9 + [153.9000001, 1] => 153.9 + [153.95, 1] => 153.9 + [153.9500001, 1] => 153.9 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -154.0 + [-153.95, 1] => -154.0 +[-153.9500001, 1] => -154.0 + [0.000001, 3] => 0.000 + [0.0005, 3] => 0.000 + [0.000500, 3] => 0.000 + [0.000501, 3] => 0.000 + [-0.000001, 3] => -0.001 + [-0.0005, 3] => -0.001 + [-0.000500, 3] => -0.001 + [-0.000501, 3] => -0.001 diff --git a/ext/bcmath/tests/bcround_half_down.phpt b/ext/bcmath/tests/bcround_half_down.phpt new file mode 100644 index 0000000000000..03d3580248111 --- /dev/null +++ b/ext/bcmath/tests/bcround_half_down.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_HALF_DOWN +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 1 + [1.2, 0] => 1 + [1.3, 0] => 1 + [1.4, 0] => 1 + [1.6, 0] => 2 + [1.7, 0] => 2 + [1.8, 0] => 2 + [1.9, 0] => 2 + [-1.1, 0] => -1 + [-1.2, 0] => -1 + [-1.3, 0] => -1 + [-1.4, 0] => -1 + [-1.6, 0] => -2 + [-1.7, 0] => -2 + [-1.8, 0] => -2 + [-1.9, 0] => -2 + +========== minus precision ========== + [50, -2] => 0 + [-50, -2] => 0 + [1230, -1] => 1230 + [1235, -1] => 1230 + [-1230, -1] => -1230 + [-1235, -1] => -1230 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3400 + [3450.0000, -2] => 3400 + [3450.0001, -2] => 3500 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3400 + [-3450.0000, -2] => -3400 + [-3450.0001, -2] => -3500 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1235 + [1235.5, 0] => 1235 + [1235.500001, 0] => 1236 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1235 + [-1235.5, 0] => -1235 +[-1235.500001, 0] => -1236 + [0.0001, 0] => 0 + [0.5, 0] => 0 + [0.5000, 0] => 0 + [0.5001, 0] => 1 + [-0.0001, 0] => 0 + [-0.5, 0] => 0 + [-0.5000, 0] => 0 + [-0.5001, 0] => -1 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.4 + [28.45, 1] => 28.4 + [28.4500001, 1] => 28.5 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.4 + [-28.45, 1] => -28.4 + [-28.4500001, 1] => -28.5 + [153.90, 1] => 153.9 + [153.9000001, 1] => 153.9 + [153.95, 1] => 153.9 + [153.9500001, 1] => 154.0 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -153.9 + [-153.95, 1] => -153.9 +[-153.9500001, 1] => -154.0 + [0.000001, 3] => 0.000 + [0.0005, 3] => 0.000 + [0.000500, 3] => 0.000 + [0.000501, 3] => 0.001 + [-0.000001, 3] => 0.000 + [-0.0005, 3] => 0.000 + [-0.000500, 3] => 0.000 + [-0.000501, 3] => -0.001 diff --git a/ext/bcmath/tests/bcround_half_even.phpt b/ext/bcmath/tests/bcround_half_even.phpt new file mode 100644 index 0000000000000..955f0e14dcfd1 --- /dev/null +++ b/ext/bcmath/tests/bcround_half_even.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_HALF_EVEN +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 1 + [1.2, 0] => 1 + [1.3, 0] => 1 + [1.4, 0] => 1 + [1.6, 0] => 2 + [1.7, 0] => 2 + [1.8, 0] => 2 + [1.9, 0] => 2 + [-1.1, 0] => -1 + [-1.2, 0] => -1 + [-1.3, 0] => -1 + [-1.4, 0] => -1 + [-1.6, 0] => -2 + [-1.7, 0] => -2 + [-1.8, 0] => -2 + [-1.9, 0] => -2 + +========== minus precision ========== + [50, -2] => 0 + [-50, -2] => 0 + [1230, -1] => 1230 + [1235, -1] => 1240 + [-1230, -1] => -1230 + [-1235, -1] => -1240 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3400 + [3450.0000, -2] => 3400 + [3450.0001, -2] => 3500 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3400 + [-3450.0000, -2] => -3400 + [-3450.0001, -2] => -3500 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1235 + [1235.5, 0] => 1236 + [1235.500001, 0] => 1236 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1235 + [-1235.5, 0] => -1236 +[-1235.500001, 0] => -1236 + [0.0001, 0] => 0 + [0.5, 0] => 0 + [0.5000, 0] => 0 + [0.5001, 0] => 1 + [-0.0001, 0] => 0 + [-0.5, 0] => 0 + [-0.5000, 0] => 0 + [-0.5001, 0] => -1 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.4 + [28.45, 1] => 28.4 + [28.4500001, 1] => 28.5 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.4 + [-28.45, 1] => -28.4 + [-28.4500001, 1] => -28.5 + [153.90, 1] => 153.9 + [153.9000001, 1] => 153.9 + [153.95, 1] => 154.0 + [153.9500001, 1] => 154.0 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -153.9 + [-153.95, 1] => -154.0 +[-153.9500001, 1] => -154.0 + [0.000001, 3] => 0.000 + [0.0005, 3] => 0.000 + [0.000500, 3] => 0.000 + [0.000501, 3] => 0.001 + [-0.000001, 3] => 0.000 + [-0.0005, 3] => 0.000 + [-0.000500, 3] => 0.000 + [-0.000501, 3] => -0.001 diff --git a/ext/bcmath/tests/bcround_half_odd.phpt b/ext/bcmath/tests/bcround_half_odd.phpt new file mode 100644 index 0000000000000..941da75843f29 --- /dev/null +++ b/ext/bcmath/tests/bcround_half_odd.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_HALF_ODD +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 1 + [1.2, 0] => 1 + [1.3, 0] => 1 + [1.4, 0] => 1 + [1.6, 0] => 2 + [1.7, 0] => 2 + [1.8, 0] => 2 + [1.9, 0] => 2 + [-1.1, 0] => -1 + [-1.2, 0] => -1 + [-1.3, 0] => -1 + [-1.4, 0] => -1 + [-1.6, 0] => -2 + [-1.7, 0] => -2 + [-1.8, 0] => -2 + [-1.9, 0] => -2 + +========== minus precision ========== + [50, -2] => 100 + [-50, -2] => -100 + [1230, -1] => 1230 + [1235, -1] => 1230 + [-1230, -1] => -1230 + [-1235, -1] => -1230 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3400 + [3450.0000, -2] => 3500 + [3450.0001, -2] => 3500 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3400 + [-3450.0000, -2] => -3500 + [-3450.0001, -2] => -3500 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1235 + [1235.5, 0] => 1235 + [1235.500001, 0] => 1236 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1235 + [-1235.5, 0] => -1235 +[-1235.500001, 0] => -1236 + [0.0001, 0] => 0 + [0.5, 0] => 1 + [0.5000, 0] => 1 + [0.5001, 0] => 1 + [-0.0001, 0] => 0 + [-0.5, 0] => -1 + [-0.5000, 0] => -1 + [-0.5001, 0] => -1 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.4 + [28.45, 1] => 28.5 + [28.4500001, 1] => 28.5 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.4 + [-28.45, 1] => -28.5 + [-28.4500001, 1] => -28.5 + [153.90, 1] => 153.9 + [153.9000001, 1] => 153.9 + [153.95, 1] => 153.9 + [153.9500001, 1] => 154.0 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -153.9 + [-153.95, 1] => -153.9 +[-153.9500001, 1] => -154.0 + [0.000001, 3] => 0.000 + [0.0005, 3] => 0.001 + [0.000500, 3] => 0.001 + [0.000501, 3] => 0.001 + [-0.000001, 3] => 0.000 + [-0.0005, 3] => -0.001 + [-0.000500, 3] => -0.001 + [-0.000501, 3] => -0.001 diff --git a/ext/bcmath/tests/bcround_half_up.phpt b/ext/bcmath/tests/bcround_half_up.phpt new file mode 100644 index 0000000000000..17c02c717e3a2 --- /dev/null +++ b/ext/bcmath/tests/bcround_half_up.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_HALF_UP +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 1 + [1.2, 0] => 1 + [1.3, 0] => 1 + [1.4, 0] => 1 + [1.6, 0] => 2 + [1.7, 0] => 2 + [1.8, 0] => 2 + [1.9, 0] => 2 + [-1.1, 0] => -1 + [-1.2, 0] => -1 + [-1.3, 0] => -1 + [-1.4, 0] => -1 + [-1.6, 0] => -2 + [-1.7, 0] => -2 + [-1.8, 0] => -2 + [-1.9, 0] => -2 + +========== minus precision ========== + [50, -2] => 100 + [-50, -2] => -100 + [1230, -1] => 1230 + [1235, -1] => 1240 + [-1230, -1] => -1230 + [-1235, -1] => -1240 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3400 + [3450.0000, -2] => 3500 + [3450.0001, -2] => 3500 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3400 + [-3450.0000, -2] => -3500 + [-3450.0001, -2] => -3500 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1235 + [1235.5, 0] => 1236 + [1235.500001, 0] => 1236 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1235 + [-1235.5, 0] => -1236 +[-1235.500001, 0] => -1236 + [0.0001, 0] => 0 + [0.5, 0] => 1 + [0.5000, 0] => 1 + [0.5001, 0] => 1 + [-0.0001, 0] => 0 + [-0.5, 0] => -1 + [-0.5000, 0] => -1 + [-0.5001, 0] => -1 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.4 + [28.45, 1] => 28.5 + [28.4500001, 1] => 28.5 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.4 + [-28.45, 1] => -28.5 + [-28.4500001, 1] => -28.5 + [153.90, 1] => 153.9 + [153.9000001, 1] => 153.9 + [153.95, 1] => 154.0 + [153.9500001, 1] => 154.0 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -153.9 + [-153.95, 1] => -154.0 +[-153.9500001, 1] => -154.0 + [0.000001, 3] => 0.000 + [0.0005, 3] => 0.001 + [0.000500, 3] => 0.001 + [0.000501, 3] => 0.001 + [-0.000001, 3] => 0.000 + [-0.0005, 3] => -0.001 + [-0.000500, 3] => -0.001 + [-0.000501, 3] => -0.001 diff --git a/ext/bcmath/tests/bcround_test_helper.inc b/ext/bcmath/tests/bcround_test_helper.inc new file mode 100644 index 0000000000000..c51efc46581b3 --- /dev/null +++ b/ext/bcmath/tests/bcround_test_helper.inc @@ -0,0 +1,108 @@ + ", bcround($num, $precision, $mode), "\n"; + } + echo "\n"; +} + +function run_round_test(int $mode) +{ + $non_boundary_value_cases = [ + ['1.1', 0], + ['1.2', 0], + ['1.3', 0], + ['1.4', 0], + ['1.6', 0], + ['1.7', 0], + ['1.8', 0], + ['1.9', 0], + ['-1.1', 0], + ['-1.2', 0], + ['-1.3', 0], + ['-1.4', 0], + ['-1.6', 0], + ['-1.7', 0], + ['-1.8', 0], + ['-1.9', 0], + ]; + + $minus_precision_cases = [ + ['50', -2], + ['-50', -2], + ['1230', -1], + ['1235', -1], + ['-1230', -1], + ['-1235', -1], + ['3400.0000', -2], + ['3400.0001', -2], + ['3450.0000', -2], + ['3450.0001', -2], + ['-3400.0000', -2], + ['-3400.0001', -2], + ['-3450.0000', -2], + ['-3450.0001', -2], + ]; + + $zero_precision_cases = [ + ['1235', 0], + ['1235.0', 0], + ['1235.000001', 0], + ['1235.5', 0], + ['1235.500001', 0], + ['-1235', 0], + ['-1235.0', 0], + ['-1235.000001', 0], + ['-1235.5', 0], + ['-1235.500001', 0], + ['0.0001', 0], + ['0.5', 0], + ['0.5000', 0], + ['0.5001', 0], + ['-0.0001', 0], + ['-0.5', 0], + ['-0.5000', 0], + ['-0.5001', 0], + ]; + + $plus_precision_cases = [ + ['28.40', 1], + ['28.4000001', 1], + ['28.45', 1], + ['28.4500001', 1], + ['-28.40', 1], + ['-28.4000001', 1], + ['-28.45', 1], + ['-28.4500001', 1], + ['153.90', 1], + ['153.9000001', 1], + ['153.95', 1], + ['153.9500001', 1], + ['-153.90', 1], + ['-153.9000001', 1], + ['-153.95', 1], + ['-153.9500001', 1], + ['0.000001', 3], + ['0.0005', 3], + ['0.000500', 3], + ['0.000501', 3], + ['-0.000001', 3], + ['-0.0005', 3], + ['-0.000500', 3], + ['-0.000501', 3], + ]; + + echo "========== non-boundary value ==========\n"; + printResult($non_boundary_value_cases, $mode); + + echo "========== minus precision ==========\n"; + printResult($minus_precision_cases, $mode); + + echo "========== zero precision ==========\n"; + printResult($zero_precision_cases, $mode); + + echo "========== plus precision ==========\n"; + printResult($plus_precision_cases, $mode); +} diff --git a/ext/bcmath/tests/bcround_toward_zero.phpt b/ext/bcmath/tests/bcround_toward_zero.phpt new file mode 100644 index 0000000000000..e9d0e277efe6e --- /dev/null +++ b/ext/bcmath/tests/bcround_toward_zero.phpt @@ -0,0 +1,89 @@ +--TEST-- +bcround() function PHP_ROUND_TOWARD_ZERO +--EXTENSIONS-- +bcmath +--FILE-- + +--EXPECT-- +========== non-boundary value ========== + [1.1, 0] => 1 + [1.2, 0] => 1 + [1.3, 0] => 1 + [1.4, 0] => 1 + [1.6, 0] => 1 + [1.7, 0] => 1 + [1.8, 0] => 1 + [1.9, 0] => 1 + [-1.1, 0] => -1 + [-1.2, 0] => -1 + [-1.3, 0] => -1 + [-1.4, 0] => -1 + [-1.6, 0] => -1 + [-1.7, 0] => -1 + [-1.8, 0] => -1 + [-1.9, 0] => -1 + +========== minus precision ========== + [50, -2] => 0 + [-50, -2] => 0 + [1230, -1] => 1230 + [1235, -1] => 1230 + [-1230, -1] => -1230 + [-1235, -1] => -1230 + [3400.0000, -2] => 3400 + [3400.0001, -2] => 3400 + [3450.0000, -2] => 3400 + [3450.0001, -2] => 3400 + [-3400.0000, -2] => -3400 + [-3400.0001, -2] => -3400 + [-3450.0000, -2] => -3400 + [-3450.0001, -2] => -3400 + +========== zero precision ========== + [1235, 0] => 1235 + [1235.0, 0] => 1235 + [1235.000001, 0] => 1235 + [1235.5, 0] => 1235 + [1235.500001, 0] => 1235 + [-1235, 0] => -1235 + [-1235.0, 0] => -1235 +[-1235.000001, 0] => -1235 + [-1235.5, 0] => -1235 +[-1235.500001, 0] => -1235 + [0.0001, 0] => 0 + [0.5, 0] => 0 + [0.5000, 0] => 0 + [0.5001, 0] => 0 + [-0.0001, 0] => 0 + [-0.5, 0] => 0 + [-0.5000, 0] => 0 + [-0.5001, 0] => 0 + +========== plus precision ========== + [28.40, 1] => 28.4 + [28.4000001, 1] => 28.4 + [28.45, 1] => 28.4 + [28.4500001, 1] => 28.4 + [-28.40, 1] => -28.4 + [-28.4000001, 1] => -28.4 + [-28.45, 1] => -28.4 + [-28.4500001, 1] => -28.4 + [153.90, 1] => 153.9 + [153.9000001, 1] => 153.9 + [153.95, 1] => 153.9 + [153.9500001, 1] => 153.9 + [-153.90, 1] => -153.9 +[-153.9000001, 1] => -153.9 + [-153.95, 1] => -153.9 +[-153.9500001, 1] => -153.9 + [0.000001, 3] => 0.000 + [0.0005, 3] => 0.000 + [0.000500, 3] => 0.000 + [0.000501, 3] => 0.000 + [-0.000001, 3] => 0.000 + [-0.0005, 3] => 0.000 + [-0.000500, 3] => 0.000 + [-0.000501, 3] => 0.000 diff --git a/ext/curl/curl_private.h b/ext/curl/curl_private.h index aeef5937a0de8..c15396f255b17 100644 --- a/ext/curl/curl_private.h +++ b/ext/curl/curl_private.h @@ -45,8 +45,7 @@ PHP_MSHUTDOWN_FUNCTION(curl); PHP_MINFO_FUNCTION(curl); typedef struct { - zval func_name; - zend_fcall_info_cache fci_cache; + zend_fcall_info_cache fcc; FILE *fp; smart_str buf; int method; @@ -54,29 +53,23 @@ typedef struct { } php_curl_write; typedef struct { - zval func_name; - zend_fcall_info_cache fci_cache; + zend_fcall_info_cache fcc; FILE *fp; zend_resource *res; int method; zval stream; } php_curl_read; -typedef struct { - zval func_name; - zend_fcall_info_cache fci_cache; -} php_curl_callback; - typedef struct { php_curl_write *write; php_curl_write *write_header; php_curl_read *read; zval std_err; - php_curl_callback *progress; - php_curl_callback *xferinfo; - php_curl_callback *fnmatch; + zend_fcall_info_cache progress; + zend_fcall_info_cache xferinfo; + zend_fcall_info_cache fnmatch; #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ - php_curl_callback *sshhostkey; + zend_fcall_info_cache sshhostkey; #endif } php_curl_handlers; @@ -114,7 +107,7 @@ typedef struct { #define CURLOPT_SAFE_UPLOAD -1 typedef struct { - php_curl_callback *server_push; + zend_fcall_info_cache server_push; } php_curlm_handlers; typedef struct { diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 60481947dddea..7b6107d4814f2 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -474,35 +474,41 @@ static HashTable *curl_get_gc(zend_object *object, zval **table, int *n) zend_get_gc_buffer_add_zval(gc_buffer, &curl->postfields); if (curl->handlers.read) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.read->func_name); + if (ZEND_FCC_INITIALIZED(curl->handlers.read->fcc)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl->handlers.read->fcc); + } zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.read->stream); } if (curl->handlers.write) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write->func_name); + if (ZEND_FCC_INITIALIZED(curl->handlers.write->fcc)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl->handlers.write->fcc); + } zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write->stream); } if (curl->handlers.write_header) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write_header->func_name); + if (ZEND_FCC_INITIALIZED(curl->handlers.write_header->fcc)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl->handlers.write_header->fcc); + } zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.write_header->stream); } - if (curl->handlers.progress) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.progress->func_name); + if (ZEND_FCC_INITIALIZED(curl->handlers.progress)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl->handlers.progress); } - if (curl->handlers.xferinfo) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.xferinfo->func_name); + if (ZEND_FCC_INITIALIZED(curl->handlers.xferinfo)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl->handlers.xferinfo); } - if (curl->handlers.fnmatch) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.fnmatch->func_name); + if (ZEND_FCC_INITIALIZED(curl->handlers.fnmatch)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl->handlers.fnmatch); } #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ - if (curl->handlers.sshhostkey) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl->handlers.sshhostkey->func_name); + if (ZEND_FCC_INITIALIZED(curl->handlers.sshhostkey)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl->handlers.sshhostkey); } #endif @@ -550,20 +556,11 @@ PHP_MSHUTDOWN_FUNCTION(curl) } /* }}} */ -/* {{{ curl_write_nothing - * Used as a work around. See _php_curl_close_ex - */ -static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ctx) -{ - return size * nmemb; -} -/* }}} */ - /* {{{ curl_write */ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) { php_curl *ch = (php_curl *) ctx; - php_curl_write *t = ch->handlers.write; + php_curl_write *write_handler = ch->handlers.write; size_t length = size * nmemb; #if PHP_CURL_DEBUG @@ -571,43 +568,31 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) fprintf(stderr, "data = %s, size = %d, nmemb = %d, ctx = %x\n", data, size, nmemb, ctx); #endif - switch (t->method) { + switch (write_handler->method) { case PHP_CURL_STDOUT: PHPWRITE(data, length); break; case PHP_CURL_FILE: - return fwrite(data, size, nmemb, t->fp); + return fwrite(data, size, nmemb, write_handler->fp); case PHP_CURL_RETURN: if (length > 0) { - smart_str_appendl(&t->buf, data, (int) length); + smart_str_appendl(&write_handler->buf, data, (int) length); } break; case PHP_CURL_USER: { zval argv[2]; zval retval; - int error; - zend_fcall_info fci; GC_ADDREF(&ch->std); ZVAL_OBJ(&argv[0], &ch->std); ZVAL_STRINGL(&argv[1], data, length); - fci.size = sizeof(fci); - fci.object = NULL; - ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); - fci.retval = &retval; - fci.param_count = 2; - fci.params = argv; - fci.named_params = NULL; - - ch->in_callback = 1; - error = zend_call_function(&fci, &t->fci_cache); - ch->in_callback = 0; - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_WRITEFUNCTION"); - length = -1; - } else if (!Z_ISUNDEF(retval)) { + ch->in_callback = true; + zend_call_known_fcc(&write_handler->fcc, &retval, /* param_count */ 2, argv, /* named_params */ NULL); + ch->in_callback = false; + if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, /* reporterror */ true); + /* TODO Check callback returns an int or something castable to int */ length = zval_get_long(&retval); } @@ -625,33 +610,22 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx) static int curl_fnmatch(void *ctx, const char *pattern, const char *string) { php_curl *ch = (php_curl *) ctx; - php_curl_callback *t = ch->handlers.fnmatch; int rval = CURL_FNMATCHFUNC_FAIL; zval argv[3]; zval retval; - zend_result error; - zend_fcall_info fci; GC_ADDREF(&ch->std); ZVAL_OBJ(&argv[0], &ch->std); ZVAL_STRING(&argv[1], pattern); ZVAL_STRING(&argv[2], string); - fci.size = sizeof(fci); - ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); - fci.object = NULL; - fci.retval = &retval; - fci.param_count = 3; - fci.params = argv; - fci.named_params = NULL; - - ch->in_callback = 1; - error = zend_call_function(&fci, &t->fci_cache); - ch->in_callback = 0; - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION"); - } else if (!Z_ISUNDEF(retval)) { + ch->in_callback = true; + zend_call_known_fcc(&ch->handlers.fnmatch, &retval, /* param_count */ 3, argv, /* named_params */ NULL); + ch->in_callback = false; + + if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, /* reporterror */ true); + /* TODO Check callback returns an int or something castable to int */ rval = zval_get_long(&retval); } zval_ptr_dtor(&argv[0]); @@ -665,7 +639,6 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string) static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { php_curl *ch = (php_curl *)clientp; - php_curl_callback *t = ch->handlers.progress; size_t rval = 0; #if PHP_CURL_DEBUG @@ -673,38 +646,29 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow); #endif - zval argv[5]; + zval args[5]; zval retval; - zend_result error; - zend_fcall_info fci; GC_ADDREF(&ch->std); - ZVAL_OBJ(&argv[0], &ch->std); - ZVAL_LONG(&argv[1], (zend_long)dltotal); - ZVAL_LONG(&argv[2], (zend_long)dlnow); - ZVAL_LONG(&argv[3], (zend_long)ultotal); - ZVAL_LONG(&argv[4], (zend_long)ulnow); - - fci.size = sizeof(fci); - ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); - fci.object = NULL; - fci.retval = &retval; - fci.param_count = 5; - fci.params = argv; - fci.named_params = NULL; - - ch->in_callback = 1; - error = zend_call_function(&fci, &t->fci_cache); - ch->in_callback = 0; - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION"); - } else if (!Z_ISUNDEF(retval)) { + ZVAL_OBJ(&args[0], &ch->std); + ZVAL_LONG(&args[1], (zend_long)dltotal); + ZVAL_LONG(&args[2], (zend_long)dlnow); + ZVAL_LONG(&args[3], (zend_long)ultotal); + ZVAL_LONG(&args[4], (zend_long)ulnow); + + ch->in_callback = true; + zend_call_known_fcc(&ch->handlers.progress, &retval, /* param_count */ 5, args, /* named_params */ NULL); + ch->in_callback = false; + + if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, /* reporterror */ true); + /* TODO Check callback returns an int or something castable to int */ if (0 != zval_get_long(&retval)) { rval = 1; } } - zval_ptr_dtor(&argv[0]); + + zval_ptr_dtor(&args[0]); return rval; } /* }}} */ @@ -713,7 +677,6 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { php_curl *ch = (php_curl *)clientp; - php_curl_callback *t = ch->handlers.xferinfo; size_t rval = 0; #if PHP_CURL_DEBUG @@ -723,8 +686,6 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, zval argv[5]; zval retval; - zend_result error; - zend_fcall_info fci; GC_ADDREF(&ch->std); ZVAL_OBJ(&argv[0], &ch->std); @@ -733,25 +694,18 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, ZVAL_LONG(&argv[3], ultotal); ZVAL_LONG(&argv[4], ulnow); - fci.size = sizeof(fci); - ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); - fci.object = NULL; - fci.retval = &retval; - fci.param_count = 5; - fci.params = argv; - fci.named_params = NULL; - - ch->in_callback = 1; - error = zend_call_function(&fci, &t->fci_cache); - ch->in_callback = 0; - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_XFERINFOFUNCTION"); - } else if (!Z_ISUNDEF(retval)) { + ch->in_callback = true; + zend_call_known_fcc(&ch->handlers.xferinfo, &retval, /* param_count */ 5, argv, /* named_params */ NULL); + ch->in_callback = false; + + if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, /* reporterror */ true); + /* TODO Check callback returns an int or something castable to int */ if (0 != zval_get_long(&retval)) { rval = 1; } } + zval_ptr_dtor(&argv[0]); return rval; } @@ -761,7 +715,6 @@ static size_t curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key, size_t keylen) { php_curl *ch = (php_curl *)clientp; - php_curl_callback *t = ch->handlers.sshhostkey; int rval = CURLKHMATCH_MISMATCH; /* cancel connection in case of an exception */ #if PHP_CURL_DEBUG @@ -769,31 +722,20 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key, fprintf(stderr, "clientp = %x, keytype = %d, key = %s, keylen = %zu\n", clientp, keytype, key, keylen); #endif - zval argv[4]; + zval args[4]; zval retval; - zend_result error; - zend_fcall_info fci; GC_ADDREF(&ch->std); - ZVAL_OBJ(&argv[0], &ch->std); - ZVAL_LONG(&argv[1], keytype); - ZVAL_STRINGL(&argv[2], key, keylen); - ZVAL_LONG(&argv[3], keylen); - - fci.size = sizeof(fci); - ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); - fci.object = NULL; - fci.retval = &retval; - fci.param_count = 4; - fci.params = argv; - fci.named_params = NULL; - - ch->in_callback = 1; - error = zend_call_function(&fci, &t->fci_cache); - ch->in_callback = 0; - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_SSH_HOSTKEYFUNCTION"); - } else if (!Z_ISUNDEF(retval)) { + ZVAL_OBJ(&args[0], &ch->std); + ZVAL_LONG(&args[1], keytype); + ZVAL_STRINGL(&args[2], key, keylen); + ZVAL_LONG(&args[3], keylen); + + ch->in_callback = true; + zend_call_known_fcc(&ch->handlers.sshhostkey, &retval, /* param_count */ 4, args, /* named_params */ NULL); + ch->in_callback = false; + + if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, /* reporterror */ true); if (Z_TYPE(retval) == IS_LONG) { zend_long retval_long = Z_LVAL(retval); @@ -806,8 +748,9 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key, zend_throw_error(NULL, "The CURLOPT_SSH_HOSTKEYFUNCTION callback must return either CURLKHMATCH_OK or CURLKHMATCH_MISMATCH"); } } - zval_ptr_dtor(&argv[0]); - zval_ptr_dtor(&argv[2]); + + zval_ptr_dtor(&args[0]); + zval_ptr_dtor(&args[2]); return rval; } #endif @@ -816,46 +759,33 @@ static int curl_ssh_hostkeyfunction(void *clientp, int keytype, const char *key, static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) { php_curl *ch = (php_curl *)ctx; - php_curl_read *t = ch->handlers.read; + php_curl_read *read_handler = ch->handlers.read; int length = 0; - switch (t->method) { + switch (read_handler->method) { case PHP_CURL_DIRECT: - if (t->fp) { - length = fread(data, size, nmemb, t->fp); + if (read_handler->fp) { + length = fread(data, size, nmemb, read_handler->fp); } break; case PHP_CURL_USER: { zval argv[3]; zval retval; - zend_result error; - zend_fcall_info fci; GC_ADDREF(&ch->std); ZVAL_OBJ(&argv[0], &ch->std); - if (t->res) { - GC_ADDREF(t->res); - ZVAL_RES(&argv[1], t->res); + if (read_handler->res) { + GC_ADDREF(read_handler->res); + ZVAL_RES(&argv[1], read_handler->res); } else { ZVAL_NULL(&argv[1]); } ZVAL_LONG(&argv[2], (int)size * nmemb); - fci.size = sizeof(fci); - ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); - fci.object = NULL; - fci.retval = &retval; - fci.param_count = 3; - fci.params = argv; - fci.named_params = NULL; - - ch->in_callback = 1; - error = zend_call_function(&fci, &t->fci_cache); - ch->in_callback = 0; - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_READFUNCTION"); - length = CURL_READFUNC_ABORT; - } else if (!Z_ISUNDEF(retval)) { + ch->in_callback = true; + zend_call_known_fcc(&read_handler->fcc, &retval, /* param_count */ 3, argv, /* named_params */ NULL); + ch->in_callback = false; + if (!Z_ISUNDEF(retval)) { _php_curl_verify_handlers(ch, /* reporterror */ true); if (Z_TYPE(retval) == IS_STRING) { length = MIN((int) (size * nmemb), Z_STRLEN(retval)); @@ -863,6 +793,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) } else if (Z_TYPE(retval) == IS_LONG) { length = Z_LVAL_P(&retval); } + // TODO Do type error if invalid type? zval_ptr_dtor(&retval); } @@ -880,10 +811,10 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx) static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx) { php_curl *ch = (php_curl *) ctx; - php_curl_write *t = ch->handlers.write_header; + php_curl_write *write_handler = ch->handlers.write_header; size_t length = size * nmemb; - switch (t->method) { + switch (write_handler->method) { case PHP_CURL_STDOUT: /* Handle special case write when we're returning the entire transfer */ @@ -894,32 +825,20 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx } break; case PHP_CURL_FILE: - return fwrite(data, size, nmemb, t->fp); + return fwrite(data, size, nmemb, write_handler->fp); case PHP_CURL_USER: { zval argv[2]; zval retval; - zend_result error; - zend_fcall_info fci; GC_ADDREF(&ch->std); ZVAL_OBJ(&argv[0], &ch->std); ZVAL_STRINGL(&argv[1], data, length); - fci.size = sizeof(fci); - ZVAL_COPY_VALUE(&fci.function_name, &t->func_name); - fci.object = NULL; - fci.retval = &retval; - fci.param_count = 2; - fci.params = argv; - fci.named_params = NULL; - - ch->in_callback = 1; - error = zend_call_function(&fci, &t->fci_cache); - ch->in_callback = 0; - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_HEADERFUNCTION"); - length = -1; - } else if (!Z_ISUNDEF(retval)) { + ch->in_callback = true; + zend_call_known_fcc(&write_handler->fcc, &retval, /* param_count */ 2, argv, /* named_params */ NULL); + ch->in_callback = false; + if (!Z_ISUNDEF(retval)) { + // TODO: Check for valid int type for return value _php_curl_verify_handlers(ch, /* reporterror */ true); length = zval_get_long(&retval); } @@ -1004,8 +923,8 @@ PHP_FUNCTION(curl_version) /* Add an array of features */ { struct feat { - const char *name; - int bitmask; + const char *name; + int bitmask; }; unsigned int i; @@ -1055,7 +974,7 @@ PHP_FUNCTION(curl_version) #endif }; - for(i = 0; i < sizeof(feats) / sizeof(feats[0]); i++) { + for(i = 0; i < sizeof(feats) / sizeof(feats[0]); i++) { if (feats[i].name) { add_assoc_bool(&feature_list, feats[i].name, d->features & feats[i].bitmask ? true : false); } @@ -1117,11 +1036,11 @@ void init_curl_handle(php_curl *ch) ch->handlers.write = ecalloc(1, sizeof(php_curl_write)); ch->handlers.write_header = ecalloc(1, sizeof(php_curl_write)); ch->handlers.read = ecalloc(1, sizeof(php_curl_read)); - ch->handlers.progress = NULL; - ch->handlers.xferinfo = NULL; - ch->handlers.fnmatch = NULL; + ch->handlers.progress = empty_fcall_info_cache; + ch->handlers.xferinfo = empty_fcall_info_cache; + ch->handlers.fnmatch = empty_fcall_info_cache; #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ - ch->handlers.sshhostkey = NULL; + ch->handlers.sshhostkey = empty_fcall_info_cache; #endif ch->clone = emalloc(sizeof(uint32_t)); *ch->clone = 1; @@ -1243,13 +1162,10 @@ PHP_FUNCTION(curl_init) } /* }}} */ -static void _php_copy_callback(php_curl *ch, php_curl_callback **new_callback, php_curl_callback *source_callback, CURLoption option) +static void php_curl_copy_fcc_with_option(php_curl *ch, CURLoption option, zend_fcall_info_cache *target_fcc, zend_fcall_info_cache *source_fcc) { - if (source_callback) { - *new_callback = ecalloc(1, sizeof(php_curl_callback)); - if (!Z_ISUNDEF(source_callback->func_name)) { - ZVAL_COPY(&(*new_callback)->func_name, &source_callback->func_name); - } + if (ZEND_FCC_INITIALIZED(*source_fcc)) { + zend_fcc_dup(target_fcc, source_fcc); curl_easy_setopt(ch->cp, option, (void *) ch); } } @@ -1277,14 +1193,14 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source) ch->handlers.read->fp = source->handlers.read->fp; ch->handlers.read->res = source->handlers.read->res; - if (!Z_ISUNDEF(source->handlers.write->func_name)) { - ZVAL_COPY(&ch->handlers.write->func_name, &source->handlers.write->func_name); + if (ZEND_FCC_INITIALIZED(source->handlers.read->fcc)) { + zend_fcc_dup(&source->handlers.read->fcc, &source->handlers.read->fcc); } - if (!Z_ISUNDEF(source->handlers.read->func_name)) { - ZVAL_COPY(&ch->handlers.read->func_name, &source->handlers.read->func_name); + if (ZEND_FCC_INITIALIZED(source->handlers.write->fcc)) { + zend_fcc_dup(&source->handlers.write->fcc, &source->handlers.write->fcc); } - if (!Z_ISUNDEF(source->handlers.write_header->func_name)) { - ZVAL_COPY(&ch->handlers.write_header->func_name, &source->handlers.write_header->func_name); + if (ZEND_FCC_INITIALIZED(source->handlers.write_header->fcc)) { + zend_fcc_dup(&source->handlers.write_header->fcc, &source->handlers.write_header->fcc); } curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); @@ -1293,11 +1209,11 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source) curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); curl_easy_setopt(ch->cp, CURLOPT_DEBUGDATA, (void *) ch); - _php_copy_callback(ch, &ch->handlers.progress, source->handlers.progress, CURLOPT_PROGRESSDATA); - _php_copy_callback(ch, &ch->handlers.xferinfo, source->handlers.xferinfo, CURLOPT_XFERINFODATA); - _php_copy_callback(ch, &ch->handlers.fnmatch, source->handlers.fnmatch, CURLOPT_FNMATCH_DATA); + php_curl_copy_fcc_with_option(ch, CURLOPT_PROGRESSDATA, &ch->handlers.progress, &source->handlers.progress); + php_curl_copy_fcc_with_option(ch, CURLOPT_XFERINFODATA, &ch->handlers.xferinfo, &source->handlers.xferinfo); + php_curl_copy_fcc_with_option(ch, CURLOPT_FNMATCH_DATA, &ch->handlers.fnmatch, &source->handlers.fnmatch); #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ - _php_copy_callback(ch, &ch->handlers.sshhostkey, source->handlers.sshhostkey, CURLOPT_SSH_HOSTKEYDATA); + php_curl_copy_fcc_with_option(ch, CURLOPT_SSH_HOSTKEYDATA, &ch->handlers.sshhostkey, &source->handlers.sshhostkey); #endif ZVAL_COPY(&ch->private_data, &source->private_data); @@ -1598,12 +1514,68 @@ PHP_FUNCTION(curl_copy_handle) } /* }}} */ +static bool php_curl_set_callable_handler(zend_fcall_info_cache *const handler_fcc, zval *callable, bool is_array_config, const char *option_name) +{ + if (ZEND_FCC_INITIALIZED(*handler_fcc)) { + zend_fcc_dtor(handler_fcc); + } + + if (Z_TYPE_P(callable) == IS_NULL) { + return true; + } + + char *error = NULL; + if (UNEXPECTED(!zend_is_callable_ex(callable, /* object */ NULL, /* check_flags */ 0, /* callable_name */ NULL, handler_fcc, /* error */ &error))) { + if (!EG(exception)) { + zend_argument_type_error(2 + !is_array_config, "must be a valid callback for option %s, %s", option_name, error); + } + efree(error); + return false; + } + zend_fcc_addref(handler_fcc); + return true; +} + + +#define HANDLE_CURL_OPTION_CALLABLE_PHP_CURL_USER(curl_ptr, constant_no_function, handler_type) \ + case constant_no_function##FUNCTION: { \ + bool result = php_curl_set_callable_handler(&curl_ptr->handlers.handler_type->fcc, zvalue, is_array_config, #constant_no_function "FUNCTION"); \ + if (!result) { \ + return FAILURE; \ + } \ + curl_ptr->handlers.handler_type->method = PHP_CURL_USER; \ + break; \ + } + +#define HANDLE_CURL_OPTION_CALLABLE(curl_ptr, constant_no_function, handler_fcc, c_callback) \ + case constant_no_function##FUNCTION: { \ + bool result = php_curl_set_callable_handler(&curl_ptr->handler_fcc, zvalue, is_array_config, #constant_no_function "FUNCTION"); \ + if (!result) { \ + return FAILURE; \ + } \ + curl_easy_setopt(curl_ptr->cp, constant_no_function##FUNCTION, (c_callback)); \ + curl_easy_setopt(curl_ptr->cp, constant_no_function##DATA, curl_ptr); \ + break; \ + } + static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool is_array_config) /* {{{ */ { CURLcode error = CURLE_OK; zend_long lval; switch (option) { + /* Callable options */ + HANDLE_CURL_OPTION_CALLABLE_PHP_CURL_USER(ch, CURLOPT_WRITE, write); + HANDLE_CURL_OPTION_CALLABLE_PHP_CURL_USER(ch, CURLOPT_HEADER, write_header); + HANDLE_CURL_OPTION_CALLABLE_PHP_CURL_USER(ch, CURLOPT_READ, read); + + HANDLE_CURL_OPTION_CALLABLE(ch, CURLOPT_PROGRESS, handlers.progress, curl_progress); + HANDLE_CURL_OPTION_CALLABLE(ch, CURLOPT_XFERINFO, handlers.xferinfo, curl_xferinfo); + HANDLE_CURL_OPTION_CALLABLE(ch, CURLOPT_FNMATCH_, handlers.fnmatch, curl_fnmatch); +#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ + HANDLE_CURL_OPTION_CALLABLE(ch, CURLOPT_SSH_HOSTKEY, handlers.sshhostkey, curl_ssh_hostkeyfunction); +#endif + /* Long options */ case CURLOPT_SSL_VERIFYHOST: lval = zval_get_long(zvalue); @@ -2113,15 +2085,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue error = curl_easy_setopt(ch->cp, option, lval); break; - case CURLOPT_HEADERFUNCTION: - if (!Z_ISUNDEF(ch->handlers.write_header->func_name)) { - zval_ptr_dtor(&ch->handlers.write_header->func_name); - ch->handlers.write_header->fci_cache = empty_fcall_info_cache; - } - ZVAL_COPY(&ch->handlers.write_header->func_name, zvalue); - ch->handlers.write_header->method = PHP_CURL_USER; - break; - case CURLOPT_POSTFIELDS: if (Z_TYPE_P(zvalue) == IS_ARRAY) { if (zend_hash_num_elements(HASH_OF(zvalue)) == 0) { @@ -2142,41 +2105,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue } break; - case CURLOPT_PROGRESSFUNCTION: - curl_easy_setopt(ch->cp, CURLOPT_PROGRESSFUNCTION, curl_progress); - curl_easy_setopt(ch->cp, CURLOPT_PROGRESSDATA, ch); - if (ch->handlers.progress == NULL) { - ch->handlers.progress = ecalloc(1, sizeof(php_curl_callback)); - } else if (!Z_ISUNDEF(ch->handlers.progress->func_name)) { - zval_ptr_dtor(&ch->handlers.progress->func_name); - ch->handlers.progress->fci_cache = empty_fcall_info_cache; - } - ZVAL_COPY(&ch->handlers.progress->func_name, zvalue); - break; - -#if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ - case CURLOPT_SSH_HOSTKEYFUNCTION: - curl_easy_setopt(ch->cp, CURLOPT_SSH_HOSTKEYFUNCTION, curl_ssh_hostkeyfunction); - curl_easy_setopt(ch->cp, CURLOPT_SSH_HOSTKEYDATA, ch); - if (ch->handlers.sshhostkey == NULL) { - ch->handlers.sshhostkey = ecalloc(1, sizeof(php_curl_callback)); - } else if (!Z_ISUNDEF(ch->handlers.sshhostkey->func_name)) { - zval_ptr_dtor(&ch->handlers.sshhostkey->func_name); - ch->handlers.sshhostkey->fci_cache = empty_fcall_info_cache; - } - ZVAL_COPY(&ch->handlers.sshhostkey->func_name, zvalue); - break; -#endif - - case CURLOPT_READFUNCTION: - if (!Z_ISUNDEF(ch->handlers.read->func_name)) { - zval_ptr_dtor(&ch->handlers.read->func_name); - ch->handlers.read->fci_cache = empty_fcall_info_cache; - } - ZVAL_COPY(&ch->handlers.read->func_name, zvalue); - ch->handlers.read->method = PHP_CURL_USER; - break; - case CURLOPT_RETURNTRANSFER: if (zend_is_true(zvalue)) { ch->handlers.write->method = PHP_CURL_RETURN; @@ -2185,27 +2113,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue } break; - case CURLOPT_WRITEFUNCTION: - if (!Z_ISUNDEF(ch->handlers.write->func_name)) { - zval_ptr_dtor(&ch->handlers.write->func_name); - ch->handlers.write->fci_cache = empty_fcall_info_cache; - } - ZVAL_COPY(&ch->handlers.write->func_name, zvalue); - ch->handlers.write->method = PHP_CURL_USER; - break; - - case CURLOPT_XFERINFOFUNCTION: - curl_easy_setopt(ch->cp, CURLOPT_XFERINFOFUNCTION, curl_xferinfo); - curl_easy_setopt(ch->cp, CURLOPT_XFERINFODATA, ch); - if (ch->handlers.xferinfo == NULL) { - ch->handlers.xferinfo = ecalloc(1, sizeof(php_curl_callback)); - } else if (!Z_ISUNDEF(ch->handlers.xferinfo->func_name)) { - zval_ptr_dtor(&ch->handlers.xferinfo->func_name); - ch->handlers.xferinfo->fci_cache = empty_fcall_info_cache; - } - ZVAL_COPY(&ch->handlers.xferinfo->func_name, zvalue); - break; - /* Curl off_t options */ case CURLOPT_MAX_RECV_SPEED_LARGE: case CURLOPT_MAX_SEND_SPEED_LARGE: @@ -2234,7 +2141,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue case CURLOPT_ISSUERCERT: case CURLOPT_SSH_KNOWNHOSTS: { - zend_string *tmp_str; + zend_string *tmp_str; zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); zend_result ret; @@ -2275,18 +2182,6 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue } break; - case CURLOPT_FNMATCH_FUNCTION: - curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_FUNCTION, curl_fnmatch); - curl_easy_setopt(ch->cp, CURLOPT_FNMATCH_DATA, ch); - if (ch->handlers.fnmatch == NULL) { - ch->handlers.fnmatch = ecalloc(1, sizeof(php_curl_callback)); - } else if (!Z_ISUNDEF(ch->handlers.fnmatch->func_name)) { - zval_ptr_dtor(&ch->handlers.fnmatch->func_name); - ch->handlers.fnmatch->fci_cache = empty_fcall_info_cache; - } - ZVAL_COPY(&ch->handlers.fnmatch->func_name, zvalue); - break; - /* Curl blob options */ #if LIBCURL_VERSION_NUM >= 0x074700 /* Available since 7.71.0 */ case CURLOPT_ISSUERCERT_BLOB: @@ -2775,14 +2670,6 @@ PHP_FUNCTION(curl_close) } /* }}} */ -static void _php_curl_free_callback(php_curl_callback* callback) -{ - if (callback) { - zval_ptr_dtor(&callback->func_name); - efree(callback); - } -} - static void curl_free_obj(zend_object *object) { php_curl *ch = curl_from_obj(object); @@ -2799,20 +2686,6 @@ static void curl_free_obj(zend_object *object) _php_curl_verify_handlers(ch, /* reporterror */ false); - /* - * Libcurl is doing connection caching. When easy handle is cleaned up, - * if the handle was previously used by the curl_multi_api, the connection - * remains open un the curl multi handle is cleaned up. Some protocols are - * sending content like the FTP one, and libcurl try to use the - * WRITEFUNCTION or the HEADERFUNCTION. Since structures used in those - * callback are freed, we need to use an other callback to which avoid - * segfaults. - * - * Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2 - */ - curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing); - curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing); - curl_easy_cleanup(ch->cp); /* cURL destructors should be invoked only by last curl handle */ @@ -2827,9 +2700,15 @@ static void curl_free_obj(zend_object *object) } smart_str_free(&ch->handlers.write->buf); - zval_ptr_dtor(&ch->handlers.write->func_name); - zval_ptr_dtor(&ch->handlers.read->func_name); - zval_ptr_dtor(&ch->handlers.write_header->func_name); + if (ZEND_FCC_INITIALIZED(ch->handlers.write->fcc)) { + zend_fcc_dtor(&ch->handlers.write->fcc); + } + if (ZEND_FCC_INITIALIZED(ch->handlers.write_header->fcc)) { + zend_fcc_dtor(&ch->handlers.write_header->fcc); + } + if (ZEND_FCC_INITIALIZED(ch->handlers.read->fcc)) { + zend_fcc_dtor(&ch->handlers.read->fcc); + } zval_ptr_dtor(&ch->handlers.std_err); if (ch->header.str) { zend_string_release_ex(ch->header.str, 0); @@ -2843,11 +2722,19 @@ static void curl_free_obj(zend_object *object) efree(ch->handlers.write_header); efree(ch->handlers.read); - _php_curl_free_callback(ch->handlers.progress); - _php_curl_free_callback(ch->handlers.xferinfo); - _php_curl_free_callback(ch->handlers.fnmatch); + if (ZEND_FCC_INITIALIZED(ch->handlers.progress)) { + zend_fcc_dtor(&ch->handlers.progress); + } + if (ZEND_FCC_INITIALIZED(ch->handlers.xferinfo)) { + zend_fcc_dtor(&ch->handlers.xferinfo); + } + if (ZEND_FCC_INITIALIZED(ch->handlers.fnmatch)) { + zend_fcc_dtor(&ch->handlers.fnmatch); + } #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ - _php_curl_free_callback(ch->handlers.sshhostkey); + if (ZEND_FCC_INITIALIZED(ch->handlers.sshhostkey)) { + zend_fcc_dtor(&ch->handlers.sshhostkey); + } #endif zval_ptr_dtor(&ch->postfields); @@ -2911,29 +2798,21 @@ static void _php_curl_reset_handlers(php_curl *ch) ZVAL_UNDEF(&ch->handlers.std_err); } - if (ch->handlers.progress) { - zval_ptr_dtor(&ch->handlers.progress->func_name); - efree(ch->handlers.progress); - ch->handlers.progress = NULL; + if (ZEND_FCC_INITIALIZED(ch->handlers.progress)) { + zend_fcc_dtor(&ch->handlers.progress); } - if (ch->handlers.xferinfo) { - zval_ptr_dtor(&ch->handlers.xferinfo->func_name); - efree(ch->handlers.xferinfo); - ch->handlers.xferinfo = NULL; + if (ZEND_FCC_INITIALIZED(ch->handlers.xferinfo)) { + zend_fcc_dtor(&ch->handlers.xferinfo); } - if (ch->handlers.fnmatch) { - zval_ptr_dtor(&ch->handlers.fnmatch->func_name); - efree(ch->handlers.fnmatch); - ch->handlers.fnmatch = NULL; + if (ZEND_FCC_INITIALIZED(ch->handlers.fnmatch)) { + zend_fcc_dtor(&ch->handlers.fnmatch); } #if LIBCURL_VERSION_NUM >= 0x075400 /* Available since 7.84.0 */ - if (ch->handlers.sshhostkey) { - zval_ptr_dtor(&ch->handlers.sshhostkey->func_name); - efree(ch->handlers.sshhostkey); - ch->handlers.sshhostkey = NULL; + if (ZEND_FCC_INITIALIZED(ch->handlers.sshhostkey)) { + zend_fcc_dtor(&ch->handlers.sshhostkey); } #endif } diff --git a/ext/curl/multi.c b/ext/curl/multi.c index a61066b5a6c7c..586f48911b261 100644 --- a/ext/curl/multi.c +++ b/ext/curl/multi.c @@ -372,51 +372,35 @@ static int _php_server_push_callback(CURL *parent_ch, CURL *easy, size_t num_hea php_curl *parent; php_curlm *mh = (php_curlm *)userp; size_t rval = CURL_PUSH_DENY; - php_curl_callback *t = mh->handlers.server_push; zval *pz_parent_ch = NULL; zval pz_ch; zval headers; zval retval; - char *header; - zend_result error; - zend_fcall_info fci = empty_fcall_info; pz_parent_ch = _php_curl_multi_find_easy_handle(mh, parent_ch); if (pz_parent_ch == NULL) { return rval; } - if (UNEXPECTED(zend_fcall_info_init(&t->func_name, 0, &fci, &t->fci_cache, NULL, NULL) == FAILURE)) { - php_error_docref(NULL, E_WARNING, "Cannot call the CURLMOPT_PUSHFUNCTION"); - return rval; - } - parent = Z_CURL_P(pz_parent_ch); ch = init_curl_handle_into_zval(&pz_ch); ch->cp = easy; _php_setup_easy_copy_handlers(ch, parent); - size_t i; array_init(&headers); - for(i=0; ifci_cache); + zend_call_known_fcc(&mh->handlers.server_push, &retval, /* param_count */ 3, call_args, /* named_params */ NULL); zval_ptr_dtor_nogc(&headers); - if (error == FAILURE) { - php_error_docref(NULL, E_WARNING, "Cannot call the CURLMOPT_PUSHFUNCTION"); - } else if (!Z_ISUNDEF(retval)) { + if (!Z_ISUNDEF(retval)) { if (CURL_PUSH_DENY != zval_get_long(&retval)) { rval = CURL_PUSH_OK; zend_llist_add_element(&mh->easyh, &pz_ch); @@ -458,21 +442,29 @@ static bool _php_curl_multi_setopt(php_curlm *mh, zend_long option, zval *zvalue error = curl_multi_setopt(mh->multi, option, lval); break; } - case CURLMOPT_PUSHFUNCTION: - if (mh->handlers.server_push == NULL) { - mh->handlers.server_push = ecalloc(1, sizeof(php_curl_callback)); - } else if (!Z_ISUNDEF(mh->handlers.server_push->func_name)) { - zval_ptr_dtor(&mh->handlers.server_push->func_name); - mh->handlers.server_push->fci_cache = empty_fcall_info_cache; + case CURLMOPT_PUSHFUNCTION: { + /* See php_curl_set_callable_handler */ + if (ZEND_FCC_INITIALIZED(mh->handlers.server_push)) { + zend_fcc_dtor(&mh->handlers.server_push); } - ZVAL_COPY(&mh->handlers.server_push->func_name, zvalue); + char *error_str = NULL; + if (UNEXPECTED(!zend_is_callable_ex(zvalue, /* object */ NULL, /* check_flags */ 0, /* callable_name */ NULL, &mh->handlers.server_push, /* error */ &error_str))) { + if (!EG(exception)) { + zend_argument_type_error(2, "must be a valid callback for option CURLMOPT_PUSHFUNCTION, %s", error_str); + } + efree(error_str); + return false; + } + zend_fcc_addref(&mh->handlers.server_push); + error = curl_multi_setopt(mh->multi, CURLMOPT_PUSHFUNCTION, _php_server_push_callback); if (error != CURLM_OK) { return false; } error = curl_multi_setopt(mh->multi, CURLMOPT_PUSHDATA, mh); break; + } default: zend_argument_value_error(2, "is not a valid cURL multi option"); error = CURLM_UNKNOWN_OPTION; @@ -548,9 +540,9 @@ static void curl_multi_free_obj(zend_object *object) curl_multi_cleanup(mh->multi); zend_llist_clean(&mh->easyh); - if (mh->handlers.server_push) { - zval_ptr_dtor(&mh->handlers.server_push->func_name); - efree(mh->handlers.server_push); + + if (ZEND_FCC_INITIALIZED(mh->handlers.server_push)) { + zend_fcc_dtor(&mh->handlers.server_push); } zend_object_std_dtor(&mh->std); @@ -562,8 +554,8 @@ static HashTable *curl_multi_get_gc(zend_object *object, zval **table, int *n) zend_get_gc_buffer *gc_buffer = zend_get_gc_buffer_create(); - if (curl_multi->handlers.server_push) { - zend_get_gc_buffer_add_zval(gc_buffer, &curl_multi->handlers.server_push->func_name); + if (ZEND_FCC_INITIALIZED(curl_multi->handlers.server_push)) { + zend_get_gc_buffer_add_fcc(gc_buffer, &curl_multi->handlers.server_push); } zend_llist_position pos; diff --git a/ext/curl/tests/callable_nullable_option.phpt b/ext/curl/tests/callable_nullable_option.phpt new file mode 100644 index 0000000000000..b43e960348099 --- /dev/null +++ b/ext/curl/tests/callable_nullable_option.phpt @@ -0,0 +1,16 @@ +--TEST-- +Callable options are nullable +--EXTENSIONS-- +curl +--FILE-- + null, +]); + +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/ext/curl/tests/curl_copy_handle_basic_008.phpt b/ext/curl/tests/curl_copy_handle_basic_008.phpt deleted file mode 100644 index c1ab325660cf8..0000000000000 --- a/ext/curl/tests/curl_copy_handle_basic_008.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION ---EXTENSIONS-- -curl ---FILE-- - ---EXPECT-- -Hello World! -Hello World! -Hello World! -Hello World! diff --git a/ext/curl/tests/curl_copy_handle_xferinfo.phpt b/ext/curl/tests/curl_copy_handle_xferinfo.phpt index 55050551b797e..bf9c1f43beea0 100644 --- a/ext/curl/tests/curl_copy_handle_xferinfo.phpt +++ b/ext/curl/tests/curl_copy_handle_xferinfo.phpt @@ -4,19 +4,23 @@ Test curl_copy_handle() with CURLOPT_XFERINFOFUNCTION curl --FILE-- --EXPECT-- diff --git a/ext/curl/tests/curl_fnmatch_trampoline.phpt b/ext/curl/tests/curl_fnmatch_trampoline.phpt new file mode 100644 index 0000000000000..ffc286cae8846 --- /dev/null +++ b/ext/curl/tests/curl_fnmatch_trampoline.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test trampoline for curl option CURLOPT_FNMATCH_FUNCTION +--EXTENSIONS-- +curl +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Trampoline for trampoline +Hello World! +Hello World! diff --git a/ext/curl/tests/curl_multi_setopt_callables.phpt b/ext/curl/tests/curl_multi_setopt_callables.phpt new file mode 100644 index 0000000000000..c0de5add49101 --- /dev/null +++ b/ext/curl/tests/curl_multi_setopt_callables.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test curl_multi_setopt() with options that take callabes +--EXTENSIONS-- +curl +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +TypeError: curl_multi_setopt(): Argument #2 ($option) must be a valid callback for option CURLMOPT_PUSHFUNCTION, function "undefined" not found or invalid function name diff --git a/ext/curl/tests/curl_progress.phpt b/ext/curl/tests/curl_progress.phpt new file mode 100644 index 0000000000000..5a7e488812233 --- /dev/null +++ b/ext/curl/tests/curl_progress.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test curl_copy_handle() with CURLOPT_PROGRESSFUNCTION +--EXTENSIONS-- +curl +--FILE-- + +--EXPECT-- +Hello World! +Hello World! +Hello World! +Hello World! diff --git a/ext/curl/tests/curl_progress_trampoline.phpt b/ext/curl/tests/curl_progress_trampoline.phpt new file mode 100644 index 0000000000000..d3d31e6aec891 --- /dev/null +++ b/ext/curl/tests/curl_progress_trampoline.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test trampoline for curl option CURLOPT_PROGRESSFUNCTION +--EXTENSIONS-- +curl +--FILE-- + +--EXPECT-- +Trampoline for trampoline +Hello World! +Hello World! diff --git a/ext/curl/tests/curl_pushfunction_nonexistent_callback.phpt b/ext/curl/tests/curl_pushfunction_trampoline.phpt similarity index 62% rename from ext/curl/tests/curl_pushfunction_nonexistent_callback.phpt rename to ext/curl/tests/curl_pushfunction_trampoline.phpt index fe2defa5eea08..de6da63914045 100644 --- a/ext/curl/tests/curl_pushfunction_nonexistent_callback.phpt +++ b/ext/curl/tests/curl_pushfunction_trampoline.phpt @@ -1,9 +1,5 @@ --TEST-- -Test CURLMOPT_PUSHFUNCTION with non-existent callback function ---CREDITS-- -Davey Shafik -Kévin Dunglas -Niels Dossche +Test trampoline for curl option CURLMOPT_PUSHFUNCTION --EXTENSIONS-- curl --SKIPIF-- @@ -17,12 +13,20 @@ if ($curl_version['version_number'] < 0x080100) { ?> --FILE-- ---EXPECTF-- -Warning: curl_multi_exec(): Cannot call the CURLMOPT_PUSHFUNCTION in %s on line %d +--EXPECT-- +Array +( + [0] => main response + [1] => pushed response +) diff --git a/ext/curl/tests/curl_setopt_CURLOPT_READFUNCTION.phpt b/ext/curl/tests/curl_read_callback.phpt similarity index 100% rename from ext/curl/tests/curl_setopt_CURLOPT_READFUNCTION.phpt rename to ext/curl/tests/curl_read_callback.phpt diff --git a/ext/curl/tests/curl_read_trampoline.phpt b/ext/curl/tests/curl_read_trampoline.phpt new file mode 100644 index 0000000000000..f69caebf79875 --- /dev/null +++ b/ext/curl/tests/curl_read_trampoline.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test trampoline for curl option CURLOPT_READFUNCTION +--EXTENSIONS-- +curl +--FILE-- + +--CLEAN-- + +--EXPECT-- +Trampoline for trampoline +string(0) "" diff --git a/ext/curl/tests/curl_setopt_callables.phpt b/ext/curl/tests/curl_setopt_callables.phpt new file mode 100644 index 0000000000000..6cde8fef6d9c7 --- /dev/null +++ b/ext/curl/tests/curl_setopt_callables.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test curl_setopt(_array)() with options that take callabes +--EXTENSIONS-- +curl +--FILE-- +getMessage(), PHP_EOL; + } + + try { + var_dump(curl_setopt_array($handle, [$option => 'undefined'])); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +$url = "https://example.com"; +$ch = curl_init($url); +testOption($ch, CURLOPT_PROGRESSFUNCTION); +testOption($ch, CURLOPT_XFERINFOFUNCTION); +testOption($ch, CURLOPT_FNMATCH_FUNCTION); +testOption($ch, CURLOPT_WRITEFUNCTION); +testOption($ch, CURLOPT_HEADERFUNCTION); +testOption($ch, CURLOPT_READFUNCTION); + +?> +--EXPECT-- +TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_PROGRESSFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_PROGRESSFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_XFERINFOFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_XFERINFOFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_FNMATCH_FUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_FNMATCH_FUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_WRITEFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_WRITEFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_HEADERFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_HEADERFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_READFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_READFUNCTION, function "undefined" not found or invalid function name diff --git a/ext/curl/tests/curl_ssh_hostkey_invalid_callable.phpt b/ext/curl/tests/curl_ssh_hostkey_invalid_callable.phpt new file mode 100644 index 0000000000000..f17fae9cbaa2d --- /dev/null +++ b/ext/curl/tests/curl_ssh_hostkey_invalid_callable.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test curl_setopt(_array)() with CURLOPT_SSH_HOSTKEYFUNCTION option +--EXTENSIONS-- +curl +--SKIPIF-- + +--FILE-- +getMessage(), PHP_EOL; + } + + try { + var_dump(curl_setopt_array($handle, [$option => 'undefined'])); + } catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; + } +} + +$url = "https://example.com"; +$ch = curl_init($url); +testOption($ch, CURLOPT_SSH_HOSTKEYFUNCTION); + +?> +--EXPECT-- +TypeError: curl_setopt(): Argument #3 ($value) must be a valid callback for option CURLOPT_SSH_HOSTKEYFUNCTION, function "undefined" not found or invalid function name +TypeError: curl_setopt_array(): Argument #2 ($options) must be a valid callback for option CURLOPT_SSH_HOSTKEYFUNCTION, function "undefined" not found or invalid function name diff --git a/ext/curl/tests/curl_ssh_hostkey_trampoline.phpt b/ext/curl/tests/curl_ssh_hostkey_trampoline.phpt new file mode 100644 index 0000000000000..84ce8eb85115a --- /dev/null +++ b/ext/curl/tests/curl_ssh_hostkey_trampoline.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test trampoline for curl option CURLOPT_SSH_HOSTKEYFUNCTION +--EXTENSIONS-- +curl +--SKIPIF-- += 7.84.0"); +} +exit("skip: cannot properly test CURLOPT_SSH_HOSTKEYFUNCTION"); +?> +--FILE-- + +--EXPECT-- +Trampoline for trampoline +FAKE diff --git a/ext/curl/tests/curl_write_trampoline.phpt b/ext/curl/tests/curl_write_trampoline.phpt new file mode 100644 index 0000000000000..8d604bc7bd4fc --- /dev/null +++ b/ext/curl/tests/curl_write_trampoline.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test trampoline for curl option CURLOPT_WRITEFUNCTION +--EXTENSIONS-- +curl +--FILE-- + +--CLEAN-- + +--EXPECT-- +Trampoline for trampoline diff --git a/ext/curl/tests/curl_writeheader_tranpoline.phpt b/ext/curl/tests/curl_writeheader_tranpoline.phpt new file mode 100644 index 0000000000000..48c53f3996a44 --- /dev/null +++ b/ext/curl/tests/curl_writeheader_tranpoline.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test trampoline for curl option CURLOPT_HEADERFUNCTION +--EXTENSIONS-- +curl +--FILE-- + +--EXPECT-- +Trampoline for trampoline diff --git a/ext/curl/tests/curl_xferinfo_trampoline.phpt b/ext/curl/tests/curl_xferinfo_trampoline.phpt new file mode 100644 index 0000000000000..f10ea890dcba8 --- /dev/null +++ b/ext/curl/tests/curl_xferinfo_trampoline.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test trampoline for curl option CURLOPT_XFERINFOFUNCTION +--EXTENSIONS-- +curl +--FILE-- + +--EXPECT-- +Trampoline for trampoline +Hello World! +Hello World! diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 0b847ed66de88..5cffe3b09f07a 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -57,6 +57,7 @@ PHP_MINFO_FUNCTION(dba); ZEND_BEGIN_MODULE_GLOBALS(dba) const char *default_handler; const dba_handler *default_hptr; + HashTable connections; ZEND_END_MODULE_GLOBALS(dba) ZEND_DECLARE_MODULE_GLOBALS(dba) @@ -64,6 +65,7 @@ ZEND_DECLARE_MODULE_GLOBALS(dba) #define DBA_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(dba, v) static PHP_GINIT_FUNCTION(dba); +static PHP_GSHUTDOWN_FUNCTION(dba); zend_module_entry dba_module_entry = { STANDARD_MODULE_HEADER, @@ -77,7 +79,7 @@ zend_module_entry dba_module_entry = { PHP_DBA_VERSION, PHP_MODULE_GLOBALS(dba), PHP_GINIT(dba), - NULL, + PHP_GSHUTDOWN(dba), NULL, STANDARD_MODULE_PROPERTIES_EX }; @@ -132,8 +134,9 @@ static zend_string* php_dba_make_key(HashTable *key) #define DBA_RELEASE_HT_KEY_CREATION() if (key_ht) {zend_string_release_ex(key_str, false);} -#define DBA_FETCH_RESOURCE(info, id) \ - if ((info = (dba_info *)zend_fetch_resource2(Z_RES_P(id), "DBA identifier", le_db, le_pdb)) == NULL) { \ +#define CHECK_DBA_CONNECTION(info) \ + if (info == NULL) { \ + zend_throw_error(NULL, "DBA connection has already been closed"); \ RETURN_THROWS(); \ } @@ -232,35 +235,18 @@ static const dba_handler handler[] = { #endif /* cdb/cdb_make and ini are no option here */ -static int le_db; static int le_pdb; -/* }}} */ -/* {{{ dba_fetch_resource -PHPAPI void dba_fetch_resource(dba_info **pinfo, zval **id) -{ - dba_info *info; - DBA_ID_FETCH - *pinfo = info; -} -*/ -/* }}} */ +static zend_class_entry *dba_connection_ce; +static zend_object_handlers dba_connection_object_handlers; -/* {{{ dba_get_handler -PHPAPI dba_handler *dba_get_handler(const char* handler_name) +static void dba_close_info(dba_info *info) { - const dba_handler *hptr; - for (hptr = handler; hptr->name && strcasecmp(hptr->name, handler_name); hptr++); - return hptr; -} -*/ -/* }}} */ + ZEND_ASSERT(info != NULL && "connection has already been closed"); -/* {{{ dba_close */ -static void dba_close(dba_info *info) -{ if (info->hnd) { info->hnd->close(info); + info->hnd = NULL; } ZEND_ASSERT(info->path); zend_string_release_ex(info->path, info->flags&DBA_PERSISTENT); @@ -280,43 +266,95 @@ static void dba_close(dba_info *info) php_stream_close(info->lock.fp); } } - pefree(info, info->flags&DBA_PERSISTENT); + + pefree(info, info->flags & DBA_PERSISTENT); + info = NULL; } -/* }}} */ -/* {{{ dba_close_rsrc */ -static void dba_close_rsrc(zend_resource *rsrc) +static int remove_pconnection_from_list(zval *zv, void *p) { - dba_info *info = (dba_info *)rsrc->ptr; + zend_resource *le = Z_RES_P(zv); + + if (le->ptr == p) { + return ZEND_HASH_APPLY_REMOVE; + } - dba_close(info); + return ZEND_HASH_APPLY_KEEP; } -/* }}} */ -/* {{{ dba_close_pe_rsrc_deleter */ -static int dba_close_pe_rsrc_deleter(zval *el, void *pDba) +static void close_pconnection(zend_resource *rsrc) { - if (Z_RES_P(el)->ptr == pDba) { - if (Z_DELREF_P(el) == 0) { - return ZEND_HASH_APPLY_REMOVE; - } else { - return ZEND_HASH_APPLY_KEEP | ZEND_HASH_APPLY_STOP; - } - } else { - return ZEND_HASH_APPLY_KEEP; + dba_info *info = (dba_info *) rsrc->ptr; + + dba_close_info(info); + + rsrc->ptr = NULL; +} + +static void dba_close_connection(dba_connection *connection) +{ + bool persistent = connection->info->flags & DBA_PERSISTENT; + + if (!persistent) { + dba_close_info(connection->info); + } + + connection->info = NULL; + + if (connection->hash) { + zend_hash_del(&DBA_G(connections), connection->hash); + zend_string_release_ex(connection->hash, persistent); + connection->hash = NULL; } } -/* }}} */ -/* {{{ dba_close_pe_rsrc */ -static void dba_close_pe_rsrc(zend_resource *rsrc) +static zend_object *dba_connection_create_object(zend_class_entry *class_type) { - dba_info *info = (dba_info *)rsrc->ptr; + dba_connection *intern = zend_object_alloc(sizeof(dba_info), class_type); + + zend_object_std_init(&intern->std, class_type); + object_properties_init(&intern->std, class_type); - /* closes the resource by calling dba_close_rsrc() */ - zend_hash_apply_with_argument(&EG(persistent_list), dba_close_pe_rsrc_deleter, info); + return &intern->std; +} + +static zend_function *dba_connection_get_constructor(zend_object *object) +{ + zend_throw_error(NULL, "Cannot directly construct Dba\\Connection, use dba_open() or dba_popen() instead"); + return NULL; +} + +static zend_result dba_connection_cast_object(zend_object *obj, zval *result, int type) +{ + if (type == IS_LONG) { + /* For better backward compatibility, make (int) $dba return the object ID, + * similar to how it previously returned the resource ID. */ + ZVAL_LONG(result, obj->handle); + + return SUCCESS; + } + + return zend_std_cast_object_tostring(obj, result, type); +} + +static inline dba_connection *dba_connection_from_obj(zend_object *obj) +{ + return (dba_connection *)((char *)(obj) - XtOffsetOf(dba_connection, std)); +} + +#define Z_DBA_CONNECTION_P(zv) dba_connection_from_obj(Z_OBJ_P(zv)) +#define Z_DBA_INFO_P(zv) Z_DBA_CONNECTION_P(zv)->info + +static void dba_connection_free_obj(zend_object *obj) +{ + dba_connection *connection = dba_connection_from_obj(obj); + + if (connection->info) { + dba_close_connection(connection); + } + + zend_object_std_dtor(&connection->std); } -/* }}} */ /* {{{ PHP_INI */ static ZEND_INI_MH(OnUpdateDefaultHandler) @@ -351,16 +389,35 @@ static PHP_GINIT_FUNCTION(dba) #endif dba_globals->default_handler = ""; dba_globals->default_hptr = NULL; + zend_hash_init(&dba_globals->connections, 0, NULL, NULL, true); + GC_MAKE_PERSISTENT_LOCAL(&dba_globals->connections); } /* }}} */ +static PHP_GSHUTDOWN_FUNCTION(dba) +{ + zend_hash_destroy(&dba_globals->connections); +} + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(dba) { REGISTER_INI_ENTRIES(); - le_db = zend_register_list_destructors_ex(dba_close_rsrc, NULL, "dba", module_number); - le_pdb = zend_register_list_destructors_ex(dba_close_pe_rsrc, dba_close_rsrc, "dba persistent", module_number); + le_pdb = zend_register_list_destructors_ex(NULL, close_pconnection, "dba persistent", module_number); register_dba_symbols(module_number); + + dba_connection_ce = register_class_Dba_Connection(); + dba_connection_ce->create_object = dba_connection_create_object; + dba_connection_ce->default_object_handlers = &dba_connection_object_handlers; + + memcpy(&dba_connection_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + dba_connection_object_handlers.offset = XtOffsetOf(dba_connection, std); + dba_connection_object_handlers.free_obj = dba_connection_free_obj; + dba_connection_object_handlers.get_constructor = dba_connection_get_constructor; + dba_connection_object_handlers.clone_obj = NULL; + dba_connection_object_handlers.cast_object = dba_connection_cast_object; + dba_connection_object_handlers.compare = zend_objects_not_comparable; + return SUCCESS; } /* }}} */ @@ -412,10 +469,11 @@ static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode) ZEND_PARSE_PARAMETERS_START(3, 3) Z_PARAM_ARRAY_HT_OR_STR(key_ht, key_str) Z_PARAM_STR(value) - Z_PARAM_RESOURCE(id); + Z_PARAM_OBJECT_OF_CLASS(id, dba_connection_ce); ZEND_PARSE_PARAMETERS_END(); - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); DBA_WRITE_CHECK(info); if (key_ht) { @@ -434,22 +492,14 @@ static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ php_find_dbm */ static dba_info *php_dba_find(const zend_string *path) { - zend_resource *le; - dba_info *info; - zend_long numitems, i; - - numitems = zend_hash_next_free_element(&EG(regular_list)); - for (i=1; itype == le_db || le->type == le_pdb) { - info = (dba_info *)(le->ptr); - if (zend_string_equals(path, info->path)) { - return (dba_info *)(le->ptr); - } + zval *zv; + + ZEND_HASH_MAP_FOREACH_VAL(&DBA_G(connections), zv) { + dba_info *info = Z_DBA_INFO_P(zv); + if (info && zend_string_equals(path, info->path)) { + return info; } - } + } ZEND_HASH_FOREACH_END(); return NULL; } @@ -468,14 +518,10 @@ static zend_always_inline zend_string *php_dba_zend_string_dup_safe(zend_string } } - -#define FREE_PERSISTENT_RESOURCE_KEY() if (persistent_resource_key) {zend_string_release_ex(persistent_resource_key, false);} - /* {{{ php_dba_open */ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) { dba_mode_t modenr; - dba_info *info, *other; const dba_handler *hptr; const char *error = NULL; int lock_mode, lock_flag = 0; @@ -495,7 +541,6 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) zend_long map_size = 0; zend_long driver_flags = DBA_DEFAULT_DRIVER_FLAGS; bool is_flags_null = true; - zend_string *persistent_resource_key = NULL; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "PS|S!lll!", &path, &mode, &handler_str, &permission, &map_size, &driver_flags, &is_flags_null)) { @@ -525,34 +570,37 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) RETURN_THROWS(); } + char *resource_key; + size_t resource_key_len = spprintf(&resource_key, 0, + "dba_%d_%s_%s_%s", persistent, ZSTR_VAL(path), ZSTR_VAL(mode), handler_str ? ZSTR_VAL(handler_str) : "" + ); + if (persistent) { zend_resource *le; - if (handler_str) { - persistent_resource_key = zend_string_concat3( - ZSTR_VAL(path), ZSTR_LEN(path), - ZSTR_VAL(mode), ZSTR_LEN(mode), - ZSTR_VAL(handler_str), ZSTR_LEN(handler_str) - ); - } else { - persistent_resource_key = zend_string_concat2( - ZSTR_VAL(path), ZSTR_LEN(path), - ZSTR_VAL(mode), ZSTR_LEN(mode) - ); - } - /* try to find if we already have this link in our persistent list */ - if ((le = zend_hash_find_ptr(&EG(persistent_list), persistent_resource_key)) != NULL) { - FREE_PERSISTENT_RESOURCE_KEY(); + if ((le = zend_hash_str_find_ptr(&EG(persistent_list), resource_key, resource_key_len)) != NULL) { if (le->type != le_pdb) { // TODO This should never happen + efree(resource_key); RETURN_FALSE; } - info = (dba_info *)le->ptr; + object_init_ex(return_value, dba_connection_ce); + dba_connection *connection = Z_DBA_CONNECTION_P(return_value); + connection->info = (dba_info *)le->ptr; + connection->hash = zend_string_init(resource_key, resource_key_len, persistent); + if (persistent) { + GC_MAKE_PERSISTENT_LOCAL(connection->hash); + } + + if (zend_hash_exists(&DBA_G(connections), connection->hash)) { + zend_hash_del(&DBA_G(connections), connection->hash); + } - GC_ADDREF(le); - RETURN_RES(zend_register_resource(info, le_pdb)); + zend_hash_add_new(&DBA_G(connections), connection->hash, return_value); + efree(resource_key); + return; } } @@ -560,7 +608,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) hptr = DBA_G(default_hptr); if (!hptr) { php_error_docref(NULL, E_WARNING, "No default handler selected"); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_FALSE; } ZEND_ASSERT(hptr->name); @@ -570,7 +618,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) if (!hptr->name) { php_error_docref(NULL, E_WARNING, "Handler \"%s\" is not available", ZSTR_VAL(handler_str)); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_FALSE; } } @@ -594,18 +642,18 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) if (ZSTR_LEN(mode) == 0) { zend_argument_value_error(2, "cannot be empty"); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_THROWS(); } if (ZSTR_LEN(mode) > 3) { zend_argument_value_error(2, "must be at most 3 characters"); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_THROWS(); } if (ZSTR_LEN(mode) == 3) { if (ZSTR_VAL(mode)[2] != 't') { zend_argument_value_error(2, "third character must be \"t\""); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_THROWS(); } is_test_lock = true; @@ -618,7 +666,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) case '-': if ((hptr->flags & DBA_LOCK_ALL) == 0) { php_error_docref(NULL, E_WARNING, "Locking cannot be disabled for handler %s", hptr->name); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_FALSE; } is_lock_ignored = true; @@ -640,7 +688,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) break; default: zend_argument_value_error(2, "second character must be one of \"d\", \"l\", \"-\", or \"t\""); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_THROWS(); } } else { @@ -709,7 +757,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) break; default: zend_argument_value_error(2, "first character must be one of \"r\", \"w\", \"c\", or \"n\""); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_THROWS(); } if (!lock_file_mode) { @@ -718,17 +766,17 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) if (is_test_lock) { if (is_lock_ignored) { zend_argument_value_error(2, "cannot combine mode \"-\" (no lock) and \"t\" (test lock)"); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_THROWS(); } if (!lock_mode) { if ((hptr->flags & DBA_LOCK_ALL) == 0) { php_error_docref(NULL, E_WARNING, "Handler %s uses its own locking which doesn't support mode modifier t (test lock)", hptr->name); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_FALSE; } else { php_error_docref(NULL, E_WARNING, "Handler %s doesn't uses locking for this mode which makes modifier t (test lock) obsolete", hptr->name); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); RETURN_FALSE; } } else { @@ -736,22 +784,36 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) } } - info = pemalloc(sizeof(dba_info), persistent); - memset(info, 0, sizeof(dba_info)); - info->path = php_dba_zend_string_dup_safe(path, persistent); - info->mode = modenr; - info->file_permission = permission; - info->map_size = map_size; - info->driver_flags = driver_flags; - info->flags = (hptr->flags & ~DBA_LOCK_ALL) | (lock_flag & DBA_LOCK_ALL) | (persistent ? DBA_PERSISTENT : 0); - info->lock.mode = lock_mode; + zval *connection_zval; + dba_connection *connection; + if ((connection_zval = zend_hash_str_find(&DBA_G(connections), resource_key, resource_key_len)) == NULL) { + object_init_ex(return_value, dba_connection_ce); + connection = Z_DBA_CONNECTION_P(return_value); + + connection->info = pecalloc(1, sizeof(dba_info), persistent); + connection->info->path = php_dba_zend_string_dup_safe(path, persistent); + connection->info->mode = modenr; + connection->info->file_permission = permission; + connection->info->map_size = map_size; + connection->info->driver_flags = driver_flags; + connection->info->flags = (hptr->flags & ~DBA_LOCK_ALL) | (lock_flag & DBA_LOCK_ALL) | (persistent ? DBA_PERSISTENT : 0); + connection->info->lock.mode = lock_mode; + connection->hash = zend_string_init(resource_key, resource_key_len, persistent); + if (persistent) { + GC_MAKE_PERSISTENT_LOCAL(connection->hash); + } + } else { + ZVAL_COPY(return_value, connection_zval); + connection = Z_DBA_CONNECTION_P(return_value); + } /* if any open call is a locking call: * check if we already have a locking call open that should block this call * the problem is some systems would allow read during write */ if (hptr->flags & DBA_LOCK_ALL) { - if ((other = php_dba_find(info->path)) != NULL) { + dba_info *other; + if ((other = php_dba_find(connection->info->path)) != NULL) { if ( ( (lock_mode&LOCK_EX) && (other->lock.mode&(LOCK_EX|LOCK_SH)) ) || ( (other->lock.mode&LOCK_EX) && (lock_mode&(LOCK_EX|LOCK_SH)) ) ) { @@ -767,91 +829,92 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) if (is_db_lock) { lock_name = ZSTR_VAL(path); } else { - spprintf(&lock_name, 0, "%s.lck", ZSTR_VAL(info->path)); + spprintf(&lock_name, 0, "%s.lck", ZSTR_VAL(connection->info->path)); if (!strcmp(file_mode, "r")) { zend_string *opened_path = NULL; /* when in read only mode try to use existing .lck file first */ /* do not log errors for .lck file while in read only mode on .lck file */ lock_file_mode = "rb"; - info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|persistent_flag, &opened_path); + connection->info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|persistent_flag, &opened_path); if (opened_path) { zend_string_release_ex(opened_path, 0); } } - if (!info->lock.fp) { + if (!connection->info->lock.fp) { /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */ lock_file_mode = "a+b"; } } - if (!info->lock.fp) { + if (!connection->info->lock.fp) { zend_string *opened_path = NULL; - info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, &opened_path); - if (info->lock.fp) { + connection->info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, &opened_path); + if (connection->info->lock.fp) { if (is_db_lock) { ZEND_ASSERT(opened_path); /* replace the path info with the real path of the opened file */ - zend_string_release(info->path); - info->path = php_dba_zend_string_dup_safe(opened_path, persistent); + zend_string_release_ex(connection->info->path, persistent); + connection->info->path = php_dba_zend_string_dup_safe(opened_path, persistent); } } if (opened_path) { zend_string_release_ex(opened_path, 0); + opened_path = NULL; } } if (!is_db_lock) { efree(lock_name); } - if (!info->lock.fp) { - dba_close(info); + if (!connection->info->lock.fp) { /* stream operation already wrote an error message */ - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); + zval_ptr_dtor(return_value); RETURN_FALSE; } - if (!php_stream_supports_lock(info->lock.fp)) { + if (!php_stream_supports_lock(connection->info->lock.fp)) { error = "Stream does not support locking"; } - if (php_stream_lock(info->lock.fp, lock_mode)) { + if (php_stream_lock(connection->info->lock.fp, lock_mode)) { error = "Unable to establish lock"; /* force failure exit */ } } /* centralised open stream for builtin */ if (!error && (hptr->flags&DBA_STREAM_OPEN)==DBA_STREAM_OPEN) { - if (info->lock.fp && is_db_lock) { - info->fp = info->lock.fp; /* use the same stream for locking and database access */ + if (connection->info->lock.fp && is_db_lock) { + connection->info->fp = connection->info->lock.fp; /* use the same stream for locking and database access */ } else { - info->fp = php_stream_open_wrapper(ZSTR_VAL(info->path), file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, NULL); + connection->info->fp = php_stream_open_wrapper(ZSTR_VAL(connection->info->path), file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, NULL); } - if (!info->fp) { - dba_close(info); + if (!connection->info->fp) { /* stream operation already wrote an error message */ - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); + zval_ptr_dtor(return_value); RETURN_FALSE; } if (hptr->flags & (DBA_NO_APPEND|DBA_CAST_AS_FD)) { /* Needed because some systems do not allow to write to the original * file contents with O_APPEND being set. */ - if (SUCCESS != php_stream_cast(info->fp, PHP_STREAM_AS_FD, (void*)&info->fd, 1)) { + if (SUCCESS != php_stream_cast(connection->info->fp, PHP_STREAM_AS_FD, (void*)&connection->info->fd, 1)) { php_error_docref(NULL, E_WARNING, "Could not cast stream"); - dba_close(info); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); + zval_ptr_dtor(return_value); RETURN_FALSE; #ifdef F_SETFL } else if (modenr == DBA_CREAT) { - int flags = fcntl(info->fd, F_GETFL); - fcntl(info->fd, F_SETFL, flags & ~O_APPEND); + int flags = fcntl(connection->info->fd, F_GETFL); + fcntl(connection->info->fd, F_SETFL, flags & ~O_APPEND); #elif defined(PHP_WIN32) } else if (modenr == DBA_CREAT && need_creation && !restarted) { - if (info->lock.fp != NULL) { - php_stream_free(info->lock.fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE); + if (connection->info->lock.fp != NULL) { + php_stream_free(connection->info->lock.fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE); } - if (info->fp != info->lock.fp) { - php_stream_free(info->fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE); + if (connection->info->fp != connection->info->lock.fp) { + php_stream_free(connection->info->fp, persistent ? PHP_STREAM_FREE_CLOSE_PERSISTENT : PHP_STREAM_FREE_CLOSE); } - info->fp = NULL; - info->lock.fp = NULL; - info->fd = -1; + connection->info->fp = NULL; + connection->info->lock.fp = NULL; + connection->info->fd = -1; lock_file_mode = "r+b"; @@ -862,8 +925,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) } } - if (error || hptr->open(info, &error) == FAILURE) { - dba_close(info); + if (error || hptr->open(connection->info, &error) == FAILURE) { if (EXPECTED(!EG(exception))) { if (error) { php_error_docref(NULL, E_WARNING, "Driver initialization failed for handler: %s: %s", hptr->name, error); @@ -871,24 +933,24 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) php_error_docref(NULL, E_WARNING, "Driver initialization failed for handler: %s", hptr->name); } } - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); + zval_ptr_dtor(return_value); RETURN_FALSE; } - info->hnd = hptr; + connection->info->hnd = hptr; if (persistent) { - ZEND_ASSERT(persistent_resource_key); - if (zend_register_persistent_resource_ex(persistent_resource_key, info, le_pdb) == NULL) { - dba_close(info); + if (zend_register_persistent_resource(resource_key, resource_key_len, connection->info, le_pdb) == NULL) { php_error_docref(NULL, E_WARNING, "Could not register persistent resource"); - FREE_PERSISTENT_RESOURCE_KEY(); + efree(resource_key); + zval_ptr_dtor(return_value); RETURN_FALSE; } - FREE_PERSISTENT_RESOURCE_KEY(); } - RETURN_RES(zend_register_resource(info, (persistent ? le_pdb : le_db))); + zend_hash_add_new(&DBA_G(connections), connection->hash, return_value); + efree(resource_key); } /* }}} */ @@ -910,15 +972,22 @@ PHP_FUNCTION(dba_open) PHP_FUNCTION(dba_close) { zval *id; - dba_info *info = NULL; + dba_connection *connection = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &id) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &id, dba_connection_ce) == FAILURE) { RETURN_THROWS(); } - DBA_FETCH_RESOURCE(info, id); + connection = Z_DBA_CONNECTION_P(id); + CHECK_DBA_CONNECTION(connection->info); + + bool persistent = connection->info->flags & DBA_PERSISTENT; + + dba_close_connection(connection); - zend_list_close(Z_RES_P(id)); + if (persistent) { + zend_hash_apply_with_argument(&EG(persistent_list), remove_pconnection_from_list, (void *) connection->info); + } } /* }}} */ @@ -932,10 +1001,11 @@ PHP_FUNCTION(dba_exists) ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_ARRAY_HT_OR_STR(key_ht, key_str) - Z_PARAM_RESOURCE(id); + Z_PARAM_OBJECT_OF_CLASS(id, dba_connection_ce); ZEND_PARSE_PARAMETERS_END(); - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); if (key_ht) { key_str = php_dba_make_key(key_ht); @@ -964,7 +1034,7 @@ PHP_FUNCTION(dba_fetch) ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_QUIET, 3, 3) Z_PARAM_ARRAY_HT_OR_STR(key_ht, key_str) Z_PARAM_LONG(skip) - Z_PARAM_RESOURCE(id); + Z_PARAM_OBJECT_OF_CLASS(id, dba_connection_ce); ZEND_PARSE_PARAMETERS_END_EX(goto standard;); zend_error(E_DEPRECATED, "Calling dba_fetch() with $dba at the 3rd parameter is deprecated"); @@ -975,13 +1045,14 @@ PHP_FUNCTION(dba_fetch) standard: ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_ARRAY_HT_OR_STR(key_ht, key_str) - Z_PARAM_RESOURCE(id); + Z_PARAM_OBJECT_OF_CLASS(id, dba_connection_ce); Z_PARAM_OPTIONAL Z_PARAM_LONG(skip) ZEND_PARSE_PARAMETERS_END(); } - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); if (key_ht) { key_str = php_dba_make_key(key_ht); @@ -1061,11 +1132,12 @@ PHP_FUNCTION(dba_firstkey) zval *id; dba_info *info = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &id) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &id, dba_connection_ce) == FAILURE) { RETURN_THROWS(); } - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); zend_string *fkey = info->hnd->firstkey(info); @@ -1083,11 +1155,12 @@ PHP_FUNCTION(dba_nextkey) zval *id; dba_info *info = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &id) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &id, dba_connection_ce) == FAILURE) { RETURN_THROWS(); } - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); zend_string *nkey = info->hnd->nextkey(info); @@ -1110,10 +1183,11 @@ PHP_FUNCTION(dba_delete) ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_ARRAY_HT_OR_STR(key_ht, key_str) - Z_PARAM_RESOURCE(id); + Z_PARAM_OBJECT_OF_CLASS(id, dba_connection_ce); ZEND_PARSE_PARAMETERS_END(); - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); DBA_WRITE_CHECK(info); if (key_ht) { @@ -1151,11 +1225,12 @@ PHP_FUNCTION(dba_optimize) zval *id; dba_info *info = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &id) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &id, dba_connection_ce) == FAILURE) { RETURN_THROWS(); } - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); DBA_WRITE_CHECK(info); if (info->hnd->optimize(info) == SUCCESS) { @@ -1172,11 +1247,12 @@ PHP_FUNCTION(dba_sync) zval *id; dba_info *info = NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &id) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &id, dba_connection_ce) == FAILURE) { RETURN_THROWS(); } - DBA_FETCH_RESOURCE(info, id); + info = Z_DBA_INFO_P(id); + CHECK_DBA_CONNECTION(info); if (info->hnd->sync(info) == SUCCESS) { RETURN_TRUE; @@ -1214,26 +1290,19 @@ PHP_FUNCTION(dba_handlers) /* {{{ List opened databases */ PHP_FUNCTION(dba_list) { - zend_ulong numitems, i; - zend_resource *le; - dba_info *info; - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } array_init(return_value); - numitems = zend_hash_next_free_element(&EG(regular_list)); - for (i=1; ipath)); } - if (le->type == le_db || le->type == le_pdb) { - info = (dba_info *)(le->ptr); - add_index_str(return_value, i, zend_string_copy(info->path)); - } - } + } ZEND_HASH_FOREACH_END(); } /* }}} */ diff --git a/ext/dba/dba.stub.php b/ext/dba/dba.stub.php index ece850f437b7d..fbc0be8cdadad 100644 --- a/ext/dba/dba.stub.php +++ b/ext/dba/dba.stub.php @@ -2,63 +2,64 @@ /** @generate-class-entries */ +namespace Dba { + /** + * @strict-properties + * @not-serializable + */ + final class Connection + { + } +} + +namespace { #ifdef DBA_LMDB -/** @var int */ -const DBA_LMDB_USE_SUB_DIR = 0; -/** - * @var int - * @cvalue MDB_NOSUBDIR - */ -const DBA_LMDB_NO_SUB_DIR = UNKNOWN; + /** @var int */ + const DBA_LMDB_USE_SUB_DIR = 0; + /** + * @var int + * @cvalue MDB_NOSUBDIR + */ + const DBA_LMDB_NO_SUB_DIR = UNKNOWN; #endif -/** @return resource|false */ -function dba_popen(string $path, string $mode, ?string $handler = null, int $permission = 0o644, int $map_size = 0, ?int $flags = null) {} + function dba_popen(string $path, string $mode, ?string $handler = null, int $permission = 0o644, int $map_size = 0, ?int $flags = null): Dba\Connection|false {} -/** @return resource|false */ -function dba_open(string $path, string $mode, ?string $handler = null, int $permission = 0o644, int $map_size = 0, ?int $flags = null) {} + function dba_open(string $path, string $mode, ?string $handler = null, int $permission = 0o644, int $map_size = 0, ?int $flags = null): Dba\Connection|false {} -/** @param resource $dba */ -function dba_close($dba): void {} + function dba_close(Dba\Connection $dba): void {} -/** @param resource $dba */ -function dba_exists(string|array $key, $dba): bool {} + function dba_exists(string|array $key, Dba\Connection $dba): bool {} -/** - * @param resource|int $dba overloaded legacy signature has params flipped - * @param resource|int $skip overloaded legacy signature has params flipped - */ -function dba_fetch(string|array $key, $dba, $skip = 0): string|false {} + /** + * @param Dba\Connection|int $dba overloaded legacy signature has params flipped + * @param Dba\Connection|int $skip overloaded legacy signature has params flipped + */ + function dba_fetch(string|array $key, $dba, $skip = 0): string|false {} -/** @return array|false */ -function dba_key_split(string|false|null $key): array|false {} + /** @return array|false */ + function dba_key_split(string|false|null $key): array|false {} -/** @param resource $dba */ -function dba_firstkey($dba): string|false {} + function dba_firstkey(Dba\Connection $dba): string|false {} -/** @param resource $dba */ -function dba_nextkey($dba): string|false {} + function dba_nextkey(Dba\Connection $dba): string|false {} -/** @param resource $dba */ -function dba_delete(string|array $key, $dba): bool {} + function dba_delete(string|array $key, Dba\Connection $dba): bool {} -/** @param resource $dba */ -function dba_insert(string|array $key, string $value, $dba): bool {} + function dba_insert(string|array $key, string $value, Dba\Connection $dba): bool {} -/** @param resource $dba */ -function dba_replace(string|array $key, string $value, $dba): bool {} + function dba_replace(string|array $key, string $value, Dba\Connection $dba): bool {} -/** @param resource $dba */ -function dba_optimize($dba): bool {} + function dba_optimize(Dba\Connection $dba): bool {} -/** @param resource $dba */ -function dba_sync($dba): bool {} + function dba_sync(Dba\Connection $dba): bool {} -/** - * @return array - * @refcount 1 - */ -function dba_handlers(bool $full_info = false): array {} + /** + * @return array + * @refcount 1 + */ + function dba_handlers(bool $full_info = false): array {} -/** @return array */ -function dba_list(): array {} + /** @return array */ + function dba_list(): array {} +} diff --git a/ext/dba/dba_arginfo.h b/ext/dba/dba_arginfo.h index 6083dff9601b9..0d703289de1a8 100644 --- a/ext/dba/dba_arginfo.h +++ b/ext/dba/dba_arginfo.h @@ -1,7 +1,7 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 1a02eaf9da45edb40720620e3beef43fd19dd520 */ + * Stub hash: da00cabc7b6930f1b834af8978b38945df96212f */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_dba_popen, 0, 2, Dba\\Connection, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, mode, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, handler, IS_STRING, 1, "null") @@ -13,12 +13,12 @@ ZEND_END_ARG_INFO() #define arginfo_dba_open arginfo_dba_popen ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dba_close, 0, 1, IS_VOID, 0) - ZEND_ARG_INFO(0, dba) + ZEND_ARG_OBJ_INFO(0, dba, Dba\\Connection, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dba_exists, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) - ZEND_ARG_INFO(0, dba) + ZEND_ARG_OBJ_INFO(0, dba, Dba\\Connection, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_fetch, 0, 2, MAY_BE_STRING|MAY_BE_FALSE) @@ -32,7 +32,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_key_split, 0, 1, MAY_BE_ARRA ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_dba_firstkey, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_INFO(0, dba) + ZEND_ARG_OBJ_INFO(0, dba, Dba\\Connection, 0) ZEND_END_ARG_INFO() #define arginfo_dba_nextkey arginfo_dba_firstkey @@ -42,13 +42,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dba_insert, 0, 3, _IS_BOOL, 0) ZEND_ARG_TYPE_MASK(0, key, MAY_BE_STRING|MAY_BE_ARRAY, NULL) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) - ZEND_ARG_INFO(0, dba) + ZEND_ARG_OBJ_INFO(0, dba, Dba\\Connection, 0) ZEND_END_ARG_INFO() #define arginfo_dba_replace arginfo_dba_insert ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dba_optimize, 0, 1, _IS_BOOL, 0) - ZEND_ARG_INFO(0, dba) + ZEND_ARG_OBJ_INFO(0, dba, Dba\\Connection, 0) ZEND_END_ARG_INFO() #define arginfo_dba_sync arginfo_dba_optimize @@ -95,6 +95,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE_END }; +static const zend_function_entry class_Dba_Connection_methods[] = { + ZEND_FE_END +}; + static void register_dba_symbols(int module_number) { #if defined(DBA_LMDB) @@ -104,3 +108,14 @@ static void register_dba_symbols(int module_number) REGISTER_LONG_CONSTANT("DBA_LMDB_NO_SUB_DIR", MDB_NOSUBDIR, CONST_PERSISTENT); #endif } + +static zend_class_entry *register_class_Dba_Connection(void) +{ + zend_class_entry ce, *class_entry; + + INIT_NS_CLASS_ENTRY(ce, "Dba", "Connection", class_Dba_Connection_methods); + class_entry = zend_register_internal_class_ex(&ce, NULL); + class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE; + + return class_entry; +} diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h index 30742661c3bba..033aed59c9eac 100644 --- a/ext/dba/php_dba.h +++ b/ext/dba/php_dba.h @@ -52,6 +52,12 @@ typedef struct dba_info { dba_lock lock; } dba_info; +typedef struct dba_connection { + dba_info *info; + zend_string *hash; + zend_object std; +} dba_connection; + #define DBA_DEFAULT_DRIVER_FLAGS -1 #define DBA_LOCK_READER (0x0001) diff --git a/ext/dba/tests/bug36436.phpt b/ext/dba/tests/bug36436.phpt index 9e7603f5a39f9..23fc9a11653dd 100644 --- a/ext/dba/tests/bug36436.phpt +++ b/ext/dba/tests/bug36436.phpt @@ -29,7 +29,8 @@ $db_name = 'bug36436.db'; cleanup_standard_db($db_name); ?> --EXPECTF-- -resource(%d) of type (dba persistent) +object(Dba\Connection)#%d (%d) { +} string(16) "Content String 1" string(13) "[key10]name10" string(13) "[key30]name30" diff --git a/ext/dba/tests/dba015.phpt b/ext/dba/tests/dba015.phpt index 5712edce59d41..52e280ced1f48 100644 --- a/ext/dba/tests/dba015.phpt +++ b/ext/dba/tests/dba015.phpt @@ -45,7 +45,11 @@ echo dba_fetch("key2", $db_file1), "\n"; echo "Test 5 - close 2nd resource\n"; dba_close($db_file2); var_dump($db_file1); -var_dump($db_file2); +try { + dba_exists("key1", $db_file2); +} catch (Error $e) { + echo $e->getMessage() . "\n"; +} echo "Test 6 - query after closing 2nd resource\n"; echo dba_fetch("key1", $db_file1), "\n"; @@ -69,8 +73,9 @@ Test 4 - fetch both rows from first resource This is a test insert 1 This is a test insert 2 Test 5 - close 2nd resource -resource(%d) of type (dba persistent) -resource(%d) of type (Unknown) +object(Dba\Connection)#%d (%d) { +} +DBA connection has already been closed Test 6 - query after closing 2nd resource This is a test insert 1 This is a test insert 2 diff --git a/ext/dba/tests/dba_db4_018.phpt b/ext/dba/tests/dba_db4_018.phpt index dd360a2ec6bba..80d6dc42cc531 100644 --- a/ext/dba/tests/dba_db4_018.phpt +++ b/ext/dba/tests/dba_db4_018.phpt @@ -45,7 +45,11 @@ echo dba_fetch("key2", $db_file1), "\n"; echo "Test 5 - close 2nd resource\n"; dba_close($db_file2); var_dump($db_file1); -var_dump($db_file2); +try { + dba_exists("key1", $db_file2); +} catch (Error $e) { + echo $e->getMessage() . "\n"; +} echo "Test 6 - query after closing 2nd resource\n"; echo dba_fetch("key1", $db_file1), "\n"; @@ -69,8 +73,9 @@ Test 4 - fetch both rows from first resource This is a test insert 1 This is a test insert 2 Test 5 - close 2nd resource -resource(%d) of type (dba persistent) -resource(%d) of type (Unknown) +object(Dba\Connection)#%d (%d) { +} +DBA connection has already been closed Test 6 - query after closing 2nd resource This is a test insert 1 This is a test insert 2 diff --git a/ext/dba/tests/default_handler_ini.phpt b/ext/dba/tests/default_handler_ini.phpt index ba115f76e2037..f81169026f4f5 100644 --- a/ext/dba/tests/default_handler_ini.phpt +++ b/ext/dba/tests/default_handler_ini.phpt @@ -39,7 +39,8 @@ database handler: flatfile Test 1 Warning: ini_set(): No such handler: does_not_exist in %s on line %d -resource(%d) of type (dba) +object(Dba\Connection)#%d (%d) { +} Test 2 Warning: dba_open(): No default handler selected in %s on line %d diff --git a/ext/dba/tests/gh9155.phpt b/ext/dba/tests/gh9155.phpt index 19ea67b2ab872..5224e36c1ff24 100644 --- a/ext/dba/tests/gh9155.phpt +++ b/ext/dba/tests/gh9155.phpt @@ -22,4 +22,5 @@ var_dump($db); require_once(__DIR__ .'/clean.inc'); ?> --EXPECTF-- -resource(%d) of type (dba) +object(Dba\Connection)#%d (%d) { +} diff --git a/ext/dba/tests/value_errors_open.phpt b/ext/dba/tests/value_errors_open.phpt index 9b61ec718f83a..9bbb0b00a94d0 100644 --- a/ext/dba/tests/value_errors_open.phpt +++ b/ext/dba/tests/value_errors_open.phpt @@ -115,7 +115,8 @@ require(__DIR__ .'/clean.inc'); ?> --EXPECTF-- database handler: flatfile -resource(%d) of type (dba) +object(Dba\Connection)#%d (%d) { +} === Invalid arguments dba_open() === Warning: dba_open(): Handler "bogus" is not available in %s on line %d diff --git a/ext/dom/attr.c b/ext/dom/attr.c index 24c92e2a33ab1..9cefed6b74798 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -199,40 +199,10 @@ PHP_METHOD(DOMAttr, isId) } /* }}} end dom_attr_is_id */ -xmlChar *dom_attr_value(const xmlAttr *attr, bool *free) -{ - /* For attributes we can have an optimized fast-path. - * This fast-path is only possible in the (common) case where the attribute - * has a single text child. Note that if the child or the content is NULL, this - * is equivalent to not having content (i.e. the attribute has the empty string as value). */ - - *free = false; - - if (attr->children == NULL) { - return BAD_CAST ""; - } - - if (attr->children->type == XML_TEXT_NODE && attr->children->next == NULL) { - if (attr->children->content == NULL) { - return BAD_CAST ""; - } else { - return attr->children->content; - } - } - - xmlChar *value = xmlNodeGetContent((const xmlNode *) attr); - if (UNEXPECTED(value == NULL)) { - return BAD_CAST ""; - } - - *free = true; - return value; -} - bool dom_compare_value(const xmlAttr *attr, const xmlChar *value) { bool free; - xmlChar *attr_value = dom_attr_value(attr, &free); + xmlChar *attr_value = php_libxml_attr_value(attr, &free); bool result = xmlStrEqual(attr_value, value); if (free) { xmlFree(attr_value); diff --git a/ext/dom/characterdata.c b/ext/dom/characterdata.c index 3e7029e8f1bd5..40e1040b4b2d0 100644 --- a/ext/dom/characterdata.c +++ b/ext/dom/characterdata.c @@ -184,7 +184,7 @@ PHP_METHOD(DOMCharacterData, appendData) dom_character_data_append_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } -PHP_METHOD(DOM_CharacterData, appendData) +PHP_METHOD(Dom_CharacterData, appendData) { dom_character_data_append_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } @@ -255,7 +255,7 @@ PHP_METHOD(DOMCharacterData, insertData) dom_character_data_insert_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } -PHP_METHOD(DOM_CharacterData, insertData) +PHP_METHOD(Dom_CharacterData, insertData) { dom_character_data_insert_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } @@ -327,7 +327,7 @@ PHP_METHOD(DOMCharacterData, deleteData) dom_character_data_delete_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } -PHP_METHOD(DOM_CharacterData, deleteData) +PHP_METHOD(Dom_CharacterData, deleteData) { dom_character_data_delete_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } @@ -407,7 +407,7 @@ PHP_METHOD(DOMCharacterData, replaceData) dom_character_data_replace_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } -PHP_METHOD(DOM_CharacterData, replaceData) +PHP_METHOD(Dom_CharacterData, replaceData) { dom_character_data_replace_data(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } diff --git a/ext/dom/document.c b/ext/dom/document.c index f6a778f086ddd..a84b8cda91e80 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -457,7 +457,7 @@ PHP_METHOD(DOMDocument, createElement) DOM_RET_OBJ(node, intern); } -PHP_METHOD(DOM_Document, createElement) +PHP_METHOD(Dom_Document, createElement) { xmlNode *node; xmlDocPtr docp; @@ -525,19 +525,17 @@ PHP_METHOD(DOMDocument, createDocumentFragment) */ PHP_METHOD(DOMDocument, createTextNode) { - zval *id; xmlNode *node; xmlDocPtr docp; size_t value_len; dom_object *intern; char *value; - id = ZEND_THIS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &value, &value_len) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STRING(value, value_len) + ZEND_PARSE_PARAMETERS_END(); - DOM_GET_OBJ(docp, id, xmlDocPtr, intern); + DOM_GET_OBJ(docp, ZEND_THIS, xmlDocPtr, intern); node = xmlNewDocText(docp, BAD_CAST value); if (!node) { @@ -664,7 +662,7 @@ PHP_METHOD(DOMDocument, createProcessingInstruction) dom_document_create_processing_instruction(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Document, createProcessingInstruction) +PHP_METHOD(Dom_Document, createProcessingInstruction) { dom_document_create_processing_instruction(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -829,13 +827,13 @@ static void dom_modern_document_import_node(INTERNAL_FUNCTION_PARAMETERS, zend_c DOM_RET_OBJ(retnodep, intern); } -PHP_METHOD(DOM_Document, importNode) +PHP_METHOD(Dom_Document, importNode) { dom_modern_document_import_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); } /* }}} end dom_document_import_node */ -PHP_METHOD(DOM_Document, importLegacyNode) +PHP_METHOD(Dom_Document, importLegacyNode) { dom_modern_document_import_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); } @@ -895,15 +893,16 @@ PHP_METHOD(DOMDocument, createElementNS) DOM_RET_OBJ(nodep, intern); } -PHP_METHOD(DOM_Document, createElementNS) +PHP_METHOD(Dom_Document, createElementNS) { xmlDocPtr docp; dom_object *intern; - zend_string *name = NULL, *uri; + zend_string *name, *uri; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S!S", &uri, &name) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR_OR_NULL(uri) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); DOM_GET_OBJ(docp, ZEND_THIS, xmlDocPtr, intern); @@ -913,7 +912,17 @@ PHP_METHOD(DOM_Document, createElementNS) if (errorcode == 0) { php_dom_libxml_ns_mapper *ns_mapper = php_dom_get_ns_mapper(intern); xmlNsPtr ns = php_dom_libxml_ns_mapper_get_ns_raw_prefix_string(ns_mapper, prefix, xmlStrlen(prefix), uri); - xmlNodePtr nodep = xmlNewDocNode(docp, ns, localname, NULL); + + /* Try to create the node with the local name interned. */ + const xmlChar *interned_localname = xmlDictLookup(docp->dict, localname, -1); + xmlNodePtr nodep; + if (interned_localname == NULL) { + nodep = xmlNewDocNodeEatName(docp, ns, localname, NULL); + } else { + xmlFree(localname); + nodep = xmlNewDocNodeEatName(docp, ns, BAD_CAST interned_localname, NULL); + } + if (UNEXPECTED(nodep == NULL)) { php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true); } else { @@ -921,9 +930,9 @@ PHP_METHOD(DOM_Document, createElementNS) } } else { php_dom_throw_error(errorcode, dom_get_strict_error(intern->document)); + xmlFree(localname); } - xmlFree(localname); xmlFree(prefix); } /* }}} end dom_document_create_element_ns */ @@ -1190,7 +1199,7 @@ PHP_METHOD(DOMDocument, adoptNode) dom_document_adopt_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Document, adoptNode) +PHP_METHOD(Dom_Document, adoptNode) { dom_document_adopt_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -1531,7 +1540,7 @@ PHP_METHOD(DOMDocument, save) zval *id; xmlDoc *docp; size_t file_len = 0; - int bytes, format, saveempty = 0; + int saveempty = 0; dom_object *intern; char *file; zend_long options = 0; @@ -1551,12 +1560,12 @@ PHP_METHOD(DOMDocument, save) /* encoding handled by property on doc */ libxml_doc_props const* doc_props = dom_get_doc_props_read_only(intern->document); - format = doc_props->formatoutput; + bool format = doc_props->formatoutput; if (options & LIBXML_SAVE_NOEMPTYTAG) { saveempty = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = 1; } - bytes = xmlSaveFormatFileEnc(file, docp, NULL, format); + zend_long bytes = intern->document->handlers->dump_doc_to_file(file, docp, format, (const char *) docp->encoding); if (options & LIBXML_SAVE_NOEMPTYTAG) { xmlSaveNoEmptyTags = saveempty; } @@ -1575,10 +1584,8 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry zval *nodep = NULL; xmlDoc *docp; xmlNode *node; - xmlBufferPtr buf; - const xmlChar *mem; dom_object *intern, *nodeobj; - int size, format, old_xml_save_no_empty_tags; + int old_xml_save_no_empty_tags; zend_long options = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!l", &nodep, node_ce, &options) != SUCCESS) { @@ -1588,9 +1595,9 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry DOM_GET_OBJ(docp, ZEND_THIS, xmlDocPtr, intern); libxml_doc_props const* doc_props = dom_get_doc_props_read_only(intern->document); - format = doc_props->formatoutput; + bool format = doc_props->formatoutput; - int status = -1; + zend_string *res; if (nodep != NULL) { /* Dump contents of Node */ DOM_GET_OBJ(node, nodep, xmlNodePtr, nodeobj); @@ -1599,38 +1606,13 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry RETURN_FALSE; } - buf = xmlBufferCreate(); - if (!buf) { - php_error_docref(NULL, E_WARNING, "Could not fetch buffer"); - RETURN_FALSE; - } - /* Save libxml2 global, override its vaule, and restore after saving. */ + /* Save libxml2 global, override its value, and restore after saving (don't move me or risk breaking the state + * w.r.t. the implicit return in DOM_GET_OBJ). */ old_xml_save_no_empty_tags = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = (options & LIBXML_SAVE_NOEMPTYTAG) ? 1 : 0; - if (php_dom_follow_spec_intern(intern)) { - xmlSaveCtxtPtr ctxt = xmlSaveToBuffer(buf, (const char *) docp->encoding, XML_SAVE_AS_XML); - if (EXPECTED(ctxt != NULL)) { - xmlCharEncodingHandlerPtr handler = xmlFindCharEncodingHandler((const char *) docp->encoding); - xmlOutputBufferPtr out = xmlOutputBufferCreateBuffer(buf, handler); - if (EXPECTED(out != NULL)) { - status = dom_xml_serialize(ctxt, out, node, format); - status |= xmlOutputBufferFlush(out); - status |= xmlOutputBufferClose(out); - } - (void) xmlSaveClose(ctxt); - xmlCharEncCloseFunc(handler); - } - } else { - status = xmlNodeDump(buf, docp, node, 0, format); - } + res = intern->document->handlers->dump_node_to_str(docp, node, format, (const char *) docp->encoding); xmlSaveNoEmptyTags = old_xml_save_no_empty_tags; } else { - buf = xmlBufferCreate(); - if (!buf) { - php_error_docref(NULL, E_WARNING, "Could not fetch buffer"); - RETURN_FALSE; - } - int converted_options = XML_SAVE_AS_XML; if (options & XML_SAVE_NO_DECL) { converted_options |= XML_SAVE_NO_DECL; @@ -1638,45 +1620,20 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry if (format) { converted_options |= XML_SAVE_FORMAT; } - /* Save libxml2 global, override its vaule, and restore after saving. */ + + /* Save libxml2 global, override its value, and restore after saving. */ old_xml_save_no_empty_tags = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = (options & LIBXML_SAVE_NOEMPTYTAG) ? 1 : 0; - /* Encoding is handled from the encoding property set on the document */ - xmlSaveCtxtPtr ctxt = xmlSaveToBuffer(buf, (const char *) docp->encoding, converted_options); + res = intern->document->handlers->dump_doc_to_str(docp, converted_options, (const char *) docp->encoding); xmlSaveNoEmptyTags = old_xml_save_no_empty_tags; - if (UNEXPECTED(!ctxt)) { - xmlBufferFree(buf); - php_error_docref(NULL, E_WARNING, "Could not create save context"); - RETURN_FALSE; - } - if (php_dom_follow_spec_intern(intern)) { - xmlCharEncodingHandlerPtr handler = xmlFindCharEncodingHandler((const char *) docp->encoding); - xmlOutputBufferPtr out = xmlOutputBufferCreateBuffer(buf, handler); - if (EXPECTED(out != NULL)) { - status = dom_xml_serialize(ctxt, out, (xmlNodePtr) docp, format); - status |= xmlOutputBufferFlush(out); - status |= xmlOutputBufferClose(out); - } else { - xmlCharEncCloseFunc(handler); - } - } else { - status = xmlSaveDoc(ctxt, docp); - } - (void) xmlSaveClose(ctxt); } - if (UNEXPECTED(status < 0)) { - xmlBufferFree(buf); + + if (!res) { php_error_docref(NULL, E_WARNING, "Could not save document"); RETURN_FALSE; + } else { + RETURN_NEW_STR(res); } - mem = xmlBufferContent(buf); - if (!mem) { - xmlBufferFree(buf); - RETURN_FALSE; - } - size = xmlBufferLength(buf); - RETVAL_STRINGL((const char *) mem, size); - xmlBufferFree(buf); } PHP_METHOD(DOMDocument, saveXML) @@ -1684,7 +1641,7 @@ PHP_METHOD(DOMDocument, saveXML) dom_document_save_xml(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); } -PHP_METHOD(DOM_XMLDocument, saveXML) +PHP_METHOD(Dom_XMLDocument, saveXml) { dom_document_save_xml(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); } @@ -2257,7 +2214,7 @@ PHP_METHOD(DOMDocument, registerNodeClass) dom_document_register_node_class(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Document, registerNodeClass) +PHP_METHOD(Dom_Document, registerNodeClass) { dom_document_register_node_class(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index ef81ecaaf7342..227cdafd65a03 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -24,12 +24,11 @@ #include "php_dom.h" #include "dom_ce.h" -typedef struct _nodeIterator nodeIterator; -struct _nodeIterator { +typedef struct nodeIterator { int cur; int index; xmlNode *node; -}; +} nodeIterator; /* Function pointer typedef changed in 2.9.8, see https://github.com/GNOME/libxml2/commit/e03f0a199a67017b2f8052354cf732b2b4cae787 */ #if LIBXML_VERSION >= 20908 @@ -114,8 +113,7 @@ static zend_result php_dom_iterator_valid(zend_object_iterator *iter) /* {{{ */ zval *php_dom_iterator_current_data(zend_object_iterator *iter) /* {{{ */ { php_dom_iterator *iterator = (php_dom_iterator *)iter; - - return &iterator->curobj; + return Z_ISUNDEF(iterator->curobj) ? NULL : &iterator->curobj; } /* }}} */ diff --git a/ext/dom/dom_properties.h b/ext/dom/dom_properties.h index a580b024796f4..fc8e530b01590 100644 --- a/ext/dom/dom_properties.h +++ b/ext/dom/dom_properties.h @@ -36,8 +36,6 @@ zend_result dom_document_doctype_read(dom_object *obj, zval *retval); zend_result dom_document_implementation_read(dom_object *obj, zval *retval); zend_result dom_modern_document_implementation_read(dom_object *obj, zval *retval); zend_result dom_document_document_element_read(dom_object *obj, zval *retval); -zend_result dom_document_actual_encoding_read(dom_object *obj, zval *retval); -zend_result dom_document_actual_encoding_write(dom_object *obj, zval *newval); zend_result dom_document_encoding_read(dom_object *obj, zval *retval); zend_result dom_document_encoding_write(dom_object *obj, zval *newval); zend_result dom_document_standalone_read(dom_object *obj, zval *retval); @@ -89,6 +87,11 @@ zend_result dom_entity_actual_encoding_read(dom_object *obj, zval *retval); zend_result dom_entity_encoding_read(dom_object *obj, zval *retval); zend_result dom_entity_version_read(dom_object *obj, zval *retval); +/* entity reference properties */ +zend_result dom_entity_reference_child_read(dom_object *obj, zval *retval); +zend_result dom_entity_reference_text_content_read(dom_object *obj, zval *retval); +zend_result dom_entity_reference_child_nodes_read(dom_object *obj, zval *retval); + /* namednodemap properties */ zend_result dom_namednodemap_length_read(dom_object *obj, zval *retval); diff --git a/ext/dom/domexception.c b/ext/dom/domexception.c index 80fc27fa7cd61..09532562d1712 100644 --- a/ext/dom/domexception.c +++ b/ext/dom/domexception.c @@ -30,8 +30,6 @@ * Since: */ -extern zend_class_entry *dom_domexception_class_entry; - void php_dom_throw_error_with_message(int error_code, char *error_message, bool strict_error) /* {{{ */ { if (strict_error) { diff --git a/ext/dom/domimplementation.c b/ext/dom/domimplementation.c index b031e793bbc4d..08acb06492b60 100644 --- a/ext/dom/domimplementation.c +++ b/ext/dom/domimplementation.c @@ -107,7 +107,7 @@ PHP_METHOD(DOMImplementation, createDocumentType) DOM_RET_OBJ((xmlNodePtr) doctype, NULL); } -PHP_METHOD(DOM_Implementation, createDocumentType) +PHP_METHOD(Dom_Implementation, createDocumentType) { size_t name_len, publicid_len = 0, systemid_len = 0; const char *name, *publicid = NULL, *systemid = NULL; @@ -249,7 +249,7 @@ PHP_METHOD(DOMImplementation, createDocument) } } -PHP_METHOD(DOM_Implementation, createDocument) +PHP_METHOD(Dom_Implementation, createDocument) { zval *dtd = NULL; xmlDtdPtr doctype = NULL; @@ -306,7 +306,7 @@ PHP_METHOD(DOM_Implementation, createDocument) (xmlNodePtr) document, NULL ); - intern->document->class_type = PHP_LIBXML_CLASS_MODERN; + dom_set_xml_class(intern->document); intern->document->private_data = php_dom_libxml_ns_mapper_header(ns_mapper); /* 4. If doctype is non-null, append doctype to document. */ @@ -343,7 +343,7 @@ PHP_METHOD(DOM_Implementation, createDocument) /* }}} end dom_domimplementation_create_document */ /* {{{ URL: https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument */ -PHP_METHOD(DOM_Implementation, createHTMLDocument) +PHP_METHOD(Dom_Implementation, createHTMLDocument) { const char *title = NULL; size_t title_len = 0; @@ -407,7 +407,7 @@ PHP_METHOD(DOM_Implementation, createHTMLDocument) (xmlNodePtr) doc, NULL ); - intern->document->class_type = PHP_LIBXML_CLASS_MODERN; + dom_set_xml_class(intern->document); intern->document->private_data = php_dom_libxml_ns_mapper_header(ns_mapper); } /* }}} */ diff --git a/ext/dom/element.c b/ext/dom/element.c index 1b9038ef429a2..348c669e1b4a2 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -572,7 +572,7 @@ PHP_METHOD(DOMElement, removeAttribute) RETURN_BOOL(dom_remove_attribute(nodep, attrp)); } -PHP_METHOD(DOM_Element, removeAttribute) +PHP_METHOD(Dom_Element, removeAttribute) { xmlNodePtr nodep, attrp; dom_object *intern; @@ -749,7 +749,7 @@ PHP_METHOD(DOMElement, removeAttributeNode) dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); } -PHP_METHOD(DOM_Element, removeAttributeNode) +PHP_METHOD(Dom_Element, removeAttributeNode) { dom_element_remove_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); } @@ -785,7 +785,7 @@ PHP_METHOD(DOMElement, getElementsByTagName) dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Element, getElementsByTagName) +PHP_METHOD(Dom_Element, getElementsByTagName) { dom_element_get_elements_by_tag_name(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -1172,7 +1172,7 @@ PHP_METHOD(DOMElement, setAttributeNodeNS) dom_element_set_attribute_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* use_ns */ true, /* modern */ false); } -PHP_METHOD(DOM_Element, setAttributeNodeNS) +PHP_METHOD(Dom_Element, setAttributeNodeNS) { dom_element_set_attribute_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, /* use_ns */ true, /* modern */ true); } @@ -1208,7 +1208,7 @@ PHP_METHOD(DOMElement, getElementsByTagNameNS) dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Element, getElementsByTagNameNS) +PHP_METHOD(Dom_Element, getElementsByTagNameNS) { dom_element_get_elements_by_tag_name_ns(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -1387,7 +1387,7 @@ PHP_METHOD(DOMElement, setIdAttributeNode) dom_element_set_id_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_attr_class_entry); } -PHP_METHOD(DOM_Element, setIdAttributeNode) +PHP_METHOD(Dom_Element, setIdAttributeNode) { dom_element_set_id_attribute_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_attr_class_entry); } @@ -1595,7 +1595,7 @@ PHP_METHOD(DOMElement, insertAdjacentElement) dom_element_insert_adjacent_element(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_element_class_entry); } -PHP_METHOD(DOM_Element, insertAdjacentElement) +PHP_METHOD(Dom_Element, insertAdjacentElement) { dom_element_insert_adjacent_element(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_element_class_entry); } diff --git a/ext/dom/entity.c b/ext/dom/entity.c index 95448f5ff2fd4..2943e364ed402 100644 --- a/ext/dom/entity.c +++ b/ext/dom/entity.c @@ -44,7 +44,7 @@ zend_result dom_entity_public_id_read(dom_object *obj, zval *retval) if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY || !nodep->ExternalID) { ZVAL_NULL(retval); } else { - ZVAL_STRING(retval, (char *) (nodep->ExternalID)); + ZVAL_STRING(retval, (const char *) nodep->ExternalID); } return SUCCESS; @@ -64,7 +64,7 @@ zend_result dom_entity_system_id_read(dom_object *obj, zval *retval) if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { ZVAL_NULL(retval); } else { - ZVAL_STRING(retval, (char *) (nodep->SystemID)); + ZVAL_STRING(retval, (const char *) nodep->SystemID); } return SUCCESS; diff --git a/ext/dom/entityreference.c b/ext/dom/entityreference.c index 2a11f69366097..c0b640d39aa60 100644 --- a/ext/dom/entityreference.c +++ b/ext/dom/entityreference.c @@ -22,6 +22,7 @@ #include "php.h" #if defined(HAVE_LIBXML) && defined(HAVE_DOM) #include "php_dom.h" +#include "dom_properties.h" /* * class DOMEntityReference extends DOMNode @@ -65,4 +66,48 @@ PHP_METHOD(DOMEntityReference, __construct) } /* }}} end DOMEntityReference::__construct */ +/* The following property handlers are necessary because of special lifetime management with entities and entity + * references. The issue is that entity references hold a reference to an entity declaration, but don't + * register that reference anywhere. When the entity declaration disappears we have no way of notifying the + * entity references. Override the property handlers for the declaration-accessing properties to fix this problem. */ + +xmlEntityPtr dom_entity_reference_fetch_and_sync_declaration(xmlNodePtr reference) +{ + xmlEntityPtr entity = xmlGetDocEntity(reference->doc, reference->name); + reference->children = (xmlNodePtr) entity; + reference->last = (xmlNodePtr) entity; + reference->content = entity ? entity->content : NULL; + return entity; +} + +zend_result dom_entity_reference_child_read(dom_object *obj, zval *retval) +{ + DOM_PROP_NODE(xmlNodePtr, nodep, obj); + + xmlEntityPtr entity = dom_entity_reference_fetch_and_sync_declaration(nodep); + if (entity == NULL) { + ZVAL_NULL(retval); + return SUCCESS; + } + + php_dom_create_object((xmlNodePtr) entity, retval, obj); + return SUCCESS; +} + +zend_result dom_entity_reference_text_content_read(dom_object *obj, zval *retval) +{ + DOM_PROP_NODE(xmlNodePtr, nodep, obj); + + dom_entity_reference_fetch_and_sync_declaration(nodep); + return dom_node_text_content_read(obj, retval); +} + +zend_result dom_entity_reference_child_nodes_read(dom_object *obj, zval *retval) +{ + DOM_PROP_NODE(xmlNodePtr, nodep, obj); + + dom_entity_reference_fetch_and_sync_declaration(nodep); + return dom_node_child_nodes_read(obj, retval); +} + #endif diff --git a/ext/dom/html5_parser.c b/ext/dom/html5_parser.c index 973586155078c..13fbbe58149f5 100644 --- a/ext/dom/html5_parser.c +++ b/ext/dom/html5_parser.c @@ -73,7 +73,7 @@ static const php_dom_ns_magic_token *get_libxml_namespace_href(uintptr_t lexbor_ } } -static xmlNodePtr lexbor_libxml2_bridge_new_text_node_fast(xmlDocPtr lxml_doc, const lxb_char_t *data, size_t data_length, bool compact_text_nodes) +static zend_always_inline xmlNodePtr lexbor_libxml2_bridge_new_text_node_fast(xmlDocPtr lxml_doc, const lxb_char_t *data, size_t data_length, bool compact_text_nodes) { if (compact_text_nodes && data_length < LXML_INTERNED_STRINGS_SIZE) { /* See xmlSAX2TextNode() in libxml2 */ @@ -132,7 +132,7 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert( xmlNodePtr lxml_element = xmlNewDocNode(lxml_doc, NULL, name, NULL); if (UNEXPECTED(lxml_element == NULL)) { retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OOM; - goto out; + break; } xmlAddChild(lxml_parent, lxml_element); lxml_element->line = sanitize_line_nr(node->line); @@ -175,13 +175,13 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert( if (UNEXPECTED(local_name_length >= INT_MAX || value_length >= INT_MAX)) { retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OVERFLOW; - goto out; + break; } xmlAttrPtr lxml_attr = xmlMalloc(sizeof(xmlAttr)); if (UNEXPECTED(lxml_attr == NULL)) { retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OOM; - goto out; + break; } memset(lxml_attr, 0, sizeof(xmlAttr)); @@ -193,7 +193,7 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert( if (UNEXPECTED(lxml_text == NULL)) { xmlFreeProp(lxml_attr); retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OOM; - goto out; + break; } lxml_attr->children = lxml_attr->last = lxml_text; @@ -226,7 +226,7 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert( last_added_attr = lxml_attr; /* xmlIsID does some other stuff too that is irrelevant here. */ - if (local_name_length == 2 && local_name[0] == 'i' && local_name[1] == 'd') { + if (local_name_length == 2 && local_name[0] == 'i' && local_name[1] == 'd' && attr->node.ns == LXB_NS_HTML) { xmlAddID(NULL, lxml_doc, value, lxml_attr); } @@ -238,12 +238,12 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert( size_t data_length = text->char_data.data.length; if (UNEXPECTED(data_length >= INT_MAX)) { retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OVERFLOW; - goto out; + break; } xmlNodePtr lxml_text = lexbor_libxml2_bridge_new_text_node_fast(lxml_doc, data, data_length, compact_text_nodes); if (UNEXPECTED(lxml_text == NULL)) { retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OOM; - goto out; + break; } xmlAddChild(lxml_parent, lxml_text); if (node->line >= USHRT_MAX) { @@ -266,7 +266,7 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert( ); if (UNEXPECTED(lxml_dtd == NULL)) { retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OOM; - goto out; + break; } /* libxml2 doesn't support line numbers on this anyway, it returns -1 instead, so don't bother */ } else if (node->type == LXB_DOM_NODE_TYPE_COMMENT) { @@ -274,14 +274,13 @@ static lexbor_libxml2_bridge_status lexbor_libxml2_bridge_convert( xmlNodePtr lxml_comment = xmlNewDocComment(lxml_doc, comment->char_data.data.data); if (UNEXPECTED(lxml_comment == NULL)) { retval = LEXBOR_LIBXML2_BRIDGE_STATUS_OOM; - goto out; + break; } xmlAddChild(lxml_parent, lxml_comment); lxml_comment->line = sanitize_line_nr(node->line); } } -out: lexbor_array_obj_destroy(&work_list, false); return retval; } diff --git a/ext/dom/html_collection.c b/ext/dom/html_collection.c index 3b74074559a26..c207a87d159a9 100644 --- a/ext/dom/html_collection.c +++ b/ext/dom/html_collection.c @@ -89,7 +89,7 @@ static void dom_html_collection_named_item_into_zval(zval *return_value, zend_st } } -PHP_METHOD(DOM_HTMLCollection, namedItem) +PHP_METHOD(Dom_HTMLCollection, namedItem) { zend_string *key; ZEND_PARSE_PARAMETERS_START(1, 1) diff --git a/ext/dom/html_document.c b/ext/dom/html_document.c index fe0a447fbb29d..9734ab863b6cd 100644 --- a/ext/dom/html_document.c +++ b/ext/dom/html_document.c @@ -30,16 +30,15 @@ #include /* Implementation defined, but as HTML5 defaults in all other cases to UTF-8, we'll do the same. */ -#define DOM_FALLBACK_ENCODING_NAME "UTF-8" #define DOM_FALLBACK_ENCODING_ID LXB_ENCODING_UTF_8 -typedef struct _dom_line_column_cache { +typedef struct dom_line_column_cache { size_t last_line; size_t last_column; size_t last_offset; } dom_line_column_cache; -typedef struct _dom_lexbor_libxml2_bridge_application_data { +typedef struct dom_lexbor_libxml2_bridge_application_data { const char *input_name; const lxb_codepoint_t *current_input_codepoints; const char *current_input_characters; @@ -49,14 +48,14 @@ typedef struct _dom_lexbor_libxml2_bridge_application_data { bool html_no_implied; } dom_lexbor_libxml2_bridge_application_data; -typedef struct _dom_character_encoding_data { +typedef struct dom_character_encoding_data { const lxb_encoding_data_t *encoding_data; size_t bom_shift; } dom_character_encoding_data; typedef zend_result (*dom_write_output)(void*, const char *, size_t); -typedef struct _dom_output_ctx { +typedef struct dom_output_ctx { const lxb_encoding_data_t *encoding_data; const lxb_encoding_data_t *decoding_data; lxb_encoding_encode_t *encode; @@ -67,7 +66,7 @@ typedef struct _dom_output_ctx { dom_write_output write_output; } dom_output_ctx; -typedef struct _dom_decoding_encoding_ctx { +typedef struct dom_decoding_encoding_ctx { /* We can skip some conversion if the input and output encoding are both UTF-8, * we only have to validate and substitute replacement characters */ bool fast_path; /* Put first, near the encode & decode structures, for cache locality */ @@ -722,13 +721,13 @@ static bool check_options_validity(uint32_t arg_num, zend_long options) "LIBXML_NOERROR, " "LIBXML_COMPACT, " "LIBXML_HTML_NOIMPLIED, " - "DOM\\NO_DEFAULT_NS)"); + "Dom\\NO_DEFAULT_NS)"); return false; } return true; } -PHP_METHOD(DOM_HTMLDocument, createEmpty) +PHP_METHOD(Dom_HTMLDocument, createEmpty) { const char *encoding = "UTF-8"; size_t encoding_len = strlen("UTF-8"); @@ -756,7 +755,7 @@ PHP_METHOD(DOM_HTMLDocument, createEmpty) (xmlNodePtr) lxml_doc, NULL ); - intern->document->class_type = PHP_LIBXML_CLASS_MODERN; + dom_set_xml_class(intern->document); intern->document->private_data = php_dom_libxml_ns_mapper_header(php_dom_libxml_ns_mapper_create()); return; @@ -775,7 +774,7 @@ static bool dom_should_register_error_handlers(zend_long options) return php_libxml_uses_internal_errors() || ((EG(error_reporting) | EG(user_error_handler_error_reporting)) & E_WARNING); } -PHP_METHOD(DOM_HTMLDocument, createFromString) +PHP_METHOD(Dom_HTMLDocument, createFromString) { const char *source, *override_encoding = NULL; size_t source_len, override_encoding_len; @@ -916,7 +915,7 @@ PHP_METHOD(DOM_HTMLDocument, createFromString) (xmlNodePtr) lxml_doc, NULL ); - intern->document->class_type = PHP_LIBXML_CLASS_MODERN; + dom_set_xml_class(intern->document); intern->document->private_data = php_dom_libxml_ns_mapper_header(ns_mapper); return; @@ -926,7 +925,7 @@ PHP_METHOD(DOM_HTMLDocument, createFromString) RETURN_THROWS(); } -PHP_METHOD(DOM_HTMLDocument, createFromFile) +PHP_METHOD(Dom_HTMLDocument, createFromFile) { const char *filename, *override_encoding = NULL; php_dom_libxml_ns_mapper *ns_mapper = NULL; @@ -1136,7 +1135,7 @@ PHP_METHOD(DOM_HTMLDocument, createFromFile) (xmlNodePtr) lxml_doc, NULL ); - intern->document->class_type = PHP_LIBXML_CLASS_MODERN; + dom_set_xml_class(intern->document); intern->document->private_data = php_dom_libxml_ns_mapper_header(ns_mapper); return; @@ -1265,7 +1264,7 @@ static zend_result dom_common_save(dom_output_ctx *output_ctx, const xmlDoc *doc return SUCCESS; } -PHP_METHOD(DOM_HTMLDocument, saveHTMLFile) +PHP_METHOD(Dom_HTMLDocument, saveHtmlFile) { zval *id; xmlDoc *docp; @@ -1304,7 +1303,7 @@ PHP_METHOD(DOM_HTMLDocument, saveHTMLFile) RETURN_LONG(bytes); } -PHP_METHOD(DOM_HTMLDocument, saveHTML) +PHP_METHOD(Dom_HTMLDocument, saveHtml) { zval *nodep = NULL; const xmlDoc *docp; diff --git a/ext/dom/namespace_compat.c b/ext/dom/namespace_compat.c index 29378b583372e..3754a2c4e04cb 100644 --- a/ext/dom/namespace_compat.c +++ b/ext/dom/namespace_compat.c @@ -54,9 +54,9 @@ static HashTable *php_dom_libxml_ns_mapper_ensure_prefix_map(php_dom_libxml_ns_m if (zv == NULL) { prefix_map = emalloc(sizeof(HashTable)); zend_hash_init(prefix_map, 0, NULL, php_dom_libxml_ns_mapper_prefix_map_element_dtor, false); - zval zv; - ZVAL_ARR(&zv, prefix_map); - zend_hash_add_new(&mapper->uri_to_prefix_map, *uri, &zv); + zval zv_prefix_map; + ZVAL_ARR(&zv_prefix_map, prefix_map); + zend_hash_add_new(&mapper->uri_to_prefix_map, *uri, &zv_prefix_map); } else { /* cast to Bucket* only works if this holds, I would prefer a static assert but we're stuck at C99. */ ZEND_ASSERT(XtOffsetOf(Bucket, val) == 0); @@ -363,7 +363,7 @@ static zend_always_inline zend_long dom_mangle_pointer_for_key(void *ptr) #endif } -static zend_always_inline void php_dom_libxml_reconcile_modern_single_node(dom_libxml_reconcile_ctx *ctx, xmlNodePtr ns_holder, xmlNodePtr node) +static zend_always_inline void php_dom_libxml_reconcile_modern_single_node(dom_libxml_reconcile_ctx *ctx, xmlNodePtr node) { ZEND_ASSERT(node->ns != NULL); @@ -404,12 +404,12 @@ static zend_always_inline void php_dom_libxml_reconcile_modern_single_element_no ZEND_ASSERT(node->nsDef == NULL); if (node->ns != NULL) { - php_dom_libxml_reconcile_modern_single_node(ctx, node, node); + php_dom_libxml_reconcile_modern_single_node(ctx, node); } for (xmlAttrPtr attr = node->properties; attr != NULL; attr = attr->next) { if (attr->ns != NULL) { - php_dom_libxml_reconcile_modern_single_node(ctx, node, (xmlNodePtr) attr); + php_dom_libxml_reconcile_modern_single_node(ctx, (xmlNodePtr) attr); } } } diff --git a/ext/dom/node.c b/ext/dom/node.c index 86585c085deb0..14992da952676 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -768,7 +768,7 @@ zend_result dom_node_text_content_write(dom_object *obj, zval *newval) /* }}} */ -static xmlNodePtr _php_dom_insert_fragment(xmlNodePtr nodep, xmlNodePtr prevsib, xmlNodePtr nextsib, xmlNodePtr fragment, dom_object *intern) /* {{{ */ +static xmlNodePtr dom_insert_fragment(xmlNodePtr nodep, xmlNodePtr prevsib, xmlNodePtr nextsib, xmlNodePtr fragment, dom_object *intern) /* {{{ */ { xmlNodePtr newchild, node; @@ -908,7 +908,7 @@ static void dom_node_insert_before_legacy(zval *return_value, zval *ref, dom_obj } } else if (child->type == XML_DOCUMENT_FRAG_NODE) { xmlNodePtr last = child->last; - new_child = _php_dom_insert_fragment(parentp, refp->prev, refp, child, intern); + new_child = dom_insert_fragment(parentp, refp->prev, refp, child, intern); dom_reconcile_ns_list(parentp->doc, new_child, last); } else { new_child = xmlAddPrevSibling(refp, child); @@ -958,7 +958,7 @@ static void dom_node_insert_before_legacy(zval *return_value, zval *ref, dom_obj } } else if (child->type == XML_DOCUMENT_FRAG_NODE) { xmlNodePtr last = child->last; - new_child = _php_dom_insert_fragment(parentp, parentp->last, NULL, child, intern); + new_child = dom_insert_fragment(parentp, parentp->last, NULL, child, intern); dom_reconcile_ns_list(parentp->doc, new_child, last); } else { new_child = xmlAddChild(parentp, child); @@ -978,7 +978,7 @@ static void dom_node_insert_before_legacy(zval *return_value, zval *ref, dom_obj /* }}} end dom_node_insert_before */ /* https://dom.spec.whatwg.org/#dom-node-insertbefore */ -static void dom_node_insert_before_modern(zval *return_value, zval *ref, dom_object *intern, dom_object *childobj, xmlNodePtr parentp, xmlNodePtr child) +static void dom_node_insert_before_modern(zval *return_value, zval *ref, dom_object *intern, xmlNodePtr parentp, xmlNodePtr child) { xmlNodePtr refp = NULL; dom_object *refobjp; @@ -1010,7 +1010,7 @@ static void dom_node_insert_before(INTERNAL_FUNCTION_PARAMETERS, bool modern) DOM_GET_OBJ(child, node, xmlNodePtr, childobj); if (modern) { - dom_node_insert_before_modern(return_value, ref, intern, childobj, parentp, child); + dom_node_insert_before_modern(return_value, ref, intern, parentp, child); } else { dom_node_insert_before_legacy(return_value, ref, intern, childobj, parentp, child); } @@ -1021,7 +1021,7 @@ PHP_METHOD(DOMNode, insertBefore) dom_node_insert_before(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Node, insertBefore) +PHP_METHOD(Dom_Node, insertBefore) { dom_node_insert_before(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -1176,7 +1176,7 @@ static void dom_node_replace_child(INTERNAL_FUNCTION_PARAMETERS, bool modern) xmlUnlinkNode(oldchild); xmlNodePtr last = newchild->last; - newchild = _php_dom_insert_fragment(nodep, prevsib, nextsib, newchild, intern); + newchild = dom_insert_fragment(nodep, prevsib, nextsib, newchild, intern); if (newchild && !modern) { dom_reconcile_ns_list(nodep->doc, newchild, last); } @@ -1207,7 +1207,7 @@ PHP_METHOD(DOMNode, replaceChild) dom_node_replace_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Node, replaceChild) +PHP_METHOD(Dom_Node, replaceChild) { dom_node_replace_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -1218,16 +1218,15 @@ PHP_METHOD(DOM_Node, replaceChild) */ static void dom_node_remove_child(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *node_ce) { - zval *id, *node; + zval *node; xmlNodePtr child, nodep; dom_object *intern, *childobj; - id = ZEND_THIS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &node, node_ce) == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(node, node_ce) + ZEND_PARSE_PARAMETERS_END(); - DOM_GET_OBJ(nodep, id, xmlNodePtr, intern); + DOM_GET_OBJ(nodep, ZEND_THIS, xmlNodePtr, intern); if (!dom_node_children_valid(nodep)) { RETURN_FALSE; @@ -1258,7 +1257,7 @@ PHP_METHOD(DOMNode, removeChild) dom_node_remove_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); } -PHP_METHOD(DOM_Node, removeChild) +PHP_METHOD(Dom_Node, removeChild) { dom_node_remove_child(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); } @@ -1344,7 +1343,7 @@ static void dom_node_append_child_legacy(zval *return_value, dom_object *intern, php_dom_reconcile_attribute_namespace_after_insertion((xmlAttrPtr) new_child); } else if (child->type == XML_DOCUMENT_FRAG_NODE) { xmlNodePtr last = child->last; - new_child = _php_dom_insert_fragment(nodep, nodep->last, NULL, child, intern); + new_child = dom_insert_fragment(nodep, nodep->last, NULL, child, intern); dom_reconcile_ns_list(nodep->doc, new_child, last); } else if (child->type == XML_DTD_NODE) { if (nodep->doc->intSubset != NULL) { @@ -1390,7 +1389,7 @@ PHP_METHOD(DOMNode, appendChild) dom_node_append_child_legacy(return_value, intern, childobj, nodep, child); } -PHP_METHOD(DOM_Node, appendChild) +PHP_METHOD(Dom_Node, appendChild) { zval *node; xmlNodePtr nodep, child; @@ -1420,26 +1419,14 @@ PHP_METHOD(DOM_Node, appendChild) */ PHP_METHOD(DOMNode, hasChildNodes) { - zval *id; xmlNode *nodep; dom_object *intern; - id = ZEND_THIS; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); - DOM_GET_OBJ(nodep, id, xmlNodePtr, intern); - - if (!dom_node_children_valid(nodep)) { - RETURN_FALSE; - } + DOM_GET_OBJ(nodep, ZEND_THIS, xmlNodePtr, intern); - if (nodep->children) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(dom_node_children_valid(nodep) && nodep->children != NULL); } /* }}} end dom_node_has_child_nodes */ @@ -1552,25 +1539,14 @@ Since: DOM Level 2 */ PHP_METHOD(DOMNode, hasAttributes) { - zval *id; xmlNode *nodep; dom_object *intern; - id = ZEND_THIS; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } - - DOM_GET_OBJ(nodep, id, xmlNodePtr, intern); + ZEND_PARSE_PARAMETERS_NONE(); - if (nodep->type != XML_ELEMENT_NODE) - RETURN_FALSE; + DOM_GET_OBJ(nodep, ZEND_THIS, xmlNodePtr, intern); - if (nodep->properties) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(nodep->type == XML_ELEMENT_NODE && nodep->properties != NULL); } /* }}} end dom_node_has_attributes */ @@ -1604,7 +1580,7 @@ PHP_METHOD(DOMNode, isSameNode) dom_node_is_same_node(INTERNAL_FUNCTION_PARAM_PASSTHRU, node); } -PHP_METHOD(DOM_Node, isSameNode) +PHP_METHOD(Dom_Node, isSameNode) { zval *node; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O!", &node, dom_modern_node_class_entry) != SUCCESS) { @@ -1804,7 +1780,7 @@ PHP_METHOD(DOMNode, isEqualNode) dom_node_is_equal_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Node, isEqualNode) +PHP_METHOD(Dom_Node, isEqualNode) { dom_node_is_equal_node_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -1901,7 +1877,7 @@ PHP_METHOD(DOMNode, lookupPrefix) dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Node, lookupPrefix) +PHP_METHOD(Dom_Node, lookupPrefix) { dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -2013,7 +1989,7 @@ PHP_METHOD(DOMNode, isDefaultNamespace) RETURN_FALSE; } -PHP_METHOD(DOM_Node, isDefaultNamespace) +PHP_METHOD(Dom_Node, isDefaultNamespace) { zval *id; xmlNodePtr nodep; @@ -2155,7 +2131,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ char *xquery; /* Find "query" key */ - tmp = zend_hash_find(ht, ZSTR_KNOWN(ZEND_STR_QUERY)); + tmp = zend_hash_find_deref(ht, ZSTR_KNOWN(ZEND_STR_QUERY)); if (!tmp) { /* if mode == 0 then $xpath arg is 3, if mode == 1 then $xpath is 4 */ zend_argument_value_error(3 + mode, "must have a \"query\" key"); @@ -2171,12 +2147,13 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ ctxp = xmlXPathNewContext(docp); ctxp->node = nodep; - tmp = zend_hash_str_find(ht, "namespaces", sizeof("namespaces")-1); + tmp = zend_hash_str_find_deref(ht, "namespaces", sizeof("namespaces")-1); if (tmp && Z_TYPE_P(tmp) == IS_ARRAY && !HT_IS_PACKED(Z_ARRVAL_P(tmp))) { zval *tmpns; zend_string *prefix; ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(tmp), prefix, tmpns) { + ZVAL_DEREF(tmpns); if (Z_TYPE_P(tmpns) == IS_STRING) { if (prefix) { xmlXPathRegisterNs(ctxp, BAD_CAST ZSTR_VAL(prefix), BAD_CAST Z_STRVAL_P(tmpns)); @@ -2207,6 +2184,7 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ inclusive_ns_prefixes = safe_emalloc(zend_hash_num_elements(Z_ARRVAL_P(ns_prefixes)) + 1, sizeof(xmlChar *), 0); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(ns_prefixes), tmpns) { + ZVAL_DEREF(tmpns); if (Z_TYPE_P(tmpns) == IS_STRING) { inclusive_ns_prefixes[nscount++] = BAD_CAST Z_STRVAL_P(tmpns); } @@ -2246,9 +2224,9 @@ static void dom_canonicalization(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ RETVAL_FALSE; } else { if (mode == 0) { - ret = xmlOutputBufferGetSize(buf); - if (ret > 0) { - RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret); + size_t size = xmlOutputBufferGetSize(buf); + if (size > 0) { + RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), size); } else { RETVAL_EMPTY_STRING(); } @@ -2314,7 +2292,7 @@ PHP_METHOD(DOMNode, getNodePath) dom_node_get_node_path(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } -PHP_METHOD(DOM_Node, getNodePath) +PHP_METHOD(Dom_Node, getNodePath) { dom_node_get_node_path(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } @@ -2377,7 +2355,7 @@ PHP_METHOD(DOMNode, contains) RETURN_BOOL(dom_node_contains(thisp, otherp)); } -PHP_METHOD(DOM_Node, contains) +PHP_METHOD(Dom_Node, contains) { zval *other, *id; xmlNodePtr otherp, thisp; @@ -2593,7 +2571,7 @@ PHP_METHOD(DOMNode, compareDocumentPosition) dom_node_compare_document_position(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_node_class_entry); } -PHP_METHOD(DOM_Node, compareDocumentPosition) +PHP_METHOD(Dom_Node, compareDocumentPosition) { dom_node_compare_document_position(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_modern_node_class_entry); } @@ -2608,7 +2586,7 @@ PHP_METHOD(DOM_Node, compareDocumentPosition) * - If the user implements __sleep / __wakeup, then it's also not a problem because they will not enter the throwing methods. */ -PHP_METHOD(DOM_Node, __construct) +PHP_METHOD(Dom_Node, __construct) { ZEND_UNREACHABLE(); } diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index b615705b621f8..2ee177c89bd82 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -50,7 +50,17 @@ static zend_always_inline void reset_objmap_cache(dom_nnodemap_object *objmap) objmap->cached_length = -1; } -int php_dom_get_nodelist_length(dom_object *obj) +static xmlNodePtr dom_nodelist_iter_start_first_child(xmlNodePtr nodep) +{ + if (nodep->type == XML_ENTITY_REF_NODE) { + /* See entityreference.c */ + dom_entity_reference_fetch_and_sync_declaration(nodep); + } + + return nodep->children; +} + +zend_long php_dom_get_nodelist_length(dom_object *obj) { dom_nnodemap_object *objmap = (dom_nnodemap_object *) obj->ptr; if (!objmap) { @@ -84,7 +94,7 @@ int php_dom_get_nodelist_length(dom_object *obj) int count = 0; if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { - xmlNodePtr curnode = nodep->children; + xmlNodePtr curnode = dom_nodelist_iter_start_first_child(nodep); if (curnode) { count++; while (curnode->next != NULL) { @@ -114,20 +124,13 @@ zend_result dom_nodelist_length_read(dom_object *obj, zval *retval) ZVAL_LONG(retval, php_dom_get_nodelist_length(obj)); return SUCCESS; } - +/* }}} */ /* {{{ */ PHP_METHOD(DOMNodeList, count) { - zval *id; - dom_object *intern; - - id = ZEND_THIS; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } - - intern = Z_DOMOBJ_P(id); + ZEND_PARSE_PARAMETERS_NONE(); + dom_object *intern = Z_DOMOBJ_P(ZEND_THIS); RETURN_LONG(php_dom_get_nodelist_length(intern)); } /* }}} end dom_nodelist_count */ @@ -177,7 +180,7 @@ void php_dom_nodelist_get_item_into_zval(dom_nnodemap_object *objmap, zend_long int count = 0; if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) { if (restart) { - nodep = nodep->children; + nodep = dom_nodelist_iter_start_first_child(nodep); } while (count < relative_index && nodep != NULL) { count++; @@ -243,10 +246,7 @@ PHP_METHOD(DOMNodeList, item) ZEND_METHOD(DOMNodeList, getIterator) { - if (zend_parse_parameters_none() == FAILURE) { - return; - } - + ZEND_PARSE_PARAMETERS_NONE(); zend_create_internal_iterator_zval(return_value, ZEND_THIS); } diff --git a/ext/dom/nodelist.h b/ext/dom/nodelist.h index 72264d683f338..5ac3de1e46c44 100644 --- a/ext/dom/nodelist.h +++ b/ext/dom/nodelist.h @@ -23,7 +23,7 @@ enum dom_nodelist_dimension_index_type { DOM_NODELIST_DIM_LONG, }; -typedef struct _dom_nodelist_dimension_index { +typedef struct dom_nodelist_dimension_index { union { zend_long lval; zend_string *str; @@ -32,7 +32,7 @@ typedef struct _dom_nodelist_dimension_index { } dom_nodelist_dimension_index; void php_dom_nodelist_get_item_into_zval(dom_nnodemap_object *objmap, zend_long index, zval *return_value); -int php_dom_get_nodelist_length(dom_object *obj); +zend_long php_dom_get_nodelist_length(dom_object *obj); dom_nodelist_dimension_index dom_modern_nodelist_get_index(const zval *offset); zval *dom_modern_nodelist_read_dimension(zend_object *object, zval *offset, int type, zval *rv); int dom_modern_nodelist_has_dimension(zend_object *object, zval *member, int check_empty); diff --git a/ext/dom/parentnode.c b/ext/dom/parentnode.c index afc87c6495e44..3969ee5e97043 100644 --- a/ext/dom/parentnode.c +++ b/ext/dom/parentnode.c @@ -108,7 +108,7 @@ zend_result dom_parent_node_child_element_count(dom_object *obj, zval *retval) } /* }}} */ -static bool dom_is_node_in_list(const zval *nodes, uint32_t nodesc, const xmlNodePtr node_to_find) +static bool dom_is_node_in_list(const zval *nodes, uint32_t nodesc, const xmlNode *node_to_find) { for (uint32_t i = 0; i < nodesc; i++) { if (Z_TYPE(nodes[i]) == IS_OBJECT) { @@ -691,7 +691,7 @@ void dom_parent_node_before(dom_object *context, zval *nodes, uint32_t nodesc) php_dom_pre_insert(context->document, fragment, parentNode, viable_previous_sibling); } -static zend_result dom_child_removal_preconditions(const xmlNodePtr child, int stricterror) +static zend_result dom_child_removal_preconditions(const xmlNode *child, int stricterror) { if (dom_node_is_read_only(child) == SUCCESS || (child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) { diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 978fbe96dec01..0f2d2b67f512e 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -107,6 +107,8 @@ static HashTable dom_documentfragment_prop_handlers; static HashTable dom_modern_documentfragment_prop_handlers; static HashTable dom_node_prop_handlers; static HashTable dom_modern_node_prop_handlers; +static HashTable dom_entity_reference_prop_handlers; +static HashTable dom_modern_entity_reference_prop_handlers; static HashTable dom_nodelist_prop_handlers; static HashTable dom_namednodemap_prop_handlers; static HashTable dom_characterdata_prop_handlers; @@ -144,8 +146,7 @@ typedef struct _dom_prop_handler { dom_write_t write_func; } dom_prop_handler; -/* {{{ int dom_node_is_read_only(xmlNodePtr node) */ -int dom_node_is_read_only(xmlNodePtr node) { +int dom_node_is_read_only(const xmlNode *node) { switch (node->type) { case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: @@ -166,9 +167,8 @@ int dom_node_is_read_only(xmlNodePtr node) { } } } -/* }}} end dom_node_is_read_only */ -bool dom_node_children_valid(xmlNodePtr node) { +bool dom_node_children_valid(const xmlNode *node) { switch (node->type) { case XML_DOCUMENT_TYPE_NODE: case XML_DTD_NODE: @@ -244,6 +244,7 @@ static void dom_copy_document_ref(php_libxml_ref_obj *source_doc, php_libxml_ref } dest_doc->class_type = source_doc->class_type; + dest_doc->handlers = source_doc->handlers; } } @@ -519,7 +520,7 @@ static void dom_import_simplexml_common(INTERNAL_FUNCTION_PARAMETERS, php_libxml if (new_class == PHP_LIBXML_CLASS_MODERN) { zend_argument_type_error(1, "must not be already imported as a DOMNode"); } else { - zend_argument_type_error(1, "must not be already imported as a DOM\\Node"); + zend_argument_type_error(1, "must not be already imported as a Dom\\Node"); } RETURN_THROWS(); } @@ -543,7 +544,7 @@ PHP_FUNCTION(dom_import_simplexml) dom_import_simplexml_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LIBXML_CLASS_LEGACY); } -PHP_FUNCTION(DOM_import_simplexml) +PHP_FUNCTION(Dom_import_simplexml) { dom_import_simplexml_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_LIBXML_CLASS_MODERN); } @@ -659,7 +660,6 @@ static zval *dom_nodemap_read_dimension(zend_object *object, zval *offset, int t static int dom_nodemap_has_dimension(zend_object *object, zval *member, int check_empty); static zval *dom_modern_nodemap_read_dimension(zend_object *object, zval *offset, int type, zval *rv); static int dom_modern_nodemap_has_dimension(zend_object *object, zval *member, int check_empty); -static zend_object *dom_objects_store_clone_obj(zend_object *zobject); #ifdef LIBXML_XPATH_ENABLED void dom_xpath_objects_free_storage(zend_object *object); @@ -731,15 +731,15 @@ PHP_MINIT_FUNCTION(dom) dom_domexception_class_entry = register_class_DOMException(zend_ce_exception); dom_parentnode_class_entry = register_class_DOMParentNode(); - dom_modern_parentnode_class_entry = register_class_DOM_ParentNode(); + dom_modern_parentnode_class_entry = register_class_Dom_ParentNode(); dom_childnode_class_entry = register_class_DOMChildNode(); - dom_modern_childnode_class_entry = register_class_DOM_ChildNode(); + dom_modern_childnode_class_entry = register_class_Dom_ChildNode(); dom_domimplementation_class_entry = register_class_DOMImplementation(); dom_domimplementation_class_entry->create_object = dom_objects_new; dom_domimplementation_class_entry->default_object_handlers = &dom_object_handlers; - dom_modern_domimplementation_class_entry = register_class_DOM_Implementation(); + dom_modern_domimplementation_class_entry = register_class_Dom_Implementation(); dom_modern_domimplementation_class_entry->create_object = dom_objects_new; dom_modern_domimplementation_class_entry->default_object_handlers = &dom_modern_domimplementation_object_handlers; @@ -768,7 +768,7 @@ PHP_MINIT_FUNCTION(dom) DOM_REGISTER_PROP_HANDLER(&dom_node_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write); zend_hash_add_new_ptr(&classes, dom_node_class_entry->name, &dom_node_prop_handlers); - dom_modern_node_class_entry = register_class_DOM_Node(); + dom_modern_node_class_entry = register_class_Dom_Node(); dom_modern_node_class_entry->create_object = dom_objects_new; dom_modern_node_class_entry->default_object_handlers = &dom_object_handlers; @@ -818,7 +818,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_documentfragment_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_documentfragment_class_entry->name, &dom_documentfragment_prop_handlers); - dom_modern_documentfragment_class_entry = register_class_DOM_DocumentFragment(dom_modern_node_class_entry, dom_modern_parentnode_class_entry); + dom_modern_documentfragment_class_entry = register_class_Dom_DocumentFragment(dom_modern_node_class_entry, dom_modern_parentnode_class_entry); dom_modern_documentfragment_class_entry->create_object = dom_objects_new; dom_modern_documentfragment_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_init(&dom_modern_documentfragment_prop_handlers, 0, NULL, NULL, true); @@ -830,7 +830,7 @@ PHP_MINIT_FUNCTION(dom) DOM_OVERWRITE_PROP_HANDLER(&dom_modern_documentfragment_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write); zend_hash_add_new_ptr(&classes, dom_modern_documentfragment_class_entry->name, &dom_modern_documentfragment_prop_handlers); - dom_abstract_base_document_class_entry = register_class_DOM_Document(dom_modern_node_class_entry, dom_modern_parentnode_class_entry); + dom_abstract_base_document_class_entry = register_class_Dom_Document(dom_modern_node_class_entry, dom_modern_parentnode_class_entry); dom_abstract_base_document_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_init(&dom_abstract_base_document_prop_handlers, 0, NULL, NULL, true); DOM_REGISTER_PROP_HANDLER(&dom_abstract_base_document_prop_handlers, "implementation", dom_modern_document_implementation_read, NULL); @@ -877,11 +877,11 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_document_class_entry->name, &dom_document_prop_handlers); - dom_html_document_class_entry = register_class_DOM_HTMLDocument(dom_abstract_base_document_class_entry); + dom_html_document_class_entry = register_class_Dom_HTMLDocument(dom_abstract_base_document_class_entry); dom_html_document_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_add_new_ptr(&classes, dom_html_document_class_entry->name, &dom_abstract_base_document_prop_handlers); - dom_xml_document_class_entry = register_class_DOM_XMLDocument(dom_abstract_base_document_class_entry); + dom_xml_document_class_entry = register_class_Dom_XMLDocument(dom_abstract_base_document_class_entry); dom_xml_document_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_init(&dom_xml_document_prop_handlers, 0, NULL, NULL, true); DOM_REGISTER_PROP_HANDLER(&dom_xml_document_prop_handlers, "xmlEncoding", dom_document_encoding_read, NULL); @@ -901,7 +901,7 @@ PHP_MINIT_FUNCTION(dom) DOM_REGISTER_PROP_HANDLER(&dom_nodelist_prop_handlers, "length", dom_nodelist_length_read, NULL); zend_hash_add_new_ptr(&classes, dom_nodelist_class_entry->name, &dom_nodelist_prop_handlers); - dom_modern_nodelist_class_entry = register_class_DOM_NodeList(zend_ce_aggregate, zend_ce_countable); + dom_modern_nodelist_class_entry = register_class_Dom_NodeList(zend_ce_aggregate, zend_ce_countable); dom_modern_nodelist_class_entry->create_object = dom_nnodemap_objects_new; dom_modern_nodelist_class_entry->default_object_handlers = &dom_modern_nodelist_object_handlers; dom_modern_nodelist_class_entry->get_iterator = php_dom_get_iterator; @@ -917,21 +917,21 @@ PHP_MINIT_FUNCTION(dom) DOM_REGISTER_PROP_HANDLER(&dom_namednodemap_prop_handlers, "length", dom_namednodemap_length_read, NULL); zend_hash_add_new_ptr(&classes, dom_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers); - dom_modern_namednodemap_class_entry = register_class_DOM_NamedNodeMap(zend_ce_aggregate, zend_ce_countable); + dom_modern_namednodemap_class_entry = register_class_Dom_NamedNodeMap(zend_ce_aggregate, zend_ce_countable); dom_modern_namednodemap_class_entry->create_object = dom_nnodemap_objects_new; dom_modern_namednodemap_class_entry->default_object_handlers = &dom_modern_nnodemap_object_handlers; dom_modern_namednodemap_class_entry->get_iterator = php_dom_get_iterator; zend_hash_add_new_ptr(&classes, dom_modern_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers); - dom_modern_dtd_namednodemap_class_entry = register_class_DOM_DTDNamedNodeMap(zend_ce_aggregate, zend_ce_countable); + dom_modern_dtd_namednodemap_class_entry = register_class_Dom_DtdNamedNodeMap(zend_ce_aggregate, zend_ce_countable); dom_modern_dtd_namednodemap_class_entry->create_object = dom_nnodemap_objects_new; dom_modern_dtd_namednodemap_class_entry->default_object_handlers = &dom_modern_nnodemap_object_handlers; dom_modern_dtd_namednodemap_class_entry->get_iterator = php_dom_get_iterator; zend_hash_add_new_ptr(&classes, dom_modern_dtd_namednodemap_class_entry->name, &dom_namednodemap_prop_handlers); - dom_html_collection_class_entry = register_class_DOM_HTMLCollection(zend_ce_aggregate, zend_ce_countable); + dom_html_collection_class_entry = register_class_Dom_HTMLCollection(zend_ce_aggregate, zend_ce_countable); dom_html_collection_class_entry->create_object = dom_nnodemap_objects_new; dom_html_collection_class_entry->default_object_handlers = &dom_html_collection_object_handlers; dom_html_collection_class_entry->get_iterator = php_dom_get_iterator; @@ -950,7 +950,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_characterdata_class_entry->name, &dom_characterdata_prop_handlers); - dom_modern_characterdata_class_entry = register_class_DOM_CharacterData(dom_modern_node_class_entry, dom_modern_childnode_class_entry); + dom_modern_characterdata_class_entry = register_class_Dom_CharacterData(dom_modern_node_class_entry, dom_modern_childnode_class_entry); dom_modern_characterdata_class_entry->create_object = dom_objects_new; dom_modern_characterdata_class_entry->default_object_handlers = &dom_object_handlers; @@ -977,7 +977,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_attr_class_entry->name, &dom_attr_prop_handlers); - dom_modern_attr_class_entry = register_class_DOM_Attr(dom_modern_node_class_entry); + dom_modern_attr_class_entry = register_class_Dom_Attr(dom_modern_node_class_entry); dom_modern_attr_class_entry->create_object = dom_objects_new; dom_modern_attr_class_entry->default_object_handlers = &dom_object_handlers; @@ -1011,7 +1011,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_element_class_entry->name, &dom_element_prop_handlers); - dom_modern_element_class_entry = register_class_DOM_Element(dom_modern_node_class_entry, dom_modern_parentnode_class_entry, dom_modern_childnode_class_entry); + dom_modern_element_class_entry = register_class_Dom_Element(dom_modern_node_class_entry, dom_modern_parentnode_class_entry, dom_modern_childnode_class_entry); dom_modern_element_class_entry->create_object = dom_objects_new; dom_modern_element_class_entry->default_object_handlers = &dom_object_handlers; @@ -1041,7 +1041,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_text_class_entry->name, &dom_text_prop_handlers); - dom_modern_text_class_entry = register_class_DOM_Text(dom_modern_characterdata_class_entry); + dom_modern_text_class_entry = register_class_Dom_Text(dom_modern_characterdata_class_entry); dom_modern_text_class_entry->create_object = dom_objects_new; dom_modern_text_class_entry->default_object_handlers = &dom_object_handlers; @@ -1055,7 +1055,7 @@ PHP_MINIT_FUNCTION(dom) dom_comment_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_add_new_ptr(&classes, dom_comment_class_entry->name, &dom_characterdata_prop_handlers); - dom_modern_comment_class_entry = register_class_DOM_Comment(dom_modern_characterdata_class_entry); + dom_modern_comment_class_entry = register_class_Dom_Comment(dom_modern_characterdata_class_entry); dom_modern_comment_class_entry->create_object = dom_objects_new; dom_modern_comment_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_add_new_ptr(&classes, dom_modern_comment_class_entry->name, &dom_modern_characterdata_prop_handlers); @@ -1065,7 +1065,7 @@ PHP_MINIT_FUNCTION(dom) dom_cdatasection_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_add_new_ptr(&classes, dom_cdatasection_class_entry->name, &dom_text_prop_handlers); - dom_modern_cdatasection_class_entry = register_class_DOM_CDATASection(dom_modern_text_class_entry); + dom_modern_cdatasection_class_entry = register_class_Dom_CDATASection(dom_modern_text_class_entry); dom_modern_cdatasection_class_entry->create_object = dom_objects_new; dom_modern_cdatasection_class_entry->default_object_handlers = &dom_object_handlers; zend_hash_add_new_ptr(&classes, dom_modern_cdatasection_class_entry->name, &dom_modern_text_prop_handlers); @@ -1084,7 +1084,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_documenttype_class_entry->name, &dom_documenttype_prop_handlers); - dom_modern_documenttype_class_entry = register_class_DOM_DocumentType(dom_modern_node_class_entry, dom_modern_childnode_class_entry); + dom_modern_documenttype_class_entry = register_class_Dom_DocumentType(dom_modern_node_class_entry, dom_modern_childnode_class_entry); dom_modern_documenttype_class_entry->create_object = dom_objects_new; dom_modern_documenttype_class_entry->default_object_handlers = &dom_object_handlers; @@ -1108,7 +1108,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_notation_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_notation_class_entry->name, &dom_notation_prop_handlers); - dom_modern_notation_class_entry = register_class_DOM_Notation(dom_modern_node_class_entry); + dom_modern_notation_class_entry = register_class_Dom_Notation(dom_modern_node_class_entry); dom_modern_notation_class_entry->create_object = dom_objects_new; dom_modern_notation_class_entry->default_object_handlers = &dom_object_handlers; @@ -1132,7 +1132,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_entity_class_entry->name, &dom_entity_prop_handlers); - dom_modern_entity_class_entry = register_class_DOM_Entity(dom_modern_node_class_entry); + dom_modern_entity_class_entry = register_class_Dom_Entity(dom_modern_node_class_entry); dom_modern_entity_class_entry->create_object = dom_objects_new; dom_modern_entity_class_entry->default_object_handlers = &dom_object_handlers; @@ -1146,12 +1146,26 @@ PHP_MINIT_FUNCTION(dom) dom_entityreference_class_entry = register_class_DOMEntityReference(dom_node_class_entry); dom_entityreference_class_entry->create_object = dom_objects_new; dom_entityreference_class_entry->default_object_handlers = &dom_object_handlers; - zend_hash_add_new_ptr(&classes, dom_entityreference_class_entry->name, &dom_node_prop_handlers); - dom_modern_entityreference_class_entry = register_class_DOM_EntityReference(dom_modern_node_class_entry); + zend_hash_init(&dom_entity_reference_prop_handlers, 0, NULL, NULL, true); + zend_hash_merge(&dom_entity_reference_prop_handlers, &dom_node_prop_handlers, NULL, false); + DOM_OVERWRITE_PROP_HANDLER(&dom_entity_reference_prop_handlers, "firstChild", dom_entity_reference_child_read, NULL); + DOM_OVERWRITE_PROP_HANDLER(&dom_entity_reference_prop_handlers, "lastChild", dom_entity_reference_child_read, NULL); + DOM_OVERWRITE_PROP_HANDLER(&dom_entity_reference_prop_handlers, "textContent", dom_entity_reference_text_content_read, NULL); + DOM_OVERWRITE_PROP_HANDLER(&dom_entity_reference_prop_handlers, "childNodes", dom_entity_reference_child_nodes_read, NULL); + zend_hash_add_new_ptr(&classes, dom_entityreference_class_entry->name, &dom_entity_reference_prop_handlers); + + dom_modern_entityreference_class_entry = register_class_Dom_EntityReference(dom_modern_node_class_entry); dom_modern_entityreference_class_entry->create_object = dom_objects_new; dom_modern_entityreference_class_entry->default_object_handlers = &dom_object_handlers; - zend_hash_add_new_ptr(&classes, dom_modern_entityreference_class_entry->name, &dom_modern_node_prop_handlers); + + zend_hash_init(&dom_modern_entity_reference_prop_handlers, 0, NULL, NULL, true); + zend_hash_merge(&dom_modern_entity_reference_prop_handlers, &dom_modern_node_prop_handlers, NULL, false); + DOM_OVERWRITE_PROP_HANDLER(&dom_modern_entity_reference_prop_handlers, "firstChild", dom_entity_reference_child_read, NULL); + DOM_OVERWRITE_PROP_HANDLER(&dom_modern_entity_reference_prop_handlers, "lastChild", dom_entity_reference_child_read, NULL); + DOM_OVERWRITE_PROP_HANDLER(&dom_modern_entity_reference_prop_handlers, "textContent", dom_entity_reference_text_content_read, NULL); + DOM_OVERWRITE_PROP_HANDLER(&dom_modern_entity_reference_prop_handlers, "childNodes", dom_entity_reference_child_nodes_read, NULL); + zend_hash_add_new_ptr(&classes, dom_modern_entityreference_class_entry->name, &dom_modern_entity_reference_prop_handlers); dom_processinginstruction_class_entry = register_class_DOMProcessingInstruction(dom_node_class_entry); dom_processinginstruction_class_entry->create_object = dom_objects_new; @@ -1163,7 +1177,7 @@ PHP_MINIT_FUNCTION(dom) zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, NULL, false); zend_hash_add_new_ptr(&classes, dom_processinginstruction_class_entry->name, &dom_processinginstruction_prop_handlers); - dom_modern_processinginstruction_class_entry = register_class_DOM_ProcessingInstruction(dom_modern_characterdata_class_entry); + dom_modern_processinginstruction_class_entry = register_class_Dom_ProcessingInstruction(dom_modern_characterdata_class_entry); dom_modern_processinginstruction_class_entry->create_object = dom_objects_new; dom_modern_processinginstruction_class_entry->default_object_handlers = &dom_object_handlers; @@ -1189,7 +1203,7 @@ PHP_MINIT_FUNCTION(dom) DOM_REGISTER_PROP_HANDLER(&dom_xpath_prop_handlers, "registerNodeNamespaces", dom_xpath_register_node_ns_read, dom_xpath_register_node_ns_write); zend_hash_add_new_ptr(&classes, dom_xpath_class_entry->name, &dom_xpath_prop_handlers); - dom_modern_xpath_class_entry = register_class_DOM_XPath(); + dom_modern_xpath_class_entry = register_class_Dom_XPath(); dom_modern_xpath_class_entry->create_object = dom_xpath_objects_new; dom_modern_xpath_class_entry->default_object_handlers = &dom_xpath_object_handlers; @@ -1240,6 +1254,8 @@ PHP_MSHUTDOWN_FUNCTION(dom) /* {{{ */ zend_hash_destroy(&dom_modern_documentfragment_prop_handlers); zend_hash_destroy(&dom_node_prop_handlers); zend_hash_destroy(&dom_modern_node_prop_handlers); + zend_hash_destroy(&dom_entity_reference_prop_handlers); + zend_hash_destroy(&dom_modern_entity_reference_prop_handlers); zend_hash_destroy(&dom_namespace_node_prop_handlers); zend_hash_destroy(&dom_nodelist_prop_handlers); zend_hash_destroy(&dom_namednodemap_prop_handlers); @@ -2227,7 +2243,7 @@ void php_dom_get_content_into_zval(const xmlNode *nodep, zval *return_value, boo case XML_ATTRIBUTE_NODE: { bool free; - xmlChar *value = dom_attr_value((const xmlAttr *) nodep, &free); + xmlChar *value = php_libxml_attr_value((const xmlAttr *) nodep, &free); RETURN_STRING_FAST((const char *) value); if (free) { xmlFree(value); diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index 5aa2a9ce949a3..1e24b38a64884 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -122,7 +122,6 @@ static inline dom_object_namespace_node *php_dom_namespace_node_obj_from_obj(zen #define DOM_HTML_NO_DEFAULT_NS (1U << 31) -dom_object *dom_object_get_data(xmlNodePtr obj); dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document); libxml_doc_props const* dom_get_doc_props_read_only(const php_libxml_ref_obj *document); zend_object *dom_objects_new(zend_class_entry *class_type); @@ -146,8 +145,8 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr basep, xmlNodePtr nodep, void php_dom_create_implementation(zval *retval, bool modern); int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child); bool dom_has_feature(zend_string *feature, zend_string *version); -int dom_node_is_read_only(xmlNodePtr node); -bool dom_node_children_valid(xmlNodePtr node); +int dom_node_is_read_only(const xmlNode *node); +bool dom_node_children_valid(const xmlNode *node); void php_dom_create_iterator(zval *return_value, dom_iterator_type iterator_type, bool modern); void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, const char *local, size_t local_len, const char *ns, size_t ns_len); xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); @@ -167,14 +166,13 @@ bool php_dom_has_sibling_following_node(xmlNodePtr node, xmlElementType type); bool php_dom_has_sibling_preceding_node(xmlNodePtr node, xmlElementType type); bool php_dom_has_child_of_type(xmlNodePtr node, xmlElementType type); void php_dom_update_document_after_clone(dom_object *original, xmlNodePtr original_node, dom_object *clone, xmlNodePtr cloned_node); -void php_dom_document_constructor(INTERNAL_FUNCTION_PARAMETERS); xmlAttrPtr php_dom_get_attribute_node(xmlNodePtr elem, const xmlChar *name, size_t name_len); xmlChar *php_dom_libxml_fix_file_path(xmlChar *path); void dom_document_convert_to_modern(php_libxml_ref_obj *document, xmlDocPtr lxml_doc); dom_object *php_dom_instantiate_object_helper(zval *return_value, zend_class_entry *ce, xmlNodePtr obj, dom_object *parent); xmlDocPtr php_dom_create_html_doc(void); - -xmlChar *dom_attr_value(const xmlAttr *attr, bool *free); +xmlEntityPtr dom_entity_reference_fetch_and_sync_declaration(xmlNodePtr reference); +void dom_set_xml_class(php_libxml_ref_obj *document); bool dom_compare_value(const xmlAttr *attr, const xmlChar *value); typedef enum { diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 692499407ccf1..15ed4ced8109f 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -94,14 +94,6 @@ * @cvalue XML_NAMESPACE_DECL */ const XML_NAMESPACE_DECL_NODE = UNKNOWN; -#ifdef XML_GLOBAL_NAMESPACE - /** - * @var int - * @cvalue XML_GLOBAL_NAMESPACE - */ - const XML_GLOBAL_NAMESPACE = UNKNOWN; -#endif - /** * @var int * @cvalue XML_LOCAL_NAMESPACE @@ -889,7 +881,7 @@ public function prepend(...$nodes): void {} public function replaceChildren(...$nodes): void {} } - /** @alias DOM\DOMException */ + /** @alias Dom\DOMException */ final class DOMException extends Exception { /** @@ -1025,7 +1017,7 @@ public static function quote(string $str): string {} function dom_import_simplexml(object $node): DOMElement {} } -namespace DOM +namespace Dom { /** * @var int @@ -1252,7 +1244,7 @@ public function count(): int {} public function getIterator(): \Iterator {} } - class DTDNamedNodeMap implements \IteratorAggregate, \Countable + class DtdNamedNodeMap implements \IteratorAggregate, \Countable { /** @readonly */ public int $length; @@ -1330,7 +1322,7 @@ public function hasAttributeNS(?string $namespace, string $localName): bool {} public function getAttributeNode(string $qualifiedName): ?Attr {} /** @implementation-alias DOMElement::getAttributeNodeNS */ public function getAttributeNodeNS(?string $namespace, string $localName): ?Attr {} - /** @implementation-alias DOM\Element::setAttributeNodeNS */ + /** @implementation-alias Dom\Element::setAttributeNodeNS */ public function setAttributeNode(Attr $attr) : ?Attr {} public function setAttributeNodeNS(Attr $attr) : ?Attr {} public function removeAttributeNode(Attr $attr) : Attr {} @@ -1452,9 +1444,9 @@ class DocumentType extends Node implements ChildNode /** @readonly */ public string $name; /** @readonly */ - public DTDNamedNodeMap $entities; + public DtdNamedNodeMap $entities; /** @readonly */ - public DTDNamedNodeMap $notations; + public DtdNamedNodeMap $notations; /** @readonly */ public string $publicId; /** @readonly */ @@ -1482,7 +1474,7 @@ class DocumentFragment extends Node implements ParentNode public int $childElementCount; /** @implementation-alias DOMDocumentFragment::appendXML */ - public function appendXML(string $data): bool {} + public function appendXml(string $data): bool {} /** @implementation-alias DOMElement::append */ public function append(Node|string ...$nodes): void {} /** @implementation-alias DOMElement::prepend */ @@ -1525,9 +1517,9 @@ abstract class Document extends Node implements ParentNode public ?DocumentType $doctype; /** @readonly */ public ?Element $documentElement; - /** @implementation-alias DOM\Element::getElementsByTagName */ + /** @implementation-alias Dom\Element::getElementsByTagName */ public function getElementsByTagName(string $qualifiedName): HTMLCollection {} - /** @implementation-alias DOM\Element::getElementsByTagNameNS */ + /** @implementation-alias Dom\Element::getElementsByTagNameNS */ public function getElementsByTagNameNS(?string $namespace, string $localName): HTMLCollection {} public function createElement(string $localName): Element {} @@ -1568,9 +1560,9 @@ public function schemaValidate(string $filename, int $flags = 0): bool {} /** @implementation-alias DOMDocument::schemaValidateSource */ public function schemaValidateSource(string $source, int $flags = 0): bool {} /** @implementation-alias DOMDocument::relaxNGValidate */ - public function relaxNGValidate(string $filename): bool {} + public function relaxNgValidate(string $filename): bool {} /** @implementation-alias DOMDocument::relaxNGValidateSource */ - public function relaxNGValidateSource(string $source): bool {} + public function relaxNgValidateSource(string $source): bool {} #endif /** @implementation-alias DOMElement::append */ @@ -1591,15 +1583,15 @@ public static function createFromFile(string $path, int $options = 0, ?string $o public static function createFromString(string $source, int $options = 0, ?string $overrideEncoding = null): HTMLDocument {} - /** @implementation-alias DOM\XMLDocument::saveXML */ - public function saveXML(?Node $node = null, int $options = 0): string|false {} + /** @implementation-alias Dom\XMLDocument::saveXml */ + public function saveXml(?Node $node = null, int $options = 0): string|false {} /** @implementation-alias DOMDocument::save */ - public function saveXMLFile(string $filename, int $options = 0): int|false {} + public function saveXmlFile(string $filename, int $options = 0): int|false {} - public function saveHTML(?Node $node = null): string {} + public function saveHtml(?Node $node = null): string {} - public function saveHTMLFile(string $filename): int|false {} + public function saveHtmlFile(string $filename): int|false {} } final class XMLDocument extends Document @@ -1628,10 +1620,10 @@ public function validate(): bool {} /** @implementation-alias DOMDocument::xinclude */ public function xinclude(int $options = 0): int|false {} - public function saveXML(?Node $node = null, int $options = 0): string|false {} + public function saveXml(?Node $node = null, int $options = 0): string|false {} /** @implementation-alias DOMDocument::save */ - public function saveXMLFile(string $filename, int $options = 0): int|false {} + public function saveXmlFile(string $filename, int $options = 0): int|false {} } #ifdef LIBXML_XPATH_ENABLED diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index dbb8109f44819..588fdc0f4d0aa 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1,11 +1,11 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 49a153db3d3aa28031d7a15c15f89f6f3e9c33a5 */ + * Stub hash: 24c4a5ec91197ae35ccd6f344cd3a985286e2a16 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_dom_import_simplexml, 0, 1, DOMElement, 0) ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_DOM_import_simplexml, 0, 1, DOM\\Element, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_Dom_import_simplexml, 0, 1, Dom\\Element, 0) ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0) ZEND_END_ARG_INFO() @@ -559,111 +559,111 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOMXPath_quote, 0, 1, IS_S ZEND_END_ARG_INFO() #endif -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_ParentNode_append, 0, 0, IS_VOID, 0) - ZEND_ARG_VARIADIC_OBJ_TYPE_MASK(0, nodes, DOM\\\116ode, MAY_BE_STRING) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_ParentNode_append, 0, 0, IS_VOID, 0) + ZEND_ARG_VARIADIC_OBJ_TYPE_MASK(0, nodes, Dom\\\116ode, MAY_BE_STRING) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_ParentNode_prepend arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_ParentNode_prepend arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_ParentNode_replaceChildren arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_ParentNode_replaceChildren arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_ChildNode_remove arginfo_class_DOMChildNode_remove +#define arginfo_class_Dom_ChildNode_remove arginfo_class_DOMChildNode_remove -#define arginfo_class_DOM_ChildNode_before arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_ChildNode_before arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_ChildNode_after arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_ChildNode_after arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_ChildNode_replaceWith arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_ChildNode_replaceWith arginfo_class_Dom_ParentNode_append -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Implementation_createDocumentType, 0, 3, DOM\\DocumentType, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Implementation_createDocumentType, 0, 3, Dom\\DocumentType, 0) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, publicId, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, systemId, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Implementation_createDocument, 0, 2, DOM\\XMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Implementation_createDocument, 0, 2, Dom\\XMLDocument, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) - ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, doctype, DOM\\DocumentType, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, doctype, Dom\\DocumentType, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Implementation_createHTMLDocument, 0, 0, DOM\\HTMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Implementation_createHTMLDocument, 0, 0, Dom\\HTMLDocument, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, title, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Node___construct arginfo_class_DOMDocumentFragment___construct +#define arginfo_class_Dom_Node___construct arginfo_class_DOMDocumentFragment___construct -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Node_getRootNode, 0, 0, DOM\\\116ode, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Node_getRootNode, 0, 0, Dom\\\116ode, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_hasChildNodes, 0, 0, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_hasChildNodes, 0, 0, _IS_BOOL, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Node_normalize arginfo_class_DOMChildNode_remove +#define arginfo_class_Dom_Node_normalize arginfo_class_DOMChildNode_remove -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Node_cloneNode, 0, 0, DOM\\\116ode, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Node_cloneNode, 0, 0, Dom\\\116ode, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, deep, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_isEqualNode, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, otherNode, DOM\\\116ode, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_isEqualNode, 0, 1, _IS_BOOL, 0) + ZEND_ARG_OBJ_INFO(0, otherNode, Dom\\\116ode, 1) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Node_isSameNode arginfo_class_DOM_Node_isEqualNode +#define arginfo_class_Dom_Node_isSameNode arginfo_class_Dom_Node_isEqualNode -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_compareDocumentPosition, 0, 1, IS_LONG, 0) - ZEND_ARG_OBJ_INFO(0, other, DOM\\\116ode, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_compareDocumentPosition, 0, 1, IS_LONG, 0) + ZEND_ARG_OBJ_INFO(0, other, Dom\\\116ode, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_contains, 0, 1, _IS_BOOL, 0) - ZEND_ARG_OBJ_INFO(0, other, DOM\\\116ode, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_contains, 0, 1, _IS_BOOL, 0) + ZEND_ARG_OBJ_INFO(0, other, Dom\\\116ode, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_lookupPrefix, 0, 1, IS_STRING, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_lookupPrefix, 0, 1, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_lookupNamespaceURI, 0, 1, IS_STRING, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_lookupNamespaceURI, 0, 1, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, prefix, IS_STRING, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_isDefaultNamespace, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_isDefaultNamespace, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Node_insertBefore, 0, 2, DOM\\\116ode, 0) - ZEND_ARG_OBJ_INFO(0, node, DOM\\\116ode, 0) - ZEND_ARG_OBJ_INFO(0, child, DOM\\\116ode, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Node_insertBefore, 0, 2, Dom\\\116ode, 0) + ZEND_ARG_OBJ_INFO(0, node, Dom\\\116ode, 0) + ZEND_ARG_OBJ_INFO(0, child, Dom\\\116ode, 1) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Node_appendChild, 0, 1, DOM\\\116ode, 0) - ZEND_ARG_OBJ_INFO(0, node, DOM\\\116ode, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Node_appendChild, 0, 1, Dom\\\116ode, 0) + ZEND_ARG_OBJ_INFO(0, node, Dom\\\116ode, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Node_replaceChild, 0, 2, DOM\\\116ode, 0) - ZEND_ARG_OBJ_INFO(0, node, DOM\\\116ode, 0) - ZEND_ARG_OBJ_INFO(0, child, DOM\\\116ode, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Node_replaceChild, 0, 2, Dom\\\116ode, 0) + ZEND_ARG_OBJ_INFO(0, node, Dom\\\116ode, 0) + ZEND_ARG_OBJ_INFO(0, child, Dom\\\116ode, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Node_removeChild, 0, 1, DOM\\\116ode, 0) - ZEND_ARG_OBJ_INFO(0, child, DOM\\\116ode, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Node_removeChild, 0, 1, Dom\\\116ode, 0) + ZEND_ARG_OBJ_INFO(0, child, Dom\\\116ode, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_getLineNo, 0, 0, IS_LONG, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_getLineNo, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Node_getNodePath, 0, 0, IS_STRING, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Node_getNodePath, 0, 0, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_DOM_Node_C14N, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Dom_Node_C14N, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, exclusive, _IS_BOOL, 0, "false") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, withComments, _IS_BOOL, 0, "false") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, xpath, IS_ARRAY, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, nsPrefixes, IS_ARRAY, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_DOM_Node_C14NFile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Dom_Node_C14NFile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, uri, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, exclusive, _IS_BOOL, 0, "false") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, withComments, _IS_BOOL, 0, "false") @@ -671,431 +671,431 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_DOM_Node_C14NFile, 0, 1, M ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, nsPrefixes, IS_ARRAY, 1, "null") ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Node___sleep arginfo_class_DOMNode___sleep +#define arginfo_class_Dom_Node___sleep arginfo_class_DOMNode___sleep -#define arginfo_class_DOM_Node___wakeup arginfo_class_DOMChildNode_remove +#define arginfo_class_Dom_Node___wakeup arginfo_class_DOMChildNode_remove -#define arginfo_class_DOM_NodeList_count arginfo_class_DOM_Node_getLineNo +#define arginfo_class_Dom_NodeList_count arginfo_class_Dom_Node_getLineNo -#define arginfo_class_DOM_NodeList_getIterator arginfo_class_DOMNodeList_getIterator +#define arginfo_class_Dom_NodeList_getIterator arginfo_class_DOMNodeList_getIterator -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_NodeList_item, 0, 1, DOM\\\116ode, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_NodeList_item, 0, 1, Dom\\\116ode, 1) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_NamedNodeMap_item, 0, 1, DOM\\Attr, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_NamedNodeMap_item, 0, 1, Dom\\Attr, 1) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_NamedNodeMap_getNamedItem, 0, 1, DOM\\Attr, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_NamedNodeMap_getNamedItem, 0, 1, Dom\\Attr, 1) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_NamedNodeMap_getNamedItemNS, 0, 2, DOM\\Attr, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_NamedNodeMap_getNamedItemNS, 0, 2, Dom\\Attr, 1) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_NamedNodeMap_count arginfo_class_DOM_Node_getLineNo +#define arginfo_class_Dom_NamedNodeMap_count arginfo_class_Dom_Node_getLineNo -#define arginfo_class_DOM_NamedNodeMap_getIterator arginfo_class_DOMNodeList_getIterator +#define arginfo_class_Dom_NamedNodeMap_getIterator arginfo_class_DOMNodeList_getIterator -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_DOM_DTDNamedNodeMap_item, 0, 1, DOM\\Entity|DOM\\\116otation, MAY_BE_NULL) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Dom_DtdNamedNodeMap_item, 0, 1, Dom\\Entity|Dom\\\116otation, MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_DOM_DTDNamedNodeMap_getNamedItem, 0, 1, DOM\\Entity|DOM\\\116otation, MAY_BE_NULL) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Dom_DtdNamedNodeMap_getNamedItem, 0, 1, Dom\\Entity|Dom\\\116otation, MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_DOM_DTDNamedNodeMap_getNamedItemNS, 0, 2, DOM\\Entity|DOM\\\116otation, MAY_BE_NULL) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Dom_DtdNamedNodeMap_getNamedItemNS, 0, 2, Dom\\Entity|Dom\\\116otation, MAY_BE_NULL) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_DTDNamedNodeMap_count arginfo_class_DOM_Node_getLineNo +#define arginfo_class_Dom_DtdNamedNodeMap_count arginfo_class_Dom_Node_getLineNo -#define arginfo_class_DOM_DTDNamedNodeMap_getIterator arginfo_class_DOMNodeList_getIterator +#define arginfo_class_Dom_DtdNamedNodeMap_getIterator arginfo_class_DOMNodeList_getIterator -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_HTMLCollection_item, 0, 1, DOM\\Element, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_HTMLCollection_item, 0, 1, Dom\\Element, 1) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_HTMLCollection_namedItem, 0, 1, DOM\\Element, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_HTMLCollection_namedItem, 0, 1, Dom\\Element, 1) ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_HTMLCollection_count arginfo_class_DOM_Node_getLineNo +#define arginfo_class_Dom_HTMLCollection_count arginfo_class_Dom_Node_getLineNo -#define arginfo_class_DOM_HTMLCollection_getIterator arginfo_class_DOMNodeList_getIterator +#define arginfo_class_Dom_HTMLCollection_getIterator arginfo_class_DOMNodeList_getIterator -#define arginfo_class_DOM_Element_hasAttributes arginfo_class_DOM_Node_hasChildNodes +#define arginfo_class_Dom_Element_hasAttributes arginfo_class_Dom_Node_hasChildNodes -#define arginfo_class_DOM_Element_getAttributeNames arginfo_class_DOMNode___sleep +#define arginfo_class_Dom_Element_getAttributeNames arginfo_class_DOMNode___sleep -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_getAttribute, 0, 1, IS_STRING, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_getAttribute, 0, 1, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_getAttributeNS, 0, 2, IS_STRING, 1) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_getAttributeNS, 0, 2, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_setAttribute, 0, 2, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_setAttribute, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_setAttributeNS, 0, 3, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_setAttributeNS, 0, 3, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_removeAttribute, 0, 1, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_removeAttribute, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_removeAttributeNS, 0, 2, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_removeAttributeNS, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Element_toggleAttribute arginfo_class_DOMElement_toggleAttribute +#define arginfo_class_Dom_Element_toggleAttribute arginfo_class_DOMElement_toggleAttribute -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_hasAttribute, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_hasAttribute, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_hasAttributeNS, 0, 2, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_hasAttributeNS, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Element_getAttributeNode arginfo_class_DOM_NamedNodeMap_getNamedItem +#define arginfo_class_Dom_Element_getAttributeNode arginfo_class_Dom_NamedNodeMap_getNamedItem -#define arginfo_class_DOM_Element_getAttributeNodeNS arginfo_class_DOM_NamedNodeMap_getNamedItemNS +#define arginfo_class_Dom_Element_getAttributeNodeNS arginfo_class_Dom_NamedNodeMap_getNamedItemNS -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Element_setAttributeNode, 0, 1, DOM\\Attr, 1) - ZEND_ARG_OBJ_INFO(0, attr, DOM\\Attr, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Element_setAttributeNode, 0, 1, Dom\\Attr, 1) + ZEND_ARG_OBJ_INFO(0, attr, Dom\\Attr, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Element_setAttributeNodeNS arginfo_class_DOM_Element_setAttributeNode +#define arginfo_class_Dom_Element_setAttributeNodeNS arginfo_class_Dom_Element_setAttributeNode -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Element_removeAttributeNode, 0, 1, DOM\\Attr, 0) - ZEND_ARG_OBJ_INFO(0, attr, DOM\\Attr, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Element_removeAttributeNode, 0, 1, Dom\\Attr, 0) + ZEND_ARG_OBJ_INFO(0, attr, Dom\\Attr, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Element_getElementsByTagName, 0, 1, DOM\\HTMLCollection, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Element_getElementsByTagName, 0, 1, Dom\\HTMLCollection, 0) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Element_getElementsByTagNameNS, 0, 2, DOM\\HTMLCollection, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Element_getElementsByTagNameNS, 0, 2, Dom\\HTMLCollection, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Element_insertAdjacentElement, 0, 2, DOM\\Element, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Element_insertAdjacentElement, 0, 2, Dom\\Element, 1) ZEND_ARG_TYPE_INFO(0, where, IS_STRING, 0) - ZEND_ARG_OBJ_INFO(0, element, DOM\\Element, 0) + ZEND_ARG_OBJ_INFO(0, element, Dom\\Element, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Element_insertAdjacentText arginfo_class_DOMElement_insertAdjacentText +#define arginfo_class_Dom_Element_insertAdjacentText arginfo_class_DOMElement_insertAdjacentText -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_setIdAttribute, 0, 2, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_setIdAttribute, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, isId, _IS_BOOL, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_setIdAttributeNS, 0, 3, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_setIdAttributeNS, 0, 3, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, isId, _IS_BOOL, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Element_setIdAttributeNode, 0, 2, IS_VOID, 0) - ZEND_ARG_OBJ_INFO(0, attr, DOM\\Attr, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_setIdAttributeNode, 0, 2, IS_VOID, 0) + ZEND_ARG_OBJ_INFO(0, attr, Dom\\Attr, 0) ZEND_ARG_TYPE_INFO(0, isId, _IS_BOOL, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Element_remove arginfo_class_DOMChildNode_remove +#define arginfo_class_Dom_Element_remove arginfo_class_DOMChildNode_remove -#define arginfo_class_DOM_Element_before arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Element_before arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Element_after arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Element_after arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Element_replaceWith arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Element_replaceWith arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Element_append arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Element_append arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Element_prepend arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Element_prepend arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Element_replaceChildren arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Element_replaceChildren arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Attr_isId arginfo_class_DOM_Node_hasChildNodes +#define arginfo_class_Dom_Attr_isId arginfo_class_Dom_Node_hasChildNodes -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_CharacterData_substringData, 0, 2, IS_STRING, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_CharacterData_substringData, 0, 2, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_CharacterData_appendData, 0, 1, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_CharacterData_appendData, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_CharacterData_insertData, 0, 2, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_CharacterData_insertData, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_CharacterData_deleteData, 0, 2, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_CharacterData_deleteData, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_CharacterData_replaceData, 0, 3, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_CharacterData_replaceData, 0, 3, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_CharacterData_remove arginfo_class_DOMChildNode_remove +#define arginfo_class_Dom_CharacterData_remove arginfo_class_DOMChildNode_remove -#define arginfo_class_DOM_CharacterData_before arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_CharacterData_before arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_CharacterData_after arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_CharacterData_after arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_CharacterData_replaceWith arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_CharacterData_replaceWith arginfo_class_Dom_ParentNode_append -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Text_splitText, 0, 1, DOM\\Text, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Text_splitText, 0, 1, Dom\\Text, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_DocumentType_remove arginfo_class_DOMChildNode_remove +#define arginfo_class_Dom_DocumentType_remove arginfo_class_DOMChildNode_remove -#define arginfo_class_DOM_DocumentType_before arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_DocumentType_before arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_DocumentType_after arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_DocumentType_after arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_DocumentType_replaceWith arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_DocumentType_replaceWith arginfo_class_Dom_ParentNode_append -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_DocumentFragment_appendXML, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_DocumentFragment_appendXml, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_DocumentFragment_append arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_DocumentFragment_append arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_DocumentFragment_prepend arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_DocumentFragment_prepend arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_DocumentFragment_replaceChildren arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_DocumentFragment_replaceChildren arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Document_getElementsByTagName arginfo_class_DOM_Element_getElementsByTagName +#define arginfo_class_Dom_Document_getElementsByTagName arginfo_class_Dom_Element_getElementsByTagName -#define arginfo_class_DOM_Document_getElementsByTagNameNS arginfo_class_DOM_Element_getElementsByTagNameNS +#define arginfo_class_Dom_Document_getElementsByTagNameNS arginfo_class_Dom_Element_getElementsByTagNameNS -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createElement, 0, 1, DOM\\Element, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createElement, 0, 1, Dom\\Element, 0) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createElementNS, 0, 2, DOM\\Element, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createElementNS, 0, 2, Dom\\Element, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createDocumentFragment, 0, 0, DOM\\DocumentFragment, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createDocumentFragment, 0, 0, Dom\\DocumentFragment, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createTextNode, 0, 1, DOM\\Text, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createTextNode, 0, 1, Dom\\Text, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createCDATASection, 0, 1, DOM\\CDATASection, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createCDATASection, 0, 1, Dom\\CDATASection, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createComment, 0, 1, DOM\\Comment, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createComment, 0, 1, Dom\\Comment, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createProcessingInstruction, 0, 2, DOM\\ProcessingInstruction, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createProcessingInstruction, 0, 2, Dom\\ProcessingInstruction, 0) ZEND_ARG_TYPE_INFO(0, target, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_importNode, 0, 1, DOM\\\116ode, 0) - ZEND_ARG_OBJ_INFO(0, node, DOM\\\116ode, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_importNode, 0, 1, Dom\\\116ode, 0) + ZEND_ARG_OBJ_INFO(0, node, Dom\\\116ode, 1) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, deep, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() -#define arginfo_class_DOM_Document_adoptNode arginfo_class_DOM_Node_appendChild +#define arginfo_class_Dom_Document_adoptNode arginfo_class_Dom_Node_appendChild -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createAttribute, 0, 1, DOM\\Attr, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createAttribute, 0, 1, Dom\\Attr, 0) ZEND_ARG_TYPE_INFO(0, localName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_createAttributeNS, 0, 2, DOM\\Attr, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_createAttributeNS, 0, 2, Dom\\Attr, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_getElementById, 0, 1, DOM\\Element, 1) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_getElementById, 0, 1, Dom\\Element, 1) ZEND_ARG_TYPE_INFO(0, elementId, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Document_registerNodeClass, 0, 2, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Document_registerNodeClass, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, baseClass, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, extendedClass, IS_STRING, 1) ZEND_END_ARG_INFO() #if defined(LIBXML_SCHEMAS_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Document_schemaValidate, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Document_schemaValidate, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") ZEND_END_ARG_INFO() #endif #if defined(LIBXML_SCHEMAS_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Document_schemaValidateSource, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Document_schemaValidateSource, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, source, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") ZEND_END_ARG_INFO() #endif #if defined(LIBXML_SCHEMAS_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Document_relaxNGValidate, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Document_relaxNgValidate, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() #endif #if defined(LIBXML_SCHEMAS_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_Document_relaxNGValidateSource, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Document_relaxNgValidateSource, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, source, IS_STRING, 0) ZEND_END_ARG_INFO() #endif -#define arginfo_class_DOM_Document_append arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Document_append arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Document_prepend arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Document_prepend arginfo_class_Dom_ParentNode_append -#define arginfo_class_DOM_Document_replaceChildren arginfo_class_DOM_ParentNode_append +#define arginfo_class_Dom_Document_replaceChildren arginfo_class_Dom_ParentNode_append -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_Document_importLegacyNode, 0, 1, DOM\\\116ode, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_Document_importLegacyNode, 0, 1, Dom\\\116ode, 0) ZEND_ARG_OBJ_INFO(0, node, DOMNode, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, deep, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_HTMLDocument_createEmpty, 0, 0, DOM\\HTMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_HTMLDocument_createEmpty, 0, 0, Dom\\HTMLDocument, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"UTF-8\"") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_HTMLDocument_createFromFile, 0, 1, DOM\\HTMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_HTMLDocument_createFromFile, 0, 1, Dom\\HTMLDocument, 0) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, overrideEncoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_HTMLDocument_createFromString, 0, 1, DOM\\HTMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_HTMLDocument_createFromString, 0, 1, Dom\\HTMLDocument, 0) ZEND_ARG_TYPE_INFO(0, source, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, overrideEncoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_DOM_HTMLDocument_saveXML, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, node, DOM\\\116ode, 1, "null") +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Dom_HTMLDocument_saveXml, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, node, Dom\\\116ode, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_DOM_HTMLDocument_saveXMLFile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Dom_HTMLDocument_saveXmlFile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_HTMLDocument_saveHTML, 0, 0, IS_STRING, 0) - ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, node, DOM\\\116ode, 1, "null") +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_HTMLDocument_saveHtml, 0, 0, IS_STRING, 0) + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, node, Dom\\\116ode, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_DOM_HTMLDocument_saveHTMLFile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Dom_HTMLDocument_saveHtmlFile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_XMLDocument_createEmpty, 0, 0, DOM\\XMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_XMLDocument_createEmpty, 0, 0, Dom\\XMLDocument, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, version, IS_STRING, 0, "\"1.0\"") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"UTF-8\"") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_XMLDocument_createFromFile, 0, 1, DOM\\XMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_XMLDocument_createFromFile, 0, 1, Dom\\XMLDocument, 0) ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, overrideEncoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_XMLDocument_createFromString, 0, 1, DOM\\XMLDocument, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_XMLDocument_createFromString, 0, 1, Dom\\XMLDocument, 0) ZEND_ARG_TYPE_INFO(0, source, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, overrideEncoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_XMLDocument_createEntityReference, 0, 1, DOM\\EntityReference, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_XMLDocument_createEntityReference, 0, 1, Dom\\EntityReference, 0) ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_DOM_XMLDocument_validate arginfo_class_DOM_Node_hasChildNodes +#define arginfo_class_Dom_XMLDocument_validate arginfo_class_Dom_Node_hasChildNodes -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_DOM_XMLDocument_xinclude, 0, 0, MAY_BE_LONG|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Dom_XMLDocument_xinclude, 0, 0, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -#define arginfo_class_DOM_XMLDocument_saveXML arginfo_class_DOM_HTMLDocument_saveXML +#define arginfo_class_Dom_XMLDocument_saveXml arginfo_class_Dom_HTMLDocument_saveXml -#define arginfo_class_DOM_XMLDocument_saveXMLFile arginfo_class_DOM_HTMLDocument_saveXMLFile +#define arginfo_class_Dom_XMLDocument_saveXmlFile arginfo_class_Dom_HTMLDocument_saveXmlFile #if defined(LIBXML_XPATH_ENABLED) -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DOM_XPath___construct, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, document, DOM\\Document, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Dom_XPath___construct, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, document, Dom\\Document, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, registerNodeNS, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() #endif #if defined(LIBXML_XPATH_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_DOM_XPath_evaluate, 0, 1, DOM\\\116odeList, MAY_BE_NULL|MAY_BE_BOOL|MAY_BE_DOUBLE|MAY_BE_STRING) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Dom_XPath_evaluate, 0, 1, Dom\\\116odeList, MAY_BE_NULL|MAY_BE_BOOL|MAY_BE_DOUBLE|MAY_BE_STRING) ZEND_ARG_TYPE_INFO(0, expression, IS_STRING, 0) - ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, contextNode, DOM\\\116ode, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, contextNode, Dom\\\116ode, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, registerNodeNS, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() #endif #if defined(LIBXML_XPATH_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_DOM_XPath_query, 0, 1, DOM\\\116odeList, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_Dom_XPath_query, 0, 1, Dom\\\116odeList, 0) ZEND_ARG_TYPE_INFO(0, expression, IS_STRING, 0) - ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, contextNode, DOM\\\116ode, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, contextNode, Dom\\\116ode, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, registerNodeNS, _IS_BOOL, 0, "true") ZEND_END_ARG_INFO() #endif #if defined(LIBXML_XPATH_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_XPath_registerNamespace, 0, 2, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_XPath_registerNamespace, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, prefix, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, namespace, IS_STRING, 0) ZEND_END_ARG_INFO() #endif #if defined(LIBXML_XPATH_ENABLED) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DOM_XPath_registerPhpFunctions, 0, 0, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_XPath_registerPhpFunctions, 0, 0, IS_VOID, 0) ZEND_ARG_TYPE_MASK(0, restrict, MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_NULL, "null") ZEND_END_ARG_INFO() #endif #if defined(LIBXML_XPATH_ENABLED) -#define arginfo_class_DOM_XPath_registerPhpFunctionNS arginfo_class_DOMXPath_registerPhpFunctionNS +#define arginfo_class_Dom_XPath_registerPhpFunctionNS arginfo_class_DOMXPath_registerPhpFunctionNS #endif #if defined(LIBXML_XPATH_ENABLED) -#define arginfo_class_DOM_XPath_quote arginfo_class_DOMXPath_quote +#define arginfo_class_Dom_XPath_quote arginfo_class_DOMXPath_quote #endif ZEND_FUNCTION(dom_import_simplexml); -ZEND_FUNCTION(DOM_import_simplexml); +ZEND_FUNCTION(Dom_import_simplexml); ZEND_METHOD(DOMCdataSection, __construct); ZEND_METHOD(DOMComment, __construct); ZEND_METHOD(DOMNode, appendChild); @@ -1245,62 +1245,62 @@ ZEND_METHOD(DOMXPath, registerPhpFunctionNS); #if defined(LIBXML_XPATH_ENABLED) ZEND_METHOD(DOMXPath, quote); #endif -ZEND_METHOD(DOM_Implementation, createDocumentType); -ZEND_METHOD(DOM_Implementation, createDocument); -ZEND_METHOD(DOM_Implementation, createHTMLDocument); -ZEND_METHOD(DOM_Node, __construct); -ZEND_METHOD(DOM_Node, isEqualNode); -ZEND_METHOD(DOM_Node, isSameNode); -ZEND_METHOD(DOM_Node, compareDocumentPosition); -ZEND_METHOD(DOM_Node, contains); -ZEND_METHOD(DOM_Node, lookupPrefix); -ZEND_METHOD(DOM_Node, isDefaultNamespace); -ZEND_METHOD(DOM_Node, insertBefore); -ZEND_METHOD(DOM_Node, appendChild); -ZEND_METHOD(DOM_Node, replaceChild); -ZEND_METHOD(DOM_Node, removeChild); -ZEND_METHOD(DOM_Node, getNodePath); -ZEND_METHOD(DOM_HTMLCollection, namedItem); -ZEND_METHOD(DOM_Element, removeAttribute); -ZEND_METHOD(DOM_Element, setAttributeNodeNS); -ZEND_METHOD(DOM_Element, removeAttributeNode); -ZEND_METHOD(DOM_Element, getElementsByTagName); -ZEND_METHOD(DOM_Element, getElementsByTagNameNS); -ZEND_METHOD(DOM_Element, insertAdjacentElement); -ZEND_METHOD(DOM_Element, setIdAttributeNode); -ZEND_METHOD(DOM_CharacterData, appendData); -ZEND_METHOD(DOM_CharacterData, insertData); -ZEND_METHOD(DOM_CharacterData, deleteData); -ZEND_METHOD(DOM_CharacterData, replaceData); -ZEND_METHOD(DOM_Document, createElement); -ZEND_METHOD(DOM_Document, createElementNS); -ZEND_METHOD(DOM_Document, createProcessingInstruction); -ZEND_METHOD(DOM_Document, importNode); -ZEND_METHOD(DOM_Document, adoptNode); -ZEND_METHOD(DOM_Document, registerNodeClass); -ZEND_METHOD(DOM_Document, importLegacyNode); -ZEND_METHOD(DOM_HTMLDocument, createEmpty); -ZEND_METHOD(DOM_HTMLDocument, createFromFile); -ZEND_METHOD(DOM_HTMLDocument, createFromString); -ZEND_METHOD(DOM_XMLDocument, saveXML); -ZEND_METHOD(DOM_HTMLDocument, saveHTML); -ZEND_METHOD(DOM_HTMLDocument, saveHTMLFile); -ZEND_METHOD(DOM_XMLDocument, createEmpty); -ZEND_METHOD(DOM_XMLDocument, createFromFile); -ZEND_METHOD(DOM_XMLDocument, createFromString); +ZEND_METHOD(Dom_Implementation, createDocumentType); +ZEND_METHOD(Dom_Implementation, createDocument); +ZEND_METHOD(Dom_Implementation, createHTMLDocument); +ZEND_METHOD(Dom_Node, __construct); +ZEND_METHOD(Dom_Node, isEqualNode); +ZEND_METHOD(Dom_Node, isSameNode); +ZEND_METHOD(Dom_Node, compareDocumentPosition); +ZEND_METHOD(Dom_Node, contains); +ZEND_METHOD(Dom_Node, lookupPrefix); +ZEND_METHOD(Dom_Node, isDefaultNamespace); +ZEND_METHOD(Dom_Node, insertBefore); +ZEND_METHOD(Dom_Node, appendChild); +ZEND_METHOD(Dom_Node, replaceChild); +ZEND_METHOD(Dom_Node, removeChild); +ZEND_METHOD(Dom_Node, getNodePath); +ZEND_METHOD(Dom_HTMLCollection, namedItem); +ZEND_METHOD(Dom_Element, removeAttribute); +ZEND_METHOD(Dom_Element, setAttributeNodeNS); +ZEND_METHOD(Dom_Element, removeAttributeNode); +ZEND_METHOD(Dom_Element, getElementsByTagName); +ZEND_METHOD(Dom_Element, getElementsByTagNameNS); +ZEND_METHOD(Dom_Element, insertAdjacentElement); +ZEND_METHOD(Dom_Element, setIdAttributeNode); +ZEND_METHOD(Dom_CharacterData, appendData); +ZEND_METHOD(Dom_CharacterData, insertData); +ZEND_METHOD(Dom_CharacterData, deleteData); +ZEND_METHOD(Dom_CharacterData, replaceData); +ZEND_METHOD(Dom_Document, createElement); +ZEND_METHOD(Dom_Document, createElementNS); +ZEND_METHOD(Dom_Document, createProcessingInstruction); +ZEND_METHOD(Dom_Document, importNode); +ZEND_METHOD(Dom_Document, adoptNode); +ZEND_METHOD(Dom_Document, registerNodeClass); +ZEND_METHOD(Dom_Document, importLegacyNode); +ZEND_METHOD(Dom_HTMLDocument, createEmpty); +ZEND_METHOD(Dom_HTMLDocument, createFromFile); +ZEND_METHOD(Dom_HTMLDocument, createFromString); +ZEND_METHOD(Dom_XMLDocument, saveXml); +ZEND_METHOD(Dom_HTMLDocument, saveHtml); +ZEND_METHOD(Dom_HTMLDocument, saveHtmlFile); +ZEND_METHOD(Dom_XMLDocument, createEmpty); +ZEND_METHOD(Dom_XMLDocument, createFromFile); +ZEND_METHOD(Dom_XMLDocument, createFromString); #if defined(LIBXML_XPATH_ENABLED) -ZEND_METHOD(DOM_XPath, __construct); +ZEND_METHOD(Dom_XPath, __construct); #endif #if defined(LIBXML_XPATH_ENABLED) -ZEND_METHOD(DOM_XPath, evaluate); +ZEND_METHOD(Dom_XPath, evaluate); #endif #if defined(LIBXML_XPATH_ENABLED) -ZEND_METHOD(DOM_XPath, query); +ZEND_METHOD(Dom_XPath, query); #endif static const zend_function_entry ext_functions[] = { ZEND_FE(dom_import_simplexml, arginfo_dom_import_simplexml) - ZEND_RAW_FENTRY(ZEND_NS_NAME("DOM", "import_simplexml"), zif_DOM_import_simplexml, arginfo_DOM_import_simplexml, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("Dom", "import_simplexml"), zif_Dom_import_simplexml, arginfo_Dom_import_simplexml, 0, NULL, NULL) ZEND_FE_END }; @@ -1550,251 +1550,251 @@ static const zend_function_entry class_DOMXPath_methods[] = { }; #endif -static const zend_function_entry class_DOM_ParentNode_methods[] = { - ZEND_RAW_FENTRY("append", NULL, arginfo_class_DOM_ParentNode_append, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) - ZEND_RAW_FENTRY("prepend", NULL, arginfo_class_DOM_ParentNode_prepend, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) - ZEND_RAW_FENTRY("replaceChildren", NULL, arginfo_class_DOM_ParentNode_replaceChildren, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) +static const zend_function_entry class_Dom_ParentNode_methods[] = { + ZEND_RAW_FENTRY("append", NULL, arginfo_class_Dom_ParentNode_append, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_RAW_FENTRY("prepend", NULL, arginfo_class_Dom_ParentNode_prepend, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_RAW_FENTRY("replaceChildren", NULL, arginfo_class_Dom_ParentNode_replaceChildren, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_ChildNode_methods[] = { - ZEND_RAW_FENTRY("remove", NULL, arginfo_class_DOM_ChildNode_remove, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) - ZEND_RAW_FENTRY("before", NULL, arginfo_class_DOM_ChildNode_before, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) - ZEND_RAW_FENTRY("after", NULL, arginfo_class_DOM_ChildNode_after, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) - ZEND_RAW_FENTRY("replaceWith", NULL, arginfo_class_DOM_ChildNode_replaceWith, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) +static const zend_function_entry class_Dom_ChildNode_methods[] = { + ZEND_RAW_FENTRY("remove", NULL, arginfo_class_Dom_ChildNode_remove, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_RAW_FENTRY("before", NULL, arginfo_class_Dom_ChildNode_before, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_RAW_FENTRY("after", NULL, arginfo_class_Dom_ChildNode_after, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) + ZEND_RAW_FENTRY("replaceWith", NULL, arginfo_class_Dom_ChildNode_replaceWith, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_Implementation_methods[] = { - ZEND_ME(DOM_Implementation, createDocumentType, arginfo_class_DOM_Implementation_createDocumentType, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Implementation, createDocument, arginfo_class_DOM_Implementation_createDocument, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Implementation, createHTMLDocument, arginfo_class_DOM_Implementation_createHTMLDocument, ZEND_ACC_PUBLIC) +static const zend_function_entry class_Dom_Implementation_methods[] = { + ZEND_ME(Dom_Implementation, createDocumentType, arginfo_class_Dom_Implementation_createDocumentType, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Implementation, createDocument, arginfo_class_Dom_Implementation_createDocument, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Implementation, createHTMLDocument, arginfo_class_Dom_Implementation_createHTMLDocument, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static const zend_function_entry class_DOM_Node_methods[] = { - ZEND_ME(DOM_Node, __construct, arginfo_class_DOM_Node___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) - ZEND_RAW_FENTRY("getRootNode", zim_DOMNode_getRootNode, arginfo_class_DOM_Node_getRootNode, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("hasChildNodes", zim_DOMNode_hasChildNodes, arginfo_class_DOM_Node_hasChildNodes, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("normalize", zim_DOMNode_normalize, arginfo_class_DOM_Node_normalize, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("cloneNode", zim_DOMNode_cloneNode, arginfo_class_DOM_Node_cloneNode, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Node, isEqualNode, arginfo_class_DOM_Node_isEqualNode, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, isSameNode, arginfo_class_DOM_Node_isSameNode, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, compareDocumentPosition, arginfo_class_DOM_Node_compareDocumentPosition, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, contains, arginfo_class_DOM_Node_contains, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, lookupPrefix, arginfo_class_DOM_Node_lookupPrefix, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("lookupNamespaceURI", zim_DOMNode_lookupNamespaceURI, arginfo_class_DOM_Node_lookupNamespaceURI, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Node, isDefaultNamespace, arginfo_class_DOM_Node_isDefaultNamespace, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, insertBefore, arginfo_class_DOM_Node_insertBefore, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, appendChild, arginfo_class_DOM_Node_appendChild, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, replaceChild, arginfo_class_DOM_Node_replaceChild, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Node, removeChild, arginfo_class_DOM_Node_removeChild, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("getLineNo", zim_DOMNode_getLineNo, arginfo_class_DOM_Node_getLineNo, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Node, getNodePath, arginfo_class_DOM_Node_getNodePath, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("C14N", zim_DOMNode_C14N, arginfo_class_DOM_Node_C14N, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("C14NFile", zim_DOMNode_C14NFile, arginfo_class_DOM_Node_C14NFile, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("__sleep", zim_DOMNode___sleep, arginfo_class_DOM_Node___sleep, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("__wakeup", zim_DOMNode___wakeup, arginfo_class_DOM_Node___wakeup, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_Node_methods[] = { + ZEND_ME(Dom_Node, __construct, arginfo_class_Dom_Node___construct, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL) + ZEND_RAW_FENTRY("getRootNode", zim_DOMNode_getRootNode, arginfo_class_Dom_Node_getRootNode, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("hasChildNodes", zim_DOMNode_hasChildNodes, arginfo_class_Dom_Node_hasChildNodes, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("normalize", zim_DOMNode_normalize, arginfo_class_Dom_Node_normalize, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("cloneNode", zim_DOMNode_cloneNode, arginfo_class_Dom_Node_cloneNode, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Node, isEqualNode, arginfo_class_Dom_Node_isEqualNode, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, isSameNode, arginfo_class_Dom_Node_isSameNode, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, compareDocumentPosition, arginfo_class_Dom_Node_compareDocumentPosition, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, contains, arginfo_class_Dom_Node_contains, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, lookupPrefix, arginfo_class_Dom_Node_lookupPrefix, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("lookupNamespaceURI", zim_DOMNode_lookupNamespaceURI, arginfo_class_Dom_Node_lookupNamespaceURI, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Node, isDefaultNamespace, arginfo_class_Dom_Node_isDefaultNamespace, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, insertBefore, arginfo_class_Dom_Node_insertBefore, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, appendChild, arginfo_class_Dom_Node_appendChild, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, replaceChild, arginfo_class_Dom_Node_replaceChild, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Node, removeChild, arginfo_class_Dom_Node_removeChild, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("getLineNo", zim_DOMNode_getLineNo, arginfo_class_Dom_Node_getLineNo, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Node, getNodePath, arginfo_class_Dom_Node_getNodePath, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("C14N", zim_DOMNode_C14N, arginfo_class_Dom_Node_C14N, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("C14NFile", zim_DOMNode_C14NFile, arginfo_class_Dom_Node_C14NFile, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("__sleep", zim_DOMNode___sleep, arginfo_class_Dom_Node___sleep, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("__wakeup", zim_DOMNode___wakeup, arginfo_class_Dom_Node___wakeup, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_NodeList_methods[] = { - ZEND_RAW_FENTRY("count", zim_DOMNodeList_count, arginfo_class_DOM_NodeList_count, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getIterator", zim_DOMNodeList_getIterator, arginfo_class_DOM_NodeList_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("item", zim_DOMNodeList_item, arginfo_class_DOM_NodeList_item, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_NodeList_methods[] = { + ZEND_RAW_FENTRY("count", zim_DOMNodeList_count, arginfo_class_Dom_NodeList_count, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getIterator", zim_DOMNodeList_getIterator, arginfo_class_Dom_NodeList_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("item", zim_DOMNodeList_item, arginfo_class_Dom_NodeList_item, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_NamedNodeMap_methods[] = { - ZEND_RAW_FENTRY("item", zim_DOMNamedNodeMap_item, arginfo_class_DOM_NamedNodeMap_item, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getNamedItem", zim_DOMNamedNodeMap_getNamedItem, arginfo_class_DOM_NamedNodeMap_getNamedItem, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getNamedItemNS", zim_DOMNamedNodeMap_getNamedItemNS, arginfo_class_DOM_NamedNodeMap_getNamedItemNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("count", zim_DOMNamedNodeMap_count, arginfo_class_DOM_NamedNodeMap_count, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getIterator", zim_DOMNamedNodeMap_getIterator, arginfo_class_DOM_NamedNodeMap_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_NamedNodeMap_methods[] = { + ZEND_RAW_FENTRY("item", zim_DOMNamedNodeMap_item, arginfo_class_Dom_NamedNodeMap_item, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getNamedItem", zim_DOMNamedNodeMap_getNamedItem, arginfo_class_Dom_NamedNodeMap_getNamedItem, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getNamedItemNS", zim_DOMNamedNodeMap_getNamedItemNS, arginfo_class_Dom_NamedNodeMap_getNamedItemNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("count", zim_DOMNamedNodeMap_count, arginfo_class_Dom_NamedNodeMap_count, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getIterator", zim_DOMNamedNodeMap_getIterator, arginfo_class_Dom_NamedNodeMap_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_DTDNamedNodeMap_methods[] = { - ZEND_RAW_FENTRY("item", zim_DOMNamedNodeMap_item, arginfo_class_DOM_DTDNamedNodeMap_item, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getNamedItem", zim_DOMNamedNodeMap_getNamedItem, arginfo_class_DOM_DTDNamedNodeMap_getNamedItem, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getNamedItemNS", zim_DOMNamedNodeMap_getNamedItemNS, arginfo_class_DOM_DTDNamedNodeMap_getNamedItemNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("count", zim_DOMNamedNodeMap_count, arginfo_class_DOM_DTDNamedNodeMap_count, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getIterator", zim_DOMNamedNodeMap_getIterator, arginfo_class_DOM_DTDNamedNodeMap_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_DtdNamedNodeMap_methods[] = { + ZEND_RAW_FENTRY("item", zim_DOMNamedNodeMap_item, arginfo_class_Dom_DtdNamedNodeMap_item, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getNamedItem", zim_DOMNamedNodeMap_getNamedItem, arginfo_class_Dom_DtdNamedNodeMap_getNamedItem, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getNamedItemNS", zim_DOMNamedNodeMap_getNamedItemNS, arginfo_class_Dom_DtdNamedNodeMap_getNamedItemNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("count", zim_DOMNamedNodeMap_count, arginfo_class_Dom_DtdNamedNodeMap_count, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getIterator", zim_DOMNamedNodeMap_getIterator, arginfo_class_Dom_DtdNamedNodeMap_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_HTMLCollection_methods[] = { - ZEND_RAW_FENTRY("item", zim_DOMNodeList_item, arginfo_class_DOM_HTMLCollection_item, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_HTMLCollection, namedItem, arginfo_class_DOM_HTMLCollection_namedItem, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("count", zim_DOMNodeList_count, arginfo_class_DOM_HTMLCollection_count, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getIterator", zim_DOMNodeList_getIterator, arginfo_class_DOM_HTMLCollection_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_HTMLCollection_methods[] = { + ZEND_RAW_FENTRY("item", zim_DOMNodeList_item, arginfo_class_Dom_HTMLCollection_item, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_HTMLCollection, namedItem, arginfo_class_Dom_HTMLCollection_namedItem, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("count", zim_DOMNodeList_count, arginfo_class_Dom_HTMLCollection_count, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getIterator", zim_DOMNodeList_getIterator, arginfo_class_Dom_HTMLCollection_getIterator, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_Element_methods[] = { - ZEND_RAW_FENTRY("hasAttributes", zim_DOMNode_hasAttributes, arginfo_class_DOM_Element_hasAttributes, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getAttributeNames", zim_DOMElement_getAttributeNames, arginfo_class_DOM_Element_getAttributeNames, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getAttribute", zim_DOMElement_getAttribute, arginfo_class_DOM_Element_getAttribute, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getAttributeNS", zim_DOMElement_getAttributeNS, arginfo_class_DOM_Element_getAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("setAttribute", zim_DOMElement_setAttribute, arginfo_class_DOM_Element_setAttribute, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("setAttributeNS", zim_DOMElement_setAttributeNS, arginfo_class_DOM_Element_setAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Element, removeAttribute, arginfo_class_DOM_Element_removeAttribute, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("removeAttributeNS", zim_DOMElement_removeAttributeNS, arginfo_class_DOM_Element_removeAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("toggleAttribute", zim_DOMElement_toggleAttribute, arginfo_class_DOM_Element_toggleAttribute, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("hasAttribute", zim_DOMElement_hasAttribute, arginfo_class_DOM_Element_hasAttribute, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("hasAttributeNS", zim_DOMElement_hasAttributeNS, arginfo_class_DOM_Element_hasAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getAttributeNode", zim_DOMElement_getAttributeNode, arginfo_class_DOM_Element_getAttributeNode, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getAttributeNodeNS", zim_DOMElement_getAttributeNodeNS, arginfo_class_DOM_Element_getAttributeNodeNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("setAttributeNode", zim_DOM_Element_setAttributeNodeNS, arginfo_class_DOM_Element_setAttributeNode, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Element, setAttributeNodeNS, arginfo_class_DOM_Element_setAttributeNodeNS, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Element, removeAttributeNode, arginfo_class_DOM_Element_removeAttributeNode, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Element, getElementsByTagName, arginfo_class_DOM_Element_getElementsByTagName, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Element, getElementsByTagNameNS, arginfo_class_DOM_Element_getElementsByTagNameNS, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Element, insertAdjacentElement, arginfo_class_DOM_Element_insertAdjacentElement, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("insertAdjacentText", zim_DOMElement_insertAdjacentText, arginfo_class_DOM_Element_insertAdjacentText, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("setIdAttribute", zim_DOMElement_setIdAttribute, arginfo_class_DOM_Element_setIdAttribute, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("setIdAttributeNS", zim_DOMElement_setIdAttributeNS, arginfo_class_DOM_Element_setIdAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Element, setIdAttributeNode, arginfo_class_DOM_Element_setIdAttributeNode, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("remove", zim_DOMElement_remove, arginfo_class_DOM_Element_remove, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("before", zim_DOMElement_before, arginfo_class_DOM_Element_before, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("after", zim_DOMElement_after, arginfo_class_DOM_Element_after, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("replaceWith", zim_DOMElement_replaceWith, arginfo_class_DOM_Element_replaceWith, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("append", zim_DOMElement_append, arginfo_class_DOM_Element_append, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("prepend", zim_DOMElement_prepend, arginfo_class_DOM_Element_prepend, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("replaceChildren", zim_DOMElement_replaceChildren, arginfo_class_DOM_Element_replaceChildren, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_Element_methods[] = { + ZEND_RAW_FENTRY("hasAttributes", zim_DOMNode_hasAttributes, arginfo_class_Dom_Element_hasAttributes, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getAttributeNames", zim_DOMElement_getAttributeNames, arginfo_class_Dom_Element_getAttributeNames, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getAttribute", zim_DOMElement_getAttribute, arginfo_class_Dom_Element_getAttribute, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getAttributeNS", zim_DOMElement_getAttributeNS, arginfo_class_Dom_Element_getAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("setAttribute", zim_DOMElement_setAttribute, arginfo_class_Dom_Element_setAttribute, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("setAttributeNS", zim_DOMElement_setAttributeNS, arginfo_class_Dom_Element_setAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Element, removeAttribute, arginfo_class_Dom_Element_removeAttribute, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("removeAttributeNS", zim_DOMElement_removeAttributeNS, arginfo_class_Dom_Element_removeAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("toggleAttribute", zim_DOMElement_toggleAttribute, arginfo_class_Dom_Element_toggleAttribute, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("hasAttribute", zim_DOMElement_hasAttribute, arginfo_class_Dom_Element_hasAttribute, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("hasAttributeNS", zim_DOMElement_hasAttributeNS, arginfo_class_Dom_Element_hasAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getAttributeNode", zim_DOMElement_getAttributeNode, arginfo_class_Dom_Element_getAttributeNode, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getAttributeNodeNS", zim_DOMElement_getAttributeNodeNS, arginfo_class_Dom_Element_getAttributeNodeNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("setAttributeNode", zim_Dom_Element_setAttributeNodeNS, arginfo_class_Dom_Element_setAttributeNode, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Element, setAttributeNodeNS, arginfo_class_Dom_Element_setAttributeNodeNS, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Element, removeAttributeNode, arginfo_class_Dom_Element_removeAttributeNode, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Element, getElementsByTagName, arginfo_class_Dom_Element_getElementsByTagName, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Element, getElementsByTagNameNS, arginfo_class_Dom_Element_getElementsByTagNameNS, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Element, insertAdjacentElement, arginfo_class_Dom_Element_insertAdjacentElement, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("insertAdjacentText", zim_DOMElement_insertAdjacentText, arginfo_class_Dom_Element_insertAdjacentText, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("setIdAttribute", zim_DOMElement_setIdAttribute, arginfo_class_Dom_Element_setIdAttribute, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("setIdAttributeNS", zim_DOMElement_setIdAttributeNS, arginfo_class_Dom_Element_setIdAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Element, setIdAttributeNode, arginfo_class_Dom_Element_setIdAttributeNode, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("remove", zim_DOMElement_remove, arginfo_class_Dom_Element_remove, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("before", zim_DOMElement_before, arginfo_class_Dom_Element_before, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("after", zim_DOMElement_after, arginfo_class_Dom_Element_after, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("replaceWith", zim_DOMElement_replaceWith, arginfo_class_Dom_Element_replaceWith, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("append", zim_DOMElement_append, arginfo_class_Dom_Element_append, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("prepend", zim_DOMElement_prepend, arginfo_class_Dom_Element_prepend, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("replaceChildren", zim_DOMElement_replaceChildren, arginfo_class_Dom_Element_replaceChildren, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_Attr_methods[] = { - ZEND_RAW_FENTRY("isId", zim_DOMAttr_isId, arginfo_class_DOM_Attr_isId, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_Attr_methods[] = { + ZEND_RAW_FENTRY("isId", zim_DOMAttr_isId, arginfo_class_Dom_Attr_isId, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_CharacterData_methods[] = { - ZEND_RAW_FENTRY("substringData", zim_DOMCharacterData_substringData, arginfo_class_DOM_CharacterData_substringData, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_CharacterData, appendData, arginfo_class_DOM_CharacterData_appendData, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_CharacterData, insertData, arginfo_class_DOM_CharacterData_insertData, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_CharacterData, deleteData, arginfo_class_DOM_CharacterData_deleteData, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_CharacterData, replaceData, arginfo_class_DOM_CharacterData_replaceData, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("remove", zim_DOMElement_remove, arginfo_class_DOM_CharacterData_remove, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("before", zim_DOMElement_before, arginfo_class_DOM_CharacterData_before, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("after", zim_DOMElement_after, arginfo_class_DOM_CharacterData_after, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("replaceWith", zim_DOMElement_replaceWith, arginfo_class_DOM_CharacterData_replaceWith, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_CharacterData_methods[] = { + ZEND_RAW_FENTRY("substringData", zim_DOMCharacterData_substringData, arginfo_class_Dom_CharacterData_substringData, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_CharacterData, appendData, arginfo_class_Dom_CharacterData_appendData, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_CharacterData, insertData, arginfo_class_Dom_CharacterData_insertData, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_CharacterData, deleteData, arginfo_class_Dom_CharacterData_deleteData, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_CharacterData, replaceData, arginfo_class_Dom_CharacterData_replaceData, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("remove", zim_DOMElement_remove, arginfo_class_Dom_CharacterData_remove, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("before", zim_DOMElement_before, arginfo_class_Dom_CharacterData_before, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("after", zim_DOMElement_after, arginfo_class_Dom_CharacterData_after, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("replaceWith", zim_DOMElement_replaceWith, arginfo_class_Dom_CharacterData_replaceWith, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_Text_methods[] = { - ZEND_RAW_FENTRY("splitText", zim_DOMText_splitText, arginfo_class_DOM_Text_splitText, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_Text_methods[] = { + ZEND_RAW_FENTRY("splitText", zim_DOMText_splitText, arginfo_class_Dom_Text_splitText, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_CDATASection_methods[] = { +static const zend_function_entry class_Dom_CDATASection_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DOM_ProcessingInstruction_methods[] = { +static const zend_function_entry class_Dom_ProcessingInstruction_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DOM_Comment_methods[] = { +static const zend_function_entry class_Dom_Comment_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DOM_DocumentType_methods[] = { - ZEND_RAW_FENTRY("remove", zim_DOMElement_remove, arginfo_class_DOM_DocumentType_remove, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("before", zim_DOMElement_before, arginfo_class_DOM_DocumentType_before, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("after", zim_DOMElement_after, arginfo_class_DOM_DocumentType_after, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("replaceWith", zim_DOMElement_replaceWith, arginfo_class_DOM_DocumentType_replaceWith, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_DocumentType_methods[] = { + ZEND_RAW_FENTRY("remove", zim_DOMElement_remove, arginfo_class_Dom_DocumentType_remove, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("before", zim_DOMElement_before, arginfo_class_Dom_DocumentType_before, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("after", zim_DOMElement_after, arginfo_class_Dom_DocumentType_after, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("replaceWith", zim_DOMElement_replaceWith, arginfo_class_Dom_DocumentType_replaceWith, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_DocumentFragment_methods[] = { - ZEND_RAW_FENTRY("appendXML", zim_DOMDocumentFragment_appendXML, arginfo_class_DOM_DocumentFragment_appendXML, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("append", zim_DOMElement_append, arginfo_class_DOM_DocumentFragment_append, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("prepend", zim_DOMElement_prepend, arginfo_class_DOM_DocumentFragment_prepend, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("replaceChildren", zim_DOMElement_replaceChildren, arginfo_class_DOM_DocumentFragment_replaceChildren, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_DocumentFragment_methods[] = { + ZEND_RAW_FENTRY("appendXml", zim_DOMDocumentFragment_appendXML, arginfo_class_Dom_DocumentFragment_appendXml, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("append", zim_DOMElement_append, arginfo_class_Dom_DocumentFragment_append, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("prepend", zim_DOMElement_prepend, arginfo_class_Dom_DocumentFragment_prepend, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("replaceChildren", zim_DOMElement_replaceChildren, arginfo_class_Dom_DocumentFragment_replaceChildren, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; -static const zend_function_entry class_DOM_Entity_methods[] = { +static const zend_function_entry class_Dom_Entity_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DOM_EntityReference_methods[] = { +static const zend_function_entry class_Dom_EntityReference_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DOM_Notation_methods[] = { +static const zend_function_entry class_Dom_Notation_methods[] = { ZEND_FE_END }; -static const zend_function_entry class_DOM_Document_methods[] = { - ZEND_RAW_FENTRY("getElementsByTagName", zim_DOM_Element_getElementsByTagName, arginfo_class_DOM_Document_getElementsByTagName, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getElementsByTagNameNS", zim_DOM_Element_getElementsByTagNameNS, arginfo_class_DOM_Document_getElementsByTagNameNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Document, createElement, arginfo_class_DOM_Document_createElement, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Document, createElementNS, arginfo_class_DOM_Document_createElementNS, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("createDocumentFragment", zim_DOMDocument_createDocumentFragment, arginfo_class_DOM_Document_createDocumentFragment, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("createTextNode", zim_DOMDocument_createTextNode, arginfo_class_DOM_Document_createTextNode, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("createCDATASection", zim_DOMDocument_createCDATASection, arginfo_class_DOM_Document_createCDATASection, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("createComment", zim_DOMDocument_createComment, arginfo_class_DOM_Document_createComment, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Document, createProcessingInstruction, arginfo_class_DOM_Document_createProcessingInstruction, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Document, importNode, arginfo_class_DOM_Document_importNode, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_Document, adoptNode, arginfo_class_DOM_Document_adoptNode, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("createAttribute", zim_DOMDocument_createAttribute, arginfo_class_DOM_Document_createAttribute, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("createAttributeNS", zim_DOMDocument_createAttributeNS, arginfo_class_DOM_Document_createAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("getElementById", zim_DOMDocument_getElementById, arginfo_class_DOM_Document_getElementById, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Document, registerNodeClass, arginfo_class_DOM_Document_registerNodeClass, ZEND_ACC_PUBLIC) +static const zend_function_entry class_Dom_Document_methods[] = { + ZEND_RAW_FENTRY("getElementsByTagName", zim_Dom_Element_getElementsByTagName, arginfo_class_Dom_Document_getElementsByTagName, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getElementsByTagNameNS", zim_Dom_Element_getElementsByTagNameNS, arginfo_class_Dom_Document_getElementsByTagNameNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Document, createElement, arginfo_class_Dom_Document_createElement, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Document, createElementNS, arginfo_class_Dom_Document_createElementNS, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("createDocumentFragment", zim_DOMDocument_createDocumentFragment, arginfo_class_Dom_Document_createDocumentFragment, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("createTextNode", zim_DOMDocument_createTextNode, arginfo_class_Dom_Document_createTextNode, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("createCDATASection", zim_DOMDocument_createCDATASection, arginfo_class_Dom_Document_createCDATASection, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("createComment", zim_DOMDocument_createComment, arginfo_class_Dom_Document_createComment, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Document, createProcessingInstruction, arginfo_class_Dom_Document_createProcessingInstruction, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Document, importNode, arginfo_class_Dom_Document_importNode, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Document, adoptNode, arginfo_class_Dom_Document_adoptNode, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("createAttribute", zim_DOMDocument_createAttribute, arginfo_class_Dom_Document_createAttribute, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("createAttributeNS", zim_DOMDocument_createAttributeNS, arginfo_class_Dom_Document_createAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("getElementById", zim_DOMDocument_getElementById, arginfo_class_Dom_Document_getElementById, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Document, registerNodeClass, arginfo_class_Dom_Document_registerNodeClass, ZEND_ACC_PUBLIC) #if defined(LIBXML_SCHEMAS_ENABLED) - ZEND_RAW_FENTRY("schemaValidate", zim_DOMDocument_schemaValidate, arginfo_class_DOM_Document_schemaValidate, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("schemaValidate", zim_DOMDocument_schemaValidate, arginfo_class_Dom_Document_schemaValidate, ZEND_ACC_PUBLIC, NULL, NULL) #endif #if defined(LIBXML_SCHEMAS_ENABLED) - ZEND_RAW_FENTRY("schemaValidateSource", zim_DOMDocument_schemaValidateSource, arginfo_class_DOM_Document_schemaValidateSource, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("schemaValidateSource", zim_DOMDocument_schemaValidateSource, arginfo_class_Dom_Document_schemaValidateSource, ZEND_ACC_PUBLIC, NULL, NULL) #endif #if defined(LIBXML_SCHEMAS_ENABLED) - ZEND_RAW_FENTRY("relaxNGValidate", zim_DOMDocument_relaxNGValidate, arginfo_class_DOM_Document_relaxNGValidate, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("relaxNgValidate", zim_DOMDocument_relaxNGValidate, arginfo_class_Dom_Document_relaxNgValidate, ZEND_ACC_PUBLIC, NULL, NULL) #endif #if defined(LIBXML_SCHEMAS_ENABLED) - ZEND_RAW_FENTRY("relaxNGValidateSource", zim_DOMDocument_relaxNGValidateSource, arginfo_class_DOM_Document_relaxNGValidateSource, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("relaxNgValidateSource", zim_DOMDocument_relaxNGValidateSource, arginfo_class_Dom_Document_relaxNgValidateSource, ZEND_ACC_PUBLIC, NULL, NULL) #endif - ZEND_RAW_FENTRY("append", zim_DOMElement_append, arginfo_class_DOM_Document_append, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("prepend", zim_DOMElement_prepend, arginfo_class_DOM_Document_prepend, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("replaceChildren", zim_DOMDocument_replaceChildren, arginfo_class_DOM_Document_replaceChildren, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_Document, importLegacyNode, arginfo_class_DOM_Document_importLegacyNode, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("append", zim_DOMElement_append, arginfo_class_Dom_Document_append, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("prepend", zim_DOMElement_prepend, arginfo_class_Dom_Document_prepend, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("replaceChildren", zim_DOMDocument_replaceChildren, arginfo_class_Dom_Document_replaceChildren, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_Document, importLegacyNode, arginfo_class_Dom_Document_importLegacyNode, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static const zend_function_entry class_DOM_HTMLDocument_methods[] = { - ZEND_ME(DOM_HTMLDocument, createEmpty, arginfo_class_DOM_HTMLDocument_createEmpty, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_ME(DOM_HTMLDocument, createFromFile, arginfo_class_DOM_HTMLDocument_createFromFile, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_ME(DOM_HTMLDocument, createFromString, arginfo_class_DOM_HTMLDocument_createFromString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_RAW_FENTRY("saveXML", zim_DOM_XMLDocument_saveXML, arginfo_class_DOM_HTMLDocument_saveXML, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("saveXMLFile", zim_DOMDocument_save, arginfo_class_DOM_HTMLDocument_saveXMLFile, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_HTMLDocument, saveHTML, arginfo_class_DOM_HTMLDocument_saveHTML, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_HTMLDocument, saveHTMLFile, arginfo_class_DOM_HTMLDocument_saveHTMLFile, ZEND_ACC_PUBLIC) +static const zend_function_entry class_Dom_HTMLDocument_methods[] = { + ZEND_ME(Dom_HTMLDocument, createEmpty, arginfo_class_Dom_HTMLDocument_createEmpty, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(Dom_HTMLDocument, createFromFile, arginfo_class_Dom_HTMLDocument_createFromFile, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(Dom_HTMLDocument, createFromString, arginfo_class_Dom_HTMLDocument_createFromString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_RAW_FENTRY("saveXml", zim_Dom_XMLDocument_saveXml, arginfo_class_Dom_HTMLDocument_saveXml, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("saveXmlFile", zim_DOMDocument_save, arginfo_class_Dom_HTMLDocument_saveXmlFile, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_HTMLDocument, saveHtml, arginfo_class_Dom_HTMLDocument_saveHtml, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_HTMLDocument, saveHtmlFile, arginfo_class_Dom_HTMLDocument_saveHtmlFile, ZEND_ACC_PUBLIC) ZEND_FE_END }; -static const zend_function_entry class_DOM_XMLDocument_methods[] = { - ZEND_ME(DOM_XMLDocument, createEmpty, arginfo_class_DOM_XMLDocument_createEmpty, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_ME(DOM_XMLDocument, createFromFile, arginfo_class_DOM_XMLDocument_createFromFile, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_ME(DOM_XMLDocument, createFromString, arginfo_class_DOM_XMLDocument_createFromString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_RAW_FENTRY("createEntityReference", zim_DOMDocument_createEntityReference, arginfo_class_DOM_XMLDocument_createEntityReference, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("validate", zim_DOMDocument_validate, arginfo_class_DOM_XMLDocument_validate, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("xinclude", zim_DOMDocument_xinclude, arginfo_class_DOM_XMLDocument_xinclude, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_ME(DOM_XMLDocument, saveXML, arginfo_class_DOM_XMLDocument_saveXML, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("saveXMLFile", zim_DOMDocument_save, arginfo_class_DOM_XMLDocument_saveXMLFile, ZEND_ACC_PUBLIC, NULL, NULL) +static const zend_function_entry class_Dom_XMLDocument_methods[] = { + ZEND_ME(Dom_XMLDocument, createEmpty, arginfo_class_Dom_XMLDocument_createEmpty, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(Dom_XMLDocument, createFromFile, arginfo_class_Dom_XMLDocument_createFromFile, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(Dom_XMLDocument, createFromString, arginfo_class_Dom_XMLDocument_createFromString, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_RAW_FENTRY("createEntityReference", zim_DOMDocument_createEntityReference, arginfo_class_Dom_XMLDocument_createEntityReference, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("validate", zim_DOMDocument_validate, arginfo_class_Dom_XMLDocument_validate, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("xinclude", zim_DOMDocument_xinclude, arginfo_class_Dom_XMLDocument_xinclude, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_ME(Dom_XMLDocument, saveXml, arginfo_class_Dom_XMLDocument_saveXml, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("saveXmlFile", zim_DOMDocument_save, arginfo_class_Dom_XMLDocument_saveXmlFile, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_FE_END }; #if defined(LIBXML_XPATH_ENABLED) -static const zend_function_entry class_DOM_XPath_methods[] = { - ZEND_ME(DOM_XPath, __construct, arginfo_class_DOM_XPath___construct, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_XPath, evaluate, arginfo_class_DOM_XPath_evaluate, ZEND_ACC_PUBLIC) - ZEND_ME(DOM_XPath, query, arginfo_class_DOM_XPath_query, ZEND_ACC_PUBLIC) - ZEND_RAW_FENTRY("registerNamespace", zim_DOMXPath_registerNamespace, arginfo_class_DOM_XPath_registerNamespace, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("registerPhpFunctions", zim_DOMXPath_registerPhpFunctions, arginfo_class_DOM_XPath_registerPhpFunctions, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("registerPhpFunctionNS", zim_DOMXPath_registerPhpFunctionNS, arginfo_class_DOM_XPath_registerPhpFunctionNS, ZEND_ACC_PUBLIC, NULL, NULL) - ZEND_RAW_FENTRY("quote", zim_DOMXPath_quote, arginfo_class_DOM_XPath_quote, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) +static const zend_function_entry class_Dom_XPath_methods[] = { + ZEND_ME(Dom_XPath, __construct, arginfo_class_Dom_XPath___construct, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_XPath, evaluate, arginfo_class_Dom_XPath_evaluate, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_XPath, query, arginfo_class_Dom_XPath_query, ZEND_ACC_PUBLIC) + ZEND_RAW_FENTRY("registerNamespace", zim_DOMXPath_registerNamespace, arginfo_class_Dom_XPath_registerNamespace, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("registerPhpFunctions", zim_DOMXPath_registerPhpFunctions, arginfo_class_Dom_XPath_registerPhpFunctions, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("registerPhpFunctionNS", zim_DOMXPath_registerPhpFunctionNS, arginfo_class_Dom_XPath_registerPhpFunctionNS, ZEND_ACC_PUBLIC, NULL, NULL) + ZEND_RAW_FENTRY("quote", zim_DOMXPath_quote, arginfo_class_Dom_XPath_quote, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) ZEND_FE_END }; #endif @@ -1819,9 +1819,6 @@ static void register_php_dom_symbols(int module_number) REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_DECL_NODE", XML_ATTRIBUTE_DECL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XML_ENTITY_DECL_NODE", XML_ENTITY_DECL, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XML_NAMESPACE_DECL_NODE", XML_NAMESPACE_DECL, CONST_PERSISTENT); -#if defined(XML_GLOBAL_NAMESPACE) - REGISTER_LONG_CONSTANT("XML_GLOBAL_NAMESPACE", XML_GLOBAL_NAMESPACE, CONST_PERSISTENT); -#endif REGISTER_LONG_CONSTANT("XML_LOCAL_NAMESPACE", XML_LOCAL_NAMESPACE, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_CDATA", XML_ATTRIBUTE_CDATA, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("XML_ATTRIBUTE_ID", XML_ATTRIBUTE_ID, CONST_PERSISTENT); @@ -1849,22 +1846,22 @@ static void register_php_dom_symbols(int module_number) REGISTER_LONG_CONSTANT("DOM_NAMESPACE_ERR", NAMESPACE_ERR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DOM_INVALID_ACCESS_ERR", INVALID_ACCESS_ERR, CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DOM_VALIDATION_ERR", VALIDATION_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\INDEX_SIZE_ERR", INDEX_SIZE_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\STRING_SIZE_ERR", DOMSTRING_SIZE_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\HIERARCHY_REQUEST_ERR", HIERARCHY_REQUEST_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\WRONG_DOCUMENT_ERR", WRONG_DOCUMENT_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\INVALID_CHARACTER_ERR", INVALID_CHARACTER_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\NO_DATA_ALLOWED_ERR", NO_DATA_ALLOWED_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\NO_MODIFICATION_ALLOWED_ERR", NO_MODIFICATION_ALLOWED_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\NOT_FOUND_ERR", NOT_FOUND_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\NOT_SUPPORTED_ERR", NOT_SUPPORTED_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\INUSE_ATTRIBUTE_ERR", INUSE_ATTRIBUTE_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\INVALID_STATE_ERR", INVALID_STATE_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\SYNTAX_ERR", SYNTAX_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\INVALID_MODIFICATION_ERR", INVALID_MODIFICATION_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\NAMESPACE_ERR", NAMESPACE_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\VALIDATION_ERR", VALIDATION_ERR, CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("DOM\\HTML_NO_DEFAULT_NS", DOM_HTML_NO_DEFAULT_NS, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\INDEX_SIZE_ERR", INDEX_SIZE_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\STRING_SIZE_ERR", DOMSTRING_SIZE_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\HIERARCHY_REQUEST_ERR", HIERARCHY_REQUEST_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\WRONG_DOCUMENT_ERR", WRONG_DOCUMENT_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\INVALID_CHARACTER_ERR", INVALID_CHARACTER_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\NO_DATA_ALLOWED_ERR", NO_DATA_ALLOWED_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\NO_MODIFICATION_ALLOWED_ERR", NO_MODIFICATION_ALLOWED_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\NOT_FOUND_ERR", NOT_FOUND_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\NOT_SUPPORTED_ERR", NOT_SUPPORTED_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\INUSE_ATTRIBUTE_ERR", INUSE_ATTRIBUTE_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\INVALID_STATE_ERR", INVALID_STATE_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\SYNTAX_ERR", SYNTAX_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\INVALID_MODIFICATION_ERR", INVALID_MODIFICATION_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\NAMESPACE_ERR", NAMESPACE_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\VALIDATION_ERR", VALIDATION_ERR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("Dom\\HTML_NO_DEFAULT_NS", DOM_HTML_NO_DEFAULT_NS, CONST_PERSISTENT); } static zend_class_entry *register_class_DOMDocumentType(zend_class_entry *class_entry_DOMNode) @@ -2551,7 +2548,7 @@ static zend_class_entry *register_class_DOMException(zend_class_entry *class_ent INIT_CLASS_ENTRY(ce, "DOMException", class_DOMException_methods); class_entry = zend_register_internal_class_ex(&ce, class_entry_Exception); class_entry->ce_flags |= ZEND_ACC_FINAL; - zend_register_class_alias("DOM\\DOMException", class_entry); + zend_register_class_alias("Dom\\DOMException", class_entry); zval property_code_default_value; ZVAL_LONG(&property_code_default_value, 0); @@ -2721,42 +2718,42 @@ static zend_class_entry *register_class_DOMXPath(void) } #endif -static zend_class_entry *register_class_DOM_ParentNode(void) +static zend_class_entry *register_class_Dom_ParentNode(void) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "ParentNode", class_DOM_ParentNode_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "ParentNode", class_Dom_ParentNode_methods); class_entry = zend_register_internal_interface(&ce); return class_entry; } -static zend_class_entry *register_class_DOM_ChildNode(void) +static zend_class_entry *register_class_Dom_ChildNode(void) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "ChildNode", class_DOM_ChildNode_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "ChildNode", class_Dom_ChildNode_methods); class_entry = zend_register_internal_interface(&ce); return class_entry; } -static zend_class_entry *register_class_DOM_Implementation(void) +static zend_class_entry *register_class_Dom_Implementation(void) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Implementation", class_DOM_Implementation_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Implementation", class_Dom_Implementation_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); class_entry->ce_flags |= ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE; return class_entry; } -static zend_class_entry *register_class_DOM_Node(void) +static zend_class_entry *register_class_Dom_Node(void) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Node", class_DOM_Node_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Node", class_Dom_Node_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); class_entry->ce_flags |= ZEND_ACC_NO_DYNAMIC_PROPERTIES; @@ -2823,57 +2820,57 @@ static zend_class_entry *register_class_DOM_Node(void) zval property_ownerDocument_default_value; ZVAL_UNDEF(&property_ownerDocument_default_value); zend_string *property_ownerDocument_name = zend_string_init("ownerDocument", sizeof("ownerDocument") - 1, 1); - zend_string *property_ownerDocument_class_DOM_Document = zend_string_init("DOM\\Document", sizeof("DOM\\Document")-1, 1); - zend_declare_typed_property(class_entry, property_ownerDocument_name, &property_ownerDocument_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerDocument_class_DOM_Document, 0, MAY_BE_NULL)); + zend_string *property_ownerDocument_class_Dom_Document = zend_string_init("Dom\\Document", sizeof("Dom\\Document")-1, 1); + zend_declare_typed_property(class_entry, property_ownerDocument_name, &property_ownerDocument_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerDocument_class_Dom_Document, 0, MAY_BE_NULL)); zend_string_release(property_ownerDocument_name); zval property_parentNode_default_value; ZVAL_UNDEF(&property_parentNode_default_value); zend_string *property_parentNode_name = zend_string_init("parentNode", sizeof("parentNode") - 1, 1); - zend_string *property_parentNode_class_DOM_Node = zend_string_init("DOM\\\116ode", sizeof("DOM\\\116ode")-1, 1); - zend_declare_typed_property(class_entry, property_parentNode_name, &property_parentNode_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentNode_class_DOM_Node, 0, MAY_BE_NULL)); + zend_string *property_parentNode_class_Dom_Node = zend_string_init("Dom\\\116ode", sizeof("Dom\\\116ode")-1, 1); + zend_declare_typed_property(class_entry, property_parentNode_name, &property_parentNode_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentNode_class_Dom_Node, 0, MAY_BE_NULL)); zend_string_release(property_parentNode_name); zval property_parentElement_default_value; ZVAL_UNDEF(&property_parentElement_default_value); zend_string *property_parentElement_name = zend_string_init("parentElement", sizeof("parentElement") - 1, 1); - zend_string *property_parentElement_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_parentElement_name, &property_parentElement_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentElement_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_parentElement_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_parentElement_name, &property_parentElement_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentElement_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_parentElement_name); zval property_childNodes_default_value; ZVAL_UNDEF(&property_childNodes_default_value); zend_string *property_childNodes_name = zend_string_init("childNodes", sizeof("childNodes") - 1, 1); - zend_string *property_childNodes_class_DOM_NodeList = zend_string_init("DOM\\\116odeList", sizeof("DOM\\\116odeList")-1, 1); - zend_declare_typed_property(class_entry, property_childNodes_name, &property_childNodes_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_childNodes_class_DOM_NodeList, 0, 0)); + zend_string *property_childNodes_class_Dom_NodeList = zend_string_init("Dom\\\116odeList", sizeof("Dom\\\116odeList")-1, 1); + zend_declare_typed_property(class_entry, property_childNodes_name, &property_childNodes_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_childNodes_class_Dom_NodeList, 0, 0)); zend_string_release(property_childNodes_name); zval property_firstChild_default_value; ZVAL_UNDEF(&property_firstChild_default_value); zend_string *property_firstChild_name = zend_string_init("firstChild", sizeof("firstChild") - 1, 1); - zend_string *property_firstChild_class_DOM_Node = zend_string_init("DOM\\\116ode", sizeof("DOM\\\116ode")-1, 1); - zend_declare_typed_property(class_entry, property_firstChild_name, &property_firstChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstChild_class_DOM_Node, 0, MAY_BE_NULL)); + zend_string *property_firstChild_class_Dom_Node = zend_string_init("Dom\\\116ode", sizeof("Dom\\\116ode")-1, 1); + zend_declare_typed_property(class_entry, property_firstChild_name, &property_firstChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstChild_class_Dom_Node, 0, MAY_BE_NULL)); zend_string_release(property_firstChild_name); zval property_lastChild_default_value; ZVAL_UNDEF(&property_lastChild_default_value); zend_string *property_lastChild_name = zend_string_init("lastChild", sizeof("lastChild") - 1, 1); - zend_string *property_lastChild_class_DOM_Node = zend_string_init("DOM\\\116ode", sizeof("DOM\\\116ode")-1, 1); - zend_declare_typed_property(class_entry, property_lastChild_name, &property_lastChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastChild_class_DOM_Node, 0, MAY_BE_NULL)); + zend_string *property_lastChild_class_Dom_Node = zend_string_init("Dom\\\116ode", sizeof("Dom\\\116ode")-1, 1); + zend_declare_typed_property(class_entry, property_lastChild_name, &property_lastChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastChild_class_Dom_Node, 0, MAY_BE_NULL)); zend_string_release(property_lastChild_name); zval property_previousSibling_default_value; ZVAL_UNDEF(&property_previousSibling_default_value); zend_string *property_previousSibling_name = zend_string_init("previousSibling", sizeof("previousSibling") - 1, 1); - zend_string *property_previousSibling_class_DOM_Node = zend_string_init("DOM\\\116ode", sizeof("DOM\\\116ode")-1, 1); - zend_declare_typed_property(class_entry, property_previousSibling_name, &property_previousSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousSibling_class_DOM_Node, 0, MAY_BE_NULL)); + zend_string *property_previousSibling_class_Dom_Node = zend_string_init("Dom\\\116ode", sizeof("Dom\\\116ode")-1, 1); + zend_declare_typed_property(class_entry, property_previousSibling_name, &property_previousSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousSibling_class_Dom_Node, 0, MAY_BE_NULL)); zend_string_release(property_previousSibling_name); zval property_nextSibling_default_value; ZVAL_UNDEF(&property_nextSibling_default_value); zend_string *property_nextSibling_name = zend_string_init("nextSibling", sizeof("nextSibling") - 1, 1); - zend_string *property_nextSibling_class_DOM_Node = zend_string_init("DOM\\\116ode", sizeof("DOM\\\116ode")-1, 1); - zend_declare_typed_property(class_entry, property_nextSibling_name, &property_nextSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextSibling_class_DOM_Node, 0, MAY_BE_NULL)); + zend_string *property_nextSibling_class_Dom_Node = zend_string_init("Dom\\\116ode", sizeof("Dom\\\116ode")-1, 1); + zend_declare_typed_property(class_entry, property_nextSibling_name, &property_nextSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextSibling_class_Dom_Node, 0, MAY_BE_NULL)); zend_string_release(property_nextSibling_name); zval property_nodeValue_default_value; @@ -2891,11 +2888,11 @@ static zend_class_entry *register_class_DOM_Node(void) return class_entry; } -static zend_class_entry *register_class_DOM_NodeList(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) +static zend_class_entry *register_class_Dom_NodeList(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "NodeList", class_DOM_NodeList_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "NodeList", class_Dom_NodeList_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Countable); @@ -2908,11 +2905,11 @@ static zend_class_entry *register_class_DOM_NodeList(zend_class_entry *class_ent return class_entry; } -static zend_class_entry *register_class_DOM_NamedNodeMap(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) +static zend_class_entry *register_class_Dom_NamedNodeMap(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "NamedNodeMap", class_DOM_NamedNodeMap_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "NamedNodeMap", class_Dom_NamedNodeMap_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Countable); @@ -2925,11 +2922,11 @@ static zend_class_entry *register_class_DOM_NamedNodeMap(zend_class_entry *class return class_entry; } -static zend_class_entry *register_class_DOM_DTDNamedNodeMap(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) +static zend_class_entry *register_class_Dom_DtdNamedNodeMap(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "DTDNamedNodeMap", class_DOM_DTDNamedNodeMap_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "DtdNamedNodeMap", class_Dom_DtdNamedNodeMap_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Countable); @@ -2942,11 +2939,11 @@ static zend_class_entry *register_class_DOM_DTDNamedNodeMap(zend_class_entry *cl return class_entry; } -static zend_class_entry *register_class_DOM_HTMLCollection(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) +static zend_class_entry *register_class_Dom_HTMLCollection(zend_class_entry *class_entry_IteratorAggregate, zend_class_entry *class_entry_Countable) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "HTMLCollection", class_DOM_HTMLCollection_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "HTMLCollection", class_Dom_HTMLCollection_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); zend_class_implements(class_entry, 2, class_entry_IteratorAggregate, class_entry_Countable); @@ -2959,13 +2956,13 @@ static zend_class_entry *register_class_DOM_HTMLCollection(zend_class_entry *cla return class_entry; } -static zend_class_entry *register_class_DOM_Element(zend_class_entry *class_entry_DOM_Node, zend_class_entry *class_entry_DOM_ParentNode, zend_class_entry *class_entry_DOM_ChildNode) +static zend_class_entry *register_class_Dom_Element(zend_class_entry *class_entry_Dom_Node, zend_class_entry *class_entry_Dom_ParentNode, zend_class_entry *class_entry_Dom_ChildNode) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Element", class_DOM_Element_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); - zend_class_implements(class_entry, 2, class_entry_DOM_ParentNode, class_entry_DOM_ChildNode); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Element", class_Dom_Element_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); + zend_class_implements(class_entry, 2, class_entry_Dom_ParentNode, class_entry_Dom_ChildNode); zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); @@ -3006,22 +3003,22 @@ static zend_class_entry *register_class_DOM_Element(zend_class_entry *class_entr zval property_attributes_default_value; ZVAL_UNDEF(&property_attributes_default_value); zend_string *property_attributes_name = zend_string_init("attributes", sizeof("attributes") - 1, 1); - zend_string *property_attributes_class_DOM_NamedNodeMap = zend_string_init("DOM\\\116amedNodeMap", sizeof("DOM\\\116amedNodeMap")-1, 1); - zend_declare_typed_property(class_entry, property_attributes_name, &property_attributes_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_attributes_class_DOM_NamedNodeMap, 0, 0)); + zend_string *property_attributes_class_Dom_NamedNodeMap = zend_string_init("Dom\\\116amedNodeMap", sizeof("Dom\\\116amedNodeMap")-1, 1); + zend_declare_typed_property(class_entry, property_attributes_name, &property_attributes_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_attributes_class_Dom_NamedNodeMap, 0, 0)); zend_string_release(property_attributes_name); zval property_firstElementChild_default_value; ZVAL_UNDEF(&property_firstElementChild_default_value); zend_string *property_firstElementChild_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, 1); - zend_string *property_firstElementChild_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_firstElementChild_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_firstElementChild_name); zval property_lastElementChild_default_value; ZVAL_UNDEF(&property_lastElementChild_default_value); zend_string *property_lastElementChild_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, 1); - zend_string *property_lastElementChild_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_lastElementChild_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_lastElementChild_name); zval property_childElementCount_default_value; @@ -3033,26 +3030,26 @@ static zend_class_entry *register_class_DOM_Element(zend_class_entry *class_entr zval property_previousElementSibling_default_value; ZVAL_UNDEF(&property_previousElementSibling_default_value); zend_string *property_previousElementSibling_name = zend_string_init("previousElementSibling", sizeof("previousElementSibling") - 1, 1); - zend_string *property_previousElementSibling_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_previousElementSibling_name, &property_previousElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_previousElementSibling_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_previousElementSibling_name, &property_previousElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_previousElementSibling_name); zval property_nextElementSibling_default_value; ZVAL_UNDEF(&property_nextElementSibling_default_value); zend_string *property_nextElementSibling_name = zend_string_init("nextElementSibling", sizeof("nextElementSibling") - 1, 1); - zend_string *property_nextElementSibling_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_nextElementSibling_name, &property_nextElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_nextElementSibling_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_nextElementSibling_name, &property_nextElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_nextElementSibling_name); return class_entry; } -static zend_class_entry *register_class_DOM_Attr(zend_class_entry *class_entry_DOM_Node) +static zend_class_entry *register_class_Dom_Attr(zend_class_entry *class_entry_Dom_Node) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Attr", class_DOM_Attr_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Attr", class_Dom_Attr_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); @@ -3087,8 +3084,8 @@ static zend_class_entry *register_class_DOM_Attr(zend_class_entry *class_entry_D zval property_ownerElement_default_value; ZVAL_UNDEF(&property_ownerElement_default_value); zend_string *property_ownerElement_name = zend_string_init("ownerElement", sizeof("ownerElement") - 1, 1); - zend_string *property_ownerElement_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_ownerElement_name, &property_ownerElement_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerElement_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_ownerElement_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_ownerElement_name, &property_ownerElement_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerElement_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_ownerElement_name); zval property_specified_default_value; @@ -3100,26 +3097,26 @@ static zend_class_entry *register_class_DOM_Attr(zend_class_entry *class_entry_D return class_entry; } -static zend_class_entry *register_class_DOM_CharacterData(zend_class_entry *class_entry_DOM_Node, zend_class_entry *class_entry_DOM_ChildNode) +static zend_class_entry *register_class_Dom_CharacterData(zend_class_entry *class_entry_Dom_Node, zend_class_entry *class_entry_Dom_ChildNode) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "CharacterData", class_DOM_CharacterData_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); - zend_class_implements(class_entry, 1, class_entry_DOM_ChildNode); + INIT_NS_CLASS_ENTRY(ce, "Dom", "CharacterData", class_Dom_CharacterData_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); + zend_class_implements(class_entry, 1, class_entry_Dom_ChildNode); zval property_previousElementSibling_default_value; ZVAL_UNDEF(&property_previousElementSibling_default_value); zend_string *property_previousElementSibling_name = zend_string_init("previousElementSibling", sizeof("previousElementSibling") - 1, 1); - zend_string *property_previousElementSibling_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_previousElementSibling_name, &property_previousElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_previousElementSibling_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_previousElementSibling_name, &property_previousElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_previousElementSibling_name); zval property_nextElementSibling_default_value; ZVAL_UNDEF(&property_nextElementSibling_default_value); zend_string *property_nextElementSibling_name = zend_string_init("nextElementSibling", sizeof("nextElementSibling") - 1, 1); - zend_string *property_nextElementSibling_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_nextElementSibling_name, &property_nextElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_nextElementSibling_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_nextElementSibling_name, &property_nextElementSibling_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_nextElementSibling_name); zval property_data_default_value; @@ -3137,12 +3134,12 @@ static zend_class_entry *register_class_DOM_CharacterData(zend_class_entry *clas return class_entry; } -static zend_class_entry *register_class_DOM_Text(zend_class_entry *class_entry_DOM_CharacterData) +static zend_class_entry *register_class_Dom_Text(zend_class_entry *class_entry_Dom_CharacterData) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Text", class_DOM_Text_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_CharacterData); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Text", class_Dom_Text_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_CharacterData); zval property_wholeText_default_value; ZVAL_UNDEF(&property_wholeText_default_value); @@ -3153,22 +3150,22 @@ static zend_class_entry *register_class_DOM_Text(zend_class_entry *class_entry_D return class_entry; } -static zend_class_entry *register_class_DOM_CDATASection(zend_class_entry *class_entry_DOM_Text) +static zend_class_entry *register_class_Dom_CDATASection(zend_class_entry *class_entry_Dom_Text) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "CDATASection", class_DOM_CDATASection_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Text); + INIT_NS_CLASS_ENTRY(ce, "Dom", "CDATASection", class_Dom_CDATASection_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Text); return class_entry; } -static zend_class_entry *register_class_DOM_ProcessingInstruction(zend_class_entry *class_entry_DOM_CharacterData) +static zend_class_entry *register_class_Dom_ProcessingInstruction(zend_class_entry *class_entry_Dom_CharacterData) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "ProcessingInstruction", class_DOM_ProcessingInstruction_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_CharacterData); + INIT_NS_CLASS_ENTRY(ce, "Dom", "ProcessingInstruction", class_Dom_ProcessingInstruction_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_CharacterData); zval property_target_default_value; ZVAL_UNDEF(&property_target_default_value); @@ -3179,23 +3176,23 @@ static zend_class_entry *register_class_DOM_ProcessingInstruction(zend_class_ent return class_entry; } -static zend_class_entry *register_class_DOM_Comment(zend_class_entry *class_entry_DOM_CharacterData) +static zend_class_entry *register_class_Dom_Comment(zend_class_entry *class_entry_Dom_CharacterData) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Comment", class_DOM_Comment_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_CharacterData); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Comment", class_Dom_Comment_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_CharacterData); return class_entry; } -static zend_class_entry *register_class_DOM_DocumentType(zend_class_entry *class_entry_DOM_Node, zend_class_entry *class_entry_DOM_ChildNode) +static zend_class_entry *register_class_Dom_DocumentType(zend_class_entry *class_entry_Dom_Node, zend_class_entry *class_entry_Dom_ChildNode) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "DocumentType", class_DOM_DocumentType_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); - zend_class_implements(class_entry, 1, class_entry_DOM_ChildNode); + INIT_NS_CLASS_ENTRY(ce, "Dom", "DocumentType", class_Dom_DocumentType_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); + zend_class_implements(class_entry, 1, class_entry_Dom_ChildNode); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); @@ -3206,15 +3203,15 @@ static zend_class_entry *register_class_DOM_DocumentType(zend_class_entry *class zval property_entities_default_value; ZVAL_UNDEF(&property_entities_default_value); zend_string *property_entities_name = zend_string_init("entities", sizeof("entities") - 1, 1); - zend_string *property_entities_class_DOM_DTDNamedNodeMap = zend_string_init("DOM\\DTDNamedNodeMap", sizeof("DOM\\DTDNamedNodeMap")-1, 1); - zend_declare_typed_property(class_entry, property_entities_name, &property_entities_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_entities_class_DOM_DTDNamedNodeMap, 0, 0)); + zend_string *property_entities_class_Dom_DtdNamedNodeMap = zend_string_init("Dom\\DtdNamedNodeMap", sizeof("Dom\\DtdNamedNodeMap")-1, 1); + zend_declare_typed_property(class_entry, property_entities_name, &property_entities_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_entities_class_Dom_DtdNamedNodeMap, 0, 0)); zend_string_release(property_entities_name); zval property_notations_default_value; ZVAL_UNDEF(&property_notations_default_value); zend_string *property_notations_name = zend_string_init("notations", sizeof("notations") - 1, 1); - zend_string *property_notations_class_DOM_DTDNamedNodeMap = zend_string_init("DOM\\DTDNamedNodeMap", sizeof("DOM\\DTDNamedNodeMap")-1, 1); - zend_declare_typed_property(class_entry, property_notations_name, &property_notations_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_notations_class_DOM_DTDNamedNodeMap, 0, 0)); + zend_string *property_notations_class_Dom_DtdNamedNodeMap = zend_string_init("Dom\\DtdNamedNodeMap", sizeof("Dom\\DtdNamedNodeMap")-1, 1); + zend_declare_typed_property(class_entry, property_notations_name, &property_notations_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_notations_class_Dom_DtdNamedNodeMap, 0, 0)); zend_string_release(property_notations_name); zval property_publicId_default_value; @@ -3238,26 +3235,26 @@ static zend_class_entry *register_class_DOM_DocumentType(zend_class_entry *class return class_entry; } -static zend_class_entry *register_class_DOM_DocumentFragment(zend_class_entry *class_entry_DOM_Node, zend_class_entry *class_entry_DOM_ParentNode) +static zend_class_entry *register_class_Dom_DocumentFragment(zend_class_entry *class_entry_Dom_Node, zend_class_entry *class_entry_Dom_ParentNode) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "DocumentFragment", class_DOM_DocumentFragment_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); - zend_class_implements(class_entry, 1, class_entry_DOM_ParentNode); + INIT_NS_CLASS_ENTRY(ce, "Dom", "DocumentFragment", class_Dom_DocumentFragment_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); + zend_class_implements(class_entry, 1, class_entry_Dom_ParentNode); zval property_firstElementChild_default_value; ZVAL_UNDEF(&property_firstElementChild_default_value); zend_string *property_firstElementChild_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, 1); - zend_string *property_firstElementChild_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_firstElementChild_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_firstElementChild_name); zval property_lastElementChild_default_value; ZVAL_UNDEF(&property_lastElementChild_default_value); zend_string *property_lastElementChild_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, 1); - zend_string *property_lastElementChild_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_lastElementChild_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_lastElementChild_name); zval property_childElementCount_default_value; @@ -3269,12 +3266,12 @@ static zend_class_entry *register_class_DOM_DocumentFragment(zend_class_entry *c return class_entry; } -static zend_class_entry *register_class_DOM_Entity(zend_class_entry *class_entry_DOM_Node) +static zend_class_entry *register_class_Dom_Entity(zend_class_entry *class_entry_Dom_Node) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Entity", class_DOM_Entity_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Entity", class_Dom_Entity_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); @@ -3297,22 +3294,22 @@ static zend_class_entry *register_class_DOM_Entity(zend_class_entry *class_entry return class_entry; } -static zend_class_entry *register_class_DOM_EntityReference(zend_class_entry *class_entry_DOM_Node) +static zend_class_entry *register_class_Dom_EntityReference(zend_class_entry *class_entry_Dom_Node) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "EntityReference", class_DOM_EntityReference_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); + INIT_NS_CLASS_ENTRY(ce, "Dom", "EntityReference", class_Dom_EntityReference_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); return class_entry; } -static zend_class_entry *register_class_DOM_Notation(zend_class_entry *class_entry_DOM_Node) +static zend_class_entry *register_class_Dom_Notation(zend_class_entry *class_entry_Dom_Node) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Notation", class_DOM_Notation_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Notation", class_Dom_Notation_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); @@ -3329,20 +3326,20 @@ static zend_class_entry *register_class_DOM_Notation(zend_class_entry *class_ent return class_entry; } -static zend_class_entry *register_class_DOM_Document(zend_class_entry *class_entry_DOM_Node, zend_class_entry *class_entry_DOM_ParentNode) +static zend_class_entry *register_class_Dom_Document(zend_class_entry *class_entry_Dom_Node, zend_class_entry *class_entry_Dom_ParentNode) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "Document", class_DOM_Document_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Node); + INIT_NS_CLASS_ENTRY(ce, "Dom", "Document", class_Dom_Document_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Node); class_entry->ce_flags |= ZEND_ACC_ABSTRACT; - zend_class_implements(class_entry, 1, class_entry_DOM_ParentNode); + zend_class_implements(class_entry, 1, class_entry_Dom_ParentNode); zval property_implementation_default_value; ZVAL_UNDEF(&property_implementation_default_value); zend_string *property_implementation_name = zend_string_init("implementation", sizeof("implementation") - 1, 1); - zend_string *property_implementation_class_DOM_Implementation = zend_string_init("DOM\\Implementation", sizeof("DOM\\Implementation")-1, 1); - zend_declare_typed_property(class_entry, property_implementation_name, &property_implementation_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_implementation_class_DOM_Implementation, 0, 0)); + zend_string *property_implementation_class_Dom_Implementation = zend_string_init("Dom\\Implementation", sizeof("Dom\\Implementation")-1, 1); + zend_declare_typed_property(class_entry, property_implementation_name, &property_implementation_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_implementation_class_Dom_Implementation, 0, 0)); zend_string_release(property_implementation_name); zval property_URL_default_value; @@ -3378,29 +3375,29 @@ static zend_class_entry *register_class_DOM_Document(zend_class_entry *class_ent zval property_doctype_default_value; ZVAL_UNDEF(&property_doctype_default_value); zend_string *property_doctype_name = zend_string_init("doctype", sizeof("doctype") - 1, 1); - zend_string *property_doctype_class_DOM_DocumentType = zend_string_init("DOM\\DocumentType", sizeof("DOM\\DocumentType")-1, 1); - zend_declare_typed_property(class_entry, property_doctype_name, &property_doctype_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_doctype_class_DOM_DocumentType, 0, MAY_BE_NULL)); + zend_string *property_doctype_class_Dom_DocumentType = zend_string_init("Dom\\DocumentType", sizeof("Dom\\DocumentType")-1, 1); + zend_declare_typed_property(class_entry, property_doctype_name, &property_doctype_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_doctype_class_Dom_DocumentType, 0, MAY_BE_NULL)); zend_string_release(property_doctype_name); zval property_documentElement_default_value; ZVAL_UNDEF(&property_documentElement_default_value); zend_string *property_documentElement_name = zend_string_init("documentElement", sizeof("documentElement") - 1, 1); - zend_string *property_documentElement_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_documentElement_name, &property_documentElement_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_documentElement_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_documentElement_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_documentElement_name, &property_documentElement_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_documentElement_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_documentElement_name); zval property_firstElementChild_default_value; ZVAL_UNDEF(&property_firstElementChild_default_value); zend_string *property_firstElementChild_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, 1); - zend_string *property_firstElementChild_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_firstElementChild_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_firstElementChild_name); zval property_lastElementChild_default_value; ZVAL_UNDEF(&property_lastElementChild_default_value); zend_string *property_lastElementChild_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, 1); - zend_string *property_lastElementChild_class_DOM_Element = zend_string_init("DOM\\Element", sizeof("DOM\\Element")-1, 1); - zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_DOM_Element, 0, MAY_BE_NULL)); + zend_string *property_lastElementChild_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); + zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_Dom_Element, 0, MAY_BE_NULL)); zend_string_release(property_lastElementChild_name); zval property_childElementCount_default_value; @@ -3412,23 +3409,23 @@ static zend_class_entry *register_class_DOM_Document(zend_class_entry *class_ent return class_entry; } -static zend_class_entry *register_class_DOM_HTMLDocument(zend_class_entry *class_entry_DOM_Document) +static zend_class_entry *register_class_Dom_HTMLDocument(zend_class_entry *class_entry_Dom_Document) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "HTMLDocument", class_DOM_HTMLDocument_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Document); + INIT_NS_CLASS_ENTRY(ce, "Dom", "HTMLDocument", class_Dom_HTMLDocument_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Document); class_entry->ce_flags |= ZEND_ACC_FINAL; return class_entry; } -static zend_class_entry *register_class_DOM_XMLDocument(zend_class_entry *class_entry_DOM_Document) +static zend_class_entry *register_class_Dom_XMLDocument(zend_class_entry *class_entry_Dom_Document) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "XMLDocument", class_DOM_XMLDocument_methods); - class_entry = zend_register_internal_class_ex(&ce, class_entry_DOM_Document); + INIT_NS_CLASS_ENTRY(ce, "Dom", "XMLDocument", class_Dom_XMLDocument_methods); + class_entry = zend_register_internal_class_ex(&ce, class_entry_Dom_Document); class_entry->ce_flags |= ZEND_ACC_FINAL; zval property_xmlEncoding_default_value; @@ -3459,19 +3456,19 @@ static zend_class_entry *register_class_DOM_XMLDocument(zend_class_entry *class_ } #if defined(LIBXML_XPATH_ENABLED) -static zend_class_entry *register_class_DOM_XPath(void) +static zend_class_entry *register_class_Dom_XPath(void) { zend_class_entry ce, *class_entry; - INIT_NS_CLASS_ENTRY(ce, "DOM", "XPath", class_DOM_XPath_methods); + INIT_NS_CLASS_ENTRY(ce, "Dom", "XPath", class_Dom_XPath_methods); class_entry = zend_register_internal_class_ex(&ce, NULL); class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NOT_SERIALIZABLE; zval property_document_default_value; ZVAL_UNDEF(&property_document_default_value); zend_string *property_document_name = zend_string_init("document", sizeof("document") - 1, 1); - zend_string *property_document_class_DOM_Document = zend_string_init("DOM\\Document", sizeof("DOM\\Document")-1, 1); - zend_declare_typed_property(class_entry, property_document_name, &property_document_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_document_class_DOM_Document, 0, 0)); + zend_string *property_document_class_Dom_Document = zend_string_init("Dom\\Document", sizeof("Dom\\Document")-1, 1); + zend_declare_typed_property(class_entry, property_document_name, &property_document_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_document_class_Dom_Document, 0, 0)); zend_string_release(property_document_name); zval property_registerNodeNamespaces_default_value; diff --git a/ext/dom/tests/DOMNode_C14N_references.phpt b/ext/dom/tests/DOMNode_C14N_references.phpt new file mode 100644 index 0000000000000..5612874f5f30f --- /dev/null +++ b/ext/dom/tests/DOMNode_C14N_references.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test: Canonicalization - C14N() with references +--EXTENSIONS-- +dom +--FILE-- + + + + + + + + +EOXML; + +$dom = new DOMDocument(); +$dom->loadXML($xml); +$doc = $dom->documentElement->firstChild; + +$xpath = [ + 'query' => '(//a:contain | //a:bar | .//namespace::*)', + 'namespaces' => ['a' => 'http://www.example.com/ns/foo'], +]; +$prefixes = ['test']; + +foreach ($xpath['namespaces'] as $k => &$v); +unset($v); +foreach ($xpath as $k => &$v); +unset($v); +foreach ($prefixes as $k => &$v); +unset($v); + +echo $doc->C14N(true, false, $xpath, $prefixes); +?> +--EXPECT-- + diff --git a/ext/dom/tests/ParentNode_append_fragment_text_coalesce.phpt b/ext/dom/tests/ParentNode_append_fragment_text_coalesce.phpt new file mode 100644 index 0000000000000..601819d611775 --- /dev/null +++ b/ext/dom/tests/ParentNode_append_fragment_text_coalesce.phpt @@ -0,0 +1,21 @@ +--TEST-- +Text coalesce bug when appending fragment with text nodes +--EXTENSIONS-- +dom +--FILE-- +loadXML(''); + +$sut = $document->createDocumentFragment(); +for($i = 0; $i < 10; $i++) { + $textNode = $document->createTextNode("Node$i"); + $sut->append($textNode); +} + +$document->documentElement->append($sut); +echo $document->saveXML(); +?> +--EXPECT-- + +Node0Node1Node2Node3Node4Node5Node6Node7Node8Node9 diff --git a/ext/dom/tests/childNodes_current_crash.phpt b/ext/dom/tests/childNodes_current_crash.phpt new file mode 100644 index 0000000000000..aa93cf33a6481 --- /dev/null +++ b/ext/dom/tests/childNodes_current_crash.phpt @@ -0,0 +1,25 @@ +--TEST-- +Crash in childNodes iterator current() +--EXTENSIONS-- +dom +--FILE-- +loadXML('foo1'); + +$nodes = $dom->documentElement->childNodes; +$iter = $nodes->getIterator(); + +var_dump($iter->valid()); +var_dump($iter->current()?->wholeText); +$iter->next(); +var_dump($iter->valid()); +var_dump($iter->current()?->wholeText); + +?> +--EXPECT-- +bool(true) +string(4) "foo1" +bool(false) +NULL diff --git a/ext/dom/tests/dom_import_simplexml.phpt b/ext/dom/tests/dom_import_simplexml.phpt index f38ea1227ca3b..e761bfa66d859 100644 --- a/ext/dom/tests/dom_import_simplexml.phpt +++ b/ext/dom/tests/dom_import_simplexml.phpt @@ -15,7 +15,7 @@ print $dom->ownerDocument->saveXML(); // This should fail because it has been imported already above in legacy DOM try { - DOM\import_simplexml($s); + Dom\import_simplexml($s); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } @@ -32,4 +32,4 @@ try { John Steinbeck -DOM\import_simplexml(): Argument #1 ($node) must not be already imported as a DOMNode +Dom\import_simplexml(): Argument #1 ($node) must not be already imported as a DOMNode diff --git a/ext/dom/tests/entity_reference_stale_01.phpt b/ext/dom/tests/entity_reference_stale_01.phpt new file mode 100644 index 0000000000000..dc1828c3cd999 --- /dev/null +++ b/ext/dom/tests/entity_reference_stale_01.phpt @@ -0,0 +1,41 @@ +--TEST-- +Entity references with stale entity declaration 01 +--EXTENSIONS-- +dom +--FILE-- +loadXML(<< +]> +&foo; +XML); + +$ref = $dom->documentElement->firstChild; +$decl = $ref->firstChild; + +$nodes = $ref->childNodes; +$dom->removeChild($dom->doctype); +unset($decl); + +var_dump($nodes); +var_dump($ref->firstChild); +var_dump($ref->lastChild); +var_dump($ref->textContent); +var_dump($ref->childNodes); + +?> +--EXPECT-- +object(DOMNodeList)#4 (1) { + ["length"]=> + int(0) +} +NULL +NULL +string(0) "" +object(DOMNodeList)#2 (1) { + ["length"]=> + int(0) +} diff --git a/ext/dom/tests/entity_reference_stale_02.phpt b/ext/dom/tests/entity_reference_stale_02.phpt new file mode 100644 index 0000000000000..9e25a2c0e94a4 --- /dev/null +++ b/ext/dom/tests/entity_reference_stale_02.phpt @@ -0,0 +1,35 @@ +--TEST-- +Entity references with stale entity declaration 02 +--EXTENSIONS-- +dom +--FILE-- +loadXML(<< + + +]> +&foo1; +XML); + +$ref = $dom->documentElement->firstChild; +$decl = $ref->firstChild; + +$nodes = $ref->childNodes; +$iter = $nodes->getIterator(); +$iter->next(); +$dom->removeChild($dom->doctype); +unset($decl); + +try { + var_dump($iter->current()->publicId); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +NULL diff --git a/ext/dom/tests/entity_reference_stale_03.phpt b/ext/dom/tests/entity_reference_stale_03.phpt new file mode 100644 index 0000000000000..03ac2ab19585e --- /dev/null +++ b/ext/dom/tests/entity_reference_stale_03.phpt @@ -0,0 +1,34 @@ +--TEST-- +Entity references with stale entity declaration 03 +--EXTENSIONS-- +dom +--FILE-- + + ]> + &foo; + XML); + + $ref = $dom->documentElement->firstChild; + $decl = $ref->firstChild; + + $nodes = $ref->childNodes; + $dom->removeChild($dom->doctype); + unset($decl); + + var_dump($ref->$prop); +} + +?> +--EXPECT-- +NULL +NULL +NULL +object(Dom\NodeList)#1 (1) { + ["length"]=> + int(0) +} diff --git a/ext/dom/tests/gh13863.phpt b/ext/dom/tests/gh13863.phpt index e9a7058c3414d..bf761438ac88a 100644 --- a/ext/dom/tests/gh13863.phpt +++ b/ext/dom/tests/gh13863.phpt @@ -26,7 +26,7 @@ function createTestDoc(DomType $type) { $doc->preserveWhiteSpace = false; $doc->loadXML($xml); } else { - $doc = DOM\XMLDocument::createFromString($xml, LIBXML_NOBLANKS); + $doc = Dom\XMLDocument::createFromString($xml, LIBXML_NOBLANKS); } return $doc; diff --git a/ext/dom/tests/modern/common/namespace_sxe_interaction.phpt b/ext/dom/tests/modern/common/namespace_sxe_interaction.phpt new file mode 100644 index 0000000000000..c25518616fca9 --- /dev/null +++ b/ext/dom/tests/modern/common/namespace_sxe_interaction.phpt @@ -0,0 +1,67 @@ +--TEST-- +Serialization interaction between simplexml and dom for namespaces +--EXTENSIONS-- +dom +simplexml +--FILE-- +'); +$sxe = simplexml_import_dom($dom); + +$sxe->addAttribute('a:attr', 'value', 'urn:a'); +$sxe->addChild('b:child', 'value', 'urn:b'); +$sxe->addChild('foo', 'value2'); +$dom->documentElement->firstElementChild->appendChild($dom->createElementNS('urn:c', 'c:child')); + +echo "namespace c: "; +var_dump($dom->documentElement->firstElementChild->firstElementChild->lookupNamespaceURI('c')); +echo "namespace b: "; +var_dump($dom->documentElement->firstElementChild->firstElementChild->lookupNamespaceURI('b')); +echo "namespace a: "; +var_dump($dom->documentElement->firstElementChild->firstElementChild->lookupNamespaceURI('a')); + +echo "=== serialize SimpleXML ===\n"; + +echo $sxe->saveXML(), "\n"; +echo $sxe->foo->saveXML(), "\n"; +$sxe->asXML(__DIR__ . "/namespace_sxe_interaction1.xml"); +$sxe->foo->asXML(__DIR__ . "/namespace_sxe_interaction2.xml"); +echo file_get_contents(__DIR__ . "/namespace_sxe_interaction1.xml"), "\n"; +echo file_get_contents(__DIR__ . "/namespace_sxe_interaction2.xml"), "\n"; + +echo "=== serialize DOM ===\n"; + +echo $dom->saveXML(), "\n\n"; + +echo "=== serialize imported DOM ===\n"; + +// Importing should yield the exact same document +$new_dom = Dom\XMLDocument::createEmpty(); +$new_dom->append($new_dom->importNode($dom->documentElement, true)); +echo $new_dom->saveXML(), "\n"; + +?> +--CLEAN-- + +--EXPECT-- +namespace c: string(5) "urn:c" +namespace b: string(5) "urn:b" +namespace a: NULL +=== serialize SimpleXML === + +valuevalue2 +value2 + +valuevalue2 +value2 +=== serialize DOM === + +valuevalue2 + +=== serialize imported DOM === + +valuevalue2 diff --git a/ext/dom/tests/modern/common/serialize_entity_reference_in_attribute.phpt b/ext/dom/tests/modern/common/serialize_entity_reference_in_attribute.phpt index 79f92439bd5fa..231546c6b3714 100644 --- a/ext/dom/tests/modern/common/serialize_entity_reference_in_attribute.phpt +++ b/ext/dom/tests/modern/common/serialize_entity_reference_in_attribute.phpt @@ -5,7 +5,7 @@ dom --FILE-- ]> @@ -13,11 +13,11 @@ $xml = DOM\XMLDocument::createFromString(<<documentElement->firstChild; -echo $xml->saveXML(), "\n"; +echo $xml->saveXml(), "\n"; -$html = DOM\HTMLDocument::createEmpty(); +$html = Dom\HTMLDocument::createEmpty(); $html->append($html->importNode($el, true)); -echo $html->saveHTML(), "\n"; +echo $html->saveHtml(), "\n"; ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_GB18030.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_GB18030.phpt index 05a348df0ce28..f1967adc379b0 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_GB18030.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_GB18030.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument GB18030 encoding test +Dom\HTMLDocument GB18030 encoding test --EXTENSIONS-- dom --FILE-- charset); $dom->documentElement->firstChild->nextElementSibling->textContent = "é"; -$output = $dom->saveHTML(); +$output = $dom->saveHtml(); echo $output, "\n"; -$dom->saveHTMLFile(__DIR__ . "/gb18030_output.tmp"); +$dom->saveHtmlFile(__DIR__ . "/gb18030_output.tmp"); var_dump(file_get_contents(__DIR__ . "/gb18030_output.tmp") === $output); echo "--- After changing encoding to UTF-8 ---\n"; $dom->charset = "UTF-8"; -echo $dom->saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; ?> --CLEAN-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_Shift_JIS.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_Shift_JIS.phpt index 84e835c1d8d89..56c0523821e7f 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_Shift_JIS.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_Shift_JIS.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument Shift JIS encoding test +Dom\HTMLDocument Shift JIS encoding test --EXTENSIONS-- dom --FILE-- charset); $dom->documentElement->firstChild->nextElementSibling->textContent .= "é"; -$output = $dom->saveHTML(); +$output = $dom->saveHtml(); echo $output, "\n"; -$dom->saveHTMLFile(__DIR__ . "/shift_jis.tmp"); +$dom->saveHtmlFile(__DIR__ . "/shift_jis.tmp"); var_dump(file_get_contents(__DIR__ . "/shift_jis.tmp") === $output); echo "--- After changing encoding to UTF-8 ---\n"; $dom->charset = "UTF-8"; -echo $dom->saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; ?> --CLEAN-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16BE_BOM.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16BE_BOM.phpt index 315384345a4b9..eb4af0a5b3ca6 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16BE_BOM.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16BE_BOM.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument UTF-16BE BOM encoding test +Dom\HTMLDocument UTF-16BE BOM encoding test --EXTENSIONS-- dom --FILE-- characterSet); $dom->documentElement->firstChild->nextElementSibling->textContent = "é"; -$output = $dom->saveHTML(); +$output = $dom->saveHtml(); echo $output, "\n"; -$dom->saveHTMLFile(__DIR__ . "/utf16be_bom_output.tmp"); +$dom->saveHtmlFile(__DIR__ . "/utf16be_bom_output.tmp"); var_dump(file_get_contents(__DIR__ . "/utf16be_bom_output.tmp") === $output); echo "--- After changing encoding to UTF-8 ---\n"; $dom->characterSet = "UTF-8"; -echo $dom->saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; ?> --CLEAN-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16LE_BOM.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16LE_BOM.phpt index 8b0183a9f055e..0a6dbf7fe80be 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16LE_BOM.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF16LE_BOM.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument UTF-16LE BOM encoding test +Dom\HTMLDocument UTF-16LE BOM encoding test --EXTENSIONS-- dom --FILE-- inputEncoding); $dom->documentElement->firstChild->nextElementSibling->textContent = "é"; -$output = $dom->saveHTML(); +$output = $dom->saveHtml(); echo $output, "\n"; -$dom->saveHTMLFile(__DIR__ . "/utf16le_bom_output.tmp"); +$dom->saveHtmlFile(__DIR__ . "/utf16le_bom_output.tmp"); var_dump(file_get_contents(__DIR__ . "/utf16le_bom_output.tmp") === $output); echo "--- After changing encoding to UTF-8 ---\n"; $dom->inputEncoding = "UTF-8"; -echo $dom->saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; ?> --CLEAN-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF8_BOM.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF8_BOM.phpt index c23ca5a9a47ec..2054cb3d4a99e 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF8_BOM.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_UTF8_BOM.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument UTF-8 BOM encoding test +Dom\HTMLDocument UTF-8 BOM encoding test --EXTENSIONS-- dom --FILE-- charset); $dom->documentElement->firstChild->nextElementSibling->textContent = "é"; -$output = $dom->saveHTML(); +$output = $dom->saveHtml(); echo $output, "\n"; -$dom->saveHTMLFile(__DIR__ . "/utf8_bom_output.tmp"); +$dom->saveHtmlFile(__DIR__ . "/utf8_bom_output.tmp"); var_dump(file_get_contents(__DIR__ . "/utf8_bom_output.tmp") === $output); echo "--- After changing encoding to UTF-8 ---\n"; $dom->charset = "UTF-8"; -echo $dom->saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; ?> --CLEAN-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_Windows1251.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_Windows1251.phpt index 98d313a554028..75e7662e4e0a6 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_Windows1251.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_Windows1251.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument Windows-1251 encoding test +Dom\HTMLDocument Windows-1251 encoding test --EXTENSIONS-- dom --FILE-- charset); $dom->documentElement->firstChild->nextElementSibling->textContent .= "é"; // Note: won't show up in Windows 1251 because it doesn't exist there -$output = $dom->saveHTML(); +$output = $dom->saveHtml(); echo $output, "\n"; -$dom->saveHTMLFile(__DIR__ . "/windows1251_output.tmp"); +$dom->saveHtmlFile(__DIR__ . "/windows1251_output.tmp"); var_dump(file_get_contents(__DIR__ . "/windows1251_output.tmp") === $output); echo "--- After changing encoding to UTF-8 ---\n"; $dom->charset = "UTF-8"; -echo $dom->saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; ?> --CLEAN-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt index 8a4271c3a0a88..5c602b87f23e1 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_http_header.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument::createFromFile() HTTP header Content-Type +Dom\HTMLDocument::createFromFile() HTTP header Content-Type --EXTENSIONS-- dom --SKIPIF-- @@ -62,7 +62,7 @@ foreach ($tests as $name => $headers) { $responses = array_map(fn ($header) => "data://text/plain,HTTP/1.1 200 OK\r\nContent-Type: " . $header . "\r\n\r\n" . "

\xE4\xF6\xFC

\n", $headers); ['pid' => $pid, 'uri' => $uri] = http_server($responses); for ($i = 0; $i < count($responses); $i++) { - $result = DOM\HTMLDocument::createFromFile($uri, LIBXML_NOERROR); + $result = Dom\HTMLDocument::createFromFile($uri, LIBXML_NOERROR); echo $result->getElementsByTagName("p")[0]->textContent, "\n"; } http_server_kill($pid); diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_override_encoding.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_override_encoding.phpt index ef1aca0f9f6f8..6b87f1d4714aa 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_override_encoding.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromFile_override_encoding.phpt @@ -1,29 +1,29 @@ --TEST-- -DOM\HTMLDocument::createFromFile() with overrideEncoding +Dom\HTMLDocument::createFromFile() with overrideEncoding --EXTENSIONS-- dom --FILE-- getMessage(), "\n"; } // The override encoding matches with the document encoding attribute -$dom = DOM\HTMLDocument::createFromFile(__DIR__ . '/gb18030_without_charset.html', overrideEncoding: 'GB18030'); +$dom = Dom\HTMLDocument::createFromFile(__DIR__ . '/gb18030_without_charset.html', overrideEncoding: 'GB18030'); var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->charset); // The override encoding mismatches with the document encoding attribute -$dom = DOM\HTMLDocument::createFromFile(__DIR__ . '/fallback_encoding.html', overrideEncoding: 'Windows-1252'); +$dom = Dom\HTMLDocument::createFromFile(__DIR__ . '/fallback_encoding.html', overrideEncoding: 'Windows-1252'); var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->charset); ?> --EXPECT-- -DOM\HTMLDocument::createFromFile(): Argument #3 ($overrideEncoding) must be a valid document encoding +Dom\HTMLDocument::createFromFile(): Argument #3 ($overrideEncoding) must be a valid document encoding string(20) " Héllo, world! " diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromString_override_encoding.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromString_override_encoding.phpt index d68e0131df9d8..75984d6acd975 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromString_override_encoding.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_createFromString_override_encoding.phpt @@ -1,29 +1,29 @@ --TEST-- -DOM\HTMLDocument::createFromString() with overrideEncoding +Dom\HTMLDocument::createFromString() with overrideEncoding --EXTENSIONS-- dom --FILE-- getMessage(), "\n"; } // The override encoding matches with the document encoding attribute -$dom = DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/gb18030_without_charset.html'), overrideEncoding: 'GB18030'); +$dom = Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/gb18030_without_charset.html'), overrideEncoding: 'GB18030'); var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->charset); // The override encoding mismatches with the document encoding attribute -$dom = DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/fallback_encoding.html'), overrideEncoding: 'Windows-1252'); +$dom = Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . '/fallback_encoding.html'), overrideEncoding: 'Windows-1252'); var_dump($dom->documentElement->lastChild->textContent); var_dump($dom->charset); ?> --EXPECT-- -DOM\HTMLDocument::createFromString(): Argument #3 ($overrideEncoding) must be a valid document encoding +Dom\HTMLDocument::createFromString(): Argument #3 ($overrideEncoding) must be a valid document encoding string(20) " Héllo, world! " diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_01.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_01.phpt index 13fbdc684b336..921b56901d4c4 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_01.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_01.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument edge case encoding 01 +Dom\HTMLDocument edge case encoding 01 --EXTENSIONS-- dom --FILE-- @@ -7,11 +7,11 @@ dom // UTF-8 -> UTF-8 // Create a UTF-8 string where a UTF-8 byte sequence falls over the boundary of the 4096 byte buffer -$dom = DOM\HTMLDocument::createEmpty(); +$dom = Dom\HTMLDocument::createEmpty(); $element = $dom->createElement("container"); $dom->append($element); $element->append(str_repeat("A", 4096 - 2 - strlen("")) . "\xf0\x90\x8d\x88AA"); -var_dump($dom->saveHTML()); +var_dump($dom->saveHtml()); ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_02.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_02.phpt index c8e9736533ad0..f23ef536fa059 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_02.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_02.phpt @@ -1,18 +1,18 @@ --TEST-- -DOM\HTMLDocument edge case encoding 02 +Dom\HTMLDocument edge case encoding 02 --EXTENSIONS-- dom --FILE-- GB18030 -$dom = DOM\HTMLDocument::createEmpty("GB18030"); +$dom = Dom\HTMLDocument::createEmpty("GB18030"); $element = $dom->createElement("container"); $dom->append($element); // Create a UTF-8 string where a UTF-8 byte sequence falls over the boundary of the 4096 byte buffer // *and* the sequence also falls over the boundary for the result $element->append(str_repeat("A", 4096 - 2 - strlen("")) . "\xf0\x90\x8d\x88AA"); -var_dump($output = $dom->saveHTML()); +var_dump($output = $dom->saveHtml()); // GB18030 encoding of the above UTF-8 symbol var_dump($output[4094] == "\x90"); diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_03.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_03.phpt index 5e66a0b0411cc..085cf92ef5546 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_03.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_03.phpt @@ -1,18 +1,18 @@ --TEST-- -DOM\HTMLDocument edge case encoding 03 +Dom\HTMLDocument edge case encoding 03 --EXTENSIONS-- dom --FILE-- GB18030 -$dom = DOM\HTMLDocument::createEmpty("GB18030"); +$dom = Dom\HTMLDocument::createEmpty("GB18030"); $element = $dom->createElement("container"); $dom->append($element); // Create a UTF-8 string where an invalid UTF-8 byte sequence falls over the boundary of the 4096 byte buffer // Note: the strange ?1?7 sequence is the GB18030 encoding for the unicode replacement character $element->append(str_repeat("A", 4096 - 2 - strlen("")) . "\xff\xff\xff"); -var_dump($dom->saveHTML()); +var_dump($dom->saveHtml()); ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_04.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_04.phpt index 1bde3303269b5..2f627d65f790f 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_04.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_04.phpt @@ -1,17 +1,17 @@ --TEST-- -DOM\HTMLDocument edge case encoding 04 +Dom\HTMLDocument edge case encoding 04 --EXTENSIONS-- dom --FILE-- UTF-8 -$dom = DOM\HTMLDocument::createEmpty(); +$dom = Dom\HTMLDocument::createEmpty(); $element = $dom->createElement("container"); $dom->append($element); // Create a UTF-8 string where an invalid UTF-8 byte sequence falls over the boundary of the 4096 byte buffer $element->append(str_repeat("A", 4096 - 2 - strlen("")) . "\xff\xff\xff"); -var_dump($dom->saveHTML()); +var_dump($dom->saveHtml()); ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_05.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_05.phpt index 0c44159c8b6ce..4f762ef4aa4fa 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_05.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_05.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument edge case encoding 05 +Dom\HTMLDocument edge case encoding 05 --EXTENSIONS-- dom --FILE-- @@ -9,11 +9,11 @@ dom $header = ""; $padding_required_until_4094 = 4094 - strlen($header); $trailer = "\x90\x30\xd5\x30"; -$dom = DOM\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4094) . $trailer); +$dom = Dom\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4094) . $trailer); // GB18030 byte sequence crossing the 4096 boundary var_dump($dom->charset); $dom->charset = "UTF-8"; -var_dump($dom->saveHTML()); +var_dump($dom->saveHtml()); ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_06.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_06.phpt index ea5962a1ae6a6..5ceb83a03ef02 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_06.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_06.phpt @@ -1,17 +1,17 @@ --TEST-- -DOM\HTMLDocument edge case encoding 06 +Dom\HTMLDocument edge case encoding 06 --EXTENSIONS-- dom --FILE-- UTF-8 -$dom = DOM\HTMLDocument::createEmpty(); +$dom = Dom\HTMLDocument::createEmpty(); $element = $dom->createElement("container"); $dom->append($element); // Create a UTF-8 string where a *broken* UTF-8 byte sequence falls over the boundary of the 4096 byte buffer $element->append(str_repeat("A", 4096 - 1 - strlen("")) . "\xf0\x90"); -var_dump($dom->saveHTML()); +var_dump($dom->saveHtml()); ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_07.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_07.phpt index 4f60cccaba155..15bf36a62fbc8 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_07.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_edge_case_07.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument edge case encoding 07 +Dom\HTMLDocument edge case encoding 07 --EXTENSIONS-- dom --FILE-- @@ -9,11 +9,11 @@ dom $header = ""; $padding_required_until_4095 = 4095 - strlen($header); $trailer = "\x90\x30"; -$dom = DOM\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4095) . $trailer); +$dom = Dom\HTMLDocument::createFromString($header . str_repeat("A", $padding_required_until_4095) . $trailer); // GB18030 *broken* byte sequence crossing the 4096 boundary var_dump($dom->charset); $dom->charset = "UTF-8"; -var_dump($dom->saveHTML()); +var_dump($dom->saveHtml()); ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_field_test.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_field_test.phpt index c5c5aec382d58..c4417d8041088 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_field_test.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_field_test.phpt @@ -1,11 +1,11 @@ --TEST-- -DOM\HTMLDocument test values for encoding field +Dom\HTMLDocument test values for encoding field --EXTENSIONS-- dom --FILE-- charset); $dom->inputEncoding = "CSeuckr"; var_dump($dom->characterSet); @@ -23,10 +23,10 @@ try { echo $e->getMessage(), "\n"; } var_dump($dom->inputEncoding); -echo $dom->saveHTML(); +echo $dom->saveHtml(); try { - $dom = DOM\HTMLDocument::createEmpty("bogus"); + $dom = Dom\HTMLDocument::createEmpty("bogus"); } catch (ValueError $e) { echo $e->getMessage(), "\n"; } @@ -40,4 +40,4 @@ string(6) "EUC-KR" string(12) "windows-1251" Invalid document encoding string(12) "windows-1251" -DOM\HTMLDocument::createEmpty(): Argument #1 ($encoding) must be a valid document encoding +Dom\HTMLDocument::createEmpty(): Argument #1 ($encoding) must be a valid document encoding diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_unicode_error.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_unicode_error.phpt index 7885f68ecf50b..0de3da6715970 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_unicode_error.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_encoding_unicode_error.phpt @@ -1,26 +1,26 @@ --TEST-- -DOM\HTMLDocument loading with unicode codepoints resulting in an error +Dom\HTMLDocument loading with unicode codepoints resulting in an error --EXTENSIONS-- dom --FILE-- --EXPECTF-- --- createFromFile --- -Warning: DOM\HTMLDocument::createFromFile(): tokenizer error missing-end-tag-name in %s on line %d +Warning: Dom\HTMLDocument::createFromFile(): tokenizer error missing-end-tag-name in %s on line %d -Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d +Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d -Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d +Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token in %s on line %d --- createFromString --- -Warning: DOM\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 29 in %s on line %d +Warning: Dom\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 29 in %s on line %d -Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 7, column: 14-17 in %s on line %d +Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 7, column: 14-17 in %s on line %d -Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 8, column: 7-10 in %s on line %d +Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token in Entity, line: 8, column: 7-10 in %s on line %d diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_fallback_encoding.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_fallback_encoding.phpt index f431b6cd31902..fda707577b5f5 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_fallback_encoding.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_fallback_encoding.phpt @@ -1,13 +1,13 @@ --TEST-- -DOM\HTMLDocument fallback encoding test +Dom\HTMLDocument fallback encoding test --EXTENSIONS-- dom --FILE-- inputEncoding); -echo $dom->saveHTML(); +echo $dom->saveHtml(); ?> --CLEAN-- diff --git a/ext/dom/tests/modern/html/encoding/HTMLDocument_override_encoding_incompatible_charset.phpt b/ext/dom/tests/modern/html/encoding/HTMLDocument_override_encoding_incompatible_charset.phpt index 737f6aca4285a..4f351d86d4d69 100644 --- a/ext/dom/tests/modern/html/encoding/HTMLDocument_override_encoding_incompatible_charset.phpt +++ b/ext/dom/tests/modern/html/encoding/HTMLDocument_override_encoding_incompatible_charset.phpt @@ -1,11 +1,11 @@ --TEST-- -DOM\HTMLDocument: overrideEncoding with incompatible charset +Dom\HTMLDocument: overrideEncoding with incompatible charset --EXTENSIONS-- iconv dom --FILE-- - äöü + ��� - äöü + ��� DOC, @@ -29,8 +29,8 @@ var_dump(iconv('UTF-8', 'ISO-8859-1', $doc->getElementsByTagName('title')->item( var_dump(iconv('UTF-8', 'ISO-8859-1', $doc->getElementsByTagName('body')->item(0)->textContent)); ?> --EXPECT-- -string(3) "äöü" -string(9) " - äöü +string(9) "���" +string(15) " + ��� " diff --git a/ext/dom/tests/modern/html/interactions/HTMLCollection_dimension_errors.phpt b/ext/dom/tests/modern/html/interactions/HTMLCollection_dimension_errors.phpt index e68d1ede3863c..571f94e4d3408 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLCollection_dimension_errors.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLCollection_dimension_errors.phpt @@ -5,7 +5,7 @@ dom --FILE-- '); +$dom = Dom\XMLDocument::createFromString(''); try { $dom->getElementsByTagName('root')[][1] = 1; @@ -27,6 +27,6 @@ try { ?> --EXPECT-- -Cannot append to DOM\HTMLCollection -Cannot access offset of type bool on DOM\HTMLCollection +Cannot append to Dom\HTMLCollection +Cannot access offset of type bool on Dom\HTMLCollection Cannot access offset of type bool in isset or empty diff --git a/ext/dom/tests/modern/html/interactions/HTMLCollection_named_reads.phpt b/ext/dom/tests/modern/html/interactions/HTMLCollection_named_reads.phpt index 82883e4ceec03..97caa7ac55471 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLCollection_named_reads.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLCollection_named_reads.phpt @@ -21,7 +21,7 @@ $xml = << XML; -$dom = DOM\XMLDocument::createFromString($xml); +$dom = Dom\XMLDocument::createFromString($xml); function test($obj, $name) { echo "--- Query \"$name\" ---\n"; diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_clone.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_clone.phpt index e5420d06b9727..7126c09553c43 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_clone.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_clone.phpt @@ -1,11 +1,11 @@ --TEST-- -Cloning a DOM\HTMLDocument +Cloning a Dom\HTMLDocument --EXTENSIONS-- dom --FILE-- foo

"); +$dom = Dom\HTMLDocument::createFromString("

foo

"); $dom2 = clone $dom; var_dump($dom2->firstChild->tagName); @@ -17,7 +17,7 @@ var_dump(get_class($element->ownerDocument)); ?> --EXPECTF-- -Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2 in %s on line %d +Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2 in %s on line %d string(4) "HTML" string(3) "foo" -string(16) "DOM\HTMLDocument" +string(16) "Dom\HTMLDocument" diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_documentURI.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_documentURI.phpt index a24ebb7bf3416..76375afe129c8 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_documentURI.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_documentURI.phpt @@ -1,17 +1,17 @@ --TEST-- -DOM\HTMLDocument::documentURI +Dom\HTMLDocument::documentURI --EXTENSIONS-- dom --FILE-- documentURI); $memory = fopen("php://memory", "w+"); fwrite($memory, "foobar"); rewind($memory); -$dom = DOM\HTMLDocument::createFromFile("php://memory"); +$dom = Dom\HTMLDocument::createFromFile("php://memory"); var_dump($dom->documentURI); fclose($memory); @@ -37,7 +37,7 @@ class DummyWrapper { stream_wrapper_register("dummy", DummyWrapper::class); -$dom = DOM\HTMLDocument::createFromFile("dummy://foo/ bar"); +$dom = Dom\HTMLDocument::createFromFile("dummy://foo/ bar"); var_dump($dom->documentURI); ?> diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_getElementsByTagName.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_getElementsByTagName.phpt index 19759c95677ed..1c90d5a338141 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_getElementsByTagName.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_getElementsByTagName.phpt @@ -1,11 +1,11 @@ --TEST-- -Test DOM\HTMLDocument::getElementsByTagName(NS) +Test Dom\HTMLDocument::getElementsByTagName(NS) --EXTENSIONS-- dom --FILE-- diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_01.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_01.phpt index 6ae7589270b73..91604c5fab827 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_01.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_01.phpt @@ -1,17 +1,17 @@ --TEST-- -DOM\HTMLDocument::registerNodeClass 01 +Dom\HTMLDocument::registerNodeClass 01 --EXTENSIONS-- dom --FILE-- registerNodeClass("DOM\\HTMLDocument", "DOMDocument"); +$dom->registerNodeClass("Dom\\HTMLDocument", "DOMDocument"); ?> --EXPECTF-- -Fatal error: Uncaught TypeError: DOMDocument::registerNodeClass(): Argument #1 ($baseClass) must be a class name derived from DOMNode, DOM\HTMLDocument given in %s:%d +Fatal error: Uncaught TypeError: DOMDocument::registerNodeClass(): Argument #1 ($baseClass) must be a class name derived from DOMNode, Dom\HTMLDocument given in %s:%d Stack trace: -#0 %s(%d): DOMDocument->registerNodeClass('DOM\\HTMLDocumen...', 'DOMDocument') +#0 %s(%d): DOMDocument->registerNodeClass('Dom\\HTMLDocumen...', 'DOMDocument') #1 {main} thrown in %s on line %d diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_02.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_02.phpt index 3eb1f0cae8af1..70be58a906bae 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_02.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_02.phpt @@ -1,18 +1,18 @@ --TEST-- -DOM\HTMLDocument::registerNodeClass 02 +Dom\HTMLDocument::registerNodeClass 02 --EXTENSIONS-- dom --FILE-- registerNodeClass("DOM\\Document", "Custom"); + $dom->registerNodeClass("Dom\\Document", "Custom"); } catch (ValueError $e) { echo $e->getMessage(), "\n"; } @@ -27,10 +27,10 @@ $element->ownerDocument->foo(); ?> --EXPECTF-- -DOM\Document::registerNodeClass(): Argument #1 ($baseClass) must not be an abstract class -string(16) "DOM\HTMLDocument" +Dom\Document::registerNodeClass(): Argument #1 ($baseClass) must not be an abstract class +string(16) "Dom\HTMLDocument" -Fatal error: Uncaught Error: Call to undefined method DOM\HTMLDocument::foo() in %s:%d +Fatal error: Uncaught Error: Call to undefined method Dom\HTMLDocument::foo() in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_03.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_03.phpt index 859212a086708..7a4d2d32797dc 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_03.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_registerNodeClass_03.phpt @@ -1,11 +1,11 @@ --TEST-- -DOM\HTMLDocument::registerNodeClass 03 +Dom\HTMLDocument::registerNodeClass 03 --EXTENSIONS-- dom --FILE-- foo", LIBXML_NOERROR); -$dom->registerNodeClass("DOM\\Element", "Custom"); +$dom = Dom\HTMLDocument::createFromString("
foo
", LIBXML_NOERROR); +$dom->registerNodeClass("Dom\\Element", "Custom"); var_dump($dom->getElementsByTagName('div')[0]->reverseTagName()); diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTMLFile_empty_path.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTMLFile_empty_path.phpt index 02514e54e07e1..93daf65f72f22 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTMLFile_empty_path.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTMLFile_empty_path.phpt @@ -1,18 +1,18 @@ --TEST-- -DOM\HTMLDocument::saveHTMLFile() empty path +Dom\HTMLDocument::saveHtmlFile() empty path --EXTENSIONS-- dom --FILE-- appendChild($dom->createElement("root")); -$dom->saveHTMLFile(""); +$dom->saveHtmlFile(""); ?> --EXPECTF-- -Fatal error: Uncaught ValueError: DOM\HTMLDocument::saveHTMLFile(): Argument #1 ($filename) must not be empty in %s:%d +Fatal error: Uncaught ValueError: Dom\HTMLDocument::saveHtmlFile(): Argument #1 ($filename) must not be empty in %s:%d Stack trace: -#0 %s(%d): DOM\HTMLDocument->saveHTMLFile('') +#0 %s(%d): Dom\HTMLDocument->saveHtmlFile('') #1 {main} thrown in %s on line %d diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTML_wrong_document.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTML_wrong_document.phpt index d2356068b4ece..7358f8b440bf0 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTML_wrong_document.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_saveHTML_wrong_document.phpt @@ -1,17 +1,17 @@ --TEST-- -DOM\HTMLDocument::saveHTML() wrong document +Dom\HTMLDocument::saveHtml() wrong document --EXTENSIONS-- dom --FILE-- saveHTML(DOM\HTMLDocument::createEmpty()); +$dom = Dom\HTMLDocument::createEmpty(); +$dom->saveHtml(Dom\HTMLDocument::createEmpty()); ?> --EXPECTF-- Fatal error: Uncaught DOMException: Wrong Document Error in %s:%d Stack trace: -#0 %s(%d): DOM\HTMLDocument->saveHTML(Object(DOM\HTMLDocument)) +#0 %s(%d): Dom\HTMLDocument->saveHtml(Object(Dom\HTMLDocument)) #1 {main} thrown in %s on line %d diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_01.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_01.phpt index 08e70cfa43019..2931aebab28f5 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_01.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_01.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument should retain properties and ownerDocument relation 01 +Dom\HTMLDocument should retain properties and ownerDocument relation 01 --EXTENSIONS-- dom --FILE-- foo

", LIBXML_NOERROR); -$dom->registerNodeClass("DOM\\Element", "MyElement"); +$dom = Dom\HTMLDocument::createFromString("

foo

", LIBXML_NOERROR); +$dom->registerNodeClass("Dom\\Element", "MyElement"); // Destroy reference to the DOM $child = $dom->documentElement; unset($dom); // Regain reference using the ownerDocument property -// Should be a DOM\HTMLDocument +// Should be a Dom\HTMLDocument $dom = $child->ownerDocument; var_dump($dom); // Test if property is preserved (any random doc_props property will do) @@ -23,7 +23,7 @@ var_dump(get_class($dom->getElementsByTagName("p")->item(0))); ?> --EXPECT-- -object(DOM\HTMLDocument)#1 (25) { +object(Dom\HTMLDocument)#1 (25) { ["implementation"]=> string(22) "(object value omitted)" ["URL"]=> diff --git a/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_02.phpt b/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_02.phpt index 379a3da4b2fa1..c356cf7ba9215 100644 --- a/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_02.phpt +++ b/ext/dom/tests/modern/html/interactions/HTMLDocument_should_retain_properties_and_owner_02.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument should retain properties and ownerDocument relation 02 +Dom\HTMLDocument should retain properties and ownerDocument relation 02 --EXTENSIONS-- dom --FILE-- foo

", LIBXML_NOERROR); -$dom->registerNodeClass("DOM\\Element", "MyElement"); +$dom = Dom\HTMLDocument::createFromString("

foo

", LIBXML_NOERROR); +$dom->registerNodeClass("Dom\\Element", "MyElement"); $child = $dom->documentElement->appendChild($dom->createElement('html')); // Destroy reference to the DOM unset($dom); // Regain reference using the ownerDocument property -// Should be a DOM\HTMLDocument +// Should be a Dom\HTMLDocument $dom = $child->ownerDocument; var_dump($dom); // Test if property is preserved (any random doc_props property will do) @@ -23,7 +23,7 @@ var_dump(get_class($dom->getElementsByTagName("p")->item(0))); ?> --EXPECT-- -object(DOM\HTMLDocument)#1 (25) { +object(Dom\HTMLDocument)#1 (25) { ["implementation"]=> string(22) "(object value omitted)" ["URL"]=> diff --git a/ext/dom/tests/modern/html/interactions/getLineNo_65536.phpt b/ext/dom/tests/modern/html/interactions/getLineNo_65536.phpt index 122bcc8aaaaef..5ab1a3293c1f5 100644 --- a/ext/dom/tests/modern/html/interactions/getLineNo_65536.phpt +++ b/ext/dom/tests/modern/html/interactions/getLineNo_65536.phpt @@ -12,7 +12,7 @@ $html = str_repeat("\n", 65536) . << EOF; -$dom = DOM\HTMLDocument::createFromString($html); +$dom = Dom\HTMLDocument::createFromString($html); var_dump($dom->documentElement->firstChild->nextSibling->firstChild->nextSibling->getLineNo()); ?> diff --git a/ext/dom/tests/modern/html/interactions/noscript.phpt b/ext/dom/tests/modern/html/interactions/noscript.phpt index d93dae79c650f..2dec9ce9b1bc0 100644 --- a/ext/dom/tests/modern/html/interactions/noscript.phpt +++ b/ext/dom/tests/modern/html/interactions/noscript.phpt @@ -7,25 +7,25 @@ dom echo "--- Parsing ---\n"; -$dom = DOM\HTMLDocument::createFromString("", DOM\HTML_NO_DEFAULT_NS); +$dom = Dom\HTMLDocument::createFromString("", Dom\HTML_NO_DEFAULT_NS); var_dump($dom->documentElement->textContent); var_dump($dom->documentElement->namespaceURI); -echo $dom->saveHTML(), "\n"; -echo $dom->saveXML(), "\n"; +echo $dom->saveHtml(), "\n"; +echo $dom->saveXml(), "\n"; echo "--- Modifying the text content: tag ---\n"; -$xpath = new DOM\XPath($dom); +$xpath = new Dom\XPath($dom); $noscript = $xpath->query("//noscript")[0]; $noscript->textContent = "

bye

"; -echo $dom->saveHTML(), "\n"; -echo $dom->saveXML(), "\n"; +echo $dom->saveHtml(), "\n"; +echo $dom->saveXml(), "\n"; echo "--- Modifying the text content: trick ---\n"; $noscript->textContent = ""; -echo $dom->saveHTML(), "\n"; -echo $dom->saveXML(), "\n"; +echo $dom->saveHtml(), "\n"; +echo $dom->saveXml(), "\n"; ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/interactions/without_constructor.phpt b/ext/dom/tests/modern/html/interactions/without_constructor.phpt index 606ebfb8b286f..96cd131b0391e 100644 --- a/ext/dom/tests/modern/html/interactions/without_constructor.phpt +++ b/ext/dom/tests/modern/html/interactions/without_constructor.phpt @@ -5,7 +5,7 @@ dom --FILE-- newInstanceWithoutConstructor(); @@ -16,5 +16,5 @@ foreach (['DOM\HTMLDocument', 'DOM\XMLDocument'] as $class) { ?> --EXPECT-- -Class DOM\HTMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor -Class DOM\XMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor +Class Dom\HTMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor +Class Dom\XMLDocument is an internal class marked as final that cannot be instantiated without invoking its constructor diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_createFromFile_createFromString_BOM_buffer_edge.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_createFromFile_createFromString_BOM_buffer_edge.phpt index b666167d2b4de..7240229721b0a 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_createFromFile_createFromString_BOM_buffer_edge.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_createFromFile_createFromString_BOM_buffer_edge.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument::createFromFile()/createFromString() BOM with a buffer on the edge +Dom\HTMLDocument::createFromFile()/createFromString() BOM with a buffer on the edge --EXTENSIONS-- dom --FILE-- @@ -9,13 +9,13 @@ $header = "\xEF\xBB\xBF"; $trailer = ""; $data = $header . str_repeat("a", 4096 - strlen($header) - strlen($trailer)) . $trailer; -$dom = DOM\HTMLDocument::createFromString($header . str_repeat("a", 4096 - strlen($header) - strlen($trailer)) . $trailer); +$dom = Dom\HTMLDocument::createFromString($header . str_repeat("a", 4096 - strlen($header) - strlen($trailer)) . $trailer); var_dump($dom->documentElement->textContent); -echo $dom->saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; file_put_contents(__DIR__ . "/BOM_edge.tmp", $data); -$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/BOM_edge.tmp"); +$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/BOM_edge.tmp"); var_dump($dom->documentElement->textContent); ?> diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_createFromString_namespaced_attributes.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_createFromString_namespaced_attributes.phpt index 7562e14beb1ab..4a4add549e17f 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_createFromString_namespaced_attributes.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_createFromString_namespaced_attributes.phpt @@ -5,7 +5,7 @@ dom --FILE-- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_DOM_HTML_NO_DEFAULT_NS.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_DOM_HTML_NO_DEFAULT_NS.phpt index 4b370b417dd5e..8c5a32f342c82 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_DOM_HTML_NO_DEFAULT_NS.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_DOM_HTML_NO_DEFAULT_NS.phpt @@ -1,37 +1,37 @@ --TEST-- -DOM\HTMLDocument::createFromFile() with DOM\HTML_NO_DEFAULT_NS +Dom\HTMLDocument::createFromFile() with Dom\HTML_NO_DEFAULT_NS --EXTENSIONS-- dom --FILE-- registerNamespace("x", "http://www.w3.org/1999/xhtml"); var_dump($xpath->query("//p")); var_dump($xpath->query("//x:p")); -$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/paragraph.html", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | DOM\HTML_NO_DEFAULT_NS); -$xpath = new DOM\XPath($dom); +$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/paragraph.html", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | Dom\HTML_NO_DEFAULT_NS); +$xpath = new Dom\XPath($dom); $xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml"); var_dump($xpath->query("//p")); var_dump($xpath->query("//x:p")); ?> --EXPECT-- -object(DOM\NodeList)#3 (1) { +object(Dom\NodeList)#3 (1) { ["length"]=> int(0) } -object(DOM\NodeList)#4 (1) { +object(Dom\NodeList)#4 (1) { ["length"]=> int(1) } -object(DOM\NodeList)#3 (1) { +object(Dom\NodeList)#3 (1) { ["length"]=> int(1) } -object(DOM\NodeList)#3 (1) { +object(Dom\NodeList)#3 (1) { ["length"]=> int(0) } diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_empty_path.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_empty_path.phpt index 73e55c1f09aac..96b054168a2dc 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_empty_path.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_empty_path.phpt @@ -1,16 +1,16 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - empty path +Dom\HTMLDocument::createFromFile() - empty path --EXTENSIONS-- dom --FILE-- --EXPECTF-- Fatal error: Uncaught ValueError: Path cannot be empty in %s:%d Stack trace: -#0 %s(%d): DOM\HTMLDocument::createFromFile('') +#0 %s(%d): Dom\HTMLDocument::createFromFile('') #1 {main} thrown in %s on line %d diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_existing_file.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_existing_file.phpt index 0e9e2b60e2bc7..96cdda681505d 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_existing_file.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_existing_file.phpt @@ -1,16 +1,16 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - local existing file +Dom\HTMLDocument::createFromFile() - local existing file --EXTENSIONS-- dom --FILE-- saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/../../../test.html"); +echo $dom->saveHtml(), "\n"; ?> --EXPECTF-- -Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in %s on line %d +Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in %s on line %d Hello world diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_file_does_not_exist.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_file_does_not_exist.phpt index 8bb91cf8ee7b6..ce96afd69eb38 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_file_does_not_exist.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_local_file_does_not_exist.phpt @@ -1,19 +1,19 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - local file that does not exist +Dom\HTMLDocument::createFromFile() - local file that does not exist --EXTENSIONS-- dom --FILE-- saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/../foobar"); +echo $dom->saveHtml(), "\n"; ?> --EXPECTF-- -Warning: DOM\HTMLDocument::createFromFile(%s): Failed to open stream: No such file or directory in %s on line %d +Warning: Dom\HTMLDocument::createFromFile(%s): Failed to open stream: No such file or directory in %s on line %d Fatal error: Uncaught Exception: Cannot open file '%s' in %s:%d Stack trace: -#0 %s(%d): DOM\HTMLDocument::createFromFile('%s') +#0 %s(%d): Dom\HTMLDocument::createFromFile('%s') #1 {main} thrown in %s on line %d diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_nul_terminator_cases_path.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_nul_terminator_cases_path.phpt index 6e79c2f12a941..37cf161ec0459 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_nul_terminator_cases_path.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_nul_terminator_cases_path.phpt @@ -1,22 +1,22 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - NUL terminator cases path +Dom\HTMLDocument::createFromFile() - NUL terminator cases path --EXTENSIONS-- dom --FILE-- getMessage(), "\n"; } try { - DOM\HTMLDocument::createFromFile('%00'); + Dom\HTMLDocument::createFromFile('%00'); } catch (ValueError $e) { echo $e->getMessage(), "\n"; } ?> --EXPECT-- -DOM\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain any null bytes -DOM\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain percent-encoded NUL bytes +Dom\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain any null bytes +Dom\HTMLDocument::createFromFile(): Argument #1 ($path) must not contain percent-encoded NUL bytes diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_01.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_01.phpt index 9c77ebeadd4d0..4940bcb1d553a 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_01.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_01.phpt @@ -1,12 +1,12 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - parser warning 01 +Dom\HTMLDocument::createFromFile() - parser warning 01 --EXTENSIONS-- dom --FILE-- saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_01.html", LIBXML_NOERROR); +echo $dom->saveHtml(), "\n"; ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_02.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_02.phpt index 9d3dd944e7ba5..976856d428056 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_02.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_02.phpt @@ -1,12 +1,12 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - parser warning 02 +Dom\HTMLDocument::createFromFile() - parser warning 02 --EXTENSIONS-- dom --FILE-- saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_02.html", LIBXML_NOERROR); +echo $dom->saveHtml(), "\n"; ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_03.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_03.phpt index f5cada6c18f22..5562fedc4e7c9 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_03.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_03.phpt @@ -1,12 +1,12 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - parser warning 03 +Dom\HTMLDocument::createFromFile() - parser warning 03 --EXTENSIONS-- dom --FILE-- saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_03.html", LIBXML_NOERROR); +echo $dom->saveHtml(), "\n"; ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_libxml_get_last_error.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_libxml_get_last_error.phpt index 3de37d94890ba..4cca3daad1a6e 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_libxml_get_last_error.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_parser_warning_libxml_get_last_error.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument::createFromFile() - parser warning libxml_get_last_error() +Dom\HTMLDocument::createFromFile() - parser warning libxml_get_last_error() --EXTENSIONS-- dom --FILE-- @@ -8,7 +8,7 @@ dom libxml_use_internal_errors(true); $html = '<>x '; -$dom = DOM\HTMLDocument::createFromFile(__DIR__."/parser_warning_01.html"); +$dom = Dom\HTMLDocument::createFromFile(__DIR__."/parser_warning_01.html"); var_dump(libxml_get_last_error()); diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_failing_stream_wrapper.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_failing_stream_wrapper.phpt index 78e07b72bbef4..c31541d657bb4 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_failing_stream_wrapper.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_failing_stream_wrapper.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument::createFromFile() with failing stream wrapper +Dom\HTMLDocument::createFromFile() with failing stream wrapper --EXTENSIONS-- dom --FILE-- @@ -32,13 +32,13 @@ class FailingWrapper { stream_wrapper_register("fail", FailingWrapper::class, 0); -DOM\HTMLDocument::createFromFile("fail://x"); +Dom\HTMLDocument::createFromFile("fail://x"); ?> --EXPECTF-- Fatal error: Uncaught Error: fail in %s:%d Stack trace: #0 [internal function]: FailingWrapper->stream_read(8192) -#1 %s(%d): DOM\HTMLDocument::createFromFile('fail://x') +#1 %s(%d): Dom\HTMLDocument::createFromFile('fail://x') #2 {main} thrown in %s on line %d diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_working_stream_wrapper.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_working_stream_wrapper.phpt index e2e24fdba2727..b763e91336115 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_working_stream_wrapper.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromFile_with_working_stream_wrapper.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument::createFromFile() with working stream wrapper +Dom\HTMLDocument::createFromFile() with working stream wrapper --EXTENSIONS-- dom --FILE-- @@ -34,15 +34,15 @@ stream_wrapper_register("euw", EchoUriWrapper::class, 0); echo "--- Stream wrapper case ---\n"; -$dom = DOM\HTMLDocument::createFromFile("euw://

hello

"); -echo $dom->saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromFile("euw://

hello

"); +echo $dom->saveHtml(), "\n"; echo "--- Stream wrapper in two chunks case ---\n"; libxml_use_internal_errors(true); // To properly test this, keep the 4096 in sync with document.c's input stream buffer size. -$dom = DOM\HTMLDocument::createFromFile("euw://" . str_repeat("\n", 4096-22) . "<>"); -echo $dom->saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromFile("euw://" . str_repeat("\n", 4096-22) . "<>"); +echo $dom->saveHtml(), "\n"; foreach (libxml_get_errors() as $error) { var_dump($error->line, $error->column); @@ -52,7 +52,7 @@ foreach (libxml_get_errors() as $error) { --EXPECTF-- --- Stream wrapper case --- -Warning: DOM\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in euw://

hello

, line: 1, column: 2 in %s on line %d +Warning: Dom\HTMLDocument::createFromFile(): tree error unexpected-token-in-initial-mode in euw://

hello

, line: 1, column: 2 in %s on line %d

hello

--- Stream wrapper in two chunks case --- <> diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_DOM_HTML_NO_DEFAULT_NS.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_DOM_HTML_NO_DEFAULT_NS.phpt index 102f4df84c3e2..bf18ffd1d021e 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_DOM_HTML_NO_DEFAULT_NS.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_DOM_HTML_NO_DEFAULT_NS.phpt @@ -1,37 +1,37 @@ --TEST-- -DOM\HTMLDocument::createFromString() with DOM\HTML_NO_DEFAULT_NS +Dom\HTMLDocument::createFromString() with Dom\HTML_NO_DEFAULT_NS --EXTENSIONS-- dom --FILE-- registerNamespace("x", "http://www.w3.org/1999/xhtml"); var_dump($xpath->query("//p")); var_dump($xpath->query("//x:p")); -$dom = DOM\HTMLDocument::createFromString(file_get_contents(__DIR__ . "/paragraph.html"), LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | DOM\HTML_NO_DEFAULT_NS); -$xpath = new DOM\XPath($dom); +$dom = Dom\HTMLDocument::createFromString(file_get_contents(__DIR__ . "/paragraph.html"), LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR | Dom\HTML_NO_DEFAULT_NS); +$xpath = new Dom\XPath($dom); $xpath->registerNamespace("x", "http://www.w3.org/1999/xhtml"); var_dump($xpath->query("//p")); var_dump($xpath->query("//x:p")); ?> --EXPECT-- -object(DOM\NodeList)#3 (1) { +object(Dom\NodeList)#3 (1) { ["length"]=> int(0) } -object(DOM\NodeList)#4 (1) { +object(Dom\NodeList)#4 (1) { ["length"]=> int(1) } -object(DOM\NodeList)#3 (1) { +object(Dom\NodeList)#3 (1) { ["length"]=> int(1) } -object(DOM\NodeList)#3 (1) { +object(Dom\NodeList)#3 (1) { ["length"]=> int(0) } diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_COMPACT.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_COMPACT.phpt index c702c48ba3f64..ec77fd141dfa3 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_COMPACT.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_COMPACT.phpt @@ -1,11 +1,11 @@ --TEST-- -DOM\HTMLDocument::createFromString() with LIBXML_COMPACT +Dom\HTMLDocument::createFromString() with LIBXML_COMPACT --EXTENSIONS-- dom --FILE-- @@ -23,7 +23,7 @@ $dom = DOM\HTMLDocument::createFromString(<< HTML, LIBXML_COMPACT); -$xpath = new DOM\XPath($dom); +$xpath = new Dom\XPath($dom); foreach ($xpath->query("//*[name()='p']") as $p) { echo $p->textContent, "\n"; } diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_error.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_error.phpt index 26f322f7127e1..60e1274e9e0db 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_error.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_error.phpt @@ -1,12 +1,12 @@ --TEST-- -DOM\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED - tree error should not happen +Dom\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED - tree error should not happen --EXTENSIONS-- dom --FILE-- foo", LIBXML_HTML_NOIMPLIED); -echo $dom->saveHTML(); +$dom = Dom\HTMLDocument::createFromString("
foo
", LIBXML_HTML_NOIMPLIED); +echo $dom->saveHtml(); ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_namespace.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_namespace.phpt index fde8f40b90b0a..7f802fbe8643a 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_namespace.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_LIBXML_HTML_NOIMPLIED_namespace.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED namespace check +Dom\HTMLDocument::createFromString() with LIBXML_HTML_NOIMPLIED namespace check --EXTENSIONS-- dom --FILE-- @@ -7,20 +7,20 @@ dom echo "--- No elements ---\n"; -$dom = DOM\HTMLDocument::createFromString("", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); -echo $dom->saveXML(), "\n"; +$dom = Dom\HTMLDocument::createFromString("", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); +echo $dom->saveXml(), "\n"; echo "--- Single element ---\n"; -$dom = DOM\HTMLDocument::createFromString("

foo

", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); -echo $dom->saveXML(), "\n"; +$dom = Dom\HTMLDocument::createFromString("

foo

", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); +echo $dom->saveXml(), "\n"; var_dump($dom->documentElement->namespaceURI); var_dump($dom->documentElement->prefix); echo "--- Multiple elements ---\n"; -$dom = DOM\HTMLDocument::createFromString("

foo

bar", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); -echo $dom->saveXML(), "\n"; +$dom = Dom\HTMLDocument::createFromString("

foo

bar", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); +echo $dom->saveXml(), "\n"; var_dump($dom->documentElement->namespaceURI); var_dump($dom->documentElement->prefix); var_dump($dom->documentElement->nextSibling->namespaceURI); diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_empty.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_empty.phpt index 898ae43fabb24..ea4ca53ef8bbb 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_empty.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_empty.phpt @@ -1,12 +1,12 @@ --TEST-- -DOM\HTMLDocument::createFromString() - empty document +Dom\HTMLDocument::createFromString() - empty document --EXTENSIONS-- dom --FILE-- saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromString(''); +echo $dom->saveHtml(), "\n"; ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_fromFile_LIBXML_HTML_NOIMPLIED.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_fromFile_LIBXML_HTML_NOIMPLIED.phpt index 3e26fc35b950f..8126d15e15611 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_fromFile_LIBXML_HTML_NOIMPLIED.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_fromFile_LIBXML_HTML_NOIMPLIED.phpt @@ -1,21 +1,21 @@ --TEST-- -DOM\HTMLDocument::createFromString()/createFromFile() with LIBXML_HTML_NOIMPLIED +Dom\HTMLDocument::createFromString()/createFromFile() with LIBXML_HTML_NOIMPLIED --EXTENSIONS-- dom --FILE-- saveHTML(); + $dom = Dom\HTMLDocument::createFromString($html, LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); + $output = $dom->saveHtml(); echo $output, "\n"; // Also test the loadHTMLFile variation. We won't print out the result, just checking the result is the same. $temp = fopen(__DIR__."/DOM_HTMLDocument_loadHTML_LIBXML_HTML_NOIMPLIED_input.tmp", "w"); fwrite($temp, $html); fclose($temp); - $dom = DOM\HTMLDocument::createFromFile(__DIR__."/DOM_HTMLDocument_loadHTML_LIBXML_HTML_NOIMPLIED_input.tmp", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); - var_dump($output === $dom->saveHTML()); + $dom = Dom\HTMLDocument::createFromFile(__DIR__."/DOM_HTMLDocument_loadHTML_LIBXML_HTML_NOIMPLIED_input.tmp", LIBXML_HTML_NOIMPLIED | LIBXML_NOERROR); + var_dump($output === $dom->saveHtml()); } echo "--- Missing html, head, body ---\n"; diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_line_column.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_line_column.phpt index 2d1ecab2cb1a2..8451be111a1f5 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_line_column.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_line_column.phpt @@ -1,11 +1,11 @@ --TEST-- -DOM\HTMLDocument::createFromString() - line and column test +Dom\HTMLDocument::createFromString() - line and column test --EXTENSIONS-- dom --FILE-- @@ -22,7 +22,7 @@ $dom = DOM\HTMLDocument::createFromString(<< HTML); -$xpath = new DOM\XPath($dom); +$xpath = new Dom\XPath($dom); foreach ($xpath->query("//*") as $element) { echo "Element: '", $element->tagName, "', ", $element->getLineNo(), "\n"; diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_normal_no_error.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_normal_no_error.phpt index b4a778a68d3ea..dfb1202e0b4b8 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_normal_no_error.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_normal_no_error.phpt @@ -1,5 +1,5 @@ --TEST-- -DOM\HTMLDocument::createFromString() - normal document, no error +Dom\HTMLDocument::createFromString() - normal document, no error --EXTENSIONS-- dom --FILE-- @@ -21,8 +21,8 @@ $html = << HTML; -$dom = DOM\HTMLDocument::createFromString($html); -echo $dom->saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromString($html); +echo $dom->saveHtml(), "\n"; ?> --EXPECT-- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_old_dtd.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_old_dtd.phpt index f140b8b1f349b..24fa6d599431d 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_old_dtd.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_old_dtd.phpt @@ -1,11 +1,11 @@ --TEST-- -DOM\HTMLDocument::createFromString(): Old DTD +Dom\HTMLDocument::createFromString(): Old DTD --EXTENSIONS-- dom --FILE-- @@ -16,13 +16,13 @@ $dom = DOM\HTMLDocument::createFromString(<<saveHTML(), "\n"; +echo $dom->saveHtml(), "\n"; echo "--- XML serialization ---\n"; -echo $dom->saveXML(); +echo $dom->saveXml(); ?> --EXPECTF-- -Warning: DOM\HTMLDocument::createFromString(): tree error bad-doctype-token-in-initial-mode in Entity, line: 1, column: 3-9 in %s on line %d +Warning: Dom\HTMLDocument::createFromString(): tree error bad-doctype-token-in-initial-mode in Entity, line: 1, column: 3-9 in %s on line %d --- HTML serialization --- diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_01.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_01.phpt index 4469ee890ee7d..0d00e879c06a9 100644 --- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_01.phpt +++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_01.phpt @@ -1,19 +1,19 @@ --TEST-- -DOM\HTMLDocument::createFromString() - parser warning 01 +Dom\HTMLDocument::createFromString() - parser warning 01 --EXTENSIONS-- dom --FILE-- saveHTML(), "\n"; +$dom = Dom\HTMLDocument::createFromString($html); +echo $dom->saveHtml(), "\n"; ?> --EXPECTF-- -Warning: DOM\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 11 in %s on line %d +Warning: Dom\HTMLDocument::createFromString(): tokenizer error missing-end-tag-name in Entity, line: 7, column: 11 in %s on line %d -Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-6 in %s on line %d +Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-6 in %s on line %d foo