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 ===
+
+value value2
+value2
+
+value value2
+value2
+=== serialize DOM ===
+
+value value2
+
+=== serialize imported DOM ===
+
+value value2
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("hi
", DOM\HTML_NO_DEFAULT_NS);
+$dom = Dom\HTMLDocument::createFromString("hi
", 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
diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_02.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_02.phpt
index 08abc826af8df..7da88cae6ceb5 100644
--- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_02.phpt
+++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_02.phpt
@@ -1,27 +1,27 @@
--TEST--
-DOM\HTMLDocument::createFromString() - parser warning 02
+Dom\HTMLDocument::createFromString() - parser warning 02
--EXTENSIONS--
dom
--FILE--
saveHTML(), "\n";
+$dom = Dom\HTMLDocument::createFromString($html);
+echo $dom->saveHtml(), "\n";
?>
--EXPECTF--
-Warning: DOM\HTMLDocument::createFromString(): tokenizer error unexpected-null-character in Entity, line: 4, column: 11 in %s on line %d
+Warning: Dom\HTMLDocument::createFromString(): tokenizer error unexpected-null-character in Entity, line: 4, column: 11 in %s on line %d
-Warning: DOM\HTMLDocument::createFromString(): tokenizer error missing-whitespace-between-attributes in Entity, line: 5, column: 20 in %s on line %d
+Warning: Dom\HTMLDocument::createFromString(): tokenizer error missing-whitespace-between-attributes in Entity, line: 5, column: 20 in %s on line %d
-Warning: DOM\HTMLDocument::createFromString(): tokenizer error incorrectly-opened-comment in Entity, line: 6, column: 11 in %s on line %d
+Warning: Dom\HTMLDocument::createFromString(): tokenizer error incorrectly-opened-comment in Entity, line: 6, column: 11 in %s on line %d
-Warning: DOM\HTMLDocument::createFromString(): tokenizer error nested-comment in Entity, line: 7, column: 18 in %s on line %d
+Warning: Dom\HTMLDocument::createFromString(): tokenizer error nested-comment in Entity, line: 7, column: 18 in %s on line %d
-Warning: DOM\HTMLDocument::createFromString(): tree error unexpected-closed-token in Entity, line: 4, column: 18 in %s on line %d
+Warning: Dom\HTMLDocument::createFromString(): tree error unexpected-closed-token in Entity, line: 4, column: 18 in %s on line %d
-Warning: DOM\HTMLDocument::createFromString(): tree error doctype-token-in-body-mode in Entity, line: 8, column: 11-17 in %s on line %d
+Warning: Dom\HTMLDocument::createFromString(): tree error doctype-token-in-body-mode in Entity, line: 8, column: 11-17 in %s on line %d
foo
diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_03.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_03.phpt
index 2de4b36e2ef42..496bbd9ad67f4 100644
--- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_03.phpt
+++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_03.phpt
@@ -1,13 +1,13 @@
--TEST--
-DOM\HTMLDocument::createFromString() - parser warning 03
+Dom\HTMLDocument::createFromString() - parser warning 03
--EXTENSIONS--
dom
--FILE--
saveHTML(), "\n";
+$dom = Dom\HTMLDocument::createFromString($html, LIBXML_NOERROR);
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_internal_error.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_internal_error.phpt
index 44dac9eb53923..84ac73e2860d4 100644
--- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_internal_error.phpt
+++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_parser_warning_internal_error.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\HTMLDocument::createFromString() - parser warning via internal error
+Dom\HTMLDocument::createFromString() - parser warning via internal error
--EXTENSIONS--
dom
--FILE--
@@ -8,7 +8,7 @@ dom
libxml_use_internal_errors(true);
$html = '<>x> ';
-$dom = DOM\HTMLDocument::createFromString($html);
+$dom = Dom\HTMLDocument::createFromString($html);
foreach (libxml_get_errors() as $error) {
var_dump($error->message, $error->line, $error->column);
}
diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_without_body.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_without_body.phpt
index 047c18640849f..fd5a2366cca93 100644
--- a/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_without_body.phpt
+++ b/ext/dom/tests/modern/html/parser/HTMLDocument_fromString_without_body.phpt
@@ -1,12 +1,12 @@
--TEST--
-DOM\HTMLDocument::createFromString() - document without body
+Dom\HTMLDocument::createFromString() - document without body
--EXTENSIONS--
dom
--FILE--
foo '
');
-echo $dom->saveHTML(), "\n";
+$dom = Dom\HTMLDocument::createFromString('foo '
');
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/parser/HTMLDocument_parse_options.phpt b/ext/dom/tests/modern/html/parser/HTMLDocument_parse_options.phpt
index c1e281b5331a9..0d3ad1a474ac8 100644
--- a/ext/dom/tests/modern/html/parser/HTMLDocument_parse_options.phpt
+++ b/ext/dom/tests/modern/html/parser/HTMLDocument_parse_options.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\HTMLDocument: loading $options check
+Dom\HTMLDocument: loading $options check
--EXTENSIONS--
dom
--FILE--
@@ -30,7 +30,7 @@ foreach (["createFromString", "createFromFile"] as $method) {
foreach ($tested_options as $options) {
var_dump($options);
try {
- DOM\HTMLDocument::{$method}("x", $options);
+ Dom\HTMLDocument::{$method}("x", $options);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
@@ -41,67 +41,67 @@ foreach (["createFromString", "createFromFile"] as $method) {
--EXPECTF--
--- Method createFromString ---
int(%d)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4194304)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(524288)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(8)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(256)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16384)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1024)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2048)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(64)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(128)
-DOM\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
--- Method createFromFile ---
int(%d)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4194304)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(524288)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(8)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(256)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(16384)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(4)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1024)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(1)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(2048)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(64)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
int(128)
-DOM\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, DOM\NO_DEFAULT_NS)
+Dom\HTMLDocument::createFromFile(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_NOERROR, LIBXML_COMPACT, LIBXML_HTML_NOIMPLIED, Dom\NO_DEFAULT_NS)
diff --git a/ext/dom/tests/modern/html/parser/predefined_namespaces.phpt b/ext/dom/tests/modern/html/parser/predefined_namespaces.phpt
index a97385de37d91..7e78460454e60 100644
--- a/ext/dom/tests/modern/html/parser/predefined_namespaces.phpt
+++ b/ext/dom/tests/modern/html/parser/predefined_namespaces.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -28,7 +28,7 @@ $dom = DOM\HTMLDocument::createFromString(<<query("//*[name()='body']//*") as $node) {
echo $node->nodeName, " ", $node->namespaceURI ?? "(NONE)", "\n";
foreach ($node->attributes as $attribute) {
@@ -37,9 +37,9 @@ foreach ($xpath->query("//*[name()='body']//*") as $node) {
}
echo "--- HTML serialization ---\n";
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
echo "--- XML serialization ---\n";
-echo $dom->saveXML();
+echo $dom->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/parser/user_error_handler.phpt b/ext/dom/tests/modern/html/parser/user_error_handler.phpt
index 86b5a6d28f54e..d02100cfcbe93 100644
--- a/ext/dom/tests/modern/html/parser/user_error_handler.phpt
+++ b/ext/dom/tests/modern/html/parser/user_error_handler.phpt
@@ -11,9 +11,9 @@ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
var_dump($errno, $errstr);
}, E_WARNING);
-DOM\HTMLDocument::createFromString('');
+Dom\HTMLDocument::createFromString('');
?>
--EXPECT--
int(2)
-string(113) "DOM\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-5"
+string(113) "Dom\HTMLDocument::createFromString(): tree error unexpected-token-in-initial-mode in Entity, line: 1, column: 2-5"
diff --git a/ext/dom/tests/modern/html/parser/xml_style_namespace.phpt b/ext/dom/tests/modern/html/parser/xml_style_namespace.phpt
index 3889d1fd2ff65..9657ac3b78097 100644
--- a/ext/dom/tests/modern/html/parser/xml_style_namespace.phpt
+++ b/ext/dom/tests/modern/html/parser/xml_style_namespace.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -18,7 +18,7 @@ $dom = DOM\HTMLDocument::createFromString(<<query("//*[name()='body']//*") as $node) {
echo $node->nodeName, " ", $node->namespaceURI ?? "(NONE)", "\n";
echo "prefix: \"", $node->prefix, "\"\n";
@@ -28,9 +28,9 @@ foreach ($xpath->query("//*[name()='body']//*") as $node) {
}
echo "--- HTML serialization ---\n";
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
echo "--- XML serialization ---\n";
-echo $dom->saveXML();
+echo $dom->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_entity_reference.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_entity_reference.phpt
index 108c383467819..2479e39306fa9 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_entity_reference.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_entity_reference.phpt
@@ -9,11 +9,11 @@ $dom1 = new DOMDocument();
$root = $dom1->appendChild($dom1->createElement('root'));
$root->appendChild($dom1->createEntityReference('nbsp'));
-$dom2 = DOM\HTMLDocument::createEmpty();
+$dom2 = Dom\HTMLDocument::createEmpty();
$dom2->appendChild($dom2->importLegacyNode($root, true));
-echo $dom2->saveXML(), "\n";
-echo $dom2->saveHTML(), "\n";
+echo $dom2->saveXml(), "\n";
+echo $dom2->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_attribute.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_attribute.phpt
index d4a888bffe82e..4953deabf0e30 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_attribute.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_attribute.phpt
@@ -1,14 +1,14 @@
--TEST--
-DOM\HTMLDocument serialization escape attribute
+Dom\HTMLDocument serialization escape attribute
--EXTENSIONS--
dom
--FILE--
", LIBXML_NOERROR);
+$dom = Dom\HTMLDocument::createFromString("
", LIBXML_NOERROR);
$p = $dom->documentElement->firstChild->nextSibling->firstChild;
$p->setAttribute("foo", "\"'&");
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_nbsp.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_nbsp.phpt
index c7b11a7a4c74f..accbec630cf5e 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_nbsp.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_escape_nbsp.phpt
@@ -1,12 +1,12 @@
--TEST--
-DOM\HTMLDocument serialization escape nbsp
+Dom\HTMLDocument serialization escape nbsp
--EXTENSIONS--
dom
--FILE--
these must transform: \xc2\xa0\xc2\xa0 but these not: \xa0|\xc2... ", LIBXML_NOERROR);
-echo $dom->saveHTML();
+$dom = Dom\HTMLDocument::createFromString("these must transform: \xc2\xa0\xc2\xa0 but these not: \xa0|\xc2...
", LIBXML_NOERROR);
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_attribute_ns.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_attribute_ns.phpt
index dc8881bfc6a70..66459d0e72825 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_attribute_ns.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_attribute_ns.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\HTMLDocument serialization of an attribute in a namespace
+Dom\HTMLDocument serialization of an attribute in a namespace
--EXTENSIONS--
dom
--FILE--
appendChild($dom->createElement("root"));
$root->setAttributeNodeNS($dom->createAttributeNS("http://php.net", "x:foo"));
$root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/XML/1998/namespace", "y:id"));
@@ -14,7 +14,7 @@ $root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/2000/xmlns/
$root->setAttributeNodeNS($dom->createAttributeNS("http://www.w3.org/1999/xlink", "z:f"));
// Note: XML declarations are not emitted in HTML5
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_cdata.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_cdata.phpt
index 27824c61eeecf..f379a61dfec0b 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_cdata.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_cdata.phpt
@@ -1,18 +1,18 @@
--TEST--
-DOM\HTMLDocument serialization of CData
+Dom\HTMLDocument serialization of CData
--EXTENSIONS--
dom
--FILE--
createCDATASection("foobaré\"<>-&");
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container"));
$container->appendChild($dom->importNode($cdata));
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_comment.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_comment.phpt
index 4abc382a3ae1f..4afe4a32f069f 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_comment.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_comment.phpt
@@ -1,13 +1,13 @@
--TEST--
-DOM\HTMLDocument serialization of comment
+Dom\HTMLDocument serialization of comment
--EXTENSIONS--
dom
--FILE--
appendChild($dom->createComment("foobaré\"<>-&"));
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_doctype.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_doctype.phpt
index 5be17d704191e..49d0e566e2967 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_doctype.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_doctype.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\HTMLDocument serialization of document type
+Dom\HTMLDocument serialization of document type
--EXTENSIONS--
dom
--FILE--
@@ -16,10 +16,10 @@ $dom = DOM\HTMLDocument::createFromString(<<saveXML(), "\n";
+echo $dom->saveXml(), "\n";
echo "--- HTML encoding ---\n";
// We don't expect to see the public ID and the system ID because the serialization algorithm doesn't serialize those
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_element_ns.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_element_ns.phpt
index 03813a6252088..8d23e09dedb86 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_element_ns.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_element_ns.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\HTMLDocument serialization of element in a namespace
+Dom\HTMLDocument serialization of element in a namespace
--EXTENSIONS--
dom
--FILE--
appendChild($dom->createElement("root"));
$root->append("\n");
@@ -16,7 +16,7 @@ $root->append($dom->createElementNS("http://www.w3.org/2000/svg", "s:svg"), "\n"
$root->append($dom->createElementNS("http://www.w3.org/1998/Math/MathML", "m:math"), "\n");
// Note: XML declarations are not emitted in HTML5
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_failing_stream.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_failing_stream.phpt
index 7241c34f7754f..c02b02a346929 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_failing_stream.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_failing_stream.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\HTMLDocument serialization with a failing stream
+Dom\HTMLDocument serialization with a failing stream
--EXTENSIONS--
dom
--FILE--
@@ -33,9 +33,9 @@ class FailingWrapper {
stream_wrapper_register("failing", "FailingWrapper");
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$root = $dom->appendChild($dom->createElement("root"));
-$dom->saveHTMLFile("failing://foo");
+$dom->saveHtmlFile("failing://foo");
?>
--EXPECTF--
@@ -44,6 +44,6 @@ string(1) "<"
Fatal error: Uncaught Error: fail in %s:%d
Stack trace:
#0 [internal function]: FailingWrapper->stream_write('root')
-#1 %s(%d): DOM\HTMLDocument->saveHTMLFile('failing://foo')
+#1 %s(%d): Dom\HTMLDocument->saveHtmlFile('failing://foo')
#2 {main}
thrown in %s on line %d
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_fragment.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_fragment.phpt
index 69c47eca4ace9..ca1e1fa3964f0 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_fragment.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_fragment.phpt
@@ -1,17 +1,17 @@
--TEST--
-DOM\HTMLDocument serialization of document fragment
+Dom\HTMLDocument serialization of document fragment
--EXTENSIONS--
dom
--FILE--
createDocumentFragment();
$fragment->appendChild($dom->createElement("foo"));
$bar = $fragment->appendChild($dom->createElement("bar"));
$fragment->appendChild($dom->createElement("baz"));
$bar->appendChild($dom->createElement("inner"));
-echo $dom->saveHTML($fragment);
+echo $dom->saveHtml($fragment);
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_full_document.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_full_document.phpt
index 28fb38024a7bc..f0dcf1ad5f0be 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_full_document.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_full_document.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\HTMLDocument serialization of full document
+Dom\HTMLDocument serialization of full document
--EXTENSIONS--
dom
--FILE--
@@ -27,7 +27,7 @@ $dom = DOM\HTMLDocument::createFromString(<<
HTML);
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_01.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_01.phpt
index 76321f473805f..d0b97e5304cf7 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_01.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_01.phpt
@@ -1,24 +1,24 @@
--TEST--
-DOM\HTMLDocument serialization with an imported namespace node 01
+Dom\HTMLDocument serialization with an imported namespace node 01
--EXTENSIONS--
dom
--FILE--
');
+$xml = Dom\XMLDocument::createFromString(' ');
$xml->documentElement->setAttributeNS("http://foo/", "foo:bar", "value");
$xml->documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
-echo $xml->saveXML(), "\n";
+echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n";
-$html = DOM\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
+$html = Dom\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, true));
-echo $html->saveXML(), "\n";
-echo $html->saveHTML(), "\n";
+echo $html->saveXml(), "\n";
+echo $html->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_02.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_02.phpt
index 94af74ffaeb2d..2460bb3426eee 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_02.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_02.phpt
@@ -1,23 +1,23 @@
--TEST--
-DOM\HTMLDocument serialization with an imported namespace node 02
+Dom\HTMLDocument serialization with an imported namespace node 02
--EXTENSIONS--
dom
--FILE--
documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
-echo $xml->saveXML(), "\n";
+echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n";
-$html = DOM\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
+$html = Dom\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, true));
-echo $html->saveXML(), "\n";
-echo $html->saveHTML(), "\n";
+echo $html->saveXml(), "\n";
+echo $html->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_03.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_03.phpt
index 7f5b9ab822f21..9314c8d200dbd 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_03.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_03.phpt
@@ -1,23 +1,23 @@
--TEST--
-DOM\HTMLDocument serialization with an imported namespace node 03
+Dom\HTMLDocument serialization with an imported namespace node 03
--EXTENSIONS--
dom
--FILE--
documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
-echo $xml->saveXML(), "\n";
+echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n";
-$html = DOM\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
+$html = Dom\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, false));
-echo $html->saveXML(), "\n";
-echo $html->saveHTML(), "\n";
+echo $html->saveXml(), "\n";
+echo $html->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_04.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_04.phpt
index d4ae507c76177..39dcb53353a23 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_04.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_04.phpt
@@ -1,23 +1,23 @@
--TEST--
-DOM\HTMLDocument serialization with an imported namespace node 04
+Dom\HTMLDocument serialization with an imported namespace node 04
--EXTENSIONS--
dom
--FILE--
documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
-echo $xml->saveXML(), "\n";
+echo $xml->saveXml(), "\n";
echo "--- After import into HTML ---\n";
-$html = DOM\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
+$html = Dom\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->importNode($xml->documentElement, false));
-echo $html->saveXML(), "\n";
-echo $html->saveHTML(), "\n";
+echo $html->saveXml(), "\n";
+echo $html->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_05.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_05.phpt
index 2e9fd671775f6..8bebf2bc195db 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_05.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_05.phpt
@@ -1,23 +1,23 @@
--TEST--
-DOM\HTMLDocument serialization with an imported namespace node 05
+Dom\HTMLDocument serialization with an imported namespace node 05
--EXTENSIONS--
dom
--FILE--
documentElement->appendChild($xml->createElementNS('some:ns2', 'child'));
-echo $xml->saveXML(), "\n";
+echo $xml->saveXml(), "\n";
echo "--- After adoption into HTML ---\n";
-$html = DOM\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
+$html = Dom\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
$p = $html->documentElement->firstChild->nextSibling->firstChild;
$p->appendChild($html->adoptNode($xml->documentElement));
-echo $html->saveXML(), "\n";
-echo $html->saveHTML(), "\n";
+echo $html->saveXml(), "\n";
+echo $html->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_06.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_06.phpt
index 753fa73633b96..7b5db9901874c 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_06.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_ns_imported_06.phpt
@@ -1,23 +1,23 @@
--TEST--
-DOM\HTMLDocument serialization with an imported namespace node 06
+Dom\HTMLDocument serialization with an imported namespace node 06
--EXTENSIONS--
dom
--FILE--
documentElement->firstElementChild->appendChild($xml->createElementNS('some:ns2', 'child'));
-echo $xml->saveXML(), "\n";
+echo $xml->saveXml(), "\n";
echo "--- After clone + import into HTML ---\n";
-$html = DOM\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
+$html = Dom\HTMLDocument::createFromString('foo
', LIBXML_NOERROR);
$p = $html->documentElement->firstElementChild->nextElementSibling->firstElementChild;
$p->appendChild($html->adoptNode($xml->documentElement->firstElementChild->cloneNode(true)));
-echo $html->saveXML(), "\n";
-echo $html->saveHTML(), "\n";
+echo $html->saveXml(), "\n";
+echo $html->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_processing_instruction.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_processing_instruction.phpt
index c45bef620faa0..54de87ef2e5bb 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_processing_instruction.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_processing_instruction.phpt
@@ -1,14 +1,14 @@
--TEST--
-DOM\HTMLDocument serialization of processing instruction
+Dom\HTMLDocument serialization of processing instruction
--EXTENSIONS--
dom
--FILE--
in a processing instruction element but that breaks (as expected)
$dom->appendChild($dom->createProcessingInstruction("target", "foobaré\"&<\xc2\xa0"));
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_roots.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_roots.phpt
index 5b5959e5adb6c..b61e52510a0e3 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_roots.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_roots.phpt
@@ -1,15 +1,15 @@
--TEST--
-DOM\HTMLDocument serialization of different roots
+Dom\HTMLDocument serialization of different roots
--EXTENSIONS--
dom
--FILE--
createCDATASection("cdata");
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container"));
$comment = $container->appendChild($dom->createComment("comment"));
$cdata = $container->appendChild($dom->importNode($cdata));
@@ -18,12 +18,12 @@ $text = $container->appendChild($dom->createTextNode("text"));
$pi = $container->appendChild($dom->createProcessingInstruction("target", "data"));
$fragment = $dom->createDocumentFragment();
-var_dump($dom->saveHTML($comment));
-var_dump($dom->saveHTML($cdata));
-var_dump($dom->saveHTML($emptyElement));
-var_dump($dom->saveHTML($text));
-var_dump($dom->saveHTML($pi));
-var_dump($dom->saveHTML($fragment));
+var_dump($dom->saveHtml($comment));
+var_dump($dom->saveHtml($cdata));
+var_dump($dom->saveHtml($emptyElement));
+var_dump($dom->saveHtml($text));
+var_dump($dom->saveHtml($pi));
+var_dump($dom->saveHtml($fragment));
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_01.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_01.phpt
index 025bee90ced70..d37a43a4a42b2 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_01.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_01.phpt
@@ -1,14 +1,14 @@
--TEST--
-DOM\HTMLDocument serialization escape text 01
+Dom\HTMLDocument serialization escape text 01
--EXTENSIONS--
dom
--FILE--
", LIBXML_NOERROR);
+$dom = Dom\HTMLDocument::createFromString("
", LIBXML_NOERROR);
$p = $dom->documentElement->firstChild->nextSibling->firstChild;
$p->textContent = "this is &text! \"\"";
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_02.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_02.phpt
index 115f3233eb2eb..48ab2e5ea59f8 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_02.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_02.phpt
@@ -1,18 +1,18 @@
--TEST--
-DOM\HTMLDocument serialization escape text 02 - special tags in html namespace
+Dom\HTMLDocument serialization escape text 02 - special tags in html namespace
--EXTENSIONS--
dom
--FILE--
appendChild($dom->createElement("body"));
foreach (["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"] as $tag) {
$tag = $body->appendChild($dom->createElement($tag));
$tag->textContent = "&\"<>\xc2\xa0 foobar";
$body->append("\n");
}
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_03.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_03.phpt
index ec6822d77582c..bb582ba533349 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_03.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_text_03.phpt
@@ -1,18 +1,18 @@
--TEST--
-DOM\HTMLDocument serialization escape text 03 - special tags in namespace should encode content
+Dom\HTMLDocument serialization escape text 03 - special tags in namespace should encode content
--EXTENSIONS--
dom
--FILE--
appendChild($dom->createElement("body"));
foreach (["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"] as $tag) {
$tag = $body->appendChild($dom->createElementNS("some:ns", $tag));
$tag->textContent = "&\"<>\xc2\xa0 foobar";
$body->append("\n");
}
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_void_elements.phpt b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_void_elements.phpt
index e4acf241e7d08..7900f11619d52 100644
--- a/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_void_elements.phpt
+++ b/ext/dom/tests/modern/html/serializer/HTMLDocument_serialize_void_elements.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\HTMLDocument serialization of void elements
+Dom\HTMLDocument serialization of void elements
--EXTENSIONS--
dom
--FILE--
createElement("container");
$dom->append($container);
@@ -35,14 +35,14 @@ foreach ($tags as $tag) {
$element->appendChild($dom->createElement("inner"));
$element->after("\n");
echo "$tag: ";
- var_dump($dom->saveHTML($element));
+ var_dump($dom->saveHtml($element));
$element = $container->appendChild($dom->createElementNS("http://php.net/foo", "x:$tag"));
$element->appendChild($dom->createElement("inner"));
$element->after("\n");
}
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Attr_name.phpt b/ext/dom/tests/modern/spec/Attr_name.phpt
index 2510de3eb1c2c..89c0aff2223eb 100644
--- a/ext/dom/tests/modern/spec/Attr_name.phpt
+++ b/ext/dom/tests/modern/spec/Attr_name.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
appendChild($dom->createElement("foo"));
$foo->setAttributeNS("http://example.com", "foo:bar", "baz");
var_dump($foo->attributes[0]->name);
diff --git a/ext/dom/tests/modern/spec/CharacterData_deleteData_negative_in_bounds_length.phpt b/ext/dom/tests/modern/spec/CharacterData_deleteData_negative_in_bounds_length.phpt
index 924f58d703627..f29a201ca1068 100644
--- a/ext/dom/tests/modern/spec/CharacterData_deleteData_negative_in_bounds_length.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_deleteData_negative_in_bounds_length.phpt
@@ -7,10 +7,10 @@ dom
echo "--- Modern behaviour ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$comment = $dom->createComment("foobarbaz");
$comment->deleteData(3, -1);
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
echo "--- Legacy behaviour ---\n";
@@ -21,7 +21,7 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_insertData_edge_cases.phpt b/ext/dom/tests/modern/spec/CharacterData_insertData_edge_cases.phpt
index b89b389ee31a8..9369bdadbffad 100644
--- a/ext/dom/tests/modern/spec/CharacterData_insertData_edge_cases.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_insertData_edge_cases.phpt
@@ -7,7 +7,7 @@ dom
--FILE--
createComment("foobarbaz");
try {
var_dump($comment->insertData(100, "data"));
@@ -19,7 +19,7 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset.phpt b/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset.phpt
index f00625df3521c..f00e9aa76aae1 100644
--- a/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset.phpt
@@ -5,16 +5,16 @@ dom
--FILE--
createComment("foobarbaz");
try {
$comment->insertData(-1, "A");
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
$comment->insertData(1, "A");
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset_mod32.phpt b/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset_mod32.phpt
index 5c0be698bda83..7c27c3bc8dd58 100644
--- a/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset_mod32.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_insertData_negative_offset_mod32.phpt
@@ -11,16 +11,16 @@ if (PHP_INT_SIZE === 4) die('skip not for 32-bit');
echo "--- Modern behaviour ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$comment = $dom->createComment("foobarbaz");
try {
$comment->insertData(-1, "A");
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
$comment->insertData(-(2**32 - 1), "A");
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
echo "--- Legacy behaviour ---\n";
@@ -31,13 +31,13 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
try {
$comment->insertData(-(2**32 - 1), "A");
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count.phpt b/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count.phpt
index 96402847f73cf..32e27778552fe 100644
--- a/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count.phpt
@@ -5,13 +5,13 @@ dom
--FILE--
createComment("foobarbaz");
$comment->replaceData(0, -1, "A");
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
$comment = $dom->createComment("foobarbaz");
$comment->replaceData(2, -2, "A");
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count_mod32.phpt b/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count_mod32.phpt
index 9382ed2549753..64634b0992579 100644
--- a/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count_mod32.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_replaceData_negative_count_mod32.phpt
@@ -11,13 +11,13 @@ if (PHP_INT_SIZE === 4) die('skip not for 32-bit');
echo "--- Modern behaviour ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$comment = $dom->createComment("foobarbaz");
$comment->replaceData(0, -1, "A");
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
$comment = $dom->createComment("foobarbaz");
$comment->replaceData(2, -(2**32 - 2), "A");
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
echo "--- Legacy behaviour ---\n";
@@ -28,13 +28,13 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
try {
$comment->replaceData(2, -(2**32 - 2), "A");
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_substringData_edge_cases.phpt b/ext/dom/tests/modern/spec/CharacterData_substringData_edge_cases.phpt
index 82f1f9ed77d3d..c463c0f7057c8 100644
--- a/ext/dom/tests/modern/spec/CharacterData_substringData_edge_cases.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_substringData_edge_cases.phpt
@@ -7,7 +7,7 @@ dom
--FILE--
createComment("foobarbaz");
try {
var_dump($comment->substringData(0, 2**31+1));
@@ -24,7 +24,7 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments.phpt b/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments.phpt
index a0b5414bb8982..28198d94d6d56 100644
--- a/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments.phpt
@@ -5,18 +5,18 @@ dom
--FILE--
createComment("foobarbaz");
var_dump($comment->substringData(0, -1));
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
var_dump($comment->substringData(2, -2));
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
try {
var_dump($comment->substringData(-2, 2));
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments_mod32.phpt b/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments_mod32.phpt
index c29eb0b779298..7d38bd28d441b 100644
--- a/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments_mod32.phpt
+++ b/ext/dom/tests/modern/spec/CharacterData_substringData_negative_arguments_mod32.phpt
@@ -11,14 +11,14 @@ if (PHP_INT_SIZE === 4) die('skip not for 32-bit');
echo "--- Modern behaviour ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$comment = $dom->createComment("foobarbaz");
var_dump($comment->substringData(0, -1));
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
var_dump($comment->substringData(2, -(2**32 - 2)));
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
var_dump($comment->substringData(-(2**32 - 2), 2));
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
echo "--- Legacy behaviour ---\n";
@@ -29,19 +29,19 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
try {
var_dump($comment->substringData(2, -(2**32 - 2)));
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
try {
var_dump($comment->substringData(-(2**32 - 2), 2));
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML($comment), "\n";
+echo $dom->saveHtml($comment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Document_createAttribute.phpt b/ext/dom/tests/modern/spec/Document_createAttribute.phpt
index 7a9ead916c8bb..9d52b3659758e 100644
--- a/ext/dom/tests/modern/spec/Document_createAttribute.phpt
+++ b/ext/dom/tests/modern/spec/Document_createAttribute.phpt
@@ -8,7 +8,7 @@ require __DIR__ . "/dump_attr.inc";
echo "--- HTML document ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$attr = $dom->createAttribute('foo');
dumpAttr($attr);
$attr = $dom->createAttribute('FoOo');
@@ -16,7 +16,7 @@ dumpAttr($attr);
echo "--- XML document ---\n";
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
$attr = $dom->createAttribute('foo');
dumpAttr($attr);
$attr = $dom->createAttribute('FoOo');
diff --git a/ext/dom/tests/modern/spec/Document_createAttributeNS.phpt b/ext/dom/tests/modern/spec/Document_createAttributeNS.phpt
index e0cb36c9ffd6e..6441ee60ef4f5 100644
--- a/ext/dom/tests/modern/spec/Document_createAttributeNS.phpt
+++ b/ext/dom/tests/modern/spec/Document_createAttributeNS.phpt
@@ -16,7 +16,7 @@ function testErrorCase($dom, $ns, $qname) {
}
}
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$attrs = [];
$attrs[] = $dom->createAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:foo');
$attrs[] = $dom->createAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:bar');
@@ -49,7 +49,7 @@ foreach ($attrs as $attr) {
$root->setAttributeNodeNS($attr);
}
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
echo "\n--- NULL prefix cases ---\n";
@@ -64,7 +64,7 @@ foreach ($attrs as $attr) {
$root->setAttributeNodeNS($attr);
}
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
--- Error cases ---
diff --git a/ext/dom/tests/modern/spec/Document_createElement.phpt b/ext/dom/tests/modern/spec/Document_createElement.phpt
index 72a330fa8e2f5..e7112bbf90c9a 100644
--- a/ext/dom/tests/modern/spec/Document_createElement.phpt
+++ b/ext/dom/tests/modern/spec/Document_createElement.phpt
@@ -9,7 +9,7 @@ require __DIR__ . "/element_dump.inc";
echo "--- Into rootless document ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$element = $dom->createElement("HTML");
$element->textContent = "&hello";
dumpElement($element);
@@ -19,7 +19,7 @@ dumpElement($element);
echo "--- Into document with HTML root ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$element = $dom->createElement("HTML");
$element->textContent = "&hello";
$dom->appendChild($element);
@@ -28,7 +28,7 @@ dumpElement($element);
echo "--- Into document with non-HTML root ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$element = $dom->createElementNS("urn:a", "container");
$dom->appendChild($element);
$element = $dom->createElement("HEad");
diff --git a/ext/dom/tests/modern/spec/Document_createElementNS.phpt b/ext/dom/tests/modern/spec/Document_createElementNS.phpt
index 3eeb1bd2cbb8b..cbdbe5dfd9835 100644
--- a/ext/dom/tests/modern/spec/Document_createElementNS.phpt
+++ b/ext/dom/tests/modern/spec/Document_createElementNS.phpt
@@ -10,7 +10,7 @@ require __DIR__ . "/create_element_util.inc";
echo "--- Normal cases ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$elements = [];
$elements[] = createElementNS($dom, NULL, "qname", "&hello");
diff --git a/ext/dom/tests/modern/spec/Document_createElement_edge_cases.phpt b/ext/dom/tests/modern/spec/Document_createElement_edge_cases.phpt
index d2113b2d1ef13..6d8fc878b6cee 100644
--- a/ext/dom/tests/modern/spec/Document_createElement_edge_cases.phpt
+++ b/ext/dom/tests/modern/spec/Document_createElement_edge_cases.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
createElement('');
} catch (DOMException $e) {
diff --git a/ext/dom/tests/modern/spec/Document_getElementsByTagNameNS.phpt b/ext/dom/tests/modern/spec/Document_getElementsByTagNameNS.phpt
index 0f18891e62c99..12df0f49c827c 100644
--- a/ext/dom/tests/modern/spec/Document_getElementsByTagNameNS.phpt
+++ b/ext/dom/tests/modern/spec/Document_getElementsByTagNameNS.phpt
@@ -7,7 +7,7 @@ dom
require __DIR__ . '/create_element_util.inc';
-$dom = DOM\HTMLDocument::createFromString(<<
diff --git a/ext/dom/tests/modern/spec/Document_implementation_createDocument.phpt b/ext/dom/tests/modern/spec/Document_implementation_createDocument.phpt
index a7025655ec406..5384cf6331f76 100644
--- a/ext/dom/tests/modern/spec/Document_implementation_createDocument.phpt
+++ b/ext/dom/tests/modern/spec/Document_implementation_createDocument.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
implementation->createDocument(null, ""));
echo "--- (null, \"qname\") ---\n";
-echo $dom->implementation->createDocument(null, "qname")->saveXML(), "\n";
+echo $dom->implementation->createDocument(null, "qname")->saveXml(), "\n";
echo "--- (\"\", \"qname\") ---\n";
-echo $dom->implementation->createDocument("", "qname")->saveXML(), "\n";
+echo $dom->implementation->createDocument("", "qname")->saveXml(), "\n";
echo "--- (\"urn:a\", \"qname\") ---\n";
-echo $dom->implementation->createDocument("urn:a", "qname")->saveXML(), "\n";
+echo $dom->implementation->createDocument("urn:a", "qname")->saveXml(), "\n";
echo "--- With doctype ---\n";
$dtd = $dom->implementation->createDocumentType("mydoc", "", "");
-echo $dom->implementation->createDocument(null, "", $dtd)->saveXML(), "\n";
+echo $dom->implementation->createDocument(null, "", $dtd)->saveXml(), "\n";
echo "--- With auto-adopting doctype ---\n";
-$dom2 = DOM\XMLDocument::createEmpty();
+$dom2 = Dom\XMLDocument::createEmpty();
$dtd = $dom2->implementation->createDocumentType("mydoc", "", "");
-echo $dom->implementation->createDocument(null, "", $dtd)->saveXML(), "\n";
+echo $dom->implementation->createDocument(null, "", $dtd)->saveXml(), "\n";
?>
--EXPECT--
--- (null, "") ---
-object(DOM\XMLDocument)#3 (29) {
+object(Dom\XMLDocument)#3 (29) {
["xmlEncoding"]=>
string(5) "UTF-8"
["xmlStandalone"]=>
diff --git a/ext/dom/tests/modern/spec/Document_implementation_createDocumentType.phpt b/ext/dom/tests/modern/spec/Document_implementation_createDocumentType.phpt
index d396477c69418..88c66abf09c91 100644
--- a/ext/dom/tests/modern/spec/Document_implementation_createDocumentType.phpt
+++ b/ext/dom/tests/modern/spec/Document_implementation_createDocumentType.phpt
@@ -13,19 +13,19 @@ $test_matrix = [
];
foreach ($test_matrix as $test_item) {
- $dom = DOM\XMLDocument::createEmpty();
+ $dom = Dom\XMLDocument::createEmpty();
$dtd = $dom->implementation->createDocumentType($test_item['uri'], $test_item['public'], $test_item['system']);
var_dump($dtd);
$dom->append($dom->importNode($dtd));
- echo $dom->saveXML(), "\n";
+ echo $dom->saveXml(), "\n";
}
?>
--EXPECT--
-object(DOM\DocumentType)#3 (23) {
+object(Dom\DocumentType)#3 (23) {
["name"]=>
string(5) "qname"
["entities"]=>
@@ -76,7 +76,7 @@ object(DOM\DocumentType)#3 (23) {
-object(DOM\DocumentType)#2 (23) {
+object(Dom\DocumentType)#2 (23) {
["name"]=>
string(5) "qname"
["entities"]=>
@@ -127,7 +127,7 @@ object(DOM\DocumentType)#2 (23) {
-object(DOM\DocumentType)#1 (23) {
+object(Dom\DocumentType)#1 (23) {
["name"]=>
string(5) "qname"
["entities"]=>
@@ -178,7 +178,7 @@ object(DOM\DocumentType)#1 (23) {
-object(DOM\DocumentType)#4 (23) {
+object(Dom\DocumentType)#4 (23) {
["name"]=>
string(5) "qname"
["entities"]=>
diff --git a/ext/dom/tests/modern/spec/Document_implementation_createDocumentType_errors.phpt b/ext/dom/tests/modern/spec/Document_implementation_createDocumentType_errors.phpt
index 622a690abc0ea..74e17fb5a4f0d 100644
--- a/ext/dom/tests/modern/spec/Document_implementation_createDocumentType_errors.phpt
+++ b/ext/dom/tests/modern/spec/Document_implementation_createDocumentType_errors.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
implementation->createDocumentType("invalid name", "public", "system");
} catch (DOMException $e) {
diff --git a/ext/dom/tests/modern/spec/Document_implementation_createDocument_errors.phpt b/ext/dom/tests/modern/spec/Document_implementation_createDocument_errors.phpt
index c66808e3895ef..673aed3ef5565 100644
--- a/ext/dom/tests/modern/spec/Document_implementation_createDocument_errors.phpt
+++ b/ext/dom/tests/modern/spec/Document_implementation_createDocument_errors.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
implementation->createDocument("urn:a", "@");
diff --git a/ext/dom/tests/modern/spec/Document_implementation_createHTMLDocument.phpt b/ext/dom/tests/modern/spec/Document_implementation_createHTMLDocument.phpt
index fe3568bb0c262..88b55878fd057 100644
--- a/ext/dom/tests/modern/spec/Document_implementation_createHTMLDocument.phpt
+++ b/ext/dom/tests/modern/spec/Document_implementation_createHTMLDocument.phpt
@@ -5,19 +5,19 @@ dom
--FILE--
implementation->createHTMLDocument()->saveXML(), "\n";
+echo $dom->implementation->createHTMLDocument()->saveXml(), "\n";
echo "---\n";
-echo $dom->implementation->createHTMLDocument("")->saveXML(), "\n";
+echo $dom->implementation->createHTMLDocument("")->saveXml(), "\n";
echo "---\n";
-echo $dom->implementation->createHTMLDocument("my ")->saveXML(), "\n";
+echo $dom->implementation->createHTMLDocument("my ")->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Document_implementation_same_object.phpt b/ext/dom/tests/modern/spec/Document_implementation_same_object.phpt
index 01e9dd2af6b9e..690b2bf63584d 100644
--- a/ext/dom/tests/modern/spec/Document_implementation_same_object.phpt
+++ b/ext/dom/tests/modern/spec/Document_implementation_same_object.phpt
@@ -5,12 +5,12 @@ dom
--FILE--
implementation === $dom->implementation);
$implementation = $dom->implementation;
var_dump($dom->implementation === $implementation);
-$dom2 = DOM\XMLDocument::createEmpty();
+$dom2 = Dom\XMLDocument::createEmpty();
var_dump($dom2->implementation === $dom->implementation);
var_dump($implementation);
@@ -26,6 +26,6 @@ try {
bool(true)
bool(true)
bool(false)
-object(DOM\Implementation)#2 (0) {
+object(Dom\Implementation)#2 (0) {
}
-Trying to clone an uncloneable object of class DOM\Implementation
+Trying to clone an uncloneable object of class Dom\Implementation
diff --git a/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt b/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt
index 55e53c3ccc169..8a6f324c3dc35 100644
--- a/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt
+++ b/ext/dom/tests/modern/spec/Document_importLegacyNode.phpt
@@ -16,7 +16,7 @@ $old->loadXML(<<
XML);
-$new = DOM\XMLDocument::createEmpty();
+$new = Dom\XMLDocument::createEmpty();
$new->append($new->importLegacyNode($old->documentElement, true));
unset($old);
@@ -33,11 +33,11 @@ foreach ($new->getElementsByTagName('child') as $child) {
}
}
-echo $new->saveXML(), "\n";
+echo $new->saveXml(), "\n";
?>
--EXPECT--
-object(DOM\NamedNodeMap)#5 (1) {
+object(Dom\NamedNodeMap)#5 (1) {
["length"]=>
int(2)
}
@@ -47,7 +47,7 @@ namespaceURI: string(29) "http://www.w3.org/2000/xmlns/"
name: string(1) "a"
prefix: NULL
namespaceURI: NULL
-object(DOM\NamedNodeMap)#3 (1) {
+object(Dom\NamedNodeMap)#3 (1) {
["length"]=>
int(3)
}
diff --git a/ext/dom/tests/modern/spec/Document_importNode_not_supported.phpt b/ext/dom/tests/modern/spec/Document_importNode_not_supported.phpt
index 779a41efb5578..9f02411fd8bb2 100644
--- a/ext/dom/tests/modern/spec/Document_importNode_not_supported.phpt
+++ b/ext/dom/tests/modern/spec/Document_importNode_not_supported.phpt
@@ -10,7 +10,7 @@ $dom = new DOMDocument();
var_dump($dom->importNode($dom));
// For modern documents this should throw
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
try {
$dom->importNode($dom);
} catch (DOMException $e) {
diff --git a/ext/dom/tests/modern/spec/Element_getAttribute.phpt b/ext/dom/tests/modern/spec/Element_getAttribute.phpt
index 73dc64f503d47..6f4f7a0d89adb 100644
--- a/ext/dom/tests/modern/spec/Element_getAttribute.phpt
+++ b/ext/dom/tests/modern/spec/Element_getAttribute.phpt
@@ -7,7 +7,7 @@ dom
echo "--- Get after parsing ---\n";
-$dom = DOM\HTMLDocument::createFromString('');
+$dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
var_dump($body->getAttribute("align"));
var_dump($body->getAttribute("foo:bar"));
diff --git a/ext/dom/tests/modern/spec/Element_getAttributeNS.phpt b/ext/dom/tests/modern/spec/Element_getAttributeNS.phpt
index cfaae5bb89791..9b27c79b93af2 100644
--- a/ext/dom/tests/modern/spec/Element_getAttributeNS.phpt
+++ b/ext/dom/tests/modern/spec/Element_getAttributeNS.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
echo "--- After parsing, i.e. without namespace ---\n";
diff --git a/ext/dom/tests/modern/spec/Element_getAttributeNode.phpt b/ext/dom/tests/modern/spec/Element_getAttributeNode.phpt
index 4bf186ac2f415..034fcbeec6a54 100644
--- a/ext/dom/tests/modern/spec/Element_getAttributeNode.phpt
+++ b/ext/dom/tests/modern/spec/Element_getAttributeNode.phpt
@@ -7,7 +7,7 @@ dom
echo "--- Get after parsing ---\n";
-$dom = DOM\HTMLDocument::createFromString('');
+$dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
var_dump($body->getAttributeNode("align")->textContent);
var_dump($body->getAttributeNode("foo:bar")->textContent);
diff --git a/ext/dom/tests/modern/spec/Element_getAttributeNodeNS.phpt b/ext/dom/tests/modern/spec/Element_getAttributeNodeNS.phpt
index 4cbc2d2558d9e..b993855bae8c7 100644
--- a/ext/dom/tests/modern/spec/Element_getAttributeNodeNS.phpt
+++ b/ext/dom/tests/modern/spec/Element_getAttributeNodeNS.phpt
@@ -7,7 +7,7 @@ dom
echo "--- Get after parsing ---\n";
-$dom = DOM\HTMLDocument::createFromString('');
+$dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
echo "--- After parsing, i.e. without namespace ---\n";
diff --git a/ext/dom/tests/modern/spec/Element_hasAttribute.phpt b/ext/dom/tests/modern/spec/Element_hasAttribute.phpt
index e72fd36672733..0f73ad8459627 100644
--- a/ext/dom/tests/modern/spec/Element_hasAttribute.phpt
+++ b/ext/dom/tests/modern/spec/Element_hasAttribute.phpt
@@ -7,7 +7,7 @@ dom
echo "--- Get after parsing ---\n";
-$dom = DOM\HTMLDocument::createFromString('');
+$dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
var_dump($body->hasAttribute("align"));
var_dump($body->hasAttribute("foo:bar"));
diff --git a/ext/dom/tests/modern/spec/Element_hasAttributeNS.phpt b/ext/dom/tests/modern/spec/Element_hasAttributeNS.phpt
index 6b8820f9452b0..bd24a6afc5f5e 100644
--- a/ext/dom/tests/modern/spec/Element_hasAttributeNS.phpt
+++ b/ext/dom/tests/modern/spec/Element_hasAttributeNS.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
echo "--- After parsing, i.e. without namespace ---\n";
diff --git a/ext/dom/tests/modern/spec/Element_insertAdjacentText.phpt b/ext/dom/tests/modern/spec/Element_insertAdjacentText.phpt
index 94bcaa13b8962..862d1053d8f1f 100644
--- a/ext/dom/tests/modern/spec/Element_insertAdjacentText.phpt
+++ b/ext/dom/tests/modern/spec/Element_insertAdjacentText.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
appendChild($dom->createElement("foo"));
try {
$foo->insertAdjacentText("beforebegin", "bar");
@@ -16,7 +16,7 @@ try {
$foo->insertAdjacentText("afterbegin", "bar");
$foo->insertAdjacentText("beforeend", "baz");
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
var_dump($foo->firstChild->textContent);
var_dump($foo->firstChild->nextSibling->textContent);
diff --git a/ext/dom/tests/modern/spec/Element_prefix_readonly.phpt b/ext/dom/tests/modern/spec/Element_prefix_readonly.phpt
index 37ceda2e4c057..7ebc3efaadc2b 100644
--- a/ext/dom/tests/modern/spec/Element_prefix_readonly.phpt
+++ b/ext/dom/tests/modern/spec/Element_prefix_readonly.phpt
@@ -1,18 +1,18 @@
--TEST--
-Ensure that DOM\Node::$prefix is read-only
+Ensure that Dom\Node::$prefix is read-only
--EXTENSIONS--
dom
--FILE--
createElement('div');
try {
$div->prefix = "foo";
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
-echo $dom->saveXML();
+echo $dom->saveXml();
?>
--EXPECT--
-Cannot modify readonly property DOM\Element::$prefix
+Cannot modify readonly property Dom\Element::$prefix
diff --git a/ext/dom/tests/modern/spec/Element_removeAttribute.phpt b/ext/dom/tests/modern/spec/Element_removeAttribute.phpt
index 20ccb6c109b90..6df71797aa01d 100644
--- a/ext/dom/tests/modern/spec/Element_removeAttribute.phpt
+++ b/ext/dom/tests/modern/spec/Element_removeAttribute.phpt
@@ -7,41 +7,41 @@ dom
echo "--- Remove after parsing ---\n";
-$dom = DOM\HTMLDocument::createFromString('');
+$dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
var_dump($body->removeAttribute("align"));
var_dump($body->removeAttribute("foo:bar"));
-echo $dom->saveHTML($body), "\n";
+echo $dom->saveHtml($body), "\n";
echo "--- Remove after creating without namespace ---\n";
$body->setAttributeNode($attr = $dom->createAttribute("prefix:local"));
$attr->value = "A";
var_dump($body->removeAttribute("prefix:local"));
-echo $dom->saveHTML($body), "\n";
+echo $dom->saveHtml($body), "\n";
echo "--- Remove after creating with namespace ---\n";
$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2"));
$attr->value = "B";
var_dump($body->removeAttribute("prefix:local2"));
-echo $dom->saveHTML($body), "\n";
+echo $dom->saveHtml($body), "\n";
$body->setAttributeNode($attr = $dom->createAttributeNS("urn:a", "prefix:local2"));
$attr->value = "B";
var_dump($body->removeAttribute("Prefix:LOCAL2"));
-echo $dom->saveHTML($body), "\n";
+echo $dom->saveHtml($body), "\n";
echo "--- Remove after creating with namespace case sensitive ---\n";
$element = $dom->createElementNS("urn:a", "a:element");
$attr = $dom->createAttributeNS("urn:a", "Prefix:local2");
$element->setAttributeNode($attr);
-echo $dom->saveHTML($element), "\n";
+echo $dom->saveHtml($element), "\n";
$attr->value = "C";
var_dump($element->removeAttribute("Prefix:local2"));
var_dump($element->removeAttribute("Prefix:LOCAL2"));
var_dump($element->removeAttribute("prefix:local2"));
-echo $dom->saveHTML($element), "\n";
+echo $dom->saveHtml($element), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Element_removeAttributeNS.phpt b/ext/dom/tests/modern/spec/Element_removeAttributeNS.phpt
index 7f31eacda5166..3e0eac8722f20 100644
--- a/ext/dom/tests/modern/spec/Element_removeAttributeNS.phpt
+++ b/ext/dom/tests/modern/spec/Element_removeAttributeNS.phpt
@@ -6,7 +6,7 @@ dom
');
+ $dom = Dom\HTMLDocument::createFromString('');
$body = $dom->getElementsByTagName("body")[0];
return $body;
}
@@ -15,35 +15,35 @@ echo "--- After parsing, i.e. without namespace ---\n";
$body = createFreshBody();
$body->removeAttributeNS(NULL, "align");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body = createFreshBody();
$body->removeAttributeNS("", "align");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body = createFreshBody();
$body->removeAttributeNS(NULL, "ALIGN");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body = createFreshBody();
$body->removeAttributeNS("", "ALIGN");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body = createFreshBody();
$body->removeAttributeNS(NULL, "foo:bar");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body = createFreshBody();
$body->removeAttributeNS("", "foo:bar");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body = createFreshBody();
$body->removeAttributeNS(NULL, "FOO:BAR");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body = createFreshBody();
$body->removeAttributeNS("", "FOO:BAR");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
echo "--- Special legacy case ---\n";
@@ -55,22 +55,22 @@ echo "--- Remove after creating without namespace ---\n";
$body = createFreshBody();
$body->setAttributeNode($attr = $body->ownerDocument->createAttribute("prefix:local"));
$attr->value = "A";
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body->removeAttributeNS(NULL, "prefix:LOCAL");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body->removeAttributeNS(NULL, "prefix:local");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
echo "--- Remove after creating with namespace ---\n";
$body = createFreshBody();
$body->setAttributeNode($attr = $body->ownerDocument->createAttributeNS("urn:a", "prefix:local2"));
$attr->value = "B";
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body->removeAttributeNS("urn:a", "LOCAL2");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
$body->removeAttributeNS("urn:a", "local2");
-echo $body->ownerDocument->saveHTML($body), "\n";
+echo $body->ownerDocument->saveHtml($body), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Element_removeAttribute_edge_cases.phpt b/ext/dom/tests/modern/spec/Element_removeAttribute_edge_cases.phpt
index fc5dbeae04058..e50ef36e31fad 100644
--- a/ext/dom/tests/modern/spec/Element_removeAttribute_edge_cases.phpt
+++ b/ext/dom/tests/modern/spec/Element_removeAttribute_edge_cases.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
try {
$dom->documentElement->removeAttributeNode($dom->createAttribute('test'));
} catch (DOMException $e) {
diff --git a/ext/dom/tests/modern/spec/Element_setAttributeNS.phpt b/ext/dom/tests/modern/spec/Element_setAttributeNS.phpt
index e23492303ac34..a38048a47ce90 100644
--- a/ext/dom/tests/modern/spec/Element_setAttributeNS.phpt
+++ b/ext/dom/tests/modern/spec/Element_setAttributeNS.phpt
@@ -7,13 +7,13 @@ dom
require __DIR__ . "/dump_attr.inc";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container"));
echo "--- xmlns attribute ---\n";
$container->setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:foo", "1");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
dumpAttrs($container);
echo "--- name validation ---\n";
@@ -26,22 +26,22 @@ try {
echo "--- ns attributes with same namespace but different prefix ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container"));
$container->setAttributeNS("urn:a", "x:foo", "1");
$container->setAttributeNS("urn:a", "y:foo", "2");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
dumpAttrs($container);
echo "--- ns attributes with different namespace but same prefix ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container"));
$container->setAttributeNS("urn:a", "x:foo", "1");
$container->setAttributeNS("urn:b", "x:foo", "2");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
dumpAttrs($container);
?>
diff --git a/ext/dom/tests/modern/spec/Element_setAttributeNode.phpt b/ext/dom/tests/modern/spec/Element_setAttributeNode.phpt
index 3379d6b8b3677..c7de0f2314976 100644
--- a/ext/dom/tests/modern/spec/Element_setAttributeNode.phpt
+++ b/ext/dom/tests/modern/spec/Element_setAttributeNode.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Element::setAttributeNode(NS) in the same document
+Dom\Element::setAttributeNode(NS) in the same document
--EXTENSIONS--
dom
--FILE--
appendChild($dom1->createElement("container"));
echo "--- Without namespace ---\n";
@@ -33,7 +33,7 @@ var_dump($container->setAttributeNodeNS($attribute5) === null);
echo "--- Resulting document ---\n";
-echo $dom1->saveHTML(), "\n";
+echo $dom1->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Element_setAttributeNode_adoption.phpt b/ext/dom/tests/modern/spec/Element_setAttributeNode_adoption.phpt
index d395c16355b94..87a2484b5893a 100644
--- a/ext/dom/tests/modern/spec/Element_setAttributeNode_adoption.phpt
+++ b/ext/dom/tests/modern/spec/Element_setAttributeNode_adoption.phpt
@@ -1,16 +1,16 @@
--TEST--
-DOM\Element::setAttributeNode(NS) adopting from another document
+Dom\Element::setAttributeNode(NS) adopting from another document
--EXTENSIONS--
dom
--FILE--
appendChild($dom1->createElement("container"));
echo "--- Without namespace ---\n";
-$dom2 = DOM\HTMLDocument::createEmpty();
+$dom2 = Dom\HTMLDocument::createEmpty();
$attr = $dom2->createAttribute("my-attribute");
$attr->value = "1";
@@ -23,12 +23,12 @@ unset($attr);
echo "--- With namespace ---\n";
-$dom2 = DOM\HTMLDocument::createEmpty();
+$dom2 = Dom\HTMLDocument::createEmpty();
$attr2 = $dom2->createAttributeNS("urn:a", "a:my-attribute");
$attr2->value = "2";
$dom1->documentElement->setAttributeNode($attr2);
-$dom2 = DOM\HTMLDocument::createEmpty();
+$dom2 = Dom\HTMLDocument::createEmpty();
$attr3 = $dom2->createAttributeNS("urn:b", "a:my-attribute");
$attr3->value = "3";
$dom1->documentElement->setAttributeNode($attr3);
@@ -38,7 +38,7 @@ var_dump($attr3->prefix, $attr3->namespaceURI, $attr3->localName);
echo "--- Resulting document ---\n";
-echo $dom1->saveHTML(), "\n";
+echo $dom1->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Element_setAttributeNode_inuse.phpt b/ext/dom/tests/modern/spec/Element_setAttributeNode_inuse.phpt
index 1e2e5e3b15fdc..ddbfbde7e616c 100644
--- a/ext/dom/tests/modern/spec/Element_setAttributeNode_inuse.phpt
+++ b/ext/dom/tests/modern/spec/Element_setAttributeNode_inuse.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Element::setAttributeNode(NS) inuse error
+Dom\Element::setAttributeNode(NS) inuse error
--EXTENSIONS--
dom
--FILE--
appendChild($dom1->createElement("container"));
$attr1 = $dom1->createAttribute("my-attribute");
$attr1->value = "1";
@@ -16,7 +16,7 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $dom1->saveHTML(), "\n";
+echo $dom1->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Element_setAttribute_with_namespace.phpt b/ext/dom/tests/modern/spec/Element_setAttribute_with_namespace.phpt
index d480dbaac5ee2..1d13d6f312324 100644
--- a/ext/dom/tests/modern/spec/Element_setAttribute_with_namespace.phpt
+++ b/ext/dom/tests/modern/spec/Element_setAttribute_with_namespace.phpt
@@ -7,32 +7,32 @@ dom
require __DIR__ . "/dump_attr.inc";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElementNS("urn:a", "container"));
$attrs = [];
-function setAttribute($container, string $name, string $value): DOM\Attr {
+function setAttribute($container, string $name, string $value): Dom\Attr {
$container->setAttribute($name, $value);
return $container->getAttributeNode($name);
}
$attrs[] = setAttribute($container, "foo:bar", "&hello1");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "foo:bar", "&hello2");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "bar", "&hello3");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "xmlns", "&hello4");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "XMLns", "&hello5");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "BAR", "&hello6");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$container->setAttributeNode($dom->createAttributeNS("urn:b", "in:ns"));
$attrs[] = setAttribute($container, "in:ns", "&hello7");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
// Dump at the end to check whether they influenced each other
foreach ($attrs as $attr) {
diff --git a/ext/dom/tests/modern/spec/Element_setAttribute_without_namespace.phpt b/ext/dom/tests/modern/spec/Element_setAttribute_without_namespace.phpt
index 7619988f4f15c..4acc811faa9c4 100644
--- a/ext/dom/tests/modern/spec/Element_setAttribute_without_namespace.phpt
+++ b/ext/dom/tests/modern/spec/Element_setAttribute_without_namespace.phpt
@@ -7,28 +7,28 @@ dom
require __DIR__ . "/dump_attr.inc";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild($dom->createElement("container"));
$attrs = [];
-function setAttribute($container, string $name, string $value): DOM\Attr {
+function setAttribute($container, string $name, string $value): Dom\Attr {
$container->setAttribute($name, $value);
return $container->getAttributeNode($name);
}
$attrs[] = setAttribute($container, "foo:bar", "&hello1");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "foo:bar", "&hello2");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "bar", "&hello3");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "xmlns", "&hello4");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "XMLns", "&hello5");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
$attrs[] = setAttribute($container, "BAR", "&hello6");
-echo $dom->saveHTML($container), "\n";
+echo $dom->saveHtml($container), "\n";
// Dump at the end to check whether they influenced each other
foreach ($attrs as $attr) {
diff --git a/ext/dom/tests/modern/spec/Element_tagName.phpt b/ext/dom/tests/modern/spec/Element_tagName.phpt
index f364ebf3be43e..76327ed531b59 100644
--- a/ext/dom/tests/modern/spec/Element_tagName.phpt
+++ b/ext/dom/tests/modern/spec/Element_tagName.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\Element::$tagName HTML-uppercased qualified name
+Dom\Element::$tagName HTML-uppercased qualified name
--EXTENSIONS--
dom
--FILE--
@@ -7,7 +7,7 @@ dom
echo "--- For HTML document ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
var_dump($dom->createElementNS('http://www.w3.org/1999/xhtml', 'html')->tagName);
var_dump($dom->createElementNS('http://www.w3.org/1999/xhtml/', 'html')->tagName);
var_dump($dom->createElementNS('http://www.w3.org/1999/xhtml', 'foo:html')->tagName);
@@ -17,7 +17,7 @@ var_dump($dom->createElementNS(null, 'html')->tagName);
echo "--- For XML document ---\n";
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
var_dump($dom->createElementNS('http://www.w3.org/1999/xhtml', 'html')->tagName);
var_dump($dom->createElementNS('http://www.w3.org/1999/xhtml/', 'html')->tagName);
var_dump($dom->createElementNS('http://www.w3.org/1999/xhtml', 'foo:html')->tagName);
diff --git a/ext/dom/tests/modern/spec/Element_toggleAttribute.phpt b/ext/dom/tests/modern/spec/Element_toggleAttribute.phpt
index 457663b3cd250..f6dc3b5831879 100644
--- a/ext/dom/tests/modern/spec/Element_toggleAttribute.phpt
+++ b/ext/dom/tests/modern/spec/Element_toggleAttribute.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
appendChild($dom->createElement('container'));
$container->toggleAttribute('hidden');
@@ -13,14 +13,14 @@ $container->toggleAttribute('xmlns:foo');
$container->toggleAttribute('xmlns:bar');
$container->toggleAttribute('xmlns');
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
$container->toggleAttribute('hidden');
$container->toggleAttribute('xmlns:foo');
$container->toggleAttribute('xmlns:bar');
$container->toggleAttribute('xmlns');
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/HTMLDocument_createCDATASection.phpt b/ext/dom/tests/modern/spec/HTMLDocument_createCDATASection.phpt
index de9989510ad79..1787ae29f95d0 100644
--- a/ext/dom/tests/modern/spec/HTMLDocument_createCDATASection.phpt
+++ b/ext/dom/tests/modern/spec/HTMLDocument_createCDATASection.phpt
@@ -1,10 +1,10 @@
--TEST--
-DOM\HTMLDocument::createCDATASection()
+Dom\HTMLDocument::createCDATASection()
--EXTENSIONS--
dom
--FILE--
createCDATASection("foo");
} catch (DOMException $e) {
@@ -18,7 +18,7 @@ try {
echo $e->getMessage(), "\n";
}
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
try {
$dom->createCDATASection("]]>");
} catch (DOMException $e) {
diff --git a/ext/dom/tests/modern/spec/HTMLDocument_createProcessingInstruction.phpt b/ext/dom/tests/modern/spec/HTMLDocument_createProcessingInstruction.phpt
index 7cb459f9866de..f1a60b875b1d2 100644
--- a/ext/dom/tests/modern/spec/HTMLDocument_createProcessingInstruction.phpt
+++ b/ext/dom/tests/modern/spec/HTMLDocument_createProcessingInstruction.phpt
@@ -1,10 +1,10 @@
--TEST--
-DOM\HTMLDocument::createProcessingInstruction()
+Dom\HTMLDocument::createProcessingInstruction()
--EXTENSIONS--
dom
--FILE--
createProcessingInstruction("?>", "");
} catch (DOMException $e) {
@@ -25,7 +25,7 @@ try {
}
$dom->appendChild($dom->createProcessingInstruction("foo", ""));
$dom->appendChild($dom->createProcessingInstruction("foo", "bar"));
-echo $dom->saveHTML();
+echo $dom->saveHtml();
?>
--EXPECT--
int(5)
diff --git a/ext/dom/tests/modern/spec/HTMLDocument_getElementsByTagName.phpt b/ext/dom/tests/modern/spec/HTMLDocument_getElementsByTagName.phpt
index c19a94ada25b8..206ee6e640d9d 100644
--- a/ext/dom/tests/modern/spec/HTMLDocument_getElementsByTagName.phpt
+++ b/ext/dom/tests/modern/spec/HTMLDocument_getElementsByTagName.phpt
@@ -8,7 +8,7 @@ dom
require __DIR__ . "/node_list_dump.inc";
require __DIR__ . "/create_element_util.inc";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$container = $dom->appendChild(createElement($dom, "container"));
$container->appendChild(createElement($dom, "HTML", "1"));
$container->appendChild(createElementNS($dom, "http://www.w3.org/1999/xhtml", "html", "2"));
diff --git a/ext/dom/tests/modern/spec/HTMLDocument_importNode_01.phpt b/ext/dom/tests/modern/spec/HTMLDocument_importNode_01.phpt
index 8108567a04f30..5d5b9938de9a6 100644
--- a/ext/dom/tests/modern/spec/HTMLDocument_importNode_01.phpt
+++ b/ext/dom/tests/modern/spec/HTMLDocument_importNode_01.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -19,7 +19,7 @@ $dom = DOM\XMLDocument::createFromString(<<importNode($dom->documentElement, true);
$dom2->appendChild($imported);
@@ -28,7 +28,7 @@ $default_p = $body->lastElementChild;
var_dump($default_p->prefix);
var_dump($default_p->namespaceURI);
-echo $dom2->saveXML();
+echo $dom2->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt b/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt
index eb015911baac4..38e00defe6223 100644
--- a/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt
+++ b/ext/dom/tests/modern/spec/NamedNodeMap_dimensions.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
$attributes = $dom->documentElement->attributes;
$test_values = [-1, 0, 1, 2, 3, 1.0, 1.1, true, null, "0", "", "1", "8", "a", "b", "c", "d"];
@@ -58,9 +58,9 @@ string(1) "b"
bool(true)
bool(false)
--- true ---
-Cannot access offset of type bool on DOM\NamedNodeMap
+Cannot access offset of type bool on Dom\NamedNodeMap
--- null ---
-Cannot access offset of type null on DOM\NamedNodeMap
+Cannot access offset of type null on Dom\NamedNodeMap
--- "0" ---
string(1) "a"
bool(true)
diff --git a/ext/dom/tests/modern/spec/NamedNodeMap_dimensions_errors.phpt b/ext/dom/tests/modern/spec/NamedNodeMap_dimensions_errors.phpt
index 8f5101c55e4f2..848b1a2c0b02f 100644
--- a/ext/dom/tests/modern/spec/NamedNodeMap_dimensions_errors.phpt
+++ b/ext/dom/tests/modern/spec/NamedNodeMap_dimensions_errors.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
$attributes = $dom->documentElement->attributes;
try {
@@ -16,4 +16,4 @@ try {
?>
--EXPECT--
-Cannot append to DOM\NamedNodeMap
+Cannot append to Dom\NamedNodeMap
diff --git a/ext/dom/tests/modern/spec/NamedNodeMap_getNamedItem.phpt b/ext/dom/tests/modern/spec/NamedNodeMap_getNamedItem.phpt
index ab6f7e027d34f..0e7d021f4e5be 100644
--- a/ext/dom/tests/modern/spec/NamedNodeMap_getNamedItem.phpt
+++ b/ext/dom/tests/modern/spec/NamedNodeMap_getNamedItem.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -36,7 +36,7 @@ var_dump($attributes["xmlns:foo"]->value);
echo "--- On XML document ---\n";
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
$dom->appendChild($dom->importNode($body, true));
$body = $dom->getElementsByTagName('body')->item(0);
diff --git a/ext/dom/tests/modern/spec/NodeList_dimensions.phpt b/ext/dom/tests/modern/spec/NodeList_dimensions.phpt
index a20e1c98ed846..f5fe6480e641d 100644
--- a/ext/dom/tests/modern/spec/NodeList_dimensions.phpt
+++ b/ext/dom/tests/modern/spec/NodeList_dimensions.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
$children = $dom->documentElement->childNodes;
$test_values = [-1, 0, 1, 2, 3, 1.0, 1.1, true, null, "0", "1", "", "foo"];
@@ -58,9 +58,9 @@ string(1) "b"
bool(true)
bool(false)
--- true ---
-Cannot access offset of type bool on DOM\NodeList
+Cannot access offset of type bool on Dom\NodeList
--- null ---
-Cannot access offset of type null on DOM\NodeList
+Cannot access offset of type null on Dom\NodeList
--- "0" ---
string(1) "a"
bool(true)
@@ -70,6 +70,6 @@ string(1) "b"
bool(true)
bool(false)
--- "" ---
-Cannot access offset of type string on DOM\NodeList
+Cannot access offset of type string on Dom\NodeList
--- "foo" ---
-Cannot access offset of type string on DOM\NodeList
+Cannot access offset of type string on Dom\NodeList
diff --git a/ext/dom/tests/modern/spec/NodeList_dimensions_errors.phpt b/ext/dom/tests/modern/spec/NodeList_dimensions_errors.phpt
index 9c0b10e6f7545..bfb882823b787 100644
--- a/ext/dom/tests/modern/spec/NodeList_dimensions_errors.phpt
+++ b/ext/dom/tests/modern/spec/NodeList_dimensions_errors.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
$children = $dom->documentElement->childNodes;
try {
@@ -16,4 +16,4 @@ try {
?>
--EXPECT--
-Cannot append to DOM\NodeList
+Cannot append to Dom\NodeList
diff --git a/ext/dom/tests/modern/spec/Node_appendChild_attribute.phpt b/ext/dom/tests/modern/spec/Node_appendChild_attribute.phpt
index c18e2527c0201..3e3a5674c6a6d 100644
--- a/ext/dom/tests/modern/spec/Node_appendChild_attribute.phpt
+++ b/ext/dom/tests/modern/spec/Node_appendChild_attribute.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::appendChild() with attribute should fail
+Dom\Node::appendChild() with attribute should fail
--EXTENSIONS--
dom
--FILE--
createElement('foo');
$attr = $dom->createAttribute('bar');
diff --git a/ext/dom/tests/modern/spec/Node_appendChild_fragment_multiple_elements.phpt b/ext/dom/tests/modern/spec/Node_appendChild_fragment_multiple_elements.phpt
index 86b90e1608715..fc62d89811b5b 100644
--- a/ext/dom/tests/modern/spec/Node_appendChild_fragment_multiple_elements.phpt
+++ b/ext/dom/tests/modern/spec/Node_appendChild_fragment_multiple_elements.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::appendChild() with fragment of multiple elements
+Dom\Node::appendChild() with fragment of multiple elements
--EXTENSIONS--
dom
--FILE--
createDocumentFragment();
$fragment->appendChild($dom->createElement('foo'));
@@ -17,7 +17,7 @@ try {
echo $e->getMessage(), "\n";
}
-echo $dom->saveXML($fragment), "\n";
+echo $dom->saveXml($fragment), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Node_appendChild_invalid_parent.phpt b/ext/dom/tests/modern/spec/Node_appendChild_invalid_parent.phpt
index 6f2e3f3762a0d..af99bfc380572 100644
--- a/ext/dom/tests/modern/spec/Node_appendChild_invalid_parent.phpt
+++ b/ext/dom/tests/modern/spec/Node_appendChild_invalid_parent.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::appendChild() invalid parent
+Dom\Node::appendChild() invalid parent
--EXTENSIONS--
dom
--FILE--
createTextNode('Hello World');
$cdata = $dom->createCDATASection('Hello World');
diff --git a/ext/dom/tests/modern/spec/Node_baseURI.phpt b/ext/dom/tests/modern/spec/Node_baseURI.phpt
index 80a07fa280db1..b262bda51f654 100644
--- a/ext/dom/tests/modern/spec/Node_baseURI.phpt
+++ b/ext/dom/tests/modern/spec/Node_baseURI.phpt
@@ -5,14 +5,14 @@ dom
--FILE--
appendChild($dom->createElement('html'));
var_dump($html->baseURI);
-$dom = DOM\HTMLDocument::createFromFile(__DIR__ . "/../../empty.html", LIBXML_NOERROR);
+$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/../../empty.html", LIBXML_NOERROR);
var_dump($dom->documentElement->baseURI);
-$dom = DOM\HTMLDocument::createFromString(<<
diff --git a/ext/dom/tests/modern/spec/Node_cloneNode_copy_document_properties.phpt b/ext/dom/tests/modern/spec/Node_cloneNode_copy_document_properties.phpt
index a6928b4a697e0..7894aa0a31318 100644
--- a/ext/dom/tests/modern/spec/Node_cloneNode_copy_document_properties.phpt
+++ b/ext/dom/tests/modern/spec/Node_cloneNode_copy_document_properties.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::cloneNode() should copy the document properties
+Dom\Node::cloneNode() should copy the document properties
--EXTENSIONS--
dom
--FILE--
cloneNode();
$dom->appendChild($dom->createElement("foo"));
diff --git a/ext/dom/tests/modern/spec/Node_getRootNode.phpt b/ext/dom/tests/modern/spec/Node_getRootNode.phpt
index 826a83055feec..b63ce50f98ebc 100644
--- a/ext/dom/tests/modern/spec/Node_getRootNode.phpt
+++ b/ext/dom/tests/modern/spec/Node_getRootNode.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\Node::getRootNode()
+Dom\Node::getRootNode()
--EXTENSIONS--
dom
--FILE--
@@ -7,7 +7,7 @@ dom
// Same as DOMNode_getRootNode.phpt but for modern DOM
-$dom = DOM\XMLDocument::createFromString(' ');
+$dom = Dom\XMLDocument::createFromString(' ');
var_dump($dom->documentElement->firstElementChild->getRootNode() === $dom);
$p = $dom->createElement('p');
diff --git a/ext/dom/tests/modern/spec/Node_insertBefore_01.phpt b/ext/dom/tests/modern/spec/Node_insertBefore_01.phpt
index 7672e8e9719a0..967334bbeba28 100644
--- a/ext/dom/tests/modern/spec/Node_insertBefore_01.phpt
+++ b/ext/dom/tests/modern/spec/Node_insertBefore_01.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::insertBefore() with DocumentFragment and dtd
+Dom\Node::insertBefore() with DocumentFragment and dtd
--EXTENSIONS--
dom
--FILE--
');
+$dom = Dom\HTMLDocument::createFromString('');
$dom->documentElement->remove();
$fragment = $dom->createDocumentFragment();
@@ -17,7 +17,7 @@ try {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Node_insertBefore_02.phpt b/ext/dom/tests/modern/spec/Node_insertBefore_02.phpt
index aa252e7eed098..390dba0f176a0 100644
--- a/ext/dom/tests/modern/spec/Node_insertBefore_02.phpt
+++ b/ext/dom/tests/modern/spec/Node_insertBefore_02.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::insertBefore() with DocumentFragment and a document element
+Dom\Node::insertBefore() with DocumentFragment and a document element
--EXTENSIONS--
dom
--FILE--
');
+$dom = Dom\HTMLDocument::createFromString('');
$fragment = $dom->createDocumentFragment();
$fragment->appendChild($dom->createElement('a'));
@@ -16,7 +16,7 @@ try {
echo $e->getMessage(), "\n";
}
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/Node_isDefaultNamespace.phpt b/ext/dom/tests/modern/spec/Node_isDefaultNamespace.phpt
index 56eee90553c5b..cd89174df7b51 100644
--- a/ext/dom/tests/modern/spec/Node_isDefaultNamespace.phpt
+++ b/ext/dom/tests/modern/spec/Node_isDefaultNamespace.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::isDefaultNamespace()
+Dom\Node::isDefaultNamespace()
--EXTENSIONS--
dom
--FILE--
diff --git a/ext/dom/tests/modern/spec/Node_isEqualNode_01.phpt b/ext/dom/tests/modern/spec/Node_isEqualNode_01.phpt
index 51b5648d8a1b8..c31d825951106 100644
--- a/ext/dom/tests/modern/spec/Node_isEqualNode_01.phpt
+++ b/ext/dom/tests/modern/spec/Node_isEqualNode_01.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::isEqualNode edge cases 01
+Dom\Node::isEqualNode edge cases 01
--EXTENSIONS--
dom
--FILE--
append($dom->createElement("container"));
$e1 = $dom->documentElement->appendChild($dom->createElementNS("urn:example1", "example:foo"));
$e1->after("\n");
@@ -14,11 +14,11 @@ $e2 = $dom->documentElement->appendChild($dom->createElementNS("urn:example2", "
$e2->setAttributeNS("urn:example2", "example2:bar", "baz1");
$e2->setAttributeNS("urn:example1", "example2:bar", "baz2");
-$dom2 = DOM\HTMLDocument::createFromString("" . $dom->saveHTML());
+$dom2 = Dom\HTMLDocument::createFromString("" . $dom->saveHtml());
// Shouldn't match because the attributes can't roundtrip.
-var_dump($dom->saveHTML($dom->getElementsByTagName("container")[0]));
-var_dump($dom2->saveHTML($dom2->getElementsByTagName("container")[0]));
+var_dump($dom->saveHtml($dom->getElementsByTagName("container")[0]));
+var_dump($dom2->saveHtml($dom2->getElementsByTagName("container")[0]));
var_dump($dom->getElementsByTagName("container")[0]->isEqualNode($dom2->getElementsByTagName("container")[0]));
?>
diff --git a/ext/dom/tests/modern/spec/Node_isEqualNode_02.phpt b/ext/dom/tests/modern/spec/Node_isEqualNode_02.phpt
index bc7f23a7d9871..32728595ca509 100644
--- a/ext/dom/tests/modern/spec/Node_isEqualNode_02.phpt
+++ b/ext/dom/tests/modern/spec/Node_isEqualNode_02.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::isEqualNode edge cases 02
+Dom\Node::isEqualNode edge cases 02
--EXTENSIONS--
dom
--FILE--
append($dom->createElement("container"));
$e1 = $dom->documentElement->appendChild($dom->createElement("foo1"));
$e1->after("\n");
@@ -17,10 +17,10 @@ $e2->setAttribute("bar2", "baz");
$e2->setAttributeNodeNS($child = $dom->createAttributeNS("http://example.com", "foo:bar"));
$e2->removeAttributeNode($child);
-$dom2 = DOM\HTMLDocument::createFromString("" . $dom->saveHTML());
+$dom2 = Dom\HTMLDocument::createFromString("" . $dom->saveHtml());
-var_dump($dom->saveHTML($dom->getElementsByTagName("container")[0]));
-var_dump($dom2->saveHTML($dom2->getElementsByTagName("container")[0]));
+var_dump($dom->saveHtml($dom->getElementsByTagName("container")[0]));
+var_dump($dom2->saveHtml($dom2->getElementsByTagName("container")[0]));
var_dump($dom->getElementsByTagName("container")[0]->isEqualNode($dom2->getElementsByTagName("container")[0]));
?>
diff --git a/ext/dom/tests/modern/spec/Node_lookupNamespaceURI.phpt b/ext/dom/tests/modern/spec/Node_lookupNamespaceURI.phpt
index c4e1015144d9a..9512891709af6 100644
--- a/ext/dom/tests/modern/spec/Node_lookupNamespaceURI.phpt
+++ b/ext/dom/tests/modern/spec/Node_lookupNamespaceURI.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::lookupNamespaceURI()
+Dom\Node::lookupNamespaceURI()
--EXTENSIONS--
dom
--FILE--
@@ -56,7 +56,7 @@ var_dump($body->lookupNamespaceURI(NULL));
var_dump($body->lookupNamespaceURI("a"));
echo "--- lookup in empty document ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
var_dump($dom->lookupNamespaceURI(""));
var_dump($dom->lookupNamespaceURI(NULL));
var_dump($dom->lookupNamespaceURI("a"));
diff --git a/ext/dom/tests/modern/spec/Node_lookupPrefix.phpt b/ext/dom/tests/modern/spec/Node_lookupPrefix.phpt
index 4bb52004027a0..913ede69cec1e 100644
--- a/ext/dom/tests/modern/spec/Node_lookupPrefix.phpt
+++ b/ext/dom/tests/modern/spec/Node_lookupPrefix.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::lookupPrefix()
+Dom\Node::lookupPrefix()
--EXTENSIONS--
dom
--FILE--
diff --git a/ext/dom/tests/modern/spec/Node_nodeName.phpt b/ext/dom/tests/modern/spec/Node_nodeName.phpt
index 84343731a00a0..ac669b6ec906c 100644
--- a/ext/dom/tests/modern/spec/Node_nodeName.phpt
+++ b/ext/dom/tests/modern/spec/Node_nodeName.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\Node::$nodeName
+Dom\Node::$nodeName
--EXTENSIONS--
dom
--FILE--
@@ -7,7 +7,7 @@ dom
echo "--- For HTML document ---\n";
-$dom = DOM\HTMLDocument::createEmpty();
+$dom = Dom\HTMLDocument::createEmpty();
$dom->appendChild($dom->createElement('container'));
var_dump($dom->createAttributeNS('http://www.w3.org/1999/xhtml', 'html')->nodeName);
@@ -24,7 +24,7 @@ var_dump($dom->createElementNS(null, 'html')->nodeName);
echo "--- For XML document ---\n";
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
$dom->appendChild($dom->createElement('container'));
var_dump($dom->createAttributeNS('http://www.w3.org/1999/xhtml', 'html')->nodeName);
diff --git a/ext/dom/tests/modern/spec/Node_nodeValue_element.phpt b/ext/dom/tests/modern/spec/Node_nodeValue_element.phpt
index 749614ea9fc71..a3e23b1381d4f 100644
--- a/ext/dom/tests/modern/spec/Node_nodeValue_element.phpt
+++ b/ext/dom/tests/modern/spec/Node_nodeValue_element.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::$nodeValue on an element
+Dom\Node::$nodeValue on an element
--EXTENSIONS--
dom
--FILE--
createElement("foo");
$foo->textContent = "bar";
var_dump($foo->nodeValue);
diff --git a/ext/dom/tests/modern/spec/Node_normalize.phpt b/ext/dom/tests/modern/spec/Node_normalize.phpt
index 04848e5d019a7..7233ff4c5bd8b 100644
--- a/ext/dom/tests/modern/spec/Node_normalize.phpt
+++ b/ext/dom/tests/modern/spec/Node_normalize.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\Node::normalize()
+Dom\Node::normalize()
--EXTENSIONS--
dom
--FILE--
@@ -19,7 +19,7 @@ dom
* Normalize title. Calculate the number of title text nodes (1).
*/
-$doc = DOM\XMLDocument::createEmpty();
+$doc = Dom\XMLDocument::createEmpty();
$root = $doc->createElement('book');
$doc->appendChild($root);
diff --git a/ext/dom/tests/modern/spec/Node_normalize_edge_case.phpt b/ext/dom/tests/modern/spec/Node_normalize_edge_case.phpt
index 03b75ede7f392..0e3a52b1bbc2a 100644
--- a/ext/dom/tests/modern/spec/Node_normalize_edge_case.phpt
+++ b/ext/dom/tests/modern/spec/Node_normalize_edge_case.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::normalize() edge case
+Dom\Node::normalize() edge case
--EXTENSIONS--
dom
--FILE--
appendChild($doc->createElement("container"));
$container->appendChild($doc->createTextNode(""));
@@ -14,7 +14,7 @@ $container->appendChild($doc->createTextNode(""));
$doc->normalize();
-echo $doc->saveXML(), "\n";
+echo $doc->saveXml(), "\n";
var_dump($middle->textContent);
diff --git a/ext/dom/tests/modern/spec/Node_replaceChild_edge_cases.phpt b/ext/dom/tests/modern/spec/Node_replaceChild_edge_cases.phpt
index e76fdc62ee730..afa6d1e8a8153 100644
--- a/ext/dom/tests/modern/spec/Node_replaceChild_edge_cases.phpt
+++ b/ext/dom/tests/modern/spec/Node_replaceChild_edge_cases.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\Node::replaceChild() edge cases
+Dom\Node::replaceChild() edge cases
--EXTENSIONS--
dom
--FILE--
");
+$dom = Dom\HTMLDocument::createFromString("");
$dom->documentElement->remove();
$parent = $dom->createElement("parent");
$child = $dom->createElement("child");
@@ -46,7 +46,7 @@ try {
echo "--- Invalid child to replace with ---\n";
try {
- $entityReference = $dom->importNode(DOM\XMLDocument::createEmpty()->createEntityReference("foo"));
+ $entityReference = $dom->importNode(Dom\XMLDocument::createEmpty()->createEntityReference("foo"));
$parent->replaceChild($entityReference, $child);
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
@@ -108,14 +108,14 @@ try {
echo "--- Replace parent with itself ---\n";
$dom->replaceChild($parent, $parent);
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
echo "--- Replace parent with single-child fragment ---\n";
$fragment = $dom->createDocumentFragment();
$fragment->appendChild($dom->createElement("new-child"));
$dom->replaceChild($fragment, $parent);
-echo $dom->saveHTML(), "\n";
+echo $dom->saveHtml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/ParentNode_append_exception_consistency.phpt b/ext/dom/tests/modern/spec/ParentNode_append_exception_consistency.phpt
index a8a65ca7bc58b..67a964a7ec515 100644
--- a/ext/dom/tests/modern/spec/ParentNode_append_exception_consistency.phpt
+++ b/ext/dom/tests/modern/spec/ParentNode_append_exception_consistency.phpt
@@ -4,7 +4,7 @@ Consistency of parent node after exception in ParentNode::append()
dom
--FILE--
createDocumentFragment();
$fragment->append($element = $dom->createElement("foo"));
$fragment->append($dom->createElement("bar"));
@@ -18,7 +18,7 @@ var_dump($element->parentNode);
?>
--EXPECT--
Exception: Cannot have more than one element child in a document
-object(DOM\DocumentFragment)#2 (17) {
+object(Dom\DocumentFragment)#2 (17) {
["firstElementChild"]=>
string(22) "(object value omitted)"
["lastElementChild"]=>
diff --git a/ext/dom/tests/modern/spec/ParentNode_edge_case.phpt b/ext/dom/tests/modern/spec/ParentNode_edge_case.phpt
index 5df27d5a27657..367f1437c67df 100644
--- a/ext/dom/tests/modern/spec/ParentNode_edge_case.phpt
+++ b/ext/dom/tests/modern/spec/ParentNode_edge_case.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
createElement('container');
try {
$container->append($dom);
diff --git a/ext/dom/tests/modern/spec/ParentNode_hierarchy_text_nodes.phpt b/ext/dom/tests/modern/spec/ParentNode_hierarchy_text_nodes.phpt
index a4ebc59450700..f81450ca261e4 100644
--- a/ext/dom/tests/modern/spec/ParentNode_hierarchy_text_nodes.phpt
+++ b/ext/dom/tests/modern/spec/ParentNode_hierarchy_text_nodes.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
append("bar");
diff --git a/ext/dom/tests/modern/spec/ProcessingInstruction_data_manipulation.phpt b/ext/dom/tests/modern/spec/ProcessingInstruction_data_manipulation.phpt
index 498561a8b7885..33198c8552aa9 100644
--- a/ext/dom/tests/modern/spec/ProcessingInstruction_data_manipulation.phpt
+++ b/ext/dom/tests/modern/spec/ProcessingInstruction_data_manipulation.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
$pi = $dom->documentElement->firstChild;
diff --git a/ext/dom/tests/modern/spec/Text_splitText_edge_case.phpt b/ext/dom/tests/modern/spec/Text_splitText_edge_case.phpt
index 5b46a2ba8dcfe..4bd79b9b4a8ba 100644
--- a/ext/dom/tests/modern/spec/Text_splitText_edge_case.phpt
+++ b/ext/dom/tests/modern/spec/Text_splitText_edge_case.phpt
@@ -1,10 +1,10 @@
--TEST--
-DOM\Text:splitText() edge case
+Dom\Text:splitText() edge case
--EXTENSIONS--
dom
--FILE--
createTextNode('Hello World!');
var_dump($text->splitText(5)->wholeText);
try {
@@ -20,5 +20,5 @@ try {
?>
--EXPECT--
string(7) " World!"
-DOM\Text::splitText(): Argument #1 ($offset) must be greater than or equal to 0
+Dom\Text::splitText(): Argument #1 ($offset) must be greater than or equal to 0
Index Size Error
diff --git a/ext/dom/tests/modern/spec/XMLDocument_getElementsByTagName.phpt b/ext/dom/tests/modern/spec/XMLDocument_getElementsByTagName.phpt
index ca521c6ff2cbd..4fa06f5e88d4d 100644
--- a/ext/dom/tests/modern/spec/XMLDocument_getElementsByTagName.phpt
+++ b/ext/dom/tests/modern/spec/XMLDocument_getElementsByTagName.phpt
@@ -8,7 +8,7 @@ dom
require __DIR__ . "/node_list_dump.inc";
require __DIR__ . "/create_element_util.inc";
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
$container = $dom->appendChild(createElement($dom, "container"));
$container->appendChild(createElement($dom, "HTML", "1"));
$container->appendChild(createElementNS($dom, "http://www.w3.org/1999/xhtml", "html", "2"));
diff --git a/ext/dom/tests/modern/spec/XMLDocument_version.phpt b/ext/dom/tests/modern/spec/XMLDocument_version.phpt
index accc06ce3d77f..82f38839ea27d 100644
--- a/ext/dom/tests/modern/spec/XMLDocument_version.phpt
+++ b/ext/dom/tests/modern/spec/XMLDocument_version.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
var_dump($dom->xmlVersion);
foreach (['0.1', '1.0', '1.1', '', 'foo'] as $version) {
diff --git a/ext/dom/tests/modern/spec/appendChild_dtd_legacy.phpt b/ext/dom/tests/modern/spec/appendChild_dtd_legacy.phpt
index 25a106479f16f..20a69b3b545dd 100644
--- a/ext/dom/tests/modern/spec/appendChild_dtd_legacy.phpt
+++ b/ext/dom/tests/modern/spec/appendChild_dtd_legacy.phpt
@@ -27,7 +27,7 @@ try {
} catch (DOMException $e) {
echo $e->getMessage(), "\n";
}
-echo $other->saveXML();
+echo $other->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/append_text_nodes_invalid_hierarchy.phpt b/ext/dom/tests/modern/spec/append_text_nodes_invalid_hierarchy.phpt
index 5b66c030a4f19..ea530d675c3cf 100644
--- a/ext/dom/tests/modern/spec/append_text_nodes_invalid_hierarchy.phpt
+++ b/ext/dom/tests/modern/spec/append_text_nodes_invalid_hierarchy.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
append("foo", "bar", "baz", $dom);
@@ -19,7 +19,7 @@ try {
echo $e->getMessage(), "\n";
}
-var_dump($dom->saveHTML());
+var_dump($dom->saveHtml());
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/attribute_entity_expansion.phpt b/ext/dom/tests/modern/spec/attribute_entity_expansion.phpt
index 19a8f91024eb3..2475a5e13ff91 100644
--- a/ext/dom/tests/modern/spec/attribute_entity_expansion.phpt
+++ b/ext/dom/tests/modern/spec/attribute_entity_expansion.phpt
@@ -4,36 +4,36 @@ Attribute entity expansion
dom
--FILE--
createElement('elt');
$doc->appendChild($elt);
$elt->setAttribute('a','&');
-print $doc->saveHTML($elt) . "\n";
+print $doc->saveHtml($elt) . "\n";
$attr = $elt->getAttributeNode('a');
$attr->value = '&';
print "$attr->value\n";
-print $doc->saveHTML($elt) . "\n";
+print $doc->saveHtml($elt) . "\n";
$attr->removeChild($attr->firstChild);
-print $doc->saveHTML($elt) . "\n";
+print $doc->saveHtml($elt) . "\n";
$attr->nodeValue = '&';
print "$attr->nodeValue\n";
-print $doc->saveHTML($elt) . "\n";
+print $doc->saveHtml($elt) . "\n";
$attr->nodeValue = '&';
print "$attr->nodeValue\n";
-print $doc->saveHTML($elt) . "\n";
+print $doc->saveHtml($elt) . "\n";
$elt->removeAttributeNode($attr);
$elt->setAttributeNS('http://www.w3.org/2000/svg', 'svg:id','&');
-print $doc->saveHTML($elt) . "\n";
+print $doc->saveHtml($elt) . "\n";
$attr = $elt->getAttributeNodeNS('http://www.w3.org/2000/svg', 'id');
$attr->value = '<&';
print "$attr->value\n";
-print $doc->saveHTML($elt) . "\n";
+print $doc->saveHtml($elt) . "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/attribute_entity_expansion_legacy.phpt b/ext/dom/tests/modern/spec/attribute_entity_expansion_legacy.phpt
index 9b8ed50801f5e..72aa18c9da198 100644
--- a/ext/dom/tests/modern/spec/attribute_entity_expansion_legacy.phpt
+++ b/ext/dom/tests/modern/spec/attribute_entity_expansion_legacy.phpt
@@ -8,32 +8,32 @@ $doc = new DOMDocument;
$elt = $doc->createElement('elt');
$doc->appendChild($elt);
$elt->setAttribute('a','&');
-print $doc->saveXML($elt) . "\n";
+print $doc->saveXml($elt) . "\n";
$attr = $elt->getAttributeNode('a');
$attr->value = '&';
print "$attr->value\n";
-print $doc->saveXML($elt) . "\n";
+print $doc->saveXml($elt) . "\n";
$attr->removeChild($attr->firstChild);
-print $doc->saveXML($elt) . "\n";
+print $doc->saveXml($elt) . "\n";
$attr->nodeValue = '&';
print "$attr->nodeValue\n";
-print $doc->saveXML($elt) . "\n";
+print $doc->saveXml($elt) . "\n";
$attr->nodeValue = '&';
print "$attr->nodeValue\n";
-print $doc->saveXML($elt) . "\n";
+print $doc->saveXml($elt) . "\n";
$elt->removeAttributeNode($attr);
$elt->setAttributeNS('http://www.w3.org/2000/svg', 'svg:id','&');
-print $doc->saveXML($elt) . "\n";
+print $doc->saveXml($elt) . "\n";
$attr = $elt->getAttributeNodeNS('http://www.w3.org/2000/svg', 'id');
$attr->value = '<&';
print "$attr->value\n";
-print $doc->saveXML($elt) . "\n";
+print $doc->saveXml($elt) . "\n";
?>
--EXPECTF--
diff --git a/ext/dom/tests/modern/spec/bug47530.phpt b/ext/dom/tests/modern/spec/bug47530.phpt
index 16d3078d07b98..847296cbece88 100644
--- a/ext/dom/tests/modern/spec/bug47530.phpt
+++ b/ext/dom/tests/modern/spec/bug47530.phpt
@@ -6,23 +6,23 @@ dom
');
+ $doc = Dom\XMLDocument::createFromString(' ');
$root = $doc->documentElement;
$frag = $doc->createDocumentFragment();
$frag->appendChild($doc->importNode($root->firstChild));
$root->appendChild($frag);
- echo $doc->saveXML(), "\n";
+ echo $doc->saveXml(), "\n";
}
function test_document_fragment_without_import() {
- $doc = DOM\XMLDocument::createFromString(' ');
+ $doc = Dom\XMLDocument::createFromString(' ');
$frag = $doc->createDocumentFragment();
$frag->appendChild($doc->createElementNS('https://php.net/bar', 'bar'));
$frag->appendChild($doc->createElementNS('', 'bar'));
$element = $doc->documentElement->firstChild;
$element->appendChild($frag);
unset($frag); // Free fragment, should not break getting the namespaceURI below
- echo $doc->saveXML(), "\n";
+ echo $doc->saveXml(), "\n";
unset($doc);
var_dump($element->firstChild->tagName);
var_dump($element->firstChild->namespaceURI);
@@ -40,13 +40,13 @@ function test_document_import() {
XML;
- $dom = DOM\XMLDocument::createFromString($xml);
+ $dom = Dom\XMLDocument::createFromString($xml);
- $dom2 = DOM\XMLDocument::createEmpty();
+ $dom2 = Dom\XMLDocument::createEmpty();
$importedNode = $dom2->importNode($dom->documentElement, true);
$dom2->appendChild($importedNode);
- echo $dom2->saveXML(), "\n";
+ echo $dom2->saveXml(), "\n";
}
function test_partial_document_import() {
@@ -61,9 +61,9 @@ function test_partial_document_import() {
XML;
- $dom = DOM\XMLDocument::createFromString($xml);
+ $dom = Dom\XMLDocument::createFromString($xml);
- $dom2 = DOM\XMLDocument::createFromString(' ');
+ $dom2 = Dom\XMLDocument::createFromString(' ');
$importedNode = $dom2->importNode($dom->documentElement, true);
$dom2->documentElement->appendChild($importedNode);
@@ -71,28 +71,28 @@ XML;
unset($importedNode);
unset($dom);
- echo $dom2->saveXML(), "\n";
+ echo $dom2->saveXml(), "\n";
}
function test_document_import_with_attributes() {
- $dom = DOM\XMLDocument::createFromString('');
- $dom2 = DOM\XMLDocument::createFromString('
');
+ $dom = Dom\XMLDocument::createFromString('');
+ $dom2 = Dom\XMLDocument::createFromString('
');
$dom2->documentElement->appendChild($dom2->importNode($dom->documentElement->firstChild));
- echo $dom2->saveXML(), "\n";
+ echo $dom2->saveXml(), "\n";
$dom2->documentElement->firstChild->appendChild($dom2->importNode($dom->documentElement->firstChild->nextSibling));
- echo $dom2->saveXML(), "\n";
+ echo $dom2->saveXml(), "\n";
}
function test_appendChild_with_shadowing() {
- $dom = DOM\XMLDocument::createFromString(' ');
+ $dom = Dom\XMLDocument::createFromString(' ');
$a = $dom->documentElement->firstElementChild;
$b = $a->nextSibling;
$b->remove();
$a->appendChild($b);
- echo $dom->saveXML(), "\n";
+ echo $dom->saveXml(), "\n";
}
echo "-- Test document fragment with import --\n";
diff --git a/ext/dom/tests/modern/spec/bug47847.phpt b/ext/dom/tests/modern/spec/bug47847.phpt
index 70a0d7bc13589..5318e58c64e46 100644
--- a/ext/dom/tests/modern/spec/bug47847.phpt
+++ b/ext/dom/tests/modern/spec/bug47847.phpt
@@ -4,7 +4,7 @@ Bug #47847 (importNode loses the namespace of an XML element)
dom
--FILE--
@@ -13,11 +13,11 @@ $fromdom = DOM\XMLDocument::createFromString(<<
XML);
-$aDOM = DOM\XMLDocument::createEmpty();
+$aDOM = Dom\XMLDocument::createEmpty();
$imported = $aDOM->importNode($fromdom->documentElement->firstElementChild, true);
$aDOM->appendChild($imported);
-echo $aDOM->saveXML(), "\n";
+echo $aDOM->saveXml(), "\n";
var_dump($aDOM->documentElement->firstElementChild->prefix);
?>
diff --git a/ext/dom/tests/modern/spec/bug55294.phpt b/ext/dom/tests/modern/spec/bug55294.phpt
index b0acd5f2118cf..a99d17679b94d 100644
--- a/ext/dom/tests/modern/spec/bug55294.phpt
+++ b/ext/dom/tests/modern/spec/bug55294.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -14,11 +14,11 @@ $aDOM = DOM\XMLDocument::createFromString(<<importNode($aDOM->getElementsByTagNameNS('http://example.com/A', 'B')->item(0), true);
$bDOM->appendChild($node);
-echo $bDOM->saveXML(), "\n";
+echo $bDOM->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/bug81468.phpt b/ext/dom/tests/modern/spec/bug81468.phpt
index 3e0835ece1c49..a56dff94c70ff 100644
--- a/ext/dom/tests/modern/spec/bug81468.phpt
+++ b/ext/dom/tests/modern/spec/bug81468.phpt
@@ -7,23 +7,23 @@ dom
// Note: the original expectation from https://bugs.php.net/bug.php?id=81468 isn't *entirely* right
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
$dom
->appendChild($dom->createElementNS('some:namespace', 'foo'))
->appendChild($dom->createElement('bar'));
-echo ($xml = $dom->saveXML()), "\n";
+echo ($xml = $dom->saveXml()), "\n";
-$xpath = new DOM\XPath($dom);
+$xpath = new Dom\XPath($dom);
$xpath->registerNamespace('n', 'some:namespace');
echo "/n:foo/bar -> ", count($xpath->query('/n:foo/bar')), "\n";
echo "/n:foo/n:bar -> ", count($xpath->query('/n:foo/n:bar')), "\n";
//
-$dom = DOM\XMLDocument::createFromString($xml);
-echo ($xml = $dom->saveXML()), "\n";
+$dom = Dom\XMLDocument::createFromString($xml);
+echo ($xml = $dom->saveXml()), "\n";
-$xpath = new DOM\XPath($dom);
+$xpath = new Dom\XPath($dom);
$xpath->registerNamespace('n', 'some:namespace');
echo "/n:foo/bar -> ", count($xpath->query('/n:foo/bar')), "\n";
echo "/n:foo/n:bar -> ", count($xpath->query('/n:foo/n:bar')), "\n";
diff --git a/ext/dom/tests/modern/spec/clone_conflicting_namespace_prefix.phpt b/ext/dom/tests/modern/spec/clone_conflicting_namespace_prefix.phpt
index b2afdfad3b74d..29259c9c8e126 100644
--- a/ext/dom/tests/modern/spec/clone_conflicting_namespace_prefix.phpt
+++ b/ext/dom/tests/modern/spec/clone_conflicting_namespace_prefix.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -20,7 +20,7 @@ XML);
$dom->documentElement->firstElementChild->setAttributeNS("urn:y", "a:foo", "bar");
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
$clone = clone $dom->documentElement->firstElementChild;
var_dump($clone->nodeName, $clone->namespaceURI);
@@ -29,7 +29,7 @@ foreach ($clone->attributes as $attr) {
var_dump($attr->name, $attr->namespaceURI);
}
-echo $dom->saveXML($clone), "\n";
+echo $dom->saveXml($clone), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/clone_document.phpt b/ext/dom/tests/modern/spec/clone_document.phpt
index 8a855bcb23ce4..6f23c888e8090 100644
--- a/ext/dom/tests/modern/spec/clone_document.phpt
+++ b/ext/dom/tests/modern/spec/clone_document.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -28,19 +28,19 @@ var_dump($dom->getElementsByTagName("child2")[0]->firstChild->nodeName);
echo "---\n";
$clone = clone $dom;
-echo $clone->saveXML(), "\n";
+echo $clone->saveXml(), "\n";
var_dump($clone->getElementsByTagName("child2")[0]->firstChild->nodeName);
echo "---\n";
$clone = $dom->cloneNode(false);
-echo $clone->saveXML(), "\n";
+echo $clone->saveXml(), "\n";
echo "---\n";
$clone = $dom->documentElement->cloneNode(false);
-echo $clone->ownerDocument->saveXML($clone), "\n";
+echo $clone->ownerDocument->saveXml($clone), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/clone_dtd_node.phpt b/ext/dom/tests/modern/spec/clone_dtd_node.phpt
index 7fd74022eab45..f0b78aec9b140 100644
--- a/ext/dom/tests/modern/spec/clone_dtd_node.phpt
+++ b/ext/dom/tests/modern/spec/clone_dtd_node.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\HTMLDocument::createFromString('');
$dt1 = clone $dom->doctype;
var_dump($dt1 === $dom->doctype);
diff --git a/ext/dom/tests/modern/spec/clone_entity_reference.phpt b/ext/dom/tests/modern/spec/clone_entity_reference.phpt
index b42d33e10059e..aed1bc850c2c9 100644
--- a/ext/dom/tests/modern/spec/clone_entity_reference.phpt
+++ b/ext/dom/tests/modern/spec/clone_entity_reference.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -14,14 +14,14 @@ $dom = DOM\XMLDocument::createFromString(<<documentElement->cloneNode(true);
-echo $dom->saveXML($clone), "\n";
+echo $dom->saveXml($clone), "\n";
var_dump($clone->firstChild->firstChild);
?>
--EXPECTF--
&foo;
-object(DOM\Entity)#4 (17) {
+object(Dom\Entity)#4 (17) {
["publicId"]=>
NULL
["systemId"]=>
diff --git a/ext/dom/tests/modern/spec/clone_text_nodes.phpt b/ext/dom/tests/modern/spec/clone_text_nodes.phpt
index 6809dc7690050..88ccad36fdf3c 100644
--- a/ext/dom/tests/modern/spec/clone_text_nodes.phpt
+++ b/ext/dom/tests/modern/spec/clone_text_nodes.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
appendChild($dom->createElementNS("urn:a", "a:root"));
$root->setAttribute("foo", "bar");
@@ -17,19 +17,19 @@ $child->appendChild($dom->createTextNode("c"));
$child2 = $root->appendChild($dom->createElement("child2"));
$child2->appendChild($dom->createTextNode("d"));
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
$clone = clone $root;
var_dump($clone->firstChild->textContent);
var_dump($clone->firstChild->nextSibling->textContent);
var_dump($clone->firstChild->nextSibling->nextSibling->textContent);
-echo $dom->saveXML($clone), "\n";
+echo $dom->saveXml($clone), "\n";
$clone = $child2->cloneNode(true);
-echo $dom->saveXML($clone), "\n";
+echo $dom->saveXml($clone), "\n";
$clone = $child2->cloneNode(false);
-echo $dom->saveXML($clone), "\n";
+echo $dom->saveXml($clone), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/default_namespace_move.phpt b/ext/dom/tests/modern/spec/default_namespace_move.phpt
index ee6d43fce82a0..1b937087f6ead 100644
--- a/ext/dom/tests/modern/spec/default_namespace_move.phpt
+++ b/ext/dom/tests/modern/spec/default_namespace_move.phpt
@@ -5,18 +5,18 @@ dom
--FILE--
appendChild($dom->createElementNS('urn:a', 'foo:bar'));
$child = $root->appendChild($dom->createElementNS('urn:a', 'foo:baz'));
$child->setAttributeNS("urn:b", "foo:attr", "value");
$root->remove();
$dom->appendChild($child);
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
-$dom2 = DOM\XMLDocument::createEmpty();
+$dom2 = Dom\XMLDocument::createEmpty();
$child = $dom2->importNode($child, true);
$dom2->appendChild($child);
-echo $dom2->saveXML(), "\n";
+echo $dom2->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/documentURI_URL.phpt b/ext/dom/tests/modern/spec/documentURI_URL.phpt
index 20ba9bbb04493..3e5a797eae67c 100644
--- a/ext/dom/tests/modern/spec/documentURI_URL.phpt
+++ b/ext/dom/tests/modern/spec/documentURI_URL.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
var_dump($dom->documentURI);
var_dump($dom->URL);
@@ -29,7 +29,7 @@ var_dump($dom->URL);
--EXPECTF--
string(%d) "%s"
string(%d) "%s"
-Cannot assign null to property DOM\Document::$URL of type string
+Cannot assign null to property Dom\Document::$URL of type string
string(0) ""
string(0) ""
string(%d) "%s"
diff --git a/ext/dom/tests/modern/spec/dom_parsing_gh44.phpt b/ext/dom/tests/modern/spec/dom_parsing_gh44.phpt
index e25e48a1aa11e..042a6039cc990 100644
--- a/ext/dom/tests/modern/spec/dom_parsing_gh44.phpt
+++ b/ext/dom/tests/modern/spec/dom_parsing_gh44.phpt
@@ -5,9 +5,9 @@ dom
--FILE--
')->documentElement;
+$root = Dom\XMLDocument::createFromString(' ')->documentElement;
$root->firstChild->setAttributeNS('uri3', 'attr1', 'value1');
-echo $root->ownerDocument->saveXML(), "\n";
+echo $root->ownerDocument->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/dom_parsing_gh45.phpt b/ext/dom/tests/modern/spec/dom_parsing_gh45.phpt
index bd13c848e0e4f..2b47f409e079e 100644
--- a/ext/dom/tests/modern/spec/dom_parsing_gh45.phpt
+++ b/ext/dom/tests/modern/spec/dom_parsing_gh45.phpt
@@ -5,11 +5,11 @@ dom
--FILE--
')->documentElement;
+$root = Dom\XMLDocument::createFromString(' ')->documentElement;
$root->firstChild->setAttributeNS('u1', 'name', 'v');
$attr = $root->firstChild->getAttributeNodeNS("u1", "name");
var_dump($attr->prefix, $attr->namespaceURI);
-echo $root->ownerDocument->saveXML($root), "\n";
+echo $root->ownerDocument->saveXml($root), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/dom_parsing_gh47.phpt b/ext/dom/tests/modern/spec/dom_parsing_gh47.phpt
index 16cd4abd41307..55bc816f1b9a5 100644
--- a/ext/dom/tests/modern/spec/dom_parsing_gh47.phpt
+++ b/ext/dom/tests/modern/spec/dom_parsing_gh47.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -23,10 +23,10 @@ $document = DOM\XMLDocument::createFromString(<<
XML);
-echo $document->saveXML(), "\n";
+echo $document->saveXml(), "\n";
$people = $document->getElementsByTagNameNS(null, 'people')->item(0);
-echo $document->saveXML($people), "\n";
+echo $document->saveXml($people), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/dom_parsing_gh47_bis.phpt b/ext/dom/tests/modern/spec/dom_parsing_gh47_bis.phpt
index c142702ebda93..4c01c2041a26f 100644
--- a/ext/dom/tests/modern/spec/dom_parsing_gh47_bis.phpt
+++ b/ext/dom/tests/modern/spec/dom_parsing_gh47_bis.phpt
@@ -7,11 +7,11 @@ dom
// Adapted from https://github.com/web-platform-tests/wpt/blob/master/domparsing/XMLSerializer-serializeToString.html
-$dom = DOM\XMLDocument::createFromString(' ');
-echo $dom->saveXML(), "\n";
+$dom = Dom\XMLDocument::createFromString(' ');
+echo $dom->saveXml(), "\n";
-$dom = DOM\XMLDocument::createFromString(' ');
-echo $dom->saveXML(), "\n";
+$dom = Dom\XMLDocument::createFromString(' ');
+echo $dom->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/gh11404_1.phpt b/ext/dom/tests/modern/spec/gh11404_1.phpt
index 884f3560c064e..ec9c0a30f7568 100644
--- a/ext/dom/tests/modern/spec/gh11404_1.phpt
+++ b/ext/dom/tests/modern/spec/gh11404_1.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
');
+$dom1 = Dom\XMLDocument::createFromString(' ');
$nodeA = $dom1->createElement('none');
$nodeB = $dom1->createElementNS(null, 'none');
@@ -13,7 +13,7 @@ $nodeB = $dom1->createElementNS(null, 'none');
$dom1->documentElement->appendChild($nodeA);
$dom1->documentElement->appendChild($nodeB);
-echo $dom1->saveXML(), "\n";
+echo $dom1->saveXml(), "\n";
var_dump($nodeA->namespaceURI, $nodeB->namespaceURI);
diff --git a/ext/dom/tests/modern/spec/gh11404_2.phpt b/ext/dom/tests/modern/spec/gh11404_2.phpt
index 601c2d4e5ac1c..946a3a0140a6e 100644
--- a/ext/dom/tests/modern/spec/gh11404_2.phpt
+++ b/ext/dom/tests/modern/spec/gh11404_2.phpt
@@ -5,9 +5,9 @@ dom
--FILE--
');
+$dom1 = Dom\XMLDocument::createFromString(' ');
-$dom2 = DOM\XMLDocument::createFromString(' ');
+$dom2 = Dom\XMLDocument::createFromString(' ');
$dom1->documentElement->append(
$dom1->importNode(
@@ -15,7 +15,7 @@ $dom1->documentElement->append(
)
);
-echo $dom1->saveXML();
+echo $dom1->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/import_entity_reference.phpt b/ext/dom/tests/modern/spec/import_entity_reference.phpt
index 02d51af68aad6..67013cf0c9f85 100644
--- a/ext/dom/tests/modern/spec/import_entity_reference.phpt
+++ b/ext/dom/tests/modern/spec/import_entity_reference.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -13,16 +13,16 @@ $dom = DOM\XMLDocument::createFromString(<<&foo;
XML);
-$importer = DOM\XMLDocument::createEmpty();
+$importer = Dom\XMLDocument::createEmpty();
$imported = $importer->importNode($dom->documentElement, true);
-echo $importer->saveXML($imported), "\n";
+echo $importer->saveXml($imported), "\n";
var_dump($imported->firstChild);
?>
--EXPECT--
&foo;
-object(DOM\EntityReference)#3 (14) {
+object(Dom\EntityReference)#3 (14) {
["nodeType"]=>
int(5)
["nodeName"]=>
diff --git a/ext/dom/tests/modern/spec/import_of_lone_attribute.phpt b/ext/dom/tests/modern/spec/import_of_lone_attribute.phpt
index b612c409e0435..1a4ddbe6a2cfe 100644
--- a/ext/dom/tests/modern/spec/import_of_lone_attribute.phpt
+++ b/ext/dom/tests/modern/spec/import_of_lone_attribute.phpt
@@ -5,15 +5,15 @@ dom
--FILE--
appendChild($dom->createElement('root'));
$root->setAttributeNS("urn:a", "a:foo", "bar");
$attr = $root->getAttributeNodeNS("urn:a", "foo");
-$importer = DOM\XMLDocument::createEmpty();
+$importer = Dom\XMLDocument::createEmpty();
$attr = $importer->importNode($attr, true);
-echo $importer->saveXML($attr), "\n";
+echo $importer->saveXml($attr), "\n";
unset($dom);
unset($root);
diff --git a/ext/dom/tests/modern/spec/import_of_namepace_conflicting_attributes.phpt b/ext/dom/tests/modern/spec/import_of_namepace_conflicting_attributes.phpt
index e66ec34efa713..71598e0414b54 100644
--- a/ext/dom/tests/modern/spec/import_of_namepace_conflicting_attributes.phpt
+++ b/ext/dom/tests/modern/spec/import_of_namepace_conflicting_attributes.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
appendChild($dom->createElement('root'));
$root->setAttributeNS("urn:a", "a:root1", "bar");
@@ -17,7 +17,7 @@ $child = $root->appendChild($dom->createElement("child"));
$child->setAttributeNS("urn:x", "a:child1", "bar");
$child1 = $child->getAttributeNodeNS("urn:x", "child1");
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
var_dump($root1->prefix, $root1->namespaceURI);
var_dump($root2->prefix, $root2->namespaceURI);
@@ -25,9 +25,9 @@ var_dump($root2->prefix, $root2->namespaceURI);
$child->removeAttribute("a:child1");
$root->setAttributeNodeNS($child1);
-$importer = DOM\XMLDocument::createEmpty();
+$importer = Dom\XMLDocument::createEmpty();
$imported = $importer->importNode($root, true);
-echo $importer->saveXML($imported), "\n";
+echo $importer->saveXml($imported), "\n";
var_dump($imported->getAttributeNodeNS("urn:a", "root1")->prefix);
var_dump($imported->getAttributeNodeNS("urn:a", "root1")->namespaceURI);
diff --git a/ext/dom/tests/modern/spec/pre_insertion_validation.phpt b/ext/dom/tests/modern/spec/pre_insertion_validation.phpt
index b0f426be5cecd..d16e3ffad9d9c 100644
--- a/ext/dom/tests/modern/spec/pre_insertion_validation.phpt
+++ b/ext/dom/tests/modern/spec/pre_insertion_validation.phpt
@@ -4,7 +4,7 @@ ParentNode/ChildNode pre-insertion validation
dom
--FILE--
");
+$dom = Dom\XMLDocument::createFromString(" ");
$doctype = $dom->doctype;
$dom->removeChild($doctype);
@@ -66,11 +66,11 @@ try {
echo "--- Document output ---\n";
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
echo "--- Document fragment edge cases with multiple elements ---\n";
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
$fragment = $dom->createDocumentFragment();
$fragment->append($dom->createElement("foo"));
$fragment->append($dom->createElement("bar"));
@@ -82,7 +82,7 @@ try {
echo "--- Document fragment edge cases with text ---\n";
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
$fragment = $dom->createDocumentFragment();
$fragment->append("foo");
$fragment->append($dom->createCDATASection("bar"));
diff --git a/ext/dom/tests/modern/spec/reconciliation_of_attributes.phpt b/ext/dom/tests/modern/spec/reconciliation_of_attributes.phpt
index be2db111092fc..bd52ad4b4bc99 100644
--- a/ext/dom/tests/modern/spec/reconciliation_of_attributes.phpt
+++ b/ext/dom/tests/modern/spec/reconciliation_of_attributes.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
appendChild($dom->createElement('root'));
$root->setAttributeNS("urn:a", "a:root1", "bar");
@@ -21,7 +21,7 @@ $child1 = $child->getAttributeNodeNS("urn:x", "child1");
$child->setAttributeNS("urn:a", "a:child2", "bar");
$child2 = $child->getAttributeNodeNS("urn:a", "child2");
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
var_dump($root1->prefix, $root1->namespaceURI);
var_dump($root2->prefix, $root2->namespaceURI);
@@ -33,7 +33,7 @@ $root->setAttributeNodeNS($child1);
var_dump($child1->prefix, $child1->namespaceURI);
var_dump($child2->prefix, $child2->namespaceURI);
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/reconciliation_of_elements.phpt b/ext/dom/tests/modern/spec/reconciliation_of_elements.phpt
index f05ad8669c954..cddd39538e295 100644
--- a/ext/dom/tests/modern/spec/reconciliation_of_elements.phpt
+++ b/ext/dom/tests/modern/spec/reconciliation_of_elements.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -23,7 +23,7 @@ $a_child = $dom->getElementsByTagName("a:child")[0];
$root->append($a_child);
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
echo "---\n";
@@ -31,7 +31,7 @@ echo "---\n";
$root->remove();
unset($root);
-echo $dom->saveXML($a_child), "\n";
+echo $dom->saveXml($a_child), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/serialize_default_and_prefixed_xmlns.phpt b/ext/dom/tests/modern/spec/serialize_default_and_prefixed_xmlns.phpt
index 3bb61d1f63ae1..4d62141bbb327 100644
--- a/ext/dom/tests/modern/spec/serialize_default_and_prefixed_xmlns.phpt
+++ b/ext/dom/tests/modern/spec/serialize_default_and_prefixed_xmlns.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
@@ -14,7 +14,7 @@ $dom = DOM\XMLDocument::createFromString(<<
XML);
-echo $dom->saveXML();
+echo $dom->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/serialize_element_unqualified.phpt b/ext/dom/tests/modern/spec/serialize_element_unqualified.phpt
index 23ecc1321a825..4ef10638d1ffd 100644
--- a/ext/dom/tests/modern/spec/serialize_element_unqualified.phpt
+++ b/ext/dom/tests/modern/spec/serialize_element_unqualified.phpt
@@ -5,14 +5,14 @@ dom
--FILE--
');
-echo $dom->saveXML(), "\n";
+$dom = Dom\XMLDocument::createFromString(' ');
+echo $dom->saveXml(), "\n";
-$dom = DOM\XMLDocument::createFromString(' ');
+$dom = Dom\XMLDocument::createFromString(' ');
$root = $dom->documentElement;
$child2 = $root->ownerDocument->createElementNS('u1', 'child2');
$root->firstChild->appendChild($child2);
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/serialize_non_default_empty_xmlns.phpt b/ext/dom/tests/modern/spec/serialize_non_default_empty_xmlns.phpt
index ab91d3e104b97..e64bcaabda9f4 100644
--- a/ext/dom/tests/modern/spec/serialize_non_default_empty_xmlns.phpt
+++ b/ext/dom/tests/modern/spec/serialize_non_default_empty_xmlns.phpt
@@ -5,12 +5,12 @@ dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
?>
--EXPECTF--
-Warning: DOM\XMLDocument::createFromString(): xmlns:a: ' ' is not a valid URI in Entity, line: 1 in %s on line %d
+Warning: Dom\XMLDocument::createFromString(): xmlns:a: ' ' is not a valid URI in Entity, line: 1 in %s on line %d
diff --git a/ext/dom/tests/modern/spec/serialize_xml_attribute.phpt b/ext/dom/tests/modern/spec/serialize_xml_attribute.phpt
index 8fd583c6b5f18..a633efed54930 100644
--- a/ext/dom/tests/modern/spec/serialize_xml_attribute.phpt
+++ b/ext/dom/tests/modern/spec/serialize_xml_attribute.phpt
@@ -5,11 +5,11 @@ dom
--FILE--
");
+$dom = Dom\XMLDocument::createFromString(" ");
$root = $dom->documentElement;
$root->setAttribute("foo", "<>\"& \t\n\rfoo ");
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/serialize_xml_namespace_on_elements.phpt b/ext/dom/tests/modern/spec/serialize_xml_namespace_on_elements.phpt
index 7e0ab39c666d1..6954fa9ae6e7f 100644
--- a/ext/dom/tests/modern/spec/serialize_xml_namespace_on_elements.phpt
+++ b/ext/dom/tests/modern/spec/serialize_xml_namespace_on_elements.phpt
@@ -5,11 +5,11 @@ dom
--FILE--
appendChild($dom->createElementNS("http://www.w3.org/XML/1998/namespace", "xml:test"));
$root->appendChild($dom->createElementNS("http://www.w3.org/XML/1998/namespace", "xml:child"));
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/serialize_xml_ns_decl.phpt b/ext/dom/tests/modern/spec/serialize_xml_ns_decl.phpt
index dc308b1ca829b..70cae693b09b5 100644
--- a/ext/dom/tests/modern/spec/serialize_xml_ns_decl.phpt
+++ b/ext/dom/tests/modern/spec/serialize_xml_ns_decl.phpt
@@ -1,14 +1,14 @@
--TEST--
-Document::saveXML() with XML namespace declaration
+Document::saveXml() with XML namespace declaration
--EXTENSIONS--
dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
$root = $dom->documentElement;
$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xml', 'http://www.w3.org/XML/1998/namespace');
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/textContent_edge_cases.phpt b/ext/dom/tests/modern/spec/textContent_edge_cases.phpt
index b482ce01c790d..2252013c7a3f9 100644
--- a/ext/dom/tests/modern/spec/textContent_edge_cases.phpt
+++ b/ext/dom/tests/modern/spec/textContent_edge_cases.phpt
@@ -5,7 +5,7 @@ dom
--FILE--
text');
+$dom = Dom\XMLDocument::createFromString('text ');
echo "document text content: ";
var_dump($dom->textContent);
@@ -34,12 +34,12 @@ echo "pi node text content: ";
var_dump($pi->textContent);
$container->textContent = NULL;
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
?>
--EXPECT--
document text content: NULL
-Cannot modify readonly property DOM\XMLDocument::$textContent
+Cannot modify readonly property Dom\XMLDocument::$textContent
text node text content: string(4) "text"
pi node text content: string(5) "value"
text node text content: string(0) ""
diff --git a/ext/dom/tests/modern/spec/text_merging.phpt b/ext/dom/tests/modern/spec/text_merging.phpt
index b3cd382158b3a..343d2b45b9f31 100644
--- a/ext/dom/tests/modern/spec/text_merging.phpt
+++ b/ext/dom/tests/modern/spec/text_merging.phpt
@@ -5,20 +5,20 @@ dom
--FILE--
createElement("div");
$span = $dom->createElement("span");
$span->textContent = "qux";
$element->append("foo", "bar", "baz", $span, $dom->createCDATASection("a"), $dom->createCDATASection("b"));
$dom->append($element);
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
var_dump($element->firstChild->textContent);
var_dump($element->firstChild->nextSibling->textContent);
var_dump($element->firstChild->nextSibling->nextSibling->textContent);
$dom->normalize();
-echo $dom->saveXML(), "\n";
+echo $dom->saveXml(), "\n";
var_dump($element->firstChild->textContent);
var_dump($element->firstChild->nextSibling->textContent);
diff --git a/ext/dom/tests/modern/spec/xml_serialize_LIBXML_NOEMPTYTAG.phpt b/ext/dom/tests/modern/spec/xml_serialize_LIBXML_NOEMPTYTAG.phpt
index 9ce097a40d68e..a8a8c5979864a 100644
--- a/ext/dom/tests/modern/spec/xml_serialize_LIBXML_NOEMPTYTAG.phpt
+++ b/ext/dom/tests/modern/spec/xml_serialize_LIBXML_NOEMPTYTAG.phpt
@@ -5,11 +5,11 @@ dom
--FILE--
');
-echo $doc->saveXML($doc, LIBXML_NOEMPTYTAG), "\n";
+$doc = Dom\XMLDocument::createFromString(' ');
+echo $doc->saveXml($doc, LIBXML_NOEMPTYTAG), "\n";
$doc->formatOutput = true;
-echo $doc->saveXML($doc, LIBXML_NOEMPTYTAG), "\n";
+echo $doc->saveXml($doc, LIBXML_NOEMPTYTAG), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/spec/xml_serialize_formatting.phpt b/ext/dom/tests/modern/spec/xml_serialize_formatting.phpt
index c704157b5b08a..c79945e3d0c5a 100644
--- a/ext/dom/tests/modern/spec/xml_serialize_formatting.phpt
+++ b/ext/dom/tests/modern/spec/xml_serialize_formatting.phpt
@@ -23,9 +23,9 @@ $tests = [
foreach ($tests as $test) {
echo "---\n";
- $dom = DOM\XMLDocument::createFromString($test);
+ $dom = Dom\XMLDocument::createFromString($test);
$dom->formatOutput = true;
- echo $dom->saveXML(), "\n";
+ echo $dom->saveXml(), "\n";
}
?>
diff --git a/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt b/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
index 29a251003cc97..c94dce263efd2 100644
--- a/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
+++ b/ext/dom/tests/modern/xml/DTDNamedNodeMap.phpt
@@ -1,11 +1,11 @@
--TEST--
-DTDNamedNodeMap
+DtdNamedNodeMap
--EXTENSIONS--
dom
--FILE--
@@ -26,7 +26,7 @@ var_dump($doctype->notations["GIF"]);
?>
--EXPECTF--
-object(DOM\DocumentType)#2 (24) {
+object(Dom\DocumentType)#2 (24) {
["name"]=>
string(4) "root"
["entities"]=>
@@ -78,7 +78,7 @@ object(DOM\DocumentType)#2 (24) {
["textContent"]=>
NULL
}
-object(DOM\Entity)#4 (17) {
+object(Dom\Entity)#4 (17) {
["publicId"]=>
NULL
["systemId"]=>
@@ -114,7 +114,7 @@ object(DOM\Entity)#4 (17) {
["textContent"]=>
NULL
}
-object(DOM\Entity)#3 (17) {
+object(Dom\Entity)#3 (17) {
["publicId"]=>
string(1) "-"
["systemId"]=>
@@ -150,7 +150,7 @@ object(DOM\Entity)#3 (17) {
["textContent"]=>
NULL
}
-object(DOM\Notation)#4 (13) {
+object(Dom\Notation)#4 (13) {
["nodeType"]=>
int(12)
["nodeName"]=>
diff --git a/ext/dom/tests/modern/xml/XMLDocument_createFromFile_empty_input.phpt b/ext/dom/tests/modern/xml/XMLDocument_createFromFile_empty_input.phpt
index 9b7be6c2e0cb4..7aac2b92f4508 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_createFromFile_empty_input.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_createFromFile_empty_input.phpt
@@ -4,15 +4,15 @@ XMLDocument::createFromFile() - empty input
dom
--FILE--
documentURI);
fclose($memory);
?>
--EXPECTF--
-Warning: DOM\XMLDocument::createFromFile(): Document is empty in php://memory, line: 1 in %s on line %d
+Warning: Dom\XMLDocument::createFromFile(): Document is empty in php://memory, line: 1 in %s on line %d
Fatal error: Uncaught Exception: XML document is malformed in %s:%d
Stack trace:
-#0 %s(%d): DOM\XMLDocument::createFromFile('php://memory')
+#0 %s(%d): Dom\XMLDocument::createFromFile('php://memory')
#1 {main}
thrown in %s on line %d
diff --git a/ext/dom/tests/modern/xml/XMLDocument_createFromFile_override_encoding.phpt b/ext/dom/tests/modern/xml/XMLDocument_createFromFile_override_encoding.phpt
index 59f96a97a09b5..f48c5f7f5a14d 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_createFromFile_override_encoding.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_createFromFile_override_encoding.phpt
@@ -1,29 +1,29 @@
--TEST--
-DOM\XMLDocument::createFromFile() with overrideEncoding
+Dom\XMLDocument::createFromFile() with overrideEncoding
--EXTENSIONS--
dom
--FILE--
getMessage(), "\n";
}
// The override encoding matches with the document encoding attribute
-$dom = DOM\XMLDocument::createFromFile(__DIR__ . '/dummy.xml', overrideEncoding: 'UTF-8');
+$dom = Dom\XMLDocument::createFromFile(__DIR__ . '/dummy.xml', overrideEncoding: 'UTF-8');
var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset);
// The override encoding mismatches with the document encoding attribute
-$dom = DOM\XMLDocument::createFromFile(__DIR__ . '/dummy.xml', overrideEncoding: 'Windows-1252');
+$dom = Dom\XMLDocument::createFromFile(__DIR__ . '/dummy.xml', overrideEncoding: 'Windows-1252');
var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset);
?>
--EXPECT--
-DOM\XMLDocument::createFromFile(): Argument #3 ($overrideEncoding) must be a valid document encoding
+Dom\XMLDocument::createFromFile(): Argument #3 ($overrideEncoding) must be a valid document encoding
string(2) "é"
string(5) "UTF-8"
string(4) "é"
diff --git a/ext/dom/tests/modern/xml/XMLDocument_createFromString_override_encoding.phpt b/ext/dom/tests/modern/xml/XMLDocument_createFromString_override_encoding.phpt
index b972aec07cb57..e45f74847dd14 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_createFromString_override_encoding.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_createFromString_override_encoding.phpt
@@ -1,29 +1,29 @@
--TEST--
-DOM\XMLDocument::createFromString() with overrideEncoding
+Dom\XMLDocument::createFromString() with overrideEncoding
--EXTENSIONS--
dom
--FILE--
getMessage(), "\n";
}
// The override encoding matches with the document encoding attribute
-$dom = DOM\XMLDocument::createFromString(file_get_contents(__DIR__ . '/dummy.xml'), overrideEncoding: 'UTF-8');
+$dom = Dom\XMLDocument::createFromString(file_get_contents(__DIR__ . '/dummy.xml'), overrideEncoding: 'UTF-8');
var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset);
// The override encoding mismatches with the document encoding attribute
-$dom = DOM\XMLDocument::createFromString(file_get_contents(__DIR__ . '/dummy.xml'), overrideEncoding: 'Windows-1252');
+$dom = Dom\XMLDocument::createFromString(file_get_contents(__DIR__ . '/dummy.xml'), overrideEncoding: 'Windows-1252');
var_dump($dom->documentElement->lastChild->textContent);
var_dump($dom->charset);
?>
--EXPECT--
-DOM\XMLDocument::createFromString(): Argument #3 ($overrideEncoding) must be a valid document encoding
+Dom\XMLDocument::createFromString(): Argument #3 ($overrideEncoding) must be a valid document encoding
string(2) "é"
string(5) "UTF-8"
string(4) "é"
diff --git a/ext/dom/tests/modern/xml/XMLDocument_debug.phpt b/ext/dom/tests/modern/xml/XMLDocument_debug.phpt
index bc277f0d05265..c9ae2afa95fdf 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_debug.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_debug.phpt
@@ -1,16 +1,16 @@
--TEST--
-DOM\XMLDocument debug
+Dom\XMLDocument debug
--EXTENSIONS--
dom
--FILE--
--EXPECT--
-object(DOM\XMLDocument)#1 (29) {
+object(Dom\XMLDocument)#1 (29) {
["xmlEncoding"]=>
string(5) "UTF-8"
["xmlStandalone"]=>
diff --git a/ext/dom/tests/modern/xml/XMLDocument_documentURI.phpt b/ext/dom/tests/modern/xml/XMLDocument_documentURI.phpt
index f31c19d0ef650..9b65df787426f 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_documentURI.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_documentURI.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\XMLDocument::documentURI
+Dom\XMLDocument::documentURI
--EXTENSIONS--
dom
--FILE--
documentURI);
?>
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_01.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_01.phpt
index cc8f3f159b086..3726e9b0a2390 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_01.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_01.phpt
@@ -1,16 +1,16 @@
--TEST--
-DOM\XMLDocument::createEmpty 01
+Dom\XMLDocument::createEmpty 01
--EXTENSIONS--
dom
--FILE--
--EXPECTF--
-Fatal error: Uncaught ValueError: DOM\XMLDocument::createEmpty(): Argument #2 ($encoding) is not a valid document encoding in %s:%d
+Fatal error: Uncaught ValueError: Dom\XMLDocument::createEmpty(): Argument #2 ($encoding) is not a valid document encoding in %s:%d
Stack trace:
-#0 %s(%d): DOM\XMLDocument::createEmpty('1.0', 'foo')
+#0 %s(%d): Dom\XMLDocument::createEmpty('1.0', 'foo')
#1 {main}
thrown in %s on line %d
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_02.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_02.phpt
index cda5210f83849..a804394bc8441 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_02.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_02.phpt
@@ -1,16 +1,16 @@
--TEST--
-DOM\XMLDocument::createEmpty 02
+Dom\XMLDocument::createEmpty 02
--EXTENSIONS--
dom
--FILE--
--EXPECT--
-object(DOM\XMLDocument)#1 (29) {
+object(Dom\XMLDocument)#1 (29) {
["xmlEncoding"]=>
string(5) "UTF-8"
["xmlStandalone"]=>
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_03.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_03.phpt
index bbbace2b06488..e8cbea5dba9cd 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_03.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromEmptyDocument_03.phpt
@@ -1,13 +1,13 @@
--TEST--
-DOM\XMLDocument::createEmpty 03
+Dom\XMLDocument::createEmpty 03
--EXTENSIONS--
dom
--FILE--
append($dom->createElement("foo"));
-echo $dom->saveXML();
+echo $dom->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromFile_01.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromFile_01.phpt
index 5e4243795f7cc..a595007c8aa9d 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromFile_01.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromFile_01.phpt
@@ -1,16 +1,16 @@
--TEST--
-DOM\XMLDocument::createFromFile 01
+Dom\XMLDocument::createFromFile 01
--EXTENSIONS--
dom
--FILE--
--EXPECTF--
-Fatal error: Uncaught ValueError: DOM\XMLDocument::createFromString(): Argument #1 ($source) must not be empty in %s:%d
+Fatal error: Uncaught ValueError: Dom\XMLDocument::createFromString(): Argument #1 ($source) must not be empty in %s:%d
Stack trace:
-#0 %s(%d): DOM\XMLDocument::createFromString('')
+#0 %s(%d): Dom\XMLDocument::createFromString('')
#1 {main}
thrown in %s on line %d
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromFile_02.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromFile_02.phpt
index 2d593c124ab8d..1fccbd5ed2b01 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromFile_02.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromFile_02.phpt
@@ -1,18 +1,18 @@
--TEST--
-DOM\XMLDocument::createFromFile 02
+Dom\XMLDocument::createFromFile 02
--EXTENSIONS--
dom
--FILE--
--EXPECTF--
-Warning: DOM\XMLDocument::createFromFile(): I/O warning : failed to load external entity "%s" in %s on line %d
+Warning: Dom\XMLDocument::createFromFile(): I/O warning : failed to load external entity "%s" in %s on line %d
Fatal error: Uncaught Exception: Cannot open file '\0' in %s:%d
Stack trace:
-#0 %s(%d): DOM\XMLDocument::createFromFile('\\0')
+#0 %s(%d): Dom\XMLDocument::createFromFile('\\0')
#1 {main}
thrown in %s on line %d
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromFile_03.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromFile_03.phpt
index f129450b38c9a..73c1b0d223563 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromFile_03.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromFile_03.phpt
@@ -1,16 +1,16 @@
--TEST--
-DOM\XMLDocument::createFromFile 03
+Dom\XMLDocument::createFromFile 03
--EXTENSIONS--
dom
--FILE--
getMessage();
}
?>
--EXPECT--
-DOM\XMLDocument::createFromFile(): Argument #1 ($path) must not contain percent-encoded NUL bytes
+Dom\XMLDocument::createFromFile(): Argument #1 ($path) must not contain percent-encoded NUL bytes
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromFile_04.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromFile_04.phpt
index fcf8709e954cb..a24193c8c9d2d 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromFile_04.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromFile_04.phpt
@@ -1,12 +1,12 @@
--TEST--
-DOM\XMLDocument::createFromFile 04
+Dom\XMLDocument::createFromFile 04
--EXTENSIONS--
dom
--FILE--
saveXML();
+$dom = Dom\XMLDocument::createFromFile(__DIR__."/../../book.xml");
+echo $dom->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromString_01.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromString_01.phpt
index f4b7771e852c5..9eee72ab52b7b 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromString_01.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromString_01.phpt
@@ -1,16 +1,16 @@
--TEST--
-DOM\XMLDocument::createFromString 01
+Dom\XMLDocument::createFromString 01
--EXTENSIONS--
dom
--FILE--
--EXPECTF--
-Fatal error: Uncaught ValueError: DOM\XMLDocument::createFromString(): Argument #1 ($source) must not be empty in %s:%d
+Fatal error: Uncaught ValueError: Dom\XMLDocument::createFromString(): Argument #1 ($source) must not be empty in %s:%d
Stack trace:
-#0 %s(%d): DOM\XMLDocument::createFromString('')
+#0 %s(%d): Dom\XMLDocument::createFromString('')
#1 {main}
thrown in %s on line %d
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromString_02.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromString_02.phpt
index 3576af5f6a625..ce5da27001560 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromString_02.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromString_02.phpt
@@ -1,15 +1,20 @@
--TEST--
-DOM\XMLDocument::createFromString 02
+Dom\XMLDocument::createFromString 02
--EXTENSIONS--
dom
--FILE--
');
-var_dump($dom->saveXMLFile("php://stdout"));
+$dom = Dom\XMLDocument::createFromString(' ');
+var_dump($dom->saveXmlFile(__DIR__ . "/fromString_02.xml"));
+echo file_get_contents(__DIR__ . "/fromString_02.xml");
+?>
+--CLEAN--
+
--EXPECT--
+int(51)
-int(52)
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromString_03.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromString_03.phpt
index 2c2bb2ba33a3e..4f29c01c2642b 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromString_03.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromString_03.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\XMLDocument::createFromString 03
+Dom\XMLDocument::createFromString 03
--EXTENSIONS--
dom
--FILE--
@@ -10,18 +10,18 @@ $flags = [
];
try {
- DOM\XMLDocument::createFromString(' ', -1);
+ Dom\XMLDocument::createFromString(' ', -1);
} catch (ValueError $e) {
echo $e->getMessage();
}
foreach ($flags as $flag) {
- var_dump(DOM\XMLDocument::createFromString(' ', $flag) instanceof DOM\XMLDocument);
+ var_dump(Dom\XMLDocument::createFromString(' ', $flag) instanceof Dom\XMLDocument);
}
?>
--EXPECT--
-DOM\XMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_RECOVER, LIBXML_NOENT, LIBXML_DTDLOAD, LIBXML_DTDATTR, LIBXML_DTDVALID, LIBXML_NOERROR, LIBXML_NOWARNING, LIBXML_NOBLANKS, LIBXML_XINCLUDE, LIBXML_NSCLEAN, LIBXML_NOCDATA, LIBXML_NONET, LIBXML_PEDANTIC, LIBXML_COMPACT, LIBXML_PARSEHUGE, LIBXML_BIGLINES)bool(true)
+Dom\XMLDocument::createFromString(): Argument #2 ($options) contains invalid flags (allowed flags: LIBXML_RECOVER, LIBXML_NOENT, LIBXML_DTDLOAD, LIBXML_DTDATTR, LIBXML_DTDVALID, LIBXML_NOERROR, LIBXML_NOWARNING, LIBXML_NOBLANKS, LIBXML_XINCLUDE, LIBXML_NSCLEAN, LIBXML_NOCDATA, LIBXML_NONET, LIBXML_PEDANTIC, LIBXML_COMPACT, LIBXML_PARSEHUGE, LIBXML_BIGLINES)bool(true)
bool(true)
bool(true)
bool(true)
diff --git a/ext/dom/tests/modern/xml/XMLDocument_fromString_04.phpt b/ext/dom/tests/modern/xml/XMLDocument_fromString_04.phpt
index a124d2e4df1e5..0a63a6e8a864b 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_fromString_04.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_fromString_04.phpt
@@ -1,5 +1,5 @@
--TEST--
-DOM\XMLDocument::createFromString 04
+Dom\XMLDocument::createFromString 04
--EXTENSIONS--
dom
--SKIPIF--
@@ -9,9 +9,9 @@ if (getenv('SKIP_ASAN') && LIBXML_VERSION < 20911) die('xleak leaks under libxml
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
var_dump($dom->charset);
-echo $dom->saveXML();
+echo $dom->saveXml();
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/xml/XMLDocument_node_ownerDocument_for_XML.phpt b/ext/dom/tests/modern/xml/XMLDocument_node_ownerDocument_for_XML.phpt
index 0a0b541476a75..946f9495114a7 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_node_ownerDocument_for_XML.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_node_ownerDocument_for_XML.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\XMLDocument getting ownerDocument from a node in an XML document should yield a DOM\XMLDocument
+Dom\XMLDocument getting ownerDocument from a node in an XML document should yield a Dom\XMLDocument
--EXTENSIONS--
dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
$element = $dom->documentElement;
unset($dom);
@@ -13,7 +13,7 @@ var_dump($element->ownerDocument);
?>
--EXPECTF--
-object(DOM\XMLDocument)#1 (29) {
+object(Dom\XMLDocument)#1 (29) {
["xmlEncoding"]=>
string(5) "UTF-8"
["xmlStandalone"]=>
diff --git a/ext/dom/tests/modern/xml/XMLDocument_saveXML_node.phpt b/ext/dom/tests/modern/xml/XMLDocument_saveXML_node.phpt
index 73a48eb454dd1..2e00e9a688762 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_saveXML_node.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_saveXML_node.phpt
@@ -1,15 +1,15 @@
--TEST--
-DOM\XMLDocument::saveXML(File) node
+Dom\XMLDocument::saveXml(File) node
--EXTENSIONS--
dom
--FILE--
appendChild($dom->createElement("root"));
$child1 = $root->appendChild($dom->createElement("child1"));
$child2 = $root->appendChild($dom->createElement("child2"));
-echo $dom->saveXML($child1);
+echo $dom->saveXml($child1);
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/xml/XMLDocument_xpath.phpt b/ext/dom/tests/modern/xml/XMLDocument_xpath.phpt
index 6a7d903948f63..62442a868b27d 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_xpath.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_xpath.phpt
@@ -1,11 +1,11 @@
--TEST--
-DOM\XMLDocument interaction with XPath
+Dom\XMLDocument interaction with XPath
--EXTENSIONS--
dom
--FILE--
hi
@@ -16,7 +16,7 @@ $dom = DOM\XMLDocument::createFromString(<<
XML);
-$xpath = new DOM\XPath($dom);
+$xpath = new Dom\XPath($dom);
echo "--- Get data of the paragraph ---\n";
@@ -48,12 +48,12 @@ var_dump($xpath->evaluate("//*/namespace::*"));
?>
--EXPECT--
--- Get data of the paragraph ---
-object(DOM\NodeList)#4 (1) {
+object(Dom\NodeList)#4 (1) {
["length"]=>
int(1)
}
string(2) "hi"
-object(DOM\NodeList)#5 (1) {
+object(Dom\NodeList)#5 (1) {
["length"]=>
int(1)
}
@@ -62,12 +62,12 @@ string(2) "hi"
float(2)
bool(true)
--- Get data of special nodes ---
-string(25) "DOM\ProcessingInstruction"
+string(25) "Dom\ProcessingInstruction"
string(4) "data"
-string(11) "DOM\Comment"
+string(11) "Dom\Comment"
string(9) " comment "
--- Get a namespace node ---
-object(DOM\NodeList)#5 (1) {
+object(Dom\NodeList)#5 (1) {
["length"]=>
int(0)
}
diff --git a/ext/dom/tests/modern/xml/XMLDocument_xpath_errors.phpt b/ext/dom/tests/modern/xml/XMLDocument_xpath_errors.phpt
index 6eeac8c83b749..1ef52b50961f2 100644
--- a/ext/dom/tests/modern/xml/XMLDocument_xpath_errors.phpt
+++ b/ext/dom/tests/modern/xml/XMLDocument_xpath_errors.phpt
@@ -1,13 +1,13 @@
--TEST--
-DOM\XMLDocument interaction with XPath evaluate - errors
+Dom\XMLDocument interaction with XPath evaluate - errors
--EXTENSIONS--
dom
--FILE--
');
+$dom = Dom\XMLDocument::createFromString(' ');
-$xpath = new DOM\XPath($dom);
+$xpath = new Dom\XPath($dom);
try {
var_dump($xpath->evaluate('-'));
@@ -17,5 +17,5 @@ try {
?>
--EXPECTF--
-Warning: DOM\XPath::evaluate(): Invalid expression in %s on line %d
+Warning: Dom\XPath::evaluate(): Invalid expression in %s on line %d
string(35) "Could not evaluate XPath expression"
diff --git a/ext/dom/tests/modern/xml/bug48339.phpt b/ext/dom/tests/modern/xml/bug48339.phpt
index 1e57927ae7f2b..1c7a2eed53e8c 100644
--- a/ext/dom/tests/modern/xml/bug48339.phpt
+++ b/ext/dom/tests/modern/xml/bug48339.phpt
@@ -4,12 +4,12 @@ Bug #48339 (DOMElement::setIdAttribute() throws 'Not Found Error' exception)
dom
--FILE--
createElement('test');
$element = $document->appendChild($element);
$element->setAttribute("xml:id", 1);
$element->setIdAttribute("xml:id", TRUE);
-echo $document->saveXML(), "\n";
+echo $document->saveXml(), "\n";
?>
--EXPECT--
diff --git a/ext/dom/tests/modern/xml/serialize_LIBXML_NOXMLDECL.phpt b/ext/dom/tests/modern/xml/serialize_LIBXML_NOXMLDECL.phpt
new file mode 100644
index 0000000000000..59d1ea149231e
--- /dev/null
+++ b/ext/dom/tests/modern/xml/serialize_LIBXML_NOXMLDECL.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Serialize modern document with LIBXML_NOXMLDECL
+--EXTENSIONS--
+dom
+--FILE--
+ ');
+echo $dom->saveXml(options: LIBXML_NOXMLDECL), "\n";
+
+?>
+--EXPECT--
+
diff --git a/ext/dom/tests/modern/xml/simplexml_interop.phpt b/ext/dom/tests/modern/xml/simplexml_interop.phpt
index 80bb478060ff4..a1b02b7bdd837 100644
--- a/ext/dom/tests/modern/xml/simplexml_interop.phpt
+++ b/ext/dom/tests/modern/xml/simplexml_interop.phpt
@@ -8,15 +8,15 @@ simplexml
$sxe = simplexml_load_string('foo ');
-$element = DOM\import_simplexml($sxe);
+$element = Dom\import_simplexml($sxe);
var_dump($element->attributes);
-echo $element->ownerDocument->saveXML($element), "\n";
+echo $element->ownerDocument->saveXml($element), "\n";
$element->appendChild($element->ownerDocument->createElementNS('urn:a', 'child'));
-echo $element->ownerDocument->saveXML($element), "\n";
+echo $element->ownerDocument->saveXml($element), "\n";
$sxe->addChild('name', 'value');
-echo $element->ownerDocument->saveXML($element), "\n";
+echo $element->ownerDocument->saveXml($element), "\n";
// This should fail because it has been imported already above in modern DOM
try {
@@ -26,16 +26,16 @@ try {
}
// Import again and compare
-var_dump(DOM\import_simplexml($sxe) === $element);
+var_dump(Dom\import_simplexml($sxe) === $element);
?>
--EXPECT--
-object(DOM\NamedNodeMap)#3 (1) {
+object(Dom\NamedNodeMap)#3 (1) {
["length"]=>
int(1)
}
foo
foo
foovalue
-dom_import_simplexml(): Argument #1 ($node) must not be already imported as a DOM\Node
+dom_import_simplexml(): Argument #1 ($node) must not be already imported as a Dom\Node
bool(true)
diff --git a/ext/dom/tests/modern/xml/xpath_query_context_in_scope_ns.phpt b/ext/dom/tests/modern/xml/xpath_query_context_in_scope_ns.phpt
index d5e7d8d7f3847..dbc20e269a14a 100644
--- a/ext/dom/tests/modern/xml/xpath_query_context_in_scope_ns.phpt
+++ b/ext/dom/tests/modern/xml/xpath_query_context_in_scope_ns.phpt
@@ -1,5 +1,5 @@
--TEST--
-Test DOM\XPath::query() with registering a context node's in-scope namespaces
+Test Dom\XPath::query() with registering a context node's in-scope namespaces
--EXTENSIONS--
dom
--FILE--
@@ -21,7 +21,7 @@ function dump($xpath, $query, $context) {
}
}
-$dom = DOM\XMLDocument::createFromString(<<
@@ -39,7 +39,7 @@ XML);
$c1 = $dom->getElementsByTagNameNS('*', 'c1')->item(0);
$c2 = $dom->getElementsByTagNameNS('*', 'c1')->item(0);
-$xpath = new DOM\XPath($dom);
+$xpath = new Dom\XPath($dom);
echo "=== Tests with c1 ===\n\n";
diff --git a/ext/dom/tests/not_serializable.phpt b/ext/dom/tests/not_serializable.phpt
index bce87754dba1d..36053070f400b 100644
--- a/ext/dom/tests/not_serializable.phpt
+++ b/ext/dom/tests/not_serializable.phpt
@@ -34,7 +34,7 @@ try {
echo $e->getMessage(), "\n";
}
-$dom = DOM\XMLDocument::createEmpty();
+$dom = Dom\XMLDocument::createEmpty();
try {
serialize($dom);
} catch (Exception $e) {
@@ -42,7 +42,7 @@ try {
}
try {
- serialize(new DOM\XPath($dom));
+ serialize(new Dom\XPath($dom));
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
@@ -53,5 +53,5 @@ Serialization of 'DOMDocument' is not allowed, unless serialization methods are
Serialization of 'DOMElement' is not allowed, unless serialization methods are implemented in a subclass
Serialization of 'DOMXPath' is not allowed
Serialization of 'DOMNameSpaceNode' is not allowed, unless serialization methods are implemented in a subclass
-Serialization of 'DOM\XMLDocument' is not allowed, unless serialization methods are implemented in a subclass
-Serialization of 'DOM\XPath' is not allowed
+Serialization of 'Dom\XMLDocument' is not allowed, unless serialization methods are implemented in a subclass
+Serialization of 'Dom\XPath' is not allowed
diff --git a/ext/dom/tests/xml_parsing_LIBXML_RECOVER.phpt b/ext/dom/tests/xml_parsing_LIBXML_RECOVER.phpt
index 89e693d47565d..09ff6803b444e 100644
--- a/ext/dom/tests/xml_parsing_LIBXML_RECOVER.phpt
+++ b/ext/dom/tests/xml_parsing_LIBXML_RECOVER.phpt
@@ -9,7 +9,7 @@ $dom = new DOMDocument;
$dom->loadXML(' ', options: LIBXML_RECOVER);
echo $dom->saveXML();
-$dom = DOM\XMLDocument::createFromString(' ', options: LIBXML_RECOVER);
+$dom = Dom\XMLDocument::createFromString(' ', options: LIBXML_RECOVER);
echo $dom->saveXML(), "\n";
?>
@@ -18,6 +18,6 @@ Warning: DOMDocument::loadXML(): %s
-Warning: DOM\XMLDocument::createFromString(): %s
+Warning: Dom\XMLDocument::createFromString(): %s
diff --git a/ext/dom/text.c b/ext/dom/text.c
index 748474299367c..4411fb35d0db7 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -22,7 +22,6 @@
#include "php.h"
#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
#include "php_dom.h"
-#include "dom_ce.h"
#include "dom_properties.h"
/*
diff --git a/ext/dom/xml_document.c b/ext/dom/xml_document.c
index ac1d39eb3b13b..fd5ded5b1a66d 100644
--- a/ext/dom/xml_document.c
+++ b/ext/dom/xml_document.c
@@ -22,6 +22,8 @@
#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
#include "php_dom.h"
#include "namespace_compat.h"
+#include "xml_serializer.h"
+#include
static bool check_options_validity(uint32_t arg_num, zend_long options)
{
@@ -42,23 +44,23 @@ static bool check_options_validity(uint32_t arg_num, zend_long options)
| XML_PARSE_HUGE
| XML_PARSE_BIG_LINES;
if ((options & ~VALID_OPTIONS) != 0) {
- zend_argument_value_error(2, "contains invalid flags (allowed flags: "
- "LIBXML_RECOVER, "
- "LIBXML_NOENT, "
- "LIBXML_DTDLOAD, "
- "LIBXML_DTDATTR, "
- "LIBXML_DTDVALID, "
- "LIBXML_NOERROR, "
- "LIBXML_NOWARNING, "
- "LIBXML_NOBLANKS, "
- "LIBXML_XINCLUDE, "
- "LIBXML_NSCLEAN, "
- "LIBXML_NOCDATA, "
- "LIBXML_NONET, "
- "LIBXML_PEDANTIC, "
- "LIBXML_COMPACT, "
- "LIBXML_PARSEHUGE, "
- "LIBXML_BIGLINES)");
+ zend_argument_value_error(arg_num, "contains invalid flags (allowed flags: "
+ "LIBXML_RECOVER, "
+ "LIBXML_NOENT, "
+ "LIBXML_DTDLOAD, "
+ "LIBXML_DTDATTR, "
+ "LIBXML_DTDVALID, "
+ "LIBXML_NOERROR, "
+ "LIBXML_NOWARNING, "
+ "LIBXML_NOBLANKS, "
+ "LIBXML_XINCLUDE, "
+ "LIBXML_NSCLEAN, "
+ "LIBXML_NOCDATA, "
+ "LIBXML_NONET, "
+ "LIBXML_PEDANTIC, "
+ "LIBXML_COMPACT, "
+ "LIBXML_PARSEHUGE, "
+ "LIBXML_BIGLINES)");
return false;
}
return true;
@@ -86,7 +88,7 @@ static void dom_mark_namespaces_as_attributes_too(php_dom_libxml_ns_mapper *ns_m
}
}
-PHP_METHOD(DOM_XMLDocument, createEmpty)
+PHP_METHOD(Dom_XMLDocument, createEmpty)
{
const char *version = NULL;
size_t encoding_len = strlen("UTF-8");
@@ -118,7 +120,7 @@ PHP_METHOD(DOM_XMLDocument, 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;
@@ -227,7 +229,7 @@ static void load_from_helper(INTERNAL_FUNCTION_PARAMETERS, int mode)
(xmlNodePtr) lxml_doc,
NULL
);
- intern->document->class_type = PHP_LIBXML_CLASS_MODERN;
+ dom_set_xml_class(intern->document);
dom_document_convert_to_modern(intern->document, lxml_doc);
}
@@ -238,14 +240,102 @@ void dom_document_convert_to_modern(php_libxml_ref_obj *document, xmlDocPtr lxml
dom_mark_namespaces_as_attributes_too(ns_mapper, lxml_doc);
}
-PHP_METHOD(DOM_XMLDocument, createFromString)
+PHP_METHOD(Dom_XMLDocument, createFromString)
{
load_from_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING);
}
-PHP_METHOD(DOM_XMLDocument, createFromFile)
+PHP_METHOD(Dom_XMLDocument, createFromFile)
{
load_from_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE);
}
+static int php_new_dom_write_smart_str(void *context, const char *buffer, int len)
+{
+ smart_str *str = context;
+ smart_str_appendl(str, buffer, len);
+ return len;
+}
+
+static zend_string *php_new_dom_dump_node_to_str_ex(xmlNodePtr node, int options, bool format, const char *encoding)
+{
+ smart_str str = {0};
+
+ int status = -1;
+ xmlSaveCtxtPtr ctxt = xmlSaveToIO(php_new_dom_write_smart_str, NULL, &str, encoding, XML_SAVE_AS_XML | options);
+ if (EXPECTED(ctxt != NULL)) {
+ xmlCharEncodingHandlerPtr handler = xmlFindCharEncodingHandler(encoding);
+ xmlOutputBufferPtr out = xmlOutputBufferCreateIO(php_new_dom_write_smart_str, NULL, &str, handler);
+ if (EXPECTED(out != NULL)) {
+ status = dom_xml_serialize(ctxt, out, node, format);
+ status |= xmlOutputBufferFlush(out);
+ status |= xmlOutputBufferClose(out);
+ } else {
+ xmlCharEncCloseFunc(handler);
+ }
+ (void) xmlSaveClose(ctxt);
+ }
+
+ if (UNEXPECTED(status < 0)) {
+ smart_str_free_ex(&str, false);
+ return NULL;
+ }
+
+ return smart_str_extract(&str);
+}
+
+static zend_string *php_new_dom_dump_node_to_str(xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding)
+{
+ return php_new_dom_dump_node_to_str_ex(node, 0, format, encoding);
+}
+
+static zend_string *php_new_dom_dump_doc_to_str(xmlDocPtr doc, int options, const char *encoding)
+{
+ return php_new_dom_dump_node_to_str_ex((xmlNodePtr) doc, options, options & XML_SAVE_FORMAT, encoding);
+}
+
+zend_long php_new_dom_dump_node_to_file(const char *filename, xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding)
+{
+ xmlCharEncodingHandlerPtr handler = xmlFindCharEncodingHandler(encoding);
+ xmlOutputBufferPtr out = xmlOutputBufferCreateFilename(filename, handler, 0);
+ if (!out) {
+ xmlCharEncCloseFunc(handler);
+ return -1;
+ }
+
+ php_stream *stream = out->context;
+
+ int status = -1;
+ xmlSaveCtxtPtr ctxt = xmlSaveToIO(out->writecallback, NULL, stream, encoding, XML_SAVE_AS_XML);
+ if (EXPECTED(ctxt != NULL)) {
+ status = dom_xml_serialize(ctxt, out, node, format);
+ status |= xmlOutputBufferFlush(out);
+ (void) xmlSaveClose(ctxt);
+ }
+
+ size_t offset = php_stream_tell(stream);
+
+ (void) xmlOutputBufferClose(out);
+
+ return status < 0 ? status : (zend_long) offset;
+}
+
+static zend_long php_new_dom_dump_doc_to_file(const char *filename, xmlDocPtr doc, bool format, const char *encoding)
+{
+ return php_new_dom_dump_node_to_file(filename, doc, (xmlNodePtr) doc, format, encoding);
+}
+
+static const php_libxml_document_handlers php_new_dom_default_document_handlers = {
+ .dump_node_to_str = php_new_dom_dump_node_to_str,
+ .dump_doc_to_str = php_new_dom_dump_doc_to_str,
+ .dump_node_to_file = php_new_dom_dump_node_to_file,
+ .dump_doc_to_file = php_new_dom_dump_doc_to_file,
+};
+
+void dom_set_xml_class(php_libxml_ref_obj *document)
+{
+ document->class_type = PHP_LIBXML_CLASS_MODERN;
+ document->handlers = &php_new_dom_default_document_handlers;
+}
+
#endif /* HAVE_LIBXML && HAVE_DOM */
diff --git a/ext/dom/xml_serializer.c b/ext/dom/xml_serializer.c
index 39fce7a51555a..7d4c8f4d31d7e 100644
--- a/ext/dom/xml_serializer.c
+++ b/ext/dom/xml_serializer.c
@@ -20,7 +20,6 @@
#include "php.h"
#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
-#include "php_dom.h"
#include "xml_serializer.h"
#include "namespace_compat.h"
#include "serialize_common.h"
@@ -46,8 +45,10 @@
* https://github.com/w3c/DOM-Parsing/issues/71
*/
-#define TRY(x) do { if (UNEXPECTED(x < 0)) { return -1; } } while (0)
-#define TRY_OR_CLEANUP(x) do { if (UNEXPECTED(x < 0)) { goto cleanup; } } while (0)
+#define TRY(x) do { if (UNEXPECTED((x) < 0)) { return -1; } } while (0)
+#define TRY_OR_CLEANUP(x) do { if (UNEXPECTED((x) < 0)) { goto cleanup; } } while (0)
+
+#define xmlOutputBufferWriteLit(out, literal) xmlOutputBufferWrite((out), strlen("" literal), "" literal)
/* https://w3c.github.io/DOM-Parsing/#dfn-namespace-prefix-map
* This associates a namespace uri with a list of possible prefixes. */
@@ -460,7 +461,7 @@ static int dom_xml_output_qname(xmlOutputBufferPtr out, const dom_qname_pair *qn
{
if (qname->prefix != NULL) {
TRY(xmlOutputBufferWriteString(out, (const char *) qname->prefix));
- TRY(xmlOutputBufferWrite(out, strlen(":"), ":"));
+ TRY(xmlOutputBufferWriteLit(out, ":"));
}
return xmlOutputBufferWriteString(out, (const char *) qname->name);
}
@@ -489,39 +490,39 @@ static int dom_xml_common_text_serialization(xmlOutputBufferPtr out, const char
switch (*content) {
case '&': {
- TRY(xmlOutputBufferWrite(out, strlen("&"), "&"));
+ TRY(xmlOutputBufferWriteLit(out, "&"));
break;
}
case '<': {
- TRY(xmlOutputBufferWrite(out, strlen("<"), "<"));
+ TRY(xmlOutputBufferWriteLit(out, "<"));
break;
}
case '>': {
- TRY(xmlOutputBufferWrite(out, strlen(">"), ">"));
+ TRY(xmlOutputBufferWriteLit(out, ">"));
break;
}
case '"': {
- TRY(xmlOutputBufferWrite(out, strlen("""), """));
+ TRY(xmlOutputBufferWriteLit(out, """));
break;
}
/* The following three are added to address https://github.com/w3c/DOM-Parsing/issues/59 */
case '\t': {
- TRY(xmlOutputBufferWrite(out, strlen(" "), " "));
+ TRY(xmlOutputBufferWriteLit(out, " "));
break;
}
case '\n': {
- TRY(xmlOutputBufferWrite(out, strlen("
"), "
"));
+ TRY(xmlOutputBufferWriteLit(out, "
"));
break;
}
case '\r': {
- TRY(xmlOutputBufferWrite(out, strlen("
"), "
"));
+ TRY(xmlOutputBufferWriteLit(out, "
"));
break;
}
}
@@ -545,19 +546,19 @@ static zend_always_inline int dom_xml_serialize_text_node(xmlOutputBufferPtr out
static int dom_xml_serialize_attribute_node_value(xmlOutputBufferPtr out, xmlAttrPtr attr)
{
TRY(xmlOutputBufferWriteString(out, (const char *) attr->name));
- TRY(xmlOutputBufferWrite(out, strlen("=\""), "=\""));
+ TRY(xmlOutputBufferWriteLit(out, "=\""));
for (xmlNodePtr child = attr->children; child != NULL; child = child->next) {
if (child->type == XML_TEXT_NODE) {
if (child->content != NULL) {
TRY(dom_xml_common_text_serialization(out, (const char *) child->content, true));
}
} else if (child->type == XML_ENTITY_REF_NODE) {
- TRY(xmlOutputBufferWrite(out, strlen("&"), "&"));
+ TRY(xmlOutputBufferWriteLit(out, "&"));
TRY(dom_xml_common_text_serialization(out, (const char *) child->name, true));
- TRY(xmlOutputBufferWrite(out, strlen(";"), ";"));
+ TRY(xmlOutputBufferWriteLit(out, ";"));
}
}
- return xmlOutputBufferWrite(out, strlen("\""), "\"");
+ return xmlOutputBufferWriteLit(out, "\"");
}
/* Spec says to do nothing, but that's inconsistent/wrong, see https://github.com/w3c/DOM-Parsing/issues/28 */
@@ -565,7 +566,7 @@ static int dom_xml_serialize_attribute_node(xmlOutputBufferPtr out, xmlNodePtr a
{
if (attr->ns != NULL && attr->ns->prefix != NULL) {
TRY(xmlOutputBufferWriteString(out, (const char *) attr->ns->prefix));
- TRY(xmlOutputBufferWrite(out, strlen(":"), ":"));
+ TRY(xmlOutputBufferWriteLit(out, ":"));
}
return dom_xml_serialize_attribute_node_value(out, (xmlAttrPtr) attr);
}
@@ -576,11 +577,11 @@ static int dom_xml_serialize_comment_node(xmlOutputBufferPtr out, xmlNodePtr com
/* 1. If the require well-formed flag is set ...
* => N/A */
- TRY(xmlOutputBufferWrite(out, strlen(""), "-->");
+ return xmlOutputBufferWriteLit(out, "-->");
}
/* https://w3c.github.io/DOM-Parsing/#xml-serializing-a-processinginstruction-node */
@@ -589,24 +590,24 @@ static int dom_xml_serialize_processing_instruction(xmlOutputBufferPtr out, xmlN
/* Steps 1-2 deal with well-formed flag
* => N/A */
- TRY(xmlOutputBufferWrite(out, strlen(""), ""));
+ TRY(xmlOutputBufferWriteLit(out, ""));
TRY(xmlOutputBufferWriteString(out, (const char *) pi->name));
- TRY(xmlOutputBufferWrite(out, strlen(" "), " "));
+ TRY(xmlOutputBufferWriteLit(out, " "));
if (EXPECTED(pi->content != NULL)) {
TRY(xmlOutputBufferWriteString(out, (const char *) pi->content));
}
- return xmlOutputBufferWrite(out, strlen("?>"), "?>");
+ return xmlOutputBufferWriteLit(out, "?>");
}
/* https://github.com/w3c/DOM-Parsing/issues/38
* and https://github.com/w3c/DOM-Parsing/blob/ab8d1ac9699ed43ae6de9f4be2b0f3cfc5f3709e/index.html#L1510 */
static int dom_xml_serialize_cdata_section_node(xmlOutputBufferPtr out, xmlNodePtr cdata)
{
- TRY(xmlOutputBufferWrite(out, strlen("content != NULL)) {
TRY(xmlOutputBufferWriteString(out, (const char *) cdata->content));
}
- return xmlOutputBufferWrite(out, strlen("]]>"), "]]>");
+ return xmlOutputBufferWriteLit(out, "]]>");
}
/* https://w3c.github.io/DOM-Parsing/#dfn-xml-serialization-of-the-attributes */
@@ -724,21 +725,21 @@ static int dom_xml_serialize_attributes(
}
/* 3.5.3.2. Append the following to result, in the order listed: */
- TRY(xmlOutputBufferWrite(out, strlen(" xmlns:"), " xmlns:"));
+ TRY(xmlOutputBufferWriteLit(out, " xmlns:"));
TRY(xmlOutputBufferWriteString(out, (const char *) candidate_prefix));
- TRY(xmlOutputBufferWrite(out, strlen("=\""), "=\""));
+ TRY(xmlOutputBufferWriteLit(out, "=\""));
TRY(dom_xml_common_text_serialization(out, (const char *) attribute_namespace, true));
- TRY(xmlOutputBufferWrite(out, strlen("\""), "\""));
+ TRY(xmlOutputBufferWriteLit(out, "\""));
}
}
/* 3.6. Append a " " (U+0020 SPACE) to result. */
- TRY(xmlOutputBufferWrite(out, strlen(" "), " "));
+ TRY(xmlOutputBufferWriteLit(out, " "));
/* 3.7. If candidate prefix is not null, then append to result the concatenation of candidate prefix with ":" (U+003A COLON). */
if (candidate_prefix != NULL) {
TRY(xmlOutputBufferWriteString(out, (const char *) candidate_prefix));
- TRY(xmlOutputBufferWrite(out, strlen(":"), ":"));
+ TRY(xmlOutputBufferWriteLit(out, ":"));
}
/* 3.8. If the require well-formed flag is set ...
@@ -769,9 +770,9 @@ static bool dom_xml_should_format_element(xmlNodePtr element)
static int dom_xml_output_indents(xmlOutputBufferPtr out, int indent)
{
- TRY(xmlOutputBufferWrite(out, strlen("\n"), "\n"));
+ TRY(xmlOutputBufferWriteLit(out, "\n"));
for (int i = 0; i < indent; i++) {
- TRY(xmlOutputBufferWrite(out, strlen(" "), " "));
+ TRY(xmlOutputBufferWriteLit(out, " "));
}
return 0;
}
@@ -793,7 +794,7 @@ static int dom_xml_serialize_element_node(
* => N/A */
/* 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). */
- TRY(xmlOutputBufferWrite(out, strlen("<"), "<"));
+ TRY(xmlOutputBufferWriteLit(out, "<"));
/* 3. Let qualified name be an empty string.
* => We're going to do it a bit differently.
@@ -910,11 +911,11 @@ static int dom_xml_serialize_element_node(
TRY_OR_CLEANUP(dom_xml_output_qname(out, &qualified_name));
/* 12.5.5. Append the following to markup, in the order listed: ... */
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen(" xmlns:"), " xmlns:")); /* 12.5.5.1 - 12.5.5.2 */
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, " xmlns:")); /* 12.5.5.1 - 12.5.5.2 */
TRY_OR_CLEANUP(xmlOutputBufferWriteString(out, (const char *) prefix));
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen("=\""), "=\""));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, "=\""));
TRY_OR_CLEANUP(dom_xml_common_text_serialization(out, (const char *) ns, true));
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen("\""), "\""));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, "\""));
/* 12.5.6. If local default namespace is not null ... (editorial numbering error: https://github.com/w3c/DOM-Parsing/issues/43) */
if (local_default_namespace != NULL) {
@@ -941,9 +942,9 @@ static int dom_xml_serialize_element_node(
TRY_OR_CLEANUP(dom_xml_output_qname(out, &qualified_name));
/* 12.6.5. Append the following to markup, in the order listed: ... */
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen(" xmlns=\""), " xmlns=\"")); /* 12.6.5.1 - 12.6.5.2 */
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, " xmlns=\"")); /* 12.6.5.1 - 12.6.5.2 */
TRY_OR_CLEANUP(dom_xml_common_text_serialization(out, (const char *) ns, true));
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen("\""), "\""));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, "\""));
}
/* 12.7. Otherwise, the node has a local default namespace that matches ns ... */
else {
@@ -983,19 +984,19 @@ static int dom_xml_serialize_element_node(
|| dom_local_name_compare_ex(element, "source", strlen("source"), name_length)
|| dom_local_name_compare_ex(element, "track", strlen("track"), name_length)
|| dom_local_name_compare_ex(element, "wbr", strlen("wbr"), name_length)) {
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen(" /"), " /"));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, " /"));
skip_end_tag = true;
}
} else {
/* 15. If ns is not the HTML namespace, and the node's list of children is empty,
* then append "/" (U+002F SOLIDUS) to markup and set the skip end tag flag to true. */
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen("/"), "/"));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, "/"));
skip_end_tag = true;
}
}
/* 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. */
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen(">"), ">"));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, ">"));
/* 17. If the value of skip end tag is true, then return the value of markup and skip the remaining steps. */
if (!skip_end_tag) {
@@ -1021,9 +1022,9 @@ static int dom_xml_serialize_element_node(
}
/* 20. Append the following to markup, in the order listed: */
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen(""), ""));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, ""));
TRY_OR_CLEANUP(dom_xml_output_qname(out, &qualified_name));
- TRY_OR_CLEANUP(xmlOutputBufferWrite(out, strlen(">"), ">"));
+ TRY_OR_CLEANUP(xmlOutputBufferWriteLit(out, ">"));
}
/* 21. Return the value of markup.
@@ -1143,7 +1144,7 @@ static int dom_xml_serialization_algorithm(
TRY(xmlSaveTree(ctxt, node));
TRY(xmlSaveFlush(ctxt));
if (node->type == XML_DTD_NODE) {
- return xmlOutputBufferWrite(out, strlen("\n"), "\n");
+ return xmlOutputBufferWriteLit(out, "\n");
}
return 0;
}
diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c
index 8919559373e21..d33d3f07a27c9 100644
--- a/ext/dom/xpath.c
+++ b/ext/dom/xpath.c
@@ -161,7 +161,7 @@ PHP_METHOD(DOMXPath, __construct)
dom_xpath_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_document_class_entry);
}
-PHP_METHOD(DOM_XPath, __construct)
+PHP_METHOD(Dom_XPath, __construct)
{
dom_xpath_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, dom_abstract_base_document_class_entry);
}
@@ -391,7 +391,7 @@ PHP_METHOD(DOMXPath, query)
php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_QUERY, false);
}
-PHP_METHOD(DOM_XPath, query)
+PHP_METHOD(Dom_XPath, query)
{
php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_QUERY, true);
}
@@ -403,7 +403,7 @@ PHP_METHOD(DOMXPath, evaluate)
php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_EVALUATE, false);
}
-PHP_METHOD(DOM_XPath, evaluate)
+PHP_METHOD(Dom_XPath, evaluate)
{
php_xpath_eval(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_DOM_XPATH_EVALUATE, true);
}
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
index ff2d3a9603672..d797f5f93f809 100644
--- a/ext/ffi/ffi.c
+++ b/ext/ffi/ffi.c
@@ -913,7 +913,7 @@ typedef struct _zend_ffi_callback_data {
ffi_cif cif;
uint32_t arg_count;
ffi_type *ret_type;
- ffi_type *arg_types[0] ZEND_ELEMENT_COUNT(arg_count);
+ ffi_type *arg_types[] ZEND_ELEMENT_COUNT(arg_count);
} zend_ffi_callback_data;
static void zend_ffi_callback_hash_dtor(zval *zv) /* {{{ */
@@ -3283,7 +3283,11 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */
code_size = buf.st_size;
code = emalloc(code_size + 1);
- fd = open(filename, O_RDONLY, 0);
+ int open_flags = O_RDONLY;
+#ifdef PHP_WIN32
+ open_flags |= _O_BINARY;
+#endif
+ fd = open(filename, open_flags, 0);
if (fd < 0 || read(fd, code, code_size) != code_size) {
if (preload) {
zend_error(E_WARNING, "FFI: Failed pre-loading '%s', cannot read_file", filename);
diff --git a/ext/ffi/ffi.stub.php b/ext/ffi/ffi.stub.php
index 5ae957634b86f..0ed3cb32ac6ed 100644
--- a/ext/ffi/ffi.stub.php
+++ b/ext/ffi/ffi.stub.php
@@ -6,10 +6,7 @@
/** @not-serializable */
final class FFI
{
- /**
- * @cvalue __BIGGEST_ALIGNMENT__
- * @link ffi-ffi.constants.biggest-alignment
- */
+ /** @cvalue __BIGGEST_ALIGNMENT__ */
public const int __BIGGEST_ALIGNMENT__ = UNKNOWN;
public static function cdef(string $code = "", ?string $lib = null): FFI {}
diff --git a/ext/ffi/ffi_arginfo.h b/ext/ffi/ffi_arginfo.h
index 62a4171734504..aca7a8d25637c 100644
--- a/ext/ffi/ffi_arginfo.h
+++ b/ext/ffi/ffi_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 81892d30ea498304dfa4105fc430a3d43f0ad54f */
+ * Stub hash: 1255ed4477be5b4361622aab54ebe37f42b1dada */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_FFI_cdef, 0, 0, FFI, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, code, IS_STRING, 0, "\"\"")
diff --git a/ext/ffi/tests/gh14215.h b/ext/ffi/tests/gh14215.h
new file mode 100644
index 0000000000000..9a1245b891297
--- /dev/null
+++ b/ext/ffi/tests/gh14215.h
@@ -0,0 +1,3 @@
+#define FFI_LIB "Kernel32.dll"
+typedef unsigned long DWORD;
+DWORD GetLastError(void);
diff --git a/ext/ffi/tests/gh14215.phpt b/ext/ffi/tests/gh14215.phpt
new file mode 100644
index 0000000000000..e259621e7a596
--- /dev/null
+++ b/ext/ffi/tests/gh14215.phpt
@@ -0,0 +1,23 @@
+--TEST--
+GH-14215 (Cannot use FFI::load on CRLF header file with apache2handler)
+--EXTENSIONS--
+ffi
+zend_test
+--SKIPIF--
+
+--INI--
+ffi.enable=1
+--FILE--
+GetLastError());
+zend_test_set_fmode(true);
+?>
+--EXPECT--
+int(0)
diff --git a/ext/filter/filter.c b/ext/filter/filter.c
index ee8db5ef3583b..3887481124a3f 100644
--- a/ext/filter/filter.c
+++ b/ext/filter/filter.c
@@ -71,10 +71,6 @@ static const filter_list_entry filter_list[] = {
#define PARSE_SERVER 5
#endif
-#ifndef PARSE_SESSION
-#define PARSE_SESSION 6
-#endif
-
static unsigned int php_sapi_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
static unsigned int php_sapi_filter_init(void);
@@ -153,8 +149,6 @@ ZEND_TSRMLS_CACHE_UPDATE();
}
/* }}} */
-#define PARSE_REQUEST 99
-
/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(filter)
{
diff --git a/ext/ftp/config.m4 b/ext/ftp/config.m4
index d5d613ecef6ec..150ed651bb899 100644
--- a/ext/ftp/config.m4
+++ b/ext/ftp/config.m4
@@ -3,11 +3,12 @@ PHP_ARG_ENABLE([ftp],
[AS_HELP_STRING([--enable-ftp],
[Enable FTP support])])
-dnl TODO: Rename this option for master.
-PHP_ARG_WITH([openssl-dir],
+PHP_ARG_WITH([ftp-ssl],
[whether to explicitly enable FTP SSL support],
- [AS_HELP_STRING([[--with-openssl-dir]],
- [FTP: Whether to enable FTP SSL support without ext/openssl])],
+ [AS_HELP_STRING([--with-ftp-ssl],
+ [Explicitly enable SSL support in ext/ftp when not building with
+ ext/openssl. If ext/openssl is enabled at the configure step, SSL is enabled
+ implicitly.])],
[no],
[no])
@@ -15,10 +16,10 @@ if test "$PHP_FTP" = "yes"; then
AC_DEFINE(HAVE_FTP,1,[Whether you want FTP support])
PHP_NEW_EXTENSION(ftp, php_ftp.c ftp.c, $ext_shared)
- dnl Empty variable means 'no'
+ dnl Empty variable means 'no' (for phpize builds).
test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
- if test "$PHP_OPENSSL" != "no" || test "$PHP_OPENSSL_DIR" != "no"; then
+ if test "$PHP_OPENSSL" != "no" || test "$PHP_FTP_SSL" != "no"; then
PHP_SETUP_OPENSSL(FTP_SHARED_LIBADD)
PHP_SUBST(FTP_SHARED_LIBADD)
AC_DEFINE(HAVE_FTP_SSL,1,[Whether FTP over SSL is supported])
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c
index 8518a80520b55..a921070197020 100644
--- a/ext/gettext/gettext.c
+++ b/ext/gettext/gettext.c
@@ -81,18 +81,20 @@ PHP_MINFO_FUNCTION(php_gettext)
/* {{{ Set the textdomain to "domain". Returns the current domain */
PHP_FUNCTION(textdomain)
{
- char *domain_name = NULL, *retval;
+ char *domain_name = NULL, *retval = NULL;
zend_string *domain = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S!", &domain) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR_OR_NULL(domain)
+ ZEND_PARSE_PARAMETERS_END();
if (domain != NULL) {
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
- }
-
- if (domain != NULL && !zend_string_equals_literal(domain, "0")) {
+ if (zend_string_equals_literal(domain, "0")) {
+ zend_argument_value_error(1, "cannot be zero");
+ RETURN_THROWS();
+ }
domain_name = ZSTR_VAL(domain);
}
@@ -105,7 +107,7 @@ PHP_FUNCTION(textdomain)
/* {{{ Return the translation of msgid for the current domain, or msgid unaltered if a translation does not exist */
PHP_FUNCTION(gettext)
{
- char *msgstr;
+ char *msgstr = NULL;
zend_string *msgid;
ZEND_PARSE_PARAMETERS_START(1, 1)
@@ -126,12 +128,13 @@ PHP_FUNCTION(gettext)
/* {{{ Return the translation of msgid for domain_name, or msgid unaltered if a translation does not exist */
PHP_FUNCTION(dgettext)
{
- char *msgstr;
+ char *msgstr = NULL;
zend_string *domain, *msgid;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &domain, &msgid) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STR(domain)
+ Z_PARAM_STR(msgid)
+ ZEND_PARSE_PARAMETERS_END();
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid))
@@ -149,13 +152,15 @@ PHP_FUNCTION(dgettext)
/* {{{ Return the translation of msgid for domain_name and category, or msgid unaltered if a translation does not exist */
PHP_FUNCTION(dcgettext)
{
- char *msgstr;
+ char *msgstr = NULL;
zend_string *domain, *msgid;
zend_long category;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSl", &domain, &msgid, &category) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_STR(domain)
+ Z_PARAM_STR(msgid)
+ Z_PARAM_LONG(category)
+ ZEND_PARSE_PARAMETERS_END();
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid))
@@ -174,19 +179,24 @@ PHP_FUNCTION(dcgettext)
/* {{{ Bind to the text domain domain_name, looking for translations in dir. Returns the current domain */
PHP_FUNCTION(bindtextdomain)
{
- char *domain;
- size_t domain_len;
- zend_string *dir = NULL;
+ zend_string *domain, *dir = NULL;
char *retval, dir_name[MAXPATHLEN];
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sS!", &domain, &domain_len, &dir) == FAILURE) {
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_STR(domain)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR_OR_NULL(dir)
+ ZEND_PARSE_PARAMETERS_END();
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
+
+ if (!ZSTR_LEN(domain)) {
+ zend_argument_value_error(1, "cannot be empty");
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
-
if (dir == NULL) {
- RETURN_STRING(bindtextdomain(domain, NULL));
+ RETURN_STRING(bindtextdomain(ZSTR_VAL(domain), NULL));
}
if (ZSTR_LEN(dir) != 0 && !zend_string_equals_literal(dir, "0")) {
@@ -197,7 +207,7 @@ PHP_FUNCTION(bindtextdomain)
RETURN_FALSE;
}
- retval = bindtextdomain(domain, dir_name);
+ retval = bindtextdomain(ZSTR_VAL(domain), dir_name);
RETURN_STRING(retval);
}
@@ -207,18 +217,20 @@ PHP_FUNCTION(bindtextdomain)
/* {{{ Plural version of gettext() */
PHP_FUNCTION(ngettext)
{
- char *msgid1, *msgid2, *msgstr;
- size_t msgid1_len, msgid2_len;
+ char *msgstr = NULL;
+ zend_string *msgid1, *msgid2;
zend_long count;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ssl", &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_STR(msgid1)
+ Z_PARAM_STR(msgid2)
+ Z_PARAM_LONG(count)
+ ZEND_PARSE_PARAMETERS_END();
- PHP_GETTEXT_LENGTH_CHECK(1, msgid1_len)
- PHP_GETTEXT_LENGTH_CHECK(2, msgid2_len)
+ PHP_GETTEXT_LENGTH_CHECK(1, ZSTR_LEN(msgid1))
+ PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid2))
- msgstr = ngettext(msgid1, msgid2, count);
+ msgstr = ngettext(ZSTR_VAL(msgid1), ZSTR_VAL(msgid2), count);
ZEND_ASSERT(msgstr);
RETURN_STRING(msgstr);
@@ -230,20 +242,22 @@ PHP_FUNCTION(ngettext)
/* {{{ Plural version of dgettext() */
PHP_FUNCTION(dngettext)
{
- char *domain, *msgid1, *msgid2, *msgstr = NULL;
- size_t domain_len, msgid1_len, msgid2_len;
+ char *msgstr = NULL;
+ zend_string *domain, *msgid1, *msgid2;
zend_long count;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sssl", &domain, &domain_len,
- &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(4, 4)
+ Z_PARAM_STR(domain)
+ Z_PARAM_STR(msgid1)
+ Z_PARAM_STR(msgid2)
+ Z_PARAM_LONG(count)
+ ZEND_PARSE_PARAMETERS_END();
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
- PHP_GETTEXT_LENGTH_CHECK(2, msgid1_len)
- PHP_GETTEXT_LENGTH_CHECK(3, msgid2_len)
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
+ PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid1))
+ PHP_GETTEXT_LENGTH_CHECK(3, ZSTR_LEN(msgid2))
- msgstr = dngettext(domain, msgid1, msgid2, count);
+ msgstr = dngettext(ZSTR_VAL(domain), ZSTR_VAL(msgid1), ZSTR_VAL(msgid2), count);
ZEND_ASSERT(msgstr);
RETURN_STRING(msgstr);
@@ -255,23 +269,26 @@ PHP_FUNCTION(dngettext)
/* {{{ Plural version of dcgettext() */
PHP_FUNCTION(dcngettext)
{
- char *domain, *msgid1, *msgid2, *msgstr = NULL;
- size_t domain_len, msgid1_len, msgid2_len;
+ char *msgstr = NULL;
+ zend_string *domain, *msgid1, *msgid2;
zend_long count, category;
RETVAL_FALSE;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sssll", &domain, &domain_len,
- &msgid1, &msgid1_len, &msgid2, &msgid2_len, &count, &category) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(5, 5)
+ Z_PARAM_STR(domain)
+ Z_PARAM_STR(msgid1)
+ Z_PARAM_STR(msgid2)
+ Z_PARAM_LONG(count)
+ Z_PARAM_LONG(category)
+ ZEND_PARSE_PARAMETERS_END();
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
- PHP_GETTEXT_LENGTH_CHECK(2, msgid1_len)
- PHP_GETTEXT_LENGTH_CHECK(3, msgid2_len)
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
+ PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid1))
+ PHP_GETTEXT_LENGTH_CHECK(3, ZSTR_LEN(msgid2))
PHP_DCGETTEXT_CATEGORY_CHECK(5, category)
- msgstr = dcngettext(domain, msgid1, msgid2, count, category);
+ msgstr = dcngettext(ZSTR_VAL(domain), ZSTR_VAL(msgid1), ZSTR_VAL(msgid2), count, category);
ZEND_ASSERT(msgstr);
RETURN_STRING(msgstr);
@@ -284,16 +301,23 @@ PHP_FUNCTION(dcngettext)
/* {{{ Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. */
PHP_FUNCTION(bind_textdomain_codeset)
{
- char *domain, *codeset = NULL, *retval = NULL;
- size_t domain_len, codeset_len;
+ char *retval = NULL;
+ zend_string *domain, *codeset = NULL;
+
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_STR(domain)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR_OR_NULL(codeset)
+ ZEND_PARSE_PARAMETERS_END();
+
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss!", &domain, &domain_len, &codeset, &codeset_len) == FAILURE) {
+ if (!ZSTR_LEN(domain)) {
+ zend_argument_value_error(1, "cannot be empty");
RETURN_THROWS();
}
- PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
-
- retval = bind_textdomain_codeset(domain, codeset);
+ retval = bind_textdomain_codeset(ZSTR_VAL(domain), codeset ? ZSTR_VAL(codeset) : NULL);
if (!retval) {
RETURN_FALSE;
diff --git a/ext/gettext/gettext.stub.php b/ext/gettext/gettext.stub.php
index ec6b197c0d77a..3e9a50177a592 100644
--- a/ext/gettext/gettext.stub.php
+++ b/ext/gettext/gettext.stub.php
@@ -3,7 +3,7 @@
/** @generate-class-entries */
/** @refcount 1 */
-function textdomain(?string $domain): string {}
+function textdomain(?string $domain = null): string {}
/** @refcount 1 */
function gettext(string $message): string {}
@@ -18,7 +18,7 @@ function dgettext(string $domain, string $message): string {}
function dcgettext(string $domain, string $message, int $category): string {}
/** @refcount 1 */
-function bindtextdomain(string $domain, ?string $directory): string|false {}
+function bindtextdomain(string $domain, ?string $directory = null): string|false {}
#ifdef HAVE_NGETTEXT
/** @refcount 1 */
@@ -37,5 +37,5 @@ function dcngettext(string $domain, string $singular, string $plural, int $count
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
/** @refcount 1 */
-function bind_textdomain_codeset(string $domain, ?string $codeset): string|false {}
+function bind_textdomain_codeset(string $domain, ?string $codeset = null): string|false {}
#endif
diff --git a/ext/gettext/gettext_arginfo.h b/ext/gettext/gettext_arginfo.h
index 8b2d7712dc87e..265f6cd900edc 100644
--- a/ext/gettext/gettext_arginfo.h
+++ b/ext/gettext/gettext_arginfo.h
@@ -1,8 +1,8 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 864b3389d4f99b0d7302ae399544e6fb9fb80b7e */
+ * Stub hash: c675dc9492943bbac106c5906b75c31436964423 */
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_textdomain, 0, 1, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_textdomain, 0, 0, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, domain, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gettext, 0, 1, IS_STRING, 0)
@@ -22,9 +22,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dcgettext, 0, 3, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, category, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bindtextdomain, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bindtextdomain, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, directory, IS_STRING, 1)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, directory, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#if defined(HAVE_NGETTEXT)
@@ -55,9 +55,9 @@ ZEND_END_ARG_INFO()
#endif
#if defined(HAVE_BIND_TEXTDOMAIN_CODESET)
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bind_textdomain_codeset, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_bind_textdomain_codeset, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, domain, IS_STRING, 0)
- ZEND_ARG_TYPE_INFO(0, codeset, IS_STRING, 1)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, codeset, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#endif
diff --git a/ext/gettext/tests/gettext_textdomain-retval.phpt b/ext/gettext/tests/gettext_textdomain-retval.phpt
index 172a0069afc7f..96b29c7bf946c 100644
--- a/ext/gettext/tests/gettext_textdomain-retval.phpt
+++ b/ext/gettext/tests/gettext_textdomain-retval.phpt
@@ -19,6 +19,12 @@ echo textdomain('test'), "\n";
echo textdomain(null), "\n";
echo textdomain('foo'), "\n";
+try {
+ textdomain('0');
+} catch (\ValueError $e) {
+ echo $e->getMessage() . PHP_EOL;
+}
+
try {
textdomain('');
} catch (\ValueError $e) {
@@ -29,6 +35,7 @@ try {
test
test
foo
+textdomain(): Argument #1 ($domain) cannot be zero
textdomain(): Argument #1 ($domain) cannot be empty
--CREDITS--
Christian Weiske, cweiske@php.net
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index e0024daf90d77..b75c21cfcd067 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -24,7 +24,6 @@
#include "ext/standard/info.h"
#include "ext/standard/file.h"
#include "ext/standard/php_var.h"
-#include "ext/spl/spl_exceptions.h"
#include "zend_attributes.h"
#include "zend_exceptions.h"
diff --git a/ext/hash/murmur/endianness.h b/ext/hash/murmur/endianness.h
index cbad6dc72fb10..11f35a402be3e 100644
--- a/ext/hash/murmur/endianness.h
+++ b/ext/hash/murmur/endianness.h
@@ -13,14 +13,7 @@ FORCE_INLINE int IsBigEndian(void)
# define BSWAP32(u) _byteswap_ulong(u)
# define BSWAP64(u) _byteswap_uint64(u)
#else
-# ifdef __has_builtin
-# if __has_builtin(__builtin_bswap32)
-# define BSWAP32(u) __builtin_bswap32(u)
-# endif // __has_builtin(__builtin_bswap32)
-# if __has_builtin(__builtin_bswap64)
-# define BSWAP64(u) __builtin_bswap64(u)
-# endif // __has_builtin(__builtin_bswap64)
-# elif defined(__GNUC__) && ( \
+# if defined(__GNUC__) && ( \
__GNUC__ > 4 || ( \
__GNUC__ == 4 && ( \
__GNUC_MINOR__ >= 3 \
@@ -29,6 +22,13 @@ FORCE_INLINE int IsBigEndian(void)
)
# define BSWAP32(u) __builtin_bswap32(u)
# define BSWAP64(u) __builtin_bswap64(u)
+# elif defined(__has_builtin)
+# if __has_builtin(__builtin_bswap32)
+# define BSWAP32(u) __builtin_bswap32(u)
+# endif // __has_builtin(__builtin_bswap32)
+# if __has_builtin(__builtin_bswap64)
+# define BSWAP64(u) __builtin_bswap64(u)
+# endif // __has_builtin(__builtin_bswap64)
# endif // __has_builtin
#endif // defined(_MSC_VER)
diff --git a/ext/intl/config.m4 b/ext/intl/config.m4
index 48f5147ca7bbf..78396dc416926 100644
--- a/ext/intl/config.m4
+++ b/ext/intl/config.m4
@@ -82,7 +82,7 @@ if test "$PHP_INTL" != "no"; then
PHP_REQUIRE_CXX()
AC_MSG_CHECKING([if intl requires -std=gnu++17])
- AS_IF([test "$PKG_CONFIG icu-uc --atleast-version=74"],[
+ AS_IF([$PKG_CONFIG icu-uc --atleast-version=74],[
AC_MSG_RESULT([yes])
PHP_CXX_COMPILE_STDCXX(17, mandatory, PHP_INTL_STDCXX)
],[
diff --git a/ext/intl/config.w32 b/ext/intl/config.w32
index ab7dc42b66246..dec7180e62174 100644
--- a/ext/intl/config.w32
+++ b/ext/intl/config.w32
@@ -126,7 +126,6 @@ if (PHP_INTL != "no") {
}
ADD_FLAG("CFLAGS_INTL", "/EHsc /DUNISTR_FROM_CHAR_EXPLICIT=explicit /DUNISTR_FROM_STRING_EXPLICIT=explicit /DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 /DU_HIDE_OBSOLETE_UTF_OLD_H=1");
- AC_DEFINE("HAVE_INTL", 1, "Internationalization support enabled");
} else {
WARNING("intl not enabled; libraries and/or headers not found");
}
diff --git a/ext/intl/dateformat/dateformat.stub.php b/ext/intl/dateformat/dateformat.stub.php
index 06f26b0658739..7582af2717fbe 100644
--- a/ext/intl/dateformat/dateformat.stub.php
+++ b/ext/intl/dateformat/dateformat.stub.php
@@ -159,6 +159,11 @@ public static function formatObject($datetime, $format = null, ?string $locale =
*/
public function parse(string $string, &$offset = null): int|float|false {}
+ /**
+ * @param int $offset
+ */
+ public function parseToCalendar(string $string, &$offset = null): int|float|false {}
+
/**
* @param int $offset
* @return array|false
diff --git a/ext/intl/dateformat/dateformat_arginfo.h b/ext/intl/dateformat/dateformat_arginfo.h
index 4d16a26ef1673..df1de7d6895f4 100644
--- a/ext/intl/dateformat/dateformat_arginfo.h
+++ b/ext/intl/dateformat/dateformat_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 91f1dbe4843fd1d4dff7266e814a3c8f9aed882a */
+ * Stub hash: 56b66b1b51220ddbff698ec4c9a6ae60f3e0bfb0 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
@@ -75,6 +75,11 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_IntlDateFormatte
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, offset, "null")
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_IntlDateFormatter_parseToCalendar, 0, 1, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE)
+ ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
+ ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, offset, "null")
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_IntlDateFormatter_localtime, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, offset, "null")
@@ -104,6 +109,7 @@ ZEND_FUNCTION(datefmt_is_lenient);
ZEND_FUNCTION(datefmt_format);
ZEND_FUNCTION(datefmt_format_object);
ZEND_FUNCTION(datefmt_parse);
+ZEND_METHOD(IntlDateFormatter, parseToCalendar);
ZEND_FUNCTION(datefmt_localtime);
ZEND_FUNCTION(datefmt_get_error_code);
ZEND_FUNCTION(datefmt_get_error_message);
@@ -127,6 +133,7 @@ static const zend_function_entry class_IntlDateFormatter_methods[] = {
ZEND_RAW_FENTRY("format", zif_datefmt_format, arginfo_class_IntlDateFormatter_format, ZEND_ACC_PUBLIC, NULL, NULL)
ZEND_RAW_FENTRY("formatObject", zif_datefmt_format_object, arginfo_class_IntlDateFormatter_formatObject, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL)
ZEND_RAW_FENTRY("parse", zif_datefmt_parse, arginfo_class_IntlDateFormatter_parse, ZEND_ACC_PUBLIC, NULL, NULL)
+ ZEND_ME(IntlDateFormatter, parseToCalendar, arginfo_class_IntlDateFormatter_parseToCalendar, ZEND_ACC_PUBLIC)
ZEND_RAW_FENTRY("localtime", zif_datefmt_localtime, arginfo_class_IntlDateFormatter_localtime, ZEND_ACC_PUBLIC, NULL, NULL)
ZEND_RAW_FENTRY("getErrorCode", zif_datefmt_get_error_code, arginfo_class_IntlDateFormatter_getErrorCode, ZEND_ACC_PUBLIC, NULL, NULL)
ZEND_RAW_FENTRY("getErrorMessage", zif_datefmt_get_error_message, arginfo_class_IntlDateFormatter_getErrorMessage, ZEND_ACC_PUBLIC, NULL, NULL)
diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.c
index 69aeff886d3b9..82b5a71bbee8f 100644
--- a/ext/intl/dateformat/dateformat_parse.c
+++ b/ext/intl/dateformat/dateformat_parse.c
@@ -31,7 +31,7 @@
* if set to 1 - store any error encountered in the parameter parse_error
* if set to 0 - no need to store any error encountered in the parameter parse_error
*/
-static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* text_to_parse, size_t text_len, int32_t *parse_pos, zval *return_value)
+static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* text_to_parse, size_t text_len, int32_t *parse_pos, bool update_calendar, zval *return_value)
{
double result = 0;
UDate timestamp =0;
@@ -42,13 +42,22 @@ static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* tex
intl_convert_utf8_to_utf16(&text_utf16, &text_utf16_len, text_to_parse, text_len, &INTL_DATA_ERROR_CODE(dfo));
INTL_METHOD_CHECK_STATUS(dfo, "Error converting timezone to UTF-16" );
- timestamp = udat_parse( DATE_FORMAT_OBJECT(dfo), text_utf16, text_utf16_len, parse_pos, &INTL_DATA_ERROR_CODE(dfo));
- if( text_utf16 ){
- efree(text_utf16);
+ if (UNEXPECTED(update_calendar)) {
+ UCalendar *parsed_calendar = (UCalendar *)udat_getCalendar(DATE_FORMAT_OBJECT(dfo));
+ udat_parseCalendar(DATE_FORMAT_OBJECT(dfo), parsed_calendar, text_utf16, text_utf16_len, parse_pos, &INTL_DATA_ERROR_CODE(dfo));
+ if (text_utf16) {
+ efree(text_utf16);
+ }
+ INTL_METHOD_CHECK_STATUS( dfo, "Calendar parsing failed" );
+ timestamp = ucal_getMillis( parsed_calendar, &INTL_DATA_ERROR_CODE(dfo));
+ } else {
+ timestamp = udat_parse(DATE_FORMAT_OBJECT(dfo), text_utf16, text_utf16_len, parse_pos, &INTL_DATA_ERROR_CODE(dfo));
+ if (text_utf16) {
+ efree(text_utf16);
+ }
}
INTL_METHOD_CHECK_STATUS( dfo, "Date parsing failed" );
-
/* Since return is in sec. */
result = (double)timestamp / U_MILLIS_PER_SECOND;
if (result > (double)LONG_MAX || result < (double)LONG_MIN) {
@@ -145,18 +154,63 @@ PHP_FUNCTION(datefmt_parse)
RETURN_FALSE;
}
parse_pos = (int32_t)long_parse_pos;
- if((size_t)parse_pos > text_len) {
+ if ((size_t)parse_pos > text_len) {
RETURN_FALSE;
}
}
- internal_parse_to_timestamp( dfo, text_to_parse, text_len, z_parse_pos?&parse_pos:NULL, return_value);
- if(z_parse_pos) {
+ internal_parse_to_timestamp( dfo, text_to_parse, text_len, z_parse_pos ? &parse_pos : NULL, false, return_value);
+ if (z_parse_pos) {
zval_ptr_dtor(z_parse_pos);
ZVAL_LONG(z_parse_pos, parse_pos);
}
}
/* }}} */
+PHP_METHOD(IntlDateFormatter, parseToCalendar)
+{
+ zend_string *text_to_parse = NULL;
+ zval* z_parse_pos = NULL;
+ int32_t parse_pos = -1;
+
+ DATE_FORMAT_METHOD_INIT_VARS;
+
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_STR(text_to_parse)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL(z_parse_pos)
+ ZEND_PARSE_PARAMETERS_END();
+
+ object = ZEND_THIS;
+
+ /* Fetch the object. */
+ DATE_FORMAT_METHOD_FETCH_OBJECT;
+
+ if (z_parse_pos) {
+ zend_long long_parse_pos;
+ ZVAL_DEREF(z_parse_pos);
+ bool failed = false;
+ long_parse_pos = zval_try_get_long(z_parse_pos, &failed);
+ if (failed) {
+ zend_argument_type_error(2, "must be of type int, %s given", zend_zval_value_name(z_parse_pos));
+ RETURN_THROWS();
+ }
+ if (ZEND_LONG_INT_OVFL(long_parse_pos)) {
+ intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
+ intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0);
+ RETURN_FALSE;
+ }
+ parse_pos = (int32_t)long_parse_pos;
+ if (parse_pos != -1 && (size_t)parse_pos > ZSTR_LEN(text_to_parse)) {
+ RETURN_FALSE;
+ }
+ }
+ internal_parse_to_timestamp( dfo, ZSTR_VAL(text_to_parse), ZSTR_LEN(text_to_parse), z_parse_pos ? &parse_pos : NULL, true, return_value);
+ if (z_parse_pos) {
+ zval_ptr_dtor(z_parse_pos);
+ ZVAL_LONG(z_parse_pos, parse_pos);
+ }
+}
+
/* {{{ Parse the string $value to a localtime array */
PHP_FUNCTION(datefmt_localtime)
{
diff --git a/ext/intl/tests/gh13766.phpt b/ext/intl/tests/gh13766.phpt
new file mode 100644
index 0000000000000..70567fa860537
--- /dev/null
+++ b/ext/intl/tests/gh13766.phpt
@@ -0,0 +1,35 @@
+--TEST--
+IntlDateFormatter::parse update its calendar
+--EXTENSIONS--
+intl
+--FILE--
+setTimeZone('Europe/Berlin');
+$oIntlDateFormatter->setPattern('VV');
+
+var_dump($oIntlDateFormatter->parse('America/Los_Angeles', $offset1));
+var_dump($oIntlDateFormatter->getTimeZone()->getID());
+var_dump($oIntlDateFormatter->parseToCalendar('America/Los_Angeles', $offset2));
+var_dump($oIntlDateFormatter->getTimeZone()->getID());
+$offset3 = "offset";
+
+try {
+ $oIntlDateFormatter->parseToCalendar('America/Los_Angeles', $offset3);
+} catch (\TypeError $e) {
+ echo $e->getMessage() . PHP_EOL;
+}
+$offset3 = PHP_INT_MAX * 16;
+try {
+ $oIntlDateFormatter->parseToCalendar('America/Los_Angeles', $offset3);
+} catch (\ValueError $e) {
+ echo $e->getMessage();
+}
+--EXPECTF--
+int(%d)
+string(13) "Europe/Berlin"
+int(%d)
+string(19) "America/Los_Angeles"
+IntlDateFormatter::parseToCalendar(): Argument #2 ($offset) must be of type int, string given
+
+Deprecated: Implicit conversion from float %r(1\.4757395258967641E\+20|34359738352)%r to int loses precision in %s on line %d
diff --git a/ext/ldap/ldap.stub.php b/ext/ldap/ldap.stub.php
index ecda9be7496a9..e10cbc6e508a6 100644
--- a/ext/ldap/ldap.stub.php
+++ b/ext/ldap/ldap.stub.php
@@ -790,12 +790,12 @@ function ldap_8859_to_t61(string $value): string|false {}
* @param string $response_data
* @param string $response_oid
*/
- function ldap_exop(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = UNKNOWN, &$response_oid = null): LDAP\Result|bool {}
+ function ldap_exop(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = null, &$response_data = UNKNOWN, &$response_oid = null): LDAP\Result|bool {}
/**
* @param string $response_data
* @param string $response_oid
*/
- function ldap_exop_sync(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = NULL, &$response_data = null, &$response_oid = null): LDAP\Result|bool {}
+ function ldap_exop_sync(LDAP\Connection $ldap, string $request_oid, ?string $request_data = null, ?array $controls = null, &$response_data = null, &$response_oid = null): LDAP\Result|bool {}
#endif
#ifdef HAVE_LDAP_PASSWD
diff --git a/ext/ldap/ldap_arginfo.h b/ext/ldap/ldap_arginfo.h
index 8993ccb994edb..ed039381762af 100644
--- a/ext/ldap/ldap_arginfo.h
+++ b/ext/ldap/ldap_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: bd41c14d3e28c21238365a28d1ee9806521719af */
+ * Stub hash: 49801a700489ac5c4ffb8c3916278ec7aa002ab6 */
#if defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_connect, 0, 0, LDAP\\Connection, MAY_BE_FALSE)
@@ -310,7 +310,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_exop, 0, 2, LDAP\\Resul
ZEND_ARG_OBJ_INFO(0, ldap, LDAP\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, request_oid, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, request_data, IS_STRING, 1, "null")
- ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "NULL")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
ZEND_ARG_INFO(1, response_data)
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response_oid, "null")
ZEND_END_ARG_INFO()
@@ -321,7 +321,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_ldap_exop_sync, 0, 2, LDAP\\
ZEND_ARG_OBJ_INFO(0, ldap, LDAP\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, request_oid, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, request_data, IS_STRING, 1, "null")
- ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "NULL")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, controls, IS_ARRAY, 1, "null")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response_data, "null")
ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, response_oid, "null")
ZEND_END_ARG_INFO()
diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c
index dc63f2d03858c..3822deed914db 100644
--- a/ext/libxml/libxml.c
+++ b/ext/libxml/libxml.c
@@ -81,6 +81,11 @@ static PHP_MSHUTDOWN_FUNCTION(libxml);
static PHP_MINFO_FUNCTION(libxml);
static zend_result php_libxml_post_deactivate(void);
+static zend_string *php_libxml_default_dump_node_to_str(xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding);
+static zend_string *php_libxml_default_dump_doc_to_str(xmlDocPtr doc, int options, const char *encoding);
+static zend_long php_libxml_dump_node_to_file(const char *filename, xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding);
+static zend_long php_libxml_default_dump_doc_to_file(const char *filename, xmlDocPtr doc, bool format, const char *encoding);
+
/* }}} */
zend_module_entry libxml_module_entry = {
@@ -102,6 +107,13 @@ zend_module_entry libxml_module_entry = {
/* }}} */
+static const php_libxml_document_handlers php_libxml_default_document_handlers = {
+ .dump_node_to_str = php_libxml_default_dump_node_to_str,
+ .dump_doc_to_str = php_libxml_default_dump_doc_to_str,
+ .dump_node_to_file = php_libxml_dump_node_to_file,
+ .dump_doc_to_file = php_libxml_default_dump_doc_to_file,
+};
+
static void php_libxml_set_old_ns_list(xmlDocPtr doc, xmlNsPtr first, xmlNsPtr last)
{
if (UNEXPECTED(doc == NULL)) {
@@ -151,18 +163,16 @@ static void php_libxml_unlink_entity(void *data, void *table, xmlChar *name)
/* {{{ internal functions for interoperability */
static void php_libxml_unregister_node(xmlNodePtr nodep)
{
- php_libxml_node_object *wrapper;
-
php_libxml_node_ptr *nodeptr = nodep->_private;
if (nodeptr != NULL) {
- wrapper = nodeptr->_private;
+ php_libxml_node_object *wrapper = nodeptr->_private;
if (wrapper) {
php_libxml_decrement_node_ptr(wrapper);
php_libxml_decrement_doc_ref(wrapper);
} else {
- if (nodeptr->node != NULL && nodeptr->node->type != XML_DOCUMENT_NODE) {
- nodeptr->node->_private = NULL;
+ if (nodep->type != XML_DOCUMENT_NODE) {
+ nodep->_private = NULL;
}
nodeptr->node = NULL;
}
@@ -333,14 +343,12 @@ PHP_LIBXML_API void php_libxml_node_free_list(xmlNodePtr node)
node = curnode;
switch (node->type) {
/* Skip property freeing for the following types */
+ case XML_ENTITY_REF_NODE:
case XML_NOTATION_NODE:
break;
case XML_ENTITY_DECL:
php_libxml_unlink_entity_decl((xmlEntityPtr) node);
break;
- case XML_ENTITY_REF_NODE:
- php_libxml_node_free_list((xmlNodePtr) node->properties);
- break;
case XML_ATTRIBUTE_NODE:
if ((node->doc != NULL) && (((xmlAttrPtr) node)->atype == XML_ATTRIBUTE_ID)) {
xmlRemoveID(node->doc, (xmlAttrPtr) node);
@@ -391,20 +399,16 @@ PHP_LIBXML_API php_stream_context *php_libxml_get_stream_context(void)
static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char *mode, const int read_only)
{
php_stream_statbuf ssbuf;
- php_stream_context *context = NULL;
- php_stream_wrapper *wrapper = NULL;
char *resolved_path;
const char *path_to_open = NULL;
- void *ret_val = NULL;
- int isescaped=0;
- xmlURI *uri;
+ bool isescaped = false;
if (strstr(filename, "%00")) {
php_error_docref(NULL, E_WARNING, "URI must not contain percent-encoded NUL bytes");
return NULL;
}
- uri = xmlParseURI(filename);
+ xmlURI *uri = xmlParseURI(filename);
if (uri && (uri->scheme == NULL ||
(xmlStrncmp(BAD_CAST uri->scheme, BAD_CAST "file", 4) == 0))) {
resolved_path = xmlURIUnescapeString(filename, 0, NULL);
@@ -442,7 +446,7 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
that the streams layer puts out at times, but for libxml we
may try to open files that don't exist, but it is not a failure
in xml processing (eg. DTD files) */
- wrapper = php_stream_locate_url_wrapper(resolved_path, &path_to_open, 0);
+ php_stream_wrapper *wrapper = php_stream_locate_url_wrapper(resolved_path, &path_to_open, 0);
if (wrapper && read_only && wrapper->wops->url_stat) {
if (wrapper->wops->url_stat(wrapper, path_to_open, PHP_STREAM_URL_STAT_QUIET, &ssbuf, NULL) == -1) {
if (isescaped) {
@@ -452,12 +456,12 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char
}
}
- context = php_libxml_get_stream_context();
+ php_stream_context *context = php_libxml_get_stream_context();
- ret_val = php_stream_open_wrapper_ex(path_to_open, (char *)mode, REPORT_ERRORS, NULL, context);
+ php_stream *ret_val = php_stream_open_wrapper_ex(path_to_open, mode, REPORT_ERRORS, NULL, context);
if (ret_val) {
/* Prevent from closing this by fclose() */
- ((php_stream*)ret_val)->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
+ ret_val->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
}
if (isescaped) {
xmlFree(resolved_path);
@@ -647,22 +651,22 @@ void php_libxml_issue_error(int level, const char *msg)
static void php_libxml_internal_error_handler_ex(php_libxml_error_level error_type, void *ctx, const char *msg, va_list ap, int line, int column)
{
char *buf;
- int len, len_iter, output = 0;
+ bool output = false;
- len = vspprintf(&buf, 0, msg, ap);
- len_iter = len;
+ size_t len = vspprintf(&buf, 0, msg, ap);
+ size_t len_iter = len;
/* remove any trailing \n */
while (len_iter && buf[--len_iter] == '\n') {
buf[len_iter] = '\0';
- output = 1;
+ output = true;
}
smart_str_appendl(&LIBXML(error_buffer), buf, len);
efree(buf);
- if (output == 1) {
+ if (output) {
if (LIBXML(error_list)) {
_php_list_set_error_structure(NULL, ZSTR_VAL(LIBXML(error_buffer).s), line, column);
} else if (!EG(exception)) {
@@ -1352,6 +1356,7 @@ PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object,
object->document->cache_tag.modification_nr = 1; /* iterators start at 0, such that they will start in an uninitialised state */
object->document->private_data = NULL;
object->document->class_type = PHP_LIBXML_CLASS_UNSET;
+ object->document->handlers = &php_libxml_default_document_handlers;
}
return ret_refcount;
@@ -1414,18 +1419,8 @@ PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node)
default:
if (node->parent == NULL || node->type == XML_NAMESPACE_DECL) {
php_libxml_node_free_list((xmlNodePtr) node->children);
- switch (node->type) {
- /* Skip property freeing for the following types */
- case XML_ATTRIBUTE_DECL:
- case XML_DTD_NODE:
- case XML_DOCUMENT_TYPE_NODE:
- case XML_ENTITY_DECL:
- case XML_ATTRIBUTE_NODE:
- case XML_NAMESPACE_DECL:
- case XML_TEXT_NODE:
- break;
- default:
- php_libxml_node_free_list((xmlNodePtr) node->properties);
+ if (node->type == XML_ELEMENT_NODE) {
+ php_libxml_node_free_list((xmlNodePtr) node->properties);
}
php_libxml_unregister_node(node);
php_libxml_node_free(node);
@@ -1456,6 +1451,101 @@ PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *o
}
/* }}} */
+PHP_LIBXML_API xmlChar *php_libxml_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;
+}
+
+static int php_libxml_write_smart_str(void *context, const char *buffer, int len)
+{
+ smart_str *str = context;
+ smart_str_appendl(str, buffer, len);
+ return len;
+}
+
+static zend_string *php_libxml_default_dump_doc_to_str(xmlDocPtr doc, int options, const char *encoding)
+{
+ smart_str str = {0};
+
+ /* Encoding is handled from the encoding property set on the document */
+ xmlSaveCtxtPtr ctxt = xmlSaveToIO(php_libxml_write_smart_str, NULL, &str, encoding, options);
+ if (!ctxt) {
+ return NULL;
+ }
+
+ long status = xmlSaveDoc(ctxt, doc);
+ (void) xmlSaveClose(ctxt);
+ if (status < 0) {
+ smart_str_free_ex(&str, false);
+ return NULL;
+ }
+
+ return smart_str_extract(&str);
+}
+
+static zend_string *php_libxml_default_dump_node_to_str(xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding)
+{
+ smart_str str = {0};
+ // TODO: should this buffer take an encoding? For now keep it NULL for BC.
+ xmlOutputBufferPtr buf = xmlOutputBufferCreateIO(php_libxml_write_smart_str, NULL, &str, NULL);
+ if (!buf) {
+ return NULL;
+ }
+
+ xmlNodeDumpOutput(buf, doc, node, 0, format, encoding);
+
+ if (xmlOutputBufferFlush(buf) < 0) {
+ smart_str_free_ex(&str, false);
+ xmlOutputBufferClose(buf);
+ return NULL;
+ }
+
+ xmlOutputBufferClose(buf);
+
+ return smart_str_extract(&str);
+}
+
+static zend_long php_libxml_default_dump_doc_to_file(const char *filename, xmlDocPtr doc, bool format, const char *encoding)
+{
+ return xmlSaveFormatFileEnc(filename, doc, encoding, format);
+}
+
+static zend_long php_libxml_dump_node_to_file(const char *filename, xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding)
+{
+ xmlOutputBufferPtr outbuf = xmlOutputBufferCreateFilename(filename, NULL, 0);
+ if (!outbuf) {
+ return -1;
+ }
+
+ xmlNodeDumpOutput(outbuf, doc, node, 0, format, encoding);
+ return xmlOutputBufferClose(outbuf);
+}
+
#if defined(PHP_WIN32) && defined(COMPILE_DL_LIBXML)
PHP_LIBXML_API BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h
index b9262f5e96944..4d799c39b165f 100644
--- a/ext/libxml/php_libxml.h
+++ b/ext/libxml/php_libxml.h
@@ -67,6 +67,18 @@ typedef struct _php_libxml_private_data_header {
/* extra fields */
} php_libxml_private_data_header;
+/**
+ * It's possible to set custom handlers for certain actions depending on the type of document.
+ * For example, there exist multiple ways to serialize an XML document,
+ * therefore this structure allows setting up a custom handler.
+ */
+typedef struct php_libxml_document_handlers {
+ zend_string *(*dump_node_to_str)(xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding);
+ zend_string *(*dump_doc_to_str)(xmlDocPtr doc, int options, const char *encoding);
+ zend_long (*dump_node_to_file)(const char *filename, xmlDocPtr doc, xmlNodePtr node, bool format, const char *encoding);
+ zend_long (*dump_doc_to_file)(const char *filename, xmlDocPtr doc, bool format, const char *encoding);
+} php_libxml_document_handlers;
+
/**
* Multiple representations are possible of the same underlying node data.
* This is the case for example when a SimpleXML node is imported into DOM.
@@ -88,6 +100,7 @@ typedef struct _php_libxml_ref_obj {
libxml_doc_props *doc_props;
php_libxml_cache_tag cache_tag;
php_libxml_private_data_header *private_data;
+ const php_libxml_document_handlers *handlers;
int refcount;
php_libxml_class_type class_type;
} php_libxml_ref_obj;
@@ -172,6 +185,8 @@ PHP_LIBXML_API void php_libxml_set_old_ns(xmlDocPtr doc, xmlNsPtr ns);
PHP_LIBXML_API php_stream_context *php_libxml_get_stream_context(void);
PHP_LIBXML_API bool php_libxml_uses_internal_errors(void);
+PHP_LIBXML_API xmlChar *php_libxml_attr_value(const xmlAttr *attr, bool *free);
+
PHP_LIBXML_API zend_string *php_libxml_sniff_charset_from_string(const char *start, const char *end);
PHP_LIBXML_API zend_string *php_libxml_sniff_charset_from_stream(const php_stream *s);
diff --git a/ext/libxml/tests/libxml_get_external_entity_loader_error_callback_name.phpt b/ext/libxml/tests/libxml_get_external_entity_loader_error_callback_name.phpt
index 1bdbbfb5b817e..20e783e279848 100644
--- a/ext/libxml/tests/libxml_get_external_entity_loader_error_callback_name.phpt
+++ b/ext/libxml/tests/libxml_get_external_entity_loader_error_callback_name.phpt
@@ -2,7 +2,8 @@
libxml_get_external_entity_loader() display correct callable name
--EXTENSIONS--
dom
-dba
+--SKIPIF--
+
--FILE--
getMessage());
}
-?>
---CLEAN--
-
--EXPECT--
string(73) "DOMDocument::validate(): supplied resource is not a valid stream resource"
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index f48c14feb7a10..fc22ca669c7ae 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -731,7 +731,7 @@ void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend
/* TODO: We don't have access to the connection object at this point, so we use low-level
* mysqlnd APIs to access the error information. We should try to pass through the connection
* object instead. */
- if (MyG(report_mode) & MYSQLI_REPORT_ERROR) {
+ if (MyG(report_mode) & MYSQLI_REPORT_ERROR && result->conn) {
MYSQLND_CONN_DATA *conn = result->conn;
unsigned error_no = conn->m->get_error_no(conn);
if (error_no) {
diff --git a/ext/mysqli/tests/gh14255.phpt b/ext/mysqli/tests/gh14255.phpt
new file mode 100644
index 0000000000000..375eda0c5b52c
--- /dev/null
+++ b/ext/mysqli/tests/gh14255.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug GH-14255 (mysqli_fetch_assoc reports error from nested query)
+--EXTENSIONS--
+mysqli
+--SKIPIF--
+
+--FILE--
+query('SELECT 1 ');
+$c = $ca->fetch_assoc();
+try {
+ $mysqli->query('SELECT non_existent_column');
+} catch (Exception $e) {
+ echo "Caught exception"."\n";
+}
+$c = $ca->fetch_assoc();
+
+print "done!";
+?>
+--EXPECTF--
+Caught exception
+done!
diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4
index 222fcd935ebc0..93f5b8f992b38 100644
--- a/ext/mysqlnd/config9.m4
+++ b/ext/mysqlnd/config9.m4
@@ -6,6 +6,15 @@ PHP_ARG_ENABLE([mysqlnd],
[no],
[yes])
+PHP_ARG_WITH([mysqlnd-ssl],
+ [whether to explicitly enable SSL support in mysqlnd],
+ [AS_HELP_STRING([--with-mysqlnd-ssl],
+ [Explicitly enable SSL support in ext/mysqlnd when not building with
+ ext/openssl. If ext/openssl is enabled at the configure step, SSL is enabled
+ implicitly.])],
+ [no],
+ [no])
+
PHP_ARG_ENABLE([mysqlnd-compression-support],
[whether to enable compressed protocol support in mysqlnd],
[AS_HELP_STRING([--disable-mysqlnd-compression-support],
@@ -32,13 +41,15 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
AC_DEFINE([MYSQLND_SSL_SUPPORTED], 1, [Enable core mysqlnd SSL code])
+ dnl Empty variable means 'no' (for phpize builds).
test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
- if test "$PHP_OPENSSL" != "no" || test "$PHP_OPENSSL_DIR" != "no"; then
+ if test "$PHP_OPENSSL" != "no" || test "$PHP_MYSQLND_SSL" != "no"; then
PHP_SETUP_OPENSSL(MYSQLND_SHARED_LIBADD, [AC_DEFINE(MYSQLND_HAVE_SSL,1,[Enable mysqlnd code that uses OpenSSL directly])])
fi
mysqlnd_sources="$mysqlnd_base_sources $mysqlnd_ps_sources"
PHP_NEW_EXTENSION(mysqlnd, $mysqlnd_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_INSTALL_HEADERS([ext/mysqlnd/])
+ PHP_SUBST([MYSQLND_SHARED_LIBADD])
fi
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index 08faed6d05874..ad63147861ea8 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -970,6 +970,13 @@ MYSQLND_METHOD(mysqlnd_res, fetch_into)(MYSQLND_RES * result, const unsigned int
bool fetched_anything;
zval *row_data;
+ // We clean the error here because in unbuffered mode we could receive a new error
+ // and therefore consumers of this method are checking for errors
+ MYSQLND_CONN_DATA *conn = result->conn;
+ if (conn) {
+ SET_EMPTY_ERROR(conn->error_info);
+ }
+
DBG_ENTER("mysqlnd_res::fetch_into");
if (FAIL == result->m.fetch_row(result, &row_data, flags, &fetched_anything)) {
RETVAL_FALSE;
diff --git a/ext/odbc/odbc.stub.php b/ext/odbc/odbc.stub.php
index 8432260ba6996..8e7a43d059dfc 100644
--- a/ext/odbc/odbc.stub.php
+++ b/ext/odbc/odbc.stub.php
@@ -2,520 +2,447 @@
/** @generate-class-entries */
-/**
- * @var string
- * @cvalue PHP_ODBC_TYPE
- */
-const ODBC_TYPE = UNKNOWN;
-/**
- * @var int
- * @cvalue PHP_ODBC_BINMODE_PASSTHRU
- */
-const ODBC_BINMODE_PASSTHRU = UNKNOWN;
-/**
- * @var int
- * @cvalue PHP_ODBC_BINMODE_RETURN
- */
-const ODBC_BINMODE_RETURN = UNKNOWN;
-/**
- * @var int
- * @cvalue PHP_ODBC_BINMODE_CONVERT
- */
-const ODBC_BINMODE_CONVERT = UNKNOWN;
-
-/* Define Constants for options. These Constants are defined in */
-
-/**
- * @var int
- * @cvalue SQL_ODBC_CURSORS
- */
-const SQL_ODBC_CURSORS = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CUR_USE_DRIVER
- */
-const SQL_CUR_USE_DRIVER = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CUR_USE_IF_NEEDED
- */
-const SQL_CUR_USE_IF_NEEDED = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CUR_USE_ODBC
- */
-const SQL_CUR_USE_ODBC = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SQL_CONCURRENCY
- */
-const SQL_CONCURRENCY = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CONCUR_READ_ONLY
- */
-const SQL_CONCUR_READ_ONLY = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CONCUR_LOCK
- */
-const SQL_CONCUR_LOCK = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CONCUR_ROWVER
- */
-const SQL_CONCUR_ROWVER = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CONCUR_VALUES
- */
-const SQL_CONCUR_VALUES = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SQL_CURSOR_TYPE
- */
-const SQL_CURSOR_TYPE = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CURSOR_FORWARD_ONLY
- */
-const SQL_CURSOR_FORWARD_ONLY = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CURSOR_KEYSET_DRIVEN
- */
-const SQL_CURSOR_KEYSET_DRIVEN = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CURSOR_DYNAMIC
- */
-const SQL_CURSOR_DYNAMIC = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_CURSOR_STATIC
- */
-const SQL_CURSOR_STATIC = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SQL_KEYSET_SIZE
- */
-const SQL_KEYSET_SIZE = UNKNOWN;
-
-/* these are for the Data Source type */
-
-/**
- * @var int
- * @cvalue SQL_FETCH_FIRST
- */
-const SQL_FETCH_FIRST = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_FETCH_NEXT
- */
-const SQL_FETCH_NEXT = UNKNOWN;
-
-/* register the standard data types */
-
-/**
- * @var int
- * @cvalue SQL_CHAR
- */
-const SQL_CHAR = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_VARCHAR
- */
-const SQL_VARCHAR = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_LONGVARCHAR
- */
-const SQL_LONGVARCHAR = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_DECIMAL
- */
-const SQL_DECIMAL = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_NUMERIC
- */
-const SQL_NUMERIC = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_BIT
- */
-const SQL_BIT = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_TINYINT
- */
-const SQL_TINYINT = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_SMALLINT
- */
-const SQL_SMALLINT = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_INTEGER
- */
-const SQL_INTEGER = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_BIGINT
- */
-const SQL_BIGINT = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_REAL
- */
-const SQL_REAL = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_FLOAT
- */
-const SQL_FLOAT = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_DOUBLE
- */
-const SQL_DOUBLE = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_BINARY
- */
-const SQL_BINARY = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_VARBINARY
- */
-const SQL_VARBINARY = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_LONGVARBINARY
- */
-const SQL_LONGVARBINARY = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_DATE
- */
-const SQL_DATE = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_TIME
- */
-const SQL_TIME = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_TIMESTAMP
- */
-const SQL_TIMESTAMP = UNKNOWN;
+namespace Odbc {
+ /**
+ * @strict-properties
+ * @not-serializable
+ */
+ class Connection
+ {
+ }
+
+ /**
+ * @strict-properties
+ * @not-serializable
+ */
+ class Result
+ {
+ }
+}
+
+namespace {
+ /**
+ * @var string
+ * @cvalue PHP_ODBC_TYPE
+ */
+ const ODBC_TYPE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue PHP_ODBC_BINMODE_PASSTHRU
+ */
+ const ODBC_BINMODE_PASSTHRU = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue PHP_ODBC_BINMODE_RETURN
+ */
+ const ODBC_BINMODE_RETURN = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue PHP_ODBC_BINMODE_CONVERT
+ */
+ const ODBC_BINMODE_CONVERT = UNKNOWN;
+
+ /* Define Constants for options. These Constants are defined in */
+
+ /**
+ * @var int
+ * @cvalue SQL_ODBC_CURSORS
+ */
+ const SQL_ODBC_CURSORS = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CUR_USE_DRIVER
+ */
+ const SQL_CUR_USE_DRIVER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CUR_USE_IF_NEEDED
+ */
+ const SQL_CUR_USE_IF_NEEDED = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CUR_USE_ODBC
+ */
+ const SQL_CUR_USE_ODBC = UNKNOWN;
+
+ /**
+ * @var int
+ * @cvalue SQL_CONCURRENCY
+ */
+ const SQL_CONCURRENCY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CONCUR_READ_ONLY
+ */
+ const SQL_CONCUR_READ_ONLY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CONCUR_LOCK
+ */
+ const SQL_CONCUR_LOCK = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CONCUR_ROWVER
+ */
+ const SQL_CONCUR_ROWVER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CONCUR_VALUES
+ */
+ const SQL_CONCUR_VALUES = UNKNOWN;
+
+ /**
+ * @var int
+ * @cvalue SQL_CURSOR_TYPE
+ */
+ const SQL_CURSOR_TYPE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CURSOR_FORWARD_ONLY
+ */
+ const SQL_CURSOR_FORWARD_ONLY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CURSOR_KEYSET_DRIVEN
+ */
+ const SQL_CURSOR_KEYSET_DRIVEN = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CURSOR_DYNAMIC
+ */
+ const SQL_CURSOR_DYNAMIC = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_CURSOR_STATIC
+ */
+ const SQL_CURSOR_STATIC = UNKNOWN;
+
+ /**
+ * @var int
+ * @cvalue SQL_KEYSET_SIZE
+ */
+ const SQL_KEYSET_SIZE = UNKNOWN;
+
+ /* these are for the Data Source type */
+
+ /**
+ * @var int
+ * @cvalue SQL_FETCH_FIRST
+ */
+ const SQL_FETCH_FIRST = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_FETCH_NEXT
+ */
+ const SQL_FETCH_NEXT = UNKNOWN;
+
+ /* register the standard data types */
+
+ /**
+ * @var int
+ * @cvalue SQL_CHAR
+ */
+ const SQL_CHAR = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_VARCHAR
+ */
+ const SQL_VARCHAR = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_LONGVARCHAR
+ */
+ const SQL_LONGVARCHAR = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_DECIMAL
+ */
+ const SQL_DECIMAL = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_NUMERIC
+ */
+ const SQL_NUMERIC = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_BIT
+ */
+ const SQL_BIT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_TINYINT
+ */
+ const SQL_TINYINT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_SMALLINT
+ */
+ const SQL_SMALLINT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_INTEGER
+ */
+ const SQL_INTEGER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_BIGINT
+ */
+ const SQL_BIGINT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_REAL
+ */
+ const SQL_REAL = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_FLOAT
+ */
+ const SQL_FLOAT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_DOUBLE
+ */
+ const SQL_DOUBLE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_BINARY
+ */
+ const SQL_BINARY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_VARBINARY
+ */
+ const SQL_VARBINARY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_LONGVARBINARY
+ */
+ const SQL_LONGVARBINARY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_DATE
+ */
+ const SQL_DATE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_TIME
+ */
+ const SQL_TIME = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_TIMESTAMP
+ */
+ const SQL_TIMESTAMP = UNKNOWN;
#if (defined(ODBCVER) && (ODBCVER >= 0x0300))
-/**
- * @var int
- * @cvalue SQL_TYPE_DATE
- */
-const SQL_TYPE_DATE = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_TYPE_TIME
- */
-const SQL_TYPE_TIME = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_TYPE_TIMESTAMP
- */
-const SQL_TYPE_TIMESTAMP = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_WCHAR
- */
-const SQL_WCHAR = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_WVARCHAR
- */
-const SQL_WVARCHAR = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_WLONGVARCHAR
- */
-const SQL_WLONGVARCHAR = UNKNOWN;
-
-/* SQLSpecialColumns values */
-
-/**
- * @var int
- * @cvalue SQL_BEST_ROWID
- */
-const SQL_BEST_ROWID = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_ROWVER
- */
-const SQL_ROWVER = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_SCOPE_CURROW
- */
-const SQL_SCOPE_CURROW = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_SCOPE_TRANSACTION
- */
-const SQL_SCOPE_TRANSACTION = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_SCOPE_SESSION
- */
-const SQL_SCOPE_SESSION = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_NO_NULLS
- */
-const SQL_NO_NULLS = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_NULLABLE
- */
-const SQL_NULLABLE = UNKNOWN;
-
-/* SQLStatistics values */
-
-/**
- * @var int
- * @cvalue SQL_INDEX_UNIQUE
- */
-const SQL_INDEX_UNIQUE = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_INDEX_ALL
- */
-const SQL_INDEX_ALL = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_ENSURE
- */
-const SQL_ENSURE = UNKNOWN;
-/**
- * @var int
- * @cvalue SQL_QUICK
- */
-const SQL_QUICK = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_TYPE_DATE
+ */
+ const SQL_TYPE_DATE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_TYPE_TIME
+ */
+ const SQL_TYPE_TIME = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_TYPE_TIMESTAMP
+ */
+ const SQL_TYPE_TIMESTAMP = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_WCHAR
+ */
+ const SQL_WCHAR = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_WVARCHAR
+ */
+ const SQL_WVARCHAR = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_WLONGVARCHAR
+ */
+ const SQL_WLONGVARCHAR = UNKNOWN;
+
+ /* SQLSpecialColumns values */
+
+ /**
+ * @var int
+ * @cvalue SQL_BEST_ROWID
+ */
+ const SQL_BEST_ROWID = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_ROWVER
+ */
+ const SQL_ROWVER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_SCOPE_CURROW
+ */
+ const SQL_SCOPE_CURROW = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_SCOPE_TRANSACTION
+ */
+ const SQL_SCOPE_TRANSACTION = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_SCOPE_SESSION
+ */
+ const SQL_SCOPE_SESSION = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_NO_NULLS
+ */
+ const SQL_NO_NULLS = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_NULLABLE
+ */
+ const SQL_NULLABLE = UNKNOWN;
+
+ /* SQLStatistics values */
+
+ /**
+ * @var int
+ * @cvalue SQL_INDEX_UNIQUE
+ */
+ const SQL_INDEX_UNIQUE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_INDEX_ALL
+ */
+ const SQL_INDEX_ALL = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_ENSURE
+ */
+ const SQL_ENSURE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SQL_QUICK
+ */
+ const SQL_QUICK = UNKNOWN;
#endif
+ function odbc_close_all(): void {}
+ function odbc_binmode(Odbc\Result $statement, int $mode): true {}
-function odbc_close_all(): void {}
+ function odbc_longreadlen(Odbc\Result $statement, int $length): true {}
-/** @param resource $statement */
-function odbc_binmode($statement, int $mode): true {}
+ function odbc_prepare(Odbc\Connection $odbc, string $query): Odbc\Result|false {}
-/** @param resource $statement */
-function odbc_longreadlen($statement, int $length): true {}
+ function odbc_execute(Odbc\Result $statement, array $params = []): bool {}
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_prepare($odbc, string $query) {}
-
-/** @param resource $statement */
-function odbc_execute($statement, array $params = []): bool {}
-
-/** @param resource $statement */
-function odbc_cursor($statement): string|false {}
+ function odbc_cursor(Odbc\Result $statement): string|false {}
#ifdef HAVE_SQLDATASOURCES
-/** @param resource $odbc */
-function odbc_data_source($odbc, int $fetch_type): array|null|false {}
+ function odbc_data_source(Odbc\Connection $odbc, int $fetch_type): array|null|false {}
#endif
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_exec($odbc, string $query) {}
+ function odbc_exec(Odbc\Connection $odbc, string $query): Odbc\Result|false {}
-/**
- * @param resource $odbc
- * @return resource|false
- * @alias odbc_exec
- */
-function odbc_do($odbc, string $query) {}
+ /** @alias odbc_exec */
+ function odbc_do(Odbc\Connection $odbc, string $query): Odbc\Result|false {}
#ifdef PHP_ODBC_HAVE_FETCH_HASH
-/** @param resource $statement */
-function odbc_fetch_object($statement, ?int $row = null): stdClass|false {}
+ /** @param resource $statement */
+ function odbc_fetch_object($statement, ?int $row = null): stdClass|false {}
-/** @param resource $statement */
-function odbc_fetch_array($statement, ?int $row = null): array|false {}
+ /** @param resource $statement */
+ function odbc_fetch_array($statement, ?int $row = null): array|false {}
#endif
-/**
- * @param resource $statement
- * @param array $array
- */
-function odbc_fetch_into($statement, &$array, ?int $row = null): int|false {}
+ /**
+ * @param resource $statement
+ * @param array $array
+ */
+ function odbc_fetch_into($statement, &$array, ?int $row = null): int|false {}
-/** @param resource $statement */
-function odbc_fetch_row($statement, ?int $row = null): bool {}
+ function odbc_fetch_row(Odbc\Result $statement, ?int $row = null): bool {}
-/** @param resource $statement */
-function odbc_result($statement, string|int $field): string|bool|null {}
+ function odbc_result(Odbc\Result $statement, string|int $field): string|bool|null {}
-/**
- * @param resource $statement
- * @deprecated
- */
-function odbc_result_all($statement, string $format = ""): int|false {}
+ /** @deprecated */
+ function odbc_result_all(Odbc\Result $statement, string $format = ""): int|false {}
-/** @param resource $statement */
-function odbc_free_result($statement): true {}
+ function odbc_free_result(Odbc\Result $statement): true {}
-/**
- * @return resource|false
- */
-function odbc_connect(string $dsn, ?string $user = null, #[\SensitiveParameter] ?string $password = null, int $cursor_option = SQL_CUR_USE_DRIVER) {}
+ function odbc_connect(string $dsn, ?string $user = null, #[\SensitiveParameter] ?string $password = null, int $cursor_option = SQL_CUR_USE_DRIVER): Odbc\Connection|false {}
-/**
- * @return resource|false
- */
-function odbc_pconnect(string $dsn, ?string $user = null, #[\SensitiveParameter] ?string $password = null, int $cursor_option = SQL_CUR_USE_DRIVER) {}
+ function odbc_pconnect(string $dsn, ?string $user = null, #[\SensitiveParameter] ?string $password = null, int $cursor_option = SQL_CUR_USE_DRIVER): Odbc\Connection|false {}
-/** @param resource $odbc */
-function odbc_close($odbc): void {}
+ function odbc_close(Odbc\Connection $odbc): void {}
-/** @param resource $statement */
-function odbc_num_rows($statement): int {}
+ function odbc_num_rows(Odbc\Result $statement): int {}
#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30)
-/** @param resource $statement */
-function odbc_next_result($statement): bool {}
+ function odbc_next_result(Odbc\Result $statement): bool {}
#endif
-/** @param resource $statement */
-function odbc_num_fields($statement): int {}
+ function odbc_num_fields(Odbc\Result $statement): int {}
-/** @param resource $statement */
-function odbc_field_name($statement, int $field): string|false {}
+ function odbc_field_name(Odbc\Result $statement, int $field): string|false {}
-/** @param resource $statement */
-function odbc_field_type($statement, int $field): string|false {}
+ function odbc_field_type(Odbc\Result $statement, int $field): string|false {}
-/** @param resource $statement */
-function odbc_field_len($statement, int $field): int|false {}
+ function odbc_field_len(Odbc\Result $statement, int $field): int|false {}
-/**
- * @param resource $statement
- * @alias odbc_field_len
- */
-function odbc_field_precision($statement, int $field): int|false {}
+ /** @alias odbc_field_len */
+ function odbc_field_precision(Odbc\Result $statement, int $field): int|false {}
-/** @param resource $statement */
-function odbc_field_scale($statement, int $field): int|false {}
+ function odbc_field_scale(Odbc\Result $statement, int $field): int|false {}
-/** @param resource $statement */
-function odbc_field_num($statement, string $field): int|false {}
+ function odbc_field_num(Odbc\Result $statement, string $field): int|false {}
-/** @param resource $odbc */
-function odbc_autocommit($odbc, ?bool $enable = null): int|bool {}
+ function odbc_autocommit(Odbc\Connection $odbc, ?bool $enable = null): int|bool {}
-/** @param resource $odbc */
-function odbc_commit($odbc): bool {}
+ function odbc_commit(Odbc\Connection $odbc): bool {}
-/** @param resource $odbc */
-function odbc_rollback($odbc): bool {}
+ function odbc_rollback(Odbc\Connection $odbc): bool {}
-/** @param resource|null $odbc */
-function odbc_error($odbc = null): string {}
+ function odbc_error(?Odbc\Connection $odbc = null): string {}
-/** @param resource|null $odbc */
-function odbc_errormsg($odbc = null): string {}
+ function odbc_errormsg(?Odbc\Connection $odbc = null): string {}
-/** @param resource $odbc */
-function odbc_setoption($odbc, int $which, int $option, int $value): bool {}
+ function odbc_setoption(Odbc\Connection|Odbc\Result $odbc, int $which, int $option, int $value): bool {}
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_tables($odbc, ?string $catalog = null, ?string $schema = null, ?string $table = null, ?string $types = null) {}
+ function odbc_tables(Odbc\Connection $odbc, ?string $catalog = null, ?string $schema = null, ?string $table = null, ?string $types = null): Odbc\Result|false {}
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_columns($odbc, ?string $catalog = null, ?string $schema = null, ?string $table = null, ?string $column = null) {}
+ function odbc_columns(Odbc\Connection $odbc, ?string $catalog = null, ?string $schema = null, ?string $table = null, ?string $column = null): Odbc\Result|false {}
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_gettypeinfo($odbc, int $data_type = 0) {}
+ function odbc_gettypeinfo(Odbc\Connection $odbc, int $data_type = 0): Odbc\Result|false {}
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_primarykeys($odbc, ?string $catalog, string $schema, string $table) {}
+ function odbc_primarykeys(Odbc\Connection $odbc, ?string $catalog, string $schema, string $table): Odbc\Result|false {}
#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35)
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_procedurecolumns($odbc, ?string $catalog = null, ?string $schema = null, ?string $procedure = null, ?string $column = null) {}
-
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_procedures($odbc, ?string $catalog = null, ?string $schema = null, ?string $procedure = null) {}
-
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_foreignkeys($odbc, ?string $pk_catalog, string $pk_schema, string $pk_table, string $fk_catalog, string $fk_schema, string $fk_table) {}
+ function odbc_procedurecolumns(Odbc\Connection $odbc, ?string $catalog = null, ?string $schema = null, ?string $procedure = null, ?string $column = null): Odbc\Result|false {}
+
+ function odbc_procedures(Odbc\Connection $odbc, ?string $catalog = null, ?string $schema = null, ?string $procedure = null): Odbc\Result|false {}
+
+ function odbc_foreignkeys(Odbc\Connection $odbc, ?string $pk_catalog, string $pk_schema, string $pk_table, string $fk_catalog, string $fk_schema, string $fk_table): Odbc\Result|false {}
#endif
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_specialcolumns($odbc, int $type, ?string $catalog, string $schema, string $table, int $scope, int $nullable) {}
+ function odbc_specialcolumns(Odbc\Connection $odbc, int $type, ?string $catalog, string $schema, string $table, int $scope, int $nullable): Odbc\Result|false {}
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_statistics($odbc, ?string $catalog, string $schema, string $table, int $unique, int $accuracy) {}
+ function odbc_statistics(Odbc\Connection $odbc, ?string $catalog, string $schema, string $table, int $unique, int $accuracy): Odbc\Result|false {}
#if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35)
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_tableprivileges($odbc, ?string $catalog, string $schema, string $table) {}
-
-/**
- * @param resource $odbc
- * @return resource|false
- */
-function odbc_columnprivileges($odbc, ?string $catalog, string $schema, string $table, string $column) {}
+ function odbc_tableprivileges(Odbc\Connection $odbc, ?string $catalog, string $schema, string $table): Odbc\Result|false {}
+
+ function odbc_columnprivileges(Odbc\Connection $odbc, ?string $catalog, string $schema, string $table, string $column): Odbc\Result|false {}
#endif
-/* odbc_utils.c */
+ /* odbc_utils.c */
-function odbc_connection_string_is_quoted(string $str): bool {}
+ function odbc_connection_string_is_quoted(string $str): bool {}
-function odbc_connection_string_should_quote(string $str): bool {}
+ function odbc_connection_string_should_quote(string $str): bool {}
-function odbc_connection_string_quote(string $str): string {}
+ function odbc_connection_string_quote(string $str): string {}
+}
diff --git a/ext/odbc/odbc_arginfo.h b/ext/odbc/odbc_arginfo.h
index 7a2916054152f..681625f3eb997 100644
--- a/ext/odbc/odbc_arginfo.h
+++ b/ext/odbc/odbc_arginfo.h
@@ -1,36 +1,36 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: a64be64f69159d0c8ad2c3b951c6451a040c3c73 */
+ * Stub hash: 34cebf41d91e4dacb8655a935c629ac62f0bb5ab */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_close_all, 0, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_binmode, 0, 2, IS_TRUE, 0)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_longreadlen, 0, 2, IS_TRUE, 0)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_prepare, 0, 0, 2)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_prepare, 0, 2, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, query, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_execute, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, params, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_cursor, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_END_ARG_INFO()
#if defined(HAVE_SQLDATASOURCES)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_data_source, 0, 2, MAY_BE_ARRAY|MAY_BE_NULL|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, odbc)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, fetch_type, IS_LONG, 0)
ZEND_END_ARG_INFO()
#endif
@@ -60,25 +60,25 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_fetch_into, 0, 2, MAY_BE_LO
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_fetch_row, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, row, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_result, 0, 2, MAY_BE_STRING|MAY_BE_BOOL|MAY_BE_NULL)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_MASK(0, field, MAY_BE_STRING|MAY_BE_LONG, NULL)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_result_all, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, format, IS_STRING, 0, "\"\"")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_free_result, 0, 1, IS_TRUE, 0)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_connect, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_connect, 0, 1, Odbc\\Connection, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, user, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, password, IS_STRING, 1, "null")
@@ -88,30 +88,30 @@ ZEND_END_ARG_INFO()
#define arginfo_odbc_pconnect arginfo_odbc_connect
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_close, 0, 1, IS_VOID, 0)
- ZEND_ARG_INFO(0, odbc)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_num_rows, 0, 1, IS_LONG, 0)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_END_ARG_INFO()
#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_next_result, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_END_ARG_INFO()
#endif
#define arginfo_odbc_num_fields arginfo_odbc_num_rows
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_field_name, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO(0, field, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_odbc_field_type arginfo_odbc_field_name
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_field_len, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO(0, field, IS_LONG, 0)
ZEND_END_ARG_INFO()
@@ -120,65 +120,65 @@ ZEND_END_ARG_INFO()
#define arginfo_odbc_field_scale arginfo_odbc_field_len
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_field_num, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
- ZEND_ARG_INFO(0, statement)
+ ZEND_ARG_OBJ_INFO(0, statement, Odbc\\Result, 0)
ZEND_ARG_TYPE_INFO(0, field, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_odbc_autocommit, 0, 1, MAY_BE_LONG|MAY_BE_BOOL)
- ZEND_ARG_INFO(0, odbc)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enable, _IS_BOOL, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_commit, 0, 1, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, odbc)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_END_ARG_INFO()
#define arginfo_odbc_rollback arginfo_odbc_commit
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_error, 0, 0, IS_STRING, 0)
- ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, odbc, "null")
+ ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, odbc, Odbc\\Connection, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_odbc_errormsg arginfo_odbc_error
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_odbc_setoption, 0, 4, _IS_BOOL, 0)
- ZEND_ARG_INFO(0, odbc)
+ ZEND_ARG_OBJ_TYPE_MASK(0, odbc, Odbc\\Connection|Odbc\\Result, 0, NULL)
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_tables, 0, 0, 1)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_tables, 0, 1, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, catalog, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, schema, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, table, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, types, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_columns, 0, 0, 1)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_columns, 0, 1, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, catalog, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, schema, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, table, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, column, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_gettypeinfo, 0, 0, 1)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_gettypeinfo, 0, 1, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, data_type, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_primarykeys, 0, 0, 4)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_primarykeys, 0, 4, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, catalog, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, schema, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, table, IS_STRING, 0)
ZEND_END_ARG_INFO()
#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_procedurecolumns, 0, 0, 1)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_procedurecolumns, 0, 1, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, catalog, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, schema, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, procedure, IS_STRING, 1, "null")
@@ -187,8 +187,8 @@ ZEND_END_ARG_INFO()
#endif
#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_procedures, 0, 0, 1)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_procedures, 0, 1, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, catalog, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, schema, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, procedure, IS_STRING, 1, "null")
@@ -196,8 +196,8 @@ ZEND_END_ARG_INFO()
#endif
#if !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) && !defined(HAVE_SOLID_35)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_foreignkeys, 0, 0, 7)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_foreignkeys, 0, 7, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, pk_catalog, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, pk_schema, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, pk_table, IS_STRING, 0)
@@ -207,8 +207,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_foreignkeys, 0, 0, 7)
ZEND_END_ARG_INFO()
#endif
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_specialcolumns, 0, 0, 7)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_specialcolumns, 0, 7, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, catalog, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, schema, IS_STRING, 0)
@@ -217,8 +217,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_specialcolumns, 0, 0, 7)
ZEND_ARG_TYPE_INFO(0, nullable, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_statistics, 0, 0, 6)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_statistics, 0, 6, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, catalog, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, schema, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, table, IS_STRING, 0)
@@ -227,8 +227,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_statistics, 0, 0, 6)
ZEND_END_ARG_INFO()
#if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_tableprivileges, 0, 0, 4)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_tableprivileges, 0, 4, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, catalog, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, schema, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, table, IS_STRING, 0)
@@ -236,8 +236,8 @@ ZEND_END_ARG_INFO()
#endif
#if !defined(HAVE_DBMAKER) && !defined(HAVE_SOLID) && !defined(HAVE_SOLID_30) &&!defined(HAVE_SOLID_35)
-ZEND_BEGIN_ARG_INFO_EX(arginfo_odbc_columnprivileges, 0, 0, 5)
- ZEND_ARG_INFO(0, odbc)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_odbc_columnprivileges, 0, 5, Odbc\\Result, MAY_BE_FALSE)
+ ZEND_ARG_OBJ_INFO(0, odbc, Odbc\\Connection, 0)
ZEND_ARG_TYPE_INFO(0, catalog, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, schema, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, table, IS_STRING, 0)
@@ -390,6 +390,14 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE_END
};
+static const zend_function_entry class_Odbc_Connection_methods[] = {
+ ZEND_FE_END
+};
+
+static const zend_function_entry class_Odbc_Result_methods[] = {
+ ZEND_FE_END
+};
+
static void register_odbc_symbols(int module_number)
{
REGISTER_STRING_CONSTANT("ODBC_TYPE", PHP_ODBC_TYPE, CONST_PERSISTENT);
@@ -489,3 +497,25 @@ static void register_odbc_symbols(int module_number)
zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "odbc_pconnect", sizeof("odbc_pconnect") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0);
}
+
+static zend_class_entry *register_class_Odbc_Connection(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_NS_CLASS_ENTRY(ce, "Odbc", "Connection", class_Odbc_Connection_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_Odbc_Result(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_NS_CLASS_ENTRY(ce, "Odbc", "Result", class_Odbc_Result_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;
+}
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 5f6f84488030f..535d2a14fcc38 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -29,6 +29,8 @@
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "ext/standard/php_standard.h"
+#include "Zend/zend_interfaces.h"
+#include "zend_smart_str.h"
#include "php_odbc.h"
#include "php_odbc_includes.h"
@@ -49,23 +51,249 @@
#include "odbc_arginfo.h"
-/*
- * not defined elsewhere
- */
+#define CHECK_ODBC_CONNECTION(conn) \
+ if (conn == NULL) { \
+ zend_throw_error(NULL, "ODBC connection has already been closed"); \
+ RETURN_THROWS(); \
+ }
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
+#define CHECK_ODBC_RESULT(result) \
+ if (result->conn_ptr == NULL) { \
+ zend_throw_error(NULL, "ODBC result has already been closed"); \
+ RETURN_THROWS(); \
+ }
void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent);
+static void safe_odbc_disconnect(void *handle);
+static void close_results_with_connection(odbc_connection *conn);
+static inline odbc_result *odbc_result_from_obj(zend_object *obj);
+
+static int le_pconn;
+
+static zend_class_entry *odbc_connection_ce, *odbc_result_ce;
+static zend_object_handlers odbc_connection_object_handlers, odbc_result_object_handlers;
+
+#define Z_ODBC_LINK_P(zv) odbc_link_from_obj(Z_OBJ_P(zv))
+#define Z_ODBC_CONNECTION_P(zv) Z_ODBC_LINK_P(zv)->connection
+#define Z_ODBC_RESULT_P(zv) odbc_result_from_obj(Z_OBJ_P(zv))
+
+static void odbc_insert_new_result(odbc_connection *connection, zval *result)
+{
+ ZEND_ASSERT(Z_TYPE_P(result) == IS_OBJECT);
+#if ZEND_DEBUG
+ ZEND_ASSERT(instanceof_function(Z_OBJCE_P(result), odbc_result_ce));
+#endif
+
+ odbc_result *res = Z_ODBC_RESULT_P(result);
+
+ res->index = connection->results.nNextFreeElement;
+ zend_hash_index_add_new(&connection->results, res->index, result);
+ Z_ADDREF_P(result);
+}
+
+static inline odbc_link *odbc_link_from_obj(zend_object *obj)
+{
+ return (odbc_link *)((char *)(obj) - XtOffsetOf(odbc_link, std));
+}
+
+static int _close_pconn_with_res(zval *zv, void *p)
+{
+ zend_resource *le = Z_RES_P(zv);
+
+ if (le->ptr == p) {
+ return ZEND_HASH_APPLY_REMOVE;
+ }
+
+ return ZEND_HASH_APPLY_KEEP;
+}
+
+static int _close_pconn(zval *zv)
+{
+ zend_resource *le = Z_RES_P(zv);
+ if (le->type == le_pconn) {
+ return ZEND_HASH_APPLY_REMOVE;
+ } else {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+}
+
+/* disconnect, and if it fails, then issue a rollback for any pending transaction (lurcher) */
+static void safe_odbc_disconnect( void *handle )
+{
+ int ret = SQLDisconnect( handle );
+
+ if ( ret == SQL_ERROR )
+ {
+ SQLTransact( NULL, handle, SQL_ROLLBACK );
+ SQLDisconnect( handle );
+ }
+}
+
+static void free_connection(odbc_connection *conn, bool persistent)
+{
+ /* If aborted via timer expiration, don't try to call any unixODBC function */
+ if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
+ safe_odbc_disconnect(conn->hdbc);
+ SQLFreeConnect(conn->hdbc);
+ SQLFreeEnv(conn->henv);
+ }
+
+ conn->hdbc = NULL;
+ conn->henv = NULL;
+
+ zend_hash_destroy(&conn->results);
+
+ pefree(conn, persistent);
+
+ ODBCG(num_links)--;
+ if (persistent) {
+ ODBCG(num_persistent)--;
+ }
+}
+
+static void odbc_link_free(odbc_link *link)
+{
+ ZEND_ASSERT(link->connection && "link has already been closed");
+
+ close_results_with_connection(link->connection);
+
+ if (!link->persistent) {
+ free_connection(link->connection, link->persistent);
+ }
+
+ link->connection = NULL;
+
+ if (link->hash) {
+ zend_hash_del(&ODBCG(connections), link->hash);
+ zend_string_release_ex(link->hash, link->persistent);
+ link->hash = NULL;
+ }
+}
+
+static zend_object *odbc_connection_create_object(zend_class_entry *class_type)
+{
+ odbc_link *intern = zend_object_alloc(sizeof(odbc_link), class_type);
+
+ zend_object_std_init(&intern->std, class_type);
+ object_properties_init(&intern->std, class_type);
+
+ return &intern->std;
+}
+
+static zend_function *odbc_connection_get_constructor(zend_object *object)
+{
+ zend_throw_error(NULL, "Cannot directly construct Odbc\\Connection, use odbc_connect() or odbc_pconnect() instead");
+ return NULL;
+}
+
+static zend_result odbc_connection_cast_object(zend_object *obj, zval *result, int type)
+{
+ if (type == IS_LONG) {
+ ZVAL_LONG(result, obj->handle);
+
+ return SUCCESS;
+ }
+
+ return zend_std_cast_object_tostring(obj, result, type);
+}
+
+static void odbc_connection_free_obj(zend_object *obj)
+{
+ odbc_link *link = odbc_link_from_obj(obj);
-static int le_result, le_conn, le_pconn;
+ if (link->connection) {
+ odbc_link_free(link);
+ }
+
+ zend_object_std_dtor(&link->std);
+}
+
+static inline odbc_result *odbc_result_from_obj(zend_object *obj)
+{
+ return (odbc_result *)((char *)(obj) - XtOffsetOf(odbc_result, std));
+}
+
+static zend_object *odbc_result_create_object(zend_class_entry *class_type)
+{
+ odbc_result *intern = zend_object_alloc(sizeof(odbc_result), class_type);
+
+ zend_object_std_init(&intern->std, class_type);
+ object_properties_init(&intern->std, class_type);
+
+ return &intern->std;
+}
+
+static zend_function *odbc_result_get_constructor(zend_object *object)
+{
+ zend_throw_error(NULL, "Cannot directly construct Odbc\\Result, use an appropriate odbc_* function instead");
+ return NULL;
+}
+
+static zend_result odbc_result_cast_object(zend_object *obj, zval *result, int type)
+{
+ if (type == IS_LONG) {
+ ZVAL_LONG(result, obj->handle);
+
+ return SUCCESS;
+ }
+
+ return zend_std_cast_object_tostring(obj, result, type);
+}
+
+static void odbc_result_free(odbc_result *res)
+{
+ ZEND_ASSERT(res->conn_ptr && "result has already been closed");
+
+ if (res->values) {
+ for (int i = 0; i < res->numcols; i++) {
+ if (res->values[i].value) {
+ efree(res->values[i].value);
+ }
+ }
+ efree(res->values);
+ res->values = NULL;
+ res->numcols = 0;
+ }
+
+ /* If aborted via timer expiration, don't try to call any unixODBC function */
+ if (res->stmt && !(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
+#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35)
+ SQLTransact(res->conn_ptr->henv, res->conn_ptr->hdbc,
+ (SQLUSMALLINT) SQL_COMMIT);
+#endif
+ SQLFreeStmt(res->stmt,SQL_DROP);
+ /* We don't want the connection to be closed after the last statement has been closed
+ * Connections will be closed on shutdown
+ */
+ res->stmt = NULL;
+ }
+ if (res->param_info) {
+ efree(res->param_info);
+ res->param_info = NULL;
+ }
+
+ HashTable *results = &res->conn_ptr->results;
+ res->conn_ptr = NULL;
+ zend_result status = zend_hash_index_del(results, res->index);
+ ZEND_ASSERT(status == SUCCESS);
+}
+
+static void odbc_result_free_obj(zend_object *obj)
+{
+ odbc_result *result = odbc_result_from_obj(obj);
+
+ if (result->conn_ptr) {
+ odbc_result_free(result);
+ }
+
+ zend_object_std_dtor(&result->std);
+}
#define SAFE_SQL_NTS(n) ((SQLSMALLINT) ((n)?(SQL_NTS):0))
PHP_ODBC_API ZEND_DECLARE_MODULE_GLOBALS(odbc)
static PHP_GINIT_FUNCTION(odbc);
+static PHP_GSHUTDOWN_FUNCTION(odbc);
/* {{{ odbc_module_entry */
zend_module_entry odbc_module_entry = {
@@ -80,7 +308,7 @@ zend_module_entry odbc_module_entry = {
PHP_ODBC_VERSION,
PHP_MODULE_GLOBALS(odbc),
PHP_GINIT(odbc),
- NULL,
+ PHP_GSHUTDOWN(odbc),
NULL,
STANDARD_MODULE_PROPERTIES_EX
};
@@ -93,111 +321,29 @@ ZEND_TSRMLS_CACHE_DEFINE()
ZEND_GET_MODULE(odbc)
#endif
-/* {{{ _free_odbc_result */
-static void _free_odbc_result(zend_resource *rsrc)
+static void close_results_with_connection(odbc_connection *conn)
{
- odbc_result *res = (odbc_result *)rsrc->ptr;
- int i;
+ zval *p;
- if (res) {
- if (res->values) {
- for(i = 0; i < res->numcols; i++) {
- if (res->values[i].value)
- efree(res->values[i].value);
- }
- efree(res->values);
- res->values = NULL;
- }
- /* If aborted via timer expiration, don't try to call any unixODBC function */
- if (res->stmt && !(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
-#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35)
- SQLTransact(res->conn_ptr->henv, res->conn_ptr->hdbc,
- (SQLUSMALLINT) SQL_COMMIT);
-#endif
- SQLFreeStmt(res->stmt,SQL_DROP);
- /* We don't want the connection to be closed after the last statement has been closed
- * Connections will be closed on shutdown
- * zend_list_delete(res->conn_ptr->id);
- */
- }
- if (res->param_info) {
- efree(res->param_info);
- }
- efree(res);
- }
-}
-/* }}} */
-
-/* {{{ safe_odbc_disconnect
- * disconnect, and if it fails, then issue a rollback for any pending transaction (lurcher)
- */
-static void safe_odbc_disconnect( void *handle )
-{
- int ret;
-
- ret = SQLDisconnect( handle );
- if ( ret == SQL_ERROR )
- {
- SQLTransact( NULL, handle, SQL_ROLLBACK );
- SQLDisconnect( handle );
- }
-}
-/* }}} */
-
-/* {{{ _close_odbc_conn */
-static void _close_odbc_conn(zend_resource *rsrc)
-{
- zend_resource *p;
- odbc_result *res;
-
- odbc_connection *conn = (odbc_connection *)rsrc->ptr;
-
- ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
- if (p->ptr && (p->type == le_result)) {
- res = (odbc_result *)p->ptr;
- if (res->conn_ptr == conn) {
- zend_list_close(p);
- }
+ ZEND_HASH_FOREACH_VAL(&conn->results, p) {
+ odbc_result *result = Z_ODBC_RESULT_P(p);
+ if (result->conn_ptr) {
+ odbc_result_free(result);
}
} ZEND_HASH_FOREACH_END();
- /* If aborted via timer expiration, don't try to call any unixODBC function */
- if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
- safe_odbc_disconnect(conn->hdbc);
- SQLFreeConnect(conn->hdbc);
- SQLFreeEnv(conn->henv);
- }
- efree(conn);
- ODBCG(num_links)--;
+ zend_hash_clean(&conn->results);
}
-/* }}} */
/* {{{ void _close_odbc_pconn */
static void _close_odbc_pconn(zend_resource *rsrc)
{
- zend_resource *p;
- odbc_result *res;
odbc_connection *conn = (odbc_connection *)rsrc->ptr;
- ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
- if (p->ptr && (p->type == le_result)) {
- res = (odbc_result *)p->ptr;
- if (res->conn_ptr == conn) {
- zend_list_close(p);
- }
- }
- } ZEND_HASH_FOREACH_END();
+ close_results_with_connection(conn);
+ free_connection(conn, true);
- /* If aborted via timer expiration, don't try to call any unixODBC function */
- if (!(PG(connection_status) & PHP_CONNECTION_TIMEOUT)) {
- safe_odbc_disconnect(conn->hdbc);
- SQLFreeConnect(conn->hdbc);
- SQLFreeEnv(conn->henv);
- }
- free(conn);
-
- ODBCG(num_links)--;
- ODBCG(num_persistent)--;
+ rsrc->ptr = NULL;
}
/* }}} */
@@ -378,6 +524,13 @@ static PHP_GINIT_FUNCTION(odbc)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
odbc_globals->num_persistent = 0;
+ zend_hash_init(&odbc_globals->connections, 0, NULL, NULL, true);
+ GC_MAKE_PERSISTENT_LOCAL(&odbc_globals->connections);
+}
+
+static PHP_GSHUTDOWN_FUNCTION(odbc)
+{
+ zend_hash_destroy(&odbc_globals->connections);
}
/* {{{ PHP_MINIT_FUNCTION */
@@ -389,19 +542,41 @@ PHP_MINIT_FUNCTION(odbc)
#endif
REGISTER_INI_ENTRIES();
- le_result = zend_register_list_destructors_ex(_free_odbc_result, NULL, "odbc result", module_number);
- le_conn = zend_register_list_destructors_ex(_close_odbc_conn, NULL, "odbc link", module_number);
le_pconn = zend_register_list_destructors_ex(NULL, _close_odbc_pconn, "odbc link persistent", module_number);
odbc_module_entry.type = type;
+ register_odbc_symbols(module_number);
+
+ odbc_connection_ce = register_class_Odbc_Connection();
+ odbc_connection_ce->create_object = odbc_connection_create_object;
+ odbc_connection_ce->default_object_handlers = &odbc_connection_object_handlers;
+
+ memcpy(&odbc_connection_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
+ odbc_connection_object_handlers.offset = XtOffsetOf(odbc_link, std);
+ odbc_connection_object_handlers.free_obj = odbc_connection_free_obj;
+ odbc_connection_object_handlers.get_constructor = odbc_connection_get_constructor;
+ odbc_connection_object_handlers.clone_obj = NULL;
+ odbc_connection_object_handlers.cast_object = odbc_connection_cast_object;
+ odbc_connection_object_handlers.compare = zend_objects_not_comparable;
+
+ odbc_result_ce = register_class_Odbc_Result();
+ odbc_result_ce->create_object = odbc_result_create_object;
+ odbc_result_ce->default_object_handlers = &odbc_result_object_handlers;
+
+ memcpy(&odbc_result_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
+ odbc_result_object_handlers.offset = XtOffsetOf(odbc_result, std);
+ odbc_result_object_handlers.free_obj = odbc_result_free_obj;
+ odbc_result_object_handlers.get_constructor = odbc_result_get_constructor;
+ odbc_result_object_handlers.clone_obj = NULL;
+ odbc_result_object_handlers.cast_object = odbc_result_cast_object;
+ odbc_result_object_handlers.compare = zend_objects_not_comparable;
+
#if defined(HAVE_IBMDB2) && defined(_AIX)
/* atexit() handler in the DB2/AIX library segfaults in PHP CLI */
/* DB2NOEXITLIST env variable prevents DB2 from invoking atexit() */
putenv("DB2NOEXITLIST=TRUE");
#endif
- register_odbc_symbols(module_number);
-
return SUCCESS;
}
/* }}} */
@@ -510,13 +685,12 @@ void php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
zval *pv_res;
zend_long flag;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &flag) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &pv_res, odbc_result_ce, &flag) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (mode) {
result->longreadlen = flag;
@@ -651,17 +825,15 @@ void odbc_bindcols(odbc_result *result)
/* {{{ odbc_transact */
void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
{
- odbc_connection *conn;
RETCODE rc;
zval *pv_conn;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_conn) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pv_conn, odbc_connection_ce) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
rc = SQLTransact(conn->henv, conn->hdbc, (SQLUSMALLINT)((type)?SQL_COMMIT:SQL_ROLLBACK));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
@@ -673,19 +845,6 @@ void odbc_transact(INTERNAL_FUNCTION_PARAMETERS, int type)
}
/* }}} */
-/* {{{ _close_pconn_with_res */
-static int _close_pconn_with_res(zval *zv, void *p)
-{
- zend_resource *le = Z_RES_P(zv);
- zend_resource *res = (zend_resource*)p;
- if (le->type == le_pconn && (((odbc_connection *)(le->ptr))->res == res)) {
- return ZEND_HASH_APPLY_REMOVE;
- } else {
- return ZEND_HASH_APPLY_KEEP;
- }
-}
-/* }}} */
-
/* {{{ odbc_column_lengths */
void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
{
@@ -704,13 +863,12 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
zval *pv_res;
zend_long pv_num;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &pv_num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &pv_res, odbc_result_ce, &pv_num) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (pv_num < 1) {
zend_argument_value_error(2, "must be greater than 0");
@@ -738,32 +896,23 @@ void odbc_column_lengths(INTERNAL_FUNCTION_PARAMETERS, int type)
/* {{{ Close all ODBC connections */
PHP_FUNCTION(odbc_close_all)
{
- zend_resource *p;
+ zval *zv;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
- /* Loop through list and close all statements */
- ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
- if (p->ptr && (p->type == le_result)) {
- zend_list_close(p);
+ /* Loop through the link list, now close all links and their results */
+ ZEND_HASH_FOREACH_VAL(&ODBCG(connections), zv) {
+ odbc_link *link = Z_ODBC_LINK_P(zv);
+ if (link->connection) {
+ odbc_link_free(link);
}
} ZEND_HASH_FOREACH_END();
- /* Second loop through list, now close all connections */
- ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
- if (p->ptr) {
- if (p->type == le_conn){
- zend_list_close(p);
- } else if (p->type == le_pconn){
- zend_list_close(p);
- /* Delete the persistent connection */
- zend_hash_apply_with_argument(&EG(persistent_list),
- _close_pconn_with_res, (void *)p);
- }
- }
- } ZEND_HASH_FOREACH_END();
+ zend_hash_clean(&ODBCG(connections));
+
+ zend_hash_apply(&EG(persistent_list), _close_pconn);
}
/* }}} */
@@ -788,36 +937,35 @@ PHP_FUNCTION(odbc_prepare)
char *query;
size_t query_len;
odbc_result *result = NULL;
- odbc_connection *conn;
RETCODE rc;
int i;
#ifdef HAVE_SQL_EXTENDED_FETCH
SQLUINTEGER scrollopts;
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pv_conn, &query, &query_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &pv_conn, odbc_connection_ce, &query, &query_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
result->numparams = 0;
result->param_info = NULL;
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -846,7 +994,7 @@ PHP_FUNCTION(odbc_prepare)
break;
default:
odbc_sql_error(conn, result->stmt, "SQLPrepare");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -858,7 +1006,6 @@ PHP_FUNCTION(odbc_prepare)
} else {
result->values = NULL;
}
- Z_ADDREF_P(pv_conn);
result->conn_ptr = conn;
result->fetched = 0;
@@ -870,12 +1017,12 @@ PHP_FUNCTION(odbc_prepare)
odbc_sql_error(result->conn_ptr, result->stmt, "SQLDescribeParameter");
SQLFreeStmt(result->stmt, SQL_RESET_PARAMS);
efree(result->param_info);
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
}
- RETURN_RES(zend_register_resource(result, le_result));
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -914,13 +1061,12 @@ PHP_FUNCTION(odbc_execute)
int i, ne;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|h", &pv_res, &pv_param_ht) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|h", &pv_res, odbc_result_ce, &pv_param_ht) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (result->numparams > 0) {
if ((ne = zend_hash_num_elements(pv_param_ht)) < result->numparams) {
@@ -1071,13 +1217,12 @@ PHP_FUNCTION(odbc_cursor)
odbc_result *result;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pv_res, odbc_result_ce) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
rc = SQLGetInfo(result->conn_ptr->hdbc,SQL_MAX_CURSOR_NAME_LEN, (void *)&max_len,sizeof(max_len),&len);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
@@ -1125,11 +1270,10 @@ PHP_FUNCTION(odbc_data_source)
zval *zv_conn;
zend_long zv_fetch_type;
RETCODE rc = 0; /* assume all is good */
- odbc_connection *conn;
UCHAR server_name[100], desc[200];
SQLSMALLINT len1=0, len2=0, fetch_type;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &zv_conn, &zv_fetch_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &zv_conn, odbc_connection_ce, &zv_fetch_type) == FAILURE) {
RETURN_THROWS();
}
@@ -1140,9 +1284,8 @@ PHP_FUNCTION(odbc_data_source)
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(zv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(zv_conn);
+ CHECK_ODBC_CONNECTION(conn);
/* now we have the "connection" lets call the DataSource object */
rc = SQLDataSources(conn->henv,
@@ -1186,32 +1329,31 @@ PHP_FUNCTION(odbc_exec)
char *query;
size_t query_len;
odbc_result *result = NULL;
- odbc_connection *conn;
RETCODE rc;
#ifdef HAVE_SQL_EXTENDED_FETCH
SQLUINTEGER scrollopts;
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pv_conn, &query, &query_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &pv_conn, odbc_connection_ce, &query, &query_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -1238,7 +1380,7 @@ PHP_FUNCTION(odbc_exec)
*/
odbc_sql_error(conn, result->stmt, "SQLExecDirect");
SQLFreeStmt(result->stmt, SQL_DROP);
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -1250,10 +1392,10 @@ PHP_FUNCTION(odbc_exec)
} else {
result->values = NULL;
}
- Z_ADDREF_P(pv_conn);
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -1277,13 +1419,12 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
SQLUSMALLINT RowStatus[1];
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l!", &pv_res, &pv_row, &pv_row_is_null) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!", &pv_res, odbc_result_ce, &pv_row, &pv_row_is_null) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
/* TODO deprecate $row argument values less than 1 after PHP 8.4 */
@@ -1437,13 +1578,12 @@ PHP_FUNCTION(odbc_fetch_into)
SQLUSMALLINT RowStatus[1];
#endif /* HAVE_SQL_EXTENDED_FETCH */
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rz|l!", &pv_res, &pv_res_arr, &pv_row, &pv_row_is_null) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oz|l!", &pv_res, odbc_result_ce, &pv_res_arr, &pv_row, &pv_row_is_null) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
/* TODO deprecate $row argument values less than 1 after PHP 8.4 */
@@ -1567,13 +1707,12 @@ PHP_FUNCTION(odbc_fetch_row)
SQLUSMALLINT RowStatus[1];
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l!", &pv_res, &pv_row, &pv_row_is_null) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!", &pv_res, odbc_result_ce, &pv_row, &pv_row_is_null) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
#ifndef HAVE_SQL_EXTENDED_FETCH
if (!pv_row_is_null) {
@@ -1605,6 +1744,7 @@ PHP_FUNCTION(odbc_fetch_row)
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
RETURN_FALSE;
}
+
#ifdef HAVE_SQL_EXTENDED_FETCH
if (!pv_row_is_null) {
result->fetched = (SQLLEN)pv_row;
@@ -1635,7 +1775,7 @@ PHP_FUNCTION(odbc_result)
#endif
ZEND_PARSE_PARAMETERS_START(2, 2)
- Z_PARAM_RESOURCE(pv_res)
+ Z_PARAM_OBJECT_OF_CLASS(pv_res, odbc_result_ce)
Z_PARAM_STR_OR_LONG(pv_field_str, pv_field_long)
ZEND_PARSE_PARAMETERS_END();
@@ -1647,9 +1787,8 @@ PHP_FUNCTION(odbc_result)
field_ind = (int) pv_field_long - 1;
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
@@ -1843,13 +1982,12 @@ PHP_FUNCTION(odbc_result_all)
SQLUSMALLINT RowStatus[1];
#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s", &pv_res, &pv_format, &pv_format_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s", &pv_res, odbc_result_ce, &pv_format, &pv_format_len) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
@@ -1975,27 +2113,15 @@ PHP_FUNCTION(odbc_free_result)
{
zval *pv_res;
odbc_result *result;
- int i;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pv_res, odbc_result_ce) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
-
- if (result->values) {
- for (i = 0; i < result->numcols; i++) {
- if (result->values[i].value) {
- efree(result->values[i].value);
- }
- }
- efree(result->values);
- result->values = NULL;
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
- zend_list_close(Z_RES_P(pv_res));
+ odbc_result_free(result);
RETURN_TRUE;
}
@@ -2016,18 +2142,35 @@ PHP_FUNCTION(odbc_pconnect)
/* }}} */
/* {{{ odbc_sqlconnect */
-int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int cur_opt, int persistent)
+bool odbc_sqlconnect(zval *zv, char *db, char *uid, char *pwd, int cur_opt, bool persistent, char *hash, int hash_len)
{
RETCODE rc;
+ SQLRETURN ret;
+ odbc_link *link;
+
+ object_init_ex(zv, odbc_connection_ce);
+ link = Z_ODBC_LINK_P(zv);
+ link->connection = pecalloc(1, sizeof(odbc_connection), persistent);
+ zend_hash_init(&link->connection->results, 0, NULL, ZVAL_PTR_DTOR, true);
+ link->persistent = persistent;
+ link->hash = zend_string_init(hash, hash_len, persistent);
+ if (persistent) {
+ GC_MAKE_PERSISTENT_LOCAL(link->hash);
+ }
+ ret = SQLAllocEnv(&link->connection->henv);
+ if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) {
+ odbc_sql_error(link->connection, SQL_NULL_HSTMT, "SQLAllocEnv");
+ return false;
+ }
- *conn = (odbc_connection *)pemalloc(sizeof(odbc_connection), persistent);
- memset(*conn, 0, sizeof(odbc_connection));
- (*conn)->persistent = persistent;
- SQLAllocEnv(&((*conn)->henv));
- SQLAllocConnect((*conn)->henv, &((*conn)->hdbc));
+ ret = SQLAllocConnect(link->connection->henv, &link->connection->hdbc);
+ if (ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO) {
+ odbc_sql_error(link->connection, SQL_NULL_HSTMT, "SQLAllocConnect");
+ return false;
+ }
#if defined(HAVE_SOLID) || defined(HAVE_SOLID_30)
- SQLSetConnectOption((*conn)->hdbc, SQL_TRANSLATE_OPTION,
+ SQLSetConnectOption((link->connection->hdbc, SQL_TRANSLATE_OPTION,
SQL_SOLID_XLATOPT_NOCNV);
#endif
#ifdef HAVE_OPENLINK
@@ -2035,16 +2178,14 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
char dsnbuf[1024];
short dsnbuflen;
- rc = SQLDriverConnect((*conn)->hdbc, NULL, db, SQL_NTS, dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
+ rc = SQLDriverConnect(link->connection->hdbc, NULL, db, SQL_NTS, dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
}
#else
if (cur_opt != SQL_CUR_DEFAULT) {
- rc = SQLSetConnectOption((*conn)->hdbc, SQL_ODBC_CURSORS, cur_opt);
+ rc = SQLSetConnectOption(link->connection->hdbc, SQL_ODBC_CURSORS, cur_opt);
if (rc != SQL_SUCCESS) { /* && rc != SQL_SUCCESS_WITH_INFO ? */
- odbc_sql_error(*conn, SQL_NULL_HSTMT, "SQLSetConnectOption");
- SQLFreeConnect((*conn)->hdbc);
- pefree(*conn, persistent);
- return FALSE;
+ odbc_sql_error(link->connection, SQL_NULL_HSTMT, "SQLSetConnectOption");
+ return false;
}
}
/* Possible fix for bug #10250
@@ -2126,9 +2267,9 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
}
if (direct) {
- rc = SQLDriverConnect((*conn)->hdbc, NULL, (SQLCHAR *) ldb, strlen(ldb), dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
+ rc = SQLDriverConnect(link->connection->hdbc, NULL, (SQLCHAR *) ldb, strlen(ldb), dsnbuf, sizeof(dsnbuf) - 1, &dsnbuflen, SQL_DRIVER_NOPROMPT);
} else {
- rc = SQLConnect((*conn)->hdbc, (SQLCHAR *) db, SQL_NTS, (SQLCHAR *) uid, SQL_NTS, (SQLCHAR *) pwd, SQL_NTS);
+ rc = SQLConnect(link->connection->hdbc, (SQLCHAR *) db, SQL_NTS, (SQLCHAR *) uid, SQL_NTS, (SQLCHAR *) pwd, SQL_NTS);
}
if (ldb) {
@@ -2136,25 +2277,17 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
}
}
#else
- rc = SQLConnect((*conn)->hdbc, (SQLCHAR *) db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS);
+ rc = SQLConnect(link->connection->hdbc, (SQLCHAR *) db, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS);
#endif
#endif
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- odbc_sql_error(*conn, SQL_NULL_HSTMT, "SQLConnect");
- SQLFreeConnect((*conn)->hdbc);
- pefree((*conn), persistent);
- return FALSE;
+ odbc_sql_error(link->connection, SQL_NULL_HSTMT, "SQLConnect");
+ return false;
}
-/* (*conn)->open = 1;*/
- return TRUE;
+ return true;
}
/* }}} */
-/* Persistent connections: two list-types le_pconn, le_conn and a plist
- * where hashed connection info is stored together with index pointer to
- * the actual link of type le_pconn in the list. Only persistent
- * connections get hashed up.
- */
/* {{{ odbc_do_connect */
void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
{
@@ -2190,17 +2323,16 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
persistent = 0;
}
+ char *hashed_details;
+ size_t hashed_details_len = spprintf(&hashed_details, 0, "odbc_%d_%s_%s_%s_%s_%d", persistent, ODBC_TYPE, db, uid, pwd, cur_opt);
+
try_and_get_another_connection:
if (persistent) {
- char *hashed_details;
- int hashed_len;
zend_resource *le;
- hashed_len = spprintf(&hashed_details, 0, "%s_%s_%s_%s_%d", ODBC_TYPE, db, uid, pwd, cur_opt);
-
/* the link is not in the persistent list */
- if ((le = zend_hash_str_find_ptr(&EG(persistent_list), hashed_details, hashed_len)) == NULL) {
+ if ((le = zend_hash_str_find_ptr(&EG(persistent_list), hashed_details, hashed_details_len)) == NULL) {
if (ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)) {
php_error_docref(NULL, E_WARNING, "Too many open links (" ZEND_LONG_FMT ")", ODBCG(num_links));
efree(hashed_details);
@@ -2212,20 +2344,24 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
RETURN_FALSE;
}
- if (!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 1)) {
+ if (!odbc_sqlconnect(return_value, db, uid, pwd, cur_opt, true, hashed_details, hashed_details_len)) {
efree(hashed_details);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
- if (zend_register_persistent_resource(hashed_details, hashed_len, db_conn, le_pconn) == NULL) {
- free(db_conn);
+ db_conn = Z_ODBC_CONNECTION_P(return_value);
+
+ if (zend_register_persistent_resource(hashed_details, hashed_details_len, db_conn, le_pconn) == NULL) {
efree(hashed_details);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
+
+ zend_hash_str_add_new(&ODBCG(connections), hashed_details, hashed_details_len, return_value);
+
ODBCG(num_persistent)++;
ODBCG(num_links)++;
- db_conn->res = zend_register_resource(db_conn, le_pconn);
- RETVAL_RES(db_conn->res);
} else { /* found connection */
ZEND_ASSERT(le->type == le_pconn);
@@ -2248,7 +2384,7 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
&dead, 0, NULL);
if (ret == SQL_SUCCESS && dead == SQL_CD_TRUE) {
/* Bail early here, since we know it's gone */
- zend_hash_str_del(&EG(persistent_list), hashed_details, hashed_len);
+ zend_hash_str_del(&EG(persistent_list), hashed_details, hashed_details_len);
goto try_and_get_another_connection;
}
/* If the driver doesn't support it, or returns
@@ -2260,7 +2396,7 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
d_name, sizeof(d_name), &len);
if(ret != SQL_SUCCESS || len == 0) {
- zend_hash_str_del(&EG(persistent_list), hashed_details, hashed_len);
+ zend_hash_str_del(&EG(persistent_list), hashed_details, hashed_details_len);
/* Commented out to fix a possible double closure error
* when working with persistent connections as submitted by
* bug #15758
@@ -2271,23 +2407,42 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
goto try_and_get_another_connection;
}
}
+
+ zval *link_zval;
+ if ((link_zval = zend_hash_str_find(&ODBCG(connections), hashed_details, hashed_details_len)) == NULL) {
+ object_init_ex(return_value, odbc_connection_ce);
+ odbc_link *link = Z_ODBC_LINK_P(return_value);
+ link->connection = db_conn;
+ link->hash = zend_string_init(hashed_details, hashed_details_len, persistent);
+ link->persistent = true;
+ } else {
+ ZVAL_COPY(return_value, link_zval);
+
+ ZEND_ASSERT(Z_ODBC_CONNECTION_P(return_value) == db_conn && "Persistent connection has changed");
+ }
}
- efree(hashed_details);
- db_conn->res = zend_register_resource(db_conn, le_pconn);
- RETVAL_RES(db_conn->res);
- } else { /* non persistent */
- if (ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)) {
- php_error_docref(NULL, E_WARNING,"Too many open connections (" ZEND_LONG_FMT ")",ODBCG(num_links));
- RETURN_FALSE;
- }
+ } else { /* non-persistent */
+ zval *link_zval;
+ if ((link_zval = zend_hash_str_find(&ODBCG(connections), hashed_details, hashed_details_len)) == NULL) { /* non-persistent, new */
+ if (ODBCG(max_links) != -1 && ODBCG(num_links) >= ODBCG(max_links)) {
+ php_error_docref(NULL, E_WARNING, "Too many open connections (" ZEND_LONG_FMT ")", ODBCG(num_links));
+ efree(hashed_details);
+ RETURN_FALSE;
+ }
- if (!odbc_sqlconnect(&db_conn, db, uid, pwd, cur_opt, 0)) {
- RETURN_FALSE;
+ if (!odbc_sqlconnect(return_value, db, uid, pwd, cur_opt, false, hashed_details, hashed_details_len)) {
+ efree(hashed_details);
+ zval_ptr_dtor(return_value);
+ RETURN_FALSE;
+ }
+ ODBCG(num_links)++;
+
+ zend_hash_str_add_new(&ODBCG(connections), hashed_details, hashed_details_len, return_value);
+ } else { /* non-persistent, pre-existing */
+ ZVAL_COPY(return_value, link_zval);
}
- db_conn->res = zend_register_resource(db_conn, le_conn);
- RETVAL_RES(db_conn->res);
- ODBCG(num_links)++;
}
+ efree(hashed_details);
}
/* }}} */
@@ -2295,36 +2450,20 @@ void odbc_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
PHP_FUNCTION(odbc_close)
{
zval *pv_conn;
- zend_resource *p;
- odbc_connection *conn;
- odbc_result *res;
- int is_pconn = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_conn) == FAILURE) {
- RETURN_THROWS();
- }
+ odbc_link *link;
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pv_conn, odbc_connection_ce) == FAILURE) {
RETURN_THROWS();
}
- if (Z_RES_P(pv_conn)->type == le_pconn) {
- is_pconn = 1;
- }
-
- ZEND_HASH_FOREACH_PTR(&EG(regular_list), p) {
- if (p->ptr && (p->type == le_result)) {
- res = (odbc_result *)p->ptr;
- if (res->conn_ptr == conn) {
- zend_list_close(p);
- }
- }
- } ZEND_HASH_FOREACH_END();
+ link = Z_ODBC_LINK_P(pv_conn);
+ odbc_connection *connection = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(connection);
- zend_list_close(Z_RES_P(pv_conn));
+ odbc_link_free(link);
- if(is_pconn){
- zend_hash_apply_with_argument(&EG(persistent_list), _close_pconn_with_res, (void *) Z_RES_P(pv_conn));
+ if (link->persistent) {
+ zend_hash_apply_with_argument(&EG(persistent_list), _close_pconn_with_res, (void *) connection);
}
}
/* }}} */
@@ -2336,13 +2475,12 @@ PHP_FUNCTION(odbc_num_rows)
SQLLEN rows;
zval *pv_res;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pv_res, odbc_result_ce) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
SQLRowCount(result->stmt, &rows);
RETURN_LONG(rows);
@@ -2357,13 +2495,12 @@ PHP_FUNCTION(odbc_next_result)
zval *pv_res;
int rc, i;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pv_res, odbc_result_ce) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (result->values) {
for(i = 0; i < result->numcols; i++) {
@@ -2405,13 +2542,12 @@ PHP_FUNCTION(odbc_num_fields)
odbc_result *result;
zval *pv_res;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pv_res) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pv_res, odbc_result_ce) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
RETURN_LONG(result->numcols);
}
@@ -2424,13 +2560,12 @@ PHP_FUNCTION(odbc_field_name)
zval *pv_res;
zend_long pv_num;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &pv_num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &pv_res, odbc_result_ce, &pv_num) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (pv_num < 1) {
zend_argument_value_error(2, "must be greater than 0");
@@ -2460,13 +2595,12 @@ PHP_FUNCTION(odbc_field_type)
zval *pv_res;
zend_long pv_num;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &pv_res, &pv_num) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &pv_res, odbc_result_ce, &pv_num) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (pv_num < 1) {
zend_argument_value_error(2, "must be greater than 0");
@@ -2510,13 +2644,12 @@ PHP_FUNCTION(odbc_field_num)
odbc_result *result;
zval *pv_res;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pv_res, &fname, &fname_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &pv_res, odbc_result_ce, &fname, &fname_len) == FAILURE) {
RETURN_THROWS();
}
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_res), "ODBC result", le_result)) == NULL) {
- RETURN_THROWS();
- }
+ result = Z_ODBC_RESULT_P(pv_res);
+ CHECK_ODBC_RESULT(result);
if (result->numcols == 0) {
php_error_docref(NULL, E_WARNING, "No tuples available at this result index");
@@ -2541,19 +2674,17 @@ PHP_FUNCTION(odbc_field_num)
/* There can be problems with pconnections!*/
PHP_FUNCTION(odbc_autocommit)
{
- odbc_connection *conn;
RETCODE rc;
zval *pv_conn;
bool pv_onoff = 0;
bool pv_onoff_is_null = true;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|b!", &pv_conn, &pv_onoff, &pv_onoff_is_null) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|b!", &pv_conn, odbc_connection_ce, &pv_onoff, &pv_onoff_is_null) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
if (!pv_onoff_is_null) {
rc = SQLSetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, pv_onoff ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
@@ -2596,14 +2727,14 @@ static void php_odbc_lasterror(INTERNAL_FUNCTION_PARAMETERS, int mode)
zval *pv_handle = NULL;
char *ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|r!", &pv_handle) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pv_handle, odbc_connection_ce) == FAILURE) {
RETURN_THROWS();
}
if (pv_handle) {
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ conn = Z_ODBC_CONNECTION_P(pv_handle);
+ CHECK_ODBC_CONNECTION(conn);
+
if (mode == 0) {
ret = conn->laststate;
} else {
@@ -2644,36 +2775,42 @@ PHP_FUNCTION(odbc_errormsg)
*/
PHP_FUNCTION(odbc_setoption)
{
- odbc_connection *conn;
+ odbc_link *link;
odbc_result *result;
RETCODE rc;
zval *pv_handle;
zend_long pv_which, pv_opt, pv_val;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlll", &pv_handle, &pv_which, &pv_opt, &pv_val) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "olll", &pv_handle, &pv_which, &pv_opt, &pv_val) == FAILURE) {
RETURN_THROWS();
}
switch (pv_which) {
case 1: /* SQLSetConnectOption */
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_handle), "ODBC-Link", le_conn, le_pconn))) {
+ if (!instanceof_function(Z_OBJCE_P(pv_handle), odbc_connection_ce)) {
+ zend_argument_type_error(1, "must be of type Odbc\\Connection for SQLSetConnectOption()");
RETURN_THROWS();
}
+ link = Z_ODBC_LINK_P(pv_handle);
+ CHECK_ODBC_CONNECTION(link->connection);
- if (conn->persistent) {
+ if (link->persistent) {
php_error_docref(NULL, E_WARNING, "Unable to set option for persistent connection");
RETURN_FALSE;
}
- rc = SQLSetConnectOption(conn->hdbc, (unsigned short) pv_opt, pv_val);
+ rc = SQLSetConnectOption(link->connection->hdbc, (unsigned short) pv_opt, pv_val);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- odbc_sql_error(conn, SQL_NULL_HSTMT, "SetConnectOption");
+ odbc_sql_error(link->connection, SQL_NULL_HSTMT, "SetConnectOption");
RETURN_FALSE;
}
break;
case 2: /* SQLSetStmtOption */
- if ((result = (odbc_result *)zend_fetch_resource(Z_RES_P(pv_handle), "ODBC result", le_result)) == NULL) {
+ if (!instanceof_function(Z_OBJCE_P(pv_handle), odbc_result_ce)) {
+ zend_argument_type_error(1, "must be of type Odbc\\Result for SQLSetStmtOption()");
RETURN_THROWS();
}
+ result = Z_ODBC_RESULT_P(pv_handle);
+ CHECK_ODBC_RESULT(result);
rc = SQLSetStmtOption(result->stmt, (unsigned short) pv_opt, pv_val);
@@ -2700,32 +2837,31 @@ PHP_FUNCTION(odbc_tables)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL, *type = NULL;
size_t cat_len = 0, schema_len = 0, table_len = 0, type_len = 0;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!s!", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!s!s!s!", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len,
&table, &table_len, &type, &type_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2742,7 +2878,7 @@ PHP_FUNCTION(odbc_tables)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLTables");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2756,7 +2892,8 @@ PHP_FUNCTION(odbc_tables)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -2765,32 +2902,31 @@ PHP_FUNCTION(odbc_columns)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL, *column = NULL;
size_t cat_len = 0, schema_len = 0, table_len = 0, column_len = 0;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!s!", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!s!s!s!", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len,
&table, &table_len, &column, &column_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2809,7 +2945,7 @@ PHP_FUNCTION(odbc_columns)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLColumns");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2823,7 +2959,8 @@ PHP_FUNCTION(odbc_columns)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -2833,32 +2970,31 @@ PHP_FUNCTION(odbc_columnprivileges)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema, *table, *column;
size_t cat_len = 0, schema_len, table_len, column_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!sss", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os!sss", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len,
&table, &table_len, &column, &column_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2870,7 +3006,7 @@ PHP_FUNCTION(odbc_columnprivileges)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLColumnPrivileges");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2884,7 +3020,8 @@ PHP_FUNCTION(odbc_columnprivileges)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
#endif /* HAVE_DBMAKER || HAVE_SOLID*/
@@ -2895,12 +3032,11 @@ PHP_FUNCTION(odbc_foreignkeys)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *pcat = NULL, *pschema, *ptable, *fcat, *fschema, *ftable;
size_t pcat_len = 0, pschema_len, ptable_len, fcat_len, fschema_len, ftable_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!sssss", &pv_conn, &pcat, &pcat_len, &pschema, &pschema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os!sssss", &pv_conn, odbc_connection_ce, &pcat, &pcat_len, &pschema, &pschema_len,
&ptable, &ptable_len, &fcat, &fcat_len, &fschema, &fschema_len, &ftable, &ftable_len) == FAILURE) {
RETURN_THROWS();
}
@@ -2917,22 +3053,22 @@ PHP_FUNCTION(odbc_foreignkeys)
EMPTY_TO_NULL(ftable);
#endif
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2946,7 +3082,7 @@ PHP_FUNCTION(odbc_foreignkeys)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLForeignKeys");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -2960,7 +3096,8 @@ PHP_FUNCTION(odbc_foreignkeys)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
#endif /* HAVE_SOLID */
@@ -2971,32 +3108,31 @@ PHP_FUNCTION(odbc_gettypeinfo)
zval *pv_conn;
zend_long pv_data_type = SQL_ALL_TYPES;
odbc_result *result = NULL;
- odbc_connection *conn;
RETCODE rc;
SQLSMALLINT data_type;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &pv_conn, &pv_data_type) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &pv_conn, odbc_connection_ce, &pv_data_type) == FAILURE) {
RETURN_THROWS();
}
data_type = (SQLSMALLINT) pv_data_type;
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3004,7 +3140,7 @@ PHP_FUNCTION(odbc_gettypeinfo)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLGetTypeInfo");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3018,7 +3154,8 @@ PHP_FUNCTION(odbc_gettypeinfo)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -3027,31 +3164,30 @@ PHP_FUNCTION(odbc_primarykeys)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL;
size_t cat_len = 0, schema_len, table_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os!ss", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3062,7 +3198,7 @@ PHP_FUNCTION(odbc_primarykeys)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLPrimaryKeys");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3076,7 +3212,8 @@ PHP_FUNCTION(odbc_primarykeys)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -3086,32 +3223,31 @@ PHP_FUNCTION(odbc_procedurecolumns)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema = NULL, *proc = NULL, *col = NULL;
size_t cat_len = 0, schema_len = 0, proc_len = 0, col_len = 0;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!s!", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!s!s!s!", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len,
&proc, &proc_len, &col, &col_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3123,7 +3259,7 @@ PHP_FUNCTION(odbc_procedurecolumns)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLProcedureColumns");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3137,7 +3273,8 @@ PHP_FUNCTION(odbc_procedurecolumns)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
#endif /* HAVE_SOLID */
@@ -3148,31 +3285,30 @@ PHP_FUNCTION(odbc_procedures)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema = NULL, *proc = NULL;
size_t cat_len = 0, schema_len = 0, proc_len = 0;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|s!s!s!", &pv_conn, &cat, &cat_len, &schema, &schema_len, &proc, &proc_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!s!s!", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len, &proc, &proc_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3183,7 +3319,7 @@ PHP_FUNCTION(odbc_procedures)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLProcedures");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3197,7 +3333,8 @@ PHP_FUNCTION(odbc_procedures)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
#endif /* HAVE_SOLID */
@@ -3208,13 +3345,12 @@ PHP_FUNCTION(odbc_specialcolumns)
zval *pv_conn;
zend_long vtype, vscope, vnullable;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema = NULL, *name = NULL;
size_t cat_len = 0, schema_len, name_len;
SQLUSMALLINT type, scope, nullable;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rls!ssll", &pv_conn, &vtype, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ols!ssll", &pv_conn, odbc_connection_ce, &vtype, &cat, &cat_len, &schema, &schema_len,
&name, &name_len, &vscope, &vnullable) == FAILURE) {
RETURN_THROWS();
}
@@ -3223,22 +3359,22 @@ PHP_FUNCTION(odbc_specialcolumns)
scope = (SQLUSMALLINT) vscope;
nullable = (SQLUSMALLINT) vnullable;
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3251,7 +3387,7 @@ PHP_FUNCTION(odbc_specialcolumns)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLSpecialColumns");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3265,7 +3401,8 @@ PHP_FUNCTION(odbc_specialcolumns)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -3275,13 +3412,12 @@ PHP_FUNCTION(odbc_statistics)
zval *pv_conn;
zend_long vunique, vreserved;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema, *name;
size_t cat_len = 0, schema_len, name_len;
SQLUSMALLINT unique, reserved;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ssll", &pv_conn, &cat, &cat_len, &schema, &schema_len,
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os!ssll", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len,
&name, &name_len, &vunique, &vreserved) == FAILURE) {
RETURN_THROWS();
}
@@ -3289,22 +3425,22 @@ PHP_FUNCTION(odbc_statistics)
unique = (SQLUSMALLINT) vunique;
reserved = (SQLUSMALLINT) vreserved;
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3317,7 +3453,7 @@ PHP_FUNCTION(odbc_statistics)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLStatistics");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3331,7 +3467,8 @@ PHP_FUNCTION(odbc_statistics)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
@@ -3341,31 +3478,30 @@ PHP_FUNCTION(odbc_tableprivileges)
{
zval *pv_conn;
odbc_result *result = NULL;
- odbc_connection *conn;
char *cat = NULL, *schema = NULL, *table = NULL;
size_t cat_len = 0, schema_len, table_len;
RETCODE rc;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs!ss", &pv_conn, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os!ss", &pv_conn, odbc_connection_ce, &cat, &cat_len, &schema, &schema_len, &table, &table_len) == FAILURE) {
RETURN_THROWS();
}
- if (!(conn = (odbc_connection *)zend_fetch_resource2(Z_RES_P(pv_conn), "ODBC-Link", le_conn, le_pconn))) {
- RETURN_THROWS();
- }
+ odbc_connection *conn = Z_ODBC_CONNECTION_P(pv_conn);
+ CHECK_ODBC_CONNECTION(conn);
- result = (odbc_result *)ecalloc(1, sizeof(odbc_result));
+ object_init_ex(return_value, odbc_result_ce);
+ result = Z_ODBC_RESULT_P(return_value);
rc = PHP_ODBC_SQLALLOCSTMT(conn->hdbc, &(result->stmt));
if (rc == SQL_INVALID_HANDLE) {
- efree(result);
php_error_docref(NULL, E_WARNING, "SQLAllocStmt error 'Invalid Handle'");
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
if (rc == SQL_ERROR) {
odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLAllocStmt");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3376,7 +3512,7 @@ PHP_FUNCTION(odbc_tableprivileges)
if (rc == SQL_ERROR) {
odbc_sql_error(conn, result->stmt, "SQLTablePrivileges");
- efree(result);
+ zval_ptr_dtor(return_value);
RETURN_FALSE;
}
@@ -3390,7 +3526,8 @@ PHP_FUNCTION(odbc_tableprivileges)
}
result->conn_ptr = conn;
result->fetched = 0;
- RETURN_RES(zend_register_resource(result, le_result));
+
+ odbc_insert_new_result(conn, return_value);
}
/* }}} */
#endif /* HAVE_DBMAKER */
diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h
index 07ee99e2f0075..71daf2f2d5194 100644
--- a/ext/odbc/php_odbc_includes.h
+++ b/ext/odbc/php_odbc_includes.h
@@ -191,10 +191,16 @@ typedef struct odbc_connection {
ODBC_SQL_CONN_T hdbc;
char laststate[6];
char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
- zend_resource *res;
- int persistent;
+ HashTable results;
} odbc_connection;
+typedef struct odbc_link {
+ odbc_connection *connection;
+ zend_string *hash;
+ bool persistent;
+ zend_object std;
+} odbc_link;
+
typedef struct odbc_result_value {
char name[256];
char *value;
@@ -220,8 +226,10 @@ typedef struct odbc_result {
zend_long longreadlen;
int binmode;
int fetched;
- odbc_param_info * param_info;
+ odbc_param_info *param_info;
odbc_connection *conn_ptr;
+ uint32_t index;
+ zend_object std;
} odbc_result;
ZEND_BEGIN_MODULE_GLOBALS(odbc)
@@ -240,8 +248,13 @@ ZEND_BEGIN_MODULE_GLOBALS(odbc)
zend_long default_cursortype;
char laststate[6];
char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
- HashTable *resource_list;
- HashTable *resource_plist;
+ /* Stores ODBC links throughout the duration of a request. The connection member may be either persistent or
+ * non-persistent. In the former case, it is a pointer to an item in EG(persistent_list). This solution makes it
+ * possible to properly free links during RSHUTDOWN (or when they are explicitly closed), while persistent
+ * connections themselves are going to be freed later during the shutdown process (or when they are explicitly
+ * closed).
+ */
+ HashTable connections;
ZEND_END_MODULE_GLOBALS(odbc)
int odbc_add_result(HashTable *list, odbc_result *result);
diff --git a/ext/odbc/tests/bug78470.phpt b/ext/odbc/tests/bug78470.phpt
index ea601a1fdfcac..92bd5c067f7b0 100644
--- a/ext/odbc/tests/bug78470.phpt
+++ b/ext/odbc/tests/bug78470.phpt
@@ -12,4 +12,5 @@ $conn = odbc_connect($dsn, $user, $pass);
var_dump(odbc_specialcolumns($conn, SQL_BEST_ROWID, '', '', '', SQL_SCOPE_CURROW, SQL_NO_NULLS));
?>
--EXPECTF--
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
diff --git a/ext/odbc/tests/bug78473.phpt b/ext/odbc/tests/bug78473.phpt
index 3903187a36219..9313237efde2b 100644
--- a/ext/odbc/tests/bug78473.phpt
+++ b/ext/odbc/tests/bug78473.phpt
@@ -11,6 +11,6 @@ try {
}
var_dump(STDIN);
?>
---EXPECTF--
-odbc_close(): supplied resource is not a valid ODBC-Link resource
-resource(%d) of type (stream)
+--EXPECT--
+odbc_close(): Argument #1 ($odbc) must be of type Odbc\Connection, resource given
+resource(1) of type (stream)
diff --git a/ext/odbc/tests/odbc_close_001.phpt b/ext/odbc/tests/odbc_close_001.phpt
new file mode 100644
index 0000000000000..1c970b58959d9
--- /dev/null
+++ b/ext/odbc/tests/odbc_close_001.phpt
@@ -0,0 +1,62 @@
+--TEST--
+odbc_close(): Basic test
+--EXTENSIONS--
+odbc
+--SKIPIF--
+
+--FILE--
+getMessage() . "\n";
+}
+
+try {
+ odbc_columns($conn2, '', '', '', '');
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ odbc_num_rows($result1);
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ odbc_num_rows($result2);
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+--EXPECTF--
+object(Odbc\Connection)#%d (%d) {
+}
+object(Odbc\Connection)#%d (%d) {
+}
+object(Odbc\Result)#%d (%d) {
+}
+object(Odbc\Result)#%d (%d) {
+}
+ODBC connection has already been closed
+ODBC connection has already been closed
+ODBC result has already been closed
+ODBC result has already been closed
diff --git a/ext/odbc/tests/odbc_close_all_001.phpt b/ext/odbc/tests/odbc_close_all_001.phpt
index f5334ce7500a2..3dc24b5679d56 100644
--- a/ext/odbc/tests/odbc_close_all_001.phpt
+++ b/ext/odbc/tests/odbc_close_all_001.phpt
@@ -21,18 +21,41 @@ var_dump($result2);
odbc_close_all();
-var_dump($conn1);
-var_dump($conn2);
-var_dump($result1);
-var_dump($result2);
+try {
+ odbc_columns($conn1, '', '', '', '');
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ odbc_columns($conn2, '', '', '', '');
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ odbc_num_rows($result1);
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ odbc_num_rows($result2);
+} catch (Error $e) {
+ echo $e->getMessage() . "\n";
+}
?>
--EXPECTF--
-resource(%d) of type (odbc link)
-resource(%d) of type (odbc link persistent)
-resource(%d) of type (odbc result)
-resource(%d) of type (odbc result)
-resource(%d) of type (Unknown)
-resource(%d) of type (Unknown)
-resource(%d) of type (Unknown)
-resource(%d) of type (Unknown)
+object(Odbc\Connection)#%d (%d) {
+}
+object(Odbc\Connection)#%d (%d) {
+}
+object(Odbc\Result)#%d (%d) {
+}
+object(Odbc\Result)#%d (%d) {
+}
+ODBC connection has already been closed
+ODBC connection has already been closed
+ODBC result has already been closed
+ODBC result has already been closed
diff --git a/ext/odbc/tests/odbc_columnprivileges_001.phpt b/ext/odbc/tests/odbc_columnprivileges_001.phpt
index 5aba25895551f..be8fa20699009 100644
--- a/ext/odbc/tests/odbc_columnprivileges_001.phpt
+++ b/ext/odbc/tests/odbc_columnprivileges_001.phpt
@@ -22,7 +22,8 @@ var_dump(odbc_fetch_row($result));
?>
--EXPECTF--
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
bool(false)
Deprecated: odbc_columnprivileges(): Passing null to parameter #3 ($schema) of type string is deprecated in %s on line %d
@@ -30,7 +31,9 @@ Deprecated: odbc_columnprivileges(): Passing null to parameter #3 ($schema) of t
Deprecated: odbc_columnprivileges(): Passing null to parameter #4 ($table) of type string is deprecated in %s on line %d
Deprecated: odbc_columnprivileges(): Passing null to parameter #5 ($column) of type string is deprecated in %s on line %d
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
bool(false)
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
bool(false)
diff --git a/ext/odbc/tests/odbc_free_result_001.phpt b/ext/odbc/tests/odbc_free_result_001.phpt
index 8fc4075581a2f..28808f64208cf 100644
--- a/ext/odbc/tests/odbc_free_result_001.phpt
+++ b/ext/odbc/tests/odbc_free_result_001.phpt
@@ -17,22 +17,34 @@ odbc_exec($conn, 'INSERT INTO free_result VALUES (1), (2)');
$res = odbc_exec($conn, 'SELECT * FROM free_result');
-var_dump(odbc_fetch_row($res));
-var_dump(odbc_result($res, 'test'));
-var_dump(odbc_free_result($res));
try {
- var_dump(odbc_free_result($conn));
+ var_dump(odbc_fetch_row($res));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ var_dump(odbc_result($res, 'test'));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ var_dump(odbc_free_result($res));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
+try {
+ var_dump(odbc_free_result($conn));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
try {
var_dump(odbc_fetch_row($res));
-} catch (TypeError $e) {
+} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(odbc_result($res, 'test'));
-} catch (TypeError $e) {
+} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
@@ -46,6 +58,6 @@ odbc_exec($conn, 'DROP TABLE free_result');
bool(true)
string(1) "1"
bool(true)
-odbc_free_result(): supplied resource is not a valid ODBC result resource
-odbc_fetch_row(): supplied resource is not a valid ODBC result resource
-odbc_result(): supplied resource is not a valid ODBC result resource
+odbc_free_result(): Argument #1 ($statement) must be of type Odbc\Result, Odbc\Connection given
+ODBC result has already been closed
+ODBC result has already been closed
diff --git a/ext/odbc/tests/odbc_non_persistent_connection_reuse.phpt b/ext/odbc/tests/odbc_non_persistent_connection_reuse.phpt
new file mode 100644
index 0000000000000..12bbc9fc6faea
--- /dev/null
+++ b/ext/odbc/tests/odbc_non_persistent_connection_reuse.phpt
@@ -0,0 +1,69 @@
+--TEST--
+odbc_pconnect(): Make sure non-persistent connections are reused
+--EXTENSIONS--
+odbc
+--SKIPIF--
+
+--FILE--
+
+--EXPECT--
+string(21) "PHP odbc_connect test"
+string(21) "PHP odbc_connect test"
+NULL
diff --git a/ext/odbc/tests/odbc_persistent_close_all.phpt b/ext/odbc/tests/odbc_persistent_close_all.phpt
new file mode 100644
index 0000000000000..6bc5a4563978f
--- /dev/null
+++ b/ext/odbc/tests/odbc_persistent_close_all.phpt
@@ -0,0 +1,69 @@
+--TEST--
+odbc_pconnect(): Make sure closing a persistent connection works in case of odbc_close_all()
+--EXTENSIONS--
+odbc
+--SKIPIF--
+
+--FILE--
+
+--EXPECT--
+string(22) "PHP odbc_pconnect test"
+string(22) "PHP odbc_pconnect test"
+NULL
diff --git a/ext/odbc/tests/odbc_tables_001.phpt b/ext/odbc/tests/odbc_tables_001.phpt
index 7d4d816c7de06..4708bcd801d6f 100644
--- a/ext/odbc/tests/odbc_tables_001.phpt
+++ b/ext/odbc/tests/odbc_tables_001.phpt
@@ -27,13 +27,17 @@ var_dump(odbc_fetch_row($result));
?>
--EXPECTF--
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
bool(false)
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
bool(true)
bool(true)
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
bool(true)
bool(true)
-resource(%d) of type (odbc result)
+object(Odbc\Result)#%d (%d) {
+}
bool(false)
diff --git a/ext/opcache/jit/ir/ir.c b/ext/opcache/jit/ir/ir.c
index c8f179d4af2bc..95a5d2b0ea8e3 100644
--- a/ext/opcache/jit/ir/ir.c
+++ b/ext/opcache/jit/ir/ir.c
@@ -1798,7 +1798,9 @@ static ir_alias ir_check_partial_aliasing(const ir_ctx *ctx, ir_ref addr1, ir_re
if (insn1->op != IR_ADD) {
base1 = addr1;
off1 = IR_UNUSED;
- } else if (ctx->ir_base[insn1->op2].op == IR_SYM) {
+ } else if (ctx->ir_base[insn1->op2].op == IR_SYM
+ || ctx->ir_base[insn1->op2].op == IR_ALLOCA
+ || ctx->ir_base[insn1->op2].op == IR_VADDR) {
base1 = insn1->op2;
off1 = insn1->op1;
} else {
@@ -1808,7 +1810,9 @@ static ir_alias ir_check_partial_aliasing(const ir_ctx *ctx, ir_ref addr1, ir_re
if (insn2->op != IR_ADD) {
base2 = addr2;
off2 = IR_UNUSED;
- } else if (ctx->ir_base[insn2->op2].op == IR_SYM) {
+ } else if (ctx->ir_base[insn2->op2].op == IR_SYM
+ || ctx->ir_base[insn2->op2].op == IR_ALLOCA
+ || ctx->ir_base[insn2->op2].op == IR_VADDR) {
base2 = insn2->op2;
off2 = insn2->op1;
} else {
@@ -1834,7 +1838,7 @@ static ir_alias ir_check_partial_aliasing(const ir_ctx *ctx, ir_ref addr1, ir_re
}
if (offset1 == offset2) {
return IR_MUST_ALIAS;
- } else if (offset1 < offset2) {
+ } else if (offset1 < offset2) {
return offset1 + ir_type_size[type1] <= offset2 ? IR_NO_ALIAS : IR_MUST_ALIAS;
} else {
return offset2 + ir_type_size[type2] <= offset1 ? IR_NO_ALIAS : IR_MUST_ALIAS;
@@ -1842,9 +1846,33 @@ static ir_alias ir_check_partial_aliasing(const ir_ctx *ctx, ir_ref addr1, ir_re
} else {
insn1 = &ctx->ir_base[base1];
insn2 = &ctx->ir_base[base2];
- if ((insn1->op == IR_ALLOCA && (insn2->op == IR_ALLOCA || insn2->op == IR_SYM || insn2->op == IR_PARAM))
- || (insn1->op == IR_SYM && (insn2->op == IR_ALLOCA || insn2->op == IR_SYM))
- || (insn1->op == IR_PARAM && insn2->op == IR_ALLOCA)) {
+ while (insn1->op == IR_ADD) {
+ insn1 = &ctx->ir_base[insn1->op2];
+ if (insn1->op == IR_SYM
+ || insn1->op == IR_ALLOCA
+ || insn1->op == IR_VADDR) {
+ break;
+ } else {
+ insn1 = &ctx->ir_base[insn1->op1];
+ }
+ }
+ while (insn2->op == IR_ADD) {
+ insn2 = &ctx->ir_base[insn2->op2];
+ if (insn2->op == IR_SYM
+ || insn2->op == IR_ALLOCA
+ || insn2->op == IR_VADDR) {
+ break;
+ } else {
+ insn2 = &ctx->ir_base[insn2->op1];
+ }
+ }
+ if (insn1 == insn2) {
+ return IR_MAY_ALIAS;
+ }
+ if ((insn1->op == IR_ALLOCA && (insn2->op == IR_ALLOCA || insn2->op == IR_VADDR || insn2->op == IR_SYM || insn2->op == IR_PARAM))
+ || (insn1->op == IR_VADDR && (insn2->op == IR_ALLOCA || insn2->op == IR_VADDR || insn2->op == IR_SYM || insn2->op == IR_PARAM))
+ || (insn1->op == IR_SYM && (insn2->op == IR_ALLOCA || insn2->op == IR_VADDR || insn2->op == IR_SYM))
+ || (insn1->op == IR_PARAM && (insn2->op == IR_ALLOCA || insn2->op == IR_VADDR))) {
return IR_NO_ALIAS;
}
}
@@ -2715,7 +2743,53 @@ ir_ref _ir_VLOAD(ir_ctx *ctx, ir_type type, ir_ref var)
void _ir_VSTORE(ir_ctx *ctx, ir_ref var, ir_ref val)
{
+ ir_ref limit = var;
+ ir_ref ref = ctx->control;
+ ir_ref prev = IR_UNUSED;
+ ir_insn *insn;
+ bool guarded = 0;
+
+ if (!IR_IS_CONST_REF(val)) {
+ insn = &ctx->ir_base[val];
+ if (insn->op == IR_BITCAST
+ && !IR_IS_CONST_REF(insn->op1)
+ && ir_type_size[insn->type] == ir_type_size[ctx->ir_base[insn->op1].type]) {
+ /* skip BITCAST */
+ val = insn->op1;
+ }
+ }
+
IR_ASSERT(ctx->control);
+ while (ref > limit) {
+ insn = &ctx->ir_base[ref];
+ if (insn->op == IR_VSTORE) {
+ if (insn->op2 == var) {
+ if (insn->op3 == val) {
+ return;
+ } else {
+ if (!guarded) {
+ if (prev) {
+ ctx->ir_base[prev].op1 = insn->op1;
+ } else {
+ ctx->control = insn->op1;
+ }
+ MAKE_NOP(insn);
+ }
+ break;
+ }
+ }
+ } else if (insn->op == IR_VLOAD) {
+ if (insn->op2 == var) {
+ break;
+ }
+ } else if (insn->op == IR_GUARD || insn->op == IR_GUARD_NOT) {
+ guarded = 1;
+ } else if (insn->op >= IR_START || insn->op == IR_CALL || insn->op == IR_LOAD || insn->op == IR_STORE) {
+ break;
+ }
+ prev = ref;
+ ref = insn->op1;
+ }
ctx->control = ir_emit3(ctx, IR_VSTORE, ctx->control, var, val);
}
diff --git a/ext/opcache/jit/ir/ir.h b/ext/opcache/jit/ir/ir.h
index 6c8cb7db944ef..832b5c2a9e20d 100644
--- a/ext/opcache/jit/ir/ir.h
+++ b/ext/opcache/jit/ir/ir.h
@@ -541,6 +541,7 @@ void ir_strtab_free(ir_strtab *strtab);
# define IR_DEBUG_GCM_SPLIT (1<<28)
# define IR_DEBUG_SCHEDULE (1<<29)
# define IR_DEBUG_RA (1<<30)
+# define IR_DEBUG_BB_SCHEDULE (1U<<31)
#endif
typedef struct _ir_ctx ir_ctx;
diff --git a/ext/opcache/jit/ir/ir_aarch64.dasc b/ext/opcache/jit/ir/ir_aarch64.dasc
index 777c16f0fc6ec..dd695a7f79db5 100644
--- a/ext/opcache/jit/ir/ir_aarch64.dasc
+++ b/ext/opcache/jit/ir/ir_aarch64.dasc
@@ -592,11 +592,11 @@ int ir_get_target_constraints(ir_ctx *ctx, ir_ref ref, ir_target_constraints *co
constraints->tmp_regs[n] = IR_TMP_REG(1, ctx->ir_base[insn->op1].type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF);
n++;
}
- if (IR_IS_CONST_REF(insn->op2)) {
+ if (IR_IS_CONST_REF(insn->op2) || ir_rule(ctx, insn->op2) == IR_STATIC_ALLOCA) {
constraints->tmp_regs[n] = IR_TMP_REG(2, insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF);
n++;
}
- if (IR_IS_CONST_REF(insn->op3)) {
+ if (IR_IS_CONST_REF(insn->op3) || ir_rule(ctx, insn->op3) == IR_STATIC_ALLOCA) {
constraints->tmp_regs[n] = IR_TMP_REG(3, insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF);
n++;
}
@@ -1010,7 +1010,7 @@ binop_fp:
return IR_RETURN_FP;
}
case IR_IF:
- if (ir_in_same_block(ctx, insn->op2) && ctx->use_lists[insn->op2].count == 1) {
+ if (!IR_IS_CONST_REF(insn->op2) && ctx->use_lists[insn->op2].count == 1) {
op2_insn = &ctx->ir_base[insn->op2];
if (op2_insn->op >= IR_EQ && op2_insn->op <= IR_UGT) {
if (IR_IS_TYPE_INT(ctx->ir_base[op2_insn->op1].type)) {
@@ -1020,7 +1020,7 @@ binop_fp:
ctx->rules[insn->op2] = IR_FUSED | IR_CMP_FP;
return IR_CMP_AND_BRANCH_FP;
}
- } else if (op2_insn->op == IR_OVERFLOW) {
+ } else if (op2_insn->op == IR_OVERFLOW && ir_in_same_block(ctx, insn->op2)) {
ctx->rules[insn->op2] = IR_FUSED | IR_SIMPLE | IR_OVERFLOW;
return IR_OVERFLOW_AND_BRANCH;
}
@@ -1033,7 +1033,7 @@ binop_fp:
}
case IR_GUARD:
case IR_GUARD_NOT:
- if (ir_in_same_block(ctx, insn->op2) && ctx->use_lists[insn->op2].count == 1) {
+ if (!IR_IS_CONST_REF(insn->op2) && ctx->use_lists[insn->op2].count == 1) {
op2_insn = &ctx->ir_base[insn->op2];
if (op2_insn->op >= IR_EQ && op2_insn->op <= IR_UGT
// TODO: register allocator may clobber operands of CMP before they are used in the GUARD_CMP
@@ -1047,7 +1047,7 @@ binop_fp:
ctx->rules[insn->op2] = IR_FUSED | IR_CMP_FP;
return IR_GUARD_CMP_FP;
}
- } else if (op2_insn->op == IR_OVERFLOW) {
+ } else if (op2_insn->op == IR_OVERFLOW && ir_in_same_block(ctx, insn->op2)) {
ctx->rules[insn->op2] = IR_FUSED | IR_SIMPLE | IR_OVERFLOW;
return IR_GUARD_OVERFLOW;
}
diff --git a/ext/opcache/jit/ir/ir_cfg.c b/ext/opcache/jit/ir/ir_cfg.c
index 355c53fb04ce3..81ecc09c9ea4d 100644
--- a/ext/opcache/jit/ir/ir_cfg.c
+++ b/ext/opcache/jit/ir/ir_cfg.c
@@ -1151,13 +1151,11 @@ static void ir_insert_chain_before(ir_chain *chains, uint32_t c, uint32_t before
}
#ifndef IR_DEBUG_BB_SCHEDULE_GRAPH
-# define IR_DEBUG_BB_SCHEDULE_GRAPH 0
-#endif
-#ifndef IR_DEBUG_BB_SCHEDULE_EDGES
-# define IR_DEBUG_BB_SCHEDULE_EDGES 0
-#endif
-#ifndef IR_DEBUG_BB_SCHEDULE_CHAINS
-# define IR_DEBUG_BB_SCHEDULE_CHAINS 0
+# ifdef IR_DEBUG
+# define IR_DEBUG_BB_SCHEDULE_GRAPH 1
+# else
+# define IR_DEBUG_BB_SCHEDULE_GRAPH 0
+# endif
#endif
#if IR_DEBUG_BB_SCHEDULE_GRAPH
@@ -1210,20 +1208,17 @@ static void ir_dump_cfg_freq_graph(ir_ctx *ctx, float *bb_freq, uint32_t edges_c
}
#endif
-#if IR_DEBUG_BB_SCHEDULE_EDGES
+#ifdef IR_DEBUG
static void ir_dump_edges(ir_ctx *ctx, uint32_t edges_count, ir_edge_info *edges)
{
uint32_t i;
fprintf(stderr, "Edges:\n");
for (i = 0; i < edges_count; i++) {
- fprintf(stderr, "\tBB%d -> BB%d [label=\"%0.3f\"]\n", edges[i].from, edges[i].to, edges[i].freq);
+ fprintf(stderr, "\tBB%d -> BB%d %0.3f\n", edges[i].from, edges[i].to, edges[i].freq);
}
- fprintf(stderr, "}\n");
}
-#endif
-#if IR_DEBUG_BB_SCHEDULE_CHAINS
static void ir_dump_chains(ir_ctx *ctx, ir_chain *chains)
{
uint32_t b, tail, i;
@@ -1507,8 +1502,10 @@ static int ir_schedule_blocks_bottom_up(ir_ctx *ctx)
/* 2. Sort EDGEs according to their frequencies */
qsort(edges, edges_count, sizeof(ir_edge_info), ir_edge_info_cmp);
-#if IR_DEBUG_BB_SCHEDULE_EDGES
- ir_dump_edges(ctx, edges_count, edges);
+#ifdef IR_DEBUG
+ if (ctx->flags & IR_DEBUG_BB_SCHEDULE) {
+ ir_dump_edges(ctx, edges_count, edges);
+ }
#endif
/* 3. Process EDGEs in the decreasing frequency order and join the connected chains */
@@ -1555,13 +1552,17 @@ static int ir_schedule_blocks_bottom_up(ir_ctx *ctx)
}
#if IR_DEBUG_BB_SCHEDULE_GRAPH
- ir_dump_cfg_freq_graph(ctx, bb_freq, edges_count, edges, chains);
+ if (ctx->flags & IR_DEBUG_BB_SCHEDULE) {
+ ir_dump_cfg_freq_graph(ctx, bb_freq, edges_count, edges, chains);
+ }
#endif
ir_mem_free(bb_freq);
-#if IR_DEBUG_BB_SCHEDULE_CHAINS
- ir_dump_chains(ctx, chains);
+#ifdef IR_DEBUG
+ if (ctx->flags & IR_DEBUG_BB_SCHEDULE) {
+ ir_dump_chains(ctx, chains);
+ }
#endif
/* 4. Merge empty entry blocks */
@@ -1585,8 +1586,10 @@ static int ir_schedule_blocks_bottom_up(ir_ctx *ctx)
}
}
-#if IR_DEBUG_BB_SCHEDULE_CHAINS
- ir_dump_chains(ctx, chains);
+#ifdef IR_DEBUG
+ if (ctx->flags & IR_DEBUG_BB_SCHEDULE) {
+ ir_dump_chains(ctx, chains);
+ }
#endif
}
@@ -1619,8 +1622,10 @@ static int ir_schedule_blocks_bottom_up(ir_ctx *ctx)
}
}
-#if IR_DEBUG_BB_SCHEDULE_CHAINS
- ir_dump_chains(ctx, chains);
+#ifdef IR_DEBUG
+ if (ctx->flags & IR_DEBUG_BB_SCHEDULE) {
+ ir_dump_chains(ctx, chains);
+ }
#endif
/* 7. Form a final BB order */
diff --git a/ext/opcache/jit/ir/ir_emit.c b/ext/opcache/jit/ir/ir_emit.c
index c117ba5becb0c..334767b4c056a 100644
--- a/ext/opcache/jit/ir/ir_emit.c
+++ b/ext/opcache/jit/ir/ir_emit.c
@@ -695,6 +695,9 @@ IR_ALWAYS_INLINE void ir_dessa_resolve_cycle(ir_ctx *ctx, int32_t *pred, int32_t
#ifdef IR_HAVE_SWAP_INT
if (pred[from] == to && to < IR_REG_NUM && from < IR_REG_NUM) {
/* a simple cycle from 2 elements */
+ if (ir_type_size[types[to]] > ir_type_size[type]) {
+ type = types[to];
+ }
ir_emit_swap(ctx, type, to, from);
ir_bitset_excl(todo, from);
ir_bitset_excl(todo, to);
@@ -713,7 +716,7 @@ IR_ALWAYS_INLINE void ir_dessa_resolve_cycle(ir_ctx *ctx, int32_t *pred, int32_t
}
} else {
#ifdef IR_HAVE_SWAP_FP
- if (pred[from] == to && to < IR_REG_NUM && from < IR_REG_NUM) {
+ if (pred[from] == to && to < IR_REG_NUM && from < IR_REG_NUM && types[to] == type) {
/* a simple cycle from 2 elements */
ir_emit_swap_fp(ctx, type, to, from);
IR_REGSET_EXCL(todo, from);
diff --git a/ext/opcache/jit/ir/ir_fold.h b/ext/opcache/jit/ir/ir_fold.h
index 9d36bc7b3cce1..8c8beefdcccdd 100644
--- a/ext/opcache/jit/ir/ir_fold.h
+++ b/ext/opcache/jit/ir/ir_fold.h
@@ -1557,32 +1557,6 @@ IR_FOLD(SUB_OV(_, C_ADDR))
IR_FOLD_NEXT;
}
-IR_FOLD(ADD(C_U8, _))
-IR_FOLD(ADD(C_U16, _))
-IR_FOLD(ADD(C_U32, _))
-IR_FOLD(ADD(C_U64, _))
-IR_FOLD(ADD(C_I8, _))
-IR_FOLD(ADD(C_I16, _))
-IR_FOLD(ADD(C_I32, _))
-IR_FOLD(ADD(C_I64, _))
-IR_FOLD(ADD(C_ADDR, _))
-IR_FOLD(ADD_OV(C_U8, _))
-IR_FOLD(ADD_OV(C_U16, _))
-IR_FOLD(ADD_OV(C_U32, _))
-IR_FOLD(ADD_OV(C_U64, _))
-IR_FOLD(ADD_OV(C_I8, _))
-IR_FOLD(ADD_OV(C_I16, _))
-IR_FOLD(ADD_OV(C_I32, _))
-IR_FOLD(ADD_OV(C_I64, _))
-IR_FOLD(ADD_OV(C_ADDR, _))
-{
- if (op1_insn->val.u64 == 0) {
- /* 0 + a => a */
- IR_FOLD_COPY(op2);
- }
- IR_FOLD_NEXT;
-}
-
IR_FOLD(SUB(C_I8, _))
IR_FOLD(SUB(C_I16, _))
IR_FOLD(SUB(C_I32, _))
@@ -1839,51 +1813,6 @@ IR_FOLD(MUL(_, C_I64))
IR_FOLD_NEXT;
}
-IR_FOLD(MUL(C_U8, _))
-IR_FOLD(MUL(C_U16, _))
-IR_FOLD(MUL(C_U32, _))
-IR_FOLD(MUL(C_U64, _))
-IR_FOLD(MUL(C_ADDR, _))
-{
- if (op1_insn->val.u64 == 0) {
- /* 0 * a => 0 */
- IR_FOLD_COPY(op1);
- } else if (op1_insn->val.u64 == 1) {
- IR_FOLD_COPY(op2);
- } else if (op1_insn->val.u64 == 2 && IR_OPT_TYPE(opt) != IR_ADDR) {
- opt = IR_ADD | (opt & IR_OPT_TYPE_MASK);
- op1 = op2;
- IR_FOLD_RESTART;
- }
- IR_FOLD_NEXT;
-}
-
-IR_FOLD(MUL(C_I8, _))
-IR_FOLD(MUL(C_I16, _))
-IR_FOLD(MUL(C_I32, _))
-IR_FOLD(MUL(C_I64, _))
-{
- if (op1_insn->val.i64 == 0) {
- /* 0 * a => 0 */
- IR_FOLD_COPY(op1);
- } else if (op1_insn->val.i64 == 1) {
- /* 1 * a => a */
- IR_FOLD_COPY(op2);
- } else if (op1_insn->val.i64 == 2) {
- /* 2 * a => a + a */
- opt = IR_ADD | (opt & IR_OPT_TYPE_MASK);
- op1 = op2;
- IR_FOLD_RESTART;
- } else if (op1_insn->val.i64 == -1) {
- /* -1 * a => -a */
- opt = IR_NEG | (opt & IR_OPT_TYPE_MASK);
- op1 = op2;
- op2 = IR_UNUSED;
- IR_FOLD_RESTART;
- }
- IR_FOLD_NEXT;
-}
-
IR_FOLD(MUL(_, C_DOUBLE))
{
if (op2_insn->val.d == 1.0) {
@@ -2481,6 +2410,50 @@ IR_FOLD(TRUNC(AND))
IR_FOLD_NEXT;
}
+IR_FOLD(AND(SHR, C_I8))
+IR_FOLD(AND(SHR, C_U8))
+{
+ if (IR_IS_CONST_REF(op1_insn->op2)) {
+ if (((uint8_t)-1) >> ctx->ir_base[op1_insn->op2].val.u8 == op2_insn->val.u8) {
+ IR_FOLD_COPY(op1);
+ }
+ }
+ IR_FOLD_NEXT;
+}
+
+IR_FOLD(AND(SHR, C_I16))
+IR_FOLD(AND(SHR, C_U16))
+{
+ if (IR_IS_CONST_REF(op1_insn->op2)) {
+ if (((uint16_t)-1) >> ctx->ir_base[op1_insn->op2].val.u16 == op2_insn->val.u16) {
+ IR_FOLD_COPY(op1);
+ }
+ }
+ IR_FOLD_NEXT;
+}
+
+IR_FOLD(AND(SHR, C_I32))
+IR_FOLD(AND(SHR, C_U32))
+{
+ if (IR_IS_CONST_REF(op1_insn->op2)) {
+ if (((uint32_t)-1) >> ctx->ir_base[op1_insn->op2].val.u32 == op2_insn->val.u32) {
+ IR_FOLD_COPY(op1);
+ }
+ }
+ IR_FOLD_NEXT;
+}
+
+IR_FOLD(AND(SHR, C_I64))
+IR_FOLD(AND(SHR, C_U64))
+{
+ if (IR_IS_CONST_REF(op1_insn->op2)) {
+ if (((uint64_t)-1) >> ctx->ir_base[op1_insn->op2].val.u64 == op2_insn->val.u64) {
+ IR_FOLD_COPY(op1);
+ }
+ }
+ IR_FOLD_NEXT;
+}
+
IR_FOLD(EQ(FP2FP, C_DOUBLE))
IR_FOLD(NE(FP2FP, C_DOUBLE))
IR_FOLD(LT(FP2FP, C_DOUBLE))
@@ -2865,6 +2838,46 @@ IR_FOLD(XOR(XOR, _))
IR_FOLD_NEXT;
}
+/* ROL/ROR */
+IR_FOLD(OR(SHL, SHR))
+IR_FOLD(OR(SHR, SHL))
+IR_FOLD(ADD(SHL, SHR))
+IR_FOLD(ADD(SHR, SHL))
+{
+ if (op1_insn->op1 == op2_insn->op1) {
+ if (IR_IS_CONST_REF(op1_insn->op2) && IR_IS_CONST_REF(op2_insn->op2)) {
+ if (ctx->ir_base[op1_insn->op2].val.u64 + ctx->ir_base[op2_insn->op2].val.u64 ==
+ ir_type_size[IR_OPT_TYPE(opt)] * 8) {
+ /* (x << c) | (x >> (32 - c)) -> ROL(x, c) */
+ op1 = op1_insn->op1;
+ op2 = op1_insn->op2;
+ opt = op1_insn->opt + 3; /* SHL -> ROL, SHR -> ROR */
+ IR_FOLD_RESTART;
+ }
+ } else if (ctx->ir_base[op2_insn->op2].op == IR_SUB
+ && IR_IS_CONST_REF(ctx->ir_base[op2_insn->op2].op1)
+ && ctx->ir_base[op2_insn->op2].op2 == op1_insn->op2
+ && ctx->ir_base[ctx->ir_base[op2_insn->op2].op1].val.u64 == ir_type_size[IR_OPT_TYPE(opt)] * 8) {
+ /* (x << y) | (x >> (32 - y)) -> ROL(x, y) */
+ op1 = op1_insn->op1;
+ op2 = op1_insn->op2;
+ opt = op1_insn->opt + 3; /* SHL -> ROL, SHR -> ROR */
+ IR_FOLD_RESTART;
+ } else if (ctx->ir_base[op1_insn->op2].op == IR_SUB
+ && IR_IS_CONST_REF(ctx->ir_base[op1_insn->op2].op1)
+ && ctx->ir_base[op1_insn->op2].op2 == op2_insn->op2
+ && ctx->ir_base[ctx->ir_base[op1_insn->op2].op1].val.u64 == ir_type_size[IR_OPT_TYPE(opt)] * 8) {
+ /* (x << (32 - y)) | (x >> y) -> ROR(x, y) */
+ op1 = op2_insn->op1;
+ op2 = op2_insn->op2;
+ opt = op2_insn->opt + 3; /* SHL -> ROL, SHR -> ROR */
+ IR_FOLD_RESTART;
+ }
+ }
+ IR_FOLD_NEXT;
+}
+
+
/* Swap operands (move lower ref to op2) for better CSE */
IR_FOLD(ADD(_, _))
IR_FOLD(MUL(_, _))
diff --git a/ext/opcache/jit/ir/ir_gcm.c b/ext/opcache/jit/ir/ir_gcm.c
index adbe77a3f5d7c..f74227e2c0223 100644
--- a/ext/opcache/jit/ir/ir_gcm.c
+++ b/ext/opcache/jit/ir/ir_gcm.c
@@ -84,6 +84,7 @@ static uint32_t ir_gcm_select_best_block(ir_ctx *ctx, ir_ref ref, uint32_t lca)
return lca;
}
+#if 0 /* This is not necessary anymore. Conditions may be fused with IF across BBs. */
if (ctx->ir_base[ref].op >= IR_EQ && ctx->ir_base[ref].op <= IR_UGT) {
ir_use_list *use_list = &ctx->use_lists[ref];
@@ -96,6 +97,7 @@ static uint32_t ir_gcm_select_best_block(ir_ctx *ctx, ir_ref ref, uint32_t lca)
}
}
}
+#endif
flags = (bb->flags & IR_BB_LOOP_HEADER) ? bb->flags : ctx->cfg_blocks[bb->loop_header].flags;
if ((flags & IR_BB_LOOP_WITH_ENTRY)
@@ -389,6 +391,13 @@ static bool ir_split_partially_dead_node(ir_ctx *ctx, ir_ref ref, uint32_t b)
n = ctx->use_lists[ref].refs;
for (i = 0; i < clones_count; i++) {
clone = clones[i].ref;
+ if (clones[i].use_count == 1) {
+ /* TOTALLY_USEFUL block may be a head of a diamond above the real usage.
+ * Sink it down to the real usage block.
+ * Clones with few uses we be sunk into the LCA block.
+ */
+ clones[i].block = uses[clones[i].use].block;
+ }
ctx->cfg_map[clone] = clones[i].block;
ctx->use_lists[clone].count = clones[i].use_count;
ctx->use_lists[clone].refs = n;
@@ -403,19 +412,29 @@ static bool ir_split_partially_dead_node(ir_ctx *ctx, ir_ref ref, uint32_t b)
ir_insn *insn = &ctx->ir_base[use];
ir_ref k, l = insn->inputs_count;
- for (k = 1; k <= l; k++) {
- if (ir_insn_op(insn, k) == ref) {
- if (insn->op == IR_PHI) {
+ if (insn->op == IR_PHI) {
+ for (k = 1; k <= l; k++) {
+ if (ir_insn_op(insn, k) == ref) {
j = ctx->cfg_map[ir_insn_op(&ctx->ir_base[insn->op1], k - 1)];
- while (ir_sparse_set_in(&data->totally_useful, ctx->cfg_blocks[j].idom)) {
- j = ctx->cfg_blocks[j].idom;
- }
if (j != clones[i].block) {
- continue;
+ uint32_t dom_depth = ctx->cfg_blocks[clones[i].block].dom_depth;
+ while (ctx->cfg_blocks[j].dom_depth > dom_depth) {
+ j = ctx->cfg_blocks[j].dom_parent;
+ }
+ if (j != clones[i].block) {
+ continue;
+ }
}
+ ir_insn_set_op(insn, k, clone);
+ break;
+ }
+ }
+ } else {
+ for (k = 1; k <= l; k++) {
+ if (ir_insn_op(insn, k) == ref) {
+ ir_insn_set_op(insn, k, clone);
+ break;
}
- ir_insn_set_op(insn, k, clone);
- break;
}
}
}
@@ -487,9 +506,19 @@ static void ir_gcm_schedule_late(ir_ctx *ctx, ir_ref ref, uint32_t b)
b = ir_gcm_select_best_block(ctx, ref, lca);
ctx->cfg_map[ref] = b;
- if (ctx->ir_base[ref + 1].op == IR_OVERFLOW) {
- /* OVERFLOW is a projection and must be scheduled together with previous ADD/SUB/MUL_OV */
- ctx->cfg_map[ref + 1] = b;
+
+ /* OVERFLOW is a projection of ADD/SUB/MUL_OV and must be scheduled into the same block */
+ if (ctx->ir_base[ref].op >= IR_ADD_OV && ctx->ir_base[ref].op <= IR_MUL_OV) {
+ ir_use_list *use_list = &ctx->use_lists[ref];
+ ir_ref n, *p, use;
+
+ for (n = use_list->count, p = &ctx->use_edges[use_list->refs]; n < 0; p++, n--) {
+ use = *p;
+ if (ctx->ir_base[use].op == IR_OVERFLOW) {
+ ctx->cfg_map[use] = b;
+ break;
+ }
+ }
}
}
}
diff --git a/ext/opcache/jit/ir/ir_private.h b/ext/opcache/jit/ir/ir_private.h
index ec8f8779b0780..8f8db7b4a3d5e 100644
--- a/ext/opcache/jit/ir/ir_private.h
+++ b/ext/opcache/jit/ir/ir_private.h
@@ -582,6 +582,17 @@ IR_ALWAYS_INLINE void ir_bitqueue_init(ir_bitqueue *q, uint32_t n)
q->set = ir_bitset_malloc(n);
}
+IR_ALWAYS_INLINE void ir_bitqueue_grow(ir_bitqueue *q, uint32_t n)
+{
+ uint32_t len = ir_bitset_len(n);
+ IR_ASSERT(len >= q->len);
+ if (len > q->len) {
+ q->set = ir_mem_realloc(q->set, len * (IR_BITSET_BITS / 8));
+ memset(q->set + q->len, 0, (len - q->len) * (IR_BITSET_BITS / 8));
+ q->len = len;
+ }
+}
+
IR_ALWAYS_INLINE void ir_bitqueue_free(ir_bitqueue *q)
{
ir_mem_free(q->set);
diff --git a/ext/opcache/jit/ir/ir_ra.c b/ext/opcache/jit/ir/ir_ra.c
index 789e9c5612d17..0608b53d6f6eb 100644
--- a/ext/opcache/jit/ir/ir_ra.c
+++ b/ext/opcache/jit/ir/ir_ra.c
@@ -2115,7 +2115,7 @@ int ir_gen_dessa_moves(ir_ctx *ctx, uint32_t b, emit_copy_t emit_copy)
ir_insn *insn;
uint32_t len;
ir_bitset todo, ready;
- bool have_constants = 0;
+ bool have_constants_or_addresses = 0;
bb = &ctx->cfg_blocks[b];
if (!(bb->flags & IR_BB_DESSA_MOVES)) {
@@ -2141,8 +2141,8 @@ int ir_gen_dessa_moves(ir_ctx *ctx, uint32_t b, emit_copy_t emit_copy)
insn = &ctx->ir_base[ref];
if (insn->op == IR_PHI) {
input = ir_insn_op(insn, k);
- if (IR_IS_CONST_REF(input)) {
- have_constants = 1;
+ if (IR_IS_CONST_REF(input) || !ctx->vregs[input]) {
+ have_constants_or_addresses = 1;
} else if (ctx->vregs[input] != ctx->vregs[ref]) {
s = ctx->vregs[input];
d = ctx->vregs[ref];
@@ -2204,13 +2204,13 @@ int ir_gen_dessa_moves(ir_ctx *ctx, uint32_t b, emit_copy_t emit_copy)
ir_mem_free(todo);
ir_mem_free(loc);
- if (have_constants) {
+ if (have_constants_or_addresses) {
for (i = 0, p = &ctx->use_edges[use_list->refs]; i < use_list->count; i++, p++) {
ref = *p;
insn = &ctx->ir_base[ref];
if (insn->op == IR_PHI) {
input = ir_insn_op(insn, k);
- if (IR_IS_CONST_REF(input)) {
+ if (IR_IS_CONST_REF(input) || !ctx->vregs[input]) {
emit_copy(ctx, insn->type, input, ref);
}
}
@@ -2328,7 +2328,10 @@ static ir_live_pos ir_first_use_pos_after(ir_live_interval *ival, ir_live_pos po
{
ir_use_pos *p = ival->use_pos;
- while (p && p->pos <= pos) {
+ while (p && p->pos < pos) {
+ p = p->next;
+ }
+ if (p && p->pos == pos && p->op_num != 0) {
p = p->next;
}
while (p && !(p->flags & flags)) {
diff --git a/ext/opcache/jit/ir/ir_sccp.c b/ext/opcache/jit/ir/ir_sccp.c
index 547ae79fe5d51..c5665873aa989 100644
--- a/ext/opcache/jit/ir/ir_sccp.c
+++ b/ext/opcache/jit/ir/ir_sccp.c
@@ -347,7 +347,8 @@ static void ir_sccp_remove_insn(ir_ctx *ctx, ir_insn *_values, ir_ref ref, ir_bi
for (j = 1, p = insn->ops + j; j <= n; j++, p++) {
ir_ref input = *p;
*p = IR_UNUSED;
- if (input > 0 && _values[input].op == IR_BOTTOM) {
+ /* we may skip nodes that are going to be removed by SCCP (TOP, CONST and COPY) */
+ if (input > 0 && _values[input].op > IR_COPY) {
ir_use_list_remove_all(ctx, input, ref);
if (ir_is_dead(ctx, input)) {
/* schedule DCE */
@@ -396,13 +397,12 @@ static void ir_sccp_replace_insn(ir_ctx *ctx, ir_insn *_values, ir_ref ref, ir_r
for (j = 1, p = insn->ops + 1; j <= n; j++, p++) {
ir_ref input = *p;
*p = IR_UNUSED;
- if (input > 0) {
+ /* we may skip nodes that are going to be removed by SCCP (TOP, CONST and COPY) */
+ if (input > 0 && _values[input].op > IR_COPY) {
ir_use_list_remove_all(ctx, input, ref);
- if (_values[input].op == IR_BOTTOM) {
- if (ir_is_dead(ctx, input)) {
- /* schedule DCE */
- ir_bitqueue_add(worklist, input);
- }
+ if (ir_is_dead(ctx, input)) {
+ /* schedule DCE */
+ ir_bitqueue_add(worklist, input);
}
}
}
@@ -429,8 +429,9 @@ static void ir_sccp_replace_insn(ir_ctx *ctx, ir_insn *_values, ir_ref ref, ir_r
}
}
#endif
- /* schedule folding */
- if (worklist && _values[use].op == IR_BOTTOM) {
+ /* we may skip nodes that are going to be removed by SCCP (TOP, CONST and COPY) */
+ if (worklist && _values[use].op > IR_COPY) {
+ /* schedule folding */
ir_bitqueue_add(worklist, use);
}
}
@@ -1067,7 +1068,7 @@ static ir_ref ir_ext_const(ir_ctx *ctx, ir_insn *val_insn, ir_op op, ir_type typ
return ir_const(ctx, new_val, type);
}
-static ir_ref ir_ext_ref(ir_ctx *ctx, ir_ref var_ref, ir_ref src_ref, ir_op op, ir_type type)
+static ir_ref ir_ext_ref(ir_ctx *ctx, ir_ref var_ref, ir_ref src_ref, ir_op op, ir_type type, ir_bitqueue *worklist)
{
uint32_t optx = IR_OPTX(op, type, 1);
ir_ref ref;
@@ -1079,6 +1080,7 @@ static ir_ref ir_ext_ref(ir_ctx *ctx, ir_ref var_ref, ir_ref src_ref, ir_op op,
if (!IR_IS_CONST_REF(src_ref)) {
ir_use_list_remove_one(ctx, src_ref, var_ref);
}
+ ir_bitqueue_add(worklist, ref);
return ref;
}
}
@@ -1091,6 +1093,8 @@ static ir_ref ir_ext_ref(ir_ctx *ctx, ir_ref var_ref, ir_ref src_ref, ir_op op,
if (!IR_IS_CONST_REF(src_ref)) {
ir_use_list_replace_one(ctx, src_ref, var_ref, ref);
}
+ ir_bitqueue_grow(worklist, ref + 1);
+ ir_bitqueue_add(worklist, ref);
return ref;
}
@@ -1162,8 +1166,7 @@ static bool ir_try_promote_ext(ir_ctx *ctx, ir_ref ext_ref, ir_insn *insn, ir_bi
&& !IR_IS_SYM_CONST(ctx->ir_base[use_insn->op1].op)) {
ctx->ir_base[use].op1 = ir_ext_const(ctx, &ctx->ir_base[use_insn->op1], op, type);
} else {
- ctx->ir_base[use].op1 = ir_ext_ref(ctx, use, use_insn->op1, op, type);
- ir_bitqueue_add(worklist, ctx->ir_base[use].op1);
+ ctx->ir_base[use].op1 = ir_ext_ref(ctx, use, use_insn->op1, op, type, worklist);
}
}
if (use_insn->op2 != ref) {
@@ -1171,8 +1174,7 @@ static bool ir_try_promote_ext(ir_ctx *ctx, ir_ref ext_ref, ir_insn *insn, ir_bi
&& !IR_IS_SYM_CONST(ctx->ir_base[use_insn->op2].op)) {
ctx->ir_base[use].op2 = ir_ext_const(ctx, &ctx->ir_base[use_insn->op2], op, type);
} else {
- ctx->ir_base[use].op2 = ir_ext_ref(ctx, use, use_insn->op2, op, type);
- ir_bitqueue_add(worklist, ctx->ir_base[use].op2);
+ ctx->ir_base[use].op2 = ir_ext_ref(ctx, use, use_insn->op2, op, type, worklist);
}
}
}
@@ -1185,8 +1187,7 @@ static bool ir_try_promote_ext(ir_ctx *ctx, ir_ref ext_ref, ir_insn *insn, ir_bi
&& !IR_IS_SYM_CONST(ctx->ir_base[phi_insn->op2].op)) {
ctx->ir_base[ref].op2 = ir_ext_const(ctx, &ctx->ir_base[phi_insn->op2], op, type);
} else {
- ctx->ir_base[ref].op2 = ir_ext_ref(ctx, ref, phi_insn->op2, op, type);
- ir_bitqueue_add(worklist, ctx->ir_base[ref].op2);
+ ctx->ir_base[ref].op2 = ir_ext_ref(ctx, ref, phi_insn->op2, op, type, worklist);
}
return 1;
diff --git a/ext/opcache/jit/ir/ir_x86.dasc b/ext/opcache/jit/ir/ir_x86.dasc
index 94cb5fd9f9af6..1fa7001198c94 100644
--- a/ext/opcache/jit/ir/ir_x86.dasc
+++ b/ext/opcache/jit/ir/ir_x86.dasc
@@ -1262,11 +1262,11 @@ op2_const:
case IR_COND_CMP_INT:
insn = &ctx->ir_base[ref];
if (IR_IS_TYPE_INT(insn->type)) {
- if (IR_IS_CONST_REF(insn->op3)) {
+ if (IR_IS_CONST_REF(insn->op3) || ir_rule(ctx, insn->op3) == IR_STATIC_ALLOCA) {
flags = IR_USE_MUST_BE_IN_REG | IR_OP1_SHOULD_BE_IN_REG | IR_OP2_MUST_BE_IN_REG | IR_OP3_MUST_BE_IN_REG;
constraints->tmp_regs[0] = IR_TMP_REG(3, insn->type, IR_LOAD_SUB_REF, IR_SAVE_SUB_REF);
n = 1;
- } else if (IR_IS_CONST_REF(insn->op2)) {
+ } else if (IR_IS_CONST_REF(insn->op2) || ir_rule(ctx, insn->op2) == IR_STATIC_ALLOCA) {
flags = IR_USE_MUST_BE_IN_REG | IR_OP1_SHOULD_BE_IN_REG | IR_OP2_MUST_BE_IN_REG | IR_OP3_MUST_BE_IN_REG;
constraints->tmp_regs[0] = IR_TMP_REG(2, insn->type, IR_LOAD_SUB_REF, IR_SAVE_SUB_REF);
n = 1;
@@ -1586,6 +1586,69 @@ static void ir_match_fuse_addr(ir_ctx *ctx, ir_ref addr_ref)
}
}
+static bool ir_match_may_fuse_SI(ir_ctx *ctx, ir_ref ref, ir_ref use)
+{
+ ir_insn *op2_insn, *insn = &ctx->ir_base[use];
+
+ if (insn->op == IR_ADD) {
+ if (insn->op1 == ref) {
+ if (IR_IS_CONST_REF(insn->op2)) {
+ op2_insn = &ctx->ir_base[insn->op2];
+ if (IR_IS_SYM_CONST(op2_insn->op)) {
+ if (ir_may_fuse_addr(ctx, op2_insn)) {
+ return 1; // LEA_SI_O
+ }
+ } else if (IR_IS_SIGNED_32BIT(op2_insn->val.i64)) {
+ return 1; // LEA_SI_O
+ }
+ } else if (insn->op2 != ref) {
+ return 1; // LEA_SI_B or LEA_SI_OB
+ }
+ } else if (insn->op2 == ref && insn->op1 != insn->op2) {
+ return 1; // LEA_B_SI or LEA_OB_SI
+ }
+ }
+ return 0;
+}
+
+static bool ir_match_fuse_addr_all_useges(ir_ctx *ctx, ir_ref ref)
+{
+ uint32_t rule = ctx->rules[ref];
+ ir_use_list *use_list;
+ ir_ref n, *p, use;
+
+ if (rule == (IR_FUSED | IR_SIMPLE | IR_LEA_SI)) {
+ return 1;
+ } else if (!rule) {
+ ir_insn *insn = &ctx->ir_base[ref];
+
+ IR_ASSERT(IR_IS_TYPE_INT(insn->type) && ir_type_size[insn->type] >= 4);
+ if (insn->op == IR_MUL
+ && IR_IS_CONST_REF(insn->op2)) {
+ insn = &ctx->ir_base[insn->op2];
+ if (!IR_IS_SYM_CONST(insn->op)
+ && (insn->val.u64 == 2 || insn->val.u64 == 4 || insn->val.u64 == 8)) {
+ ctx->rules[ref] = IR_LEA_SI;
+
+ use_list = &ctx->use_lists[ref];
+ n = use_list->count;
+ IR_ASSERT(n > 1);
+ p = &ctx->use_edges[use_list->refs];
+ for (; n > 0; p++, n--) {
+ use = *p;
+ if (!ir_match_may_fuse_SI(ctx, ref, use)) {
+ return 0;
+ }
+ }
+
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
/* A naive check if there is a STORE or CALL between this LOAD and the fusion root */
static bool ir_match_has_mem_deps(ir_ctx *ctx, ir_ref ref, ir_ref root)
{
@@ -1895,13 +1958,13 @@ static uint32_t ir_match_insn(ir_ctx *ctx, ir_ref ref)
} else if ((ir_type_size[insn->type] >= 4 && insn->op == IR_ADD && IR_IS_SIGNED_32BIT(op2_insn->val.i64)) ||
(ir_type_size[insn->type] >= 4 && insn->op == IR_SUB && IR_IS_SIGNED_NEG_32BIT(op2_insn->val.i64))) {
lea:
- if (ctx->use_lists[insn->op1].count == 1) {
+ if (ctx->use_lists[insn->op1].count == 1 || ir_match_fuse_addr_all_useges(ctx, insn->op1)) {
uint32_t rule = ctx->rules[insn->op1];
if (!rule) {
ctx->rules[insn->op1] = rule = ir_match_insn(ctx, insn->op1);
}
- if (rule == IR_LEA_SI) {
+ if (rule == IR_LEA_SI || rule == (IR_FUSED | IR_SIMPLE | IR_LEA_SI)) {
/* z = MUL(Y, 2|4|8) ... ADD(z, imm32) => SKIP ... LEA [Y*2|4|8+im32] */
ctx->rules[insn->op1] = IR_FUSED | IR_SIMPLE | IR_LEA_SI;
return IR_LEA_SI_O;
@@ -1938,19 +2001,19 @@ lea:
}
} else if ((ctx->flags & IR_OPT_CODEGEN) && insn->op == IR_ADD && ir_type_size[insn->type] >= 4) {
if (insn->op1 != insn->op2) {
- if (ctx->use_lists[insn->op1].count == 1) {
+ if (ctx->use_lists[insn->op1].count == 1 || ir_match_fuse_addr_all_useges(ctx, insn->op1)) {
uint32_t rule =ctx->rules[insn->op1];
if (!rule) {
ctx->rules[insn->op1] = rule = ir_match_insn(ctx, insn->op1);
}
if (rule == IR_LEA_OB) {
ctx->rules[insn->op1] = IR_FUSED | IR_SIMPLE | IR_LEA_OB;
- if (ctx->use_lists[insn->op2].count == 1) {
+ if (ctx->use_lists[insn->op2].count == 1 || ir_match_fuse_addr_all_useges(ctx, insn->op2)) {
rule = ctx->rules[insn->op2];
if (!rule) {
ctx->rules[insn->op2] = rule = ir_match_insn(ctx, insn->op2);
}
- if (rule == IR_LEA_SI) {
+ if (rule == IR_LEA_SI || rule == (IR_FUSED | IR_SIMPLE | IR_LEA_SI)) {
/* x = ADD(X, imm32) ... y = MUL(Y, 2|4|8) ... ADD(x, y) => SKIP ... SKIP ... LEA */
ctx->rules[insn->op2] = IR_FUSED | IR_SIMPLE | IR_LEA_SI;
return IR_LEA_OB_SI;
@@ -1958,7 +2021,7 @@ lea:
}
/* x = ADD(X, imm32) ... ADD(x, Y) => SKIP ... LEA */
return IR_LEA_OB_I;
- } else if (rule == IR_LEA_SI) {
+ } else if (rule == IR_LEA_SI || rule == (IR_FUSED | IR_SIMPLE | IR_LEA_SI)) {
ctx->rules[insn->op1] = IR_FUSED | IR_SIMPLE | IR_LEA_SI;
if (ctx->use_lists[insn->op2].count == 1) {
rule = ctx->rules[insn->op2];
@@ -1975,7 +2038,7 @@ lea:
return IR_LEA_SI_B;
}
}
- if (ctx->use_lists[insn->op2].count == 1) {
+ if (ctx->use_lists[insn->op2].count == 1 || ir_match_fuse_addr_all_useges(ctx, insn->op2)) {
uint32_t rule = ctx->rules[insn->op2];
if (!rule) {
ctx->rules[insn->op2] = rule = ir_match_insn(ctx, insn->op2);
@@ -1984,7 +2047,7 @@ lea:
ctx->rules[insn->op2] = IR_FUSED | IR_SIMPLE | IR_LEA_OB;
/* x = ADD(X, imm32) ... ADD(Y, x) => SKIP ... LEA */
return IR_LEA_I_OB;
- } else if (rule == IR_LEA_SI) {
+ } else if (rule == IR_LEA_SI || rule == (IR_FUSED | IR_SIMPLE | IR_LEA_SI)) {
ctx->rules[insn->op2] = IR_FUSED | IR_SIMPLE | IR_LEA_SI;
/* x = MUL(X, 2|4|8) ... ADD(Y, x) => SKIP ... LEA */
return IR_LEA_B_SI;
@@ -2497,7 +2560,7 @@ store_int:
return IR_RETURN_FP;
}
case IR_IF:
- if (ir_in_same_block(ctx, insn->op2) && ctx->use_lists[insn->op2].count == 1) {
+ if (!IR_IS_CONST_REF(insn->op2) && ctx->use_lists[insn->op2].count == 1) {
op2_insn = &ctx->ir_base[insn->op2];
if (op2_insn->op >= IR_EQ && op2_insn->op <= IR_UGT) {
if (IR_IS_TYPE_INT(ctx->ir_base[op2_insn->op1].type)) {
@@ -2545,15 +2608,14 @@ store_int:
ir_match_fuse_load_test_int(ctx, op2_insn, ref);
ctx->rules[insn->op2] = IR_FUSED | IR_TEST_INT;
return IR_TEST_AND_BRANCH_INT;
- } else if (op2_insn->op == IR_OVERFLOW) {
+ } else if (op2_insn->op == IR_OVERFLOW && ir_in_same_block(ctx, insn->op2)) {
/* c = OVERFLOW(_) ... IF(c) => SKIP_OVERFLOW ... OVERFLOW_AND_BRANCH */
ctx->rules[insn->op2] = IR_FUSED | IR_SIMPLE | IR_OVERFLOW;
return IR_OVERFLOW_AND_BRANCH;
}
}
if (IR_IS_TYPE_INT(ctx->ir_base[insn->op2].type)) {
- if (insn->op2 == ref - 1 /* previous instruction */
- && ir_in_same_block(ctx, insn->op2)) {
+ if (insn->op2 == ref - 1) { /* previous instruction */
op2_insn = &ctx->ir_base[insn->op2];
if (op2_insn->op == IR_ADD ||
op2_insn->op == IR_SUB ||
@@ -2575,7 +2637,6 @@ store_int:
} else if ((ctx->flags & IR_OPT_CODEGEN)
&& insn->op1 == ref - 1 /* previous instruction */
&& insn->op2 == ref - 2 /* previous instruction */
- && ir_in_same_block(ctx, insn->op2)
&& ctx->use_lists[insn->op2].count == 2
&& IR_IS_TYPE_INT(ctx->ir_base[insn->op2].type)) {
ir_insn *store_insn = &ctx->ir_base[insn->op1];
@@ -2626,7 +2687,7 @@ store_int:
break;
}
case IR_COND:
- if (ir_in_same_block(ctx, insn->op1) && ctx->use_lists[insn->op1].count == 1) {
+ if (!IR_IS_CONST_REF(insn->op1) && ctx->use_lists[insn->op1].count == 1) {
ir_insn *op1_insn = &ctx->ir_base[insn->op1];
if (op1_insn->op >= IR_EQ && op1_insn->op <= IR_UGT) {
@@ -2644,7 +2705,7 @@ store_int:
return IR_COND;
case IR_GUARD:
case IR_GUARD_NOT:
- if (ir_in_same_block(ctx, insn->op2) && ctx->use_lists[insn->op2].count == 1) {
+ if (!IR_IS_CONST_REF(insn->op2) && ctx->use_lists[insn->op2].count == 1) {
op2_insn = &ctx->ir_base[insn->op2];
if (op2_insn->op >= IR_EQ && op2_insn->op <= IR_UGT
// TODO: register allocator may clobber operands of CMP before they are used in the GUARD_CMP
@@ -2734,7 +2795,7 @@ store_int:
ir_match_fuse_load_test_int(ctx, op2_insn, ref);
ctx->rules[insn->op2] = IR_FUSED | IR_TEST_INT;
return IR_GUARD_TEST_INT;
- } else if (op2_insn->op == IR_OVERFLOW) {
+ } else if (op2_insn->op == IR_OVERFLOW && ir_in_same_block(ctx, insn->op2)) {
/* c = OVERFLOW(_) ... GUARD(c) => SKIP_OVERFLOW ... GUARD_OVERFLOW */
ctx->rules[insn->op2] = IR_FUSED | IR_SIMPLE | IR_OVERFLOW;
return IR_GUARD_OVERFLOW;
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index caf9e8d086c6e..4596a14ba7224 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -106,6 +106,7 @@ static void zend_jit_trace_add_code(const void *start, uint32_t size);
static zend_string *zend_jit_func_name(const zend_op_array *op_array);
static bool zend_jit_needs_arg_dtor(const zend_function *func, uint32_t arg_num, zend_call_info *call_info);
+static bool zend_jit_supported_binary_op(uint8_t op, uint32_t op1_info, uint32_t op2_info);
static bool dominates(const zend_basic_block *blocks, int a, int b) {
while (blocks[b].level > blocks[a].level) {
@@ -1273,7 +1274,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
bool recv_emitted = 0; /* emitted at least one RECV opcode */
uint8_t smart_branch_opcode;
uint32_t target_label, target_label2;
- uint32_t op1_info, op1_def_info, op2_info, res_info, res_use_info;
+ uint32_t op1_info, op1_def_info, op2_info, res_info, res_use_info, op1_mem_info;
zend_jit_addr op1_addr, op1_def_addr, op2_addr, op2_def_addr, res_addr;
zend_class_entry *ce;
bool ce_is_instanceof;
@@ -1667,10 +1668,18 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
opline->extended_value, op1_info, op2_info)) {
break;
}
+ op1_addr = OP1_REG_ADDR();
+ op1_mem_info = -1;
+ if (Z_MODE(op1_addr) != IS_REG
+ || Z_LOAD(op1_addr)
+ || Z_STORE(op1_addr)) {
+ op1_mem_info = op1_info;
+ }
op1_def_info = OP1_DEF_INFO();
if (!zend_jit_assign_op(&ctx, opline,
- op1_info, op1_def_info, OP1_RANGE(),
- op2_info, OP2_RANGE(),
+ op1_info, op1_addr, OP1_RANGE(),
+ op1_def_info, OP1_DEF_REG_ADDR(), op1_mem_info,
+ op2_info, OP2_REG_ADDR(), OP2_RANGE(),
(op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (op1_def_info & MAY_BE_DOUBLE) && zend_may_overflow(opline, ssa_op, op_array, ssa),
zend_may_throw(opline, ssa_op, op_array, ssa))) {
goto jit_failure;
@@ -1688,8 +1697,10 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
break;
}
if (!zend_jit_assign_dim_op(&ctx, opline,
- OP1_INFO(), OP1_DEF_INFO(), OP1_REG_ADDR(), OP2_INFO(),
- OP1_DATA_INFO(), OP1_DATA_RANGE(), IS_UNKNOWN,
+ OP1_INFO(), OP1_DEF_INFO(), OP1_REG_ADDR(),
+ OP2_INFO(), (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
+ (opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
+ OP1_DATA_INFO(), OP1_DATA_REG_ADDR(), OP1_DATA_RANGE(), IS_UNKNOWN,
zend_may_throw(opline, ssa_op, op_array, ssa))) {
goto jit_failure;
}
@@ -1702,7 +1713,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
break;
}
if (!zend_jit_assign_dim(&ctx, opline,
- OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), OP1_DATA_INFO(), IS_UNKNOWN,
+ OP1_INFO(), OP1_REG_ADDR(),
+ OP2_INFO(), (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
+ (opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
+ OP1_DATA_INFO(), OP1_DATA_REG_ADDR(),
+ (ctx.ra && (ssa_op+1)->op1_def >= 0) ? OP1_DATA_DEF_REG_ADDR() : 0,
+ (opline->result_type != IS_UNUSED) ? RES_REG_ADDR() : 0,
+ IS_UNKNOWN,
zend_may_throw(opline, ssa_op, op_array, ssa))) {
goto jit_failure;
}
@@ -1725,7 +1742,10 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
@@ -1773,7 +1793,10 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
@@ -1814,7 +1837,10 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
@@ -2008,7 +2034,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
/* For EX variant write into the result of EX opcode. */
if ((opline+1)->opcode == ZEND_JMPZ_EX
|| (opline+1)->opcode == ZEND_JMPNZ_EX) {
- res_addr = OP_REG_ADDR(opline + 1, result_type, result, result_def);
+ res_addr = OP_REG_ADDR(opline + 1, ssa_op + 1, result_type, result, result_def);
}
} else {
smart_branch_opcode = 0;
@@ -2044,7 +2070,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
/* For EX variant write into the result of EX opcode. */
if ((opline+1)->opcode == ZEND_JMPZ_EX
|| (opline+1)->opcode == ZEND_JMPNZ_EX) {
- res_addr = OP_REG_ADDR(opline + 1, result_type, result, result_def);
+ res_addr = OP_REG_ADDR(opline + 1, ssa_op + 1, result_type, result, result_def);
}
} else {
smart_branch_opcode = 0;
@@ -2219,7 +2245,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
}
if (!zend_jit_fetch_dim_read(&ctx, opline, ssa, ssa_op,
OP1_INFO(), OP1_REG_ADDR(), 0,
- OP2_INFO(), RES_INFO(), RES_REG_ADDR(), IS_UNKNOWN)) {
+ OP2_INFO(), OP2_REG_ADDR(), OP2_RANGE(),
+ RES_INFO(), RES_REG_ADDR(), IS_UNKNOWN)) {
goto jit_failure;
}
goto done;
@@ -2234,7 +2261,10 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
break;
}
if (!zend_jit_fetch_dim(&ctx, opline,
- OP1_INFO(), OP1_REG_ADDR(), OP2_INFO(), RES_REG_ADDR(), IS_UNKNOWN)) {
+ OP1_INFO(), OP1_REG_ADDR(),
+ OP2_INFO(), (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
+ (opline->op2_type != IS_UNUSED) ? OP2_RANGE() : 0,
+ RES_REG_ADDR(), IS_UNKNOWN)) {
goto jit_failure;
}
goto done;
@@ -2262,7 +2292,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
}
if (!zend_jit_isset_isempty_dim(&ctx, opline,
OP1_INFO(), OP1_REG_ADDR(), 0,
- OP2_INFO(), IS_UNKNOWN,
+ OP2_INFO(), OP2_REG_ADDR(), OP2_RANGE(), IS_UNKNOWN,
zend_may_throw(opline, ssa_op, op_array, ssa),
smart_branch_opcode, target_label, target_label2,
NULL)) {
@@ -2284,7 +2314,10 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
op1_addr = 0;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
on_this = 1;
} else {
op1_info = OP1_INFO();
@@ -2305,7 +2338,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
}
if (!zend_jit_fetch_obj(&ctx, opline, op_array, ssa, ssa_op,
op1_info, op1_addr, 0, ce, ce_is_instanceof, on_this, 0, 0, NULL,
- IS_UNKNOWN,
+ RES_REG_ADDR(), IS_UNKNOWN,
zend_may_throw(opline, ssa_op, op_array, ssa))) {
goto jit_failure;
}
@@ -2435,7 +2468,10 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
op1_addr = 0;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
on_this = 1;
} else {
op1_info = OP1_INFO();
diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c
index d0a24aacc2e56..de59349e5f250 100644
--- a/ext/opcache/jit/zend_jit_helpers.c
+++ b/ext/opcache/jit/zend_jit_helpers.c
@@ -1956,6 +1956,110 @@ static void ZEND_FASTCALL zend_jit_fetch_obj_is_dynamic(zend_object *zobj, intpt
zend_jit_fetch_obj_is_slow(zobj);
}
+static zval* ZEND_FASTCALL zend_jit_fetch_obj_r_slow_ex(zend_object *zobj)
+{
+ zval *retval;
+ zend_execute_data *execute_data = EG(current_execute_data);
+ const zend_op *opline = EX(opline);
+ zend_string *name = Z_STR_P(RT_CONSTANT(opline, opline->op2));
+ zval *result = EX_VAR(opline->result.var);
+ void **cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS);
+
+ retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, result);
+ if (retval == result && UNEXPECTED(Z_ISREF_P(retval))) {
+ zend_unwrap_reference(retval);
+ }
+ return retval;
+}
+
+static zval* ZEND_FASTCALL zend_jit_fetch_obj_r_dynamic_ex(zend_object *zobj, intptr_t prop_offset)
+{
+ if (zobj->properties) {
+ zval *retval;
+ zend_execute_data *execute_data = EG(current_execute_data);
+ const zend_op *opline = EX(opline);
+ zend_string *name = Z_STR_P(RT_CONSTANT(opline, opline->op2));
+ void **cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS);
+
+ if (!IS_UNKNOWN_DYNAMIC_PROPERTY_OFFSET(prop_offset)) {
+ intptr_t idx = ZEND_DECODE_DYN_PROP_OFFSET(prop_offset);
+
+ if (EXPECTED(idx < zobj->properties->nNumUsed * sizeof(Bucket))) {
+ Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx);
+
+ if (EXPECTED(p->key == name) ||
+ (EXPECTED(p->h == ZSTR_H(name)) &&
+ EXPECTED(p->key != NULL) &&
+ EXPECTED(zend_string_equal_content(p->key, name)))) {
+ return &p->val;
+ }
+ }
+ CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET);
+ }
+
+ retval = zend_hash_find_known_hash(zobj->properties, name);
+
+ if (EXPECTED(retval)) {
+ intptr_t idx = (char*)retval - (char*)zobj->properties->arData;
+ CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx));
+ return retval;
+ }
+ }
+ return zend_jit_fetch_obj_r_slow_ex(zobj);
+}
+
+static zval* ZEND_FASTCALL zend_jit_fetch_obj_is_slow_ex(zend_object *zobj)
+{
+ zval *retval;
+ zend_execute_data *execute_data = EG(current_execute_data);
+ const zend_op *opline = EX(opline);
+ zend_string *name = Z_STR_P(RT_CONSTANT(opline, opline->op2));
+ zval *result = EX_VAR(opline->result.var);
+ void **cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS);
+
+ retval = zobj->handlers->read_property(zobj, name, BP_VAR_IS, cache_slot, result);
+ if (retval == result && UNEXPECTED(Z_ISREF_P(retval))) {
+ zend_unwrap_reference(retval);
+ }
+ return retval;
+}
+
+static zval* ZEND_FASTCALL zend_jit_fetch_obj_is_dynamic_ex(zend_object *zobj, intptr_t prop_offset)
+{
+ if (zobj->properties) {
+ zval *retval;
+ zend_execute_data *execute_data = EG(current_execute_data);
+ const zend_op *opline = EX(opline);
+ zend_string *name = Z_STR_P(RT_CONSTANT(opline, opline->op2));
+ void **cache_slot = CACHE_ADDR(opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS);
+
+ if (!IS_UNKNOWN_DYNAMIC_PROPERTY_OFFSET(prop_offset)) {
+ intptr_t idx = ZEND_DECODE_DYN_PROP_OFFSET(prop_offset);
+
+ if (EXPECTED(idx < zobj->properties->nNumUsed * sizeof(Bucket))) {
+ Bucket *p = (Bucket*)((char*)zobj->properties->arData + idx);
+
+ if (EXPECTED(p->key == name) ||
+ (EXPECTED(p->h == ZSTR_H(name)) &&
+ EXPECTED(p->key != NULL) &&
+ EXPECTED(zend_string_equal_content(p->key, name)))) {
+ return &p->val;
+ }
+ }
+ CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_DYNAMIC_PROPERTY_OFFSET);
+ }
+
+ retval = zend_hash_find_known_hash(zobj->properties, name);
+
+ if (EXPECTED(retval)) {
+ intptr_t idx = (char*)retval - (char*)zobj->properties->arData;
+ CACHE_PTR_EX(cache_slot + 1, (void*)ZEND_ENCODE_DYN_PROP_OFFSET(idx));
+ return retval;
+ }
+ }
+ return zend_jit_fetch_obj_is_slow_ex(zobj);
+}
+
static zend_always_inline bool promotes_to_array(zval *val) {
return Z_TYPE_P(val) <= IS_FALSE
|| (Z_ISREF_P(val) && Z_TYPE_P(Z_REFVAL_P(val)) <= IS_FALSE);
diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h
index da1a1c6f4dc2e..25123a92276e9 100644
--- a/ext/opcache/jit/zend_jit_internal.h
+++ b/ext/opcache/jit/zend_jit_internal.h
@@ -77,9 +77,9 @@ typedef uintptr_t zend_jit_addr;
ZEND_ADDR_MEM_ZVAL(ZREG_FP, (opline)->op.var))
#endif
-#define OP_REG_ADDR(opline, type, op, _ssa_op) \
- ((ctx.ra && ssa_op->_ssa_op >= 0 && ctx.ra[ssa_op->_ssa_op].ref) ? \
- ZEND_ADDR_REG(ssa_op->_ssa_op) : \
+#define OP_REG_ADDR(opline, ssa_op, type, op, _ssa_op) \
+ ((ctx.ra && (ssa_op)->_ssa_op >= 0 && ctx.ra[(ssa_op)->_ssa_op].ref) ? \
+ ZEND_ADDR_REG((ssa_op)->_ssa_op) : \
OP_ADDR(opline, type, op))
#define OP1_ADDR() \
@@ -92,22 +92,22 @@ typedef uintptr_t zend_jit_addr;
OP_ADDR(opline + 1, op1_type, op1)
#define OP1_REG_ADDR() \
- OP_REG_ADDR(opline, op1_type, op1, op1_use)
+ OP_REG_ADDR(opline, ssa_op, op1_type, op1, op1_use)
#define OP2_REG_ADDR() \
- OP_REG_ADDR(opline, op2_type, op2, op2_use)
+ OP_REG_ADDR(opline, ssa_op, op2_type, op2, op2_use)
#define RES_REG_ADDR() \
- OP_REG_ADDR(opline, result_type, result, result_def)
+ OP_REG_ADDR(opline, ssa_op, result_type, result, result_def)
#define OP1_DATA_REG_ADDR() \
- OP_REG_ADDR(opline + 1, op1_type, op1, op1_use)
+ OP_REG_ADDR(opline + 1, ssa_op + 1, op1_type, op1, op1_use)
#define OP1_DEF_REG_ADDR() \
- OP_REG_ADDR(opline, op1_type, op1, op1_def)
+ OP_REG_ADDR(opline, ssa_op, op1_type, op1, op1_def)
#define OP2_DEF_REG_ADDR() \
- OP_REG_ADDR(opline, op2_type, op2, op2_def)
+ OP_REG_ADDR(opline, ssa_op, op2_type, op2, op2_def)
#define RES_USE_REG_ADDR() \
- OP_REG_ADDR(opline, result_type, result, result_use)
+ OP_REG_ADDR(opline, ssa_op, result_type, result, result_use)
#define OP1_DATA_DEF_REG_ADDR() \
- OP_REG_ADDR(opline + 1, op1_type, op1, op1_def)
+ OP_REG_ADDR(opline + 1, ssa_op + 1, op1_type, op1, op1_def)
static zend_always_inline bool zend_jit_same_addr(zend_jit_addr addr1, zend_jit_addr addr2)
{
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index 18bcbbd141155..44296464feead 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -146,7 +146,7 @@
typedef struct _ir_refs {
uint32_t count;
uint32_t limit;
- ir_ref refs[0] ZEND_ELEMENT_COUNT(count);
+ ir_ref refs[] ZEND_ELEMENT_COUNT(count);
} ir_refs;
#define ir_refs_size(_n) (offsetof(ir_refs, refs) + sizeof(ir_ref) * (_n))
@@ -3039,9 +3039,13 @@ static void zend_jit_setup_disasm(void)
REGISTER_HELPER(zend_jit_assign_dim_op_helper);
REGISTER_HELPER(zend_jit_fetch_obj_w_slow);
REGISTER_HELPER(zend_jit_fetch_obj_r_slow);
+ REGISTER_HELPER(zend_jit_fetch_obj_r_slow_ex);
REGISTER_HELPER(zend_jit_fetch_obj_is_slow);
+ REGISTER_HELPER(zend_jit_fetch_obj_is_slow_ex);
REGISTER_HELPER(zend_jit_fetch_obj_r_dynamic);
+ REGISTER_HELPER(zend_jit_fetch_obj_r_dynamic_ex);
REGISTER_HELPER(zend_jit_fetch_obj_is_dynamic);
+ REGISTER_HELPER(zend_jit_fetch_obj_is_dynamic_ex);
REGISTER_HELPER(zend_jit_check_array_promotion);
REGISTER_HELPER(zend_jit_create_typed_ref);
REGISTER_HELPER(zend_jit_invalid_property_write);
@@ -5858,19 +5862,26 @@ static int zend_jit_concat(zend_jit_ctx *jit, const zend_op *opline, uint32_t op
return zend_jit_concat_helper(jit, opline, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, res_addr, may_throw);
}
-static int zend_jit_assign_op(zend_jit_ctx *jit, const zend_op *opline, uint32_t op1_info, uint32_t op1_def_info, zend_ssa_range *op1_range, uint32_t op2_info, zend_ssa_range *op2_range, int may_overflow, int may_throw)
+static int zend_jit_assign_op(zend_jit_ctx *jit,
+ const zend_op *opline,
+ uint32_t op1_info,
+ zend_jit_addr op1_addr,
+ zend_ssa_range *op1_range,
+ uint32_t op1_def_info,
+ zend_jit_addr op1_def_addr,
+ uint32_t op1_mem_info,
+ uint32_t op2_info,
+ zend_jit_addr op2_addr,
+ zend_ssa_range *op2_range,
+ int may_overflow,
+ int may_throw)
{
int result = 1;
- zend_jit_addr op1_addr, op2_addr;
ir_ref slow_path = IR_UNUSED;
-
ZEND_ASSERT(opline->op1_type == IS_CV && opline->result_type == IS_UNUSED);
ZEND_ASSERT(!(op1_info & MAY_BE_UNDEF) && !(op2_info & MAY_BE_UNDEF));
- op1_addr = OP1_ADDR();
- op2_addr = OP2_ADDR();
-
if (op1_info & MAY_BE_REF) {
ir_ref ref, ref2, arg2, op1_noref_path;
ir_ref if_op1_ref = IR_UNUSED;
@@ -5887,7 +5898,15 @@ static int zend_jit_assign_op(zend_jit_ctx *jit, const zend_op *opline, uint32_t
if_op1_typed = jit_if_TYPED_REF(jit, ref2);
ir_IF_TRUE_cold(if_op1_typed);
- arg2 = jit_ZVAL_ADDR(jit, op2_addr);
+ if (Z_MODE(op2_addr) == IS_REG) {
+ zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op2.var);
+ if (!zend_jit_spill_store_inv(jit, op2_addr, real_addr, op2_info)) {
+ return 0;
+ }
+ arg2 = jit_ZVAL_ADDR(jit, real_addr);
+ } else {
+ arg2 = jit_ZVAL_ADDR(jit, op2_addr);
+ }
jit_SET_EX_OPLINE(jit, opline);
if ((opline->op2_type & (IS_TMP_VAR|IS_VAR))
&& (op2_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
@@ -5905,7 +5924,8 @@ static int zend_jit_assign_op(zend_jit_ctx *jit, const zend_op *opline, uint32_t
ir_MERGE_WITH(op1_noref_path);
ref = ir_PHI_2(IR_ADDR, ref2, ref);
- op1_addr = ZEND_ADDR_REF_ZVAL(ref);
+ ZEND_ASSERT(op1_addr == op1_def_addr);
+ op1_def_addr = op1_addr = ZEND_ADDR_REF_ZVAL(ref);
}
switch (opline->extended_value) {
@@ -5913,7 +5933,7 @@ static int zend_jit_assign_op(zend_jit_ctx *jit, const zend_op *opline, uint32_t
case ZEND_SUB:
case ZEND_MUL:
case ZEND_DIV:
- result = zend_jit_math_helper(jit, opline, opline->extended_value, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->op1.var, op1_addr, op1_def_info, op1_info, may_overflow, may_throw);
+ result = zend_jit_math_helper(jit, opline, opline->extended_value, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, opline->op1.var, op1_def_addr, op1_def_info, op1_mem_info, may_overflow, may_throw);
break;
case ZEND_BW_OR:
case ZEND_BW_AND:
@@ -5924,10 +5944,10 @@ static int zend_jit_assign_op(zend_jit_ctx *jit, const zend_op *opline, uint32_t
result = zend_jit_long_math_helper(jit, opline, opline->extended_value,
opline->op1_type, opline->op1, op1_addr, op1_info, op1_range,
opline->op2_type, opline->op2, op2_addr, op2_info, op2_range,
- opline->op1.var, op1_addr, op1_def_info, op1_info, may_throw);
+ opline->op1.var, op1_def_addr, op1_def_info, op1_mem_info, may_throw);
break;
case ZEND_CONCAT:
- result = zend_jit_concat_helper(jit, opline, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, op1_addr, may_throw);
+ result = zend_jit_concat_helper(jit, opline, opline->op1_type, opline->op1, op1_addr, op1_info, opline->op2_type, opline->op2, op2_addr, op2_info, op1_def_addr, may_throw);
break;
default:
ZEND_UNREACHABLE();
@@ -6232,8 +6252,14 @@ static int zend_jit_assign_to_variable(zend_jit_ctx *jit,
ir_IF_TRUE_cold(if_typed);
jit_SET_EX_OPLINE(jit, opline);
if (Z_MODE(val_addr) == IS_REG) {
- ZEND_ASSERT(opline->opcode == ZEND_ASSIGN);
- zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op2.var);
+ zend_jit_addr real_addr;
+
+ if (opline->opcode == ZEND_ASSIGN_DIM) {
+ real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, (opline+1)->op1.var);
+ } else {
+ ZEND_ASSERT(opline->opcode == ZEND_ASSIGN);
+ real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op2.var);
+ }
if (!zend_jit_spill_store_inv(jit, val_addr, real_addr, val_info)) {
return 0;
}
@@ -11366,6 +11392,8 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
uint32_t type,
uint32_t op1_info,
uint32_t op2_info,
+ zend_jit_addr op2_addr,
+ zend_ssa_range *op2_range,
uint8_t dim_type,
const void *found_exit_addr,
const void *not_found_exit_addr,
@@ -11377,7 +11405,6 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
ir_ref *end_inputs,
ir_ref *not_found_inputs)
{
- zend_jit_addr op2_addr = OP2_ADDR();
zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
ir_ref ref = IR_UNUSED, cond, if_found;
ir_ref if_type = IS_UNUSED;
@@ -11467,9 +11494,16 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit,
// JIT: if (EXPECTED((zend_ulong)(_h) < (zend_ulong)(_ht)->nNumUsed))
ref = ir_LOAD_U32(ir_ADD_OFFSET(ht_ref, offsetof(zend_array, nNumUsed)));
#if SIZEOF_ZEND_LONG == 8
- ref = ir_ZEXT_L(ref);
-#endif
+ if ((Z_MODE(op2_addr) == IS_CONST_ZVAL && val >= 0 && val <= UINT32_MAX)
+ || (op2_range && op2_range->min >= 0 && op2_range->max <= UINT32_MAX)) {
+ /* comapre only the lower 32-bits to allow load fusion on x86_64 */
+ cond = ir_ULT(ir_TRUNC_U32(h), ref);
+ } else {
+ cond = ir_ULT(h, ir_ZEXT_L(ref));
+ }
+#else
cond = ir_ULT(h, ref);
+#endif
if (type == BP_JIT_IS) {
if (not_found_exit_addr) {
ir_GUARD(cond, ir_CONST_ADDR(not_found_exit_addr));
@@ -11965,11 +11999,13 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit,
zend_jit_addr op1_addr,
bool op1_avoid_refcounting,
uint32_t op2_info,
+ zend_jit_addr op2_addr,
+ zend_ssa_range *op2_range,
uint32_t res_info,
zend_jit_addr res_addr,
uint8_t dim_type)
{
- zend_jit_addr orig_op1_addr, op2_addr;
+ zend_jit_addr orig_op1_addr;
const void *exit_addr = NULL;
const void *not_found_exit_addr = NULL;
bool result_type_guard = 0;
@@ -11981,7 +12017,6 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit,
ir_ref not_found_inputs = IR_UNUSED;
orig_op1_addr = OP1_ADDR();
- op2_addr = OP2_ADDR();
if (opline->opcode != ZEND_FETCH_DIM_IS
&& JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE
@@ -12086,7 +12121,7 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit,
if (!zend_jit_fetch_dimension_address_inner(jit, opline,
(opline->opcode != ZEND_FETCH_DIM_IS) ? BP_VAR_R : BP_VAR_IS,
- op1_info, op2_info, dim_type, NULL, not_found_exit_addr, exit_addr,
+ op1_info, op2_info, op2_addr, op2_range, dim_type, NULL, not_found_exit_addr, exit_addr,
result_type_guard, ht_ref, found_inputs, found_vals,
&end_inputs, ¬_found_inputs)) {
return 0;
@@ -12423,16 +12458,15 @@ static int zend_jit_fetch_dim(zend_jit_ctx *jit,
uint32_t op1_info,
zend_jit_addr op1_addr,
uint32_t op2_info,
+ zend_jit_addr op2_addr,
+ zend_ssa_range *op2_range,
zend_jit_addr res_addr,
uint8_t dim_type)
{
- zend_jit_addr op2_addr;
int may_throw = 0;
ir_ref end_inputs = IR_UNUSED;
ir_ref ref, if_type = IR_UNUSED, ht_ref;
- op2_addr = (opline->op2_type != IS_UNUSED) ? OP2_ADDR() : 0;
-
if (opline->opcode == ZEND_FETCH_DIM_RW) {
jit_SET_EX_OPLINE(jit, opline);
}
@@ -12489,7 +12523,8 @@ static int zend_jit_fetch_dim(zend_jit_ctx *jit,
if (op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF) - (MAY_BE_LONG|MAY_BE_STRING))) {
may_throw = 1;
}
- if (!zend_jit_fetch_dimension_address_inner(jit, opline, type, op1_info, op2_info, dim_type, NULL, NULL, NULL,
+ if (!zend_jit_fetch_dimension_address_inner(jit, opline, type, op1_info,
+ op2_info, op2_addr, op2_range, dim_type, NULL, NULL, NULL,
0, ht_ref, found_inputs, found_vals, &end_inputs, NULL)) {
return 0;
}
@@ -12599,6 +12634,8 @@ static int zend_jit_isset_isempty_dim(zend_jit_ctx *jit,
zend_jit_addr op1_addr,
bool op1_avoid_refcounting,
uint32_t op2_info,
+ zend_jit_addr op2_addr,
+ zend_ssa_range *op2_range,
uint8_t dim_type,
int may_throw,
uint8_t smart_branch_opcode,
@@ -12606,7 +12643,7 @@ static int zend_jit_isset_isempty_dim(zend_jit_ctx *jit,
uint32_t target_label2,
const void *exit_addr)
{
- zend_jit_addr op2_addr, res_addr;
+ zend_jit_addr res_addr;
ir_ref if_type = IR_UNUSED;
ir_ref false_inputs = IR_UNUSED, end_inputs = IR_UNUSED;
ir_refs *true_inputs;
@@ -12616,7 +12653,6 @@ static int zend_jit_isset_isempty_dim(zend_jit_ctx *jit,
// TODO: support for empty() ???
ZEND_ASSERT(!(opline->extended_value & ZEND_ISEMPTY));
- op2_addr = OP2_ADDR();
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
if (op1_info & MAY_BE_REF) {
@@ -12648,7 +12684,8 @@ static int zend_jit_isset_isempty_dim(zend_jit_ctx *jit,
not_found_exit_addr = exit_addr;
}
}
- if (!zend_jit_fetch_dimension_address_inner(jit, opline, BP_JIT_IS, op1_info, op2_info, dim_type, found_exit_addr, not_found_exit_addr, NULL,
+ if (!zend_jit_fetch_dimension_address_inner(jit, opline, BP_JIT_IS, op1_info,
+ op2_info, op2_addr, op2_range, dim_type, found_exit_addr, not_found_exit_addr, NULL,
0, ht_ref, true_inputs, NULL, &false_inputs, NULL)) {
return 0;
}
@@ -12786,18 +12823,30 @@ static int zend_jit_isset_isempty_dim(zend_jit_ctx *jit,
return 1;
}
-static int zend_jit_assign_dim(zend_jit_ctx *jit, const zend_op *opline, uint32_t op1_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t val_info, uint8_t dim_type, int may_throw)
+static int zend_jit_assign_dim(zend_jit_ctx *jit,
+ const zend_op *opline,
+ uint32_t op1_info,
+ zend_jit_addr op1_addr,
+ uint32_t op2_info,
+ zend_jit_addr op2_addr,
+ zend_ssa_range *op2_range,
+ uint32_t val_info,
+ zend_jit_addr op3_addr,
+ zend_jit_addr op3_def_addr,
+ zend_jit_addr res_addr,
+ uint8_t dim_type,
+ int may_throw)
{
- zend_jit_addr op2_addr, op3_addr, res_addr;
ir_ref if_type = IR_UNUSED;
ir_ref end_inputs = IR_UNUSED, ht_ref;
- op2_addr = (opline->op2_type != IS_UNUSED) ? OP2_ADDR() : 0;
- op3_addr = OP1_DATA_ADDR();
- if (opline->result_type == IS_UNUSED) {
- res_addr = 0;
- } else {
- res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
+ if (op3_addr != op3_def_addr && op3_def_addr) {
+ if (!zend_jit_update_regs(jit, (opline+1)->op1.var, op3_addr, op3_def_addr, val_info)) {
+ return 0;
+ }
+ if (Z_MODE(op3_def_addr) == IS_REG && Z_MODE(op3_addr) != IS_REG) {
+ op3_addr = op3_def_addr;
+ }
}
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE && (val_info & MAY_BE_UNDEF)) {
@@ -12849,7 +12898,8 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, const zend_op *opline, uint32_
ir_refs_init(found_inputs, 8);
ir_refs_init(found_values, 8);
- if (!zend_jit_fetch_dimension_address_inner(jit, opline, BP_VAR_W, op1_info, op2_info, dim_type, NULL, NULL, NULL,
+ if (!zend_jit_fetch_dimension_address_inner(jit, opline, BP_VAR_W, op1_info,
+ op2_info, op2_addr, op2_range, dim_type, NULL, NULL, NULL,
0, ht_ref, found_inputs, found_values, &end_inputs, NULL)) {
return 0;
}
@@ -12867,7 +12917,9 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, const zend_op *opline, uint32_
var_addr = ZEND_ADDR_REF_ZVAL(ref);
// JIT: value = zend_assign_to_variable(variable_ptr, value, OP_DATA_TYPE);
- if (opline->op1_type == IS_VAR) {
+ if (opline->op1_type == IS_VAR
+ && Z_MODE(op3_addr) != IS_REG
+ && (res_addr == 0 || Z_MODE(res_addr) != IS_REG)) {
ZEND_ASSERT(opline->result_type == IS_UNUSED);
if (!zend_jit_assign_to_variable_call(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0)) {
return 0;
@@ -12942,9 +12994,21 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, const zend_op *opline, uint32_
return 1;
}
-static int zend_jit_assign_dim_op(zend_jit_ctx *jit, const zend_op *opline, uint32_t op1_info, uint32_t op1_def_info, zend_jit_addr op1_addr, uint32_t op2_info, uint32_t op1_data_info, zend_ssa_range *op1_data_range, uint8_t dim_type, int may_throw)
+static int zend_jit_assign_dim_op(zend_jit_ctx *jit,
+ const zend_op *opline,
+ uint32_t op1_info,
+ uint32_t op1_def_info,
+ zend_jit_addr op1_addr,
+ uint32_t op2_info,
+ zend_jit_addr op2_addr,
+ zend_ssa_range *op2_range,
+ uint32_t op1_data_info,
+ zend_jit_addr op3_addr,
+ zend_ssa_range *op1_data_range,
+ uint8_t dim_type,
+ int may_throw)
{
- zend_jit_addr op2_addr, op3_addr, var_addr = IS_UNUSED;
+ zend_jit_addr var_addr = IS_UNUSED;
const void *not_found_exit_addr = NULL;
uint32_t var_info = MAY_BE_NULL;
ir_ref if_type = IS_UNUSED;
@@ -12953,10 +13017,9 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, const zend_op *opline, uint
ZEND_ASSERT(opline->result_type == IS_UNUSED);
- op2_addr = (opline->op2_type != IS_UNUSED) ? OP2_ADDR() : 0;
- op3_addr = OP1_DATA_ADDR();
-
- jit_SET_EX_OPLINE(jit, opline);
+ if (may_throw) {
+ jit_SET_EX_OPLINE(jit, opline);
+ }
op1_addr = zend_jit_prepare_array_update(jit, opline, op1_info, op1_addr, &if_type, &ht_ref, &may_throw);
@@ -13009,7 +13072,8 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, const zend_op *opline, uint
}
}
- if (!zend_jit_fetch_dimension_address_inner(jit, opline, BP_VAR_RW, op1_info, op2_info, dim_type, NULL, not_found_exit_addr, NULL,
+ if (!zend_jit_fetch_dimension_address_inner(jit, opline, BP_VAR_RW, op1_info,
+ op2_info, op2_addr, op2_range, dim_type, NULL, not_found_exit_addr, NULL,
0, ht_ref, found_inputs, found_values, &end_inputs, NULL)) {
return 0;
}
@@ -13602,13 +13666,13 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit,
bool delayed_fetch_this,
bool op1_avoid_refcounting,
zend_class_entry *trace_ce,
+ zend_jit_addr res_addr,
uint8_t prop_type,
int may_throw)
{
zval *member;
zend_property_info *prop_info;
bool may_be_dynamic = 1;
- zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
zend_jit_addr prop_addr;
uint32_t res_info = RES_INFO();
ir_ref prop_type_ref = IR_UNUSED;
@@ -13616,6 +13680,7 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit,
ir_ref prop_ref = IR_UNUSED;
ir_ref end_inputs = IR_UNUSED;
ir_ref slow_inputs = IR_UNUSED;
+ ir_ref end_values = IR_UNUSED;
ZEND_ASSERT(opline->op2_type == IS_CONST);
ZEND_ASSERT(op1_info & MAY_BE_OBJECT);
@@ -13744,13 +13809,28 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit,
jit_SET_EX_OPLINE(jit, opline);
if (opline->opcode != ZEND_FETCH_OBJ_IS) {
- ir_CALL_2(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_r_dynamic),
- obj_ref, offset_ref);
+ if (((res_info & MAY_BE_GUARD) && JIT_G(current_frame) && prop_info)
+ || Z_MODE(res_addr) == IS_REG) {
+ ir_ref val_addr = ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(zend_jit_fetch_obj_r_dynamic_ex),
+ obj_ref, offset_ref);
+ ir_END_PHI_list(end_values, val_addr);
+ } else {
+ ir_CALL_2(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_r_dynamic),
+ obj_ref, offset_ref);
+ ir_END_list(end_inputs);
+ }
} else {
- ir_CALL_2(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_is_dynamic),
- obj_ref, offset_ref);
+ if (((res_info & MAY_BE_GUARD) && JIT_G(current_frame) && prop_info)
+ || Z_MODE(res_addr) == IS_REG) {
+ ir_ref val_addr = ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(zend_jit_fetch_obj_is_dynamic_ex),
+ obj_ref, offset_ref);
+ ir_END_PHI_list(end_values, val_addr);
+ } else {
+ ir_CALL_2(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_is_dynamic),
+ obj_ref, offset_ref);
+ ir_END_list(end_inputs);
+ }
}
- ir_END_list(end_inputs);
}
ir_IF_FALSE(if_dynamic);
}
@@ -13936,12 +14016,56 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit,
}
ir_END_list(end_inputs);
} else {
+ if (((res_info & MAY_BE_GUARD) && JIT_G(current_frame) && prop_info)
+ || Z_MODE(res_addr) == IS_REG) {
+ ir_END_PHI_list(end_values, jit_ZVAL_ADDR(jit, prop_addr));
+ } else {
+ prop_type_ref = jit_Z_TYPE_INFO(jit, prop_addr);
+
+ if (!zend_jit_zval_copy_deref(jit, res_addr, prop_addr, prop_type_ref)) {
+ return 0;
+ }
+ ir_END_list(end_inputs);
+ }
+ }
+
+ if (op1_avoid_refcounting) {
+ SET_STACK_REG(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE);
+ }
+
+ if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || !prop_info) {
+ ir_MERGE_list(slow_inputs);
+ jit_SET_EX_OPLINE(jit, opline);
+
+ if (opline->opcode == ZEND_FETCH_OBJ_W) {
+ ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_w_slow), obj_ref);
+ ir_END_list(end_inputs);
+ } else if (opline->opcode != ZEND_FETCH_OBJ_IS) {
+ if (Z_MODE(res_addr) == IS_REG) {
+ ir_ref val_ref = ir_CALL_1(IR_ADDR, ir_CONST_FC_FUNC(zend_jit_fetch_obj_r_slow_ex), obj_ref);
+ ir_END_PHI_list(end_values, val_ref);
+ } else {
+ ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_r_slow), obj_ref);
+ ir_END_list(end_inputs);
+ }
+ } else {
+ ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_is_slow), obj_ref);
+ ir_END_list(end_inputs);
+ }
+ }
+
+ if (end_values) {
+ ir_ref val_ref = ir_PHI_list(end_values);
+ zend_jit_addr val_addr = ZEND_ADDR_REF_ZVAL(val_ref);
bool result_avoid_refcounting = 0;
- if ((res_info & MAY_BE_GUARD) && JIT_G(current_frame) && prop_info) {
+ ZEND_ASSERT(opline->opcode == ZEND_FETCH_OBJ_R
+ || opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG
+ || opline->opcode == ZEND_FETCH_OBJ_IS);
+ ZEND_ASSERT(end_inputs == IR_UNUSED);
+ if ((res_info & MAY_BE_GUARD) && JIT_G(current_frame)) {
uint8_t type = concrete_type(res_info);
uint32_t flags = 0;
- zend_jit_addr val_addr = prop_addr;
if ((opline->op1_type & (IS_VAR|IS_TMP_VAR))
&& !delayed_fetch_this
@@ -13966,39 +14090,14 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit,
res_info &= ~MAY_BE_GUARD;
ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
-
- // ZVAL_COPY
- jit_ZVAL_COPY(jit, res_addr, -1, val_addr, res_info, !result_avoid_refcounting);
- } else {
- prop_type_ref = jit_Z_TYPE_INFO(jit, prop_addr);
-
- if (!zend_jit_zval_copy_deref(jit, res_addr, prop_addr, prop_type_ref)) {
- return 0;
- }
}
- ir_END_list(end_inputs);
- }
-
- if (op1_avoid_refcounting) {
- SET_STACK_REG(JIT_G(current_frame)->stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE);
- }
-
- if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || !prop_info) {
- ir_MERGE_list(slow_inputs);
- jit_SET_EX_OPLINE(jit, opline);
- if (opline->opcode == ZEND_FETCH_OBJ_W) {
- ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_w_slow), obj_ref);
- } else if (opline->opcode != ZEND_FETCH_OBJ_IS) {
- ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_r_slow), obj_ref);
- } else {
- ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_fetch_obj_is_slow), obj_ref);
- }
- ir_END_list(end_inputs);
+ // ZVAL_COPY
+ jit_ZVAL_COPY(jit, res_addr, -1, val_addr, res_info, !result_avoid_refcounting);
+ } else {
+ ir_MERGE_list(end_inputs);
}
- ir_MERGE_list(end_inputs);
-
if (opline->op1_type != IS_UNUSED && !delayed_fetch_this && !op1_indirect) {
if (opline->op1_type == IS_VAR
&& opline->opcode == ZEND_FETCH_OBJ_W
@@ -16466,6 +16565,13 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa
return (op_array->type != ZEND_EVAL_CODE && op_array->function_name);
case ZEND_ASSIGN:
return (opline->op1_type == IS_CV);
+ case ZEND_ASSIGN_OP:
+ if (opline->op1_type != IS_CV || opline->result_type != IS_UNUSED) {
+ return 0;
+ }
+ op1_info = OP1_INFO();
+ op2_info = OP2_INFO();
+ return zend_jit_supported_binary_op(opline->extended_value, op1_info, op2_info);
case ZEND_ADD:
case ZEND_SUB:
case ZEND_MUL:
@@ -16535,7 +16641,14 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa
return 1;
case ZEND_FETCH_CONSTANT:
return 1;
+ case ZEND_ISSET_ISEMPTY_DIM_OBJ:
+ if ((opline->extended_value & ZEND_ISEMPTY)) {
+ return 0;
+ }
+ ZEND_FALLTHROUGH;
case ZEND_FETCH_DIM_R:
+ case ZEND_FETCH_DIM_IS:
+ case ZEND_FETCH_LIST_R:
op1_info = OP1_INFO();
op2_info = OP2_INFO();
if (trace
@@ -16544,10 +16657,58 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa
op1_info &= ~((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY);
}
return ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) &&
- (!(opline->op1_type & (IS_TMP_VAR|IS_VAR)) || !(op1_info & MAY_BE_RC1)) &&
(((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) ||
- (((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_STRING) &&
- (!(opline->op2_type & (IS_TMP_VAR|IS_VAR)) || !(op2_info & MAY_BE_RC1))));
+ ((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_STRING));
+ case ZEND_ASSIGN_DIM_OP:
+ if (opline->result_type != IS_UNUSED) {
+ return 0;
+ }
+ if (!zend_jit_supported_binary_op(opline->extended_value, MAY_BE_ANY, OP1_DATA_INFO())) {
+ return 0;
+ }
+ ZEND_FALLTHROUGH;
+ case ZEND_ASSIGN_DIM:
+ case ZEND_FETCH_DIM_W:
+ case ZEND_FETCH_DIM_RW:
+ case ZEND_FETCH_LIST_W:
+ op1_info = OP1_INFO();
+ op2_info = OP2_INFO();
+ if (trace) {
+ if (opline->op1_type == IS_CV) {
+ if ((opline->opcode == ZEND_ASSIGN_DIM
+ || opline->opcode == ZEND_ASSIGN_DIM_OP)
+ && (opline+1)->op1_type == IS_CV
+ && (opline+1)->op1.var == opline->op1.var) {
+ /* skip $a[x] = $a; */
+ return 0;
+ }
+ } else if (opline->op1_type == IS_VAR) {
+ if (trace->op1_type == IS_UNKNOWN
+ || !(trace->op1_type & IS_TRACE_INDIRECT)
+ || opline->result_type != IS_UNUSED) {
+ return 0;
+ }
+ }
+ if (trace->op1_type != IS_UNKNOWN
+ && (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)) == IS_ARRAY) {
+ op1_info &= ~((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_ARRAY);
+ }
+ } else {
+ if (opline->op1_type != IS_CV) {
+ return 0;
+ }
+ }
+ return ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) &&
+ (((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_LONG) ||
+ ((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_STRING));
+ case ZEND_FETCH_OBJ_R:
+ if (opline->op2_type != IS_CONST
+ || Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) != IS_STRING
+ || Z_STRVAL_P(RT_CONSTANT(opline, opline->op2))[0] == '\0') {
+ return 0;
+ }
+ op1_info = OP1_INFO();
+ return opline->op1_type == IS_UNUSED || (op1_info & MAY_BE_OBJECT);
}
return 0;
}
@@ -16607,11 +16768,6 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa,
!zend_jit_opline_supports_reg(op_array, ssa, op_array->opcodes + use, ssa->ops + use, NULL)) {
return 0;
}
- /* Quick workaround to disable register allocation for unsupported operand */
- // TODO: Find a general solution ???
- if (op_array->opcodes[use].opcode == ZEND_FETCH_DIM_R) {
- return 0;
- }
use = zend_ssa_next_use(ssa->ops, var, use);
} while (use >= 0);
}
diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c
index db8fa7356c998..df10a93bcb837 100644
--- a/ext/opcache/jit/zend_jit_trace.c
+++ b/ext/opcache/jit/zend_jit_trace.c
@@ -2909,9 +2909,7 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
if (ssa_op->op2_use >= 0
&& ssa_op->op2_use != ssa_op->op1_use
&& RA_HAS_IVAL(ssa_op->op2_use)) {
- /* Quick workaround to disable register allocation for unsupported operand */
- // TODO: Find a general solution ???
- if (!support_opline || opline->opcode == ZEND_FETCH_DIM_R) {
+ if (!support_opline) {
RA_IVAL_DEL(ssa_op->op2_use);
count--;
} else if (!zend_ssa_is_no_val_use(opline, ssa_op, ssa_op->op2_use)) {
@@ -2965,6 +2963,7 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
|| opline->opcode == ZEND_SUB
|| opline->opcode == ZEND_MUL
|| opline->opcode == ZEND_FETCH_DIM_R
+ || opline->opcode == ZEND_FETCH_OBJ_R
|| opline->opcode == ZEND_FETCH_CONSTANT) {
if (!(ssa->var_info[ssa_op->result_def].type & MAY_BE_DOUBLE)
|| (opline->opcode != ZEND_PRE_INC && opline->opcode != ZEND_PRE_DEC)) {
@@ -3036,7 +3035,8 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t
&& (ssa->vars[ssa_op->op1_def].use_chain >= 0
|| ssa->vars[ssa_op->op1_def].phi_use_chain)
&& ssa->vars[ssa_op->op1_def].alias == NO_ALIAS
- && zend_jit_var_supports_reg(ssa, ssa_op->op1_def)) {
+ && zend_jit_var_supports_reg(ssa, ssa_op->op1_def)
+ && !(ssa->var_info[ssa_op->op1_def].type & MAY_BE_GUARD)) {
vars_op_array[ssa_op->op1_def] = op_array;
RA_IVAL_START(ssa_op->op1_def, idx);
count++;
@@ -3967,6 +3967,33 @@ static bool zend_jit_trace_must_store_type(const zend_op_array *op_array,
return 1;
}
+static bool zend_jit_trace_may_throw(const zend_op *opline,
+ const zend_ssa_op *ssa_op,
+ const zend_op_array *op_array,
+ const zend_ssa *ssa,
+ uint32_t t1,
+ uint32_t t2,
+ uint32_t t3,
+ uint32_t val_type)
+{
+ switch (opline->opcode) {
+ case ZEND_ASSIGN_DIM_OP:
+ if (opline->extended_value != ZEND_CONCAT
+ && val_type == IS_LONG
+ && (t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF)) == MAY_BE_ARRAY
+ && MAY_BE_PACKED_ONLY(t1)
+ && !(t1 & MAY_BE_ARRAY_OF_REF)
+ && (t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF)) == MAY_BE_LONG
+ && (t3 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF)) == MAY_BE_LONG) {
+ return 0;
+ }
+ break;
+ default:
+ break;
+ }
+ return zend_may_throw_ex(opline, ssa_op, op_array, ssa, t1, t2);
+}
+
static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t parent_trace, uint32_t exit_num)
{
const void *handler = NULL;
@@ -3986,7 +4013,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
const zend_op_array *op_arrays[ZEND_JIT_TRACE_MAX_FUNCS];
uint8_t smart_branch_opcode;
const void *exit_addr;
- uint32_t op1_info, op1_def_info, op2_info, res_info, res_use_info, op1_data_info;
+ uint32_t op1_info, op1_def_info, op2_info, res_info, res_use_info, op1_data_info, op1_mem_info;
bool send_result = 0;
bool skip_comparison;
zend_jit_addr op1_addr, op1_def_addr, op2_addr, op2_def_addr, res_addr;
@@ -4564,14 +4591,24 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
opline->extended_value, op1_info, op2_info)) {
break;
}
+ op1_addr = OP1_REG_ADDR();
+ if (Z_MODE(op1_addr) != IS_REG
+ || Z_LOAD(op1_addr)
+ || Z_STORE(op1_addr)) {
+ op1_mem_info = op1_info;
+ } else {
+ op1_mem_info = zend_jit_trace_type_to_info(
+ STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var)));
+ }
op1_def_info = OP1_DEF_INFO();
if (op1_def_info & MAY_BE_GUARD
&& !has_concrete_type(op1_def_info)) {
op1_def_info &= ~MAY_BE_GUARD;
}
if (!zend_jit_assign_op(&ctx, opline,
- op1_info, op1_def_info, OP1_RANGE(),
- op2_info, OP2_RANGE(),
+ op1_info, op1_addr, OP1_RANGE(),
+ op1_def_info, OP1_DEF_REG_ADDR(), op1_mem_info,
+ op2_info, OP2_REG_ADDR(), OP2_RANGE(),
(op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (op1_def_info & (MAY_BE_DOUBLE|MAY_BE_GUARD)) && zend_may_overflow(opline, ssa_op, op_array, ssa),
zend_may_throw(opline, ssa_op, op_array, ssa))) {
goto jit_failure;
@@ -4631,9 +4668,12 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
CHECK_OP1_DATA_TRACE_TYPE();
op1_def_info = OP1_DEF_INFO();
if (!zend_jit_assign_dim_op(&ctx, opline,
- op1_info, op1_def_info, op1_addr, op2_info,
- op1_data_info, OP1_DATA_RANGE(), val_type,
- zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info))) {
+ op1_info, op1_def_info, op1_addr,
+ op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
+ (opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
+ op1_data_info, OP1_DATA_REG_ADDR(), OP1_DATA_RANGE(), val_type,
+ zend_jit_trace_may_throw(opline, ssa_op, op_array, ssa,
+ op1_info, op2_info, op1_data_info, val_type))) {
goto jit_failure;
}
goto done;
@@ -4653,7 +4693,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
@@ -4744,7 +4787,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
@@ -4824,7 +4870,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
@@ -4936,7 +4985,13 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
op1_data_info = OP1_DATA_INFO();
CHECK_OP1_DATA_TRACE_TYPE();
if (!zend_jit_assign_dim(&ctx, opline,
- op1_info, op1_addr, op2_info, op1_data_info, val_type,
+ op1_info, op1_addr,
+ op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
+ (opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
+ op1_data_info, OP1_DATA_REG_ADDR(),
+ (ctx.ra && (ssa_op+1)->op1_def >= 0) ? OP1_DATA_DEF_REG_ADDR() : 0,
+ (opline->result_type != IS_UNUSED) ? RES_REG_ADDR() : 0,
+ val_type,
zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info))) {
goto jit_failure;
}
@@ -5530,7 +5585,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
/* unconditional branch */
exit_addr = NULL;
} else if (opline->result_type == IS_TMP_VAR) {
- zend_jit_trace_stack *stack = JIT_G(current_frame)->stack;
uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->result.var));
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), IS_UNKNOWN, 1);
@@ -5717,7 +5771,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
}
if (!zend_jit_fetch_dim_read(&ctx, opline, ssa, ssa_op,
op1_info, op1_addr, avoid_refcounting,
- op2_info, res_info, RES_REG_ADDR(), val_type)) {
+ op2_info, OP2_REG_ADDR(), OP2_RANGE(),
+ res_info, RES_REG_ADDR(), val_type)) {
goto jit_failure;
}
if (ssa_op->op1_def >= 0 && op1_type != IS_UNKNOWN) {
@@ -5763,7 +5818,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
CHECK_OP2_TRACE_TYPE();
op1_def_info = OP1_DEF_INFO();
if (!zend_jit_fetch_dim(&ctx, opline,
- op1_info, op1_addr, op2_info, RES_REG_ADDR(), val_type)) {
+ op1_info, op1_addr,
+ op2_info, (opline->op2_type != IS_UNUSED) ? OP2_REG_ADDR() : 0,
+ (opline->op2_type != IS_UNUSED) ? OP2_RANGE() : NULL,
+ RES_REG_ADDR(), val_type)) {
goto jit_failure;
}
if (ssa_op->result_def > 0
@@ -5799,14 +5857,19 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
bool exit_if_true = 0;
const zend_op *exit_opline = zend_jit_trace_get_exit_opline(p + 1, opline + 1, &exit_if_true);
uint32_t exit_point;
+ int32_t old_ref = 0;
+ uint8_t old_flags = 0;
if (ra) {
+ if (opline->op2_type != IS_CONST) {
+ old_ref = STACK_REF(stack, EX_VAR_TO_NUM(opline->op2.var));
+ old_flags = STACK_FLAGS(stack, EX_VAR_TO_NUM(opline->op2.var));
+ }
zend_jit_trace_cleanup_stack(&ctx, stack, opline, ssa_op, ssa, ssa_opcodes);
}
if (ssa_op->op1_use >= 0
&& ssa->var_info[ssa_op->op1_use].avoid_refcounting) {
/* Temporary reset ZREG_ZVAL_TRY_ADDREF */
- zend_jit_trace_stack *stack = JIT_G(current_frame)->stack;
uint32_t old_info = STACK_INFO(stack, EX_VAR_TO_NUM(opline->op1.var));
SET_STACK_REG(stack, EX_VAR_TO_NUM(opline->op1.var), ZREG_NONE);
@@ -5819,6 +5882,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
if (!exit_addr) {
goto jit_failure;
}
+ if (old_ref) {
+ SET_STACK_REF_EX(stack, EX_VAR_TO_NUM(opline->op2.var), old_ref, old_flags);
+ }
smart_branch_opcode = exit_if_true ? ZEND_JMPNZ : ZEND_JMPZ;
} else {
smart_branch_opcode = 0;
@@ -5843,7 +5909,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
}
if (!zend_jit_isset_isempty_dim(&ctx, opline,
op1_info, op1_addr, avoid_refcounting,
- op2_info, val_type,
+ op2_info, OP2_REG_ADDR(), OP2_RANGE(), val_type,
zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, op2_info),
smart_branch_opcode, -1, -1,
exit_addr)) {
@@ -5874,7 +5940,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
@@ -5936,7 +6005,8 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
}
if (!zend_jit_fetch_obj(&ctx, opline, op_array, ssa, ssa_op,
op1_info, op1_addr, op1_indirect, ce, ce_is_instanceof,
- on_this, delayed_fetch_this, avoid_refcounting, op1_ce, val_type,
+ on_this, delayed_fetch_this, avoid_refcounting, op1_ce,
+ RES_REG_ADDR(), val_type,
zend_may_throw_ex(opline, ssa_op, op_array, ssa, op1_info, MAY_BE_STRING))) {
goto jit_failure;
}
@@ -6153,7 +6223,10 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
if (opline->op1_type == IS_UNUSED) {
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
ce = op_array->scope;
- ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ /* scope is NULL for closures. */
+ if (ce) {
+ ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
+ }
op1_addr = 0;
on_this = 1;
} else {
diff --git a/ext/opcache/jit/zend_jit_vm_helpers.c b/ext/opcache/jit/zend_jit_vm_helpers.c
index 7df2cd5b9029b..fd4d83aeca71a 100644
--- a/ext/opcache/jit/zend_jit_vm_helpers.c
+++ b/ext/opcache/jit/zend_jit_vm_helpers.c
@@ -692,6 +692,12 @@ zend_jit_trace_stop ZEND_FASTCALL zend_jit_trace_execute(zend_execute_data *ex,
}
}
op1_type |= flags;
+ } else if (opline->op1_type == IS_UNUSED && (op_array->fn_flags & ZEND_ACC_CLOSURE)) {
+ uint32_t op1_flags = ZEND_VM_OP1_FLAGS(zend_get_opcode_flags(opline->opcode));
+ if ((op1_flags & ZEND_VM_OP_MASK) == ZEND_VM_OP_THIS) {
+ op1_type = IS_OBJECT;
+ ce1 = Z_OBJCE(EX(This));
+ }
}
if (opline->op2_type & (IS_TMP_VAR|IS_VAR|IS_CV)
&& opline->opcode != ZEND_INSTANCEOF
diff --git a/ext/opcache/tests/bug67215.phpt b/ext/opcache/tests/bug67215.phpt
index 133efaf435b1d..e4c65470897c9 100644
--- a/ext/opcache/tests/bug67215.phpt
+++ b/ext/opcache/tests/bug67215.phpt
@@ -25,4 +25,4 @@ unlink($file_c);
unlink($file_p);
?>
--EXPECTF--
-Fatal error: Cannot declare class p, because the name is already in use in %sbug67215.p.php on line %d
+Fatal error: Cannot redeclare class p (previously declared in %sbug67215.p.php:%d) in %sbug67215.p.php on line %d
diff --git a/ext/opcache/tests/bug73583.phpt b/ext/opcache/tests/bug73583.phpt
index 9fb98faf80b90..419734188b37b 100644
--- a/ext/opcache/tests/bug73583.phpt
+++ b/ext/opcache/tests/bug73583.phpt
@@ -16,4 +16,4 @@ if (true) {
}
?>
--EXPECTF--
-Fatal error: Cannot redeclare A() (previously declared in %sbug73583.php:4) in %sbug73583.php on line 5
+Fatal error: Cannot redeclare function A() (previously declared in %sbug73583.php:4) in %sbug73583.php on line 5
diff --git a/ext/opcache/tests/gh8846.phpt b/ext/opcache/tests/gh8846.phpt
index dcfac1918de3b..98e94a401cb7a 100644
--- a/ext/opcache/tests/gh8846.phpt
+++ b/ext/opcache/tests/gh8846.phpt
@@ -33,7 +33,7 @@ echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/gh8846-index.php?s
--EXPECTF--
bool(true)
-Fatal error : Cannot declare class Foo, because the name is already in use in %sgh8846-2.inc on line %d
+Fatal error : Cannot redeclare class Foo (previously declared in %sgh8846-1.inc:2) in %sgh8846-2.inc on line %d
bool(true)
Ok
diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c
index 74161688ea443..a8eefad60c2fe 100644
--- a/ext/opcache/zend_accelerator_util_funcs.c
+++ b/ext/opcache/zend_accelerator_util_funcs.c
@@ -178,12 +178,12 @@ static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target,
CG(zend_lineno) = function1->op_array.opcodes[0].lineno;
if (function2->type == ZEND_USER_FUNCTION
&& function2->op_array.last > 0) {
- zend_error_noreturn(E_ERROR, "Cannot redeclare %s() (previously declared in %s:%d)",
+ zend_error_noreturn(E_ERROR, "Cannot redeclare function %s() (previously declared in %s:%d)",
ZSTR_VAL(function1->common.function_name),
ZSTR_VAL(function2->op_array.filename),
(int)function2->op_array.opcodes[0].lineno);
} else {
- zend_error_noreturn(E_ERROR, "Cannot redeclare %s()", ZSTR_VAL(function1->common.function_name));
+ zend_error_noreturn(E_ERROR, "Cannot redeclare function %s()", ZSTR_VAL(function1->common.function_name));
}
}
@@ -227,9 +227,7 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha
CG(in_compilation) = 1;
zend_set_compiled_filename(ce1->info.user.filename);
CG(zend_lineno) = ce1->info.user.line_start;
- zend_error_noreturn(E_ERROR,
- "Cannot declare %s %s, because the name is already in use",
- zend_get_object_type(ce1), ZSTR_VAL(ce1->name));
+ zend_class_redeclaration_error(E_ERROR, Z_PTR_P(t));
return;
}
continue;
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index 7513f71db3401..7cc22f9669196 100644
--- a/ext/opcache/zend_persist.c
+++ b/ext/opcache/zend_persist.c
@@ -806,12 +806,17 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop)
static void zend_persist_class_constant(zval *zv)
{
- zend_class_constant *c = zend_shared_alloc_get_xlat_entry(Z_PTR_P(zv));
+ zend_class_constant *orig_c = Z_PTR_P(zv);
+ zend_class_constant *c = zend_shared_alloc_get_xlat_entry(orig_c);
zend_class_entry *ce;
if (c) {
Z_PTR_P(zv) = c;
return;
+ } else if (((orig_c->ce->ce_flags & ZEND_ACC_IMMUTABLE) && !(Z_CONSTANT_FLAGS(orig_c->value) & CONST_OWNED))
+ || orig_c->ce->type == ZEND_INTERNAL_CLASS) {
+ /* Class constant comes from a different file in shm or internal class, keep existing pointer. */
+ return;
} else if (!ZCG(current_persistent_script)->corrupted
&& zend_accel_in_shm(Z_PTR_P(zv))) {
return;
diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c
index c4c5c5fa3ba5f..881f3954c04f3 100644
--- a/ext/opcache/zend_persist_calc.c
+++ b/ext/opcache/zend_persist_calc.c
@@ -26,6 +26,7 @@
#include "zend_shared_alloc.h"
#include "zend_operators.h"
#include "zend_attributes.h"
+#include "zend_constants.h"
#define ADD_DUP_SIZE(m,s) ZCG(current_persistent_script)->size += zend_shared_memdup_size((void*)m, s)
#define ADD_SIZE(m) ZCG(current_persistent_script)->size += ZEND_ALIGNED_SIZE(m)
@@ -386,6 +387,11 @@ static void zend_persist_class_constant_calc(zval *zv)
zend_class_constant *c = Z_PTR_P(zv);
if (!zend_shared_alloc_get_xlat_entry(c)) {
+ if (((c->ce->ce_flags & ZEND_ACC_IMMUTABLE) && !(Z_CONSTANT_FLAGS(c->value) & CONST_OWNED))
+ || c->ce->type == ZEND_INTERNAL_CLASS) {
+ /* Class constant comes from a different file in shm or internal class, keep existing pointer. */
+ return;
+ }
if (!ZCG(current_persistent_script)->corrupted
&& zend_accel_in_shm(Z_PTR_P(zv))) {
return;
diff --git a/ext/openssl/config0.m4 b/ext/openssl/config0.m4
index 1861a09ca5496..a2404c601cc78 100644
--- a/ext/openssl/config0.m4
+++ b/ext/openssl/config0.m4
@@ -10,6 +10,13 @@ PHP_ARG_WITH([system-ciphers],
[no],
[no])
+PHP_ARG_WITH([openssl-legacy-provider],
+ [whether to load legacy algorithm provider],
+ [AS_HELP_STRING([--with-openssl-legacy-provider],
+ [OPENSSL: Load legacy algorithm provider in addition to default provider])],
+ [no],
+ [no])
+
if test "$PHP_OPENSSL" != "no"; then
PHP_NEW_EXTENSION(openssl, openssl.c xp_ssl.c, $ext_shared)
PHP_SUBST(OPENSSL_SHARED_LIBADD)
@@ -25,4 +32,8 @@ if test "$PHP_OPENSSL" != "no"; then
if test "$PHP_SYSTEM_CIPHERS" != "no"; then
AC_DEFINE(USE_OPENSSL_SYSTEM_CIPHERS,1,[ Use system default cipher list instead of hardcoded value ])
fi
+
+ if test "$PHP_OPENSSL_LEGACY_PROVIDER" != "no"; then
+ AC_DEFINE(LOAD_OPENSSL_LEGACY_PROVIDER,1,[ Load legacy algorithm provider in addition to default provider ])
+ fi
fi
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index 949f5d76245e8..45db5065707a7 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -59,6 +59,7 @@
#if PHP_OPENSSL_API_VERSION >= 0x30000
#include
#include
+#include
#endif
#if defined(LIBRESSL_VERSION_NUMBER) && !defined(OPENSSL_NO_ENGINE)
@@ -1277,6 +1278,10 @@ PHP_MINIT_FUNCTION(openssl)
OpenSSL_add_all_algorithms();
SSL_load_error_strings();
#else
+#if PHP_OPENSSL_API_VERSION >= 0x30000 && defined(LOAD_OPENSSL_LEGACY_PROVIDER)
+ OSSL_PROVIDER_load(NULL, "legacy");
+ OSSL_PROVIDER_load(NULL, "default");
+#endif
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);
#endif
diff --git a/ext/openssl/tests/gh13860.phpt b/ext/openssl/tests/gh13860.phpt
index c7c0c40a15760..0b52e0e0583ab 100644
--- a/ext/openssl/tests/gh13860.phpt
+++ b/ext/openssl/tests/gh13860.phpt
@@ -9,7 +9,7 @@ if (!function_exists("proc_open")) die("skip no proc_open");
--FILE--
typedef cpuset_t cpu_set_t;
#endif
+ #define PCNTL_CPUSET(mask) &mask
+ #define PCNTL_CPUSET_SIZE(mask) sizeof(mask)
+ #define PCNTL_CPU_ISSET(i, mask) CPU_ISSET(i, &mask)
+ #define PCNTL_CPU_SET(i, mask) CPU_SET(i, &mask)
+ #define PCNTL_CPU_ZERO(mask) CPU_ZERO(&mask)
+ #define PCNTL_CPU_DESTROY(mask) ((void)0)
+#elif defined(__NetBSD__)
+#include
+#include
+typedef cpuset_t *cpu_set_t;
+ #define sched_getaffinity(p, c, m) syscall(SYS__sched_getaffinity, p, 0, c, m)
+ #define sched_setaffinity(p, c, m) syscall(SYS__sched_setaffinity, p, 0, c, m)
+ #define PCNTL_CPUSET(mask) mask
+ #define PCNTL_CPUSET_SIZE(mask) cpuset_size(mask)
+ #define PCNTL_CPU_ISSET(i, mask) cpuset_isset((cpuid_t)i, mask)
+ #define PCNTL_CPU_SET(i, mask) cpuset_set((cpuid_t)i, mask)
+ #define PCNTL_CPU_ZERO(mask) \
+ do { \
+ mask = cpuset_create(); \
+ if (UNEXPECTED(!mask)) { \
+ php_error_docref(NULL, E_WARNING, "cpuset_create: Insufficient memory"); \
+ RETURN_FALSE; \
+ } \
+ cpuset_zero(mask); \
+ } while(0)
+ #define PCNTL_CPU_DESTROY(mask) cpuset_destroy(mask)
+ #define HAVE_SCHED_SETAFFINITY 1
+#elif defined(HAVE_PSET_BIND)
+#include
+typedef psetid_t cpu_set_t;
+ #define sched_getaffinity(p, c, m) pset_bind(PS_QUERY, P_PID, (p <= 0 ? getpid() : p), &m)
+ #define sched_setaffinity(p, c, m) pset_bind(m, P_PID, (p <= 0 ? getpid() : p), NULL)
+ #define PCNTL_CPUSET(mask) mask
+ #define PCNTL_CPU_ISSET(i, mask) (pset_assign(PS_QUERY, (processorid_t)i, &query) == 0 && query == mask)
+ #define PCNTL_CPU_SET(i, mask) pset_assign(mask, (processorid_t)i, NULL)
+ #define PCNTL_CPU_ZERO(mask) \
+ psetid_t query; \
+ do { \
+ if (UNEXPECTED(pset_create(&mask) != 0)) { \
+ php_error_docref(NULL, E_WARNING, "pset_create: %s", strerror(errno)); \
+ RETURN_FALSE; \
+ } \
+ } while (0)
+ #define PCNTL_CPU_DESTROY(mask) \
+ do { \
+ if (UNEXPECTED(mask != PS_NONE && pset_destroy(mask) != 0)) { \
+ php_error_docref(NULL, E_WARNING, "pset_destroy: %s", strerror(errno)); \
+ } \
+ } while (0)
+ #define HAVE_SCHED_SETAFFINITY 1
+#endif
+
+#if defined(HAVE_GETCPUID)
+#include
+#define sched_getcpu getcpuid
+#define HAVE_SCHED_GETCPU 1
#endif
#if defined(HAVE_PTHREAD_SET_QOS_CLASS_SELF_NP)
@@ -1533,9 +1589,10 @@ PHP_FUNCTION(pcntl_getcpuaffinity)
// 0 == getpid in this context, we're just saving a syscall
pid = pid_is_null ? 0 : pid;
- CPU_ZERO(&mask);
+ PCNTL_CPU_ZERO(mask);
- if (sched_getaffinity(pid, sizeof(mask), &mask) != 0) {
+ if (sched_getaffinity(pid, PCNTL_CPUSET_SIZE(mask), PCNTL_CPUSET(mask)) != 0) {
+ PCNTL_CPU_DESTROY(mask);
PCNTL_G(last_error) = errno;
switch (errno) {
case ESRCH:
@@ -1558,10 +1615,11 @@ PHP_FUNCTION(pcntl_getcpuaffinity)
array_init(return_value);
for (zend_ulong i = 0; i < maxcpus; i ++) {
- if (CPU_ISSET(i, &mask)) {
+ if (PCNTL_CPU_ISSET(i, mask)) {
add_next_index_long(return_value, i);
}
}
+ PCNTL_CPU_DESTROY(mask);
}
PHP_FUNCTION(pcntl_setcpuaffinity)
@@ -1585,7 +1643,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
// 0 == getpid in this context, we're just saving a syscall
pid = pid_is_null ? 0 : pid;
zend_ulong maxcpus = (zend_ulong)sysconf(_SC_NPROCESSORS_CONF);
- CPU_ZERO(&mask);
+ PCNTL_CPU_ZERO(mask);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(hmask), ncpu) {
ZVAL_DEREF(ncpu);
@@ -1595,6 +1653,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
zend_ulong tmp;
if (!ZEND_HANDLE_NUMERIC(Z_STR_P(ncpu), tmp)) {
zend_argument_value_error(2, "cpu id invalid value (%s)", ZSTR_VAL(Z_STR_P(ncpu)));
+ PCNTL_CPU_DESTROY(mask);
RETURN_THROWS();
}
@@ -1603,6 +1662,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
zend_string *wcpu = zval_get_string_func(ncpu);
zend_argument_value_error(2, "cpu id invalid type (%s)", ZSTR_VAL(wcpu));
zend_string_release(wcpu);
+ PCNTL_CPU_DESTROY(mask);
RETURN_THROWS();
}
} else {
@@ -1614,12 +1674,13 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
RETURN_THROWS();
}
- if (!CPU_ISSET(cpu, &mask)) {
- CPU_SET(cpu, &mask);
+ if (!PCNTL_CPU_ISSET(cpu, mask)) {
+ PCNTL_CPU_SET(cpu, mask);
}
} ZEND_HASH_FOREACH_END();
- if (sched_setaffinity(pid, sizeof(mask), &mask) != 0) {
+ if (sched_setaffinity(pid, PCNTL_CPUSET_SIZE(mask), PCNTL_CPUSET(mask)) != 0) {
+ PCNTL_CPU_DESTROY(mask);
PCNTL_G(last_error) = errno;
switch (errno) {
case ESRCH:
@@ -1636,6 +1697,7 @@ PHP_FUNCTION(pcntl_setcpuaffinity)
}
RETURN_FALSE;
} else {
+ PCNTL_CPU_DESTROY(mask);
RETURN_TRUE;
}
}
diff --git a/ext/pcre/tests/preg_replace_callback_fatal_error_leak.phpt b/ext/pcre/tests/preg_replace_callback_fatal_error_leak.phpt
index 5ea3d4081e688..6bbcab49d99f5 100644
--- a/ext/pcre/tests/preg_replace_callback_fatal_error_leak.phpt
+++ b/ext/pcre/tests/preg_replace_callback_fatal_error_leak.phpt
@@ -15,4 +15,4 @@ preg_replace_callback('/a/', function($matches) {
?>
--EXPECTF--
-Fatal error: Cannot redeclare test() (previously declared in %s on line %d
+Fatal error: Cannot redeclare function test() (previously declared in %s:%d) in %s on line %d
diff --git a/ext/pdo_dblib/config.m4 b/ext/pdo_dblib/config.m4
index 694c44c7e7ab2..993ca3d6033af 100644
--- a/ext/pdo_dblib/config.m4
+++ b/ext/pdo_dblib/config.m4
@@ -45,7 +45,6 @@ if test "$PHP_PDO_DBLIB" != "no"; then
PDO_DBLIB_DEFS="-DPDO_DBLIB_FLAVOUR=\\\"freetds\\\""
PHP_NEW_EXTENSION(pdo_dblib, pdo_dblib.c dblib_driver.c dblib_stmt.c, $ext_shared,,-I$pdo_cv_inc_path $PDO_DBLIB_DEFS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
- AC_DEFINE(HAVE_PDO_DBLIB,1,[ ])
PHP_SUBST(PDO_DBLIB_SHARED_LIBADD)
PHP_ADD_EXTENSION_DEP(pdo_dblib, pdo)
diff --git a/ext/pdo_firebird/config.m4 b/ext/pdo_firebird/config.m4
index 594e7c220ecf1..d4a245d5a904b 100644
--- a/ext/pdo_firebird/config.m4
+++ b/ext/pdo_firebird/config.m4
@@ -60,7 +60,6 @@ if test "$PHP_PDO_FIREBIRD" != "no"; then
PHP_CHECK_PDO_INCLUDES
- AC_DEFINE(HAVE_PDO_FIREBIRD,1,[ ])
PHP_NEW_EXTENSION(pdo_firebird, pdo_firebird.c firebird_driver.c firebird_statement.c, $ext_shared,,-I$pdo_cv_inc_path)
PHP_SUBST(PDO_FIREBIRD_SHARED_LIBADD)
PHP_ADD_EXTENSION_DEP(pdo_firebird, pdo)
diff --git a/ext/pdo_pgsql/config.m4 b/ext/pdo_pgsql/config.m4
index 27482a59f0e21..a21b11106bab1 100644
--- a/ext/pdo_pgsql/config.m4
+++ b/ext/pdo_pgsql/config.m4
@@ -67,6 +67,7 @@ if test "$PHP_PDO_PGSQL" != "no"; then
LDFLAGS="-L$PGSQL_LIBDIR $LDFLAGS"
AC_CHECK_LIB(pq, PQlibVersion,, AC_MSG_ERROR([Unable to build the PDO PostgreSQL driver: at least libpq 9.1 is required]))
+ AC_CHECK_LIB(pq, PQresultMemorySize, AC_DEFINE(HAVE_PG_RESULT_MEMORY_SIZE,1,[PostgreSQL 12 or later]))
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c
index 8be27adb4b704..9dd9b868554fd 100644
--- a/ext/pdo_pgsql/pdo_pgsql.c
+++ b/ext/pdo_pgsql/pdo_pgsql.c
@@ -30,7 +30,7 @@
static zend_class_entry *PdoPgsql_ce;
-/* {{{ pdo_sqlite_deps */
+/* {{{ pdo_pgsql_deps */
static const zend_module_dep pdo_pgsql_deps[] = {
ZEND_MOD_REQUIRED("pdo")
ZEND_MOD_END
@@ -156,6 +156,9 @@ PHP_MINIT_FUNCTION(pdo_pgsql)
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS);
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
+#ifdef HAVE_PG_RESULT_MEMORY_SIZE
+ REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_RESULT_MEMORY_SIZE", (zend_long)PDO_PGSQL_ATTR_RESULT_MEMORY_SIZE);
+#endif
PdoPgsql_ce = register_class_PdoPgsql(pdo_dbh_ce);
PdoPgsql_ce->create_object = pdo_dbh_new;
diff --git a/ext/pdo_pgsql/pdo_pgsql.stub.php b/ext/pdo_pgsql/pdo_pgsql.stub.php
index eb7707147a192..eb0e3d6efd685 100644
--- a/ext/pdo_pgsql/pdo_pgsql.stub.php
+++ b/ext/pdo_pgsql/pdo_pgsql.stub.php
@@ -11,6 +11,11 @@ class PdoPgsql extends PDO
/** @cvalue PDO_PGSQL_ATTR_DISABLE_PREPARES */
public const int ATTR_DISABLE_PREPARES = UNKNOWN;
+#ifdef HAVE_PG_RESULT_MEMORY_SIZE
+ /** @cvalue PDO_PGSQL_ATTR_RESULT_MEMORY_SIZE */
+ public const int ATTR_RESULT_MEMORY_SIZE = UNKNOWN;
+#endif
+
/** @cvalue PGSQL_TRANSACTION_IDLE */
public const int TRANSACTION_IDLE = UNKNOWN;
diff --git a/ext/pdo_pgsql/pdo_pgsql_arginfo.h b/ext/pdo_pgsql/pdo_pgsql_arginfo.h
index 41f18486ad53c..04e1441b4b6d3 100644
--- a/ext/pdo_pgsql/pdo_pgsql_arginfo.h
+++ b/ext/pdo_pgsql/pdo_pgsql_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 2be4e9679d29fcbc3330b78f9e63c4c6e1284f19 */
+ * Stub hash: 57eb44ac4546230b33165b7226b05d006b651e46 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_PdoPgsql_escapeIdentifier, 0, 1, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0)
@@ -88,6 +88,14 @@ static zend_class_entry *register_class_PdoPgsql(zend_class_entry *class_entry_P
zend_string *const_ATTR_DISABLE_PREPARES_name = zend_string_init_interned("ATTR_DISABLE_PREPARES", sizeof("ATTR_DISABLE_PREPARES") - 1, 1);
zend_declare_typed_class_constant(class_entry, const_ATTR_DISABLE_PREPARES_name, &const_ATTR_DISABLE_PREPARES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
zend_string_release(const_ATTR_DISABLE_PREPARES_name);
+#if defined(HAVE_PG_RESULT_MEMORY_SIZE)
+
+ zval const_ATTR_RESULT_MEMORY_SIZE_value;
+ ZVAL_LONG(&const_ATTR_RESULT_MEMORY_SIZE_value, PDO_PGSQL_ATTR_RESULT_MEMORY_SIZE);
+ zend_string *const_ATTR_RESULT_MEMORY_SIZE_name = zend_string_init_interned("ATTR_RESULT_MEMORY_SIZE", sizeof("ATTR_RESULT_MEMORY_SIZE") - 1, 1);
+ zend_declare_typed_class_constant(class_entry, const_ATTR_RESULT_MEMORY_SIZE_name, &const_ATTR_RESULT_MEMORY_SIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+ zend_string_release(const_ATTR_RESULT_MEMORY_SIZE_name);
+#endif
zval const_TRANSACTION_IDLE_value;
ZVAL_LONG(&const_TRANSACTION_IDLE_value, PGSQL_TRANSACTION_IDLE);
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 15ecd8ce6f562..7843902a9a3aa 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -705,6 +705,32 @@ static int pdo_pgsql_stmt_cursor_closer(pdo_stmt_t *stmt)
return 1;
}
+static int pgsql_stmt_get_attr(pdo_stmt_t *stmt, zend_long attr, zval *val)
+{
+ pdo_pgsql_stmt *S = (pdo_pgsql_stmt*)stmt->driver_data;
+
+ switch (attr) {
+#ifdef HAVE_PG_RESULT_MEMORY_SIZE
+ case PDO_PGSQL_ATTR_RESULT_MEMORY_SIZE:
+ if(stmt->executed) {
+ ZVAL_LONG(val, PQresultMemorySize(S->result));
+ } else {
+ char *tmp;
+ spprintf(&tmp, 0, "statement '%s' has not been executed yet", S->stmt_name);
+
+ pdo_pgsql_error_stmt_msg(stmt, 0, "HY000", tmp);
+ efree(tmp);
+
+ ZVAL_NULL(val);
+ }
+ return 1;
+#endif
+
+ default:
+ return 0;
+ }
+}
+
const struct pdo_stmt_methods pgsql_stmt_methods = {
pgsql_stmt_dtor,
pgsql_stmt_execute,
@@ -713,7 +739,7 @@ const struct pdo_stmt_methods pgsql_stmt_methods = {
pgsql_stmt_get_col,
pgsql_stmt_param_hook,
NULL, /* set_attr */
- NULL, /* get_attr */
+ pgsql_stmt_get_attr,
pgsql_stmt_get_column_meta,
NULL, /* next_rowset */
pdo_pgsql_stmt_cursor_closer
diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h
index 303aff6006058..ad48de384a3da 100644
--- a/ext/pdo_pgsql/php_pdo_pgsql_int.h
+++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h
@@ -86,6 +86,7 @@ extern const struct pdo_stmt_methods pgsql_stmt_methods;
enum {
PDO_PGSQL_ATTR_DISABLE_PREPARES = PDO_ATTR_DRIVER_SPECIFIC,
+ PDO_PGSQL_ATTR_RESULT_MEMORY_SIZE,
};
struct pdo_pgsql_lob_self {
diff --git a/ext/pdo_pgsql/tests/result_memory_size.phpt b/ext/pdo_pgsql/tests/result_memory_size.phpt
new file mode 100644
index 0000000000000..ce73e4af32664
--- /dev/null
+++ b/ext/pdo_pgsql/tests/result_memory_size.phpt
@@ -0,0 +1,45 @@
+--TEST--
+PDO PgSQL PDOStatement::getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE)
+--EXTENSIONS--
+pdo_pgsql
+--SKIPIF--
+query('select 1');
+$result_1 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE);
+var_dump($result_1);
+
+echo 'Result set with many rows: ';
+$result = $db->query('select generate_series(1, 10000)');
+$result_2 = $result->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE);
+var_dump($result_2);
+
+echo 'Large result sets should require more memory than small ones: ';
+var_dump($result_2 > $result_1);
+
+echo 'Statements that are not executed should not consume memory: ';
+$statement = $db->prepare('select 1');
+$result_3 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE);
+var_dump($result_3);
+
+echo 'and should emit Error: ';
+printf("%s: %d: %s\n", ...$statement->errorInfo());
+
+--EXPECTF--
+Result set with only 1 row: int(%d)
+Result set with many rows: int(%d)
+Large result sets should require more memory than small ones: bool(true)
+Statements that are not executed should not consume memory: NULL
+and should emit Error: HY000: 0: statement '%s' has not been executed yet
diff --git a/ext/pdo_sqlite/config.m4 b/ext/pdo_sqlite/config.m4
index 2231ff5c6de88..0aeb9bad64d17 100644
--- a/ext/pdo_sqlite/config.m4
+++ b/ext/pdo_sqlite/config.m4
@@ -16,7 +16,6 @@ if test "$PHP_PDO_SQLITE" != "no"; then
PHP_EVAL_INCLINE($SQLITE_CFLAGS)
PHP_EVAL_LIBLINE($SQLITE_LIBS, PDO_SQLITE_SHARED_LIBADD)
- AC_DEFINE(HAVE_PDO_SQLITELIB, 1, [Define to 1 if you have the pdo_sqlite extension enabled.])
PHP_CHECK_LIBRARY(sqlite3, sqlite3_close_v2, [
AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c
index 55bfc621291ee..487fa6b4c35d6 100644
--- a/ext/pdo_sqlite/pdo_sqlite.c
+++ b/ext/pdo_sqlite/pdo_sqlite.c
@@ -335,25 +335,18 @@ PHP_METHOD(PdoSqlite, openBlob)
static int php_sqlite_collation_callback(void *context, int string1_len, const void *string1,
int string2_len, const void *string2)
{
- int ret;
+ int ret = 0;
zval zargs[2];
zval retval;
struct pdo_sqlite_collation *collation = (struct pdo_sqlite_collation*) context;
- collation->fc.fci.size = sizeof(collation->fc.fci);
- ZVAL_COPY_VALUE(&collation->fc.fci.function_name, &collation->callback);
- collation->fc.fci.object = NULL;
- collation->fc.fci.retval = &retval;
-
// Prepare the arguments.
ZVAL_STRINGL(&zargs[0], (char *) string1, string1_len);
ZVAL_STRINGL(&zargs[1], (char *) string2, string2_len);
- collation->fc.fci.param_count = 2;
- collation->fc.fci.params = zargs;
- if ((ret = zend_call_function(&collation->fc.fci, &collation->fc.fcc)) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "An error occurred while invoking the callback");
- } else if (!Z_ISUNDEF(retval)) {
+ zend_call_known_fcc(&collation->callback, &retval, /* argc */ 2, zargs, /* named_params */ NULL);
+
+ if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
zend_string *func_name = get_active_function_or_method_name();
zend_type_error("%s(): Return value of the callback must be of type int, %s returned",
@@ -361,7 +354,6 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v
zend_string_release(func_name);
return FAILURE;
}
- ret = 0;
if (Z_LVAL(retval) > 0) {
ret = 1;
} else if (Z_LVAL(retval) < 0) {
diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
index ae42a03e8a80c..054e1fbae262a 100644
--- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
@@ -26,28 +26,23 @@ typedef struct {
char *errmsg;
} pdo_sqlite_error_info;
-struct pdo_sqlite_fci {
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
-};
-
struct pdo_sqlite_func {
struct pdo_sqlite_func *next;
- zval func, step, fini;
int argc;
const char *funcname;
/* accelerated callback references */
- struct pdo_sqlite_fci afunc, astep, afini;
+ zend_fcall_info_cache func;
+ zend_fcall_info_cache step;
+ zend_fcall_info_cache fini;
};
struct pdo_sqlite_collation {
struct pdo_sqlite_collation *next;
const char *name;
- zval callback;
- struct pdo_sqlite_fci fc;
+ zend_fcall_info_cache callback;
};
typedef struct {
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index a5875f84f8301..99882388a59df 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -112,14 +112,14 @@ static void pdo_sqlite_cleanup_callbacks(pdo_sqlite_db_handle *H)
}
efree((char*)func->funcname);
- if (!Z_ISUNDEF(func->func)) {
- zval_ptr_dtor(&func->func);
+ if (ZEND_FCC_INITIALIZED(func->func)) {
+ zend_fcc_dtor(&func->func);
}
- if (!Z_ISUNDEF(func->step)) {
- zval_ptr_dtor(&func->step);
+ if (ZEND_FCC_INITIALIZED(func->step)) {
+ zend_fcc_dtor(&func->step);
}
- if (!Z_ISUNDEF(func->fini)) {
- zval_ptr_dtor(&func->fini);
+ if (ZEND_FCC_INITIALIZED(func->fini)) {
+ zend_fcc_dtor(&func->fini);
}
efree(func);
}
@@ -139,8 +139,8 @@ static void pdo_sqlite_cleanup_callbacks(pdo_sqlite_db_handle *H)
}
efree((char*)collation->name);
- if (!Z_ISUNDEF(collation->callback)) {
- zval_ptr_dtor(&collation->callback);
+ if (ZEND_FCC_INITIALIZED(collation->callback)) {
+ zend_fcc_dtor(&collation->callback);
}
efree(collation);
}
@@ -309,12 +309,12 @@ typedef struct {
zend_long row;
} aggregate_context;
-static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, int argc, sqlite3_value **argv, sqlite3_context *context, int is_agg)
+static int do_callback(zend_fcall_info_cache *fcc, int argc, sqlite3_value **argv, sqlite3_context *context, int is_agg)
{
zval *zargs = NULL;
zval retval;
int i;
- int ret;
+ int ret = SUCCESS;
int fake_argc;
aggregate_context *agg_context = NULL;
@@ -324,14 +324,7 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, int argc, sqlite3_va
fake_argc = argc + is_agg;
- fc->fci.size = sizeof(fc->fci);
- ZVAL_COPY_VALUE(&fc->fci.function_name, cb);
- fc->fci.object = NULL;
- fc->fci.retval = &retval;
- fc->fci.param_count = fake_argc;
-
/* build up the params */
-
if (fake_argc) {
zargs = safe_emalloc(fake_argc, sizeof(zval), 0);
}
@@ -372,11 +365,7 @@ static int do_callback(struct pdo_sqlite_fci *fc, zval *cb, int argc, sqlite3_va
}
}
- fc->fci.params = zargs;
-
- if ((ret = zend_call_function(&fc->fci, &fc->fcc)) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "An error occurred while invoking the callback");
- }
+ zend_call_known_fcc(fcc, &retval, fake_argc, zargs, /* named_params */ NULL);
/* clean up the params */
if (zargs) {
@@ -445,41 +434,33 @@ static void php_sqlite3_func_step_callback(sqlite3_context *context, int argc, s
{
struct pdo_sqlite_func *func = (struct pdo_sqlite_func*)sqlite3_user_data(context);
- do_callback(&func->astep, &func->step, argc, argv, context, 1);
+ do_callback(&func->step, argc, argv, context, 1);
}
static void php_sqlite3_func_final_callback(sqlite3_context *context)
{
struct pdo_sqlite_func *func = (struct pdo_sqlite_func*)sqlite3_user_data(context);
- do_callback(&func->afini, &func->fini, 0, NULL, context, 1);
+ do_callback(&func->fini, 0, NULL, context, 1);
}
static int php_sqlite3_collation_callback(void *context, int string1_len, const void *string1, int string2_len, const void *string2)
{
- int ret;
+ int ret = 0;
zval zargs[2];
zval retval;
struct pdo_sqlite_collation *collation = (struct pdo_sqlite_collation*) context;
- collation->fc.fci.size = sizeof(collation->fc.fci);
- ZVAL_COPY_VALUE(&collation->fc.fci.function_name, &collation->callback);
- collation->fc.fci.object = NULL;
- collation->fc.fci.retval = &retval;
-
/* Prepare the arguments. */
ZVAL_STRINGL(&zargs[0], (char *) string1, string1_len);
ZVAL_STRINGL(&zargs[1], (char *) string2, string2_len);
- collation->fc.fci.param_count = 2;
- collation->fc.fci.params = zargs;
- if ((ret = zend_call_function(&collation->fc.fci, &collation->fc.fcc)) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "An error occurred while invoking the callback");
- } else if (!Z_ISUNDEF(retval)) {
+ zend_call_known_fcc(&collation->callback, &retval, /* argc */ 2, zargs, /* named_params */ NULL);
+
+ if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long(&retval);
}
- ret = 0;
if (Z_LVAL(retval) > 0) {
ret = 1;
} else if (Z_LVAL(retval) < 0) {
@@ -498,14 +479,14 @@ static void php_sqlite3_func_callback(sqlite3_context *context, int argc, sqlite
{
struct pdo_sqlite_func *func = (struct pdo_sqlite_func*)sqlite3_user_data(context);
- do_callback(&func->afunc, &func->func, argc, argv, context, 0);
+ do_callback(&func->func, argc, argv, context, 0);
}
void pdo_sqlite_create_function_internal(INTERNAL_FUNCTION_PARAMETERS)
{
struct pdo_sqlite_func *func;
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fcc = empty_fcall_info_cache;
char *func_name;
size_t func_name_len;
zend_long argc = -1;
@@ -516,11 +497,11 @@ void pdo_sqlite_create_function_internal(INTERNAL_FUNCTION_PARAMETERS)
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_STRING(func_name, func_name_len)
- Z_PARAM_FUNC(fci, fcc)
+ Z_PARAM_FUNC_NO_TRAMPOLINE_FREE(fci, fcc)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(argc)
Z_PARAM_LONG(flags)
- ZEND_PARSE_PARAMETERS_END();
+ ZEND_PARSE_PARAMETERS_END_EX(goto error;);
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
@@ -533,7 +514,7 @@ void pdo_sqlite_create_function_internal(INTERNAL_FUNCTION_PARAMETERS)
if (ret == SQLITE_OK) {
func->funcname = estrdup(func_name);
- ZVAL_COPY(&func->func, &fci.function_name);
+ zend_fcc_dup(&func->func, &fcc);
func->argc = argc;
@@ -544,6 +525,9 @@ void pdo_sqlite_create_function_internal(INTERNAL_FUNCTION_PARAMETERS)
}
efree(func);
+
+error:
+ zend_release_fcall_info_cache(&fcc);
RETURN_FALSE;
}
@@ -558,8 +542,10 @@ PHP_METHOD(PDO_SQLite_Ext, sqliteCreateFunction)
void pdo_sqlite_create_aggregate_internal(INTERNAL_FUNCTION_PARAMETERS)
{
struct pdo_sqlite_func *func;
- zend_fcall_info step_fci, fini_fci;
- zend_fcall_info_cache step_fcc, fini_fcc;
+ zend_fcall_info step_fci = empty_fcall_info;
+ zend_fcall_info fini_fci = empty_fcall_info;
+ zend_fcall_info_cache step_fcc = empty_fcall_info_cache;
+ zend_fcall_info_cache fini_fcc = empty_fcall_info_cache;
char *func_name;
size_t func_name_len;
zend_long argc = -1;
@@ -569,11 +555,11 @@ void pdo_sqlite_create_aggregate_internal(INTERNAL_FUNCTION_PARAMETERS)
ZEND_PARSE_PARAMETERS_START(3, 4)
Z_PARAM_STRING(func_name, func_name_len)
- Z_PARAM_FUNC(step_fci, step_fcc)
- Z_PARAM_FUNC(fini_fci, fini_fcc)
+ Z_PARAM_FUNC_NO_TRAMPOLINE_FREE(step_fci, step_fcc)
+ Z_PARAM_FUNC_NO_TRAMPOLINE_FREE(fini_fci, fini_fcc)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(argc)
- ZEND_PARSE_PARAMETERS_END();
+ ZEND_PARSE_PARAMETERS_END_EX(goto error;);
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
@@ -587,9 +573,8 @@ void pdo_sqlite_create_aggregate_internal(INTERNAL_FUNCTION_PARAMETERS)
if (ret == SQLITE_OK) {
func->funcname = estrdup(func_name);
- ZVAL_COPY(&func->step, &step_fci.function_name);
-
- ZVAL_COPY(&func->fini, &fini_fci.function_name);
+ zend_fcc_dup(&func->step, &step_fcc);
+ zend_fcc_dup(&func->fini, &fini_fcc);
func->argc = argc;
@@ -600,6 +585,10 @@ void pdo_sqlite_create_aggregate_internal(INTERNAL_FUNCTION_PARAMETERS)
}
efree(func);
+
+error:
+ zend_release_fcall_info_cache(&step_fcc);
+ zend_release_fcall_info_cache(&fini_fcc);
RETURN_FALSE;
}
@@ -631,8 +620,8 @@ PHP_METHOD(PDO_SQLite_Ext, sqliteCreateAggregate)
void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqlite_create_collation_callback callback)
{
struct pdo_sqlite_collation *collation;
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fcc = empty_fcall_info_cache;
char *collation_name;
size_t collation_name_len;
pdo_dbh_t *dbh;
@@ -641,7 +630,7 @@ void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqli
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_STRING(collation_name, collation_name_len)
- Z_PARAM_FUNC(fci, fcc)
+ Z_PARAM_FUNC_NO_TRAMPOLINE_FREE(fci, fcc)
ZEND_PARSE_PARAMETERS_END();
dbh = Z_PDO_DBH_P(ZEND_THIS);
@@ -655,7 +644,7 @@ void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqli
if (ret == SQLITE_OK) {
collation->name = estrdup(collation_name);
- ZVAL_COPY(&collation->callback, &fci.function_name);
+ zend_fcc_dup(&collation->callback, &fcc);
collation->next = H->collations;
H->collations = collation;
@@ -663,6 +652,8 @@ void pdo_sqlite_create_collation_internal(INTERNAL_FUNCTION_PARAMETERS, pdo_sqli
RETURN_TRUE;
}
+ zend_release_fcall_info_cache(&fcc);
+
if (UNEXPECTED(EG(exception))) {
RETURN_THROWS();
}
@@ -706,15 +697,23 @@ static void pdo_sqlite_get_gc(pdo_dbh_t *dbh, zend_get_gc_buffer *gc_buffer)
struct pdo_sqlite_func *func = H->funcs;
while (func) {
- zend_get_gc_buffer_add_zval(gc_buffer, &func->func);
- zend_get_gc_buffer_add_zval(gc_buffer, &func->step);
- zend_get_gc_buffer_add_zval(gc_buffer, &func->fini);
+ if (ZEND_FCC_INITIALIZED(func->func)) {
+ zend_get_gc_buffer_add_fcc(gc_buffer, &func->func);
+ }
+ if (ZEND_FCC_INITIALIZED(func->step)) {
+ zend_get_gc_buffer_add_fcc(gc_buffer, &func->step);
+ }
+ if (ZEND_FCC_INITIALIZED(func->fini)) {
+ zend_get_gc_buffer_add_fcc(gc_buffer, &func->fini);
+ }
func = func->next;
}
struct pdo_sqlite_collation *collation = H->collations;
while (collation) {
- zend_get_gc_buffer_add_zval(gc_buffer, &collation->callback);
+ if (ZEND_FCC_INITIALIZED(collation->callback)) {
+ zend_get_gc_buffer_add_fcc(gc_buffer, &collation->callback);
+ }
collation = collation->next;
}
}
diff --git a/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createafunction_arg_error.phpt b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createafunction_arg_error.phpt
new file mode 100644
index 0000000000000..9cdd689f74aaa
--- /dev/null
+++ b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createafunction_arg_error.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Test PdoSqlite::createFunction() arguments error
+--EXTENSIONS--
+pdo_sqlite
+--FILE--
+createFunction(null, [new TrampolineTest(), 'strtoupper']);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createFunction('strtoupper', null);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper'], null);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper'], 1, null);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+echo 'done!';
+?>
+--EXPECT--
+PdoSqlite::createFunction(): Argument #1 ($function_name) must be of type string, null given
+PdoSqlite::createFunction(): Argument #2 ($callback) must be a valid callback, no array or string given
+PdoSqlite::createFunction(): Argument #3 ($num_args) must be of type int, null given
+PdoSqlite::createFunction(): Argument #4 ($flags) must be of type int, null given
+done!
diff --git a/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createaggregate_arg_error.phpt b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createaggregate_arg_error.phpt
new file mode 100644
index 0000000000000..8c0f3fedd9635
--- /dev/null
+++ b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createaggregate_arg_error.phpt
@@ -0,0 +1,63 @@
+--TEST--
+Test PdoSqlite::createAggregate() arguments error
+--EXTENSIONS--
+pdo_sqlite
+--FILE--
+createAggregate(null, [new TrampolineTest(), 'step'], null, 1);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createAggregate(null, null, [new TrampolineTest(), 'step'], 1);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createAggregate(null, [new TrampolineTest(), 'step'], [new TrampolineTest(), 'step'], 1);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createAggregate('S', null, [new TrampolineTest(), 'finalize'], 1);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createAggregate('S', [new TrampolineTest(), 'step'], null, 1);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createAggregate('S', [new TrampolineTest(), 'step'], [new TrampolineTest(), 'finalize'], null);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+echo 'done!';
+?>
+--EXPECT--
+PdoSqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
+PdoSqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
+PdoSqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
+PdoSqlite::createAggregate(): Argument #2 ($step) must be a valid callback, no array or string given
+PdoSqlite::createAggregate(): Argument #3 ($finalize) must be a valid callback, no array or string given
+PdoSqlite::createAggregate(): Argument #4 ($numArgs) must be of type int, null given
+done!
diff --git a/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createcollation_arg_error.phpt b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createcollation_arg_error.phpt
new file mode 100644
index 0000000000000..c5be063efc7aa
--- /dev/null
+++ b/ext/pdo_sqlite/tests/subclasses/pdo_sqlite_createcollation_arg_error.phpt
@@ -0,0 +1,35 @@
+--TEST--
+Test PdoSqlite::createCollation() arguments error
+--EXTENSIONS--
+pdo_sqlite
+--FILE--
+createCollation(null, [new TrampolineTest(), 'NAT']);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+try {
+ $db->createCollation('NAT', null);
+} catch (Throwable $e) {
+ echo $e->getMessage() . "\n";
+}
+
+echo 'done!';
+?>
+--EXPECT--
+PdoSqlite::createCollation(): Argument #1 ($name) must be of type string, null given
+PdoSqlite::createCollation(): Argument #2 ($callback) must be a valid callback, no array or string given
+done!
diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4
index 606047ac6769a..b4d1fec22d380 100644
--- a/ext/pgsql/config.m4
+++ b/ext/pgsql/config.m4
@@ -66,6 +66,7 @@ if test "$PHP_PGSQL" != "no"; then
AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
AC_CHECK_LIB(pq, lo_truncate64, AC_DEFINE(HAVE_PG_LO64,1,[PostgreSQL 9.3 or later]))
AC_CHECK_LIB(pq, PQsetErrorContextVisibility, AC_DEFINE(HAVE_PG_CONTEXT_VISIBILITY,1,[PostgreSQL 9.6 or later]))
+ AC_CHECK_LIB(pq, PQresultMemorySize, AC_DEFINE(HAVE_PG_RESULT_MEMORY_SIZE,1,[PostgreSQL 12 or later]))
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index fdf096d8107fb..1bb5214c255e0 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -543,9 +543,11 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
zend_long connect_type = 0;
PGresult *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &connstring, &connstring_len, &connect_type) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_STRING(connstring, connstring_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(connect_type)
+ ZEND_PARSE_PARAMETERS_END();
smart_str_appends(&str, "pgsql");
smart_str_appendl(&str, connstring, connstring_len);
@@ -728,9 +730,9 @@ PHP_FUNCTION(pg_connect_poll)
PGconn *pgsql;
int ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
pgsql_handle = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(pgsql_handle);
@@ -755,9 +757,10 @@ PHP_FUNCTION(pg_close)
zval *pgsql_link = NULL;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
if (!pgsql_link) {
link = FETCH_DEFAULT_LINK();
@@ -796,9 +799,10 @@ static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type
PGconn *pgsql;
char *result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
if (!pgsql_link) {
link = FETCH_DEFAULT_LINK();
@@ -912,9 +916,9 @@ PHP_FUNCTION(pg_parameter_status)
size_t len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "Os", &pgsql_link, pgsql_link_ce, ¶m, &len) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", ¶m, &len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(param, len)
+ ZEND_PARSE_PARAMETERS_END();
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
@@ -941,9 +945,10 @@ PHP_FUNCTION(pg_ping)
PGresult *res;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
if (pgsql_link == NULL) {
link = FETCH_DEFAULT_LINK();
@@ -984,15 +989,18 @@ PHP_FUNCTION(pg_query)
ExecStatusType status;
if (ZEND_NUM_ARGS() == 1) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &query, &query_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(query, query_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &pgsql_link, pgsql_link_ce, &query, &query_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(query, query_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
}
@@ -1078,15 +1086,20 @@ PHP_FUNCTION(pg_query_params)
pgsql_result_handle *pg_result;
if (ZEND_NUM_ARGS() == 2) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa", &query, &query_len, &pv_param_arr) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STRING(query, query_len)
+ Z_PARAM_ARRAY(pv_param_arr)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osa", &pgsql_link, pgsql_link_ce, &query, &query_len, &pv_param_arr) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(query, query_len)
+ Z_PARAM_ARRAY(pv_param_arr)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
}
@@ -1183,15 +1196,20 @@ PHP_FUNCTION(pg_prepare)
pgsql_result_handle *pg_result;
if (ZEND_NUM_ARGS() == 2) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STRING(stmtname, stmtname_len)
+ Z_PARAM_STRING(query, query_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oss", &pgsql_link, pgsql_link_ce, &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(stmtname, stmtname_len)
+ Z_PARAM_STRING(query, query_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
}
@@ -1264,15 +1282,20 @@ PHP_FUNCTION(pg_execute)
pgsql_result_handle *pg_result;
if (ZEND_NUM_ARGS() == 2) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sa", &stmtname, &stmtname_len, &pv_param_arr)==FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_STRING(stmtname, stmtname_len)
+ Z_PARAM_ARRAY(pv_param_arr)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osa", &pgsql_link, pgsql_link_ce, &stmtname, &stmtname_len, &pv_param_arr) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(stmtname, stmtname_len)
+ Z_PARAM_ARRAY(pv_param_arr)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
}
@@ -1365,9 +1388,9 @@ static void php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAMETERS, int entry_ty
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &result, pgsql_result_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -1414,9 +1437,11 @@ PHP_FUNCTION(pg_last_notice)
pgsql_link_handle *link;
zend_long option = PGSQL_NOTICE_LAST;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &pgsql_link, pgsql_link_ce, &option) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(option)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -1514,9 +1539,12 @@ PHP_FUNCTION(pg_field_table)
zend_long fnum = -1;
bool return_oid = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol|b", &result, pgsql_result_ce, &fnum, &return_oid) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 3)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_LONG(fnum)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(return_oid)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -1588,9 +1616,10 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ
pgsql_result_handle *pg_result;
Oid oid;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &result, pgsql_result_ce, &field) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_LONG(field)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -1664,9 +1693,10 @@ PHP_FUNCTION(pg_field_num)
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &result, pgsql_result_ce, &field, &field_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_STRING(field, field_len)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -1783,23 +1813,31 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_
pgsql_result_handle *pg_result;
int i, num_fields, pgsql_row;
zend_long row;
- bool row_is_null = 1;
+ bool row_is_null = true;
char *field_name;
HashTable *ctor_params = NULL;
zend_class_entry *ce = NULL;
if (into_object) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!Ch", &result, pgsql_result_ce, &row, &row_is_null, &ce, &ctor_params) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 4)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG_OR_NULL(row, row_is_null)
+ Z_PARAM_CLASS(ce)
+ Z_PARAM_ARRAY_HT(ctor_params)
+ ZEND_PARSE_PARAMETERS_END();
+
if (!ce) {
ce = zend_standard_class_def;
}
result_type = PGSQL_ASSOC;
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!l", &result, pgsql_result_ce, &row, &row_is_null, &result_type) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 3)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG_OR_NULL(row, row_is_null)
+ Z_PARAM_LONG(result_type)
+ ZEND_PARSE_PARAMETERS_END();
}
if (!row_is_null && row < 0) {
@@ -1927,9 +1965,11 @@ PHP_FUNCTION(pg_fetch_all)
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &result, pgsql_result_ce, &result_type) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(result_type)
+ ZEND_PARSE_PARAMETERS_END();
if (!(result_type & PGSQL_BOTH)) {
zend_argument_value_error(2, "must be one of PGSQL_ASSOC, PGSQL_NUM, or PGSQL_BOTH");
@@ -1955,9 +1995,11 @@ PHP_FUNCTION(pg_fetch_all_columns)
int pg_numrows, pg_row;
size_t num_fields;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &result, pgsql_result_ce, &colno) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(colno)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -1998,9 +2040,10 @@ PHP_FUNCTION(pg_result_seek)
zend_long row;
pgsql_result_handle *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &result, pgsql_result_ce, &row) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_LONG(row)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -2131,9 +2174,9 @@ PHP_FUNCTION(pg_free_result)
zval *result;
pgsql_result_handle *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &result, pgsql_result_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -2151,9 +2194,9 @@ PHP_FUNCTION(pg_last_oid)
pgsql_result_handle *pg_result;
Oid oid;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &result, pgsql_result_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -2179,9 +2222,13 @@ PHP_FUNCTION(pg_trace)
php_stream *stream;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|sO!l", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link, pgsql_link_ce, &trace_mode) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 4)
+ Z_PARAM_PATH(z_filename, z_filename_len)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STRING(mode, mode_len)
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pgsql_link, pgsql_link_ce)
+ Z_PARAM_LONG(trace_mode)
+ ZEND_PARSE_PARAMETERS_END();
if (!pgsql_link) {
link = FETCH_DEFAULT_LINK();
@@ -2229,9 +2276,10 @@ PHP_FUNCTION(pg_untrace)
PGconn *pgsql;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
if (pgsql_link == NULL) {
link = FETCH_DEFAULT_LINK();
@@ -2256,9 +2304,11 @@ PHP_FUNCTION(pg_lo_create)
Oid pgsql_oid, wanted_oid = InvalidOid;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &pgsql_link, &oid) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 2)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ZVAL(pgsql_link)
+ Z_PARAM_ZVAL(oid)
+ ZEND_PARSE_PARAMETERS_END();
/* Overloaded method uses default link if arg 1 is not an object, set oid pointer */
if ((ZEND_NUM_ARGS() == 1) && (Z_TYPE_P(pgsql_link) != IS_OBJECT)) {
@@ -2500,9 +2550,9 @@ PHP_FUNCTION(pg_lo_close)
zval *pgsql_lofp;
pgLofp *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_lofp, pgsql_lob_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_lofp, pgsql_lob_ce)
+ ZEND_PARSE_PARAMETERS_END();
pgsql = Z_PGSQL_LOB_P(pgsql_lofp);
CHECK_PGSQL_LOB(pgsql);
@@ -2529,9 +2579,11 @@ PHP_FUNCTION(pg_lo_read)
zend_string *buf;
pgLofp *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &pgsql_id, pgsql_lob_ce, &buffer_length) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_id, pgsql_lob_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(buffer_length)
+ ZEND_PARSE_PARAMETERS_END();
pgsql = Z_PGSQL_LOB_P(pgsql_id);
CHECK_PGSQL_LOB(pgsql);
@@ -2564,9 +2616,12 @@ PHP_FUNCTION(pg_lo_write)
size_t len;
pgLofp *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS|l!", &pgsql_id, pgsql_lob_ce, &str, &z_len, &z_len_is_null) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_id, pgsql_lob_ce)
+ Z_PARAM_STR(str)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG_OR_NULL(z_len, z_len_is_null)
+ ZEND_PARSE_PARAMETERS_END();
if (!z_len_is_null) {
if (z_len < 0) {
@@ -2603,9 +2658,9 @@ PHP_FUNCTION(pg_lo_read_all)
char buf[PGSQL_LO_READ_BUF_SIZE];
pgLofp *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_id, pgsql_lob_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_id, pgsql_lob_ce)
+ ZEND_PARSE_PARAMETERS_END();
pgsql = Z_PGSQL_LOB_P(pgsql_id);
CHECK_PGSQL_LOB(pgsql);
@@ -2705,7 +2760,7 @@ PHP_FUNCTION(pg_lo_export)
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
"OlP", &pgsql_link, pgsql_link_ce, &oid_long, &file_out) == SUCCESS) {
if (oid_long <= (zend_long)InvalidOid) {
- zend_value_error("Invalid OID value passed");
+ zend_argument_value_error(2, "Invalid OID value passed");
RETURN_THROWS();
}
oid = (Oid)oid_long;
@@ -2716,7 +2771,7 @@ PHP_FUNCTION(pg_lo_export)
"OSP", &pgsql_link, pgsql_link_ce, &oid_string, &file_out) == SUCCESS) {
if (!is_valid_oid_string(oid_string, &oid)) {
/* wrong integer format */
- zend_value_error("Invalid OID value passed");
+ zend_argument_value_error(2, "Invalid OID value passed");
RETURN_THROWS();
}
link = Z_PGSQL_LINK_P(pgsql_link);
@@ -2725,7 +2780,7 @@ PHP_FUNCTION(pg_lo_export)
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
"lP", &oid_long, &file_out) == SUCCESS) {
if (oid_long <= (zend_long)InvalidOid) {
- zend_value_error("Invalid OID value passed");
+ zend_argument_value_error(1, "Invalid OID value passed");
RETURN_THROWS();
}
oid = (Oid)oid_long;
@@ -2736,7 +2791,7 @@ PHP_FUNCTION(pg_lo_export)
"SP", &oid_string, &file_out) == SUCCESS) {
if (!is_valid_oid_string(oid_string, &oid)) {
/* wrong integer format */
- zend_value_error("Invalid OID value passed");
+ zend_argument_value_error(1, "Invalid OID value passed");
RETURN_THROWS();
}
link = FETCH_DEFAULT_LINK();
@@ -2767,9 +2822,13 @@ PHP_FUNCTION(pg_lo_seek)
zend_long result, offset = 0, whence = SEEK_CUR;
pgLofp *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol|l", &pgsql_id, pgsql_lob_ce, &offset, &whence) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_id, pgsql_lob_ce)
+ Z_PARAM_LONG(offset)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(whence)
+ ZEND_PARSE_PARAMETERS_END();
+
if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) {
zend_argument_value_error(3, "must be one of PGSQL_SEEK_SET, PGSQL_SEEK_CUR, or PGSQL_SEEK_END");
RETURN_THROWS();
@@ -2802,9 +2861,9 @@ PHP_FUNCTION(pg_lo_tell)
zend_long offset = 0;
pgLofp *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_id, pgsql_lob_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_id, pgsql_lob_ce)
+ ZEND_PARSE_PARAMETERS_END();
pgsql = Z_PGSQL_LOB_P(pgsql_id);
CHECK_PGSQL_LOB(pgsql);
@@ -2826,13 +2885,14 @@ PHP_FUNCTION(pg_lo_tell)
PHP_FUNCTION(pg_lo_truncate)
{
zval *pgsql_id = NULL;
- size_t size;
+ zend_long size;
pgLofp *pgsql;
int result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &pgsql_id, pgsql_lob_ce, &size) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_id, pgsql_lob_ce)
+ Z_PARAM_LONG(size)
+ ZEND_PARSE_PARAMETERS_END();
pgsql = Z_PGSQL_LOB_P(pgsql_id);
CHECK_PGSQL_LOB(pgsql);
@@ -2863,15 +2923,18 @@ PHP_FUNCTION(pg_set_error_verbosity)
pgsql_link_handle *link;
if (ZEND_NUM_ARGS() == 1) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &verbosity) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_LONG(verbosity)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &pgsql_link, pgsql_link_ce, &verbosity) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_LONG(verbosity)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
}
@@ -2894,9 +2957,11 @@ PHP_FUNCTION(pg_set_error_context_visibility)
PGconn *pgsql;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &pgsql_link, pgsql_link_ce, &visibility) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_LONG(visibility)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -2911,6 +2976,23 @@ PHP_FUNCTION(pg_set_error_context_visibility)
}
#endif
+#ifdef HAVE_PG_RESULT_MEMORY_SIZE
+PHP_FUNCTION(pg_result_memory_size)
+{
+ zval *result;
+ pgsql_result_handle *pg_result;
+
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ ZEND_PARSE_PARAMETERS_END();
+
+ pg_result = Z_PGSQL_RESULT_P(result);
+ CHECK_PGSQL_RESULT(pg_result);
+
+ RETURN_LONG(PQresultMemorySize(pg_result->result));
+}
+#endif
+
/* {{{ Set client encoding */
PHP_FUNCTION(pg_set_client_encoding)
{
@@ -2921,15 +3003,18 @@ PHP_FUNCTION(pg_set_client_encoding)
pgsql_link_handle *link;
if (ZEND_NUM_ARGS() == 1) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &encoding, &encoding_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(encoding, encoding_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &pgsql_link, pgsql_link_ce, &encoding, &encoding_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(encoding, encoding_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
}
@@ -2947,9 +3032,10 @@ PHP_FUNCTION(pg_client_encoding)
PGconn *pgsql;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
if (pgsql_link == NULL) {
link = FETCH_DEFAULT_LINK();
@@ -2975,9 +3061,10 @@ PHP_FUNCTION(pg_end_copy)
int result = 0;
pgsql_link_handle *link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|O!", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(0, 1)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_OBJECT_OF_CLASS_OR_NULL(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
if (pgsql_link == NULL) {
link = FETCH_DEFAULT_LINK();
@@ -3010,15 +3097,18 @@ PHP_FUNCTION(pg_put_line)
int result = 0;
if (ZEND_NUM_ARGS() == 1) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &query, &query_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(query, query_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
} else {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &pgsql_link, pgsql_link_ce, &query, &query_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(query, query_len)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
}
@@ -3050,11 +3140,13 @@ PHP_FUNCTION(pg_copy_to)
ExecStatusType status;
char *csv = (char *)NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|Ss", &pgsql_link, pgsql_link_ce,
- &table_name, &pg_delimiter, &pg_null_as, &pg_null_as_len) == FAILURE
- ) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 4)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table_name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR(pg_delimiter)
+ Z_PARAM_STRING(pg_null_as, pg_null_as_len)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3146,11 +3238,14 @@ PHP_FUNCTION(pg_copy_from)
PGresult *pgsql_result;
ExecStatusType status;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OPa|Ss", &pgsql_link, pgsql_link_ce,
- &table_name, &pg_rows, &pg_delimiter, &pg_null_as, &pg_null_as_len) == FAILURE
- ) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 5)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table_name)
+ Z_PARAM_ARRAY(pg_rows)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_STR(pg_delimiter)
+ Z_PARAM_STRING(pg_null_as, pg_null_as_len)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3194,18 +3289,20 @@ PHP_FUNCTION(pg_copy_from)
if (UNEXPECTED(!tmp)) {
return;
}
- query = (char *)emalloc(ZSTR_LEN(tmp) + 2);
- strlcpy(query, ZSTR_VAL(tmp), ZSTR_LEN(tmp) + 2);
- if (ZSTR_LEN(tmp) > 0 && *(query + ZSTR_LEN(tmp) - 1) != '\n') {
- strlcat(query, "\n", ZSTR_LEN(tmp) + 2);
+ zend_string *zquery = zend_string_alloc(ZSTR_LEN(tmp) + 1, false);
+ memcpy(ZSTR_VAL(zquery), ZSTR_VAL(tmp), ZSTR_LEN(tmp) + 1);
+ ZSTR_LEN(zquery) = ZSTR_LEN(tmp);
+ if (ZSTR_LEN(tmp) > 0 && ZSTR_VAL(zquery)[ZSTR_LEN(tmp)] != '\n') {
+ ZSTR_VAL(zquery)[ZSTR_LEN(tmp)] = '\n';
+ ZSTR_LEN(zquery) ++;
}
- if (PQputCopyData(pgsql, query, (int)strlen(query)) != 1) {
- efree(query);
+ if (PQputCopyData(pgsql, ZSTR_VAL(zquery), ZSTR_LEN(zquery)) != 1) {
+ zend_string_release_ex(zquery, false);
zend_string_release(tmp);
PHP_PQ_ERROR("copy failed: %s", pgsql);
RETURN_FALSE;
}
- efree(query);
+ zend_string_release_ex(zquery, false);
zend_string_release(tmp);
} ZEND_HASH_FOREACH_END();
@@ -3248,15 +3345,18 @@ PHP_FUNCTION(pg_escape_string)
switch (ZEND_NUM_ARGS()) {
case 1:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &from) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STR(from)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
break;
default:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS", &pgsql_link, pgsql_link_ce, &from) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STR(from)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
break;
@@ -3288,15 +3388,18 @@ PHP_FUNCTION(pg_escape_bytea)
switch (ZEND_NUM_ARGS()) {
case 1:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &from) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STR(from)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
break;
default:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS", &pgsql_link, pgsql_link_ce, &from) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STR(from)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
break;
@@ -3320,9 +3423,10 @@ PHP_FUNCTION(pg_unescape_bytea)
char *from, *tmp;
size_t to_len;
size_t from_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &from, &from_len) == FAILURE) {
- RETURN_THROWS();
- }
+
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STRING(from, from_len)
+ ZEND_PARSE_PARAMETERS_END();
tmp = (char *)PQunescapeBytea((unsigned char*)from, &to_len);
if (!tmp) {
@@ -3344,17 +3448,20 @@ static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_l
switch (ZEND_NUM_ARGS()) {
case 1:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &from) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_STR(from)
+ ZEND_PARSE_PARAMETERS_END();
+
link = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(link);
break;
default:
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS", &pgsql_link, pgsql_link_ce, &from) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STR(from)
+ ZEND_PARSE_PARAMETERS_END();
+
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
break;
@@ -3399,9 +3506,9 @@ PHP_FUNCTION(pg_result_error)
pgsql_result_handle *pg_result;
char *err = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &result, pgsql_result_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
pgsql_result = pg_result->result;
@@ -3423,9 +3530,10 @@ PHP_FUNCTION(pg_result_error_field)
pgsql_result_handle *pg_result;
char *field = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &result, pgsql_result_ce, &fieldcode) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_LONG(fieldcode)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
pgsql_result = pg_result->result;
@@ -3462,9 +3570,9 @@ PHP_FUNCTION(pg_connection_status)
pgsql_link_handle *link;
PGconn *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3482,9 +3590,9 @@ PHP_FUNCTION(pg_transaction_status)
pgsql_link_handle *link;
PGconn *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3502,9 +3610,9 @@ PHP_FUNCTION(pg_connection_reset)
pgsql_link_handle *link;
PGconn *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3548,9 +3656,9 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
PGconn *pgsql;
PGresult *pgsql_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3626,9 +3734,10 @@ PHP_FUNCTION(pg_send_query)
int is_non_blocking;
int ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os", &pgsql_link, pgsql_link_ce, &query, &len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(query, len)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3698,9 +3807,11 @@ PHP_FUNCTION(pg_send_query_params)
int is_non_blocking;
int ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osa", &pgsql_link, pgsql_link_ce, &query, &query_len, &pv_param_arr) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(query, query_len)
+ Z_PARAM_ARRAY(pv_param_arr)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3792,9 +3903,11 @@ PHP_FUNCTION(pg_send_prepare)
int is_non_blocking;
int ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oss", &pgsql_link, pgsql_link_ce, &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(stmtname, stmtname_len)
+ Z_PARAM_STRING(query, query_len)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3865,9 +3978,11 @@ PHP_FUNCTION(pg_send_execute)
int is_non_blocking;
int ret;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osa", &pgsql_link, pgsql_link_ce, &stmtname, &stmtname_len, &pv_param_arr) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_STRING(stmtname, stmtname_len)
+ Z_PARAM_ARRAY(pv_param_arr)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3958,9 +4073,9 @@ PHP_FUNCTION(pg_get_result)
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -3989,9 +4104,11 @@ PHP_FUNCTION(pg_result_status)
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &result, pgsql_result_ce, &result_type) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(result_type)
+ ZEND_PARSE_PARAMETERS_END();
pg_result = Z_PGSQL_RESULT_P(result);
CHECK_PGSQL_RESULT(pg_result);
@@ -4019,9 +4136,11 @@ PHP_FUNCTION(pg_get_notify)
PGconn *pgsql;
PGnotify *pgsql_notify;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l", &pgsql_link, pgsql_link_ce, &result_type) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 2)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(result_type)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -4066,9 +4185,9 @@ PHP_FUNCTION(pg_get_pid)
pgsql_link_handle *link;
PGconn *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -4147,9 +4266,9 @@ PHP_FUNCTION(pg_socket)
php_stream *stream;
PGconn *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -4173,9 +4292,9 @@ PHP_FUNCTION(pg_consume_input)
pgsql_link_handle *link;
PGconn *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -4194,9 +4313,9 @@ PHP_FUNCTION(pg_flush)
int ret;
int is_non_blocking;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &pgsql_link, pgsql_link_ce) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -4344,11 +4463,12 @@ PHP_FUNCTION(pg_meta_data)
bool extended=0;
PGconn *pgsql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|b",
- &pgsql_link, pgsql_link_ce, &table_name, &extended) == FAILURE
- ) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 3)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table_name)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_BOOL(extended)
+ ZEND_PARSE_PARAMETERS_END();
link = Z_PGSQL_LINK_P(pgsql_link);
CHECK_PGSQL_LINK(link);
@@ -5192,12 +5312,16 @@ PHP_FUNCTION(pg_convert)
zval *pgsql_link, *values;
pgsql_link_handle *link;
zend_string *table_name;
- zend_ulong option = 0;
+ zend_long option = 0;
PGconn *pg_link;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OPa|l", &pgsql_link, pgsql_link_ce, &table_name, &values, &option) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 4)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table_name)
+ Z_PARAM_ARRAY(values)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(option)
+ ZEND_PARSE_PARAMETERS_END();
if (ZSTR_LEN(table_name) == 0) {
zend_argument_value_error(2, "cannot be empty");
@@ -5398,17 +5522,19 @@ PHP_FUNCTION(pg_insert)
zval *pgsql_link, *values;
pgsql_link_handle *link;
zend_string *table;
- zend_ulong option = PGSQL_DML_EXEC, return_sql;
+ zend_long option = PGSQL_DML_EXEC, return_sql;
PGconn *pg_link;
PGresult *pg_result;
ExecStatusType status;
zend_string *sql = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OPa|l",
- &pgsql_link, pgsql_link_ce, &table, &values, &option) == FAILURE
- ) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 4)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table)
+ Z_PARAM_ARRAY(values)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(option)
+ ZEND_PARSE_PARAMETERS_END();
if (ZSTR_LEN(table) == 0) {
zend_argument_value_error(2, "cannot be empty");
@@ -5619,15 +5745,18 @@ PHP_FUNCTION(pg_update)
zval *pgsql_link, *values, *ids;
pgsql_link_handle *link;
zend_string *table;
- zend_ulong option = PGSQL_DML_EXEC;
+ zend_long option = PGSQL_DML_EXEC;
PGconn *pg_link;
zend_string *sql = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OPaa|l",
- &pgsql_link, pgsql_link_ce, &table, &values, &ids, &option) == FAILURE
- ) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(4, 5)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table)
+ Z_PARAM_ARRAY(values)
+ Z_PARAM_ARRAY(ids)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(option)
+ ZEND_PARSE_PARAMETERS_END();
if (ZSTR_LEN(table) == 0) {
zend_argument_value_error(2, "cannot be empty");
@@ -5716,15 +5845,17 @@ PHP_FUNCTION(pg_delete)
zval *pgsql_link, *ids;
pgsql_link_handle *link;
zend_string *table;
- zend_ulong option = PGSQL_DML_EXEC;
+ zend_long option = PGSQL_DML_EXEC;
PGconn *pg_link;
zend_string *sql;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OPa|l",
- &pgsql_link, pgsql_link_ce, &table, &ids, &option
- ) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(3, 4)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table)
+ Z_PARAM_ARRAY(ids)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_LONG(option)
+ ZEND_PARSE_PARAMETERS_END();
if (ZSTR_LEN(table) == 0) {
zend_argument_value_error(2, "cannot be empty");
@@ -5867,17 +5998,20 @@ PHP_FUNCTION(pg_select)
zval *ids = NULL;
pgsql_link_handle *link;
zend_string *table;
- zend_ulong option = PGSQL_DML_EXEC;
+ zend_long option = PGSQL_DML_EXEC;
zend_long result_type = PGSQL_ASSOC;
PGconn *pg_link;
zend_string *sql = NULL;
/* TODO Document result_type param on php.net (apparently it was added in PHP 7.1) */
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|all",
- &pgsql_link, pgsql_link_ce, &table, &ids, &option, &result_type
- ) == FAILURE) {
- RETURN_THROWS();
- }
+ ZEND_PARSE_PARAMETERS_START(2, 5)
+ Z_PARAM_OBJECT_OF_CLASS(pgsql_link, pgsql_link_ce)
+ Z_PARAM_PATH_STR(table)
+ Z_PARAM_OPTIONAL
+ Z_PARAM_ARRAY(ids)
+ Z_PARAM_LONG(option)
+ Z_PARAM_LONG(result_type)
+ ZEND_PARSE_PARAMETERS_END();
if (ZSTR_LEN(table) == 0) {
zend_argument_value_error(2, "cannot be empty");
diff --git a/ext/pgsql/pgsql.stub.php b/ext/pgsql/pgsql.stub.php
index b706959d89437..db4ee6b7bab58 100644
--- a/ext/pgsql/pgsql.stub.php
+++ b/ext/pgsql/pgsql.stub.php
@@ -943,6 +943,10 @@ function pg_select(PgSql\Connection $connection, string $table_name, array $cond
#ifdef HAVE_PG_CONTEXT_VISIBILITY
function pg_set_error_context_visibility(PgSql\Connection $connection, int $visibility): int {}
#endif
+
+#ifdef HAVE_PG_RESULT_MEMORY_SIZE
+ function pg_result_memory_size(PgSql\Result $result): int {}
+#endif
}
namespace PgSql {
diff --git a/ext/pgsql/pgsql_arginfo.h b/ext/pgsql/pgsql_arginfo.h
index 169f0eff67bbf..9d4c036baca4f 100644
--- a/ext/pgsql/pgsql_arginfo.h
+++ b/ext/pgsql/pgsql_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: a37b9df0c3b172d1160b1a7ef953cbd5a0a811b6 */
+ * Stub hash: e06a7116c1048975cbb348ffcdb36c9b65cee659 */
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_pg_connect, 0, 1, PgSql\\Connection, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, connection_string, IS_STRING, 0)
@@ -459,6 +459,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_set_error_context_visibility,
ZEND_END_ARG_INFO()
#endif
+#if defined(HAVE_PG_RESULT_MEMORY_SIZE)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pg_result_memory_size, 0, 1, IS_LONG, 0)
+ ZEND_ARG_OBJ_INFO(0, result, PgSql\\Result, 0)
+ZEND_END_ARG_INFO()
+#endif
+
ZEND_FUNCTION(pg_connect);
ZEND_FUNCTION(pg_pconnect);
ZEND_FUNCTION(pg_connect_poll);
@@ -553,6 +559,9 @@ ZEND_FUNCTION(pg_select);
#if defined(HAVE_PG_CONTEXT_VISIBILITY)
ZEND_FUNCTION(pg_set_error_context_visibility);
#endif
+#if defined(HAVE_PG_RESULT_MEMORY_SIZE)
+ZEND_FUNCTION(pg_result_memory_size);
+#endif
static const zend_function_entry ext_functions[] = {
ZEND_FE(pg_connect, arginfo_pg_connect)
@@ -671,6 +680,9 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(pg_select, arginfo_pg_select)
#if defined(HAVE_PG_CONTEXT_VISIBILITY)
ZEND_FE(pg_set_error_context_visibility, arginfo_pg_set_error_context_visibility)
+#endif
+#if defined(HAVE_PG_RESULT_MEMORY_SIZE)
+ ZEND_FE(pg_result_memory_size, arginfo_pg_result_memory_size)
#endif
ZEND_FE_END
};
diff --git a/ext/pgsql/tests/pg_result_memory_size.phpt b/ext/pgsql/tests/pg_result_memory_size.phpt
new file mode 100644
index 0000000000000..33369a7788151
--- /dev/null
+++ b/ext/pgsql/tests/pg_result_memory_size.phpt
@@ -0,0 +1,29 @@
+--TEST--
+pg_result_memory_size
+--EXTENSIONS--
+pgsql
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
+int(%d)
+int(%d)
+bool(true)
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 082112ba67b60..64ed39683d033 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -384,10 +384,8 @@ void destroy_phar_manifest_entry(zval *zv) /* {{{ */
}
/* }}} */
-int phar_entry_delref(phar_entry_data *idata) /* {{{ */
+void phar_entry_delref(phar_entry_data *idata) /* {{{ */
{
- int ret = 0;
-
if (idata->internal_file && !idata->internal_file->is_persistent) {
if (--idata->internal_file->fp_refcount < 0) {
idata->internal_file->fp_refcount = 0;
@@ -405,7 +403,6 @@ int phar_entry_delref(phar_entry_data *idata) /* {{{ */
phar_archive_delref(idata->phar);
efree(idata);
- return ret;
}
/* }}} */
@@ -1231,7 +1228,6 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, size_t fname_len, ch
}
snprintf(mydata->version, sizeof(mydata->version), "%u.%u.%u", manifest_ver >> 12, (manifest_ver >> 8) & 0xF, (manifest_ver >> 4) & 0xF);
- mydata->internal_file_start = halt_offset + manifest_len + 4;
mydata->halt_offset = halt_offset;
mydata->flags = manifest_flags;
endbuffer = strrchr(mydata->fname, '/');
@@ -1472,7 +1468,6 @@ int phar_create_or_parse_filename(char *fname, size_t fname_len, char *alias, si
mydata->fname_len = fname_len;
snprintf(mydata->version, sizeof(mydata->version), "%s", PHP_PHAR_API_VERSION);
mydata->is_temporary_alias = alias ? 0 : 1;
- mydata->internal_file_start = -1;
mydata->fp = NULL;
mydata->is_writeable = 1;
mydata->is_brandnew = 1;
@@ -3181,7 +3176,6 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
php_stream_close(oldfile);
}
- phar->internal_file_start = halt_offset + manifest_len + 4;
phar->halt_offset = halt_offset;
phar->is_brandnew = 0;
@@ -3367,9 +3361,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type)
}
/* }}} */
-typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int);
-typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
-
static void mime_type_dtor(zval *zv)
{
free(Z_PTR_P(zv));
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index 9f8a46b65ec60..0e19645300fee 100644
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -137,19 +137,19 @@ ZEND_BEGIN_MODULE_GLOBALS(phar)
phar_entry_fp *cached_fp;
HashTable phar_alias_map;
int phar_SERVER_mung_list;
- int readonly;
char* cache_list;
- int manifest_cached;
- int persist;
- int has_zlib;
- int has_bz2;
+ bool readonly;
+ bool manifest_cached;
+ bool persist;
+ bool has_zlib;
+ bool has_bz2;
bool readonly_orig;
bool require_hash_orig;
bool intercepted;
- int request_init;
- int require_hash;
- int request_done;
- int request_ends;
+ bool request_init;
+ bool require_hash;
+ bool request_done;
+ bool request_ends;
zif_handler orig_fopen;
zif_handler orig_file_get_contents;
zif_handler orig_is_file;
@@ -175,7 +175,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phar)
/* used for includes with . in them inside front controller */
char* cwd;
uint32_t cwd_len;
- int cwd_init;
+ bool cwd_init;
char *openssl_privatekey;
uint32_t openssl_privatekey_len;
/* phar_get_archive cache */
@@ -285,7 +285,6 @@ struct _phar_archive_data {
char *alias;
uint32_t alias_len;
char version[12];
- size_t internal_file_start;
size_t halt_offset;
HashTable manifest;
/* hash of virtual directories, as in path/to/file.txt has path/to and path as virtual directories */
@@ -459,9 +458,6 @@ typedef struct _phar_entry_data {
zend_off_t position;
/* for copies of the phar fp, defines where 0 is */
zend_off_t zero;
- uint32_t for_write:1;
- uint32_t is_zip:1;
- uint32_t is_tar:1;
phar_entry_info *internal_file;
} phar_entry_data;
@@ -527,7 +523,6 @@ void phar_request_initialize(void);
void phar_object_init(void);
void phar_destroy_phar_data(phar_archive_data *phar);
-int phar_open_entry_file(phar_archive_data *phar, phar_entry_info *entry, char **error);
int phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char **error, int process_zip);
int phar_open_from_filename(char *fname, size_t fname_len, char *alias, size_t alias_len, uint32_t options, phar_archive_data** pphar, char **error);
int phar_open_or_create_filename(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error);
@@ -558,8 +553,6 @@ void phar_metadata_tracker_copy(phar_metadata_tracker* dest, const phar_metadata
void phar_metadata_tracker_clone(phar_metadata_tracker* tracker);
void phar_metadata_tracker_try_ensure_has_serialized_data(phar_metadata_tracker* tracker, int persistent);
int phar_metadata_tracker_unserialize_or_copy(phar_metadata_tracker* tracker, zval *value, int persistent, HashTable *unserialize_options, const char* method_name);
-void phar_release_entry_metadata(phar_entry_info *entry);
-void phar_release_archive_metadata(phar_archive_data *phar);
void destroy_phar_manifest_entry(zval *zv);
int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links);
php_stream *phar_get_efp(phar_entry_info *entry, int follow_links);
@@ -591,7 +584,7 @@ extern HashTable cached_alias;
#endif
int phar_archive_delref(phar_archive_data *phar);
-int phar_entry_delref(phar_entry_data *idata);
+void phar_entry_delref(phar_entry_data *idata);
phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, size_t path_len, char **error, int security);
phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, size_t path_len, char dir, char **error, int security);
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index 2225d21d187a9..1da17b247b246 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -1500,7 +1500,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */
}
ZEND_FALLTHROUGH;
default:
- zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid value (must return a string)", ZSTR_VAL(ce->name));
+ zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Iterator %s returned an invalid value (must return a string, a stream, or an SplFileInfo object)", ZSTR_VAL(ce->name));
return ZEND_HASH_APPLY_STOP;
}
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index 752e15ed7176d..f7f997407e003 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -63,7 +63,7 @@ php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const
char *arch = NULL, *entry = NULL, *error;
size_t arch_len, entry_len;
- if (strlen(filename) < 7 || strncasecmp(filename, "phar://", 7)) {
+ if (strncasecmp(filename, "phar://", 7)) {
return NULL;
}
if (mode[0] == 'a') {
@@ -372,7 +372,7 @@ static int phar_stream_close(php_stream *stream, int close_handle) /* {{{ */
static ssize_t phar_stream_read(php_stream *stream, char *buf, size_t count) /* {{{ */
{
phar_entry_data *data = (phar_entry_data *)stream->abstract;
- size_t got;
+ ssize_t got;
phar_entry_info *entry;
if (data->internal_file->link) {
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index ce8ee0a369882..0b1de03c33f7b 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -19,7 +19,7 @@
#include "phar_internal.h"
-static uint32_t phar_tar_number(char *buf, size_t len) /* {{{ */
+static uint32_t phar_tar_number(const char *buf, size_t len) /* {{{ */
{
uint32_t num = 0;
size_t i = 0;
@@ -146,7 +146,6 @@ int phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t a
if (phar->is_brandnew) {
phar->is_tar = 1;
phar->is_zip = 0;
- phar->internal_file_start = 0;
return SUCCESS;
}
diff --git a/ext/phar/tests/phar_buildfromiterator5.phpt b/ext/phar/tests/phar_buildfromiterator5.phpt
index 1e937fe4e8dd2..2ddf1c282ecef 100644
--- a/ext/phar/tests/phar_buildfromiterator5.phpt
+++ b/ext/phar/tests/phar_buildfromiterator5.phpt
@@ -49,4 +49,4 @@ rewind
valid
current
%s(24) "UnexpectedValueException"
-Iterator myIterator returned an invalid value (must return a string)
+Iterator myIterator returned an invalid value (must return a string, a stream, or an SplFileInfo object)
diff --git a/ext/phar/tests/tar/phar_buildfromiterator5.phpt b/ext/phar/tests/tar/phar_buildfromiterator5.phpt
index 27d9dc323b415..6a81c1df65d26 100644
--- a/ext/phar/tests/tar/phar_buildfromiterator5.phpt
+++ b/ext/phar/tests/tar/phar_buildfromiterator5.phpt
@@ -49,4 +49,4 @@ rewind
valid
current
%s(24) "UnexpectedValueException"
-Iterator myIterator returned an invalid value (must return a string)
+Iterator myIterator returned an invalid value (must return a string, a stream, or an SplFileInfo object)
diff --git a/ext/phar/tests/zip/phar_buildfromiterator5.phpt b/ext/phar/tests/zip/phar_buildfromiterator5.phpt
index fb34f09095483..3c587dfc9c874 100644
--- a/ext/phar/tests/zip/phar_buildfromiterator5.phpt
+++ b/ext/phar/tests/zip/phar_buildfromiterator5.phpt
@@ -49,4 +49,4 @@ rewind
valid
current
%s(24) "UnexpectedValueException"
-Iterator myIterator returned an invalid value (must return a string)
+Iterator myIterator returned an invalid value (must return a string, a stream, or an SplFileInfo object)
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 04efe89d8fc41..aed95e635dd8c 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -438,10 +438,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname_len, ch
(*ret)->position = 0;
(*ret)->fp = NULL;
(*ret)->phar = phar;
- (*ret)->for_write = for_write;
(*ret)->internal_file = entry;
- (*ret)->is_zip = entry->is_zip;
- (*ret)->is_tar = entry->is_tar;
if (!phar->is_persistent) {
++(entry->phar->refcount);
@@ -486,10 +483,7 @@ int phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname_len, ch
*ret = (phar_entry_data *) emalloc(sizeof(phar_entry_data));
(*ret)->position = 0;
(*ret)->phar = phar;
- (*ret)->for_write = for_write;
(*ret)->internal_file = entry;
- (*ret)->is_zip = entry->is_zip;
- (*ret)->is_tar = entry->is_tar;
(*ret)->fp = phar_get_efp(entry, 1);
if (entry->link) {
phar_entry_info *link = phar_get_link_source(entry);
@@ -616,9 +610,6 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch
ret->phar = phar;
ret->fp = entry->fp;
ret->position = ret->zero = 0;
- ret->for_write = 1;
- ret->is_zip = entry->is_zip;
- ret->is_tar = entry->is_tar;
ret->internal_file = entry;
return ret;
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 03bddfcc154f5..f7d927b62a31b 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -150,7 +150,7 @@ static int phar_zip_process_extra(php_stream *fp, phar_entry_info *entry, uint16
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-static time_t phar_zip_d2u_time(char *cdtime, char *cddate) /* {{{ */
+static time_t phar_zip_d2u_time(const char *cdtime, const char *cddate) /* {{{ */
{
int dtime = PHAR_GET_16(cdtime), ddate = PHAR_GET_16(cddate);
struct tm *tm, tmbuf;
@@ -842,7 +842,6 @@ int phar_open_or_create_zip(char *fname, size_t fname_len, char *alias, size_t a
}
if (phar->is_brandnew) {
- phar->internal_file_start = 0;
phar->is_zip = 1;
phar->is_tar = 0;
return SUCCESS;
@@ -861,9 +860,9 @@ struct _phar_zip_pass {
php_stream *filefp;
php_stream *centralfp;
php_stream *old;
- int free_fp;
- int free_ufp;
char **error;
+ bool free_fp;
+ bool free_ufp;
};
/* perform final modification of zip contents for each file in the manifest before saving */
static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ */
diff --git a/ext/random/engine_combinedlcg.c b/ext/random/engine_combinedlcg.c
index 32f9af7d07297..a68f0e3d0cb07 100644
--- a/ext/random/engine_combinedlcg.c
+++ b/ext/random/engine_combinedlcg.c
@@ -101,7 +101,7 @@ static bool unserialize(void *state, HashTable *data)
return true;
}
-const php_random_algo php_random_algo_combinedlcg = {
+PHPAPI const php_random_algo php_random_algo_combinedlcg = {
sizeof(php_random_status_state_combinedlcg),
generate,
range,
diff --git a/ext/random/engine_mt19937.c b/ext/random/engine_mt19937.c
index 077d3681b0ad4..d44fd7c93b742 100644
--- a/ext/random/engine_mt19937.c
+++ b/ext/random/engine_mt19937.c
@@ -228,7 +228,7 @@ static bool unserialize(void *state, HashTable *data)
return true;
}
-const php_random_algo php_random_algo_mt19937 = {
+PHPAPI const php_random_algo php_random_algo_mt19937 = {
sizeof(php_random_status_state_mt19937),
generate,
range,
diff --git a/ext/random/engine_pcgoneseq128xslrr64.c b/ext/random/engine_pcgoneseq128xslrr64.c
index 4d288f5793eb7..9ff4f911920b2 100644
--- a/ext/random/engine_pcgoneseq128xslrr64.c
+++ b/ext/random/engine_pcgoneseq128xslrr64.c
@@ -105,7 +105,7 @@ static bool unserialize(void *state, HashTable *data)
return true;
}
-const php_random_algo php_random_algo_pcgoneseq128xslrr64 = {
+PHPAPI const php_random_algo php_random_algo_pcgoneseq128xslrr64 = {
sizeof(php_random_status_state_pcgoneseq128xslrr64),
generate,
range,
diff --git a/ext/random/engine_secure.c b/ext/random/engine_secure.c
index e55b984693992..0a03a03bdf136 100644
--- a/ext/random/engine_secure.c
+++ b/ext/random/engine_secure.c
@@ -46,7 +46,7 @@ static zend_long range(void *state, zend_long min, zend_long max)
return result;
}
-const php_random_algo php_random_algo_secure = {
+PHPAPI const php_random_algo php_random_algo_secure = {
0,
generate,
range,
diff --git a/ext/random/engine_user.c b/ext/random/engine_user.c
index d8c6909d1db8b..e343bc91d4894 100644
--- a/ext/random/engine_user.c
+++ b/ext/random/engine_user.c
@@ -73,7 +73,7 @@ static zend_long range(void *state, zend_long min, zend_long max)
}, min, max);
}
-const php_random_algo php_random_algo_user = {
+PHPAPI const php_random_algo php_random_algo_user = {
sizeof(php_random_status_state_user),
generate,
range,
diff --git a/ext/random/engine_xoshiro256starstar.c b/ext/random/engine_xoshiro256starstar.c
index fba834ebcd5e2..1a054362f0652 100644
--- a/ext/random/engine_xoshiro256starstar.c
+++ b/ext/random/engine_xoshiro256starstar.c
@@ -154,7 +154,7 @@ static bool unserialize(void *state, HashTable *data)
return true;
}
-const php_random_algo php_random_algo_xoshiro256starstar = {
+PHPAPI const php_random_algo php_random_algo_xoshiro256starstar = {
sizeof(php_random_status_state_xoshiro256starstar),
generate,
range,
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
index 7c92687088f85..8130c4b6533d8 100644
--- a/ext/readline/readline_cli.c
+++ b/ext/readline/readline_cli.c
@@ -343,6 +343,7 @@ static int cli_is_valid_code(char *code, size_t len, zend_string **prompt) /* {{
case ' ':
case '\t':
case '\'':
+ case '"':
break;
case '\r':
case '\n':
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index d2be2f869ae20..990d1c83c9550 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -3609,7 +3609,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getShortName)
GET_REFLECTION_OBJECT_PTR(fptr);
zend_string *name = fptr->common.function_name;
- if (!(fptr->common.fn_flags & ZEND_ACC_CLOSURE)) {
+ if ((fptr->common.fn_flags & (ZEND_ACC_CLOSURE | ZEND_ACC_FAKE_CLOSURE)) != ZEND_ACC_CLOSURE) {
const char *backslash = zend_memrchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name));
if (backslash) {
RETURN_STRINGL(backslash + 1, ZSTR_LEN(name) - (backslash - ZSTR_VAL(name) + 1));
@@ -4067,6 +4067,20 @@ ZEND_METHOD(ReflectionClassConstant, isEnumCase)
RETURN_BOOL(ZEND_CLASS_CONST_FLAGS(ref) & ZEND_CLASS_CONST_IS_CASE);
}
+ZEND_METHOD(ReflectionClassConstant, isDeprecated)
+{
+ reflection_object *intern;
+ zend_constant *ref;
+
+ if (zend_parse_parameters_none() == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ GET_REFLECTION_OBJECT_PTR(ref);
+
+ RETURN_BOOL(ZEND_CLASS_CONST_FLAGS(ref) & ZEND_ACC_DEPRECATED);
+}
+
/* {{{ reflection_class_object_ctor */
static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_object)
{
@@ -6713,92 +6727,6 @@ ZEND_METHOD(ReflectionAttribute, getArguments)
}
/* }}} */
-static int 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);
- }
-}
-/* }}} */
-
/* {{{ Returns the attribute as an object */
ZEND_METHOD(ReflectionAttribute, newInstance)
{
@@ -6807,10 +6735,6 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
zend_attribute *marker;
zend_class_entry *ce;
- zval obj;
-
- zval *args = NULL;
- HashTable *named_params = NULL;
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
@@ -6829,16 +6753,9 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
}
if (ce->type == ZEND_USER_CLASS) {
- uint32_t flags = ZEND_ATTRIBUTE_TARGET_ALL;
-
- if (marker->argc > 0) {
- zval tmp;
-
- if (FAILURE == zend_get_attribute_value(&tmp, marker, 0, ce)) {
- RETURN_THROWS();
- }
-
- flags = (uint32_t) Z_LVAL(tmp);
+ uint32_t flags = zend_attribute_attribute_get_flags(marker, ce);
+ if (EG(exception)) {
+ RETURN_THROWS();
}
if (!(attr->target & flags)) {
@@ -6863,45 +6780,12 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
}
}
- if (SUCCESS != object_init_ex(&obj, ce)) {
- RETURN_THROWS();
- }
-
- uint32_t argc = 0;
- if (attr->data->argc) {
- args = emalloc(attr->data->argc * sizeof(zval));
-
- for (uint32_t i = 0; i < attr->data->argc; i++) {
- zval val;
- if (FAILURE == zend_get_attribute_value(&val, attr->data, i, attr->scope)) {
- attribute_ctor_cleanup(&obj, args, argc, named_params);
- RETURN_THROWS();
- }
- if (attr->data->args[i].name) {
- if (!named_params) {
- named_params = zend_new_array(0);
- }
- zend_hash_add_new(named_params, attr->data->args[i].name, &val);
- } else {
- ZVAL_COPY_VALUE(&args[i], &val);
- argc++;
- }
- }
- }
+ zval obj;
- if (ce->constructor) {
- if (FAILURE == call_attribute_constructor(attr->data, ce, Z_OBJ(obj), args, argc, named_params, attr->filename)) {
- attribute_ctor_cleanup(&obj, args, argc, named_params);
- RETURN_THROWS();
- }
- } 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(ce->name));
+ if (SUCCESS != zend_get_attribute_object(&obj, ce, attr->data, attr->scope, attr->filename)) {
RETURN_THROWS();
}
- attribute_ctor_cleanup(NULL, args, argc, named_params);
-
RETURN_COPY_VALUE(&obj);
}
diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php
index c9ce811bfeeb3..d3eee1ee3cf5c 100644
--- a/ext/reflection/php_reflection.stub.php
+++ b/ext/reflection/php_reflection.stub.php
@@ -554,6 +554,8 @@ public function getAttributes(?string $name = null, int $flags = 0): array {}
public function isEnumCase(): bool {}
+ public function isDeprecated(): bool {}
+
public function hasType(): bool {}
public function getType(): ?ReflectionType {}
diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h
index e06469db82b3a..a1cfc2f69a9c0 100644
--- a/ext/reflection/php_reflection_arginfo.h
+++ b/ext/reflection/php_reflection_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: c81572d388f2539d861df717b3cc8c0491fe72a0 */
+ * Stub hash: f3fd5084866ba31bfa4e7e2bf78d95107cfe4b61 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
@@ -418,6 +418,8 @@ ZEND_END_ARG_INFO()
#define arginfo_class_ReflectionClassConstant_isEnumCase arginfo_class_ReflectionFunctionAbstract_hasTentativeReturnType
+#define arginfo_class_ReflectionClassConstant_isDeprecated arginfo_class_ReflectionFunctionAbstract_hasTentativeReturnType
+
#define arginfo_class_ReflectionClassConstant_hasType arginfo_class_ReflectionFunctionAbstract_hasTentativeReturnType
#define arginfo_class_ReflectionClassConstant_getType arginfo_class_ReflectionFunctionAbstract_getTentativeReturnType
@@ -783,6 +785,7 @@ ZEND_METHOD(ReflectionClassConstant, getDeclaringClass);
ZEND_METHOD(ReflectionClassConstant, getDocComment);
ZEND_METHOD(ReflectionClassConstant, getAttributes);
ZEND_METHOD(ReflectionClassConstant, isEnumCase);
+ZEND_METHOD(ReflectionClassConstant, isDeprecated);
ZEND_METHOD(ReflectionClassConstant, hasType);
ZEND_METHOD(ReflectionClassConstant, getType);
ZEND_METHOD(ReflectionParameter, __construct);
@@ -1068,6 +1071,7 @@ static const zend_function_entry class_ReflectionClassConstant_methods[] = {
ZEND_ME(ReflectionClassConstant, getDocComment, arginfo_class_ReflectionClassConstant_getDocComment, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionClassConstant, getAttributes, arginfo_class_ReflectionClassConstant_getAttributes, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionClassConstant, isEnumCase, arginfo_class_ReflectionClassConstant_isEnumCase, ZEND_ACC_PUBLIC)
+ ZEND_ME(ReflectionClassConstant, isDeprecated, arginfo_class_ReflectionClassConstant_isDeprecated, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionClassConstant, hasType, arginfo_class_ReflectionClassConstant_hasType, ZEND_ACC_PUBLIC)
ZEND_ME(ReflectionClassConstant, getType, arginfo_class_ReflectionClassConstant_getType, ZEND_ACC_PUBLIC)
ZEND_FE_END
diff --git a/ext/reflection/tests/ReflectionAttribute_newInstance_exception.phpt b/ext/reflection/tests/ReflectionAttribute_newInstance_exception.phpt
new file mode 100644
index 0000000000000..a6f516bc414d0
--- /dev/null
+++ b/ext/reflection/tests/ReflectionAttribute_newInstance_exception.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Exception handling in ReflectionAttribute::newInstance()
+--FILE--
+getAttributes()[0];
+
+var_dump($attribute->newInstance());
+?>
+--EXPECTF--
+Fatal error: Uncaught Exception: Test in %s:6
+Stack trace:
+#0 %sReflectionAttribute_newInstance_exception.php(11): A->__construct()
+#1 %sReflectionAttribute_newInstance_exception.php(18): ReflectionAttribute->newInstance()
+#2 {main}
+ thrown in %sReflectionAttribute_newInstance_exception.php on line 6
diff --git a/ext/session/mod_files.bat b/ext/session/mod_files.bat
index 83f85eb66bc7c..f3c8695927efb 100644
--- a/ext/session/mod_files.bat
+++ b/ext/session/mod_files.bat
@@ -6,11 +6,11 @@ IF _%1_==_AUTO_ (
)
IF _%2_==__ (
- ECHO Usage %0 ^ ^ ^[^hash_bits^]
+ ECHO Usage %0 ^ ^ ^[^bits^]
ECHO.
ECHO Where ^ is the session directory
ECHO ^ is the number of levels defined in session.save_path
- ECHO ^[hash_bits^] is the number of bits defined in session.hash_bits_per_character
+ ECHO ^[bits^] is the number of bits defined in session.sid_bits_per_character
EXIT /B 1
)
@@ -53,5 +53,5 @@ ECHO ERROR: Invalid depth : %2
EXIT /B 0
:BitsError
-ECHO ERROR: Invalid hash_bits : %3
+ECHO ERROR: Invalid bits : %3
EXIT /B 0
diff --git a/ext/session/tests/031.phpt b/ext/session/tests/031.phpt
deleted file mode 100644
index 63a90a6da5ead..0000000000000
--- a/ext/session/tests/031.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-setting hash_function to sha512 and hash_bits_per_character > 4 should not crash
---EXTENSIONS--
-session
---SKIPIF--
-
---INI--
-session.use_cookies=0
-session.cache_limiter=
-session.serialize_handler=php
-session.save_handler=files
-session.hash_function=sha512
-session.hash_bits_per_character=5
---FILE--
-
---EXPECT--
-I live
diff --git a/ext/session/tests/session_basic2.phpt b/ext/session/tests/session_basic2.phpt
index 6bd94969e7d9a..165ca21af5228 100644
--- a/ext/session/tests/session_basic2.phpt
+++ b/ext/session/tests/session_basic2.phpt
@@ -3,7 +3,6 @@ Test basic function : variation2
--INI--
session.use_strict_mode=1
session.save_handler=files
-session.hash_bits_per_character=4
session.gc_probability=1
session.gc_divisor=1000
session.gc_maxlifetime=300
diff --git a/ext/session/tests/session_basic3.phpt b/ext/session/tests/session_basic3.phpt
index 61173feeefc1c..661f48546d123 100644
--- a/ext/session/tests/session_basic3.phpt
+++ b/ext/session/tests/session_basic3.phpt
@@ -5,8 +5,6 @@ session.use_strict_mode=0
session.use_only_cookies=0
session.use_trans_sid=1
session.save_handler=files
-session.hash_bits_per_character=4
-session.hash_function=0
session.gc_probability=1
session.gc_divisor=1000
session.gc_maxlifetime=300
diff --git a/ext/session/tests/session_basic4.phpt b/ext/session/tests/session_basic4.phpt
index 996fcac3647f5..93b04604d24d4 100644
--- a/ext/session/tests/session_basic4.phpt
+++ b/ext/session/tests/session_basic4.phpt
@@ -5,8 +5,6 @@ session.use_strict_mode=0
session.use_only_cookies=0
session.use_trans_sid=1
session.save_handler=files
-session.hash_bits_per_character=4
-session.hash_function=0
session.gc_probability=1
session.gc_divisor=1000
session.gc_maxlifetime=300
diff --git a/ext/session/tests/session_basic5.phpt b/ext/session/tests/session_basic5.phpt
index f9399428a9b5a..4f1d39ee02701 100644
--- a/ext/session/tests/session_basic5.phpt
+++ b/ext/session/tests/session_basic5.phpt
@@ -5,8 +5,6 @@ session.use_strict_mode=0
session.use_only_cookies=0
session.use_trans_sid=1
session.save_handler=files
-session.hash_bits_per_character=4
-session.hash_function=0
session.gc_probability=1
session.gc_divisor=1000
session.gc_maxlifetime=300
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index a66b31a499b99..3bc7964541e9f 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1342,9 +1342,6 @@ PHP_METHOD(SimpleXMLElement, asXML)
{
php_sxe_object *sxe;
xmlNodePtr node;
- xmlOutputBufferPtr outbuf;
- xmlChar *strval;
- int strval_len;
char *filename = NULL;
size_t filename_len;
@@ -1360,74 +1357,56 @@ PHP_METHOD(SimpleXMLElement, asXML)
RETURN_FALSE;
}
+ xmlDocPtr doc = sxe->document->ptr;
+
if (filename) {
+ zend_long bytes;
if (node->parent && (XML_DOCUMENT_NODE == node->parent->type)) {
- int bytes;
- bytes = xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr);
- if (bytes == -1) {
- RETURN_FALSE;
- } else {
- RETURN_TRUE;
- }
+ bytes = sxe->document->handlers->dump_doc_to_file(filename, doc, false, (const char *) doc->encoding);
+ } else {
+ bytes = sxe->document->handlers->dump_node_to_file(filename, doc, node, false, NULL);
+ }
+ if (bytes == -1) {
+ RETURN_FALSE;
} else {
- outbuf = xmlOutputBufferCreateFilename(filename, NULL, 0);
-
- if (outbuf == NULL) {
- RETURN_FALSE;
- }
-
- xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, NULL);
- xmlOutputBufferClose(outbuf);
RETURN_TRUE;
}
}
+ zend_string *result;
if (node->parent && (XML_DOCUMENT_NODE == node->parent->type)) {
- xmlDocDumpMemoryEnc((xmlDocPtr) sxe->document->ptr, &strval, &strval_len, (const char *) ((xmlDocPtr) sxe->document->ptr)->encoding);
- if (!strval) {
- RETVAL_FALSE;
- } else {
- RETVAL_STRINGL((char *)strval, strval_len);
- }
- xmlFree(strval);
+ result = sxe->document->handlers->dump_doc_to_str(doc, 0, (const char *) doc->encoding);
} else {
- char *return_content;
- size_t return_len;
- /* Should we be passing encoding information instead of NULL? */
- outbuf = xmlAllocOutputBuffer(NULL);
-
- if (outbuf == NULL) {
- RETURN_FALSE;
- }
+ result = sxe->document->handlers->dump_node_to_str(doc, node, false, (const char *) doc->encoding);
+ }
- xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, (const char *) ((xmlDocPtr) sxe->document->ptr)->encoding);
- xmlOutputBufferFlush(outbuf);
- return_content = (char *)xmlOutputBufferGetContent(outbuf);
- return_len = xmlOutputBufferGetSize(outbuf);
- if (!return_content) {
- RETVAL_FALSE;
- } else {
- RETVAL_STRINGL(return_content, return_len);
- }
- xmlOutputBufferClose(outbuf);
+ if (!result) {
+ RETURN_FALSE;
+ } else {
+ RETURN_NEW_STR(result);
}
}
/* }}} */
#define SXE_NS_PREFIX(ns) (ns->prefix ? (char*)ns->prefix : "")
-static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns) /* {{{ */
+static inline void sxe_add_namespace_name_raw(zval *return_value, const char *prefix, const char *href)
{
- char *prefix = SXE_NS_PREFIX(ns);
zend_string *key = zend_string_init(prefix, strlen(prefix), 0);
zval zv;
if (!zend_hash_exists(Z_ARRVAL_P(return_value), key)) {
- ZVAL_STRING(&zv, (char*)ns->href);
+ ZVAL_STRING(&zv, href);
zend_hash_add_new(Z_ARRVAL_P(return_value), key, &zv);
}
zend_string_release_ex(key, 0);
}
+
+static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns) /* {{{ */
+{
+ char *prefix = SXE_NS_PREFIX(ns);
+ sxe_add_namespace_name_raw(return_value, prefix, (const char *) ns->href);
+}
/* }}} */
static void sxe_add_namespaces(php_sxe_object *sxe, xmlNodePtr node, bool recursive, zval *return_value) /* {{{ */
@@ -1484,7 +1463,7 @@ PHP_METHOD(SimpleXMLElement, getNamespaces)
}
/* }}} */
-static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node, bool recursive, zval *return_value) /* {{{ */
+static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node, bool recursive, bool include_xmlns_attributes, zval *return_value) /* {{{ */
{
xmlNsPtr ns;
@@ -1494,10 +1473,24 @@ static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node,
sxe_add_namespace_name(return_value, ns);
ns = ns->next;
}
+ if (include_xmlns_attributes) {
+ for (const xmlAttr *attr = node->properties; attr; attr = attr->next) {
+ /* Attributes in the xmlns namespace should be treated as namespace declarations too. */
+ if (attr->ns && xmlStrEqual(attr->ns->href, (const xmlChar *) "http://www.w3.org/2000/xmlns/")) {
+ const char *prefix = attr->ns->prefix ? (const char *) attr->name : "";
+ bool free;
+ xmlChar *href = php_libxml_attr_value(attr, &free);
+ sxe_add_namespace_name_raw(return_value, prefix, (const char *) href);
+ if (free) {
+ xmlFree(href);
+ }
+ }
+ }
+ }
if (recursive) {
node = node->children;
while (node) {
- sxe_add_registered_namespaces(sxe, node, recursive, return_value);
+ sxe_add_registered_namespaces(sxe, node, recursive, include_xmlns_attributes, return_value);
node = node->next;
}
}
@@ -1532,8 +1525,11 @@ PHP_METHOD(SimpleXMLElement, getDocNamespaces)
RETURN_FALSE;
}
+ /* Only do this for modern documents to keep BC. */
+ bool include_xmlns_attributes = sxe->document->class_type == PHP_LIBXML_CLASS_MODERN;
+
array_init(return_value);
- sxe_add_registered_namespaces(sxe, node, recursive, return_value);
+ sxe_add_registered_namespaces(sxe, node, recursive, include_xmlns_attributes, return_value);
}
/* }}} */
diff --git a/ext/simplexml/tests/getDocNamespaces_no_internal_declaration.phpt b/ext/simplexml/tests/getDocNamespaces_no_internal_declaration.phpt
new file mode 100644
index 0000000000000..322dee4569239
--- /dev/null
+++ b/ext/simplexml/tests/getDocNamespaces_no_internal_declaration.phpt
@@ -0,0 +1,57 @@
+--TEST--
+getDocNamespaces() without internal namespace declaration in the document
+--EXTENSIONS--
+simplexml
+dom
+--FILE--
+
+
+
+
+
+
+
+
+XML;
+
+$sxe = simplexml_load_string($xml);
+var_dump($sxe->getDocNamespaces(true));
+
+$dom = new DOMDocument;
+$dom->loadXML($xml);
+$sxe = simplexml_import_dom($dom);
+var_dump($sxe->getDocNamespaces(true));
+
+$dom = Dom\XMLDocument::createFromString($xml);
+$sxe = simplexml_import_dom($dom);
+var_dump($sxe->getDocNamespaces(true));
+
+?>
+--EXPECT--
+array(3) {
+ [""]=>
+ string(5) "urn:a"
+ ["a"]=>
+ string(5) "urn:a"
+ ["d"]=>
+ string(5) "urn:d"
+}
+array(3) {
+ [""]=>
+ string(5) "urn:a"
+ ["a"]=>
+ string(5) "urn:a"
+ ["d"]=>
+ string(5) "urn:d"
+}
+array(3) {
+ [""]=>
+ string(5) "urn:a"
+ ["a"]=>
+ string(5) "urn:a"
+ ["d"]=>
+ string(5) "urn:d"
+}
diff --git a/ext/simplexml/tests/simplexml_import_new_dom.phpt b/ext/simplexml/tests/simplexml_import_new_dom.phpt
index b0e00c731e503..4e205bd590128 100644
--- a/ext/simplexml/tests/simplexml_import_new_dom.phpt
+++ b/ext/simplexml/tests/simplexml_import_new_dom.phpt
@@ -5,7 +5,7 @@ simplexml
dom
--FILE--
book;
foreach ($books as $book) {
diff --git a/ext/snmp/snmp.stub.php b/ext/snmp/snmp.stub.php
index 87496c936fe4d..0a303aea77ff0 100644
--- a/ext/snmp/snmp.stub.php
+++ b/ext/snmp/snmp.stub.php
@@ -183,66 +183,30 @@ function snmp_read_mib(string $filename): bool {}
class SNMP
{
- /**
- * @cvalue SNMP_VERSION_1
- * @link snmp.class.constants.version-1
- */
+ /** @cvalue SNMP_VERSION_1 */
public const int VERSION_1 = UNKNOWN;
- /**
- * @cvalue SNMP_VERSION_2c
- * @link snmp.class.constants.version-2c
- */
+ /** @cvalue SNMP_VERSION_2c */
public const int VERSION_2c = UNKNOWN;
- /**
- * @cvalue SNMP_VERSION_2c
- * @link snmp.class.constants.version-2c
- */
+ /** @cvalue SNMP_VERSION_2c */
public const int VERSION_2C = UNKNOWN;
- /**
- * @cvalue SNMP_VERSION_3
- * @link snmp.class.constants.version-3
- */
+ /** @cvalue SNMP_VERSION_3 */
public const int VERSION_3 = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_NOERROR
- * @link snmp.class.constants.errno-noerror
- */
+ /** @cvalue PHP_SNMP_ERRNO_NOERROR */
public const int ERRNO_NOERROR = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_ANY
- * @link snmp.class.constants.errno-any
- */
+ /** @cvalue PHP_SNMP_ERRNO_ANY */
public const int ERRNO_ANY = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_GENERIC
- * @link snmp.class.constants.errno-generic
- */
+ /** @cvalue PHP_SNMP_ERRNO_GENERIC */
public const int ERRNO_GENERIC = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_TIMEOUT
- * @link snmp.class.constants.errno-timeout
- */
+ /** @cvalue PHP_SNMP_ERRNO_TIMEOUT */
public const int ERRNO_TIMEOUT = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_ERROR_IN_REPLY
- * @link snmp.class.constants.errno-error-in-reply
- */
+ /** @cvalue PHP_SNMP_ERRNO_ERROR_IN_REPLY */
public const int ERRNO_ERROR_IN_REPLY = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_OID_NOT_INCREASING
- * @link snmp.class.constants.errno-oid-not-increasing
- */
+ /** @cvalue PHP_SNMP_ERRNO_OID_NOT_INCREASING */
public const int ERRNO_OID_NOT_INCREASING = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_OID_PARSING_ERROR
- * @link snmp.class.constants.errno-oid-parsing-error
- */
+ /** @cvalue PHP_SNMP_ERRNO_OID_PARSING_ERROR */
public const int ERRNO_OID_PARSING_ERROR = UNKNOWN;
- /**
- * @cvalue PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES
- * @link snmp.class.constants.errno-multiple-set-queries
- */
+ /** @cvalue PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES */
public const int ERRNO_MULTIPLE_SET_QUERIES = UNKNOWN;
/** @readonly */
diff --git a/ext/snmp/snmp_arginfo.h b/ext/snmp/snmp_arginfo.h
index 60a91c61b550d..307c22ecb8d8e 100644
--- a/ext/snmp/snmp_arginfo.h
+++ b/ext/snmp/snmp_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 449ae0af39f24f3e5696b88a30d2a440628c409b */
+ * Stub hash: e2451ac3ea0fa5eb1158e8b7252e61c6794d514f */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_snmpget, 0, 3, IS_MIXED, 0)
ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)
diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c
index 241afb16e52d3..14d3919265d6a 100644
--- a/ext/soap/php_http.c
+++ b/ext/soap/php_http.c
@@ -484,8 +484,8 @@ int make_http_soap_request(zval *this_ptr,
if (stream != NULL) {
php_url *orig;
tmp = Z_CLIENT_HTTPURL_P(this_ptr);
- if (Z_TYPE_P(tmp) == IS_RESOURCE &&
- (orig = (php_url *) zend_fetch_resource_ex(tmp, "httpurl", le_url)) != NULL &&
+ if (Z_TYPE_P(tmp) == IS_OBJECT && instanceof_function(Z_OBJCE_P(tmp), soap_url_class_entry) &&
+ (orig = Z_SOAP_URL_P(tmp)->url) != NULL &&
((use_proxy && !use_ssl) ||
(((use_ssl && orig->scheme != NULL && zend_string_equals_literal(orig->scheme, "https")) ||
(!use_ssl && orig->scheme == NULL) ||
@@ -536,9 +536,15 @@ int make_http_soap_request(zval *this_ptr,
if (stream) {
zval *cookies, *login, *password;
- zend_resource *ret = zend_register_resource(phpurl, le_url);
- ZVAL_RES(Z_CLIENT_HTTPURL_P(this_ptr), ret);
- GC_ADDREF(ret);
+
+ zval *url_zval = Z_CLIENT_HTTPURL_P(this_ptr);
+ if (Z_TYPE_P(url_zval) == IS_OBJECT) {
+ zval_ptr_dtor(url_zval);
+ }
+
+ object_init_ex(url_zval, soap_url_class_entry);
+ soap_url_object *url_obj = Z_SOAP_URL_P(url_zval);
+ url_obj->url = phpurl;
if (context &&
(tmp = php_stream_context_get_option(context, "http", "protocol_version")) != NULL &&
diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c
index e1961a05e38c1..4215d07c853ef 100644
--- a/ext/soap/php_sdl.c
+++ b/ext/soap/php_sdl.c
@@ -3449,12 +3449,10 @@ void delete_sdl_impl(void *handle)
efree(tmp);
}
-void delete_sdl(void *handle)
+void delete_sdl(sdl *handle)
{
- sdlPtr tmp = (sdlPtr)handle;
-
- if (!tmp->is_persistent) {
- delete_sdl_impl(tmp);
+ if (!handle->is_persistent) {
+ delete_sdl_impl(handle);
}
}
diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h
index 08f3923698011..3a1bcb51a8af6 100644
--- a/ext/soap/php_sdl.h
+++ b/ext/soap/php_sdl.h
@@ -260,7 +260,7 @@ encodePtr get_encoder_ex(sdlPtr sdl, const char *nscat, int len);
sdlBindingPtr get_binding_from_type(sdlPtr sdl, sdlBindingType type);
sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns);
-void delete_sdl(void *handle);
+void delete_sdl(sdl *handle);
void delete_sdl_impl(void *handle);
void sdl_set_uri_credentials(sdlCtx *ctx, char *uri);
diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h
index 33a071ed41819..3d9ccf330300a 100644
--- a/ext/soap/php_soap.h
+++ b/ext/soap/php_soap.h
@@ -40,8 +40,6 @@
# define stricmp strcasecmp
#endif
-extern int le_url;
-
typedef struct _encodeType encodeType, *encodeTypePtr;
typedef struct _encode encode, *encodePtr;
@@ -194,6 +192,8 @@ ZEND_TSRMLS_CACHE_EXTERN()
extern zend_class_entry* soap_class_entry;
extern zend_class_entry* soap_var_class_entry;
+extern zend_class_entry* soap_url_class_entry;
+extern zend_class_entry* soap_sdl_class_entry;
void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail);
@@ -253,4 +253,21 @@ static zend_always_inline zval *php_soap_deref(zval *zv) {
#define Z_CLIENT_LAST_REQUEST_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 34))
#define Z_CLIENT_LAST_RESPONSE_HEADERS_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 35))
+typedef struct soap_url_object {
+ php_url *url;
+ zend_object std;
+} soap_url_object;
+
+static inline soap_url_object *soap_url_object_fetch(zend_object *obj)
+{
+ return (soap_url_object *) ((char *) obj - XtOffsetOf(soap_url_object, std));
+}
+
+#define Z_SOAP_URL_P(zv) soap_url_object_fetch(Z_OBJ_P(zv))
+
+typedef struct soap_sdl_object {
+ sdl *sdl;
+ zend_object std;
+} soap_sdl_object;
+
#endif
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index 9064d1cbacef0..e7be6640e8173 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -28,11 +28,6 @@
#include "zend_interfaces.h"
#include "ext/standard/php_incomplete_class.h"
-
-static int le_sdl = 0;
-int le_url = 0;
-static int le_typemap = 0;
-
typedef struct _soapHeader {
sdlFunctionPtr function;
zval function_name;
@@ -65,8 +60,6 @@ static xmlNodePtr serialize_parameter(sdlParamPtr param,zval *param_val,int inde
static xmlNodePtr serialize_zval(zval *val, sdlParamPtr param, char *paramName, int style, xmlNodePtr parent);
static void delete_service(void *service);
-static void delete_url(void *handle);
-static void delete_hashtable(void *hashtable);
static void soap_error_handler(int error_num, zend_string *error_filename, const uint32_t error_lineno, zend_string *message);
@@ -130,17 +123,13 @@ static void soap_error_handler(int error_num, zend_string *error_filename, const
#define FETCH_THIS_SDL(ss) \
{ \
zval *__tmp = Z_CLIENT_SDL_P(ZEND_THIS); \
- if (Z_TYPE_P(__tmp) == IS_RESOURCE) { \
- FETCH_SDL_RES(ss,__tmp); \
+ if (Z_TYPE_P(__tmp) == IS_OBJECT && instanceof_function(Z_OBJCE_P(__tmp), soap_sdl_class_entry)) { \
+ ss = Z_SOAP_SDL_P(__tmp)->sdl; \
} else { \
ss = NULL; \
} \
}
-#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource_ex(tmp, "sdl", le_sdl)
-
-#define FETCH_TYPEMAP_RES(ss,tmp) ss = (HashTable*) zend_fetch_resource_ex(tmp, "typemap", le_typemap)
-
#define Z_PARAM_NAME_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 0))
#define Z_PARAM_DATA_P(zv) php_soap_deref(OBJ_PROP_NUM(Z_OBJ_P(zv), 1))
@@ -178,8 +167,12 @@ static zend_class_entry* soap_fault_class_entry;
static zend_class_entry* soap_header_class_entry;
static zend_class_entry* soap_param_class_entry;
zend_class_entry* soap_var_class_entry;
+zend_class_entry *soap_url_class_entry;
+zend_class_entry *soap_sdl_class_entry;
static zend_object_handlers soap_server_object_handlers;
+static zend_object_handlers soap_url_object_handlers;
+static zend_object_handlers soap_sdl_object_handlers;
typedef struct {
soapServicePtr service;
@@ -206,6 +199,93 @@ static void soap_server_object_free(zend_object *obj) {
zend_object_std_dtor(obj);
}
+static zend_object *soap_url_object_create(zend_class_entry *ce)
+{
+ soap_url_object *url_obj = zend_object_alloc(sizeof(soap_url_object), ce);
+
+ zend_object_std_init(&url_obj->std, ce);
+ object_properties_init(&url_obj->std, ce);
+
+ return &url_obj->std;
+}
+
+static void soap_url_object_free(zend_object *obj)
+{
+ soap_url_object *url_obj = soap_url_object_fetch(obj);
+
+ if (url_obj->url) {
+ php_url_free(url_obj->url);
+ url_obj->url = NULL;
+ }
+
+ zend_object_std_dtor(&url_obj->std);
+}
+
+static zend_function *soap_url_object_get_constructor(zend_object *object)
+{
+ zend_throw_error(NULL, "Cannot directly construct Soap\\Url");
+
+ return NULL;
+}
+
+static zend_result soap_url_cast_object(zend_object *obj, zval *result, int type)
+{
+ if (type == IS_LONG) {
+ ZVAL_LONG(result, obj->handle);
+
+ return SUCCESS;
+ }
+
+ return zend_std_cast_object_tostring(obj, result, type);
+}
+
+static inline soap_sdl_object *soap_sdl_object_fetch(zend_object *obj)
+{
+ return (soap_sdl_object *) ((char *) obj - XtOffsetOf(soap_sdl_object, std));
+}
+
+#define Z_SOAP_SDL_P(zv) soap_sdl_object_fetch(Z_OBJ_P(zv))
+
+static zend_object *soap_sdl_object_create(zend_class_entry *ce)
+{
+ soap_sdl_object *sdl_obj = zend_object_alloc(sizeof(soap_sdl_object), ce);
+
+ zend_object_std_init(&sdl_obj->std, ce);
+ object_properties_init(&sdl_obj->std, ce);
+
+ return &sdl_obj->std;
+}
+
+static void soap_sdl_object_free(zend_object *obj)
+{
+ soap_sdl_object *sdl_obj = soap_sdl_object_fetch(obj);
+
+ if (sdl_obj->sdl) {
+ delete_sdl(sdl_obj->sdl);
+ sdl_obj->sdl = NULL;
+ }
+
+ zend_object_std_dtor(&sdl_obj->std);
+}
+
+static zend_function *soap_sdl_object_get_constructor(zend_object *object)
+{
+ zend_throw_error(NULL, "Cannot directly construct Soap\\Sdl");
+
+ return NULL;
+}
+
+static zend_result soap_sdl_cast_object(zend_object *obj, zval *result, int type)
+{
+ if (type == IS_LONG) {
+ ZVAL_LONG(result, obj->handle);
+
+ return SUCCESS;
+ }
+
+ return zend_std_cast_object_tostring(obj, result, type);
+}
+
ZEND_DECLARE_MODULE_GLOBALS(soap)
static void (*old_error_handler)(int, zend_string *, const uint32_t, zend_string *);
@@ -390,21 +470,6 @@ PHP_RINIT_FUNCTION(soap)
return SUCCESS;
}
-static void delete_sdl_res(zend_resource *res)
-{
- delete_sdl(res->ptr);
-}
-
-static void delete_url_res(zend_resource *res)
-{
- delete_url(res->ptr);
-}
-
-static void delete_hashtable_res(zend_resource *res)
-{
- delete_hashtable(res->ptr);
-}
-
PHP_MINIT_FUNCTION(soap)
{
/* TODO: add ini entry for always use soap errors */
@@ -435,9 +500,29 @@ PHP_MINIT_FUNCTION(soap)
soap_header_class_entry = register_class_SoapHeader();
- le_sdl = zend_register_list_destructors_ex(delete_sdl_res, NULL, "SOAP SDL", module_number);
- le_url = zend_register_list_destructors_ex(delete_url_res, NULL, "SOAP URL", module_number);
- le_typemap = zend_register_list_destructors_ex(delete_hashtable_res, NULL, "SOAP table", module_number);
+ soap_url_class_entry = register_class_Soap_Url();
+ soap_url_class_entry->create_object = soap_url_object_create;
+ soap_url_class_entry->default_object_handlers = &soap_url_object_handlers;
+
+ memcpy(&soap_url_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
+ soap_url_object_handlers.offset = XtOffsetOf(soap_url_object, std);
+ soap_url_object_handlers.free_obj = soap_url_object_free;
+ soap_url_object_handlers.get_constructor = soap_url_object_get_constructor;
+ soap_url_object_handlers.clone_obj = NULL;
+ soap_url_object_handlers.cast_object = soap_url_cast_object;
+ soap_url_object_handlers.compare = zend_objects_not_comparable;
+
+ soap_sdl_class_entry = register_class_Soap_Sdl();
+ soap_sdl_class_entry->create_object = soap_sdl_object_create;
+ soap_sdl_class_entry->default_object_handlers = &soap_sdl_object_handlers;
+
+ memcpy(&soap_sdl_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
+ soap_sdl_object_handlers.offset = XtOffsetOf(soap_sdl_object, std);
+ soap_sdl_object_handlers.free_obj = soap_sdl_object_free;
+ soap_sdl_object_handlers.get_constructor = soap_sdl_object_get_constructor;
+ soap_sdl_object_handlers.clone_obj = NULL;
+ soap_url_object_handlers.cast_object = soap_sdl_cast_object;
+ soap_sdl_object_handlers.compare = zend_objects_not_comparable;
register_soap_symbols(module_number);
@@ -2053,15 +2138,20 @@ PHP_METHOD(SoapClient, __construct)
if (wsdl) {
int old_soap_version;
- zend_resource *res;
old_soap_version = SOAP_GLOBAL(soap_version);
SOAP_GLOBAL(soap_version) = soap_version;
sdl = get_sdl(this_ptr, ZSTR_VAL(wsdl), cache_wsdl);
- res = zend_register_resource(sdl, le_sdl);
- ZVAL_RES(Z_CLIENT_SDL_P(this_ptr), res);
+ zval *sdl_zval = Z_CLIENT_SDL_P(this_ptr);
+ if (Z_TYPE_P(sdl_zval) == IS_OBJECT) {
+ zval_ptr_dtor(sdl_zval);
+ }
+
+ object_init_ex(sdl_zval, soap_sdl_class_entry);
+ soap_sdl_object *sdl_object = Z_SOAP_SDL_P(sdl_zval);
+ sdl_object->sdl = sdl;
SOAP_GLOBAL(soap_version) = old_soap_version;
}
@@ -2069,8 +2159,7 @@ PHP_METHOD(SoapClient, __construct)
if (typemap_ht) {
HashTable *typemap = soap_create_typemap(sdl, typemap_ht);
if (typemap) {
- zend_resource *res = zend_register_resource(typemap, le_typemap);
- ZVAL_RES(Z_CLIENT_TYPEMAP_P(this_ptr), res);
+ ZVAL_ARR(Z_CLIENT_TYPEMAP_P(this_ptr), typemap);
}
}
SOAP_CLIENT_END_CODE();
@@ -2194,13 +2283,16 @@ static void do_soap_call(zend_execute_data *execute_data,
}
tmp = Z_CLIENT_SDL_P(this_ptr);
- if (Z_TYPE_P(tmp) == IS_RESOURCE) {
- FETCH_SDL_RES(sdl,tmp);
+ if (Z_TYPE_P(tmp) == IS_OBJECT) {
+#ifdef ZEND_DEBUG
+ ZEND_ASSERT(instanceof_function(Z_OBJCE_P(tmp), soap_sdl_class_entry));
+#endif
+ sdl = Z_SOAP_SDL_P(tmp)->sdl;
}
tmp = Z_CLIENT_TYPEMAP_P(this_ptr);
- if (Z_TYPE_P(tmp) == IS_RESOURCE) {
- FETCH_TYPEMAP_RES(typemap, tmp);
+ if (Z_TYPE_P(tmp) == IS_ARRAY) {
+ typemap = Z_ARR_P(tmp);
}
clear_soap_fault(this_ptr);
@@ -2503,14 +2595,13 @@ PHP_METHOD(SoapClient, __soapCall)
/* {{{ Returns list of SOAP functions */
PHP_METHOD(SoapClient, __getFunctions)
{
- sdlPtr sdl;
-
- FETCH_THIS_SDL(sdl);
-
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
+ sdl *sdl;
+ FETCH_THIS_SDL(sdl);
+
if (sdl) {
smart_str buf = {0};
sdlFunctionPtr function;
@@ -2529,14 +2620,13 @@ PHP_METHOD(SoapClient, __getFunctions)
/* {{{ Returns list of SOAP types */
PHP_METHOD(SoapClient, __getTypes)
{
- sdlPtr sdl;
-
- FETCH_THIS_SDL(sdl);
-
if (zend_parse_parameters_none() == FAILURE) {
RETURN_THROWS();
}
+ sdl *sdl;
+ FETCH_THIS_SDL(sdl);
+
if (sdl) {
sdlTypePtr type;
smart_str buf = {0};
@@ -4355,12 +4445,6 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
}
/* }}} */
-static void delete_url(void *handle) /* {{{ */
-{
- php_url_free((php_url*)handle);
-}
-/* }}} */
-
static void delete_service(void *data) /* {{{ */
{
soapServicePtr service = (soapServicePtr)data;
@@ -4404,10 +4488,4 @@ static void delete_service(void *data) /* {{{ */
}
/* }}} */
-static void delete_hashtable(void *data) /* {{{ */
-{
- HashTable *ht = (HashTable*)data;
- zend_hash_destroy(ht);
- efree(ht);
-}
/* }}} */
diff --git a/ext/soap/soap.stub.php b/ext/soap/soap.stub.php
index 99d752a723e03..8806d73662d9c 100644
--- a/ext/soap/soap.stub.php
+++ b/ext/soap/soap.stub.php
@@ -2,603 +2,620 @@
/** @generate-class-entries */
-/**
- * @var int
- * @cvalue SOAP_1_1
- */
-const SOAP_1_1 = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_1_2
- */
-const SOAP_1_2 = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_PERSISTENCE_SESSION
- */
-const SOAP_PERSISTENCE_SESSION = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_PERSISTENCE_REQUEST
- */
-const SOAP_PERSISTENCE_REQUEST = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_FUNCTIONS_ALL
- */
-const SOAP_FUNCTIONS_ALL = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SOAP_ENCODED
- */
-const SOAP_ENCODED = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_LITERAL
- */
-const SOAP_LITERAL = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SOAP_RPC
- */
-const SOAP_RPC = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_DOCUMENT
- */
-const SOAP_DOCUMENT = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SOAP_ACTOR_NEXT
- */
-const SOAP_ACTOR_NEXT = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_ACTOR_NONE
- */
-const SOAP_ACTOR_NONE = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_ACTOR_UNLIMATERECEIVER
- */
-const SOAP_ACTOR_UNLIMATERECEIVER = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SOAP_COMPRESSION_ACCEPT
- */
-const SOAP_COMPRESSION_ACCEPT = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_COMPRESSION_GZIP
- */
-const SOAP_COMPRESSION_GZIP = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_COMPRESSION_DEFLATE
- */
-const SOAP_COMPRESSION_DEFLATE = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SOAP_AUTHENTICATION_BASIC
- */
-const SOAP_AUTHENTICATION_BASIC = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_AUTHENTICATION_DIGEST
- */
-const SOAP_AUTHENTICATION_DIGEST = UNKNOWN;
-
-/**
- * @var int
- * @cvalue UNKNOWN_TYPE
- */
-const UNKNOWN_TYPE = UNKNOWN;
-
-/**
- * @var int
- * @cvalue XSD_STRING
- */
-const XSD_STRING = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_BOOLEAN
- */
-const XSD_BOOLEAN = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_DECIMAL
- */
-const XSD_DECIMAL = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_FLOAT
- */
-const XSD_FLOAT = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_DOUBLE
- */
-const XSD_DOUBLE = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_DURATION
- */
-const XSD_DURATION = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_DATETIME
- */
-const XSD_DATETIME = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_TIME
- */
-const XSD_TIME = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_DATE
- */
-const XSD_DATE = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_GYEARMONTH
- */
-const XSD_GYEARMONTH = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_GYEAR
- */
-const XSD_GYEAR = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_GMONTHDAY
- */
-const XSD_GMONTHDAY = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_GDAY
- */
-const XSD_GDAY = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_GMONTH
- */
-const XSD_GMONTH = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_HEXBINARY
- */
-const XSD_HEXBINARY = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_BASE64BINARY
- */
-const XSD_BASE64BINARY = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_ANYURI
- */
-const XSD_ANYURI = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_QNAME
- */
-const XSD_QNAME = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NOTATION
- */
-const XSD_NOTATION = UNKNOWN;
-
-/**
- * @var int
- * @cvalue XSD_NORMALIZEDSTRING
- */
-const XSD_NORMALIZEDSTRING = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_TOKEN
- */
-const XSD_TOKEN = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_LANGUAGE
- */
-const XSD_LANGUAGE = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NMTOKEN
- */
-const XSD_NMTOKEN = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NAME
- */
-const XSD_NAME = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NCNAME
- */
-const XSD_NCNAME = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_ID
- */
-const XSD_ID = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_IDREF
- */
-const XSD_IDREF = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_IDREFS
- */
-const XSD_IDREFS = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_ENTITY
- */
-const XSD_ENTITY = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_ENTITIES
- */
-const XSD_ENTITIES = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_INTEGER
- */
-const XSD_INTEGER = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NONPOSITIVEINTEGER
- */
-const XSD_NONPOSITIVEINTEGER = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NEGATIVEINTEGER
- */
-const XSD_NEGATIVEINTEGER = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_LONG
- */
-const XSD_LONG = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_INT
- */
-const XSD_INT = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_SHORT
- */
-const XSD_SHORT = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_BYTE
- */
-const XSD_BYTE = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NONNEGATIVEINTEGER
- */
-const XSD_NONNEGATIVEINTEGER = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_UNSIGNEDLONG
- */
-const XSD_UNSIGNEDLONG = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_UNSIGNEDINT
- */
-const XSD_UNSIGNEDINT = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_UNSIGNEDSHORT
- */
-const XSD_UNSIGNEDSHORT = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_UNSIGNEDBYTE
- */
-const XSD_UNSIGNEDBYTE = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_POSITIVEINTEGER
- */
-const XSD_POSITIVEINTEGER = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_NMTOKENS
- */
-const XSD_NMTOKENS = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_ANYTYPE
- */
-const XSD_ANYTYPE = UNKNOWN;
-/**
- * @var int
- * @cvalue XSD_ANYXML
- */
-const XSD_ANYXML = UNKNOWN;
-
-/**
- * @var int
- * @cvalue APACHE_MAP
- */
-const APACHE_MAP = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SOAP_ENC_OBJECT
- */
-const SOAP_ENC_OBJECT = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_ENC_ARRAY
- */
-const SOAP_ENC_ARRAY = UNKNOWN;
-
-/**
- * @var int
- * @cvalue XSD_1999_TIMEINSTANT
- */
-const XSD_1999_TIMEINSTANT = UNKNOWN;
-
-/**
- * @var string
- * @cvalue XSD_NAMESPACE
- */
-const XSD_NAMESPACE = UNKNOWN;
-/**
- * @var string
- * @cvalue XSD_1999_NAMESPACE
- */
-const XSD_1999_NAMESPACE = UNKNOWN;
-
-/**
- * @var int
- * @cvalue SOAP_SINGLE_ELEMENT_ARRAYS
- */
-const SOAP_SINGLE_ELEMENT_ARRAYS = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_WAIT_ONE_WAY_CALLS
- */
-const SOAP_WAIT_ONE_WAY_CALLS = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_USE_XSI_ARRAY_TYPE
- */
-const SOAP_USE_XSI_ARRAY_TYPE = UNKNOWN;
-
-/**
- * @var int
- * @cvalue WSDL_CACHE_NONE
- */
-const WSDL_CACHE_NONE = UNKNOWN;
-/**
- * @var int
- * @cvalue WSDL_CACHE_DISK
- */
-const WSDL_CACHE_DISK = UNKNOWN;
-/**
- * @var int
- * @cvalue WSDL_CACHE_MEMORY
- */
-const WSDL_CACHE_MEMORY = UNKNOWN;
-/**
- * @var int
- * @cvalue WSDL_CACHE_BOTH
- */
-const WSDL_CACHE_BOTH = UNKNOWN;
-
-/* New SOAP SSL Method Constants */
-
-/**
- * @var int
- * @cvalue SOAP_SSL_METHOD_TLS
- */
-const SOAP_SSL_METHOD_TLS = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_SSL_METHOD_SSLv2
- */
-const SOAP_SSL_METHOD_SSLv2 = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_SSL_METHOD_SSLv3
- */
-const SOAP_SSL_METHOD_SSLv3 = UNKNOWN;
-/**
- * @var int
- * @cvalue SOAP_SSL_METHOD_SSLv23
- */
-const SOAP_SSL_METHOD_SSLv23 = UNKNOWN;
-
-function use_soap_error_handler(bool $enable = true): bool {}
-
-function is_soap_fault(mixed $object): bool {}
-
-class SoapParam
-{
- public string $param_name;
- public mixed $param_data;
-
- public function __construct(mixed $data, string $name) {}
-}
-
-class SoapHeader
-{
- public string $namespace;
- public string $name;
- public mixed $data = null;
- public bool $mustUnderstand;
- public string|int|null $actor;
+namespace Soap {
+ /**
+ * @strict-properties
+ * @not-serializable
+ */
+ final class Url
+ {
+ }
- public function __construct(string $namespace, string $name, mixed $data = UNKNOWN, bool $mustUnderstand = false, string|int|null $actor = null) {}
+ /**
+ * @strict-properties
+ * @not-serializable
+ */
+ final class Sdl
+ {
+ }
}
-class SoapFault extends Exception
-{
- public string $faultstring;
- public ?string $faultcode = null;
- public ?string $faultcodens = null;
- public ?string $faultactor = null;
- public mixed $detail = null;
- public ?string $_name = null;
- public mixed $headerfault = null;
+namespace {
+ /**
+ * @var int
+ * @cvalue SOAP_1_1
+ */
+ const SOAP_1_1 = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_1_2
+ */
+ const SOAP_1_2 = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_PERSISTENCE_SESSION
+ */
+ const SOAP_PERSISTENCE_SESSION = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_PERSISTENCE_REQUEST
+ */
+ const SOAP_PERSISTENCE_REQUEST = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_FUNCTIONS_ALL
+ */
+ const SOAP_FUNCTIONS_ALL = UNKNOWN;
- public function __construct(array|string|null $code, string $string, ?string $actor = null, mixed $details = null, ?string $name = null, mixed $headerFault = null) {}
+ /**
+ * @var int
+ * @cvalue SOAP_ENCODED
+ */
+ const SOAP_ENCODED = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_LITERAL
+ */
+ const SOAP_LITERAL = UNKNOWN;
- public function __toString(): string {}
-}
+ /**
+ * @var int
+ * @cvalue SOAP_RPC
+ */
+ const SOAP_RPC = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_DOCUMENT
+ */
+ const SOAP_DOCUMENT = UNKNOWN;
-class SoapVar
-{
- public int $enc_type;
- public mixed $enc_value = null;
- public ?string $enc_stype = null;
- public ?string $enc_ns = null;
- public ?string $enc_name = null;
- public ?string $enc_namens = null;
+ /**
+ * @var int
+ * @cvalue SOAP_ACTOR_NEXT
+ */
+ const SOAP_ACTOR_NEXT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_ACTOR_NONE
+ */
+ const SOAP_ACTOR_NONE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_ACTOR_UNLIMATERECEIVER
+ */
+ const SOAP_ACTOR_UNLIMATERECEIVER = UNKNOWN;
- public function __construct(mixed $data, ?int $encoding, ?string $typeName = null, ?string $typeNamespace = null, ?string $nodeName = null, ?string $nodeNamespace = null) {}
-}
+ /**
+ * @var int
+ * @cvalue SOAP_COMPRESSION_ACCEPT
+ */
+ const SOAP_COMPRESSION_ACCEPT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_COMPRESSION_GZIP
+ */
+ const SOAP_COMPRESSION_GZIP = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_COMPRESSION_DEFLATE
+ */
+ const SOAP_COMPRESSION_DEFLATE = UNKNOWN;
-class SoapServer
-{
- private ?SoapFault $__soap_fault = null;
+ /**
+ * @var int
+ * @cvalue SOAP_AUTHENTICATION_BASIC
+ */
+ const SOAP_AUTHENTICATION_BASIC = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_AUTHENTICATION_DIGEST
+ */
+ const SOAP_AUTHENTICATION_DIGEST = UNKNOWN;
- public function __construct(?string $wsdl, array $options = []) {}
+ /**
+ * @var int
+ * @cvalue UNKNOWN_TYPE
+ */
+ const UNKNOWN_TYPE = UNKNOWN;
+
+ /**
+ * @var int
+ * @cvalue XSD_STRING
+ */
+ const XSD_STRING = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_BOOLEAN
+ */
+ const XSD_BOOLEAN = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_DECIMAL
+ */
+ const XSD_DECIMAL = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_FLOAT
+ */
+ const XSD_FLOAT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_DOUBLE
+ */
+ const XSD_DOUBLE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_DURATION
+ */
+ const XSD_DURATION = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_DATETIME
+ */
+ const XSD_DATETIME = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_TIME
+ */
+ const XSD_TIME = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_DATE
+ */
+ const XSD_DATE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_GYEARMONTH
+ */
+ const XSD_GYEARMONTH = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_GYEAR
+ */
+ const XSD_GYEAR = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_GMONTHDAY
+ */
+ const XSD_GMONTHDAY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_GDAY
+ */
+ const XSD_GDAY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_GMONTH
+ */
+ const XSD_GMONTH = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_HEXBINARY
+ */
+ const XSD_HEXBINARY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_BASE64BINARY
+ */
+ const XSD_BASE64BINARY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_ANYURI
+ */
+ const XSD_ANYURI = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_QNAME
+ */
+ const XSD_QNAME = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NOTATION
+ */
+ const XSD_NOTATION = UNKNOWN;
- /** @tentative-return-type */
- public function fault(string $code, string $string, string $actor = "", mixed $details = null, string $name = ""): void {}
+ /**
+ * @var int
+ * @cvalue XSD_NORMALIZEDSTRING
+ */
+ const XSD_NORMALIZEDSTRING = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_TOKEN
+ */
+ const XSD_TOKEN = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_LANGUAGE
+ */
+ const XSD_LANGUAGE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NMTOKEN
+ */
+ const XSD_NMTOKEN = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NAME
+ */
+ const XSD_NAME = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NCNAME
+ */
+ const XSD_NCNAME = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_ID
+ */
+ const XSD_ID = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_IDREF
+ */
+ const XSD_IDREF = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_IDREFS
+ */
+ const XSD_IDREFS = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_ENTITY
+ */
+ const XSD_ENTITY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_ENTITIES
+ */
+ const XSD_ENTITIES = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_INTEGER
+ */
+ const XSD_INTEGER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NONPOSITIVEINTEGER
+ */
+ const XSD_NONPOSITIVEINTEGER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NEGATIVEINTEGER
+ */
+ const XSD_NEGATIVEINTEGER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_LONG
+ */
+ const XSD_LONG = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_INT
+ */
+ const XSD_INT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_SHORT
+ */
+ const XSD_SHORT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_BYTE
+ */
+ const XSD_BYTE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NONNEGATIVEINTEGER
+ */
+ const XSD_NONNEGATIVEINTEGER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_UNSIGNEDLONG
+ */
+ const XSD_UNSIGNEDLONG = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_UNSIGNEDINT
+ */
+ const XSD_UNSIGNEDINT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_UNSIGNEDSHORT
+ */
+ const XSD_UNSIGNEDSHORT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_UNSIGNEDBYTE
+ */
+ const XSD_UNSIGNEDBYTE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_POSITIVEINTEGER
+ */
+ const XSD_POSITIVEINTEGER = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_NMTOKENS
+ */
+ const XSD_NMTOKENS = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_ANYTYPE
+ */
+ const XSD_ANYTYPE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue XSD_ANYXML
+ */
+ const XSD_ANYXML = UNKNOWN;
- /** @tentative-return-type */
- public function addSoapHeader(SoapHeader $header): void {}
+ /**
+ * @var int
+ * @cvalue APACHE_MAP
+ */
+ const APACHE_MAP = UNKNOWN;
- /** @tentative-return-type */
- public function setPersistence(int $mode): void {}
+ /**
+ * @var int
+ * @cvalue SOAP_ENC_OBJECT
+ */
+ const SOAP_ENC_OBJECT = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_ENC_ARRAY
+ */
+ const SOAP_ENC_ARRAY = UNKNOWN;
- /** @tentative-return-type */
- public function setClass(string $class, mixed ...$args): void {}
+ /**
+ * @var int
+ * @cvalue XSD_1999_TIMEINSTANT
+ */
+ const XSD_1999_TIMEINSTANT = UNKNOWN;
- /** @tentative-return-type */
- public function setObject(object $object): void {}
+ /**
+ * @var string
+ * @cvalue XSD_NAMESPACE
+ */
+ const XSD_NAMESPACE = UNKNOWN;
+ /**
+ * @var string
+ * @cvalue XSD_1999_NAMESPACE
+ */
+ const XSD_1999_NAMESPACE = UNKNOWN;
- /** @tentative-return-type */
- public function getFunctions(): array {}
+ /**
+ * @var int
+ * @cvalue SOAP_SINGLE_ELEMENT_ARRAYS
+ */
+ const SOAP_SINGLE_ELEMENT_ARRAYS = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_WAIT_ONE_WAY_CALLS
+ */
+ const SOAP_WAIT_ONE_WAY_CALLS = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_USE_XSI_ARRAY_TYPE
+ */
+ const SOAP_USE_XSI_ARRAY_TYPE = UNKNOWN;
/**
- * @param array|string|int $functions
- * @tentative-return-type
+ * @var int
+ * @cvalue WSDL_CACHE_NONE
*/
- public function addFunction($functions): void {}
+ const WSDL_CACHE_NONE = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue WSDL_CACHE_DISK
+ */
+ const WSDL_CACHE_DISK = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue WSDL_CACHE_MEMORY
+ */
+ const WSDL_CACHE_MEMORY = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue WSDL_CACHE_BOTH
+ */
+ const WSDL_CACHE_BOTH = UNKNOWN;
- /** @tentative-return-type */
- public function handle(?string $request = null): void {}
-}
+ /* New SOAP SSL Method Constants */
-class SoapClient
-{
- private ?string $uri = null;
- private ?int $style = null;
- private ?int $use = null;
- private ?string $location = null;
- private bool $trace = false;
- private ?int $compression = null;
- /** @var resource|null */
- private $sdl = null;
- /** @var resource|null */
- private $typemap = null;
- /** @var resource|null */
- private $httpsocket = null;
- /** @var resource|null */
- private $httpurl = null;
-
- private ?string $_login = null;
- private ?string $_password = null;
- private bool $_use_digest = false;
- private ?string $_digest = null;
- private ?string $_proxy_host = null;
- private ?int $_proxy_port = null;
- private ?string $_proxy_login = null;
- private ?string $_proxy_password = null;
- private bool $_exceptions = true;
- private ?string $_encoding = null;
- private ?array $_classmap = null;
- private ?int $_features = null;
- private int $_connection_timeout = 0;
- /** @var resource|null */
- private $_stream_context = null;
- private ?string $_user_agent = null;
- private bool $_keep_alive = true;
- private ?int $_ssl_method = null;
- private int $_soap_version;
- private ?int $_use_proxy = null;
- private array $_cookies = [];
- private ?array $__default_headers = null;
- private ?SoapFault $__soap_fault = null;
- private ?string $__last_request = null;
- private ?string $__last_response = null;
- private ?string $__last_request_headers = null;
- private ?string $__last_response_headers = null;
-
- public function __construct(?string $wsdl, array $options = []) {}
-
- /** @tentative-return-type */
- public function __call(string $name, array $args): mixed {}
-
- /**
- * @param SoapHeader|array|null $inputHeaders
- * @param array $outputHeaders
- * @tentative-return-type
- */
- public function __soapCall(string $name, array $args, ?array $options = null, $inputHeaders = null, &$outputHeaders = null): mixed {}
-
- /** @tentative-return-type */
- public function __getFunctions(): ?array {}
-
- /** @tentative-return-type */
- public function __getTypes(): ?array {}
-
- /** @tentative-return-type */
- public function __getLastRequest(): ?string {}
-
- /** @tentative-return-type */
- public function __getLastResponse(): ?string {}
-
- /** @tentative-return-type */
- public function __getLastRequestHeaders(): ?string {}
-
- /** @tentative-return-type */
- public function __getLastResponseHeaders(): ?string {}
-
- /** @tentative-return-type */
- public function __doRequest(string $request, string $location, string $action, int $version, bool $oneWay = false): ?string {}
-
- /** @tentative-return-type */
- public function __setCookie(string $name, ?string $value = null): void {}
-
- /** @tentative-return-type */
- public function __getCookies(): array {}
-
- /**
- * @param SoapHeader|array|null $headers
- * @tentative-return-type
- */
- public function __setSoapHeaders($headers = null): bool {}
-
- /** @tentative-return-type */
- public function __setLocation(?string $location = null): ?string {}
+ /**
+ * @var int
+ * @cvalue SOAP_SSL_METHOD_TLS
+ */
+ const SOAP_SSL_METHOD_TLS = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_SSL_METHOD_SSLv2
+ */
+ const SOAP_SSL_METHOD_SSLv2 = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_SSL_METHOD_SSLv3
+ */
+ const SOAP_SSL_METHOD_SSLv3 = UNKNOWN;
+ /**
+ * @var int
+ * @cvalue SOAP_SSL_METHOD_SSLv23
+ */
+ const SOAP_SSL_METHOD_SSLv23 = UNKNOWN;
+
+ function use_soap_error_handler(bool $enable = true): bool {}
+
+ function is_soap_fault(mixed $object): bool {}
+
+ class SoapParam
+ {
+ public string $param_name;
+ public mixed $param_data;
+
+ public function __construct(mixed $data, string $name) {}
+ }
+
+ class SoapHeader
+ {
+ public string $namespace;
+ public string $name;
+ public mixed $data = null;
+ public bool $mustUnderstand;
+ public string|int|null $actor;
+
+ public function __construct(string $namespace, string $name, mixed $data = UNKNOWN, bool $mustUnderstand = false, string|int|null $actor = null) {}
+ }
+
+ class SoapFault extends Exception
+ {
+ public string $faultstring;
+ public ?string $faultcode = null;
+ public ?string $faultcodens = null;
+ public ?string $faultactor = null;
+ public mixed $detail = null;
+ public ?string $_name = null;
+ public mixed $headerfault = null;
+
+ public function __construct(array|string|null $code, string $string, ?string $actor = null, mixed $details = null, ?string $name = null, mixed $headerFault = null) {}
+
+ public function __toString(): string {}
+ }
+
+ class SoapVar
+ {
+ public int $enc_type;
+ public mixed $enc_value = null;
+ public ?string $enc_stype = null;
+ public ?string $enc_ns = null;
+ public ?string $enc_name = null;
+ public ?string $enc_namens = null;
+
+ public function __construct(mixed $data, ?int $encoding, ?string $typeName = null, ?string $typeNamespace = null, ?string $nodeName = null, ?string $nodeNamespace = null) {}
+ }
+
+ class SoapServer
+ {
+ private ?SoapFault $__soap_fault = null;
+
+ public function __construct(?string $wsdl, array $options = []) {}
+
+ /** @tentative-return-type */
+ public function fault(string $code, string $string, string $actor = "", mixed $details = null, string $name = ""): void {}
+
+ /** @tentative-return-type */
+ public function addSoapHeader(SoapHeader $header): void {}
+
+ /** @tentative-return-type */
+ public function setPersistence(int $mode): void {}
+
+ /** @tentative-return-type */
+ public function setClass(string $class, mixed ...$args): void {}
+
+ /** @tentative-return-type */
+ public function setObject(object $object): void {}
+
+ /** @tentative-return-type */
+ public function getFunctions(): array {}
+
+ /**
+ * @param array|string|int $functions
+ * @tentative-return-type
+ */
+ public function addFunction($functions): void {}
+
+ /** @tentative-return-type */
+ public function handle(?string $request = null): void {}
+ }
+
+ class SoapClient
+ {
+ private ?string $uri = null;
+ private ?int $style = null;
+ private ?int $use = null;
+ private ?string $location = null;
+ private bool $trace = false;
+ private ?int $compression = null;
+ private ?Soap\Sdl $sdl = null;
+ private ?array $typemap = null;
+ /** @var resource|null */
+ private $httpsocket = null;
+ private ?Soap\Url $httpurl = null;
+
+ private ?string $_login = null;
+ private ?string $_password = null;
+ private bool $_use_digest = false;
+ private ?string $_digest = null;
+ private ?string $_proxy_host = null;
+ private ?int $_proxy_port = null;
+ private ?string $_proxy_login = null;
+ private ?string $_proxy_password = null;
+ private bool $_exceptions = true;
+ private ?string $_encoding = null;
+ private ?array $_classmap = null;
+ private ?int $_features = null;
+ private int $_connection_timeout = 0;
+ /** @var resource|null */
+ private $_stream_context = null;
+ private ?string $_user_agent = null;
+ private bool $_keep_alive = true;
+ private ?int $_ssl_method = null;
+ private int $_soap_version;
+ private ?int $_use_proxy = null;
+ private array $_cookies = [];
+ private ?array $__default_headers = null;
+ private ?SoapFault $__soap_fault = null;
+ private ?string $__last_request = null;
+ private ?string $__last_response = null;
+ private ?string $__last_request_headers = null;
+ private ?string $__last_response_headers = null;
+
+ public function __construct(?string $wsdl, array $options = []) {}
+
+ /** @tentative-return-type */
+ public function __call(string $name, array $args): mixed {}
+
+ /**
+ * @param SoapHeader|array|null $inputHeaders
+ * @param array $outputHeaders
+ * @tentative-return-type
+ */
+ public function __soapCall(string $name, array $args, ?array $options = null, $inputHeaders = null, &$outputHeaders = null): mixed {}
+
+ /** @tentative-return-type */
+ public function __getFunctions(): ?array {}
+
+ /** @tentative-return-type */
+ public function __getTypes(): ?array {}
+
+ /** @tentative-return-type */
+ public function __getLastRequest(): ?string {}
+
+ /** @tentative-return-type */
+ public function __getLastResponse(): ?string {}
+
+ /** @tentative-return-type */
+ public function __getLastRequestHeaders(): ?string {}
+
+ /** @tentative-return-type */
+ public function __getLastResponseHeaders(): ?string {}
+
+ /** @tentative-return-type */
+ public function __doRequest(string $request, string $location, string $action, int $version, bool $oneWay = false): ?string {}
+
+ /** @tentative-return-type */
+ public function __setCookie(string $name, ?string $value = null): void {}
+
+ /** @tentative-return-type */
+ public function __getCookies(): array {}
+
+ /**
+ * @param SoapHeader|array|null $headers
+ * @tentative-return-type
+ */
+ public function __setSoapHeaders($headers = null): bool {}
+
+ /** @tentative-return-type */
+ public function __setLocation(?string $location = null): ?string {}
+ }
}
diff --git a/ext/soap/soap_arginfo.h b/ext/soap/soap_arginfo.h
index e4611093842a0..857c3f4be3c23 100644
--- a/ext/soap/soap_arginfo.h
+++ b/ext/soap/soap_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 4dfc98696d4bc5e36610bdf03de906dbae049cf3 */
+ * Stub hash: 81d0b54b93829f3cd4b12731f6b6ae140b06a0f1 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_use_soap_error_handler, 0, 0, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enable, _IS_BOOL, 0, "true")
@@ -173,6 +173,14 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE_END
};
+static const zend_function_entry class_Soap_Url_methods[] = {
+ ZEND_FE_END
+};
+
+static const zend_function_entry class_Soap_Sdl_methods[] = {
+ ZEND_FE_END
+};
+
static const zend_function_entry class_SoapParam_methods[] = {
ZEND_ME(SoapParam, __construct, arginfo_class_SoapParam___construct, ZEND_ACC_PUBLIC)
ZEND_FE_END
@@ -310,6 +318,28 @@ static void register_soap_symbols(int module_number)
REGISTER_LONG_CONSTANT("SOAP_SSL_METHOD_SSLv23", SOAP_SSL_METHOD_SSLv23, CONST_PERSISTENT);
}
+static zend_class_entry *register_class_Soap_Url(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_NS_CLASS_ENTRY(ce, "Soap", "Url", class_Soap_Url_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;
+}
+
+static zend_class_entry *register_class_Soap_Sdl(void)
+{
+ zend_class_entry ce, *class_entry;
+
+ INIT_NS_CLASS_ENTRY(ce, "Soap", "Sdl", class_Soap_Sdl_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;
+}
+
static zend_class_entry *register_class_SoapParam(void)
{
zend_class_entry ce, *class_entry;
@@ -533,13 +563,14 @@ static zend_class_entry *register_class_SoapClient(void)
zval property_sdl_default_value;
ZVAL_NULL(&property_sdl_default_value);
zend_string *property_sdl_name = zend_string_init("sdl", sizeof("sdl") - 1, 1);
- zend_declare_typed_property(class_entry, property_sdl_name, &property_sdl_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
+ zend_string *property_sdl_class_Soap_Sdl = zend_string_init("Soap\\Sdl", sizeof("Soap\\Sdl")-1, 1);
+ zend_declare_typed_property(class_entry, property_sdl_name, &property_sdl_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_sdl_class_Soap_Sdl, 0, MAY_BE_NULL));
zend_string_release(property_sdl_name);
zval property_typemap_default_value;
ZVAL_NULL(&property_typemap_default_value);
zend_string *property_typemap_name = zend_string_init("typemap", sizeof("typemap") - 1, 1);
- zend_declare_typed_property(class_entry, property_typemap_name, &property_typemap_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
+ zend_declare_typed_property(class_entry, property_typemap_name, &property_typemap_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL));
zend_string_release(property_typemap_name);
zval property_httpsocket_default_value;
@@ -551,7 +582,8 @@ static zend_class_entry *register_class_SoapClient(void)
zval property_httpurl_default_value;
ZVAL_NULL(&property_httpurl_default_value);
zend_string *property_httpurl_name = zend_string_init("httpurl", sizeof("httpurl") - 1, 1);
- zend_declare_typed_property(class_entry, property_httpurl_name, &property_httpurl_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0));
+ zend_string *property_httpurl_class_Soap_Url = zend_string_init("Soap\\\125rl", sizeof("Soap\\\125rl")-1, 1);
+ zend_declare_typed_property(class_entry, property_httpurl_name, &property_httpurl_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_httpurl_class_Soap_Url, 0, MAY_BE_NULL));
zend_string_release(property_httpurl_name);
zval property__login_default_value;
diff --git a/ext/soap/tests/any.phpt b/ext/soap/tests/any.phpt
index eeb1831080678..5717ba085b76a 100644
--- a/ext/soap/tests/any.phpt
+++ b/ext/soap/tests/any.phpt
@@ -53,14 +53,14 @@ $ret = $client->echoAnyElement(
var_dump($g);
var_dump($ret);
?>
---EXPECT--
-object(stdClass)#5 (1) {
+--EXPECTF--
+object(stdClass)#%d (%d) {
["inputAny"]=>
- object(stdClass)#6 (1) {
+ object(stdClass)#%d (%d) {
["any"]=>
array(1) {
["SOAPComplexType"]=>
- object(SOAPComplexType)#7 (3) {
+ object(SOAPComplexType)#%d (%d) {
["varString"]=>
string(3) "arg"
["varInt"]=>
@@ -71,13 +71,13 @@ object(stdClass)#5 (1) {
}
}
}
-object(stdClass)#8 (1) {
+object(stdClass)#%d (%d) {
["return"]=>
- object(stdClass)#9 (1) {
+ object(stdClass)#%d (%d) {
["any"]=>
array(1) {
["SOAPComplexType"]=>
- object(SOAPComplexType)#10 (3) {
+ object(SOAPComplexType)#%d (%d) {
["varString"]=>
string(3) "arg"
["varInt"]=>
diff --git a/ext/soap/tests/bugs/bug36226-2.phpt b/ext/soap/tests/bugs/bug36226-2.phpt
index 6776b1a7ba1a3..51b13dfcf499c 100644
--- a/ext/soap/tests/bugs/bug36226-2.phpt
+++ b/ext/soap/tests/bugs/bug36226-2.phpt
@@ -93,11 +93,11 @@ class IVREvents {
}
?>
---EXPECT--
+--EXPECTF--
-object(IVREvents)#5 (6) {
+object(IVREvents)#%d (%d) {
["version"]=>
string(3) "1.0"
["activityId"]=>
@@ -111,7 +111,7 @@ object(IVREvents)#5 (6) {
["logOffEvent"]=>
array(1) {
[0]=>
- object(LogOffEvent)#6 (4) {
+ object(LogOffEvent)#%d (%d) {
["audienceMemberId"]=>
int(34567)
["timestamp"]=>
diff --git a/ext/soap/tests/bugs/bug36226.phpt b/ext/soap/tests/bugs/bug36226.phpt
index 73ce6ea80aa48..58b830bd9ab34 100644
--- a/ext/soap/tests/bugs/bug36226.phpt
+++ b/ext/soap/tests/bugs/bug36226.phpt
@@ -105,7 +105,7 @@ object(IVREvents)#%d (6) {
["logOnEvent"]=>
array(1) {
[0]=>
- object(LogOnEvent)#10 (2) {
+ object(LogOnEvent)#%d (%d) {
["audienceMemberId"]=>
int(34567)
["timestamp"]=>
diff --git a/ext/soap/tests/bugs/bug51561.phpt b/ext/soap/tests/bugs/bug51561.phpt
index 4b0c21eb8b22a..8c97cf8cfed57 100644
--- a/ext/soap/tests/bugs/bug51561.phpt
+++ b/ext/soap/tests/bugs/bug51561.phpt
@@ -2,6 +2,7 @@
Bug #51561 (SoapServer with a extended class and using sessions, lost the setPersistence())
--EXTENSIONS--
soap
+session
--SKIPIF--
query(""));
?>
---EXPECT--
-object(stdClass)#2 (1) {
+--EXPECTF--
+object(stdClass)#%d (%d) {
["result"]=>
- object(stdClass)#3 (4) {
+ object(stdClass)#%d (%d) {
["done"]=>
string(4) "true"
["queryLocator"]=>
NULL
["records"]=>
- object(SoapVar)#6 (6) {
+ object(SoapVar)#%d (%d) {
["enc_type"]=>
int(0)
["enc_value"]=>
- object(stdClass)#4 (3) {
+ object(stdClass)#%d (%d) {
["type"]=>
string(14) "CampaignMember"
["Id"]=>
@@ -44,7 +44,7 @@ object(stdClass)#2 (1) {
[0]=>
string(175) "701i0000001lreeAAA Sent 00Qi000001UrbYFEAZ "
["Lead"]=>
- object(stdClass)#5 (3) {
+ object(stdClass)#%d (%d) {
["type"]=>
string(4) "Lead"
["Id"]=>
diff --git a/ext/soap/tests/bugs/segfault_assertion_props.phpt b/ext/soap/tests/bugs/segfault_assertion_props.phpt
index 9d496d72967b0..cbe504abd02e7 100644
--- a/ext/soap/tests/bugs/segfault_assertion_props.phpt
+++ b/ext/soap/tests/bugs/segfault_assertion_props.phpt
@@ -32,8 +32,8 @@ class DummyClass {
$client = new TestSoapClient(__DIR__."/../classmap.wsdl", ['classmap' => ['Struct' => 'DummyClass']]);
var_dump($client->dotest2("???"));
?>
---EXPECT--
-object(DummyClass)#2 (2) {
+--EXPECTF--
+object(DummyClass)#%d (%d) {
["a"]=>
array(2) {
[0]=>
diff --git a/ext/soap/tests/classmap002.phpt b/ext/soap/tests/classmap002.phpt
index 6f27094ebf94d..4e0b5c22988ff 100644
--- a/ext/soap/tests/classmap002.phpt
+++ b/ext/soap/tests/classmap002.phpt
@@ -36,8 +36,8 @@ $ret = $client->dotest2("???");
var_dump($ret);
echo "ok\n";
?>
---EXPECT--
-object(book)#2 (2) {
+--EXPECTF--
+object(book)#%d (%d) {
["a"]=>
string(5) "Blaat"
["b"]=>
diff --git a/ext/soap/tests/classmap005.phpt b/ext/soap/tests/classmap005.phpt
index f46b5c5f9de92..0070659622348 100644
--- a/ext/soap/tests/classmap005.phpt
+++ b/ext/soap/tests/classmap005.phpt
@@ -40,8 +40,8 @@ $ret = $client->dotest2("???");
var_dump($ret);
echo "ok\n";
?>
---EXPECT--
-object(bookNs)#2 (2) {
+--EXPECTF--
+object(bookNs)#%d (%d) {
["a"]=>
string(5) "Blaat"
["b"]=>
diff --git a/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_001w.phpt b/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_001w.phpt
index d8de69e4a8e84..c63cf57d4bd00 100644
--- a/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_001w.phpt
+++ b/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_001w.phpt
@@ -17,12 +17,12 @@ $HTTP_RAW_POST_DATA = $client->__getlastrequest();
include("round3_groupE_list.inc");
echo "ok\n";
?>
---EXPECT--
+--EXPECTF--
1 arg1
1 arg1
-object(stdClass)#5 (3) {
+object(stdClass)#%d (%d) {
["varInt"]=>
int(1)
["varString"]=>
diff --git a/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_002w.phpt b/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_002w.phpt
index 8d87f59352c94..0d1d4c2fbb647 100644
--- a/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_002w.phpt
+++ b/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_002w.phpt
@@ -17,18 +17,18 @@ $HTTP_RAW_POST_DATA = $client->__getlastrequest();
include("round3_groupE_list.inc");
echo "ok\n";
?>
---EXPECT--
+--EXPECTF--
1 arg1 2 arg2
1 arg1 2 arg2
-object(stdClass)#6 (3) {
+object(stdClass)#%d (%d) {
["varInt"]=>
int(1)
["varString"]=>
string(4) "arg1"
["child"]=>
- object(stdClass)#7 (3) {
+ object(stdClass)#%d (%d) {
["varInt"]=>
int(2)
["varString"]=>
diff --git a/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_003w.phpt b/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_003w.phpt
index 326854241a0d7..a545a7d360347 100644
--- a/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_003w.phpt
+++ b/ext/soap/tests/interop/Round3/GroupE/r3_groupE_list_003w.phpt
@@ -17,24 +17,24 @@ $HTTP_RAW_POST_DATA = $client->__getlastrequest();
include("round3_groupE_list.inc");
echo "ok\n";
?>
---EXPECT--
+--EXPECTF--
1 arg1 2 arg2 3 arg3
1 arg1 2 arg2 3 arg3
-object(stdClass)#7 (3) {
+object(stdClass)#%d (%d) {
["varInt"]=>
int(1)
["varString"]=>
string(4) "arg1"
["child"]=>
- object(stdClass)#8 (3) {
+ object(stdClass)#%d (%d) {
["varInt"]=>
int(2)
["varString"]=>
string(4) "arg2"
["child"]=>
- object(stdClass)#9 (3) {
+ object(stdClass)#%d (%d) {
["varInt"]=>
int(3)
["varString"]=>
diff --git a/ext/soap/tests/schema/schema086.phpt b/ext/soap/tests/schema/schema086.phpt
index 4a770056c6fcf..dca9ed78af600 100644
--- a/ext/soap/tests/schema/schema086.phpt
+++ b/ext/soap/tests/schema/schema086.phpt
@@ -64,7 +64,7 @@ object(stdClass)#%d (8) {
}
2023-10-14T13:37:42.123400+02:00 13:37:42.123400+02:00 2023-10-14+02:00 2023-10+02:00 2023+02:00 --10-14+02:00 ---14+02:00 --10--+02:00
-object(stdClass)#9 (8) {
+object(stdClass)#%d (%d) {
["dateTime"]=>
string(32) "2023-10-14T13:37:42.123400+02:00"
["time"]=>
@@ -84,7 +84,7 @@ object(stdClass)#9 (8) {
}
2023-10-14T13:37:42.123400Z 13:37:42.123400Z 2023-10-14Z 2023-10Z 2023Z --10-14Z ---14Z --10--Z
-object(stdClass)#8 (8) {
+object(stdClass)#%d (%d) {
["dateTime"]=>
string(27) "2023-10-14T13:37:42.123400Z"
["time"]=>
diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php
index 00062610b7ea7..0b48d7109064b 100644
--- a/ext/sockets/sockets.stub.php
+++ b/ext/sockets/sockets.stub.php
@@ -1782,6 +1782,13 @@
*/
const SO_EXCLUSIVEADDRUSE = UNKNOWN;
#endif
+#if defined(SO_NOSIGPIPE)
+/**
+ * @var int
+ * @cvalue SO_NOSIGPIPE
+ */
+const SO_NOSIGPIPE = UNKNOWN;
+#endif
#if defined(TCP_QUICKACK)
/**
* @var int
diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h
index 50c5e114c8ed4..30a5aade8a0c0 100644
--- a/ext/sockets/sockets_arginfo.h
+++ b/ext/sockets/sockets_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 88a8e188f73c18c510eb984586b21109b347f251 */
+ * Stub hash: 70a996a13d739c1d2d165c73427cff59ebae1c5f */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(1, read, IS_ARRAY, 1)
@@ -1020,6 +1020,9 @@ static void register_sockets_symbols(int module_number)
#if defined(SO_EXCLUSIVEADDRUSE)
REGISTER_LONG_CONSTANT("SO_EXCLUSIVEADDRUSE", SO_EXCLUSIVEADDRUSE, CONST_PERSISTENT);
#endif
+#if defined(SO_NOSIGPIPE)
+ REGISTER_LONG_CONSTANT("SO_NOSIGPIPE", SO_NOSIGPIPE, CONST_PERSISTENT);
+#endif
#if defined(TCP_QUICKACK)
REGISTER_LONG_CONSTANT("TCP_QUICKACK", TCP_QUICKACK, CONST_PERSISTENT);
#endif
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index 261d9b19968a5..f1e42889a5e45 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -758,6 +758,49 @@ PHP_METHOD(SplObjectStorage, next)
intern->index++;
} /* }}} */
+/* {{{ Seek to position. */
+PHP_METHOD(SplObjectStorage, seek)
+{
+ zend_long position;
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &position) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (position < 0 || position >= zend_hash_num_elements(&intern->storage)) {
+ zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", position);
+ RETURN_THROWS();
+ }
+
+ if (position == 0) {
+ /* fast path */
+ zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
+ intern->index = 0;
+ } else if (position > intern->index) {
+ /* unlike the optimization below, it's not cheap to go to the end */
+ do {
+ zend_hash_move_forward_ex(&intern->storage, &intern->pos);
+ intern->index++;
+ } while (position > intern->index);
+ } else if (position < intern->index) {
+ /* optimization: check if it's more profitable to reset and do a forwards seek instead, it's cheap to reset */
+ if (intern->index - position > position) {
+ zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
+ intern->index = 0;
+ do {
+ zend_hash_move_forward_ex(&intern->storage, &intern->pos);
+ intern->index++;
+ } while (position > intern->index);
+ } else {
+ do {
+ zend_hash_move_backwards_ex(&intern->storage, &intern->pos);
+ intern->index--;
+ } while (position < intern->index);
+ }
+ }
+} /* }}} */
+
/* {{{ Serializes storage */
PHP_METHOD(SplObjectStorage, serialize)
{
@@ -1326,7 +1369,7 @@ PHP_MINIT_FUNCTION(spl_observer)
spl_ce_SplObserver = register_class_SplObserver();
spl_ce_SplSubject = register_class_SplSubject();
- spl_ce_SplObjectStorage = register_class_SplObjectStorage(zend_ce_countable, zend_ce_iterator, zend_ce_serializable, zend_ce_arrayaccess);
+ spl_ce_SplObjectStorage = register_class_SplObjectStorage(zend_ce_countable, spl_ce_SeekableIterator, zend_ce_serializable, zend_ce_arrayaccess);
spl_ce_SplObjectStorage->create_object = spl_SplObjectStorage_new;
spl_ce_SplObjectStorage->default_object_handlers = &spl_handler_SplObjectStorage;
diff --git a/ext/spl/spl_observer.stub.php b/ext/spl/spl_observer.stub.php
index 24d4fd08aa746..9e78272cf3506 100644
--- a/ext/spl/spl_observer.stub.php
+++ b/ext/spl/spl_observer.stub.php
@@ -20,7 +20,7 @@ public function detach(SplObserver $observer): void;
public function notify(): void;
}
-class SplObjectStorage implements Countable, Iterator, Serializable, ArrayAccess
+class SplObjectStorage implements Countable, SeekableIterator, Serializable, ArrayAccess
{
/** @tentative-return-type */
public function attach(object $object, mixed $info = null): void {}
@@ -64,6 +64,8 @@ public function current(): object {}
/** @tentative-return-type */
public function next(): void {}
+ public function seek(int $offset): void {}
+
/** @tentative-return-type */
public function unserialize(string $data): void {}
diff --git a/ext/spl/spl_observer_arginfo.h b/ext/spl/spl_observer_arginfo.h
index 913e481e57d52..730f4c279c254 100644
--- a/ext/spl/spl_observer_arginfo.h
+++ b/ext/spl/spl_observer_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 1fc23a91e7531eeb73729d4ad44addf0190c3a62 */
+ * Stub hash: a846c9dd240b6f0666cd5e805abfacabe360cf4c */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplObserver_update, 0, 1, IS_VOID, 0)
ZEND_ARG_OBJ_INFO(0, subject, SplSubject, 0)
@@ -59,6 +59,10 @@ ZEND_END_ARG_INFO()
#define arginfo_class_SplObjectStorage_next arginfo_class_SplSubject_notify
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SplObjectStorage_seek, 0, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, offset, IS_LONG, 0)
+ZEND_END_ARG_INFO()
+
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SplObjectStorage_unserialize, 0, 1, IS_VOID, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -147,6 +151,7 @@ ZEND_METHOD(SplObjectStorage, valid);
ZEND_METHOD(SplObjectStorage, key);
ZEND_METHOD(SplObjectStorage, current);
ZEND_METHOD(SplObjectStorage, next);
+ZEND_METHOD(SplObjectStorage, seek);
ZEND_METHOD(SplObjectStorage, unserialize);
ZEND_METHOD(SplObjectStorage, serialize);
ZEND_METHOD(SplObjectStorage, offsetGet);
@@ -194,6 +199,7 @@ static const zend_function_entry class_SplObjectStorage_methods[] = {
ZEND_ME(SplObjectStorage, key, arginfo_class_SplObjectStorage_key, ZEND_ACC_PUBLIC)
ZEND_ME(SplObjectStorage, current, arginfo_class_SplObjectStorage_current, ZEND_ACC_PUBLIC)
ZEND_ME(SplObjectStorage, next, arginfo_class_SplObjectStorage_next, ZEND_ACC_PUBLIC)
+ ZEND_ME(SplObjectStorage, seek, arginfo_class_SplObjectStorage_seek, ZEND_ACC_PUBLIC)
ZEND_ME(SplObjectStorage, unserialize, arginfo_class_SplObjectStorage_unserialize, ZEND_ACC_PUBLIC)
ZEND_ME(SplObjectStorage, serialize, arginfo_class_SplObjectStorage_serialize, ZEND_ACC_PUBLIC)
ZEND_RAW_FENTRY("offsetExists", zim_SplObjectStorage_contains, arginfo_class_SplObjectStorage_offsetExists, ZEND_ACC_PUBLIC, NULL, NULL)
@@ -244,13 +250,13 @@ static zend_class_entry *register_class_SplSubject(void)
return class_entry;
}
-static zend_class_entry *register_class_SplObjectStorage(zend_class_entry *class_entry_Countable, zend_class_entry *class_entry_Iterator, zend_class_entry *class_entry_Serializable, zend_class_entry *class_entry_ArrayAccess)
+static zend_class_entry *register_class_SplObjectStorage(zend_class_entry *class_entry_Countable, zend_class_entry *class_entry_SeekableIterator, zend_class_entry *class_entry_Serializable, zend_class_entry *class_entry_ArrayAccess)
{
zend_class_entry ce, *class_entry;
INIT_CLASS_ENTRY(ce, "SplObjectStorage", class_SplObjectStorage_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
- zend_class_implements(class_entry, 4, class_entry_Countable, class_entry_Iterator, class_entry_Serializable, class_entry_ArrayAccess);
+ zend_class_implements(class_entry, 4, class_entry_Countable, class_entry_SeekableIterator, class_entry_Serializable, class_entry_ArrayAccess);
return class_entry;
}
diff --git a/ext/spl/tests/SplObjectStorage_seek.phpt b/ext/spl/tests/SplObjectStorage_seek.phpt
new file mode 100644
index 0000000000000..f51a285d06007
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage_seek.phpt
@@ -0,0 +1,139 @@
+--TEST--
+SplObjectStorage::seek() basic functionality
+--FILE--
+seek(-1);
+} catch (OutOfBoundsException $e) {
+ echo $e->getMessage(), "\n";
+}
+try {
+ $storage->seek(5);
+} catch (OutOfBoundsException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+var_dump($storage->key());
+var_dump($storage->current());
+
+echo "--- Normal cases ---\n";
+
+$storage->seek(2);
+var_dump($storage->key());
+var_dump($storage->current());
+
+$storage->seek(1);
+var_dump($storage->key());
+var_dump($storage->current());
+
+$storage->seek(4);
+var_dump($storage->key());
+var_dump($storage->current());
+
+$storage->seek(0);
+var_dump($storage->key());
+var_dump($storage->current());
+
+$storage->seek(3);
+var_dump($storage->key());
+var_dump($storage->current());
+
+$storage->seek(3);
+var_dump($storage->key());
+var_dump($storage->current());
+
+echo "--- With holes cases ---\n";
+
+$storage->detach($b);
+$storage->detach($d);
+
+foreach (range(0, 2) as $index) {
+ $storage->seek($index);
+ var_dump($storage->key());
+ var_dump($storage->current());
+}
+
+try {
+ $storage->seek(3);
+} catch (OutOfBoundsException $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+--- Error cases ---
+Seek position -1 is out of range
+Seek position 5 is out of range
+int(0)
+object(Test)#1 (1) {
+ ["marker"]=>
+ string(1) "a"
+}
+--- Normal cases ---
+int(2)
+object(Test)#3 (1) {
+ ["marker"]=>
+ string(1) "c"
+}
+int(1)
+object(Test)#2 (1) {
+ ["marker"]=>
+ string(1) "b"
+}
+int(4)
+object(Test)#5 (1) {
+ ["marker"]=>
+ string(1) "e"
+}
+int(0)
+object(Test)#1 (1) {
+ ["marker"]=>
+ string(1) "a"
+}
+int(3)
+object(Test)#4 (1) {
+ ["marker"]=>
+ string(1) "d"
+}
+int(3)
+object(Test)#4 (1) {
+ ["marker"]=>
+ string(1) "d"
+}
+--- With holes cases ---
+int(0)
+object(Test)#1 (1) {
+ ["marker"]=>
+ string(1) "a"
+}
+int(1)
+object(Test)#3 (1) {
+ ["marker"]=>
+ string(1) "c"
+}
+int(2)
+object(Test)#5 (1) {
+ ["marker"]=>
+ string(1) "e"
+}
+Seek position 3 is out of range
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index c24a63cc88a45..d1ab0164567a9 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -44,6 +44,13 @@ static int php_sqlite3_compare_stmt_zval_free(php_sqlite3_free_list **free_list,
RETURN_THROWS(); \
}
+#define SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE(db_obj, member, class_name, trampoline_fcc) \
+ if (!(db_obj) || !(member)) { \
+ zend_release_fcall_info_cache((trampoline_fcc)); \
+ zend_throw_error(NULL, "The " #class_name " object has not been correctly initialised or is already closed"); \
+ RETURN_THROWS(); \
+ }
+
#define SQLITE3_CHECK_INITIALIZED_STMT(member, class_name) \
if (!(member)) { \
zend_throw_error(NULL, "The " #class_name " object has not been correctly initialised or is already closed"); \
@@ -936,19 +943,22 @@ PHP_METHOD(SQLite3, createFunction)
php_sqlite3_func *func;
char *sql_func;
size_t sql_func_len;
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fcc = empty_fcall_info_cache;
zend_long sql_func_num_args = -1;
zend_long flags = 0;
db_obj = Z_SQLITE3_DB_P(object);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sf|ll", &sql_func, &sql_func_len, &fci, &fcc, &sql_func_num_args, &flags) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sF|ll", &sql_func, &sql_func_len, &fci, &fcc, &sql_func_num_args, &flags) == FAILURE) {
+ zend_release_fcall_info_cache(&fcc);
RETURN_THROWS();
}
- SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
+ SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE(db_obj, db_obj->initialised, SQLite3, &fcc);
if (!sql_func_len) {
+ /* TODO Add warning/ValueError that name cannot be empty? */
+ zend_release_fcall_info_cache(&fcc);
RETURN_FALSE;
}
@@ -956,13 +966,6 @@ PHP_METHOD(SQLite3, createFunction)
if (sqlite3_create_function(db_obj->db, sql_func, sql_func_num_args, flags | SQLITE_UTF8, func, php_sqlite3_callback_func, NULL, NULL) == SQLITE_OK) {
func->func_name = estrdup(sql_func);
-
- if (!ZEND_FCC_INITIALIZED(fcc)) {
- zend_is_callable_ex(&fci.function_name, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL);
- /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
- * with it outselves. It is important that it is not refetched on every call,
- * because calls may occur from different scopes. */
- }
zend_fcc_dup(&func->func, &fcc);
func->argc = sql_func_num_args;
@@ -972,6 +975,7 @@ PHP_METHOD(SQLite3, createFunction)
RETURN_TRUE;
}
efree(func);
+ zend_release_fcall_info_cache(&fcc);
RETURN_FALSE;
}
@@ -985,19 +989,26 @@ PHP_METHOD(SQLite3, createAggregate)
php_sqlite3_func *func;
char *sql_func;
size_t sql_func_len;
- zend_fcall_info step_fci, fini_fci;
- zend_fcall_info_cache step_fcc, fini_fcc;
+ zend_fcall_info step_fci = empty_fcall_info;
+ zend_fcall_info_cache step_fcc = empty_fcall_info_cache;
+ zend_fcall_info fini_fci = empty_fcall_info;
+ zend_fcall_info_cache fini_fcc = empty_fcall_info_cache;
zend_long sql_func_num_args = -1;
db_obj = Z_SQLITE3_DB_P(object);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sff|l", &sql_func, &sql_func_len, &step_fci, &step_fcc, &fini_fci, &fini_fcc, &sql_func_num_args) == FAILURE) {
- RETURN_THROWS();
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sFF|l", &sql_func, &sql_func_len, &step_fci, &step_fcc, &fini_fci, &fini_fcc, &sql_func_num_args) == FAILURE) {
+ goto error;
}
- SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
+ /* Cannot use SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE() as we have 2 FCCs */
+ if (!db_obj || !db_obj->initialised) {
+ zend_throw_error(NULL, "The SQLite3 object has not been correctly initialised or is already closed");
+ goto error;
+ }
if (!sql_func_len) {
- RETURN_FALSE;
+ /* TODO Add warning/ValueError that name cannot be empty? */
+ goto error;
}
func = (php_sqlite3_func *)ecalloc(1, sizeof(*func));
@@ -1005,19 +1016,7 @@ PHP_METHOD(SQLite3, createAggregate)
if (sqlite3_create_function(db_obj->db, sql_func, sql_func_num_args, SQLITE_UTF8, func, NULL, php_sqlite3_callback_step, php_sqlite3_callback_final) == SQLITE_OK) {
func->func_name = estrdup(sql_func);
- if (!ZEND_FCC_INITIALIZED(step_fcc)) {
- /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
- * with it outselves. It is important that it is not refetched on every call,
- * because calls may occur from different scopes. */
- zend_is_callable_ex(&step_fci.function_name, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &step_fcc, NULL);
- }
zend_fcc_dup(&func->step, &step_fcc);
- if (!ZEND_FCC_INITIALIZED(fini_fcc)) {
- /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
- * with it outselves. It is important that it is not refetched on every call,
- * because calls may occur from different scopes. */
- zend_is_callable_ex(&fini_fci.function_name, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fini_fcc, NULL);
- }
zend_fcc_dup(&func->fini, &fini_fcc);
func->argc = sql_func_num_args;
@@ -1028,6 +1027,10 @@ PHP_METHOD(SQLite3, createAggregate)
}
efree(func);
+ error:
+ zend_release_fcall_info_cache(&step_fcc);
+ zend_release_fcall_info_cache(&fini_fcc);
+
RETURN_FALSE;
}
/* }}} */
@@ -1040,17 +1043,19 @@ PHP_METHOD(SQLite3, createCollation)
php_sqlite3_collation *collation;
char *collation_name;
size_t collation_name_len;
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fcc = empty_fcall_info_cache;
db_obj = Z_SQLITE3_DB_P(object);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "sf", &collation_name, &collation_name_len, &fci, &fcc) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sF", &collation_name, &collation_name_len, &fci, &fcc) == FAILURE) {
RETURN_THROWS();
}
- SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
+ SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE(db_obj, db_obj->initialised, SQLite3, &fcc);
if (!collation_name_len) {
+ /* TODO Add warning/ValueError that name cannot be empty? */
+ zend_release_fcall_info_cache(&fcc);
RETURN_FALSE;
}
@@ -1058,12 +1063,6 @@ PHP_METHOD(SQLite3, createCollation)
if (sqlite3_create_collation(db_obj->db, collation_name, SQLITE_UTF8, collation, php_sqlite3_callback_compare) == SQLITE_OK) {
collation->collation_name = estrdup(collation_name);
- if (!ZEND_FCC_INITIALIZED(fcc)) {
- /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
- * with it outselves. It is important that it is not refetched on every call,
- * because calls may occur from different scopes. */
- zend_is_callable_ex(&fci.function_name, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL);
- }
zend_fcc_dup(&collation->cmp_func, &fcc);
collation->next = db_obj->collations;
@@ -1072,6 +1071,7 @@ PHP_METHOD(SQLite3, createCollation)
RETURN_TRUE;
}
efree(collation);
+ zend_release_fcall_info_cache(&fcc);
RETURN_FALSE;
}
@@ -1310,17 +1310,16 @@ PHP_METHOD(SQLite3, enableExceptions)
/* {{{ Register a callback function to be used as an authorizer by SQLite. The callback should return SQLite3::OK, SQLite3::IGNORE or SQLite3::DENY. */
PHP_METHOD(SQLite3, setAuthorizer)
{
- php_sqlite3_db_object *db_obj;
- zval *object = ZEND_THIS;
- db_obj = Z_SQLITE3_DB_P(object);
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fcc = empty_fcall_info_cache;
ZEND_PARSE_PARAMETERS_START(1, 1)
- Z_PARAM_FUNC_OR_NULL(fci, fcc)
+ Z_PARAM_FUNC_NO_TRAMPOLINE_FREE_OR_NULL(fci, fcc)
ZEND_PARSE_PARAMETERS_END();
- SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
+ php_sqlite3_db_object *db_obj = Z_SQLITE3_DB_P(ZEND_THIS);
+
+ SQLITE3_CHECK_INITIALIZED_FREE_TRAMPOLINE(db_obj, db_obj->initialised, SQLite3, &fcc);
/* Clear previously set callback */
if (ZEND_FCC_INITIALIZED(db_obj->authorizer_fcc)) {
@@ -1329,14 +1328,7 @@ PHP_METHOD(SQLite3, setAuthorizer)
/* Only enable userland authorizer if argument is not NULL */
if (ZEND_FCI_INITIALIZED(fci)) {
- if (!ZEND_FCC_INITIALIZED(fcc)) {
- zend_is_callable_ex(&fci.function_name, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL);
- /* Call trampoline has been cleared by zpp. Refetch it, because we want to deal
- * with it outselves. It is important that it is not refetched on every call,
- * because calls may occur from different scopes. */
- }
- db_obj->authorizer_fcc = fcc;
- zend_fcc_addref(&db_obj->authorizer_fcc);
+ zend_fcc_dup(&db_obj->authorizer_fcc, &fcc);
}
RETURN_TRUE;
diff --git a/ext/sqlite3/sqlite3.stub.php b/ext/sqlite3/sqlite3.stub.php
index c88ec780b021f..3545da36acfcd 100644
--- a/ext/sqlite3/sqlite3.stub.php
+++ b/ext/sqlite3/sqlite3.stub.php
@@ -78,197 +78,86 @@ class SQLite3Exception extends \Exception
/** @not-serializable */
class SQLite3
{
- /**
- * @cvalue SQLITE_OK
- * @link sqlite3.class.constants.ok
- */
+ /** @cvalue SQLITE_OK */
public const int OK = UNKNOWN;
/* Constants for authorizer return */
- /**
- * @cvalue SQLITE_DENY
- * @link sqlite3.class.constants.deny
- */
+ /** @cvalue SQLITE_DENY */
public const int DENY = UNKNOWN;
- /**
- * @cvalue SQLITE_IGNORE
- * @link sqlite3.class.constants.ignore
- */
+ /** @cvalue SQLITE_IGNORE */
public const int IGNORE = UNKNOWN;
/* Constants for authorizer actions */
- /**
- * @cvalue SQLITE_CREATE_INDEX
- * @link sqlite3.class.constants.create-index
- */
+ /** @cvalue SQLITE_CREATE_INDEX */
public const int CREATE_INDEX = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_TABLE
- * @link sqlite3.class.constants.create-table
- */
+ /** @cvalue SQLITE_CREATE_TABLE */
public const int CREATE_TABLE = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_TEMP_INDEX
- * @link sqlite3.class.constants.create-temp-index
- */
+ /** @cvalue SQLITE_CREATE_TEMP_INDEX */
public const int CREATE_TEMP_INDEX = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_TEMP_TABLE
- * @link sqlite3.class.constants.create-temp-table
- */
+ /** @cvalue SQLITE_CREATE_TEMP_TABLE */
public const int CREATE_TEMP_TABLE = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_TEMP_TRIGGER
- * @link sqlite3.class.constants.create-temp-trigger
- */
+ /** @cvalue SQLITE_CREATE_TEMP_TRIGGER */
public const int CREATE_TEMP_TRIGGER = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_TEMP_VIEW
- * @link sqlite3.class.constants.create-temp-view
- */
+ /** @cvalue SQLITE_CREATE_TEMP_VIEW */
public const int CREATE_TEMP_VIEW = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_TRIGGER
- * @link sqlite3.class.constants.create-trigger
- */
+ /** @cvalue SQLITE_CREATE_TRIGGER */
public const int CREATE_TRIGGER = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_VIEW
- * @link sqlite3.class.constants.create-view
- */
+ /** @cvalue SQLITE_CREATE_VIEW */
public const int CREATE_VIEW = UNKNOWN;
- /**
- * @cvalue SQLITE_DELETE
- * @link sqlite3.class.constants.delete
- */
+ /** @cvalue SQLITE_DELETE */
public const int DELETE = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_INDEX
- * @link sqlite3.class.constants.drop-index
- */
+ /** @cvalue SQLITE_DROP_INDEX */
public const int DROP_INDEX = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_TABLE
- * @link sqlite3.class.constants.drop-table
- */
+ /** @cvalue SQLITE_DROP_TABLE */
public const int DROP_TABLE = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_TEMP_INDEX
- * @link sqlite3.class.constants.drop-temp-index
- */
+ /** @cvalue SQLITE_DROP_TEMP_INDEX */
public const int DROP_TEMP_INDEX = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_TEMP_TABLE
- * @link sqlite3.class.constants.drop-temp-table
- */
+ /** @cvalue SQLITE_DROP_TEMP_TABLE */
public const int DROP_TEMP_TABLE = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_TEMP_TRIGGER
- * @link sqlite3.class.constants.drop-temp-trigger
- */
+ /** @cvalue SQLITE_DROP_TEMP_TRIGGER */
public const int DROP_TEMP_TRIGGER = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_TEMP_VIEW
- * @link sqlite3.class.constants.drop-temp-view
- */
+ /** @cvalue SQLITE_DROP_TEMP_VIEW */
public const int DROP_TEMP_VIEW = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_TRIGGER
- * @link sqlite3.class.constants.drop-trigger
- */
+ /** @cvalue SQLITE_DROP_TRIGGER */
public const int DROP_TRIGGER = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_VIEW
- * @link sqlite3.class.constants.drop-view
- */
+ /** @cvalue SQLITE_DROP_VIEW */
public const int DROP_VIEW = UNKNOWN;
- /**
- * @cvalue SQLITE_INSERT
- * @link sqlite3.class.constants.insert
- */
+ /** @cvalue SQLITE_INSERT */
public const int INSERT = UNKNOWN;
- /**
- * @cvalue SQLITE_PRAGMA
- * @link sqlite3.class.constants.pragma
- */
+ /** @cvalue SQLITE_PRAGMA */
public const int PRAGMA = UNKNOWN;
- /**
- * @cvalue SQLITE_READ
- * @link sqlite3.class.constants.read
- */
+ /** @cvalue SQLITE_READ */
public const int READ = UNKNOWN;
- /**
- * @cvalue SQLITE_SELECT
- * @link sqlite3.class.constants.select
- */
+ /** @cvalue SQLITE_SELECT */
public const int SELECT = UNKNOWN;
- /**
- * @cvalue SQLITE_TRANSACTION
- * @link sqlite3.class.constants.transaction
- */
+ /** @cvalue SQLITE_TRANSACTION */
public const int TRANSACTION = UNKNOWN;
- /**
- * @cvalue SQLITE_UPDATE
- * @link sqlite3.class.constants.update
- */
+ /** @cvalue SQLITE_UPDATE */
public const int UPDATE = UNKNOWN;
- /**
- * @cvalue SQLITE_ATTACH
- * @link sqlite3.class.constants.attach
- */
+ /** @cvalue SQLITE_ATTACH */
public const int ATTACH = UNKNOWN;
- /**
- * @cvalue SQLITE_DETACH
- * @link sqlite3.class.constants.detach
- */
+ /** @cvalue SQLITE_DETACH */
public const int DETACH = UNKNOWN;
- /**
- * @cvalue SQLITE_ALTER_TABLE
- * @link sqlite3.class.constants.alter-table
- */
+ /** @cvalue SQLITE_ALTER_TABLE */
public const int ALTER_TABLE = UNKNOWN;
- /**
- * @cvalue SQLITE_REINDEX
- * @link sqlite3.class.constants.reindex
- */
+ /** @cvalue SQLITE_REINDEX */
public const int REINDEX = UNKNOWN;
- /**
- * @cvalue SQLITE_ANALYZE
- * @link sqlite3.class.constants.analyze
- */
+ /** @cvalue SQLITE_ANALYZE */
public const int ANALYZE = UNKNOWN;
- /**
- * @cvalue SQLITE_CREATE_VTABLE
- * @link sqlite3.class.constants.create-vtable
- */
+ /** @cvalue SQLITE_CREATE_VTABLE */
public const int CREATE_VTABLE = UNKNOWN;
- /**
- * @cvalue SQLITE_DROP_VTABLE
- * @link sqlite3.class.constants.drop-vtable
- */
+ /** @cvalue SQLITE_DROP_VTABLE */
public const int DROP_VTABLE = UNKNOWN;
- /**
- * @cvalue SQLITE_FUNCTION
- * @link sqlite3.class.constants.function
- */
+ /** @cvalue SQLITE_FUNCTION */
public const int FUNCTION = UNKNOWN;
- /**
- * @cvalue SQLITE_SAVEPOINT
- * @link sqlite3.class.constants.savepoint
- */
+ /** @cvalue SQLITE_SAVEPOINT */
public const int SAVEPOINT = UNKNOWN;
- /**
- * @cvalue SQLITE_COPY
- * @link sqlite3.class.constants.copy
- */
+ /** @cvalue SQLITE_COPY */
public const int COPY = UNKNOWN;
#ifdef SQLITE_RECURSIVE
- /**
- * @cvalue SQLITE_RECURSIVE
- * @link sqlite3.class.constants.recursive
- */
+ /** @cvalue SQLITE_RECURSIVE */
public const int RECURSIVE = UNKNOWN;
#endif
diff --git a/ext/sqlite3/sqlite3_arginfo.h b/ext/sqlite3/sqlite3_arginfo.h
index 46b2fb820a37c..9c813bace265c 100644
--- a/ext/sqlite3/sqlite3_arginfo.h
+++ b/ext/sqlite3/sqlite3_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 4474d0a8fb45923895d172af430663932675a4ac */
+ * Stub hash: edf910997672a2b8d8b5c25e8a7a4ff1c135e7b1 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SQLite3___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
diff --git a/ext/sqlite3/tests/sqlite3_trampoline_create_aggregate_no_leak.phpt b/ext/sqlite3/tests/sqlite3_trampoline_create_aggregate_no_leak.phpt
new file mode 100644
index 0000000000000..31f8a2cbd47b6
--- /dev/null
+++ b/ext/sqlite3/tests/sqlite3_trampoline_create_aggregate_no_leak.phpt
@@ -0,0 +1,86 @@
+--TEST--
+SQLite3::createAggregate() use F ZPP for trampoline callback and does not leak
+--EXTENSIONS--
+sqlite3
+--FILE--
+ 0, 'values' => []];
+ }
+ $context['total'] += (int) $arguments[2];
+ $context['values'][] = $context['total'];
+ return $context;
+ }
+}
+$o = new TrampolineTest();
+$step = [$o, 'step'];
+$finalize = [$o, 'finalize'];
+
+var_dump($db->createAggregate('', $step, $finalize, 1));
+
+try {
+ var_dump($db->createAggregate(new stdClass(), $step, $finalize, new stdClass()));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+try {
+ var_dump($db->createAggregate('S', $step, $finalize, new stdClass()));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+try {
+ var_dump($db->createAggregate('S', $step, 'no_func', 1));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+try {
+ var_dump($db->createAggregate('S', 'no_func', $finalize, 1));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+try {
+ var_dump($db->createAggregate('S', $step, $finalize, 'not a number'));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Invalid SQLite3 object:\n";
+$rc = new ReflectionClass(SQLite3::class);
+$obj = $rc->newInstanceWithoutConstructor();
+
+try {
+ var_dump($obj->createAggregate('S', $step, $finalize, 1));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+var_dump($db->createAggregate('S', $step, $finalize, 1));
+
+echo "Closing database\n";
+var_dump($db->close());
+echo "Done\n";
+?>
+--EXPECT--
+bool(false)
+TypeError: SQLite3::createAggregate(): Argument #1 ($name) must be of type string, stdClass given
+TypeError: SQLite3::createAggregate(): Argument #4 ($argCount) must be of type int, stdClass given
+TypeError: SQLite3::createAggregate(): Argument #3 ($finalCallback) must be a valid callback, function "no_func" not found or invalid function name
+TypeError: SQLite3::createAggregate(): Argument #2 ($stepCallback) must be a valid callback, function "no_func" not found or invalid function name
+TypeError: SQLite3::createAggregate(): Argument #4 ($argCount) must be of type int, string given
+Invalid SQLite3 object:
+Error: The SQLite3 object has not been correctly initialised or is already closed
+bool(true)
+Closing database
+bool(true)
+Done
diff --git a/ext/sqlite3/tests/sqlite3_trampoline_createcollation_no_leak.phpt b/ext/sqlite3/tests/sqlite3_trampoline_createcollation_no_leak.phpt
new file mode 100644
index 0000000000000..f1c4be0f9c789
--- /dev/null
+++ b/ext/sqlite3/tests/sqlite3_trampoline_createcollation_no_leak.phpt
@@ -0,0 +1,51 @@
+--TEST--
+SQLite3::createFunction use F ZPP for trampoline callback and does not leak
+--EXTENSIONS--
+sqlite3
+--FILE--
+createCollation('', $callback));
+
+try {
+ var_dump($db->createCollation(new stdClass(), $callback));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+try {
+ var_dump($db->createCollation('NAT', $callback, new stdClass()));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Invalid SQLite3 object:\n";
+$rc = new ReflectionClass(SQLite3::class);
+$obj = $rc->newInstanceWithoutConstructor();
+
+try {
+ var_dump($obj->createCollation('NAT', $callback));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+var_dump($db->createCollation('NAT', $callback));
+
+?>
+--EXPECT--
+bool(false)
+TypeError: SQLite3::createCollation(): Argument #1 ($name) must be of type string, stdClass given
+ArgumentCountError: SQLite3::createCollation() expects exactly 2 arguments, 3 given
+Invalid SQLite3 object:
+Error: The SQLite3 object has not been correctly initialised or is already closed
+bool(true)
diff --git a/ext/sqlite3/tests/sqlite3_trampoline_createfunction_no_leak.phpt b/ext/sqlite3/tests/sqlite3_trampoline_createfunction_no_leak.phpt
new file mode 100644
index 0000000000000..dea0f6c5210b9
--- /dev/null
+++ b/ext/sqlite3/tests/sqlite3_trampoline_createfunction_no_leak.phpt
@@ -0,0 +1,52 @@
+--TEST--
+SQLite3::createFunction use F ZPP for trampoline callback and does not leak
+--EXTENSIONS--
+sqlite3
+--FILE--
+createfunction('', $callback));
+
+try {
+ var_dump($db->createfunction(new stdClass(), $callback, new stdClass()));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+try {
+ var_dump($db->createfunction('strtoupper', $callback, new stdClass()));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+echo "Invalid SQLite3 object:\n";
+$rc = new ReflectionClass(SQLite3::class);
+$obj = $rc->newInstanceWithoutConstructor();
+
+try {
+ var_dump($obj->createfunction('strtoupper', $callback));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+var_dump($db->createfunction('strtoupper', $callback));
+
+?>
+--EXPECT--
+bool(false)
+TypeError: SQLite3::createFunction(): Argument #1 ($name) must be of type string, stdClass given
+TypeError: SQLite3::createFunction(): Argument #3 ($argCount) must be of type int, stdClass given
+Invalid SQLite3 object:
+Error: The SQLite3 object has not been correctly initialised or is already closed
+bool(true)
diff --git a/ext/sqlite3/tests/sqlite3_trampoline_setauthorizer_no_leak.phpt b/ext/sqlite3/tests/sqlite3_trampoline_setauthorizer_no_leak.phpt
new file mode 100644
index 0000000000000..331f4e1e63c94
--- /dev/null
+++ b/ext/sqlite3/tests/sqlite3_trampoline_setauthorizer_no_leak.phpt
@@ -0,0 +1,41 @@
+--TEST--
+SQLite3::setAuthorizer use F ZPP for trampoline callback and does not leak
+--EXTENSIONS--
+sqlite3
+--FILE--
+enableExceptions(true);
+
+echo "Invalid SQLite3 object:\n";
+$rc = new ReflectionClass(SQLite3::class);
+$obj = $rc->newInstanceWithoutConstructor();
+
+try {
+ var_dump($obj->setAuthorizer($callback));
+} catch (\Throwable $e) {
+ echo $e::class, ': ', $e->getMessage(), PHP_EOL;
+}
+
+$db->setAuthorizer($callback);
+
+?>
+DONE
+--EXPECT--
+Invalid SQLite3 object:
+Error: The SQLite3 object has not been correctly initialised or is already closed
+DONE
diff --git a/ext/sqlite3/tests/sqlite3_trampoline_setauthorizer_null.phpt b/ext/sqlite3/tests/sqlite3_trampoline_setauthorizer_null.phpt
new file mode 100644
index 0000000000000..2cea279f077ed
--- /dev/null
+++ b/ext/sqlite3/tests/sqlite3_trampoline_setauthorizer_null.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SQLite3 user authorizer null
+--EXTENSIONS--
+sqlite3
+--FILE--
+enableExceptions(true);
+
+$db->setAuthorizer(null);
+
+// This query should be accepted
+var_dump($db->querySingle('SELECT 1;'));
+
+try {
+ // This one should fail
+ var_dump($db->querySingle('CREATE TABLE test (a, b);'));
+} catch (\Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+
+?>
+--EXPECT--
+int(1)
+NULL
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 95768bf90aa5d..d93ac630c3723 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -40,7 +40,6 @@
#include "zend_smart_str.h"
#include "zend_bitset.h"
#include "zend_exceptions.h"
-#include "ext/spl/spl_array.h"
#include "ext/random/php_random.h"
#include "zend_frameless_function.h"
diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c
index 31e5c57435639..69ef1f3dffdcd 100644
--- a/ext/standard/browscap.c
+++ b/ext/standard/browscap.c
@@ -18,7 +18,6 @@
#include "php_browscap.h"
#include "php_ini.h"
#include "php_string.h"
-#include "ext/pcre/php_pcre.h"
#include "zend_ini_scanner.h"
#include "zend_globals.h"
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index 2bcef360f6d49..d58c7ebac98b8 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -275,22 +275,6 @@ else
PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
fi
-dnl
-dnl Check for __attribute__ ((__aligned__)) support in the compiler
-dnl
-AC_CACHE_CHECK(whether the compiler supports aligned attribute, ac_cv_attribute_aligned,[
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-]],[[
- unsigned char test[32] __attribute__ ((__aligned__ (__alignof__ (int))));
-]])],[
- ac_cv_attribute_aligned=yes
-],[
- ac_cv_attribute_aligned=no
-])])
-if test "$ac_cv_attribute_aligned" = "yes"; then
- AC_DEFINE([HAVE_ATTRIBUTE_ALIGNED], 1, [whether the compiler supports __attribute__ ((__aligned__))])
-fi
-
if test "$cross_compiling" = yes ; then
case $host_alias in
*linux*)
diff --git a/ext/standard/image.c b/ext/standard/image.c
index d5455963f3120..d064d9d4fd3b4 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -749,10 +749,10 @@ static signed short php_ifd_get16s(void *Short, int motorola_intel)
static int php_ifd_get32s(void *Long, int motorola_intel)
{
if (motorola_intel) {
- return ((( char *)Long)[0] << 24) | (((unsigned char *)Long)[1] << 16)
- | (((unsigned char *)Long)[2] << 8 ) | (((unsigned char *)Long)[3] << 0 );
+ return ((unsigned)((( char *)Long)[0]) << 24) | (((unsigned char *)Long)[1] << 16)
+ | ((( char *)Long)[2] << 8 ) | (((unsigned char *)Long)[3] << 0 );
} else {
- return ((( char *)Long)[3] << 24) | (((unsigned char *)Long)[2] << 16)
+ return ((unsigned)((( char *)Long)[3]) << 24) | (((unsigned char *)Long)[2] << 16)
| (((unsigned char *)Long)[1] << 8 ) | (((unsigned char *)Long)[0] << 0 );
}
}
diff --git a/ext/standard/php_math.h b/ext/standard/php_math.h
index 6ff895cce3c8d..9ebd600537fdb 100644
--- a/ext/standard/php_math.h
+++ b/ext/standard/php_math.h
@@ -28,6 +28,7 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret);
PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base);
#include
+#include "php_math_round_mode.h"
#ifndef M_E
#define M_E 2.7182818284590452354 /* e */
@@ -97,37 +98,4 @@ PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base);
#define M_SQRT3 1.73205080756887729352 /* sqrt(3) */
#endif
-/* Define rounding modes (all are round-to-nearest) */
-#ifndef PHP_ROUND_HALF_UP
-#define PHP_ROUND_HALF_UP 0x01 /* Arithmetic rounding, up == away from zero */
-#endif
-
-#ifndef PHP_ROUND_HALF_DOWN
-#define PHP_ROUND_HALF_DOWN 0x02 /* Arithmetic rounding, down == towards zero */
-#endif
-
-#ifndef PHP_ROUND_HALF_EVEN
-#define PHP_ROUND_HALF_EVEN 0x03 /* Banker's rounding */
-#endif
-
-#ifndef PHP_ROUND_HALF_ODD
-#define PHP_ROUND_HALF_ODD 0x04
-#endif
-
-#ifndef PHP_ROUND_CEILING
-#define PHP_ROUND_CEILING 0x05
-#endif
-
-#ifndef PHP_ROUND_FLOOR
-#define PHP_ROUND_FLOOR 0x06
-#endif
-
-#ifndef PHP_ROUND_TOWARD_ZERO
-#define PHP_ROUND_TOWARD_ZERO 0x07
-#endif
-
-#ifndef PHP_ROUND_AWAY_FROM_ZERO
-#define PHP_ROUND_AWAY_FROM_ZERO 0x08
-#endif
-
#endif /* PHP_MATH_H */
diff --git a/ext/standard/php_math_round_mode.h b/ext/standard/php_math_round_mode.h
new file mode 100644
index 0000000000000..d4c11a8312fb2
--- /dev/null
+++ b/ext/standard/php_math_round_mode.h
@@ -0,0 +1,49 @@
+/*
+ +----------------------------------------------------------------------+
+ | 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: Jim Winstead |
+ | Stig Sæther Bakken |
+ +----------------------------------------------------------------------+
+*/
+
+/* Define rounding modes (all are round-to-nearest) */
+#ifndef PHP_ROUND_HALF_UP
+#define PHP_ROUND_HALF_UP 0x01 /* Arithmetic rounding, up == away from zero */
+#endif
+
+#ifndef PHP_ROUND_HALF_DOWN
+#define PHP_ROUND_HALF_DOWN 0x02 /* Arithmetic rounding, down == towards zero */
+#endif
+
+#ifndef PHP_ROUND_HALF_EVEN
+#define PHP_ROUND_HALF_EVEN 0x03 /* Banker's rounding */
+#endif
+
+#ifndef PHP_ROUND_HALF_ODD
+#define PHP_ROUND_HALF_ODD 0x04
+#endif
+
+#ifndef PHP_ROUND_CEILING
+#define PHP_ROUND_CEILING 0x05
+#endif
+
+#ifndef PHP_ROUND_FLOOR
+#define PHP_ROUND_FLOOR 0x06
+#endif
+
+#ifndef PHP_ROUND_TOWARD_ZERO
+#define PHP_ROUND_TOWARD_ZERO 0x07
+#endif
+
+#ifndef PHP_ROUND_AWAY_FROM_ZERO
+#define PHP_ROUND_AWAY_FROM_ZERO 0x08
+#endif
diff --git a/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_1.phpt b/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_1.phpt
index 8d0939cdf1bc7..55b6613c1c711 100644
--- a/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_1.phpt
+++ b/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_1.phpt
@@ -12,7 +12,7 @@ $batch_file_content = <<
diff --git a/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_2.phpt b/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_2.phpt
index a1e39d7ef9ba0..0b186e977bf3f 100644
--- a/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_2.phpt
+++ b/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_2.phpt
@@ -12,7 +12,7 @@ $batch_file_content = <<^()!.exe
--CLEAN--
diff --git a/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_3.phpt b/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_3.phpt
index 69f12d7b358d2..e9bcd3bf24b96 100644
--- a/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_3.phpt
+++ b/ext/standard/tests/general_functions/ghsa-pc52-254m-w9w7_3.phpt
@@ -12,7 +12,7 @@ $batch_file_content = <<
diff --git a/ext/standard/tests/strings/setlocale_variation3.phpt b/ext/standard/tests/strings/setlocale_variation3.phpt
index 551eece086fc0..30f281a502006 100644
--- a/ext/standard/tests/strings/setlocale_variation3.phpt
+++ b/ext/standard/tests/strings/setlocale_variation3.phpt
@@ -47,7 +47,7 @@ if($locale_info_before == $locale_info_after){
echo "\nDone\n";
?>
---EXPECT--
+--EXPECTF--
*** Testing setlocale() : usage variations - setting system locale = 0 ***
Locale info, before setting the locale
array(18) {
@@ -84,17 +84,13 @@ array(18) {
["n_sign_posn"]=>
int(1)
["grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
["mon_grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
}
@@ -134,17 +130,13 @@ array(18) {
["n_sign_posn"]=>
int(1)
["grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
["mon_grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
}
diff --git a/ext/standard/tests/strings/setlocale_variation4.phpt b/ext/standard/tests/strings/setlocale_variation4.phpt
index 91171543bb694..ca469759dbd15 100644
--- a/ext/standard/tests/strings/setlocale_variation4.phpt
+++ b/ext/standard/tests/strings/setlocale_variation4.phpt
@@ -45,7 +45,7 @@ if($locale_info_before != $locale_info_after){
echo "\nDone\n";
?>
---EXPECT--
+--EXPECTF--
*** Testing setlocale() : usage variations - Setting system locale = null ***
Locale info, before setting the locale
array(18) {
@@ -82,17 +82,13 @@ array(18) {
["n_sign_posn"]=>
int(1)
["grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
["mon_grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
}
@@ -132,17 +128,13 @@ array(18) {
["n_sign_posn"]=>
int(1)
["grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
["mon_grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
}
diff --git a/ext/standard/tests/strings/setlocale_variation5.phpt b/ext/standard/tests/strings/setlocale_variation5.phpt
index 15f912d3841ec..50c8a03bb8785 100644
--- a/ext/standard/tests/strings/setlocale_variation5.phpt
+++ b/ext/standard/tests/strings/setlocale_variation5.phpt
@@ -49,7 +49,7 @@ if($locale_info_before != $locale_info_after){
echo "\nDone\n";
?>
---EXPECT--
+--EXPECTF--
*** Testing setlocale() : usage variations - setting system locale = "" ***
Locale info, before setting the locale
array(18) {
@@ -86,17 +86,13 @@ array(18) {
["n_sign_posn"]=>
int(1)
["grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
["mon_grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
}
@@ -136,17 +132,13 @@ array(18) {
["n_sign_posn"]=>
int(1)
["grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
["mon_grouping"]=>
- array(2) {
- [0]=>
- int(3)
- [1]=>
+ array(%d) {%A
+ [%d]=>
int(3)
}
}
diff --git a/ext/tokenizer/config.w32 b/ext/tokenizer/config.w32
index ee98c0cc138a4..5d933c3c31b77 100644
--- a/ext/tokenizer/config.w32
+++ b/ext/tokenizer/config.w32
@@ -4,5 +4,4 @@ ARG_ENABLE("tokenizer", "tokenizer support", "yes");
if (PHP_TOKENIZER == "yes") {
EXTENSION("tokenizer", "tokenizer.c tokenizer_data.c");
- AC_DEFINE("HAVE_TOKENIZER", 1, "Tokenizer support");
}
diff --git a/ext/xml/tests/gh14124.phpt b/ext/xml/tests/gh14124.phpt
new file mode 100644
index 0000000000000..ea4b4f579efa5
--- /dev/null
+++ b/ext/xml/tests/gh14124.phpt
@@ -0,0 +1,27 @@
+--TEST--
+GH-14124 (Segmentation fault on unknown address 0x0001ffff8041 with XML extension under certain memory limit)
+--EXTENSIONS--
+xml
+--INI--
+memory_limit=33M
+--SKIPIF--
+
+--FILE--
+<$long_text/><$long_text/>foo ";
+$long_xml_tail = " ";
+$parser = createParser(true);
+xml_parse_into_struct($parser, $long_xml_head . $long_xml_tail, $values, $index);
+?>
+--EXPECTF--
+Fatal error: Allowed memory size of %d bytes exhausted %s in %s on line %d
diff --git a/ext/xml/xml.c b/ext/xml/xml.c
index f6b4d8c5008ed..4661bc3d7cccb 100644
--- a/ext/xml/xml.c
+++ b/ext/xml/xml.c
@@ -1363,6 +1363,7 @@ PHP_FUNCTION(xml_parse_into_struct)
parser->level = 0;
xml_parser_free_ltags(parser);
parser->ltags = safe_emalloc(XML_MAXLEVEL, sizeof(char *), 0);
+ memset(parser->ltags, 0, XML_MAXLEVEL * sizeof(char *));
XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler);
XML_SetCharacterDataHandler(parser->parser, _xml_characterDataHandler);
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index 4674868370baa..48c9de2996d6d 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -162,12 +162,17 @@ zval *xmlreader_write_property(zend_object *object, zend_string *name, zval *val
/* {{{ */
static zend_function *xmlreader_get_method(zend_object **obj, zend_string *name, const zval *key)
{
- if (zend_string_equals_literal_ci(name, "open")) {
- return (zend_function*)&xmlreader_open_fn;
- } else if (zend_string_equals_literal_ci(name, "xml")) {
- return (zend_function*)&xmlreader_xml_fn;
+ zend_function *method = zend_std_get_method(obj, name, key);
+ if (method && (method->common.fn_flags & ZEND_ACC_STATIC) && method->common.type == ZEND_INTERNAL_FUNCTION) {
+ /* There are only two static internal methods and they both have overrides. */
+ if (ZSTR_LEN(name) == sizeof("xml") - 1) {
+ return (zend_function *) &xmlreader_xml_fn;
+ } else {
+ ZEND_ASSERT(ZSTR_LEN(name) == sizeof("open") - 1);
+ return (zend_function *) &xmlreader_open_fn;
+ }
}
- return zend_std_get_method(obj, name, key);
+ return method;
}
/* }}} */
diff --git a/ext/xmlreader/tests/gh14183.phpt b/ext/xmlreader/tests/gh14183.phpt
new file mode 100644
index 0000000000000..cc578c3a4ea20
--- /dev/null
+++ b/ext/xmlreader/tests/gh14183.phpt
@@ -0,0 +1,24 @@
+--TEST--
+GH-14183 (XMLReader::open() can't be overridden)
+--EXTENSIONS--
+xmlreader
+--FILE--
+open('asdf'));
+?>
+--EXPECT--
+overridden
+bool(true)
+overridden
+bool(true)
diff --git a/ext/xsl/php_xsl.stub.php b/ext/xsl/php_xsl.stub.php
index c01e218162eef..24da81b7d71b8 100644
--- a/ext/xsl/php_xsl.stub.php
+++ b/ext/xsl/php_xsl.stub.php
@@ -80,25 +80,25 @@ class XSLTProcessor
public int $maxTemplateVars;
/**
- * @param DOMDocument|DOM\Document|SimpleXMLElement $stylesheet
+ * @param DOMDocument|Dom\Document|SimpleXMLElement $stylesheet
* @tentative-return-type
*/
public function importStylesheet(object $stylesheet): bool {}
/**
- * @param DOMDocument|DOM\Document|SimpleXMLElement $document
+ * @param DOMDocument|Dom\Document|SimpleXMLElement $document
* @tentative-return-type
*/
public function transformToDoc(object $document, ?string $returnClass = null): object|false {}
/**
- * @param DOMDocument|DOM\Document|SimpleXMLElement $document
+ * @param DOMDocument|Dom\Document|SimpleXMLElement $document
* @tentative-return-type
*/
public function transformToUri(object $document, string $uri): int {}
/**
- * @param DOMDocument|DOM\Document|SimpleXMLElement $document
+ * @param DOMDocument|Dom\Document|SimpleXMLElement $document
* @tentative-return-type
*/
public function transformToXml(object $document): string|null|false {}
diff --git a/ext/xsl/php_xsl_arginfo.h b/ext/xsl/php_xsl_arginfo.h
index 033e1e8e3b21f..20559328d8181 100644
--- a/ext/xsl/php_xsl_arginfo.h
+++ b/ext/xsl/php_xsl_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: f7f9951cbb437f1985016dc06490d55f711bc725 */
+ * Stub hash: 5b4ce3f5f7dee60bde803b3c2eb3994777f56914 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XSLTProcessor_importStylesheet, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, stylesheet, IS_OBJECT, 0)
diff --git a/ext/xsl/tests/XSLTProcessor_namespace_mapper_lifetime.phpt b/ext/xsl/tests/XSLTProcessor_namespace_mapper_lifetime.phpt
index 2bd7c30dc8fd6..0d334031df78d 100644
--- a/ext/xsl/tests/XSLTProcessor_namespace_mapper_lifetime.phpt
+++ b/ext/xsl/tests/XSLTProcessor_namespace_mapper_lifetime.phpt
@@ -6,7 +6,7 @@ xsl
--FILE--
World
@@ -26,8 +26,8 @@ XML;
$processor = new XSLTProcessor();
// The fact that this is a temporary is important!
// And yes, this is done twice on purpose to check for leaks
-$processor->importStylesheet(DOM\XMLDocument::createFromString($xslXML));
-$processor->importStylesheet(DOM\XMLDocument::createFromString($xslXML));
+$processor->importStylesheet(Dom\XMLDocument::createFromString($xslXML));
+$processor->importStylesheet(Dom\XMLDocument::createFromString($xslXML));
$processor->registerPHPFunctions();
echo $processor->transformToXML($input), "\n";
diff --git a/ext/xsl/tests/auto_registration_namespaces_new_dom.phpt b/ext/xsl/tests/auto_registration_namespaces_new_dom.phpt
index f3e7f6b0601d3..e2a99bcb7141d 100644
--- a/ext/xsl/tests/auto_registration_namespaces_new_dom.phpt
+++ b/ext/xsl/tests/auto_registration_namespaces_new_dom.phpt
@@ -6,7 +6,7 @@ xsl
--FILE--
documentElement->append($sheet->createElementNS('urn:test', 'test:dummy'));
-$input = DOM\XMLDocument::createFromString(<<
World
diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c
index 464a465fd345d..7feb1920a58ee 100644
--- a/ext/zend_test/test.c
+++ b/ext/zend_test/test.c
@@ -739,6 +739,18 @@ static ZEND_FUNCTION(zend_test_is_pcre_bundled)
#endif
}
+#ifdef PHP_WIN32
+static ZEND_FUNCTION(zend_test_set_fmode)
+{
+ bool binary;
+ ZEND_PARSE_PARAMETERS_START(1, 1)
+ Z_PARAM_BOOL(binary)
+ ZEND_PARSE_PARAMETERS_END();
+
+ _fmode = binary ? _O_BINARY : _O_TEXT;
+}
+#endif
+
static zend_object *zend_test_class_new(zend_class_entry *class_type)
{
zend_object *obj = zend_objects_new(class_type);
diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php
index 1bfb08251f8a3..5c1bed2847822 100644
--- a/ext/zend_test/test.stub.php
+++ b/ext/zend_test/test.stub.php
@@ -38,6 +38,11 @@ class _ZendTestClass implements _ZendTestInterface {
*/
public const int|string TYPED_CLASS_CONST3 = UNKNOWN;
+ /**
+ * @deprecated
+ */
+ public const int ZEND_TEST_DEPRECATED = 42;
+
/** @var mixed */
public static $_StaticProp;
public static int $staticIntProp = 123;
@@ -270,6 +275,10 @@ function zend_test_override_libxml_global_state(): void {}
#endif
function zend_test_is_pcre_bundled(): bool {}
+
+#if defined(PHP_WIN32)
+ function zend_test_set_fmode(bool $binary): void {}
+#endif
}
namespace ZendTestNS {
diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h
index 1f846e830525b..32229d9d9d323 100644
--- a/ext/zend_test/test_arginfo.h
+++ b/ext/zend_test/test_arginfo.h
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: dd3f852ea9f8e3a356ed226380edf5cc336f8a4e */
+ * Stub hash: 53027610adee7e1c675b1c1b38886100ce4e63ef */
ZEND_STATIC_ASSERT(PHP_VERSION_ID >= 80000, "test_arginfo.h only supports PHP version ID 80000 or newer, "
"but it is included on an older PHP version");
@@ -147,6 +147,12 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_is_pcre_bundled, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
+#if defined(PHP_WIN32)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_set_fmode, 0, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, binary, _IS_BOOL, 0)
+ZEND_END_ARG_INFO()
+#endif
+
#define arginfo_ZendTestNS2_namespaced_func arginfo_zend_test_is_pcre_bundled
#define arginfo_ZendTestNS2_namespaced_deprecated_func arginfo_zend_test_void_return
@@ -268,6 +274,9 @@ static ZEND_FUNCTION(get_open_basedir);
static ZEND_FUNCTION(zend_test_override_libxml_global_state);
#endif
static ZEND_FUNCTION(zend_test_is_pcre_bundled);
+#if defined(PHP_WIN32)
+static ZEND_FUNCTION(zend_test_set_fmode);
+#endif
static ZEND_FUNCTION(ZendTestNS2_namespaced_func);
static ZEND_FUNCTION(ZendTestNS2_namespaced_deprecated_func);
static ZEND_FUNCTION(ZendTestNS2_ZendSubNS_namespaced_func);
@@ -360,6 +369,9 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(zend_test_override_libxml_global_state, arginfo_zend_test_override_libxml_global_state)
#endif
ZEND_FE(zend_test_is_pcre_bundled, arginfo_zend_test_is_pcre_bundled)
+#if defined(PHP_WIN32)
+ ZEND_FE(zend_test_set_fmode, arginfo_zend_test_set_fmode)
+#endif
#if (PHP_VERSION_ID >= 80400)
ZEND_RAW_FENTRY(ZEND_NS_NAME("ZendTestNS2", "namespaced_func"), zif_ZendTestNS2_namespaced_func, arginfo_ZendTestNS2_namespaced_func, 0, NULL, NULL)
#else
@@ -586,6 +598,16 @@ static zend_class_entry *register_class__ZendTestClass(zend_class_entry *class_e
#endif
zend_string_release(const_TYPED_CLASS_CONST3_name);
+ zval const_ZEND_TEST_DEPRECATED_value;
+ ZVAL_LONG(&const_ZEND_TEST_DEPRECATED_value, 42);
+ zend_string *const_ZEND_TEST_DEPRECATED_name = zend_string_init_interned("ZEND_TEST_DEPRECATED", sizeof("ZEND_TEST_DEPRECATED") - 1, 1);
+#if (PHP_VERSION_ID >= 80300)
+ zend_declare_typed_class_constant(class_entry, const_ZEND_TEST_DEPRECATED_name, &const_ZEND_TEST_DEPRECATED_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG));
+#else
+ zend_declare_class_constant_ex(class_entry, const_ZEND_TEST_DEPRECATED_name, &const_ZEND_TEST_DEPRECATED_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL);
+#endif
+ zend_string_release(const_ZEND_TEST_DEPRECATED_name);
+
zval property__StaticProp_default_value;
ZVAL_NULL(&property__StaticProp_default_value);
zend_string *property__StaticProp_name = zend_string_init("_StaticProp", sizeof("_StaticProp") - 1, 1);
diff --git a/ext/zend_test/tests/class_constant_deprecated.phpt b/ext/zend_test/tests/class_constant_deprecated.phpt
new file mode 100644
index 0000000000000..81ff0e5208ffa
--- /dev/null
+++ b/ext/zend_test/tests/class_constant_deprecated.phpt
@@ -0,0 +1,17 @@
+--TEST--
+ReflectionClassConstant::isDeprecated()
+--EXTENSIONS--
+zend_test
+--FILE--
+isDeprecated());
+
+$r = new ReflectionClassConstant('_ZendTestClass', 'TYPED_CLASS_CONST2');
+var_dump($r->isDeprecated());
+
+?>
+--EXPECTF--
+bool(true)
+bool(false)
diff --git a/ext/zend_test/tests/gh13970.phpt b/ext/zend_test/tests/gh13970.phpt
new file mode 100644
index 0000000000000..f6b68f8970234
--- /dev/null
+++ b/ext/zend_test/tests/gh13970.phpt
@@ -0,0 +1,22 @@
+--TEST--
+GH-13970 (Incorrect validation of #[\Attribute]'s first parameter)
+--EXTENSIONS--
+zend_test
+--FILE--
+getAttributes()[0]->newInstance());
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Attribute::__construct(): Argument #1 ($flags) must be of type int, ZendTestUnitEnum given
diff --git a/ext/zend_test/tests/gh14109.phpt b/ext/zend_test/tests/gh14109.phpt
new file mode 100644
index 0000000000000..be8c5a75a7bc2
--- /dev/null
+++ b/ext/zend_test/tests/gh14109.phpt
@@ -0,0 +1,16 @@
+--TEST--
+GH-14109: User class extending internal class with attributes
+--EXTENSIONS--
+zend_test
+--FILE--
+getAttributes() as $attribute) {
+ var_dump($attribute->newInstance());
+}
+?>
+--EXPECTF--
+object(ZendTestRepeatableAttribute)#%d (0) {
+}
+object(ZendTestRepeatableAttribute)#%d (0) {
+}
diff --git a/main/SAPI.c b/main/SAPI.c
index e30a04144db49..f9d8693a2bc0c 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -18,6 +18,7 @@
#include
#include
+#include
#include "php.h"
#include "SAPI.h"
@@ -25,7 +26,6 @@
#include "php_ini.h"
#include "ext/standard/php_string.h"
#include "ext/standard/pageinfo.h"
-#include "ext/pcre/php_pcre.h"
#ifdef ZTS
#include "TSRM.h"
#endif
diff --git a/main/fastcgi.c b/main/fastcgi.c
index 47b86b468588d..448576a978598 100644
--- a/main/fastcgi.c
+++ b/main/fastcgi.c
@@ -737,7 +737,7 @@ int fcgi_listen(const char *path, int backlog)
memset(&sa.sa_unix, 0, sizeof(sa.sa_unix));
sa.sa_unix.sun_family = AF_UNIX;
memcpy(sa.sa_unix.sun_path, path, path_len + 1);
- sock_len = (size_t)(((struct sockaddr_un *)0)->sun_path) + path_len;
+ sock_len = XtOffsetOf(struct sockaddr_un, sun_path) + path_len;
#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
sa.sa_unix.sun_len = sock_len;
#endif
@@ -958,9 +958,9 @@ static inline ssize_t safe_read(fcgi_request *req, const void *buf, size_t count
tmp = count - n;
if (!req->tcp) {
- unsigned int in_len = tmp > UINT_MAX ? UINT_MAX : (unsigned int)tmp;
+ unsigned int in_len = tmp > INT_MAX ? INT_MAX : (unsigned int)tmp;
- ret = read(req->fd, ((char*)buf)+n, in_len);
+ ret = _read(req->fd, ((char*)buf)+n, in_len);
} else {
int in_len = tmp > INT_MAX ? INT_MAX : (int)tmp;
diff --git a/main/php_variables.h b/main/php_variables.h
index 598de70f03598..f2b4b8cae241a 100644
--- a/main/php_variables.h
+++ b/main/php_variables.h
@@ -27,7 +27,6 @@
#define PARSE_STRING 3
#define PARSE_ENV 4
#define PARSE_SERVER 5
-#define PARSE_SESSION 6
BEGIN_EXTERN_C()
void php_startup_auto_globals(void);
diff --git a/pear/install-pear.txt b/pear/install-pear.txt
index d168cf4c93c53..2005a56997210 100644
--- a/pear/install-pear.txt
+++ b/pear/install-pear.txt
@@ -4,9 +4,9 @@
| |
| PEAR: PHP Extension and Application Repository |
| |
-| To install these components, |
-| download http://pear.php.net/go-pear.phar to php-src/pear/ |
+| To install these components, download |
+| https://pear.php.net/install-pear-nozlib.phar to php-src/pear/ |
| become the superuser and execute: |
| |
-| # make install-su |
+| # make install-pear |
+----------------------------------------------------------------------+
diff --git a/run-tests.php b/run-tests.php
index 5837a1a85000c..5314a26f48550 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -75,9 +75,11 @@ function show_usage(): void
-s Write output to .
- -x Sets 'SKIP_SLOW_TESTS' environmental variable.
+ -x Sets 'SKIP_SLOW_TESTS' environment variable.
- --offline Sets 'SKIP_ONLINE_TESTS' environmental variable.
+ --online Prevents setting the 'SKIP_ONLINE_TESTS' environment variable.
+
+ --offline Sets 'SKIP_ONLINE_TESTS' environment variable (default).
--verbose
-v Verbose mode.
@@ -355,6 +357,7 @@ function main(): void
$num_repeats = 1;
$show_progress = true;
$ignored_by_ext = [];
+ $online = null;
$cfgtypes = ['show', 'keep'];
$cfgfiles = ['skip', 'php', 'clean', 'out', 'diff', 'exp', 'mem'];
@@ -553,8 +556,11 @@ function main(): void
case 'x':
$environment['SKIP_SLOW_TESTS'] = 1;
break;
+ case '--online':
+ $online = true;
+ break;
case '--offline':
- $environment['SKIP_ONLINE_TESTS'] = 1;
+ $online = false;
break;
case '--shuffle':
$shuffle = true;
@@ -637,6 +643,13 @@ function main(): void
}
}
+ if ($online === null && !isset($environment['SKIP_ONLINE_TESTS'])) {
+ $online = false;
+ }
+ if ($online !== null) {
+ $environment['SKIP_ONLINE_TESTS'] = $online ? '0' : '1';
+ }
+
if ($selected_tests && count($test_files) === 0) {
echo "No tests found.\n";
return;
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index d5c4888211135..3d7df7e283954 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -486,9 +486,9 @@ static size_t sapi_cgi_read_post(char *buffer, size_t count_bytes)
while (read_bytes < count_bytes) {
#ifdef PHP_WIN32
size_t diff = count_bytes - read_bytes;
- unsigned int to_read = (diff > UINT_MAX) ? UINT_MAX : (unsigned int)diff;
+ unsigned int to_read = (diff > INT_MAX) ? INT_MAX : (unsigned int)diff;
- tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, to_read);
+ tmp_read_bytes = _read(STDIN_FILENO, buffer + read_bytes, to_read);
#else
tmp_read_bytes = read(STDIN_FILENO, buffer + read_bytes, count_bytes - read_bytes);
#endif
@@ -1779,9 +1779,9 @@ int main(int argc, char *argv[])
#ifdef PHP_WIN32
_fmode = _O_BINARY; /* sets default for file streams to binary */
- setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
#endif
if (!fastcgi) {
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index e107667828caa..0376ffe2e5dac 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -1240,9 +1240,9 @@ int main(int argc, char *argv[])
#ifdef PHP_WIN32
_fmode = _O_BINARY; /*sets default for file streams to binary */
- setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
#endif
php_ini_builder_init(&ini_builder);
diff --git a/sapi/cli/tests/gh14189.phpt b/sapi/cli/tests/gh14189.phpt
new file mode 100644
index 0000000000000..5c0a8b252bf73
--- /dev/null
+++ b/sapi/cli/tests/gh14189.phpt
@@ -0,0 +1,44 @@
+--TEST--
+GH-14189 (PHP Interactive shell input state incorrectly handles quoted heredoc literals.)
+--EXTENSIONS--
+readline
+--SKIPIF--
+
+--FILE--
+
+--EXPECT--
+Interactive shell
+
+php > $test = <<<"EOF"
+<<< > foo
+<<< > bar
+<<< > baz
+<<< > EOF;
+php > echo $test;
+foo
+bar
+baz
+php > exit
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
index 4626451f9f68a..33364d3e65334 100644
--- a/sapi/embed/php_embed.c
+++ b/sapi/embed/php_embed.c
@@ -194,9 +194,9 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
#ifdef PHP_WIN32
_fmode = _O_BINARY; /*sets default for file streams to binary */
- setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
- setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stdin), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stdout), O_BINARY); /* make the stdio mode be binary */
+ _setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */
#endif
/* This hard-coded string of INI settings is parsed and read into PHP's
diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4
index 339e3add944a8..0c56fc14a070f 100644
--- a/sapi/fpm/config.m4
+++ b/sapi/fpm/config.m4
@@ -265,7 +265,12 @@ AC_DEFUN([AC_FPM_LQ],
AC_MSG_CHECKING([for TCP_INFO])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct tcp_info ti; int x = TCP_INFO;]])], [
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[
+ struct tcp_info ti;
+ int x = TCP_INFO;
+ (void)ti;
+ (void)x;
+ ]])], [
have_lq=tcp_info
AC_MSG_RESULT([yes])
], [
@@ -278,7 +283,12 @@ AC_DEFUN([AC_FPM_LQ],
AC_MSG_CHECKING([for TCP_CONNECTION_INFO])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[struct tcp_connection_info ti; int x = TCP_CONNECTION_INFO;]])], [
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[
+ struct tcp_connection_info ti;
+ int x = TCP_CONNECTION_INFO;
+ (void)ti;
+ (void)x;
+ ]])], [
have_lq=tcp_connection_info
AC_MSG_RESULT([yes])
], [
@@ -292,7 +302,12 @@ AC_DEFUN([AC_FPM_LQ],
if test "$have_lq" = "no" ; then
AC_MSG_CHECKING([for SO_LISTENQLEN])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int x = SO_LISTENQLIMIT; int y = SO_LISTENQLEN;]])], [
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[
+ int x = SO_LISTENQLIMIT;
+ int y = SO_LISTENQLEN;
+ (void)x;
+ (void)y;
+ ]])], [
have_lq=so_listenq
AC_MSG_RESULT([yes])
], [
diff --git a/sapi/fpm/fpm/events/kqueue.c b/sapi/fpm/fpm/events/kqueue.c
index 1204a75ae1a39..09f5da12799be 100644
--- a/sapi/fpm/fpm/events/kqueue.c
+++ b/sapi/fpm/fpm/events/kqueue.c
@@ -81,7 +81,7 @@ static int fpm_event_kqueue_init(int max) /* {{{ */
kevents = calloc(max, sizeof(struct kevent));
if (!kevents) {
- zlog(ZLOG_ERROR, "epoll: unable to allocate %d events", max);
+ zlog(ZLOG_ERROR, "kevent: unable to allocate %d events", max);
return -1;
}
@@ -128,7 +128,7 @@ static int fpm_event_kqueue_wait(struct fpm_event_queue_s *queue, unsigned long
/* trigger error unless signal interrupt */
if (errno != EINTR) {
- zlog(ZLOG_WARNING, "epoll_wait() returns %d", errno);
+ zlog(ZLOG_WARNING, "kevent() returns %d", errno);
return -1;
}
}
diff --git a/sapi/fpm/fpm/fpm_systemd.c b/sapi/fpm/fpm/fpm_systemd.c
index 175312412330f..d5858ac780d64 100644
--- a/sapi/fpm/fpm/fpm_systemd.c
+++ b/sapi/fpm/fpm/fpm_systemd.c
@@ -29,13 +29,13 @@ static void fpm_systemd(void)
}
/*
- zlog(ZLOG_DEBUG, "systemd %s (Processes active:%d, idle:%d, Requests:%lu, slow:%lu, Traffic:%.3greq/sec)",
+ zlog(ZLOG_DEBUG, "systemd %s (Processes active:%d, idle:%d, Requests:%lu, slow:%lu, Traffic:%.2freq/sec)",
fpm_global_config.systemd_watchdog ? "watchdog" : "heartbeat",
active, idle, requests, slow_req, ((float)requests - last) * 1000.0 / fpm_global_config.systemd_interval);
*/
if (0 > sd_notifyf(0, "READY=1\n%s"
- "STATUS=Processes active: %d, idle: %d, Requests: %lu, slow: %lu, Traffic: %.3greq/sec",
+ "STATUS=Processes active: %d, idle: %d, Requests: %lu, slow: %lu, Traffic: %.2freq/sec",
fpm_global_config.systemd_watchdog ? "WATCHDOG=1\n" : "",
active, idle, requests, slow_req, ((float)requests - last) * 1000.0 / fpm_global_config.systemd_interval)) {
zlog(ZLOG_NOTICE, "failed to notify status to systemd");
diff --git a/sapi/fpm/status.html.in b/sapi/fpm/status.html.in
index b87a446f59f66..b14123dd323ac 100644
--- a/sapi/fpm/status.html.in
+++ b/sapi/fpm/status.html.in
@@ -72,7 +72,7 @@
-
+