diff --git a/.github/actions/configure-unit-tests/action.yml b/.github/actions/configure-unit-tests/action.yml new file mode 100644 index 0000000000000..ef8239b7111c7 --- /dev/null +++ b/.github/actions/configure-unit-tests/action.yml @@ -0,0 +1,10 @@ +name: ./configure (unit tests) +description: Configure PHP with minimal settings for unit testing +runs: + using: composite + steps: + - shell: bash + run: | + set -x + ./buildconf --force + ./configure --disable-all --enable-embed=static diff --git a/.github/actions/macos-update-clang/action.yml b/.github/actions/macos-update-clang/action.yml new file mode 100644 index 0000000000000..916b4dfe41f48 --- /dev/null +++ b/.github/actions/macos-update-clang/action.yml @@ -0,0 +1,17 @@ +name: Update clang +runs: + using: composite + steps: + - shell: bash + run: | + softwareupdate -l + label=$((softwareupdate -l 2>/dev/null | grep 'Label:' | grep -o 'Command Line Tools for Xcode.*' | head -1) || echo '') + if [ -n "$label" ]; then + softwareupdate -i "$label" + xcode_path=$(ls -1 '/Applications' | grep 'Xcode_.*\.app' | sort -r | head -1) + sudo xcode-select -s "/Applications/$xcode_path" + else + echo "Not found." + fi + which clang + clang -v diff --git a/.github/actions/verify-generated-files/action.yml b/.github/actions/verify-generated-files/action.yml index 5228105f25908..79c49dbfcfffb 100644 --- a/.github/actions/verify-generated-files/action.yml +++ b/.github/actions/verify-generated-files/action.yml @@ -12,5 +12,5 @@ runs: Zend/zend_vm_gen.php ext/tokenizer/tokenizer_data_gen.php build/gen_stub.php -f --generate-optimizer-info --verify - # Use the -a flag for a bug in git 2.46.0, which doesn't consider changed -diff files. - git add . -N && git diff -a --exit-code + ext/phar/makestub.php + .github/scripts/test-directory-unchanged.sh . diff --git a/.github/nightly_matrix.php b/.github/nightly_matrix.php index c1f5627542684..0032da7dbcea8 100644 --- a/.github/nightly_matrix.php +++ b/.github/nightly_matrix.php @@ -6,7 +6,6 @@ ['ref' => 'PHP-8.4', 'version' => [8, 4]], ['ref' => 'PHP-8.3', 'version' => [8, 3]], ['ref' => 'PHP-8.2', 'version' => [8, 2]], - ['ref' => 'PHP-8.1', 'version' => [8, 1]], ]; function get_branch_commit_cache_file_path(): string { diff --git a/.github/scripts/download-bundled/pcre2.sh b/.github/scripts/download-bundled/pcre2.sh new file mode 100755 index 0000000000000..b43554206c929 --- /dev/null +++ b/.github/scripts/download-bundled/pcre2.sh @@ -0,0 +1,32 @@ +#!/bin/sh +set -ex +cd "$(dirname "$0")/../../.." + +revision=refs/tags/pcre2-10.44 + +git clone --depth 1 --recurse-submodules --revision="$revision" https://github.com/PCRE2Project/pcre2.git /tmp/php-src-bundled/pcre2 + +rm -rf ext/pcre/pcre2lib +cp -R /tmp/php-src-bundled/pcre2/src ext/pcre/pcre2lib + +cd ext/pcre/pcre2lib + +# remove unneeded files +rm config.h.generic +rm pcre2.h.in +rm pcre2_dftables.c +rm pcre2_fuzzsupport.c +rm pcre2_jit_test.c +rm pcre2demo.c +rm pcre2grep.c +rm pcre2posix.c +rm pcre2posix.h +rm pcre2posix_test.c +rm pcre2test.c + +# move renamed files +mv pcre2.h.generic pcre2.h +mv pcre2_chartables.c.dist pcre2_chartables.c + +# add extra files +git restore config.h # based on config.h.generic but with many changes diff --git a/.github/scripts/test-directory-unchanged.sh b/.github/scripts/test-directory-unchanged.sh new file mode 100755 index 0000000000000..0ce7fd4cc4afd --- /dev/null +++ b/.github/scripts/test-directory-unchanged.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -ex + +cd "$(dirname "$0")/../../$1" + +# notify git about untracked (except ignored) files +git add -N . + +# display overview of changed files +git status . + +# display diff of working directory vs HEAD commit and set exit code +git diff -a --exit-code HEAD . diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3e59990742cbe..0ab56f77ab3f8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,7 +17,7 @@ jobs: if: github.repository == 'php/php-src' steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Install dependencies run: pip install -r docs/requirements.txt - name: Check formatting diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index dbddbdc5d89b3..4cf6357c491fd 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -12,6 +12,6 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v5 + - uses: actions/labeler@v6 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 97078677b0aca..9ab95da2d935d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,6 +14,9 @@ on: libmysqlclient_with_mysqli: required: true type: boolean + macos_arm64_version: + required: true + type: string run_alpine: required: true type: boolean @@ -57,7 +60,7 @@ jobs: runs-on: [self-hosted, gentoo, ppc64] steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: System info @@ -98,7 +101,7 @@ jobs: image: 'alpine:3.22' steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apk @@ -199,7 +202,7 @@ jobs: runs-on: ubuntu-${{ matrix.asan && inputs.asan_ubuntu_version || inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -294,7 +297,7 @@ jobs: FIREBIRD_PASSWORD: test steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -350,16 +353,18 @@ jobs: matrix: debug: [true, false] zts: [true, false] - os: ['13', '14'] + arch: ['X64', 'ARM64'] exclude: - - os: ${{ !inputs.run_macos_arm64 && '14' || '*never*' }} - name: "MACOS_${{ matrix.os == '13' && 'X64' || 'ARM64' }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" - runs-on: macos-${{ matrix.os }} + - arch: ${{ !inputs.run_macos_arm64 && 'ARM64' || '*never*' }} + name: "MACOS_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" + runs-on: macos-${{ matrix.arch == 'X64' && '15-intel' || inputs.macos_arm64_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} + - name: Update clang + uses: ./.github/actions/macos-update-clang - name: brew uses: ./.github/actions/brew - name: ./configure @@ -377,7 +382,7 @@ jobs: - name: Test uses: ./.github/actions/test-macos - name: Test Tracing JIT - if: matrix.os != '14' || !matrix.zts + if: matrix.arch == 'X64' || !matrix.zts uses: ./.github/actions/test-macos with: jitType: tracing @@ -389,7 +394,7 @@ jobs: runTestsParameters: >- -d opcache.enable_cli=1 - name: Test Function JIT - if: matrix.os != '14' || !matrix.zts + if: matrix.arch == 'X64' || !matrix.zts uses: ./.github/actions/test-macos with: jitType: function @@ -427,7 +432,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -475,7 +480,7 @@ jobs: USE_TRACKED_ALLOC: 1 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -674,7 +679,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Create MSSQL container @@ -732,7 +737,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -818,7 +823,7 @@ jobs: runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: apt @@ -863,38 +868,38 @@ jobs: CXX: ccache g++ steps: - name: git checkout PHP - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: path: php ref: ${{ inputs.branch }} - name: git checkout apcu - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: krakjoe/apcu path: apcu - name: git checkout imagick - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: Imagick/imagick path: imagick - name: git checkout memcached - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: php-memcached-dev/php-memcached path: memcached - name: git checkout redis - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: phpredis/phpredis path: redis - name: git checkout xdebug if: false - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: xdebug/xdebug path: xdebug - name: git checkout yaml - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: php/pecl-file_formats-yaml path: yaml @@ -987,7 +992,7 @@ jobs: PHP_BUILD_CACHE_BASE_DIR: C:\build-cache PHP_BUILD_OBJ_DIR: C:\obj PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk - PHP_BUILD_SDK_BRANCH: php-sdk-2.3.0 + PHP_BUILD_SDK_BRANCH: php-sdk-2.5.0 PHP_BUILD_CRT: ${{ inputs.vs_crt_version }} PLATFORM: ${{ matrix.x64 && 'x64' || 'x86' }} THREAD_SAFE: "${{ matrix.zts && '1' || '0' }}" @@ -999,7 +1004,7 @@ jobs: - name: git config run: git config --global core.autocrlf false && git config --global core.eol lf - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: Setup @@ -1020,7 +1025,7 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: ref: ${{ inputs.branch }} - name: FreeBSD diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index cda86327a68ec..64dc1ce6b60ed 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -40,7 +40,7 @@ jobs: image: 'alpine:3.22' steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: apk uses: ./.github/actions/apk - name: System info @@ -115,7 +115,7 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: apt uses: ./.github/actions/apt-x64 - name: System info @@ -200,7 +200,7 @@ jobs: FIREBIRD_PASSWORD: test steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: apt uses: ./.github/actions/apt-x32 - name: ccache @@ -238,7 +238,9 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 + - name: Update clang + uses: ./.github/actions/macos-update-clang - name: brew uses: ./.github/actions/brew - name: ccache @@ -274,7 +276,7 @@ jobs: PHP_BUILD_CACHE_BASE_DIR: C:\build-cache PHP_BUILD_OBJ_DIR: C:\obj PHP_BUILD_CACHE_SDK_DIR: C:\build-cache\sdk - PHP_BUILD_SDK_BRANCH: php-sdk-2.3.0 + PHP_BUILD_SDK_BRANCH: php-sdk-2.5.0 PHP_BUILD_CRT: vs17 PLATFORM: x64 THREAD_SAFE: "1" @@ -285,7 +287,7 @@ jobs: - name: git config run: git config --global core.autocrlf false && git config --global core.eol lf - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Setup uses: ./.github/actions/setup-windows - name: Build @@ -299,7 +301,7 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: fetch-depth: 0 # ASLR can cause a lot of noise due to missed sse opportunities for memcpy @@ -361,7 +363,7 @@ jobs: mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" - name: git checkout benchmarking-data - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: php/benchmarking-data ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} @@ -392,7 +394,7 @@ jobs: ${{ github.sha }} \ $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \ > $GITHUB_STEP_SUMMARY - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v6 with: name: profiles path: ${{ github.workspace }}/benchmark/profiles @@ -404,6 +406,6 @@ jobs: timeout-minutes: 50 steps: - name: git checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: FreeBSD uses: ./.github/actions/freebsd diff --git a/.github/workflows/real-time-benchmark.yml b/.github/workflows/real-time-benchmark.yml index 539e9768f4ac1..9276539841e72 100644 --- a/.github/workflows/real-time-benchmark.yml +++ b/.github/workflows/real-time-benchmark.yml @@ -118,21 +118,21 @@ jobs: sudo apt-get update -y sudo apt-get install -y terraform=1.5.7-* - name: Checkout benchmark suite - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: 'kocsismate/php-version-benchmarks' ref: 'main' fetch-depth: 1 path: 'php-version-benchmarks' - name: Checkout php-src (benchmarked version) - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: '${{ env.REPOSITORY }}' ref: '${{ env.COMMIT }}' fetch-depth: 100 path: 'php-version-benchmarks/tmp/php_${{ env.ID }}' - name: Checkout php-src (baseline version) - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: '${{ env.REPOSITORY }}' ref: '${{ env.BASELINE_COMMIT }}' @@ -146,7 +146,7 @@ jobs: rm -rf ./php-version-benchmarks/docs/results - name: Checkout benchmark data if: github.event_name != 'workflow_dispatch' - uses: actions/checkout@v5 + uses: actions/checkout@v6 with: repository: php/real-time-benchmark-data ssh-key: ${{ secrets.PHP_VERSION_BENCHMARK_RESULTS_DEPLOY_KEY }} @@ -290,7 +290,7 @@ jobs: git push - name: Upload artifact if: github.event_name == 'workflow_dispatch' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: results path: ./php-version-benchmarks/docs/results/${{ env.YEAR }} diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml index ea23349fd6928..123ccc17c611d 100644 --- a/.github/workflows/root.yml +++ b/.github/workflows/root.yml @@ -13,14 +13,14 @@ jobs: outputs: branches: ${{ steps.set-matrix.outputs.branches }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: # Set fetch-depth to 0 to clone the full repository # including all branches. This is required to find # the correct commit hashes. fetch-depth: 0 - name: Grab the commit mapping - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: branch-commit-cache.json # The cache key needs to change every time for the @@ -47,6 +47,7 @@ jobs: branch: ${{ matrix.branch.ref }} community_verify_type_inference: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9 }} libmysqlclient_with_mysqli: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1) }} + macos_arm64_version: ${{ ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 5) || matrix.branch.version[0] >= 9) && '15' || '14' }} run_alpine: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9 }} run_linux_ppc64: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9 }} run_macos_arm64: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9 }} @@ -57,9 +58,7 @@ jobs: windows_version: '2022' vs_crt_version: ${{ ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) && 'vs17') || 'vs16' }} skip_laravel: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} - symfony_version: ${{ (((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9) && '8.1') - || ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 2) && '7.4') - || '' }} + symfony_version: ${{ (((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9) && '8.1') || '7.4' }} skip_wordpress: ${{ matrix.branch.version[0] == 8 && matrix.branch.version[1] == 1 }} variation_enable_zend_max_execution_timers: ${{ (matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 3) || matrix.branch.version[0] >= 9 }} secrets: inherit diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000000..6338a1cb945db --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,75 @@ +name: Unit Tests +on: + push: + paths: + - 'main/network.c' + - 'tests/unit/**' + - '.github/workflows/unit-tests.yml' + branches: + - master + pull_request: + paths: + - 'main/network.c' + - 'tests/unit/**' + - '.github/workflows/unit-tests.yml' + branches: + - '**' + workflow_dispatch: ~ + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.url || github.run_id }} + cancel-in-progress: true + +env: + CC: ccache gcc + CXX: ccache g++ + +jobs: + UNIT_TESTS: + if: github.repository == 'php/php-src' || github.event_name == 'pull_request' + name: UNIT_TESTS_LINUX_X64 + runs-on: ubuntu-24.04 + timeout-minutes: 20 + steps: + - name: git checkout + uses: actions/checkout@v6 + + - name: Install dependencies + run: | + set -x + sudo apt-get update + sudo apt-get install -y \ + libcmocka-dev \ + autoconf \ + gcc \ + make \ + unzip \ + bison \ + re2c \ + locales \ + ccache + + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: "unit-tests-${{hashFiles('main/php_version.h')}}" + append-timestamp: false + save: ${{ github.event_name != 'pull_request' }} + + - name: ./configure (minimal build) + uses: ./.github/actions/configure-unit-tests + + - name: make libphp.a + run: | + set -x + make -j$(/usr/bin/nproc) >/dev/null + + - name: Run unit tests + run: | + set -x + cd tests/unit + make test + diff --git a/.github/workflows/verify-bundled-files.yml b/.github/workflows/verify-bundled-files.yml new file mode 100644 index 0000000000000..6cce1a14cf7f3 --- /dev/null +++ b/.github/workflows/verify-bundled-files.yml @@ -0,0 +1,43 @@ +name: Verify Bundled Files + +on: + push: + paths: &paths + - '.github/scripts/download-bundled/pcre2.sh' + - 'ext/pcre/pcre2lib/**' + pull_request: + paths: *paths + schedule: + - cron: "0 1 * * *" + workflow_dispatch: ~ + +permissions: + contents: read + +jobs: + VERIFY_BUNDLED_FILES: + name: Verify Bundled Files + runs-on: ubuntu-24.04 + steps: + - name: git checkout + uses: actions/checkout@v6 + + - name: Detect changed files + uses: dorny/paths-filter@v3 + id: changes + with: + base: master + filters: | + pcre2: + - '.github/scripts/download-bundled/pcre2.sh' + - 'ext/pcre/pcre2lib/**' + + - name: PCRE2 + if: ${{ !cancelled() && (steps.changes.outputs.pcre2 == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} + run: | + echo "::group::Download" + .github/scripts/download-bundled/pcre2.sh + echo "::endgroup::" + echo "::group::Verify files" + .github/scripts/test-directory-unchanged.sh ext/pcre/pcre2lib + echo "::endgroup::" diff --git a/CODING_STANDARDS.md b/CODING_STANDARDS.md index c599194ed50e3..47b76717c8391 100644 --- a/CODING_STANDARDS.md +++ b/CODING_STANDARDS.md @@ -276,7 +276,7 @@ rewritten to comply with these rules. 1. The length of constant string literals should be calculated via ``strlen()`` instead of using ``sizeof()-1`` as it is clearer and any modern compiler - will optimize it away. Legacy usages of the latter style exists within the + will optimize it away. Legacy usages of the latter style exist within the codebase but should not be refactored, unless larger refactoring around that code is taking place. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 31d893e8d42a8..32e8098c08e48 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -100,6 +100,7 @@ scattered across different websites, and often outdated. Nonetheless, they can provide a good starting point for learning about the fundamentals of the code base. +* https://php.github.io/php-src/ * https://www.phpinternalsbook.com/ * https://www.npopov.com/ * [Internal value representation](https://www.npopov.com/2015/05/05/Internal-value-representation-in-PHP-7-part-1.html), [part 2](https://www.npopov.com/2015/06/19/Internal-value-representation-in-PHP-7-part-2.html) @@ -357,7 +358,8 @@ Currently, we have the following branches in use: | Branch | | | --------- | --------- | -| master | Active development branch for PHP 8.5, which is open for backwards incompatible changes and major internal API changes. | +| master | Active development branch for PHP 8.6, which is open for backwards incompatible changes and major internal API changes. | +| PHP-8.5 | Is used to release the PHP 8.5.x series. This is a current stable version and is open for bugfixes only. | | PHP-8.4 | Is used to release the PHP 8.4.x series. This is a current stable version and is open for bugfixes only. | | PHP-8.3 | Is used to release the PHP 8.3.x series. This is a current stable version and is open for bugfixes only. | | PHP-8.2 | Is used to release the PHP 8.2.x series. This is an old stable version and is open for security fixes only. | diff --git a/LICENSE b/LICENSE index 0815d7eb79119..b155a18c2fb73 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -------------------------------------------------------------------- The PHP License, version 3.01 -Copyright (c) 1999 - 2024 The PHP Group. All rights reserved. +Copyright (c) 1999 - 2025 The PHP Group. All rights reserved. -------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without diff --git a/NEWS b/NEWS index b89c399f3fee4..12740c65c3c89 100644 --- a/NEWS +++ b/NEWS @@ -1,728 +1,87 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? ????, PHP 8.5.1 +?? ??? ????, PHP 8.6.0alpha1 - Core: - . Sync all boost.context files with release 1.86.0. (mvorisek) - . Fixed bug GH-20435 (SensitiveParameter doesn't work for named argument - passing to variadic parameter). (ndossche) - . Fixed bug GH-20546 (preserve_none attribute configure check on macOs - issue). (David Carlier/cho-m) - . Fixed bug GH-20286 (use-after-destroy during userland stream_close()). - (ndossche, David Carlier) + . Added first-class callable cache to share instances for the duration of the + request. (ilutov) + . It is now possible to use reference assign on WeakMap without the key + needing to be present beforehand. (ndossche) + . Added `clamp()`. (kylekatarnls, thinkverse) -- Bz2: - . Fix assertion failures resulting in crashes with stream filter - object parameters. (ndossche) - -- DOM: - . Fix memory leak when edge case is hit when registering xpath callback. - (ndossche) - . Fixed bug GH-20395 (querySelector and querySelectorAll requires elements - in $selectors to be lowercase). (ndossche) - . Fix missing NUL byte check on C14NFile(). (ndossche) - -- Fibers: - . Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI - small value). (David Carlier) +- Hash: + . Upgrade xxHash to 0.8.2. (timwolla) - Intl: + . Added IntlNumberRangeFormatter class to format an interval of two numbers + with a given skeleton, locale, collapse type and identity fallback. + (BogdanUngureanu) . Fixed bug GH-20426 (Spoofchecker::setRestrictionLevel() error message suggests missing constants). (DanielEScherzer) -- Lexbor: - . Fixed bug GH-20501 (\Uri\WhatWg\Url lose host after calling - withPath() or withQuery()). (lexborisov) - . Fixed bug GH-20502 (\Uri\WhatWg\Url crashes (SEGV) when parsing - malformed URL due to Lexbor memory corruption). (lexborisov) - -- LibXML: - . Fix some deprecations on newer libxml versions regarding input - buffer/parser handling. (ndossche) - -- MySQLnd: - . Fixed bug GH-20528 (Regression breaks mysql connexion using an IPv6 address - enclosed in square brackets). (Remi) - -- Opcache: - . Fixed bug GH-20329 (opcache.file_cache broken with full interned string - buffer). (Arnaud) - -- Phar: - . Fixed bug GH-20442 (Phar does not respect case-insensitiveness of - __halt_compiler() when reading stub). (ndossche, TimWolla) - . Fix broken return value of fflush() for phar file entries. (ndossche) - . Fix assertion failure when fseeking a phar file out of bounds. (ndossche) - -- PHPDBG: - . Fixed ZPP type violation in phpdbg_get_executable() and phpdbg_end_oplog(). - (Girgias) - -- SPL: - . Fixed bug GH-20614 (SplFixedArray incorrectly handles references - in deserialization). (ndossche) - -- Standard: - . Fix memory leak in array_diff() with custom type checks. (ndossche) - . Fixed bug GH-20583 (Stack overflow in http_build_query - via deep structures). (ndossche) - . Fixed bug GH-20584 (Information Leak of Memory). (ndossche) - -- XML: - . Fixed bug GH-20439 (xml_set_default_handler() does not properly handle - special characters in attributes when passing data to callback). (ndossche) - -- Zip: - . Fix crash in property existence test. (ndossche) - . Don't truncate return value of zip_fread() with user sizes. (ndossche) - -- Zlib: - . Fix assertion failures resulting in crashes with stream filter - object parameters. (ndossche) - -- URI: - . Fixed bug GH-20366 (ext/uri incorrectly throws ValueError when encountering - null byte). (kocsismate) - -20 Nov 2025, PHP 8.5.0 - -- Core: - . Added the #[\NoDiscard] attribute to indicate that a function's return - value is important and should be consumed. (timwolla, edorian) - . Added the (void) cast to indicate that not using a value is intentional. - (timwolla, edorian) - . Added get_error_handler(), get_exception_handler() functions. (Arnaud) - . Added support for casts in constant expressions. (nielsdos) - . Added the pipe (|>) operator. (crell) - . Added support for `final` with constructor property promotion. - (DanielEScherzer) - . Added support for configuring the URI parser for the FTP/FTPS as well as - the SSL/TLS stream wrappers as described in - https://wiki.php.net/rfc/url_parsing_api#plugability. (kocsismate) - . Added PHP_BUILD_PROVIDER constant. (timwolla) - . Added PHP_BUILD_DATE constant. (cmb) - . Added support for Closures and first class callables in constant - expressions. (timwolla, edorian) - . Add support for backtraces for fatal errors. (enorris) - . Add clone-with support to the clone() function. (timwolla, edorian) - . Add RFC 3986 and WHATWG URL compliant APIs for URL parsing - and manipulation (kocsismate, timwolla) - . Fixed AST printing for immediately invoked Closure. (Dmitrii Derepko) - . Properly handle __debugInfo() returning an array reference. (nielsdos) - . Properly handle reference return value from __toString(). (nielsdos) - . Improved error message of UnhandledMatchError for - zend.exception_string_param_max_len=0. (timwolla) - . Fixed bug GH-15753 and GH-16198 (Bind traits before parent class). (ilutov) - . Fixed bug GH-17951 (memory_limit is not always limited by max_memory_limit). - (manuelm) - . Fixed bug GH-20183 (Stale EG(opline_before_exception) pointer through eval). - (ilutov) - . Fixed bug GH-20113 (Missing new Foo(...) error in constant expressions). - (ilutov) - . Fixed bug GH-19844 (Don't bail when closing resources on shutdown). (ilutov) - . Fixed bug GH-20177 (Accessing overridden private property in - get_object_vars() triggers assertion error). (ilutov) - . Fix OSS-Fuzz #447521098 (Fatal error during sccp shift eval). (ilutov) - . Fixed bug GH-20002 (Broken build on *BSD with MSAN). (outtersg) - . Fixed bug GH-19352 (Cross-compilation with musl C library). - (henderkes, Peter Kokot) - . Fixed bug GH-19765 (object_properties_load() bypasses readonly property - checks). (timwolla) - . Fixed hard_timeout with --enable-zend-max-execution-timers. (Appla) - . Fixed bug GH-19839 (Incorrect HASH_FLAG_HAS_EMPTY_IND flag on userland - array). (ilutov) - . Fixed bug GH-19823 (register_argc_argv deprecation emitted twice when - using OPcache). (timwolla) - . Fixed bug GH-19480 (error_log php.ini cannot be unset when open_basedir is - configured). (nielsdos) - . Fixed bug GH-19719 (Allow empty statements before declare(strict_types)). - (nielsdos) - . Fixed bug GH-19934 (CGI with auto_globals_jit=0 causes uouv). (ilutov) - . Fixed bug GH-19613 (Stale array iterator pointer). (ilutov) - . Fixed bug GH-19679 (zend_ssa_range_widening may fail to converge). (Arnaud) - . Fixed bug GH-19681 (PHP_EXPAND_PATH broken with bash 5.3.0). (Remi) - . Fixed bug GH-18850 (Repeated inclusion of file with __halt_compiler() - triggers "Constant already defined" warning). (ilutov) - . Fixed bug GH-19476 (pipe operator fails to correctly handle returning - by reference). (alexandre-daubois) - . Fixed bug GH-19081 (Wrong lineno in property error with constructor property - promotion). (ilutov) - . Fixed bug GH-17959 (Relax missing trait fatal error to error exception). - (ilutov) - . Fixed bug GH-18033 (NULL-ptr dereference when using register_tick_function - in destructor). (nielsdos) - . Fixed bug GH-18026 (Improve "expecting token" error for ampersand). (ilutov) - . The report_memleaks INI directive has been deprecated. (alexandre-daubois) - . Fixed OSS-Fuzz #439125710 (Pipe cannot be used in write context). - (nielsdos) - . Fixed bug GH-19548 (Shared memory violation on property inheritance). - (alexandre-daubois) - . Fixed bug GH-19544 (GC treats ZEND_WEAKREF_TAG_MAP references as WeakMap - references). (Arnaud, timwolla) - . Fixed bug GH-18373 (Don't substitute self/parent with anonymous class). - (ilutov) - . Fix support for non-userland stream notifiers. (timwolla) - . Fixed bug GH-19305 (Operands may be being released during comparison). - (Arnaud) - . Fixed bug GH-19306 (Generator can be resumed while fetching next value from - delegated Generator). (Arnaud) - . Fixed bug GH-19326 (Calling Generator::throw() on a running generator with - a non-Generator delegate crashes). (Arnaud) - . Fix OSS-Fuzz #427814452 (pipe compilation fails with assert). - (nielsdos, ilutov) - . Fixed bug GH-16665 (\array and \callable should not be usable in - class_alias). (nielsdos) - . Use `clock_gettime_nsec_np()` for high resolution timer on macOS - if available. (timwolla) - . Make `clone()` a function. (timwolla, edorian) - . Introduced the TAILCALL VM, enabled by default when compiling with Clang>=19 - on x86_64 or aarch64. (Arnaud) - . Enacted the follow-up phase of the "Path to Saner Increment/Decrement - operators" RFC, meaning that incrementing non-numeric strings is now - deprecated. (Girgias). - . Various closure binding issues are now deprecated. (alexandre-daubois) - . Constant redeclaration has been deprecated. (alexandre-daubois) - . Marks the stack as non-executable on Haiku. (David Carlier) - . Deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string is - now deprecated. (timwolla, nicolasgrekas) - . Using null as an array offset or when calling array_key_exists() is now - deprecated. (alexandre-daubois) - . The disable_classes INI directive has been removed. (Girgias) - . The locally predefined variable $http_response_header is deprecated. - (Girgias) - . Non-canonical cast names (boolean), (integer), (double), and (binary) have - been deprecated. (Girgias) - . The $exclude_disabled parameter of the get_defined_functions() function has - been deprecated, as it no longer has any effect since PHP 8.0. (Girgias) - . Terminating case statements with a semicolon instead of a colon has - been deprecated. (theodorejb) - . The backtick operator as an alias for shell_exec() has been deprecated. - (timwolla) - . Returning null from __debugInfo() has been deprecated. (DanielEScherzer) - . Support #[\Override] on properties. (Jiří Pudil) - . Destructing non-array values (other than NULL) using [] or list() now - emits a warning. (Girgias) - . Casting floats that are not representable as ints now emits a warning. - (Girgias) - . Casting NAN to other types now emits a warning. (Girgias) - . Implement GH-15680 (Enhance zend_dump_op_array to properly represent - non-printable characters in string literals). (nielsdos, WangYihang) - . Fixed bug GH-17442 (Engine UAF with reference assign and dtor). (nielsdos) - . Do not use RTLD_DEEPBIND if dlmopen is available. (Daniil Gentili) - -- BCMath: - . Simplify `bc_divide()` code. (SakiTakamachi) - . If the result is 0, n_scale is set to 0. (SakiTakamachi) - . If size of BC_VECTOR array is within 64 bytes, stack area is now used. - (SakiTakamachi) - . Fixed bug GH-20006 (Power of 0 of BcMath number causes UB). (nielsdos) - -- Bz2: - . Fixed bug GH-19810 (Broken bzopen() stream mode validation). (ilutov) - -- CLI: - . Add --ini=diff to print INI settings changed from the builtin default. - (timwolla) - . Drop support for -z CLI/CGI flag. (nielsdos) - . Fixed GH-17956 - development server 404 page does not adapt to mobiles. - (pascalchevrel) - . Fix useless "Failed to poll event" error logs due to EAGAIN in CLI server - with PHP_CLI_SERVER_WORKERS. (leotaku) - . Fixed bug GH-19461 (Improve error message on listening error with IPv6 - address). (alexandre-daubois) - -- COM: - . Fixed property access of PHP objects wrapped in variant. (cmb) - . Fixed method calls for PHP objects wrapped in variant. (cmb) - -- Curl: - . Added CURLFOLLOW_ALL, CURLFOLLOW_OBEYCODE and CURLFOLLOW_FIRSTONLY - values for CURLOPT_FOLLOWLOCATION curl_easy_setopt option. (David Carlier) - . Added curl_multi_get_handles(). (timwolla) - . Added curl_share_init_persistent(). (enorris) - . Added CURLINFO_USED_PROXY, CURLINFO_HTTPAUTH_USED, and CURLINFO_PROXYAUTH_USED - support to curl_getinfo. (Ayesh Karunaratne) - . Add support for CURLINFO_CONN_ID in curl_getinfo() (thecaliskan) - . Add support for CURLINFO_QUEUE_TIME_T in curl_getinfo() (thecaliskan) - . Add support for CURLOPT_SSL_SIGNATURE_ALGORITHMS. (Ayesh Karunaratne) - . The curl_close() function has been deprecated. (DanielEScherzer) - . The curl_share_close() function has been deprecated. (DanielEScherzer) - . Fix cloning of CURLOPT_POSTFIELDS when using the clone operator instead - of the curl_copy_handle() function to clone a CurlHandle. (timwolla) - -- Date: - . Fix undefined behaviour problems regarding integer overflow in extreme edge - cases. (nielsdos, cmb, ilutov) - . The DATE_RFC7231 and DateTimeInterface::RFC7231 constants have been - deprecated. (jorgsowa) - . Fixed date_sunrise() and date_sunset() with partial-hour UTC offset. - (ilutov) - . Fixed GH-17159: "P" format for ::createFromFormat swallows string literals. - (nielsdos) - . The __wakeup() magic method of DateTimeInterface, DateTime, - DateTimeImmutable, DateTimeZone, DateInterval, and DatePeriod has been - deprecated in favour of the __unserialize() magic method. (Girgias) - -- DOM: - . Added Dom\Element::$outerHTML. (nielsdos) - . Added Dom\Element::insertAdjacentHTML(). (nielsdos) - . Added $children property to ParentNode implementations. (nielsdos) - . Make cloning DOM node lists, maps, and collections fail. (nielsdos) - . Added Dom\Element::getElementsByClassName(). (nielsdos) - . Fixed bug GH-18877 (\Dom\HTMLDocument querySelectorAll selecting only the - first when using ~ and :has). (nielsdos, lexborisov) - . Fix getNamedItemNS() incorrect namespace check. (nielsdos) - -- Enchant: - . Added enchant_dict_remove_from_session(). (nielsdos) - . Added enchant_dict_remove(). (nielsdos) - . Fix missing empty string checks. (nielsdos) - -- EXIF: - . Add OffsetTime* Exif tags. (acc987) - . Added support to retrieve Exif from HEIF file. (Benstone Zhang) - . Fix OSS-Fuzz #442954659 (zero-size box in HEIF file causes infinite loop). - (nielsdos) - . Fix OSS-Fuzz #442954659 (Crash in exif_scan_HEIF_header). (nielsdos) - . Various hardening fixes to HEIF parsing. (nielsdos) - - -- FileInfo: - . The finfo_close() function has been deprecated. (timwolla) - . The $context parameter of the finfo_buffer() function has been deprecated - as it is ignored. (Girgias) - . Upgrade to file 5.46. (nielsdos) - . Change return type of finfo_close() to true. (timwolla) - -- Filter: - . Added support for configuring the URI parser for FILTER_VALIDATE_URL - as described in https://wiki.php.net/rfc/url_parsing_api#plugability. - (kocsismate) - . Fixed bug GH-16993 (filter_var_array with FILTER_VALIDATE_INT|FILTER_NULL_ON_FAILURE - should emit warning for invalid filter usage). (alexandre-daubois) - -- FPM: - . Fixed bug GH-19817 (Decode SCRIPT_FILENAME issue in php 8.5). - (Jakub Zelenka) - . Fixed bug GH-19989 (PHP 8.5 FPM access log lines also go to STDERR). - (Jakub Zelenka) - . Fixed GH-17645 (FPM with httpd ProxyPass does not decode script path). - (Jakub Zelenka) - . Make FPM access log limit configurable using log_limit. (Jakub Zelenka) - . Fixed failed debug assertion when php_admin_value setting fails. (ilutov) - . Fixed GH-8157 (post_max_size evaluates .user.ini too late in php-fpm). - (Jakub Zelenka) - -- GD: - . Fixed bug #68629 (Transparent artifacts when using imagerotate). (pierre, - cmb) - . Fixed bug #64823 (ZTS GD fails to find system TrueType font). (cmb) - . Fix incorrect comparison with result of php_stream_can_cast(). (Girgias) - . The imagedestroy() function has been deprecated. (DanielEScherzer) - -- Iconv: - . Extends the ICONV_CONST preprocessor for illumos/solaris. (jMichaelA) - -- Intl: - . Bumped ICU requirement to ICU >= 57.1. (cmb) - . IntlDateFormatter::setTimeZone()/datefmt_set_timezone() throws an exception - with uninitialised classes or clone failure. (David Carlier) - . Added DECIMAL_COMPACT_SHORT/DECIMAL_COMPACT_LONG for NumberFormatter class. - (BogdanUngureanu) - . Added Locale::isRightToLeft to check if a locale is written right to left. - (David Carlier) - . Added null bytes presence in locale inputs for Locale class. (David Carlier) - . Added grapheme_levenshtein() function. (Yuya Hamada) - . Added Locale::addLikelySubtags/Locale::minimizeSubtags to handle - adding/removing likely subtags to a locale. (David Carlier) - . Added IntlListFormatter class to format a list of items with a locale, - operands types and units. (BogdanUngureanu) - . Added grapheme_strpos(), grapheme_stripos(), grapheme_strrpos(), - grapheme_strripos(), grapheme_substr(), grapheme_strstr(), grapheme_stristr() and - grapheme_levenshtein() functions add $locale parameter (Yuya Hamada). - . Fixed bug GH-11952 (Fix locale strings canonicalization for IntlDateFormatter - and NumberFormatter). (alexandre-daubois) - . Fixed bug GH-18566 ([intl] Weird numeric sort in Collator). (nielsdos) - . Fix return value on failure for resourcebundle count handler. (Girgias) - . Fixed bug GH-19307 (PGO builds of shared ext-intl are broken). (cmb) - . Intl's internal error mechanism has been modernized so that it - indicates more accurately which call site caused what error. - Moreover, some ext/date exceptions have been wrapped inside a - IntlException now. (Girgias) - . The intl.error_level INI setting has been deprecated. (Girgias) +- Mbstring + . Fixed bug GH-20674 (Fix GH-20674 mb_decode_mimeheader does not handle + separator). (Yuya Hamada) -- LDAP: - . Allow ldap_get_option to retrieve global option by allowing NULL for - connection instance ($ldap). (Remi) - -- MBstring: - . Updated Unicode data tables to Unicode 17.0. (Yuya Hamada) - -- MySQLi: - . Fixed bugs GH-17900 and GH-8084 (calling mysqli::__construct twice). - (nielsdos) - . The mysqli_execute() alias function has been deprecated. (timwolla) - -- MySQLnd: - . Added mysqlnd.collect_memory_statistics to ini quick reference. - (hauk92) +- Fibers: + . Fixed bug GH-20483 (ASAN stack overflow with fiber.stack_size INI + small value). (David Carlier) -- ODBC: - . Removed driver-specific build flags and support. (Calvin Buckley) - . Remove ODBCVER and assume ODBC 3.5. (Calvin Buckley) +- Mbstring: + . ini_set() with mbstring.detect_order changes the order of mb_detect_order + as intended, since mbstring.detect_order is an INI_ALL setting. (tobee94) + . Added GB18030-2022 to default encoding list for zh-CN. (HeRaNO) + . Fixed bug GH-20674 (Fix GH-20674 mb_decode_mimeheader does not handle + separator). (Yuya Hamada) - Opcache: - . Make OPcache non-optional (Arnaud, timwolla) - . Added opcache.file_cache_read_only. (Samuel Melrose) - . Updated default value of opcache.jit_hot_loop. (Arnaud) - . Log a warning when opcache lock file permissions could not be changed. - (Taavi Eomäe) - . Fixed bug GH-20012 (heap buffer overflow in jit). (Arnaud) - . Partially fixed bug GH-17733 (Avoid calling wrong function when reusing file - caches across differing environments). (ilutov) - . Disallow changing opcache.memory_consumption when SHM is already set up. - (timwolla) - . Fixed bug GH-15074 (Compiling opcache statically into ZTS PHP fails). - (Arnaud) - . Fixed bug GH-17422 (OPcache bypasses the user-defined error handler for - deprecations). (Arnaud, timwolla) - . Fixed bug GH-19301 (opcache build failure). (Remi) - . Fixed bug GH-20081 (access to uninitialized vars in preload_load()). - (Arnaud) - . Fixed bug GH-20121 (JIT broken in ZTS builds on MacOS 15). - (Arnaud, Shivam Mathur) - . Fixed bug GH-19875 (JIT 1205 segfault on large file compiled in subprocess). - (Arnaud) - . Fixed segfault in function JIT due to NAN to bool warning. (Girgias) - . Fixed bug GH-19984 (Double-free of EG(errors)/persistent_script->warnings on - persist of already persisted file). (ilutov, Arnaud) - . Fixed bug GH-19889 (race condition in zend_runtime_jit(), - zend_jit_hot_func()). (Arnaud) - . Fixed bug GH-19669 (assertion failure in zend_jit_trace_type_to_info_ex). - (Arnaud) - . Fixed bug GH-19831 (function JIT may not deref property value). (Arnaud) - . Fixed bug GH-19486 (Incorrect opline after deoptimization). (Arnaud) - . Fixed bug GH-19601 (Wrong JIT stack setup on aarch64/clang). (Arnaud) - . Fixed bug GH-19388 (Broken opcache.huge_code_pages). (Arnaud) - . Fixed bug GH-19657 (Build fails on non-glibc/musl/freebsd/macos/win - platforms). (Arnaud) - . Fixed ZTS OPcache build on Cygwin. (cmb) - . Fixed bug GH-19493 (JIT variable not stored before YIELD). (Arnaud) - -- OpenSSL: - . Added openssl.libctx INI that allows to select the OpenSSL library context - type and convert various parts of the extension to use the custom libctx. - (Jakub Zelenka) - . Add $digest_algo parameter to openssl_public_encrypt() and - openssl_private_decrypt() functions. (Jakub Zelenka) - . Implement #81724 (openssl_cms_encrypt only allows specific ciphers). - (Jakub Zelenka) - . Implement #80495 (Enable to set padding in openssl_(sign|verify). - (Jakub Zelenka) - . Implement #47728 (openssl_pkcs7_sign ignores new openssl flags). - (Jakub Zelenka) - . Fixed bug GH-19994 (openssl_get_cipher_methods inconsistent with fetching). - (Jakub Zelenka) - . Fixed build when --with-openssl-legacy-provider set. (Jakub Zelenka) - . Fixed bug GH-19369 (8.5 | Regression in openssl_sign() - support for alias - algorithms appears to be broken). (Jakub Zelenka) - . The $key_length parameter for openssl_pkey_derive() has been deprecated. - (Girgias) - -- Output: - . Fixed calculation of aligned buffer size. (cmb) - -- PCNTL: - . Extend pcntl_waitid with rusage parameter. (vrza) - -- PCRE: - . Remove PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK from pcre compile options. - (mvorisek) - -- PDO: - . Fixed bug GH-20095 (Incorrect class name in deprecation message for PDO - mixins). (timwolla) - . Driver specific methods and constants in the PDO class - are now deprecated. (Arnaud) - . The "uri:" DSN scheme has been deprecated due to security concerns with - DSNs coming from remote URIs. (timwolla) - -- PDO_ODBC: - . Fetch larger block sizes and better handle SQL_NO_TOTAL when calling - SQLGetData. (Calvin Buckley, Saki Takamachi) + . Fixed bug GH-20051 (apache2 shutdowns when restart is requested during + preloading). (Arnaud, welcomycozyhom) - PDO_PGSQL: - . Added Iterable support for PDO::pgsqlCopyFromArray. (KentarouTakeda) - . Implement GH-15387 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0) or - Pdo\Pgsql::prepare(…, [ PDO::ATTR_PREFETCH => 0 ]) make fetch() lazy - instead of storing the whole result set in memory (Guillaume Outters) - -- PDO_SQLITE: - . Add PDO\Sqlite::ATTR_TRANSACTION_MODE connection attribute. - (Samuel Štancl) - . Implement GH-17321: Add setAuthorizer to Pdo\Sqlite. (nielsdos) - . PDO::sqliteCreateCollation now throws a TypeError if the callback - has a wrong return type. (David Carlier) - . Added Pdo_Sqlite::ATTR_BUSY_STATEMENT constant to check - if a statement is currently executing. (David Carlier) - . Added Pdo_Sqlite::ATTR_EXPLAIN_STATEMENT constant to set a statement - in either EXPLAIN_MODE_PREPARED, EXPLAIN_MODE_EXPLAIN, - EXPLAIN_MODE_EXPLAIN_QUERY_PLAN modes. (David Carlier) - . Fix bug GH-13952 (sqlite PDO::quote silently corrupts strings - with null bytes) by throwing on null bytes. (divinity76) - -- PGSQL: - . Added pg_close_stmt to close a prepared statement while allowing - its name to be reused. (David Carlier) - . Added Iterable support for pgsql_copy_from. (David Carlier) - . pg_connect checks if connection_string contains any null byte, - pg_close_stmt check if the statement contains any null byte. - (David Carlier) - . Added pg_service to get the connection current service identifier. - (David Carlier) - . Fix segfaults when attempting to fetch row into a non-instantiable class - name. (Girgias, nielsdos) + . Clear session-local state disconnect-equivalent processing. + (KentarouTakeda) - Phar: - . Fix potential buffer length truncation due to usage of type int instead - of type size_t. (Girgias) - . Fixed memory leaks when verifying OpenSSL signature. (Girgias) - -- POSIX: - . Added POSIX_SC_OPEN_MAX constant to get the number of file descriptors - a process can handle. (David Carlier) - . posix_ttyname() sets last_error to EBADF on invalid file descriptors, - posix_isatty() raises E_WARNING on invalid file descriptors, - posix_fpathconf checks invalid file descriptors. (David Carlier) - . posix_kill and posix_setpgid throws a ValueError on invalid process_id. - (David Carlier) - . posix_setpgid throws a ValueError on invalid process_group_id, - posix_setrlimit throws a ValueError on invalid soft_limit and hard_limit - arguments. (David Carlier) - -- Random: - . Moves from /dev/urandom usage to arc4random_buf on Haiku. (David Carlier) + . Support reference values in Phar::mungServer(). (ndossche) + . Invalid values now throw in Phar::mungServer() instead of being silently + ignored. (ndossche) + . Support overridden methods in SplFileInfo for getMTime() and getPathname() + when building a phar. (ndossche) - Reflection: - . Added ReflectionConstant::getExtension() and ::getExtensionName(). - (DanielEScherzer) - . Added ReflectionProperty::getMangledName() method. (alexandre-daubois) - . ReflectionConstant is no longer final. (sasezaki) - . The setAccessible() methods of various Reflection objects have been - deprecated, as those no longer have an effect. (timwolla) - . ReflectionClass::getConstant() for constants that do not exist has been - deprecated. (DanielEScherzer) - . ReflectionProperty::getDefaultValue() for properties without default values - has been deprecated. (DanielEScherzer) - . Fixed bug GH-12856 (ReflectionClass::getStaticPropertyValue() returns UNDEF - zval for uninitialized typed properties). (nielsdos) - . Fixed bug GH-15766 (ReflectionClass::__toString() should have better output - for enums). (DanielEScherzer) - . Fix GH-19691 (getModifierNames() not reporting asymmetric visibility). - (DanielEScherzer) - . Fixed bug GH-17927 (Reflection: have some indication of property hooks in - `_property_string()`). (DanielEScherzer) - . Fixed bug GH-19187 (ReflectionNamedType::getName() prints nullable type when - retrieved from ReflectionProperty::getSettableType()). (ilutov) . Fixed bug GH-20217 (ReflectionClass::isIterable() incorrectly returns true for classes with property hooks). (alexandre-daubois) -- SAPI: - . Fixed bug GH-18582 and #81451: http_response_code() does not override the - status code generated by header(). (ilutov, Jakub Zelenka) - -- Session: - . session_start() throws a ValueError on option argument if not a hashmap - or a TypeError if read_and_close value is not compatible with int. - (David Carlier) - . Added support for partitioned cookies. (nielsdos) - . Fix RC violation of session SID constant deprecation attribute. (ilutov) - . Fixed GH-19197: build broken with ZEND_STRL usage with memcpy - when implemented as macro. (David Carlier) - -- SimpleXML: - . Fixed bug GH-12231 (SimpleXML xpath should warn when returning other return - types than node lists). (nielsdos) - -- SNMP: - . snmpget, snmpset, snmp_get2, snmp_set2, snmp_get3, snmp_set3 and - SNMP::__construct() throw an exception on invalid hostname, community - timeout and retries arguments. (David Carlier) - -- SOAP: - . Added support for configuring the URI parser for SoapClient::__doRequest() - as described in https://wiki.php.net/rfc/url_parsing_api#plugability. - (kocsismate) - . Implement request #55503 (Extend __getTypes to support enumerations). - (nielsdos, datibbaw) - . Implement request #61105 (Support Soap 1.2 SoapFault Reason Text lang - attribute). (nielsdos) - . Fixed bug #49169 (SoapServer calls wrong function, although "SOAP action" - header is correct). (nielsdos) - . Fix namespace handling of WSDL and XML schema in SOAP, - fixing at least GH-16320 and bug #68576. (nielsdos) - . Fixed bug #70951 (Segmentation fault on invalid WSDL cache). (nielsdos) - . Fixed bug GH-19773 (SIGSEGV due to uninitialized soap_globals->lang_en). - (nielsdos, KaseyJenkins) - . Fixed bug GH-19226 (Segfault when spawning new thread in soap extension). - (Florian Engelhardt) +- Soap: + . Soap::__setCookie() when cookie name is a digit is now not stored and represented + as a string anymore but a int. (David Carlier) - Sockets: - . Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage. - (David Carlier) - . Added TCP_FUNCTION_BLK to change the TCP stack algorithm on FreeBSD. - (David Carlier) - . Added IP_BINDANY for a socket to bind to any address. (David Carlier) - . Added SO_BUSY_POOL to reduce packets poll latency. (David Carlier) - . Added UDP_SEGMENT support to optimise multiple large datagrams over UDP - if the kernel and hardware supports it. (David Carlier) - . Added SHUT_RD, SHUT_WR and SHUT_RDWR constants for socket_shutdown(). - (David Carlier) - . Added TCP_FUNCTION_ALIAS, TCP_REUSPORT_LB_NUMA, TCP_REUSPORT_LB_NUMA_NODOM, - TCP_REUSPORT_LB_CURDOM, TCP_BBR_ALGORITHM constants. - . socket_set_option() catches possible overflow with SO_RCVTIMEO/SO_SNDTIMEO - with timeout setting on windows. (David Carlier) - . socket_create_listen() throws an exception on invalid port value. - (David Carlier) - . socket_bind() throws an exception on invalid port value. - (David Carlier) - . socket_sendto() throws an exception on invalid port value. - (David Carlier) - . socket_addrinfo_lookup throws an exception on invalid hints value types. - (David Carlier) - . socket_addrinfo_lookup throws an exception if any of the hints value - overflows. (David Carlier) - . socket_addrinfo_lookup throws an exception if one or more hints entries - has an index as numeric. (David Carlier) - . socket_set_option with the options MCAST_LEAVE_GROUP/MCAST_LEAVE_SOURCE_GROUP - will throw an exception if its value is not a valid array/object. - (David Carlier) - . socket_getsockname/socket_create/socket_bind handled AF_PACKET family socket. - (David Carlier) - . socket_set_option for multicast context throws a ValueError - when the socket family is not of AF_INET/AF_INET6 family. (David Carlier) - -- Sodium: - . Fix overall theoretical overflows on zend_string buffer allocations. - (David Carlier/nielsdos) + . Added the TCP_USER_TIMEOUT constant for Linux to set the maximum time in milliseconds + transmitted data can remain unacknowledged. (James Lucas) - SPL: - . Fixed bug GH-20101 (SplHeap/SplPriorityQueue serialization - exposes INDIRECTs). (nielsdos) - . Improve __unserialize() hardening for SplHeap/SplPriorityQueue. (nielsdos) - . Deprecate ArrayObject and ArrayIterator with objects. (Girgias) - . Unregistering all autoloaders by passing the spl_autoload_call() function - as a callback argument to spl_autoload_unregister() has been deprecated. - Instead if this is needed, one should iterate over the return value of - spl_autoload_functions() and call spl_autoload_unregister() on each - value. (Girgias) - . The SplObjectStorage::contains(), SplObjectStorage::attach(), and - SplObjectStorage::detach() methods have been deprecated in favour of - SplObjectStorage::offsetExists(), SplObjectStorage::offsetSet(), and - SplObjectStorage::offsetUnset() respectively. (Girgias) + . DirectoryIterator key can now work better with filesystem supporting larger + directory indexing. (David Carlier) -- Sqlite: - . Added Sqlite3Stmt::busy to check if a statement is still being executed. - (David Carlier) - . Added Sqlite3Stmt::explain to produce an explain query plan from - the statement. (David Carlier) - . Added Sqlite3Result::fetchAll to return all results at once from a query. - (David Carlier) +- Sqlite3: + . Fix NUL byte truncation in sqlite3 TEXT column handling. (ndossche) - Standard: - . Add HEIF/HEIC support to getimagesize. (Benstone Zhang) - . Added support for partitioned cookies. (nielsdos) - . Implement #71517 (Implement SVG support for getimagesize() and friends). - (nielsdos) - . Implement GH-19188: Add support for new INI mail.cr_lf_mode. - (alexandre-daubois) - . Optimized PHP html_entity_decode function. (Artem Ukrainskiy) - . Minor optimization to array_chunk(). (nielsdos) - . Optimized pack(). (nielsdos, divinity76) - . Fixed crypt() tests on musl when using --with-external-libcrypt - (Michael Orlitzky). - . Fixed bug GH-18062 (is_callable(func(...), callable_name: $name) for first - class callables returns wrong name). (timwolla) - . Added array_first() and array_last(). (nielsdos) - . Fixed bug GH-18823 (setlocale's 2nd and 3rd argument ignores strict_types). - (nielsdos) - . Fixed exit code handling of sendmail cmd and added warnings. - (Jesse Hathaway) - . Fixed bug GH-18897 (printf: empty precision is interpreted as precision 6, - not as precision 0). (nielsdos) - . Fixed bug GH-20257 (mail() heap overflow with an empty message in lf mode). - (David Carlier) - . Fixed bug GH-20201 (AVIF images misdetected as HEIF after introducing HEIF - support in getimagesize()). (nielsdos) . Fixed bug GH-19926 (reset internal pointer earlier while splicing array while COW violation flag is still set). (alexandre-daubois) - . Fixed bug GH-19801 (leaks in var_dump() and debug_zval_dump()). - (alexandre-daubois) - . Fixed GH-14402 (SplPriorityQueue, SplMinHeap, and SplMaxHeap lost their - data on serialize()). (alexandre-daubois) - . Fixed GH-19610 (Deprecation warnings in functions taking as argument). - (Girgias) - . Fixed bug GH-19577 (Avoid integer overflow when using a small offset - and PHP_INT_MAX with LimitIterator). (alexandre-daubois) - . Fixed bug GH-19153 (#[\Attribute] validation should error on - trait/interface/enum/abstract class). (DanielEScherzer) - . Fixed bug GH-19070 (setlocale($type, NULL) should not be deprecated). - (nielsdos) - . Fixed bug GH-16649 (UAF during array_splice). (alexandre-daubois) - . Passing strings which are not one byte long to ord() is now deprecated. - (Girgias) - . Passing integers outside the interval [0, 255] to chr() is now deprecated. - (Girgias) - . The socket_set_timeout() alias function has been deprecated. (timwolla) - . Passing null to readdir(), rewinddir(), and closedir() to use the last - opened directory has been deprecated. (Girgias) - Streams: - . Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows). - (cmb) - . Fixed bug GH-19798: XP_SOCKET XP_SSL (Socket stream modules): Incorrect - condition for Win32/Win64. (Jakub Zelenka) - . Fixed bug GH-14506 (Closing a userspace stream inside a userspace handler - causes heap corruption). (nielsdos) - . Avoid double conversion to string in php_userstreamop_readdir(). (nielsdos) - -- Tests: - . Allow to shuffle tests even in non-parallel mode. (dhuang00) - -- Tidy: - . tidy::__construct/parseFile/parseString methods throw an exception if - the configuration argument is invalid. (David Carlier) - . Fixed GH-19021 (improved tidyOptGetCategory detection). - (arjendekorte, David Carlier, Peter Kokot) - -- Tokenizer: - . Fixed bug GH-19507 (Corrupted result after recursive tokenization during - token_get_all()). (kubawerlos, nielsdos, Arnaud) - -- Windows: - . Fixed bug GH-10992 (Improper long path support for relative paths). (cmb, - nielsdos) - . Fixed bug GH-16843 (Windows phpize builds ignore source subfolders). (cmb) - . Fix GH-19722 (_get_osfhandle asserts in debug mode when given a socket). - (dktapps) - -- XML: - . The xml_parser_free() function has been deprecated. (DanielEScherzer) - -- XMLWriter: - . Improved performance and reduce memory consumption. (nielsdos) - -- XSL: - . Implement request #30622 (make $namespace parameter functional). (nielsdos) - -- Zlib: - . gzfile, gzopen and readgzfile, their "use_include_path" argument - is now a boolean. (David Carlier) - . Fixed bug GH-16883 (gzopen() does not use the default stream context when - opening HTTP URLs). (nielsdos) - . Implemented GH-17668 (zlib streams should support locking). (nielsdos) + . Added so_reuseaddr streams context socket option that allows disabling + address resuse. + . Fixed bug GH-20370 (User stream filters could violate typed property + constraints). (alexandre-daubois) - Zip: - . Fixed missing zend_release_fcall_info_cache on the following methods - ZipArchive::registerProgressCallback() and ZipArchive::registerCancelCallback() - on failure. (David Carlier) + . Fixed ZipArchive callback being called after executor has shut down. + (ilutov) + . Support minimum version for libzip dependency updated to 1.0.0. + (David Carlier) + +<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>> diff --git a/UPGRADING b/UPGRADING index 94b272c69c70f..d52827bf96154 100644 --- a/UPGRADING +++ b/UPGRADING @@ -1,4 +1,4 @@ -PHP 8.5 UPGRADE NOTES +PHP 8.6 UPGRADE NOTES 1. Backward Incompatible Changes 2. New Features @@ -19,811 +19,66 @@ PHP 8.5 UPGRADE NOTES 1. Backward Incompatible Changes ======================================== -- Core: - . It is no longer possible to use "array" and "callable" as class alias names - in class_alias(). - . Loosely comparing uncomparable objects (e.g. enums, \CurlHandle and other - internal classes) to booleans was previously inconsistent. If compared to a - boolean literal $object == true, it would behave the same way as (bool) - $object. If compared to a statically unknown value $object == $true, it - would always return false. This behavior was consolidated to always follow - the behavior of (bool) $object. - . The return value of gc_collect_cycles() no longer includes strings and - resources that were indirectly collected through cycles. - . It is now allowed to substitute static with self or the concrete class name - in final subclasses. - . The tick handlers are now deactivated after all shutdown functions, destructors - have run and the output handlers have been cleaned up. - This is a consequence of fixing GH-18033. - . Traits are now bound before the parent class. This is a subtle behavioral - change, but should more closely match user expectations, demonstrated by - GH-15753 and GH-16198. - . Errors emitted during compilation and class linking are now always delayed - and handled after compilation or class linking. Fatal errors emitted during - compilation or class linking cause any delayed errors to be handled - immediately, without calling user-defined error handlers. - . Exceptions thrown by user-defined error handlers when handling class linking - errors are not promoted to fatal errors anymore and do not prevent linking. - . Applying #[\Attribute] to an abstract class, enum, interface, or trait triggers - an error during compilation. Previously, the attribute could be added, but when - ReflectionAttribute::newInstance() was called an error would be thrown. - The error can be delayed from compilation to runtime using the new - #[\DelayedTargetValidation] attribute. - . The disable_classes INI setting has been removed as it causes various - engine assumptions to be broken. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#remove_disable_classes_ini_setting - . Destructuring non-array values (other than NULL) using [] or list() now - emits a warning. - RFC: https://wiki.php.net/rfc/warnings-php-8-5#destructuring_non-array_values - . A warning is now emitted when casting floats (or strings that look like - floats) to int if they cannot be represented as one. This affects explicit - int casts and implicit int casts. - RFC: https://wiki.php.net/rfc/warnings-php-8-5#casting_out_of_range_floats_to_int - . A warning is now emitted when casting NAN to other types. - RFC: https://wiki.php.net/rfc/warnings-php-8-5#coercing_nan_to_other_types - -- BZ2: - . bzcompress() now throws a ValueError when $block_size is not between - 1 and 9. - . bzcompress() now throws a ValueError when $work_factor is not between - 0 and 250. - -- DOM: - . Cloning a DOMNamedNodeMap, DOMNodeList, Dom\NamedNodeMap, Dom\NodeList, - Dom\HTMLCollection, and Dom\DtdNamedNodeMap now fails. - This never actually resulted in a working object, - so the impact should actually be zero. - -- FileInfo: - . finfo_file() and finfo::file() now throws a ValueError instead of a - TypeError when $filename contains nul bytes. - This aligns the type of Error thrown to be consistent with the rest of - the language. - -- Intl: - . The extension now requires at least ICU 57.1. - . The behaviour of Collator::SORT_REGULAR with respect to handling numeric - strings is now aligned with the behaviour of SORT_REGULAR in ext/standard. - This is a consequence of fixing bug GH-18566. - -- LDAP: - . ldap_get_option() and ldap_set_option() now throw a ValueError when - passing an invalid option. - -- MBstring: - . Unicode data tables have been updated to Unicode 17.0 - -- MySQLi: - . Calling the mysqli constructor on an already-constructed object - is now no longer possible and throws an Error. - -- ODBC: - . ODBC now assumes that at least ODBC 3.5 functionality is available. The - ODBCVER definition and build system flags to control it have been removed. - . ODBC no longer has build flags to build against specific drivers (except - for DB2) and removes special cases for those drivers. It is strongly - recommended to use a driver manager like iODBC or unixODBC on non-Windows. - -- Opcache: - . The Opcache extension is now always built into the PHP binary and is always - loaded. The INI directives opcache.enable and opcache.enable_cli are still - honored. - The --enable-opcache/--disable-opcache configure flags have been removed, - and the build does not produce opcache.so or php_opcache.dll objects - anymore. - Using zend_extension=opcache.so or zend_extension=php_opcache.dll INI - directives will emit a warning. - -- PCNTL: - . pcntl_exec() now throws ValueErrors when entries of the $args parameter - contain null bytes. - . pcntl_exec() now throws ValueErrors when entries or keys of the - $env_vars parameter contain null bytes. - -- PCRE: - . The extension is compiled without semi-deprecated - PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK compile option. - https://github.com/PCRE2Project/pcre2/issues/736#issuecomment-2754024651 - -- PDO: - . The constructor arguments set in conjunction with PDO::FETCH_CLASS now - follow the usual CUFA (call_user_func_array) semantics. - This means string keys will act like a named argument. - Moreover, automatic wrapping for by-value arguments passed to a by-ref - parameter has been removed, and the usual E_WARNING about this is now - emitted. - To pass a variable by-ref to a constructor argument use the general - array value reference assignment: $ctor_args = [&$valByRef] - . Attempting to call PDOStatement::setFetchMode during a call to PDO::fetch(), - PDO::fetchObject(), PDO::fetchAll(), - for example using tricks such as passing the statement object as a constructor - argument when fetching into an object, will now throw an Error. - . The value of the constants PDO::FETCH_GROUP, PDO::FETCH_UNIQUE, - PDO::FETCH_CLASSTYPE, PDO::FETCH_PROPS_LATE, and PDO::FETCH_SERIALIZE - have changed. - . A ValueError is now thrown if PDO::FETCH_PROPS_LATE is used with a fetch - mode different than PDO::FETCH_CLASS, consistent with other fetch flags. - . A ValueError is now thrown if PDO::FETCH_INTO is used as a fetch mode in - PDO::fetchAll(), similar to PDO::FETCH_LAZY. - -- PDO_FIREBIRD: - . A ValueError is now thrown when trying to set a cursor name that is too - long on a PDOStatement resulting from the Firebird driver. - -- Session: - . Attempting to write session data where $_SESSION has a key containing - the pipe character will now emit a warning instead of silently failing. - -- SimpleXML: - . Passing an XPath expression that returns something other than a node set - to SimpleXMLElement::xpath() will now emit a warning and return false, - instead of silently failing and returning an empty array. - -- SPL: - . ArrayObject no longer accepts enums, as modifying the $name or $value - properties can break engine assumptions. - . SplFileObject::fwrite's parameter $length is now nullable. The default - value changed from 0 to null. - -- Standard: - . Using a printf-family function with a formatter that did not specify the - precision previously incorrectly reset the precision instead of treating - it as a precision of 0. See GH-18897. - -- SOAP: - . SoapClient::__doRequest() expects a new, optional $uriParserClass parameter - as described in https://wiki.php.net/rfc/url_parsing_api#plugability. +- Phar: + . Invalid values now throw in Phar::mungServer() instead of being silently + ignored. ======================================== 2. New Features ======================================== - Core: - . Closure is now a proper subtype of callable - . Added support for Closures and first class callables in constant - expressions. - RFC: https://wiki.php.net/rfc/closures_in_const_expr - RFC: https://wiki.php.net/rfc/fcc_in_const_expr - . Fatal Errors (such as an exceeded maximum execution time) now include a - backtrace. - RFC: https://wiki.php.net/rfc/error_backtraces_v2 - . Added the #[\NoDiscard] attribute to indicate that a function's return - value is important and should be consumed. - RFC: https://wiki.php.net/rfc/marking_return_value_as_important - . Added the (void) cast to indicate that not using a value is intentional. - The (void) cast has no effect on the program's execution by itself, but - it can be used to suppress warnings emitted by #[\NoDiscard] and possibly - also diagnostics emitted by external IDEs or static analysis tools. - RFC: https://wiki.php.net/rfc/marking_return_value_as_important - . Added asymmetric visibility support for static properties. - RFC: https://wiki.php.net/rfc/static-aviz - . Added support for casts in constant expressions. - . Added support for attributes on compile-time non-class constants. - RFC: https://wiki.php.net/rfc/attributes-on-constants - . The #[\Deprecated] attribute can now be used on constants. - RFC: https://wiki.php.net/rfc/attributes-on-constants - . Added the pipe (|>) operator. - RFC: https://wiki.php.net/rfc/pipe-operator-v3 - . Constructor property promotion can now be used for final properties. - RFC: https://wiki.php.net/rfc/final_promotion - . #[\Override] can now be applied to properties. - RFC: https://wiki.php.net/rfc/override_properties - . The #[\DelayedTargetValidation] attribute can be used to suppress - compile-time errors from core (or extension) attributes that are used on - invalid targets. These errors are instead reported at runtime if and when - ReflectionAttribute::newInstance() is called. - RFC: https://wiki.php.net/rfc/delayedtargetvalidation_attribute - -- Curl: - . Added support for share handles that are persisted across multiple PHP - requests, safely allowing for more effective connection reuse. - RFC: https://wiki.php.net/rfc/curl_share_persistence_improvement - . Added support for CURLINFO_USED_PROXY (libcurl >= 8.7.0), - CURLINFO_HTTPAUTH_USED, and CURLINFO_PROXYAUTH_USED - (libcurl >= 8.12.0) to the curl_getinfo() function. - When curl_getinfo() returns an array, the same information - is available as "used_proxy", "httpauth_used", and "proxyauth_used" - keys. - CURLINFO_USED_PROXY gets zero set if no proxy was used in the - previous transfer or a non-zero value if a proxy was used. - CURLINFO_HTTPAUTH_USED and CURLINFO_PROXYAUTH_USED get bitmasks - indicating the HTTP and proxy authentication methods that were - used in the previous request. See CURLAUTH_* constants for - possible values. - . Added CURLOPT_INFILESIZE_LARGE Curl option, which is a safe - replacement for CURLOPT_INFILESIZE. On certain systems, - CURLOPT_INFILESIZE only accepts a 32-bit signed integer as the file - size (2.0 GiB) even on 64-bit systems. CURLOPT_INFILESIZE_LARGE - accepts the largest integer value the system can handle. - . Added CURLFOLLOW_OBEYCODE, CURLFOLLOW_FIRSTONLY and CURLFOLLOW_ALL values for - CURLOPT_FOLLOWLOCATION curl_easy_setopt option. - CURLFOLLOW_OBEYCODE to follow more strictly in regard to redirect - if they are allowed. CURLFOLLOW_FIRSTONLY to follow only the - first redirect thus if there is any follow up redirect, it won't go - any further. CURLFOLLOW_ALL is equivalent to setting CURLOPT_FOLLOWLOCATION - to true. - . Added support for CURLINFO_CONN_ID (libcurl >= 8.2.0) to the curl_getinfo() - function. This constant allows retrieving the unique ID of the connection - used by a cURL transfer. It is primarily useful when connection reuse or - connection pooling logic is needed in PHP-level applications. When - curl_getinfo() returns an array, this value is available as the "conn_id" key. - . Added support for CURLINFO_QUEUE_TIME_T (libcurl >= 8.6.0) to the curl_getinfo() - function. This constant allows retrieving the time (in microseconds) that the - request spent in libcurl’s connection queue before it was sent. - This value can also be retrieved by passing CURLINFO_QUEUE_TIME_T to the - curl_getinfo() $option parameter. - . Added support for CURLOPT_SSL_SIGNATURE_ALGORITHMS to specify the signature - algorithms to use for TLS. - -- DOM: - . Added Dom\Element::$outerHTML. - . Added $children property to Dom\ParentNode implementations. - -- EXIF: - . Add OffsetTime* Exif tags. - . Added support for HEIF/HEIC. - -- Filter: - . Add new FILTER_THROW_ON_FAILURE flag which can be passed to the filter - functions and will force an exception to be triggered when validation fails. - The new flag cannot be combined with FILTER_NULL_ON_FAILURE; trying - to do so will result in a ValueError being thrown. - RFC: https://wiki.php.net/rfc/filter_throw_on_failure + . It is now possible to use reference assign on WeakMap without the key + needing to be present beforehand. - Intl: - . Added class constants NumberFormatter::CURRENCY_ISO, - NumberFormatter::CURRENCY_PLURAL, NumberFormatter::CASH_CURRENCY, - and NumberFormatter::CURRENCY_STANDARD for various currency-related - number formats. - . Added Locale::addLikelySubtags and Locale::minimizeSubtags to - handle likely tags on a given locale. - . Added IntlListFormatter class to format, order, and punctuate - a list of items with a given locale, IntlListFormatter::TYPE_AND, - IntlListFormatter::TYPE_OR, IntlListFormatter::TYPE_UNITS operands and - IntlListFormatter::WIDTH_WIDE, IntlListFormatter::WIDTH_SHORT and - IntlListFormatter::WIDTH_NARROW widths. - It is supported from icu 67. - -- PDO_Sqlite: - . Added class constant Pdo_Sqlite::ATTR_BUSY_STATEMENT. - . Added class constants Pdo_Sqlite::ATTR_EXPLAIN_STATEMENT, - Pdo_Sqlite::EXPLAIN_MODE_PREPARED, Pdo_Sqlite::EXPLAIN_MODE_EXPLAIN, - Pdo_Sqlite::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN. - . Added PDO\Sqlite::ATTR_TRANSACTION_MODE connection attribute with - possible values PDO\Sqlite::TRANSACTION_MODE_DEFERRED, - PDO\Sqlite::TRANSACTION_MODE_IMMEDIATE, - and PDO\Sqlite::TRANSACTION_MODE_EXCLUSIVE, allowing to configure - the transaction mode to use when calling beginTransaction(). + . Added IntlNumberRangeFormatter class to format an interval of two numbers with a given skeleton, locale, IntlNumberRangeFormatter::COLLAPSE_AUTO, IntlNumberRangeFormatter::COLLAPSE_NONE, IntlNumberRangeFormatter::COLLAPSE_UNIT, IntlNumberRangeFormatter::COLLAPSE_ALL collapse and + IntlNumberRangeFormatter::IDENTITY_FALLBACK_SINGLE_VALUE, IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE, IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY and + IntlNumberRangeFormatter::IDENTITY_FALLBACK_RANGE identity fallbacks. + It is supported from icu 63. -- Session: - . session_set_cookie_params(), session_get_cookie_params(), and session_start() - now support partitioned cookies via the "partitioned" key. - RFC: https://wiki.php.net/rfc/CHIPS - -- SOAP: - . Enumeration cases are now dumped in __getTypes(). - . Implemented request #61105: - support for Soap 1.2 Reason Text xml:lang attribute. - The signature of SoapFault::__construct() and SoapServer::fault() therefore - now have an optional $lang parameter. - This support solves compatibility with .NET SOAP clients. - -- Sqlite: - . Added class constants Sqlite3Stmt::EXPLAIN_MODE_PREPARED, - Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN and - Sqlite3Stmt::EXPLAIN_MODE_EXPLAIN_QUERY_PLAN. - -- Standard: - . mail() now returns the actual sendmail error and detects if the sendmail - process was terminated unexpectedly. In such cases, a warning is emitted - and the function returns false. Previously, these errors were silently - ignored. This change affects only the sendmail transport. - . getimagesize() now supports HEIF/HEIC images. - . getimagesize() now supports SVG images when ext-libxml is also loaded. - Similarly, image_type_to_extension() and image_type_to_mime_type() - now also handle IMAGETYPE_SVG. - . The array returned by getimagesize() now has two additional entries: - "width_unit" and "height_unit" to indicate in which units the dimensions - are expressed. These units are px by default. They are not necessarily - the same (just to give one example: one may be cm and the other may be px). - . setcookie() and setrawcookie() now support the "partitioned" key. - RFC: https://wiki.php.net/rfc/CHIPS +- Phar: + . Overriding the getMTime() and getPathname() methods of SplFileInfo now + influences the result of the phar buildFrom family of functions. + This makes it possible to override the timestamp and names of files. -- XSL: - . The $namespace argument of XSLTProcessor::getParameter(), - XSLTProcessor::setParameter() and XSLTProcessor::removeParameter() - now actually works instead of being treated as empty. - This only works if the $name argument does not use Clark notation - and is not a QName because in those cases the namespace is taken - from the namespace href or prefix respectively. - -- Zlib: - . flock() is now supported on zlib streams. Previously, this always - failed to perform any locking action. +- Streams: + . Added stream socket context option so_reuseaddr that allows disabling + address reuse (SO_REUSEADDR) and explicitly uses SO_EXCLUSIVEADDRUSE on + Windows. ======================================== 3. Changes in SAPI modules ======================================== -- CLI: - . Trying to set a process title that is too long with cli_set_process_title() - will now fail instead of silently truncating the given title. - . Added a new --ini=diff option to print INI settings changed from the builtin - default. - -- FPM: - . FPM with httpd ProxyPass optionally decodes the full script path. Added - fastcgi.script_path_encoded INI setting to prevent this new behavior. - . FPM access log limit now respects log_limit value. - ======================================== 4. Deprecated Functionality ======================================== -- Core: - . Trying to produce output (e.g. with `echo`) within a user output handler - is deprecated. The deprecation warning will bypass the handler producing the - output to ensure it is visible; if there are nested output handlers the next - one will still be used. - RFC: https://wiki.php.net/rfc/deprecations_php_8_4 - . Non-canonical cast names (boolean), (integer), (double), and (binary) have - been deprecated, use (bool), (int), (float), and (string) respectively. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_non-standard_cast_names - . The $exclude_disabled parameter of the get_defined_functions() function has - been deprecated, as it no longer has any effect since PHP 8.0. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_exclude_disabled_parameter_of_get_defined_functions - . Terminating case statements with a semicolon instead of a colon has - been deprecated. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_semicolon_after_case_in_switch_statement - . The backtick operator as an alias for shell_exec() has been deprecated. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_backticks_as_an_alias_for_shell_exec - . Returning null from __debugInfo() has been deprecated. - Return an empty array instead. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_debuginfo_returning_null - . The report_memleaks INI directive has been deprecated. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_report_memleaks_ini_directive - . Constant redeclaration has been deprecated. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_constant_redeclaration - . Enacted the follow-up phase of the "Path to Saner Increment/Decrement - operators" RFC, meaning that incrementing non-numeric strings is now - deprecated. Instead the str_increment() function should be used. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#enact_follow-up_phase_of_the_path_to_saner_incrementdecrement_operators_rfc - . The following closure binding issues, which already emit an E_WARNING, are - now deprecated: - - Binding an instance to a static closure - - Binding methods to objects that are not instances of the class - (or subclass) that the method is defined - - Unbinding $this from a method - - Unbinding $this from a closure that uses `$this` - - Binding a closure to the scope of an internal class - - Rebinding the scope of a closure created from a function or method - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_closure_binding_issues - . Using null as an array offset or when calling array_key_exists() is now - deprecated. Instead an empty string should be used. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists - . Deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string for non-CLI - SAPIs has been deprecated. Configure register_argc_argv=0 and switch to either - $_GET or $_SERVER['QUERY_STRING'] to access the information, after verifying - that the usage is safe. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive - . The __sleep() and __wakeup() magic methods have been soft-deprecated. The - __serialize() and __unserialize() magic methods should be used instead, - or at the same time if compatibility with PHP 7 is required. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods - RFC: https://wiki.php.net/rfc/soft-deprecate-sleep-wakeup - -- Curl: - . The curl_close() function has been deprecated, as CurlHandle objects are - freed automatically. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_curl_close - . The curl_share_close() function has been deprecated, as CurlShareHandle - objects are freed automatically. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_curl_share_close - -- Date: - . The DATE_RFC7231 and DateTimeInterface::RFC7231 constants have been - deprecated. This is because the associated timezone is ignored and always - uses GMT. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_date_rfc7231_and_datetimeinterfacerfc7231 - . The __wakeup() magic method of DateTimeInterface, DateTime, - DateTimeImmutable, DateTimeZone, DateInterval, and DatePeriod has been - deprecated in favour of the __unserialize() magic method. - Related to RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_sleep_and_wakeup_magic_methods - -- FileInfo: - . The finfo_close() function has been deprecated. - As finfo objects are freed automatically. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_finfo_close - . The $context parameter of the finfo_buffer() function has been deprecated - as it is ignored. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_context_parameter_for_finfo_buffer - -- GD: - . The imagedestroy() function has been deprecated, as GdImage objects are - freed automatically. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_imagedestroy - -- Hash: - . The MHASH_* constants have been deprecated. These have been overlooked - when the mhash*() function family has been deprecated per - https://wiki.php.net/rfc/deprecations_php_8_1#mhash_function_family - -- Intl: - . The intl.error_level INI setting has been deprecated. - Errors should either be checked manually or exceptions should be enabled - by using the intl.use_exceptions INI setting. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_intlerror_level_ini_setting - -- LDAP: - - Specific Oracle Instant Client calls and constants have been deprecated. - List of affected calls: - ldap_connect() with wallet support - ldap_connect_wallet() - List of affected constants: - GSLC_SSL_NO_UATH - GSLC_SSL_ONEWAY_UATH - GSLC_SSL_TWOWAY_UATH - https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_building_ext_ldap_against_oracle_ldap - -- MySQLi: - . The mysqli_execute() alias function has been deprecated. - Use mysqli_stmt_execute() instead. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#formally_deprecate_mysqli_execute - -- OpenSSL: - . The $key_length parameter for openssl_pkey_derive() has been deprecated. - This is because it is either ignored, or truncates the key, which can be - a vulnerability. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_key_length_parameter_of_openssl_pkey_derive - -- PDO: - . The "uri:" DSN scheme has been deprecated due to security concerns with - DSNs coming from remote URIs. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_pdo_s_urischeme - . Driver specific constants in the PDO class have been deprecated. - List of affected constants and their replacement: - PDO::DBLIB_ATTR_CONNECTION_TIMEOUT => Pdo\Dblib::ATTR_CONNECTION_TIMEOUT - PDO::DBLIB_ATTR_QUERY_TIMEOUT => Pdo\Dblib::ATTR_QUERY_TIMEOUT - PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER => Pdo\Dblib::ATTR_STRINGIFY_UNIQUEIDENTIFIER - PDO::DBLIB_ATTR_VERSION => Pdo\Dblib::ATTR_VERSION - PDO::DBLIB_ATTR_TDS_VERSION => Pdo\Dblib::ATTR_TDS_VERSION - PDO::DBLIB_ATTR_SKIP_EMPTY_ROWSETS => Pdo\Dblib::ATTR_SKIP_EMPTY_ROWSETS - PDO::DBLIB_ATTR_DATETIME_CONVERT => Pdo\Dblib::ATTR_DATETIME_CONVERT - PDO::FB_ATTR_DATE_FORMAT => Pdo\Firebird::ATTR_DATE_FORMAT - PDO::FB_ATTR_TIME_FORMAT => Pdo\Firebird::ATTR_TIME_FORMAT - PDO::FB_ATTR_TIMESTAMP_FORMAT => Pdo\Firebird::ATTR_TIMESTAMP_FORMAT - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => Pdo\Mysql::ATTR_USE_BUFFERED_QUERY - PDO::MYSQL_ATTR_LOCAL_INFILE => Pdo\Mysql::ATTR_LOCAL_INFILE - PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY => Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY - PDO::MYSQL_ATTR_INIT_COMMAND => Pdo\Mysql::ATTR_INIT_COMMAND - PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => Pdo\Mysql::ATTR_MAX_BUFFER_SIZE - PDO::MYSQL_ATTR_READ_DEFAULT_FILE => Pdo\Mysql::ATTR_READ_DEFAULT_FILE - PDO::MYSQL_ATTR_READ_DEFAULT_GROUP => Pdo\Mysql::ATTR_READ_DEFAULT_GROUP - PDO::MYSQL_ATTR_COMPRESS => Pdo\Mysql::ATTR_COMPRESS - PDO::MYSQL_ATTR_DIRECT_QUERY => Pdo\Mysql::ATTR_DIRECT_QUERY - PDO::MYSQL_ATTR_FOUND_ROWS => Pdo\Mysql::ATTR_FOUND_ROWS - PDO::MYSQL_ATTR_IGNORE_SPACE => Pdo\Mysql::ATTR_IGNORE_SPACE - PDO::MYSQL_ATTR_SSL_KEY => Pdo\Mysql::ATTR_SSL_KEY - PDO::MYSQL_ATTR_SSL_CERT => Pdo\Mysql::ATTR_SSL_CERT - PDO::MYSQL_ATTR_SSL_CA => Pdo\Mysql::ATTR_SSL_CA - PDO::MYSQL_ATTR_SSL_CAPATH => Pdo\Mysql::ATTR_SSL_CAPATH - PDO::MYSQL_ATTR_SSL_CIPHER => Pdo\Mysql::ATTR_SSL_CIPHER - PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT - PDO::MYSQL_ATTR_SERVER_PUBLIC_KEY => Pdo\Mysql::ATTR_SERVER_PUBLIC_KEY - PDO::MYSQL_ATTR_MULTI_STATEMENTS => Pdo\Mysql::ATTR_MULTI_STATEMENTS - PDO::ODBC_ATTR_USE_CURSOR_LIBRARY => Pdo\Odbc::ATTR_USE_CURSOR_LIBRARY - PDO::ODBC_ATTR_ASSUME_UTF8 => Pdo\Odbc::ATTR_ASSUME_UTF8 - PDO::ODBC_SQL_USE_IF_NEEDED => Pdo\Odbc::SQL_USE_IF_NEEDED - PDO::ODBC_SQL_USE_DRIVER => Pdo\Odbc::SQL_USE_DRIVER - PDO::ODBC_SQL_USE_ODBC => Pdo\Odbc::SQL_USE_ODBC - PDO::PGSQL_ATTR_DISABLE_PREPARES => Pdo\Pgsql::ATTR_DISABLE_PREPARES - PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES => Pdo\Sqlite::ATTR_EXTENDED_RESULT_CODES - PDO::SQLITE_ATTR_OPEN_FLAGS => Pdo\Sqlite::OPEN_FLAGS - PDO::SQLITE_ATTR_READONLY_STATEMENT => Pdo\Sqlite::ATTR_READONLY_STATEMENT - PDO::SQLITE_DETERMINISTIC => Pdo\Sqlite::DETERMINISTIC - PDO::SQLITE_OPEN_READONLY => Pdo\Sqlite::OPEN_READONLY - PDO::SQLITE_OPEN_READWRITE => Pdo\Sqlite::OPEN_READWRITE - PDO::SQLITE_OPEN_CREATE => Pdo\Sqlite::OPEN_CREATE - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_driver_specific_pdo_constants_and_methods - . Driver specific methods in the PDO class have been deprecated. - List of affected methods and their replacement: - PDO::pgsqlCopyFromArray() => Pdo\Pgsql::copyFromArray() - PDO::pgsqlCopyFromFile() => Pdo\Pgsql::copyFromFile() - PDO::pgsqlCopyToArray() => Pdo\Pgsql::copyToArray() - PDO::pgsqlCopyToFile() => Pdo\Pgsql::copyToFile() - PDO::pgsqlGetNotify() => Pdo\Pgsql::getNotify() - PDO::pgsqlGetPid() => Pdo\Pgsql::getPid() - PDO::pgsqlLOBCreate() => Pdo\Pgsql::lobCreate() - PDO::pgsqlLOBOpen() => Pdo\Pgsql::lobOpen() - PDO::pgsqlLOBUnlink() => Pdo\Pgsql::lobUnlink() - PDO::sqliteCreateAggregate() => Pdo\Sqlite::createAggregate() - PDO::sqliteCreateCollation() => Pdo\Sqlite::createCollation() - PDO::sqliteCreateFunction() => Pdo\Sqlite::createFunction() - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_driver_specific_pdo_constants_and_methods - -- PDO_PGSQL: Constants related to transaction states have been deprecated: - PDO::PGSQL_TRANSACTION_IDLE, PDO::PGSQL_TRANSACTION_ACTIVE, PDO::PGSQL_TRANSACTION_INTRANS, - PDO::PGSQL_TRANSACTION_INERROR, PDO::PGSQL_TRANSACTION_UNKNOWN. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#extpdo_deprecations - -- Reflection: - . The setAccessible() methods of various Reflection objects have been - deprecated, as those no longer have an effect. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible - . Calling ReflectionClass::getConstant() for constants that do not exist has - been deprecated. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionclassgetconstant_for_missing_constants - . Calling ReflectionProperty::getDefaultValue() for properties without default - values has been deprecated. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionpropertygetdefaultvalue_for_properties_without_default_values - -- SPL: - . Unregistering all autoloaders by passing the spl_autoload_call() function - as a callback argument to spl_autoload_unregister() has been deprecated. - Instead if this is needed, one should iterate over the return value of - spl_autoload_functions() and call spl_autoload_unregister() on each value. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_spl_autoload_call_to_spl_autoload_unregister - . The SplObjectStorage::contains(), SplObjectStorage::attach(), and - SplObjectStorage::detach() methods have been deprecated in favour of - SplObjectStorage::offsetExists(), SplObjectStorage::offsetSet(), and - SplObjectStorage::offsetUnset() respectively. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_splobjectstoragecontains_splobjectstorageattach_and_splobjectstoragedetach - . Using ArrayObject and ArrayIterator with objects has been deprecated. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_arrayobject_and_arrayiterator_with_objects - -- Standard: - . The socket_set_timeout() alias function has been deprecated. - Use stream_set_timeout() instead. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#formally_deprecate_socket_set_timeout - . Passing null to to readdir(), rewinddir(), and closedir() to use the last - opened directory has been deprecated. Provide the last opened directory - explicitly instead. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_null_to_readdir_rewinddir_and_closedir - . Passing integers outside the interval [0, 255] to chr() is now deprecated. - This is because a byte can only hold a value within this interval. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_integers_outside_the_interval_0_255_to_chr - . Passing a string which is not a single byte to ord() is now deprecated, - this is indicative of a bug. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_passing_string_which_are_not_one_byte_long_to_ord - . The locally predefined variable $http_response_header is deprecated. - Instead one should call the http_get_last_response_headers() function. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_http_response_header_predefined_variable - -- XML: - . The xml_parser_free() function has been deprecated, as XMLParser objects - are freed automatically. - RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_xml_parser_free - ======================================== 5. Changed Functions ======================================== -- Intl: - . IntlDateFormatter::setTimeZone()/datefmt_set_timezone() - throws an IntlException on uninitialised classes/clone failures. - . grapheme_extract() properly assigns $next value when skipping over - invalid starting bytes. Previously there were cases where it would - point to the start of the grapheme boundary instead of the end. - . Locale:: methods throw a ValueError when locale inputs contain null - bytes. - . transliterator_get_error_code(), transliterator_get_error_message() - TransLiterator::getErrorCode(), and TransLiterator::getErrorMessage() - have dropped the false from the return type union. Returning false - was actually never possible. - . grapheme_strpos(), grapheme_stripos(), grapheme_strrpos(), - grapheme_strripos(), grapheme_substr(), grapheme_strstr() - and grapheme_stristr() functions add $locale parameter. - RFC: https://wiki.php.net/rfc/grapheme_add_locale_for_case_insensitive - -- LDAP: - . ldap_get_option() now accepts a NULL connection, like ldap_set_option(), - to allow retrieval of global options. - -- libxml: - . libxml_set_external_entity_loader() now has a formal return type of true. - -- OpenSSL: - . openssl_public_encrypt() and openssl_private_decrypt() have a new parameter - $digest_algo that allows specifying the hash digest algorithm for OAEP padding. - . openssl_sign() and openssl_verify() have a new parameter $padding to allow - using more secure RSA PSS padding. - . openssl_cms_encrypt() $cipher_algo parameter can be a string with the - cipher name. That allows to use more algorithms including AES GCM cipher - algorithms for auth enveloped data. - -- PCNTL: - . pcntl_exec() now has a formal return type of false. - . pcntl_waitid() takes an additional resource_usage argument to - gather various platform specific metrics about the child process. - -- PDO_PGSQL: - . PDO::pgsqlCopyFromArray now supports Iterable inputs. - . Pdo\Pgsql::setAttribute and Pdo\Pgsql::prepare support setting - PDO::ATTR_PREFETCH to 0 which enters lazy fetch mode. - In this mode, statements cannot be run in parallel. - -- PDO_SQLITE: - . SQLite PDO::quote() will now throw an exception or emit a warning, - depending on the error mode, if the string contains a null byte. - . PDO::sqliteCreateCollation will now throw an exception - if the callback has the wrong return type, making it more - in line with Pdo_Sqlite::createCollation behavior. - -- PGSQL: - . pg_copy_from now supports Iterable inputs. - . pg_connect checks if the connection_string argument contains - any null byte. - . pg_close_stmt checks if the statement_name argument contains - any null byte. - -- POSIX: - . posix_ttyname sets last_error to EBADF when encountering - an invalid file descriptor. - . posix_isatty raises an E_WARNING message when encountering - an invalid file descriptor. - . posix_fpathconf checks invalid file descriptors and sets - last_error to EBADF and raises an E_WARNING message. - . posix_kill throws a ValueError when the process_id argument is lower - or greater than what the platform supports (signed integer or long - range), posix_setpgid throws a ValueError when the process_id or - the process_group_id is lower than zero or greater than - what the platform supports. - . posix_setrlimit throws a ValueError when the hard_limit or soft_limit - arguments are lower than -1 or if soft_limit is greater than hard_limit. - -- Reflection: - . The output of ReflectionClass::__toString() for enums has changed to - better indicate that the class is an enum, and that the enum cases - are enum cases rather than normal class constants. - . The output of ReflectionProperty::__toString() for properties with - hooks has changed to indicate what hooks the property has, whether those - hooks are final, and whether the property is virtual. This also affects - the output of ReflectionClass::__toString() when a class contains hooked - properties. - . ReflectionAttribute::newInstance() can now throw errors for internal - attributes if the attribute was applied on an invalid target and the - error was delayed from compile time to runtime via the - #[\DelayedTargetValidation] attribute. - RFC: https://wiki.php.net/rfc/delayedtargetvalidation_attribute +- Phar: + . Phar::mungServer() now supports reference values. -- Session: - . session_start is stricter in regard to the options argument. - It throws a ValueError if the array is not a hashmap, or - a TypeError if the read_and_close value is not a valid type - compatible with int. - -- SNMP: - . snmpget, snmpset, snmp_get2, snmp_set2, snmp_get3, snmp_set3 - and SNMP::__construct() throw a ValueError when the hostname - is too large, contains any null byte or if the port is given - when negative or greater than 65535, timeout and retries values - are lower than -1 or too large. - -- Sockets: - . socket_create_listen, socket_bind and socket_sendto throw a - ValueError if the port is lower than 0 or greater than 65535, - and also if any of the hints array entries are indexed numerically. - . socket_addrinfo_lookup throws a TypeError if any of the hints - values cannot be cast to int and can throw a ValueError if - any of these values overflow. - . socket_set_option with MCAST_LEAVE_GROUP/MCAST_LEAVE_SOURCE_GROUP - options will throw an exception if the value isn't a valid object - or array. - . socket_create/socket_bind can create AF_PACKET family sockets. - . socket_getsockname gets the interface index and its string - representation with AF_PACKET socket. - . socket_set_option with multicast context throws a ValueError - when the created socket is not of AF_INET/AF_INET6 family. - -- Tidy: - . tidy::__construct/parseFile/parseString now throws a ValueError if the - configuration contains an invalid value or attempts to set a read-only - internal entry, and a TypeError if a configuration key is not a string. - -- Zlib: - . The "use_include_path" argument for the - gzfile, gzopen and readgzfile functions has been changed - from int to boolean. - . gzfile, gzopen and readgzfile functions now respect the default - stream context. +- Zip: + . ZipArchive::extractTo now raises a TypeError for the + files argument if one or more of the entries is not + a string. ======================================== 6. New Functions ======================================== -- Core: - . get_error_handler() allows retrieving the current user-defined error handler - function. - RFC: https://wiki.php.net/rfc/get-error-exception-handler - . get_exception_handler() allows retrieving the current user-defined exception - handler function. - RFC: https://wiki.php.net/rfc/get-error-exception-handler - . The clone language construct is now a function and supports reassigning - (readonly) properties during cloning via the new $withProperties parameter. - RFC: https://wiki.php.net/rfc/clone_with_v2 - . Added Closure::getCurrent() to receive currently executing closure. - -- Curl: - . curl_multi_get_handles() allows retrieving all CurlHandles currently - attached to a CurlMultiHandle. This includes both handles added using - curl_multi_add_handle() and handles accepted by CURLMOPT_PUSHFUNCTION. - . curl_share_init_persistent() allows creating a share handle that is - persisted across multiple PHP requests. - RFC: https://wiki.php.net/rfc/curl_share_persistence_improvement - -- DOM: - . Added Dom\Element::getElementsByClassName(). - . Added Dom\Element::insertAdjacentHTML(). - -- Enchant: - . Added enchant_dict_remove_from_session() to remove a word added to the - spellcheck session via enchant_dict_add_to_session(). - . Added enchant_dict_remove() to put a word on the exclusion list and - remove it from the session dictionary. - -- Intl: - . Added locale_is_right_to_left/Locale::isRightToLeft, returns true if - the locale is written right to left (after its enrichment with likely subtags). - . Added grapheme_levenshtein() function. - RFC: https://wiki.php.net/rfc/grapheme_levenshtein - -- Opcache: - . Added opcache_is_script_cached_in_file_cache(). - -- Pdo\Sqlite: - . Added support for Pdo\Sqlite::setAuthorizer(), which is the equivalent of - SQLite3::setAuthorizer(). The only interface difference is that the - pdo version returns void. - -- PGSQL: - . pg_close_stmt offers an alternative way to close a prepared - statement from the DEALLOCATE sql command in that we can reuse - its name afterwards. - . pg_service returns the ongoing service name of the connection. - -- Reflection: - . ReflectionConstant::getFileName() was introduced. - . ReflectionConstant::getExtension() and - ReflectionConstant::getExtensionName() were introduced. - . ReflectionConstant::getAttributes() was introduced. - RFC: https://wiki.php.net/rfc/attributes-on-constants - . ReflectionProperty::getMangledName() was introduced. - -- Sqlite: - . Sqlite3Stmt::busy to check if a statement had been fetched - but not completely. - - Standard: - . Added array_first() and array_last(). - RFC: https://wiki.php.net/rfc/array_first_last + . `clamp()` returns the given value if in range, else return the nearest bound. + RFC: https://wiki.php.net/rfc/clamp_v2 ======================================== 7. New Classes and Interfaces ======================================== -- Core: - . NoDiscard attribute was added. - RFC: https://wiki.php.net/rfc/marking_return_value_as_important - . DelayedTargetValidation attribute was added. - RFC: https://wiki.php.net/rfc/delayedtargetvalidation_attribute - -- Curl: - . CurlSharePersistentHandle representing a share handle that is persisted - across multiple PHP requests. - RFC: https://wiki.php.net/rfc/curl_share_persistence_improvement - -- Filter: - . Filter\FilterException and Filter\FilterFailedException for use - when FILTER_THROW_ON_FAILURE has been enabled. - RFC: https://wiki.php.net/rfc/filter_throw_on_failure - -- URI: - . Uri\UriException, Uri\InvalidUriException, Uri\UriComparisonMode, - Uri\Rfc3986\Uri, Uri\WhatWg\InvalidUrlException, - Uri\WhatWg\UrlValidationErrorType, Uri\WhatWg\UrlValidationError, - and Uri\WhatWg\Url are added. - RFC: https://wiki.php.net/rfc/url_parsing_api - ======================================== 8. Removed Extensions and SAPIs ======================================== @@ -832,249 +87,68 @@ PHP 8.5 UPGRADE NOTES 9. Other Changes to Extensions ======================================== -- Curl: - . curl_easy_setopt with CURLOPT_FOLLOWLOCATION option's value no longer - is treated as boolean but integer to handle CURLFOLLOW_OBEYCODE and - CURLFOLLOW_FIRSTONLY. - -- Fileinfo: - . Upgraded file from 5.45 to 5.46. - . The return type of finfo_close() has been changed to true, rather - than bool. - -- Intl: - . Intl's internal error mechanism has been modernized so that it - indicates more accurately which call site caused what error. - Moreover, some ext/date exceptions have been wrapped inside a - IntlException now. - -- Lexbor: - . An always enabled lexbor extension is added. It contains the lexbor - library that was separated from ext/dom for being reused among other - extensions. The new extension is not directly exposed to userland. - -- Opcache: - . The Opcache extension is now always built into the PHP binary and is always - loaded. The INI directives opcache.enable and opcache.enable_cli are still - honored. - -- URI: - . An always enabled uri extension is added that can be used for handling - URIs and URLs according to RFC 3986 and WHATWG URL. - RFC: https://wiki.php.net/rfc/url_parsing_api - -- PDO_Sqlite: - . Increased minimum release version support from 3.7.7 to 3.7.17. - -- Readline: - . The return types of readline_add_history(), readline_clear_history(), and - readline_callback_handler_install() have been changed to true, rather - than bool. - -- Reflection: - . ReflectionConstant is no longer final. +- Hash: + . The bundled version of xxHash was upgraded to 0.8.2. ======================================== 10. New Global Constants ======================================== -- Core: - . PHP_BUILD_DATE. - . PHP_BUILD_PROVIDER. - -- Curl: - . CURLINFO_USED_PROXY. - . CURLINFO_HTTPAUTH_USED. - . CURLINFO_PROXYAUTH_USED. - . CURLINFO_CONN_ID. - . CURLINFO_QUEUE_TIME_T. - . CURLOPT_INFILESIZE_LARGE. - . CURLFOLLOW_ALL. - . CURLFOLLOW_OBEYCODE. - . CURLFOLLOW_FIRSTONLY. - -- Filter: - . FILTER_THROW_ON_FAILURE. - -- Intl: - . DECIMAL_COMPACT_SHORT. - . DECIMAL_COMPACT_LONG. - -- OpenSSL: - . OPENSSL_PKCS1_PSS_PADDING. - . PKCS7_NOSMIMECAP. - . PKCS7_CRLFEOL. - . PKCS7_NOCRL. - . PKCS7_NO_DUAL_CONTENT. - -- POSIX: - . POSIX_SC_OPEN_MAX. - - Sockets: - . IPPROTO_ICMP/IPPROTO_ICMPV6. - . TCP_FUNCTION_BLK (FreeBSD only). - . TCP_FUNCTION_ALIAS (FreeBSD only). - . TCP_REUSPORT_LB_NUMA (FreeBSD only). - . TCP_REUSPORT_LB_NUMA_NODOM (FreeBSD only). - . TCP_REUSPORT_LB_NUMA_CURDOM (FreeBSD only). - . TCP_BBR_ALGORITHM (FreeBSD only). - . AF_PACKET (Linux only). - . ETH_P_IP (Linux only). - . ETH_P_IPV6 (Linux only). - . ETH_P_LOOP (Linux only). - . ETH_P_ALL (Linux only). - . IP_BINDANY (FreeBSD/NetBSD/OpenBSD only). - . SO_BUSY_POLL (Linux only). - . UDP_SEGMENT (Linux only). - . SHUT_RD. - . SHUT_WR. - . SHUT_RDWR. - -- Tokenizer: - . T_VOID_CAST. - . T_PIPE. - -- Standard: - . IMAGETYPE_SVG when libxml is loaded. + . TCP_USER_TIMEOUT (Linux only). ======================================== 11. Changes to INI File Handling ======================================== -- Core: - . Added fatal_error_backtraces to control whether fatal errors should include - a backtrace. - RFC: https://wiki.php.net/rfc/error_backtraces_v2 - . Added startup-only max_memory_limit INI setting to control the maximum - memory_limit that may be configured at startup or runtime. Exceeding this - value emits a warning, unless set to -1, and sets memory_limit to the - current max_memory_limit instead. - ML discussion: https://externals.io/message/127108 +- Mysqli: + . mysqli.default_port now checks the validity of the value which should be + between 0 and 65535 included. - Opcache: - . Added opcache.file_cache_read_only to support a read-only - opcache.file_cache directory, for use with read-only file systems - (e.g. read-only Docker containers). - Best used with opcache.validate_timestamps=0, - opcache.enable_file_override=1, - and opcache.file_cache_consistency_checks=0. - Note: A cache generated with a different build of PHP, a different file - path, or different settings (including which extensions are loaded), may be - ignored. - . The default value of opcache.jit_hot_loop is now 61 (a prime) to prevent it - from being a multiple of loop iteration counts. - It is recommended that this parameter is set to a prime number. - . Changing opcache.memory_consumption when OPcache SHM is already set up - will now correctly report a failure instead of silently doing nothing and - showing misleading values in PHPInfo. + . opcache.jit_debug accepts a new flag: ZEND_JIT_DEBUG_TRACE_EXIT_INFO_SRC. + When used along with ZEND_JIT_DEBUG_TRACE_EXIT_INFO, the source of exit + points is printed in exit info output, in debug builds. -- OpenSSL: - . Added openssl.libctx to select the OpenSSL library context type. Either - custom libctx for each thread can be used or a single global (default) - libctx is used. +- Mbstring: + . The mbstring.detect_order INI directive now updates the internal detection + order when changed at runtime via ini_set(). Previously, runtime changes + using ini_set() did not take effect for mb_detect_order(). Setting the + directive to NULL or an empty string at runtime now leaves the previously + configured detection order unchanged. ======================================== 12. Windows Support ======================================== -* The configuration variables PHP_VERSION, PHP_MINOR_VERSION, and - PHP_RELEASE_VERSION are now always numbers. Previously, they have been - strings for buildconf builds. - -* phpize builds now reflect the source tree in the build dir (as it already - worked for in-tree builds); some extension builds (especially when using - Makefile.frag.w32) may need adjustments. - -* --enable-sanitizer is now supported for MSVC builds. This enables ASan and - debug assertions, and is supported as of MSVC 16.10 and Windows 10. - -* The --with-uncritical-warn-choke configuration option for clang builds is - no longer supported. Select warnings to suppress via CFLAGS instead. - -* COM: - . The extension is now build shared by default; previously it defaulted to a - static extension, although the official Windows binaries built a shared - extension. - -* FFI: - . It is no longer necessary to specify the library when using FFI::cdef() - and FFI::load(). However, this convenience feature should not be used in - production. - -* Streams: - . If only pipe streams are contained in the $read array, and the $write and - $except arrays are empty, stream_select() now behaves similar to POSIX - systems, i.e. the function only returns if at least one pipe is ready to be - read, or after the timeout expires. Previously, stream_select() returned - immediately, reporting all streams as ready to read. - ======================================== 13. Other Changes ======================================== -- Core: - . The high resolution timer (`hrtime()`) on macOS now uses the recommended - `clock_gettime_nsec_np(CLOCK_UPTIME_RAW)` API instead of - `mach_absolute_time()`. - -- CLI/CGI: - . The `-z` or `--zend-extension` option has been removed as it was - non-functional. Use `-d zend_extension=` instead. - -- PDO_ODBC - . The fetch behaviour for larger columns has been changed. Rather than - fetching 256 byte blocks, PDO_ODBC will try to fetch a larger block size; - currently, this is the page size minus string overhead. Drivers that - return SQL_NO_TOTAL in SQLGetData are also better handled as well. - This should improve compatibility and performance. See GH-10809, GH-10733. - ======================================== 14. Performance Improvements ======================================== - Core: - . Remove OPcodes for identity comparisons against booleans, particularly - for the match(true) pattern. - . Add OPcode specialization for `=== []` and `!== []` comparisons. - . Creating exception objects is now much faster. - . The parts of the code that used SSE2 have been adapted to use SIMD - with ARM NEON as well. - . Introduced the TAILCALL VM, enabled by default when compiling with Clang>=19 - on x86_64 or aarch64. The TAILCALL VM is as fast as the HYBRID VM used when - compiling with GCC. This makes PHP binaries built with Clang>=19 as fast as - binaries built with GCC. The performance of the CALL VM, used with other - compilers, has also improved considerably. + . `printf()` using only `%s` and `%d` will be compiled into the equivalent + string interpolation, avoiding the overhead of a function call and repeatedly + parsing the format string. + . Arguments are now passed more efficiently to known constructors (e.g. when + using new self()). -- Intl: - . Now avoids creating extra string copies when converting strings - for use in the collator. - -- MBString: - . The parts of the code that used SSE2 have been adapted to use SIMD - with ARM NEON as well. - -- Opcache: - . Improved performance of fetching TLS variables in JIT'ed code in non-Glibc - builds. - -- ReflectionProperty: - . Improved performance of the following methods: getValue(), getRawValue(), - isInitialized(), setValue(), setRawValue(). +- DOM: + . Made splitText() faster and consume less memory. -- SPL: - . Improved performance of dimension accessors and methods of SplFixedArray. +- JSON: + . Improve performance of encoding arrays and objects. - Standard: - . Improved performance of array functions with callbacks - (array_find, array_filter, array_map, usort, ...). - . Improved performance of urlencode() and rawurlencode(). - . Improved unpack() performance with nameless repetitions by avoiding - creating temporary strings and reparsing them. - . Improved pack() performance. - . Minor improvements in array_chunk() performance. - -- XMLReader: - . Improved property access performance. - -- XMLWriter: - . Improved performance and reduced memory consumption. + . Improved performance of array_fill_keys(). + . Improved performance of array_map() with multiple arrays passed. + . Improved performance of array_unshift(). + . Improved performance of array_walk(). + . Improved performance of intval('+0b...', 2) and intval('0b...', 2). + . Improved performance of str_split(). + +- Zip: + . Avoid string copies in ZipArchive::addFromString(). diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 40b20b73d6b1f..3ec54f49391b8 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -1,4 +1,4 @@ -PHP 8.5 INTERNALS UPGRADE NOTES +PHP 8.6 INTERNALS UPGRADE NOTES 1. Internal API changes @@ -14,167 +14,66 @@ PHP 8.5 INTERNALS UPGRADE NOTES 1. Internal API changes ======================== - . PG(arg_separator).input and PG(arg_separator).output are now `zend_string*` - instead of `char*`. - . DL_LOAD now doesn't use RTLD_DEEPBIND deepbind anymore on platforms - where dlmopen with LM_ID_NEWLM is available: - this means shared library symbol isolation (if needed) must be enabled on - the user side when requiring libphp.so, by using dlmopen with LM_ID_NEWLM - instead of dlopen. - RTLD_DEEPBIND is still enabled when the Apache SAPI is in use. - . The ptr field of the php_stream_notifier struct is now a void* instead - of a zval. If the zval was used to store IS_PTR values only, the - extra layer of indirection can be removed. In other cases a zval can - be heap-allocated and stored in the pointer as a minimal change to keep - compatibility. - . The validator callbacks for internal attribute now return `zend_string *` - rather than `void`; instead of emitting an error when an attribute is - applied incorrectly, the error message should be returned as a zend_string - pointer. If the error will be delayed until runtime, it is stored in the - new `validation_error` field of the `zend_attribute` struct. - RFC: https://wiki.php.net/rfc/delayedtargetvalidation_attribute - . Added zend_safe_assign_to_variable_noref() function to safely assign - a value to a non-reference zval. - . Added zval_ptr_safe_dtor() to safely destroy a zval when a destructor - could interfere. - . zend_get_callable_name() now returns the name of the underlying function - for fake closures. - . Added smart_string_append_printf() matching smart_str_append_printf() for - char* instead of zend_string*-based smart strings. - . Added php_build_provider() to retrieve the value of PHP_BUILD_PROVIDER at - runtime. - . Removed the cache_slot argument of zend_check_user_type_slow() because - now it only relies on the CE cache. - . Added ZEND_NONSTRING attribute macro for character arrays that do not - represent strings. This allows to silence the GCC 15.x - `-Wunterminated-string-initialization` warning. - . Added the zend_update_exception_properties() function for instantiating - Exception child classes. It updates the $message, $code, and $previous - properties. - . zend_exception_get_default() was removed, use zend_ce_exception directly. - . zend_get_error_exception() was removed, use zend_ce_error_exception - directly. - . ZEND_IS_XDIGIT() macro was removed because it was unused and its name - did not match its actual behavior. - . The following zend_string-related legacy aliases were removed: - * IS_INTERNED() - use ZSTR_IS_INTERNED() - * STR_EMPTY_ALLOC() - use ZSTR_EMPTY_ALLOC() - * _STR_HEADER_SIZE - use _ZSTR_HEADER_SIZE - * STR_ALLOCA_ALLOC() - use ZSTR_ALLOCA_ALLOC() - * STR_ALLOCA_INIT() - use ZSTR_ALLOCA_INIT() - * STR_ALLOCA_FREE() - use ZSTR_ALLOCA_FREE() - . zend_register_constant() now returns a pointer to the added constant - on success and NULL on failure instead of SUCCESS/FAILURE. - The specialized registration methods that previously had void returns - also return pointers to the added constants: - * zend_register_bool_constant() - * zend_register_null_constant() - * zend_register_long_constant() - * zend_register_double_constant() - * zend_register_string_constant() - * zend_register_stringl_constant() - . EG(fake_scope) now is a _const_ zend_class_entry*. - . zend_begin_record_errors() or EG(record_errors)=true cause errors to be - delayed. Before, errors would be recorded but not delayed. - . zend_mm_refresh_key_child() must be called on any zend_mm_heap inherited - from the parent process after a fork(). - . HASH_KEY_IS_* constants have been moved in the zend_hash_key_type enum. + . ZSTR_INIT_LITERAL(), zend_string_starts_with_literal(), and + zend_string_starts_with_literal_ci() now support strings containing NUL + bytes. Passing non-literal char* is no longer supported. + . The misnamed ZVAL_IS_NULL() has been removed. Use Z_ISNULL() instead. + . New zend_class_entry.ce_flags2 and zend_function.fn_flags2 fields were + added, given the primary flags were running out of bits. + . The zval_is_true() alias of zend_is_true() has been removed. Call + zend_is_true() directly instead. + . The _zval_get_*() compatibility macros for PHP 7.2 have been removed + call the variant without the leading underscore instead. + Affected: _zval_get_long, _zval_get_double, _zval_get_string, + _zval_get_long_func, _zval_get_double_func, _zval_get_string_func + . CHECK_ZVAL_NULL_PATH() and CHECK_NULL_PATH() have been removed, use + zend_str_has_nul_byte(Z_STR_P(...)) and zend_char_has_nul_byte() + respectively. + . ZEND_LTOA() (and ZEND_LTOA_BUF_LEN) has been removed, as it was + unsafe. Directly use ZEND_LONG_FMT with a function from the + printf family. + . The zval_dtor() alias of zval_ptr_dtor_nogc() has been removed. + Call zval_ptr_dtor_nogc() directly instead. + . The internal zend_copy_parameters_array() function is no longer exposed. + . The zend_make_callable() function has been removed, if a callable zval + needs to be obtained use the zend_get_callable_zval_from_fcc() function + instead. If this was used to store a callable, then an FCC should be + stored instead. + . The zend_active_function{_ex}() functions now return a const zend_function + pointer. + . The zend_get_call_trampoline_func() API now takes the __call or + __callStatic zend_function* instead of a CE and a boolean argument. + . The zend_set_hash_symbol() API has been removed. + . Added zend_hash_str_lookup(). + . The WRONG_PARAM_COUNT and ZEND_WRONG_PARAM_COUNT() macros have been + removed. Call zend_wrong_param_count(); followed by RETURN_THROWS(); + instead. + . PHP_HAVE_STREAMS macro removed from . + . zend_function.arg_info is now always a zend_arg_info*. Before, it was a + zend_internal_arg_info on internal functions, unless the + ZEND_ACC_USER_ARG_INFO flag was set. ======================== 2. Build system changes ======================== -- Abstract - . Preprocessor macro SIZEOF_PTRDIFF_T has been removed. - . Preprocessor macro SIZEOF_INTMAX_T has been removed. - -- Windows build system changes - . SAPI() and ADD_SOURCES() now support the optional `duplicate_sources` - parameter. If truthy, no rules to build the object files are generated. - This allows to build additional variants of SAPIs (e.g. a DLL and EXE) - without duplicate build rules. It is up to the SAPI maintainers to ensure - that appropriate build rules are created. - -- Unix build system changes - . libdir is properly set when --libdir (ex: /usr/lib64) and --with-libdir (ex: lib64) - configure options are used to ${libdir}/php (ex: /usr/lib64/php) - . PHP_ODBC_CFLAGS, PHP_ODBC_LFLAGS, PHP_ODBC_LIBS, PHP_ODBC_TYPE preprocessor - macros defined by ext/odbc are now defined in php_config.h instead of the - build-defs.h header. - . Autoconf macro AX_CHECK_COMPILE_FLAG updated to serial 11. - . Autoconf macro PHP_AP_EXTRACT_VERSION has been removed. - . Autoconf macro PHP_BUILD_THREAD_SAFE has been removed (set enable_zts - manually). - . Autoconf macro PHP_CHECK_SIZEOF is obsolete (use AC_CHECK_SIZEOF). - . Autoconf macro PHP_DEF_HAVE has been removed (use AC_DEFINE). - . Autoconf macro PHP_OUTPUT has been removed (use AC_CONFIG_FILES). - . Autoconf macro PHP_TEST_BUILD has been removed (use AC_* macros). - . Preprocessor macro HAVE_PTRDIFF_T has been removed. - . Preprocessor macro HAVE_INTMAX_T has been removed. - . Preprocessor macro HAVE_SSIZE_T has been removed. - . Preprocessor macro SIZEOF_SSIZE_T has been removed. - ======================== 3. Module changes ======================== -- Gd: - . The gdImageScale*() and gdImageRotate*() helpers are now internal in the - bundled libgd, like they have been in external libgd as of gd-2.1.1. - -- Hash: - . Hash functions now use proper hash_spec_result enum for return values - instead of using SUCCESS and FAILURE. - -- JSON: - . php_json_encode_serializable_object() now assumes `EG(active)`, - if not a bailout is caused. Therefore a minor BC break exists if the - `PHP_JSON_PARTIAL_OUTPUT_ON_ERROR` option is in use. - However, this situation is highly unlikely. - -- Libxml: - . The refcount APIs now return an `unsigned int` instead of an `int`. - . Removed php_libxml_xmlCheckUTF8(). Use xmlCheckUTF8() from libxml instead. +- ext/xml: + . Removed the XML_ExpatVersion() libxml compatibility wrapper, + as it was unused. + . Removed the XML_GetCurrentByteCount() libxml compatibility wrapper, + as it was unused and could return the wrong result. -- PDO: - . Added `php_pdo_stmt_valid_db_obj_handle()` to check if the database object - is still valid. This is useful when a GC cycle is collected and the - database object can be destroyed prior to destroying the statement. - -- Random: - . The handlers parameter of php_random_engine_common_init() has been - removed. Use the default_object_handlers field on the CE instead. - -- Standard: - . Added php_url_decode_ex() and php_raw_url_decode_ex() that unlike their - non-ex counterparts do not work in-place. - . The php_std_date() function has been removed. Use php_format_date() with - the "D, d M Y H:i:s \\G\\M\\T" format instead. - . Added php_url_encode_to_smart_str() to encode a URL to a smart_str buffer. - . The functionality of getimagesize(), image_type_to_mime_type(), - and image_type_to_extension() is now extensible using the internal APIs - php_image_register_handler() and php_image_unregister_handler() in - php_image.h. - . ext/standard/php_smart_string.h and ext/standard/php_smart_string_public.h - were removed. Use the corresponding headers in Zend/ instead. - -- URI: - . New extension with an internal API for URI handling is available via the - php_uri_* symbols exposed in the ext/uri/ headers. +- ext/mbstring: + . Added GB18030-2022 to default encoding list for zh-CN. ======================== 4. OpCode changes ======================== -* New ZEND_DECLARE_ATTRIBUTED_CONST is used when a global constant is declared - with `const` and has attributes; this opcode is used *instead* of the - ZEND_DECLARE_CONST, and in addition to the name of the constant and the - value to use, has a ZEND_OP_DATA with a pointer to the compiled attributes. - ======================== 5. SAPI changes ======================== - -- SAPIs must now call php_child_init() after a fork. If php-src code was - executed in other threads than the one initiating the fork, - refresh_memory_manager() must be called in every such thread. diff --git a/Zend/Optimizer/block_pass.c b/Zend/Optimizer/block_pass.c index 77beec2f72a73..b1fd8e44222e5 100644 --- a/Zend/Optimizer/block_pass.c +++ b/Zend/Optimizer/block_pass.c @@ -30,9 +30,9 @@ #include "zend_dump.h" /* Checks if a constant (like "true") may be replaced by its value */ -bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int copy) +bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, bool copy) { - zend_constant *c = zend_hash_find_ptr(EG(zend_constants), name); + const zend_constant *c = zend_hash_find_ptr(EG(zend_constants), name); if (c) { if ((ZEND_CONSTANT_FLAGS(c) & CONST_PERSISTENT) && !(ZEND_CONSTANT_FLAGS(c) & CONST_DEPRECATED) @@ -42,9 +42,9 @@ bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int if (copy) { Z_TRY_ADDREF_P(result); } - return 1; + return true; } else { - return 0; + return false; } } @@ -52,9 +52,9 @@ bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int c = zend_get_special_const(ZSTR_VAL(name), ZSTR_LEN(name)); if (c) { ZVAL_COPY_VALUE(result, &c->value); - return 1; + return true; } - return 0; + return false; } /* Data dependencies macros */ @@ -62,9 +62,9 @@ bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int #define VAR_SOURCE(op) Tsource[VAR_NUM(op.var)] #define SET_VAR_SOURCE(opline) Tsource[VAR_NUM(opline->result.var)] = opline -static void strip_leading_nops(zend_op_array *op_array, zend_basic_block *b) +static void strip_leading_nops(const zend_op_array *op_array, zend_basic_block *b) { - zend_op *opcodes = op_array->opcodes; + const zend_op *opcodes = op_array->opcodes; do { b->start++; @@ -72,7 +72,7 @@ static void strip_leading_nops(zend_op_array *op_array, zend_basic_block *b) } while (b->len > 0 && opcodes[b->start].opcode == ZEND_NOP); } -static void strip_nops(zend_op_array *op_array, zend_basic_block *b) +static void strip_nops(const zend_op_array *op_array, zend_basic_block *b) { uint32_t i, j; @@ -106,7 +106,7 @@ static void strip_nops(zend_op_array *op_array, zend_basic_block *b) } } -static int get_const_switch_target(zend_cfg *cfg, zend_op_array *op_array, zend_basic_block *block, zend_op *opline, zval *val) { +static uint32_t get_const_switch_target(const zend_cfg *cfg, const zend_op_array *op_array, const zend_basic_block *block, zend_op *opline, const zval *val) { HashTable *jumptable = Z_ARRVAL(ZEND_OP2_LITERAL(opline)); zval *zv; if ((opline->opcode == ZEND_SWITCH_LONG && Z_TYPE_P(val) != IS_LONG) @@ -371,7 +371,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array } } else if(flen == sizeof("constant")-1 && zend_binary_strcasecmp(fname, flen, "constant", sizeof("constant")-1) == 0) { zval c; - if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, 1 ELS_CC)) { + if (zend_optimizer_get_persistent_constant(Z_STR_P(arg), &c, true ELS_CC)) { literal_dtor(arg); MAKE_NOP(sv); MAKE_NOP(fcall); @@ -409,7 +409,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array break; } if (opline->op1_type == IS_CONST) { - int target = get_const_switch_target(cfg, op_array, block, opline, &ZEND_OP1_LITERAL(opline)); + uint32_t target = get_const_switch_target(cfg, op_array, block, opline, &ZEND_OP1_LITERAL(opline)); literal_dtor(&ZEND_OP1_LITERAL(opline)); literal_dtor(&ZEND_OP2_LITERAL(opline)); opline->opcode = ZEND_JMP; @@ -822,7 +822,6 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array src->extended_value == IS_STRING && src->op1_type != IS_CONST) { /* convert T1 = CAST(STRING, X), T2 = CONCAT(Y, T1) to T2 = CONCAT(Y,X) */ - zend_op *src = VAR_SOURCE(opline->op2); VAR_SOURCE(opline->op2) = NULL; COPY_NODE(opline->op2, src->op1); MAKE_NOP(src); @@ -949,14 +948,14 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array src = VAR_SOURCE(opline->op1); if (src && src->opcode == ZEND_QM_ASSIGN) { zend_op *op = src + 1; - bool optimize = 1; + bool optimize = true; while (op < opline) { if ((op->op1_type == opline->op1_type && op->op1.var == opline->op1.var) || (op->op2_type == opline->op1_type && op->op2.var == opline->op1.var)) { - optimize = 0; + optimize = false; break; } op++; @@ -1009,10 +1008,10 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array } /* Rebuild plain (optimized) op_array from CFG */ -static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_optimizer_ctx *ctx) +static void assemble_code_blocks(const zend_cfg *cfg, zend_op_array *op_array, zend_optimizer_ctx *ctx) { zend_basic_block *blocks = cfg->blocks; - zend_basic_block *end = blocks + cfg->blocks_count; + const zend_basic_block *end = blocks + cfg->blocks_count; zend_basic_block *b; zend_op *new_opcodes; zend_op *opline; @@ -1025,7 +1024,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) { opline = op_array->opcodes + b->start + b->len - 1; if (opline->opcode == ZEND_JMP) { - zend_basic_block *next = b + 1; + const zend_basic_block *next = b + 1; while (next < end && !(next->flags & ZEND_BB_REACHABLE)) { next++; @@ -1042,9 +1041,9 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op len += b->len; } else { /* this block will not be used, delete all constants there */ - zend_op *op = op_array->opcodes + b->start; - zend_op *end = op + b->len; - for (; op < end; op++) { + const zend_op *op = op_array->opcodes + b->start; + const zend_op *last_op = op + b->len; + for (; op < last_op; op++) { if (op->op1_type == IS_CONST) { literal_dtor(&ZEND_OP1_LITERAL(op)); } @@ -1109,7 +1108,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op case ZEND_SWITCH_STRING: case ZEND_MATCH: { - HashTable *jumptable = Z_ARRVAL(ZEND_OP2_LITERAL(opline)); + const HashTable *jumptable = Z_ARRVAL(ZEND_OP2_LITERAL(opline)); zval *zv; uint32_t s = 0; ZEND_ASSERT(b->successors_count == (opline->opcode == ZEND_MATCH ? 1 : 2) + zend_hash_num_elements(jumptable)); @@ -1125,7 +1124,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op /* adjust exception jump targets & remove unused try_catch_array entries */ if (op_array->last_try_catch) { - int i, j; + uint32_t i, j; uint32_t *map; ALLOCA_FLAG(use_heap); @@ -1160,15 +1159,15 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op } if (op_array->fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK) { - zend_op *opline = new_opcodes; - zend_op *end = opline + len; - while (opline < end) { - if (opline->opcode == ZEND_FAST_RET && - opline->op2.num != (uint32_t)-1 && - opline->op2.num < (uint32_t)j) { - opline->op2.num = map[opline->op2.num]; + zend_op *finally_opline = new_opcodes; + const zend_op *last_finally_op = finally_opline + len; + while (finally_opline < last_finally_op) { + if (finally_opline->opcode == ZEND_FAST_RET && + finally_opline->op2.num != (uint32_t)-1 && + finally_opline->op2.num < j) { + finally_opline->op2.num = map[finally_opline->op2.num]; } - opline++; + finally_opline++; } } } @@ -1184,7 +1183,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array, zend_op } } -static zend_always_inline zend_basic_block *get_target_block(const zend_cfg *cfg, zend_basic_block *block, int n, uint32_t *opt_count) +static zend_always_inline zend_basic_block *get_target_block(const zend_cfg *cfg, const zend_basic_block *block, int n, uint32_t *opt_count) { int b; zend_basic_block *target_block = cfg->blocks + block->successors[n]; @@ -1200,7 +1199,7 @@ static zend_always_inline zend_basic_block *get_target_block(const zend_cfg *cfg return target_block; } -static zend_always_inline zend_basic_block *get_follow_block(const zend_cfg *cfg, zend_basic_block *block, int n, uint32_t *opt_count) +static zend_always_inline zend_basic_block *get_follow_block(const zend_cfg *cfg, const zend_basic_block *block, int n, uint32_t *opt_count) { int b; zend_basic_block *target_block = cfg->blocks + block->successors[n]; @@ -1219,7 +1218,7 @@ static zend_always_inline zend_basic_block *get_follow_block(const zend_cfg *cfg static zend_always_inline zend_basic_block *get_next_block(const zend_cfg *cfg, zend_basic_block *block) { zend_basic_block *next_block = block + 1; - zend_basic_block *end = cfg->blocks + cfg->blocks_count; + const zend_basic_block *end = cfg->blocks + cfg->blocks_count; while (1) { if (next_block == end) { @@ -1237,7 +1236,7 @@ static zend_always_inline zend_basic_block *get_next_block(const zend_cfg *cfg, /* we use "jmp_hitlist" to avoid infinity loops during jmp optimization */ -static zend_always_inline bool in_hitlist(int target, int *jmp_hitlist, int jmp_hitlist_count) +static zend_always_inline bool in_hitlist(int target, const int *jmp_hitlist, int jmp_hitlist_count) { int i; @@ -1483,7 +1482,7 @@ static void zend_jmp_optimization(zend_basic_block *block, zend_op_array *op_arr /* Find a set of variables which are used outside of the block where they are * defined. We won't apply some optimization patterns for such variables. */ -static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset used_ext, zend_optimizer_ctx *ctx) +static void zend_t_usage(const zend_cfg *cfg, const zend_op_array *op_array, zend_bitset used_ext, zend_optimizer_ctx *ctx) { int n; zend_basic_block *block, *next_block; @@ -1566,14 +1565,14 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use } if (ctx->debug_level & ZEND_DUMP_BLOCK_PASS_VARS) { - bool printed = 0; + bool printed = false; uint32_t i; for (i = op_array->last_var; i< op_array->T; i++) { if (zend_bitset_in(used_ext, i)) { if (!printed) { fprintf(stderr, "NON-LOCAL-VARS: %d", i); - printed = 1; + printed = true; } else { fprintf(stderr, ", %d", i); } @@ -1687,7 +1686,7 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset use zend_arena_release(&ctx->arena, checkpoint); } -static void zend_merge_blocks(zend_op_array *op_array, zend_cfg *cfg, uint32_t *opt_count) +static void zend_merge_blocks(const zend_op_array *op_array, const zend_cfg *cfg, uint32_t *opt_count) { int i; zend_basic_block *b, *bb; @@ -1707,7 +1706,7 @@ static void zend_merge_blocks(zend_op_array *op_array, zend_cfg *cfg, uint32_t * for (bb = prev + 1; bb != b; bb++) { zend_op *op = op_array->opcodes + bb->start; - zend_op *end = op + bb->len; + const zend_op *end = op + bb->len; while (op < end) { if (op->op1_type == IS_CONST) { literal_dtor(&ZEND_OP1_LITERAL(op)); diff --git a/Zend/Optimizer/compact_literals.c b/Zend/Optimizer/compact_literals.c index d0aaccec7ce2c..447a034530e1b 100644 --- a/Zend/Optimizer/compact_literals.c +++ b/Zend/Optimizer/compact_literals.c @@ -110,7 +110,7 @@ static zend_string *create_str_cache_key(zval *literal, uint8_t num_related) void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx *ctx) { zend_op *opline, *end; - int i, j, n, *map; + int n, *map; uint32_t cache_size; zval zv, *pos; literal_info *info; @@ -124,6 +124,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx int *const_slot, *class_slot, *func_slot, *bind_var_slot, *property_slot, *method_slot, *jmp_slot; if (op_array->last_literal) { + uint32_t j; info = (literal_info*)zend_arena_calloc(&ctx->arena, op_array->last_literal, sizeof(literal_info)); /* Mark literals of specific types */ @@ -258,9 +259,9 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx op_array->function_name ? op_array->function_name->val : "main"); fprintf(stderr, "Literals table size %d\n", op_array->last_literal); - for (int i = 0; i < op_array->last_literal; i++) { + for (uint32_t i = 0; i < op_array->last_literal; i++) { zend_string *str = zval_get_string(op_array->literals + i); - fprintf(stderr, "Literal %d, val (%zu):%s\n", i, ZSTR_LEN(str), ZSTR_VAL(str)); + fprintf(stderr, "Literal %" PRIu32 ", val (%zu):%s\n", i, ZSTR_LEN(str), ZSTR_VAL(str)); zend_string_release(str); } fflush(stderr); @@ -272,7 +273,7 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx zend_hash_init(&hash, op_array->last_literal, NULL, NULL, 0); map = (int*)zend_arena_alloc(&ctx->arena, op_array->last_literal * sizeof(int)); memset(map, 0, op_array->last_literal * sizeof(int)); - for (i = 0; i < op_array->last_literal; i++) { + for (uint32_t i = 0; i < op_array->last_literal; i++) { if (!info[i].num_related) { /* unset literal */ zval_ptr_dtor_nogc(&op_array->literals[i]); @@ -740,6 +741,12 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx cache_size += 2 * sizeof(void *); } break; + case ZEND_CALLABLE_CONVERT: + if (opline->extended_value != (uint32_t)-1) { + opline->extended_value = cache_size; + cache_size += sizeof(void *); + } + break; } opline++; } @@ -770,9 +777,9 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx { fprintf(stderr, "Optimized literals table size %d\n", op_array->last_literal); - for (int i = 0; i < op_array->last_literal; i++) { + for (uint32_t i = 0; i < op_array->last_literal; i++) { zend_string *str = zval_get_string(op_array->literals + i); - fprintf(stderr, "Literal %d, val (%zu):%s\n", i, ZSTR_LEN(str), ZSTR_VAL(str)); + fprintf(stderr, "Literal %" PRIu32 ", val (%zu):%s\n", i, ZSTR_LEN(str), ZSTR_VAL(str)); zend_string_release(str); } fflush(stderr); diff --git a/Zend/Optimizer/dce.c b/Zend/Optimizer/dce.c index a00fd8bc6ad30..41fd0f6c30af4 100644 --- a/Zend/Optimizer/dce.c +++ b/Zend/Optimizer/dce.c @@ -62,17 +62,17 @@ typedef struct { static inline bool is_bad_mod(const zend_ssa *ssa, int use, int def) { if (def < 0) { /* This modification is not tracked by SSA, assume the worst */ - return 1; + return true; } if (ssa->var_info[use].type & MAY_BE_REF) { /* Modification of reference may have side-effect */ - return 1; + return true; } - return 0; + return false; } static inline bool may_have_side_effects( - zend_op_array *op_array, zend_ssa *ssa, + const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op, bool reorder_dtor_effects) { switch (opline->opcode) { @@ -124,19 +124,20 @@ static inline bool may_have_side_effects( case ZEND_FUNC_NUM_ARGS: case ZEND_FUNC_GET_ARGS: case ZEND_ARRAY_KEY_EXISTS: + case ZEND_COPY_TMP: /* No side effects */ - return 0; + return false; case ZEND_FREE: return opline->extended_value == ZEND_FREE_VOID_CAST; case ZEND_ADD_ARRAY_ELEMENT: /* TODO: We can't free two vars. Keep instruction alive. "$b"]; */ if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && (opline->op2_type & (IS_VAR|IS_TMP_VAR))) { - return 1; + return true; } - return 0; + return false; case ZEND_ROPE_END: /* TODO: Rope dce optimization, see #76446 */ - return 1; + return true; case ZEND_JMP: case ZEND_JMPZ: case ZEND_JMPNZ: @@ -149,7 +150,7 @@ static inline bool may_have_side_effects( case ZEND_BIND_INIT_STATIC_OR_JMP: case ZEND_JMP_FRAMELESS: /* For our purposes a jumps and branches are side effects. */ - return 1; + return true; case ZEND_BEGIN_SILENCE: case ZEND_END_SILENCE: case ZEND_ECHO: @@ -164,7 +165,7 @@ static inline bool may_have_side_effects( case ZEND_YIELD_FROM: case ZEND_VERIFY_NEVER_TYPE: /* Intrinsic side effects */ - return 1; + return true; case ZEND_DO_FCALL: case ZEND_DO_FCALL_BY_NAME: case ZEND_DO_ICALL: @@ -174,31 +175,31 @@ static inline bool may_have_side_effects( case ZEND_FRAMELESS_ICALL_2: case ZEND_FRAMELESS_ICALL_3: /* For now assume all calls have side effects */ - return 1; + return true; case ZEND_RECV: case ZEND_RECV_INIT: /* Even though RECV_INIT can be side-effect free, these cannot be simply dropped * due to the prologue skipping code. */ - return 1; + return true; case ZEND_ASSIGN_REF: - return 1; + return true; case ZEND_ASSIGN: { if (is_bad_mod(ssa, ssa_op->op1_use, ssa_op->op1_def)) { - return 1; + return true; } if (!reorder_dtor_effects) { if (opline->op2_type != IS_CONST && (OP2_INFO() & MAY_HAVE_DTOR) && ssa->vars[ssa_op->op2_use].escape_state != ESCAPE_STATE_NO_ESCAPE) { /* DCE might shorten lifetime */ - return 1; + return true; } } - return 0; + return false; } case ZEND_UNSET_VAR: - return 1; + return true; case ZEND_UNSET_CV: { uint32_t t1 = OP1_INFO(); @@ -207,9 +208,9 @@ static inline bool may_have_side_effects( * an unset may be considered dead even if there is a later assignment to the * variable. Removing the unset in this case would not be correct if the variable * is a reference, because unset breaks references. */ - return 1; + return true; } - return 0; + return false; } case ZEND_PRE_INC: case ZEND_POST_INC: @@ -223,7 +224,7 @@ static inline bool may_have_side_effects( case ZEND_ASSIGN_OBJ: if (is_bad_mod(ssa, ssa_op->op1_use, ssa_op->op1_def) || ssa->vars[ssa_op->op1_def].escape_state != ESCAPE_STATE_NO_ESCAPE) { - return 1; + return true; } if (!reorder_dtor_effects) { opline++; @@ -231,33 +232,33 @@ static inline bool may_have_side_effects( if (opline->op1_type != IS_CONST && (OP1_INFO() & MAY_HAVE_DTOR)) { /* DCE might shorten lifetime */ - return 1; + return true; } } - return 0; + return false; case ZEND_PRE_INC_OBJ: case ZEND_PRE_DEC_OBJ: case ZEND_POST_INC_OBJ: case ZEND_POST_DEC_OBJ: if (is_bad_mod(ssa, ssa_op->op1_use, ssa_op->op1_def) || ssa->vars[ssa_op->op1_def].escape_state != ESCAPE_STATE_NO_ESCAPE) { - return 1; + return true; } - return 0; + return false; case ZEND_BIND_STATIC: if (op_array->static_variables) { /* Implicit and Explicit bind static is effectively prologue of closure so report it has side effects like RECV, RECV_INIT; This allows us to reflect on the closure and discover used variable at runtime */ if ((opline->extended_value & (ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT))) { - return 1; + return true; } /* Modifies static variables which are observable through reflection */ if ((opline->extended_value & ZEND_BIND_REF) && opline->op2_type != IS_UNUSED) { - return 1; + return true; } } - return 0; + return false; case ZEND_CHECK_VAR: return (OP1_INFO() & MAY_BE_UNDEF) != 0; case ZEND_FE_RESET_R: @@ -267,12 +268,12 @@ static inline bool may_have_side_effects( return (OP1_INFO() & MAY_BE_ANY) != MAY_BE_ARRAY; default: /* For everything we didn't handle, assume a side-effect */ - return 1; + return true; } } -static zend_always_inline void add_to_worklists(context *ctx, int var_num, int check) { - zend_ssa_var *var = &ctx->ssa->vars[var_num]; +static zend_always_inline void add_to_worklists(const context *ctx, int var_num, int check) { + const zend_ssa_var *var = &ctx->ssa->vars[var_num]; if (var->definition >= 0) { if (!check || zend_bitset_in(ctx->instr_dead, var->definition)) { zend_bitset_incl(ctx->instr_worklist, var->definition); @@ -284,14 +285,14 @@ static zend_always_inline void add_to_worklists(context *ctx, int var_num, int c } } -static inline void add_to_phi_worklist_no_val(context *ctx, int var_num) { - zend_ssa_var *var = &ctx->ssa->vars[var_num]; +static inline void add_to_phi_worklist_no_val(const context *ctx, int var_num) { + const zend_ssa_var *var = &ctx->ssa->vars[var_num]; if (var->definition_phi && zend_bitset_in(ctx->phi_dead, var_num)) { zend_bitset_incl(ctx->phi_worklist_no_val, var_num); } } -static zend_always_inline void add_operands_to_worklists(context *ctx, zend_op *opline, zend_ssa_op *ssa_op, zend_ssa *ssa, int check) { +static zend_always_inline void add_operands_to_worklists(const context *ctx, const zend_op *opline, const zend_ssa_op *ssa_op, const zend_ssa *ssa, int check) { if (ssa_op->result_use >= 0) { add_to_worklists(ctx, ssa_op->result_use, check); } @@ -315,16 +316,16 @@ static zend_always_inline void add_operands_to_worklists(context *ctx, zend_op * } } -static zend_always_inline void add_phi_sources_to_worklists(context *ctx, zend_ssa_phi *phi, int check) { - zend_ssa *ssa = ctx->ssa; +static zend_always_inline void add_phi_sources_to_worklists(const context *ctx, zend_ssa_phi *phi, int check) { + const zend_ssa *ssa = ctx->ssa; int source; FOREACH_PHI_SOURCE(phi, source) { add_to_worklists(ctx, source, check); } FOREACH_PHI_SOURCE_END(); } -static inline bool is_var_dead(context *ctx, int var_num) { - zend_ssa_var *var = &ctx->ssa->vars[var_num]; +static inline bool is_var_dead(const context *ctx, int var_num) { + const zend_ssa_var *var = &ctx->ssa->vars[var_num]; if (var->definition_phi) { return zend_bitset_in(ctx->phi_dead, var_num); } else if (var->definition >= 0) { @@ -338,9 +339,9 @@ static inline bool is_var_dead(context *ctx, int var_num) { } // Sometimes we can mark the var as EXT_UNUSED -static bool try_remove_var_def(context *ctx, int free_var, int use_chain, zend_op *opline) { +static bool try_remove_var_def(const context *ctx, int free_var, int use_chain, const zend_op *opline) { if (use_chain >= 0) { - return 0; + return false; } zend_ssa_var *var = &ctx->ssa->vars[free_var]; int def = var->definition; @@ -381,54 +382,56 @@ static bool try_remove_var_def(context *ctx, int free_var, int use_chain, zend_o def_opline->result.var = 0; def_op->result_def = -1; var->definition = -1; - return 1; + return true; default: break; } } } - return 0; + return false; } static zend_always_inline bool may_be_refcounted(uint32_t type) { return (type & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) != 0; } -static inline bool is_free_of_live_var(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) { +static inline bool is_free_of_live_var(const context *ctx, const zend_op *opline, const zend_ssa_op *ssa_op) { switch (opline->opcode) { case ZEND_FREE: /* It is always safe to remove FREEs of non-refcounted values, even if they are live. */ if ((ctx->ssa->var_info[ssa_op->op1_use].type & (MAY_BE_REF|MAY_BE_ANY|MAY_BE_UNDEF)) != 0 && !may_be_refcounted(ctx->ssa->var_info[ssa_op->op1_use].type)) { - return 0; + return false; } ZEND_FALLTHROUGH; case ZEND_FE_FREE: return !is_var_dead(ctx, ssa_op->op1_use); default: - return 0; + return false; } } /* Returns whether the instruction has been DCEd */ -static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) { - zend_ssa *ssa = ctx->ssa; +static bool dce_instr(const context *ctx, zend_op *opline, zend_ssa_op *ssa_op) { + const zend_ssa *ssa = ctx->ssa; int free_var = -1; uint8_t free_var_type; if (opline->opcode == ZEND_NOP) { - return 0; + return false; } /* We mark FREEs as dead, but they're only really dead if the destroyed var is dead */ if (is_free_of_live_var(ctx, opline, ssa_op)) { - return 0; + return false; } - if ((opline->op1_type & (IS_VAR|IS_TMP_VAR))&& !is_var_dead(ctx, ssa_op->op1_use)) { + if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && !is_var_dead(ctx, ssa_op->op1_use)) { if (!try_remove_var_def(ctx, ssa_op->op1_use, ssa_op->op1_use_chain, opline)) { if (may_be_refcounted(ssa->var_info[ssa_op->op1_use].type) - && opline->opcode != ZEND_CASE && opline->opcode != ZEND_CASE_STRICT) { + && opline->opcode != ZEND_CASE + && opline->opcode != ZEND_CASE_STRICT + && opline->opcode != ZEND_COPY_TMP) { free_var = ssa_op->op1_use; free_var_type = opline->op1_type; } @@ -440,7 +443,7 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) { if (free_var >= 0) { // TODO: We can't free two vars. Keep instruction alive. zend_bitset_excl(ctx->instr_dead, opline - ctx->op_array->opcodes); - return 0; + return false; } free_var = ssa_op->op2_use; free_var_type = opline->op2_type; @@ -459,12 +462,12 @@ static bool dce_instr(context *ctx, zend_op *opline, zend_ssa_op *ssa_op) { ssa_op->op1_use = free_var; ssa_op->op1_use_chain = ssa->vars[free_var].use_chain; ssa->vars[free_var].use_chain = ssa_op - ssa->ops; - return 0; + return false; } - return 1; + return true; } -static inline int get_common_phi_source(zend_ssa *ssa, zend_ssa_phi *phi) { +static inline int get_common_phi_source(const zend_ssa *ssa, zend_ssa_phi *phi) { int common_source = -1; int source; FOREACH_PHI_SOURCE(phi, source) { @@ -484,7 +487,7 @@ static inline int get_common_phi_source(zend_ssa *ssa, zend_ssa_phi *phi) { return common_source; } -static void try_remove_trivial_phi(context *ctx, zend_ssa_phi *phi) { +static void try_remove_trivial_phi(const context *ctx, zend_ssa_phi *phi) { zend_ssa *ssa = ctx->ssa; if (phi->pi < 0) { /* Phi assignment with identical source operands */ @@ -507,17 +510,17 @@ static void try_remove_trivial_phi(context *ctx, zend_ssa_phi *phi) { static inline bool may_break_varargs(const zend_op_array *op_array, const zend_ssa *ssa, const zend_ssa_op *ssa_op) { if (ssa_op->op1_def >= 0 && ssa->vars[ssa_op->op1_def].var < op_array->num_args) { - return 1; + return true; } if (ssa_op->op2_def >= 0 && ssa->vars[ssa_op->op2_def].var < op_array->num_args) { - return 1; + return true; } if (ssa_op->result_def >= 0 && ssa->vars[ssa_op->result_def].var < op_array->num_args) { - return 1; + return true; } - return 0; + return false; } static inline bool may_throw_dce_exception(const zend_op *opline) { @@ -567,7 +570,7 @@ int dce_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *optimizer int op_data = -1; b--; - zend_basic_block *block = &ssa->cfg.blocks[b]; + const zend_basic_block *block = &ssa->cfg.blocks[b]; if (!(block->flags & ZEND_BB_REACHABLE)) { continue; } diff --git a/Zend/Optimizer/dfa_pass.c b/Zend/Optimizer/dfa_pass.c index bf85764c93b49..796e998493d76 100644 --- a/Zend/Optimizer/dfa_pass.c +++ b/Zend/Optimizer/dfa_pass.c @@ -226,7 +226,7 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa, zend_op } /* update try/catch array */ - for (j = 0; j < op_array->last_try_catch; j++) { + for (uint32_t j = 0; j < op_array->last_try_catch; j++) { op_array->try_catch_array[j].try_op -= shiftlist[op_array->try_catch_array[j].try_op]; op_array->try_catch_array[j].catch_op -= shiftlist[op_array->try_catch_array[j].catch_op]; if (op_array->try_catch_array[j].finally_op) { @@ -256,11 +256,11 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa, zend_op static bool safe_instanceof(const zend_class_entry *ce1, const zend_class_entry *ce2) { if (ce1 == ce2) { - return 1; + return true; } if (!(ce1->ce_flags & ZEND_ACC_LINKED)) { /* This case could be generalized, similarly to unlinked_instanceof */ - return 0; + return false; } return instanceof_function(ce1, ce2); } @@ -297,7 +297,7 @@ static inline bool can_elide_return_type_check( zend_ssa_var_info *use_info = &ssa->var_info[ssa_op->op1_use]; uint32_t use_type = use_info->type & (MAY_BE_ANY|MAY_BE_UNDEF); if (use_type & MAY_BE_REF) { - return 0; + return false; } if (use_type & MAY_BE_UNDEF) { @@ -322,20 +322,20 @@ static bool opline_supports_assign_contraction( zend_op_array *op_array, zend_ssa *ssa, zend_op *opline, int src_var, uint32_t cv_var) { if (opline->opcode == ZEND_NEW) { /* see Zend/tests/generators/aborted_yield_during_new.phpt */ - return 0; + return false; } /* Frameless calls override the return value, but the return value may overlap with the arguments. */ switch (opline->opcode) { case ZEND_FRAMELESS_ICALL_3: - if ((opline + 1)->op1_type == IS_CV && (opline + 1)->op1.var == cv_var) return 0; + if ((opline + 1)->op1_type == IS_CV && (opline + 1)->op1.var == cv_var) return false; ZEND_FALLTHROUGH; case ZEND_FRAMELESS_ICALL_2: - if (opline->op2_type == IS_CV && opline->op2.var == cv_var) return 0; + if (opline->op2_type == IS_CV && opline->op2.var == cv_var) return false; ZEND_FALLTHROUGH; case ZEND_FRAMELESS_ICALL_1: - if (opline->op1_type == IS_CV && opline->op1.var == cv_var) return 0; - return 1; + if (opline->op1_type == IS_CV && opline->op1.var == cv_var) return false; + return true; } if (opline->opcode == ZEND_DO_ICALL || opline->opcode == ZEND_DO_UCALL @@ -374,10 +374,10 @@ static bool opline_supports_assign_contraction( && opline->op1_type == IS_CV && opline->op1.var == cv_var && zend_may_throw(opline, &ssa->ops[ssa->vars[src_var].definition], op_array, ssa)) { - return 0; + return false; } - return 1; + return true; } static bool variable_defined_or_used_in_range(zend_ssa *ssa, int var, int start, int end) @@ -391,11 +391,11 @@ static bool variable_defined_or_used_in_range(zend_ssa *ssa, int var, int start, (ssa_op->op2_use >= 0 && ssa->vars[ssa_op->op2_use].var == var) || (ssa_op->result_use >= 0 && ssa->vars[ssa_op->result_use].var == var) ) { - return 1; + return true; } start++; } - return 0; + return false; } int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) @@ -414,19 +414,19 @@ int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) && call_info->callee_func && zend_string_equals_literal_ci(call_info->callee_func->common.function_name, "in_array")) { - bool strict = 0; + bool strict = false; bool has_opdata = op->opcode == ZEND_FRAMELESS_ICALL_3; ZEND_ASSERT(!call_info->is_prototype); if (has_opdata) { if (zend_is_true(CT_CONSTANT_EX(op_array, (op + 1)->op1.constant))) { - strict = 1; + strict = true; } } if (op->op2_type == IS_CONST && Z_TYPE_P(CT_CONSTANT_EX(op_array, op->op2.constant)) == IS_ARRAY) { - bool ok = 1; + bool ok = true; HashTable *src = Z_ARRVAL_P(CT_CONSTANT_EX(op_array, op->op2.constant)); HashTable *dst; @@ -443,7 +443,7 @@ int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) zend_hash_index_add(dst, Z_LVAL_P(val), &tmp); } else { zend_array_destroy(dst); - ok = 0; + ok = false; break; } } ZEND_HASH_FOREACH_END(); @@ -451,7 +451,7 @@ int zend_dfa_optimize_calls(zend_op_array *op_array, zend_ssa *ssa) ZEND_HASH_FOREACH_VAL(src, val) { if (Z_TYPE_P(val) != IS_STRING || ZEND_HANDLE_NUMERIC(Z_STR_P(val), idx)) { zend_array_destroy(dst); - ok = 0; + ok = false; break; } zend_hash_add(dst, Z_STR_P(val), &tmp); @@ -711,12 +711,12 @@ static int zend_dfa_optimize_jmps(zend_op_array *op_array, zend_ssa *ssa) uint32_t op_num; zend_op *opline; zend_ssa_op *ssa_op; - bool can_follow = 1; + bool can_follow = true; while (next_block_num < ssa->cfg.blocks_count && !(ssa->cfg.blocks[next_block_num].flags & ZEND_BB_REACHABLE)) { if (ssa->cfg.blocks[next_block_num].flags & ZEND_BB_UNREACHABLE_FREE) { - can_follow = 0; + can_follow = false; } next_block_num++; } @@ -989,7 +989,7 @@ static bool zend_dfa_try_to_replace_result(zend_op_array *op_array, zend_ssa *ss if ((opline->op1_type == IS_CV && opline->op1.var == cv) || (opline->op2_type == IS_CV && opline->op2.var == cv) || (opline->result_type == IS_CV && opline->result.var == cv)) { - return 0; + return false; } opline--; i--; @@ -1026,12 +1026,12 @@ static bool zend_dfa_try_to_replace_result(zend_op_array *op_array, zend_ssa *ss op_array->opcodes[use].result.var = cv; } - return 1; + return true; } } } - return 0; + return false; } void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx, zend_ssa *ssa, zend_call_info **call_map) diff --git a/Zend/Optimizer/escape_analysis.c b/Zend/Optimizer/escape_analysis.c index 840a18341a0ff..00ee329845026 100644 --- a/Zend/Optimizer/escape_analysis.c +++ b/Zend/Optimizer/escape_analysis.c @@ -155,7 +155,7 @@ static bool is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, i if (ssa_op->result_def == var) { switch (opline->opcode) { case ZEND_INIT_ARRAY: - return 1; + return true; case ZEND_NEW: { /* objects with destructors should escape */ zend_class_entry *ce = zend_optimizer_get_class_entry_from_op1( @@ -175,22 +175,22 @@ static bool is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, i && !ce->__set && !(ce->ce_flags & forbidden_flags) && (ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED)) { - return 1; + return true; } break; } case ZEND_QM_ASSIGN: if (opline->op1_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT(opline->op1)) == IS_ARRAY) { - return 1; + return true; } if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_ARRAY)) { - return 1; + return true; } break; case ZEND_ASSIGN: if (opline->op1_type == IS_CV && (OP1_INFO() & MAY_BE_ARRAY)) { - return 1; + return true; } break; } @@ -199,22 +199,22 @@ static bool is_allocation_def(zend_op_array *op_array, zend_ssa *ssa, int def, i case ZEND_ASSIGN: if (opline->op2_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_ARRAY) { - return 1; + return true; } if (opline->op2_type == IS_CV && (OP2_INFO() & MAY_BE_ARRAY)) { - return 1; + return true; } break; case ZEND_ASSIGN_DIM: if (OP1_INFO() & (MAY_BE_UNDEF | MAY_BE_NULL | MAY_BE_FALSE)) { /* implicit object/array allocation */ - return 1; + return true; } break; } } - return 0; + return false; } /* }}} */ @@ -229,7 +229,7 @@ static bool is_local_def(zend_op_array *op_array, zend_ssa *ssa, int def, int va case ZEND_ADD_ARRAY_ELEMENT: case ZEND_QM_ASSIGN: case ZEND_ASSIGN: - return 1; + return true; case ZEND_NEW: { /* objects with destructors should escape */ zend_class_entry *ce = zend_optimizer_get_class_entry_from_op1( @@ -243,7 +243,7 @@ static bool is_local_def(zend_op_array *op_array, zend_ssa *ssa, int def, int va && !ce->__get && !ce->__set && !ce->parent) { - return 1; + return true; } break; } @@ -260,11 +260,11 @@ static bool is_local_def(zend_op_array *op_array, zend_ssa *ssa, int def, int va case ZEND_PRE_DEC_OBJ: case ZEND_POST_INC_OBJ: case ZEND_POST_DEC_OBJ: - return 1; + return true; } } - return 0; + return false; } /* }}} */ @@ -282,7 +282,7 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int v if (opline->op1_type == IS_CV) { if (OP1_INFO() & MAY_BE_OBJECT) { /* object aliasing */ - return 1; + return true; } } break; @@ -294,7 +294,7 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int v case ZEND_FETCH_OBJ_IS: break; case ZEND_ASSIGN_OP: - return 1; + return true; case ZEND_ASSIGN_DIM_OP: case ZEND_ASSIGN_OBJ_OP: case ZEND_ASSIGN_STATIC_PROP_OP: @@ -310,22 +310,22 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int v case ZEND_INIT_ARRAY: case ZEND_ADD_ARRAY_ELEMENT: if (opline->extended_value & ZEND_ARRAY_ELEMENT_REF) { - return 1; + return true; } if (OP1_INFO() & MAY_BE_OBJECT) { /* object aliasing */ - return 1; + return true; } /* reference dependencies processed separately */ break; case ZEND_OP_DATA: if ((opline-1)->opcode != ZEND_ASSIGN_DIM && (opline-1)->opcode != ZEND_ASSIGN_OBJ) { - return 1; + return true; } if (OP1_INFO() & MAY_BE_OBJECT) { /* object aliasing */ - return 1; + return true; } opline--; ssa_op--; @@ -333,12 +333,12 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int v || (OP1_INFO() & MAY_BE_REF) || (ssa_op->op1_def >= 0 && ssa->vars[ssa_op->op1_def].alias)) { /* assignment into escaping structure */ - return 1; + return true; } /* reference dependencies processed separately */ break; default: - return 1; + return true; } } @@ -349,17 +349,17 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int v || (OP1_INFO() & MAY_BE_REF) || (ssa_op->op1_def >= 0 && ssa->vars[ssa_op->op1_def].alias)) { /* assignment into escaping variable */ - return 1; + return true; } if (opline->op2_type == IS_CV || opline->result_type != IS_UNUSED) { if (OP2_INFO() & MAY_BE_OBJECT) { /* object aliasing */ - return 1; + return true; } } break; default: - return 1; + return true; } } @@ -371,11 +371,11 @@ static bool is_escape_use(zend_op_array *op_array, zend_ssa *ssa, int use, int v case ZEND_ADD_ARRAY_ELEMENT: break; default: - return 1; + return true; } } - return 0; + return false; } /* }}} */ @@ -393,12 +393,12 @@ zend_result zend_ssa_escape_analysis(const zend_script *script, zend_op_array *o return SUCCESS; } - has_allocations = 0; + has_allocations = false; for (i = op_array->last_var; i < ssa_vars_count; i++) { if (ssa_vars[i].definition >= 0 && (ssa->var_info[i].type & (MAY_BE_ARRAY|MAY_BE_OBJECT)) && is_allocation_def(op_array, ssa, ssa_vars[i].definition, i, script)) { - has_allocations = 1; + has_allocations = true; break; } } @@ -470,7 +470,7 @@ zend_result zend_ssa_escape_analysis(const zend_script *script, zend_op_array *o bool changed; do { - changed = 0; + changed = false; for (i = 0; i < ssa_vars_count; i++) { if (ssa_vars[i].use_chain >= 0) { root = ees[i]; @@ -506,13 +506,13 @@ zend_result zend_ssa_escape_analysis(const zend_script *script, zend_op_array *o if (ssa_vars[root].escape_state == ESCAPE_STATE_GLOBAL_ESCAPE) { num_non_escaped--; if (num_non_escaped == 0) { - changed = 0; + changed = false; } else { - changed = 1; + changed = true; } break; } else { - changed = 1; + changed = true; } } } FOREACH_USE_END(); diff --git a/Zend/Optimizer/nop_removal.c b/Zend/Optimizer/nop_removal.c index fd5a87cbfb287..7de3919ee8cb2 100644 --- a/Zend/Optimizer/nop_removal.c +++ b/Zend/Optimizer/nop_removal.c @@ -32,21 +32,20 @@ void zend_optimizer_nop_removal(zend_op_array *op_array, zend_optimizer_ctx *ctx) { - zend_op *end, *opline; + zend_op *opline; uint32_t new_count, i, shift; - int j; uint32_t *shiftlist; ALLOCA_FLAG(use_heap); shiftlist = (uint32_t *)do_alloca(sizeof(uint32_t) * op_array->last, use_heap); i = new_count = shift = 0; - end = op_array->opcodes + op_array->last; + const zend_op *end = op_array->opcodes + op_array->last; for (opline = op_array->opcodes; opline < end; opline++) { /* Kill JMP-over-NOP-s */ if (opline->opcode == ZEND_JMP && ZEND_OP1_JMP_ADDR(opline) > op_array->opcodes + i) { /* check if there are only NOPs under the branch */ - zend_op *target = ZEND_OP1_JMP_ADDR(opline) - 1; + const zend_op *target = ZEND_OP1_JMP_ADDR(opline) - 1; while (target->opcode == ZEND_NOP) { target--; @@ -81,7 +80,7 @@ void zend_optimizer_nop_removal(zend_op_array *op_array, zend_optimizer_ctx *ctx } /* update try/catch array */ - for (j = 0; j < op_array->last_try_catch; j++) { + for (uint32_t j = 0; j < op_array->last_try_catch; j++) { op_array->try_catch_array[j].try_op -= shiftlist[op_array->try_catch_array[j].try_op]; op_array->try_catch_array[j].catch_op -= shiftlist[op_array->try_catch_array[j].catch_op]; if (op_array->try_catch_array[j].finally_op) { diff --git a/Zend/Optimizer/optimize_func_calls.c b/Zend/Optimizer/optimize_func_calls.c index 8b29f47c94976..62b50464e87ba 100644 --- a/Zend/Optimizer/optimize_func_calls.c +++ b/Zend/Optimizer/optimize_func_calls.c @@ -37,7 +37,7 @@ typedef struct _optimizer_call_info { uint32_t func_arg_num; } optimizer_call_info; -static void zend_delete_call_instructions(zend_op_array *op_array, zend_op *opline) +static void zend_delete_call_instructions(const zend_op_array *op_array, zend_op *opline) { int call = 0; @@ -76,7 +76,7 @@ static void zend_delete_call_instructions(zend_op_array *op_array, zend_op *opli } } -static void zend_try_inline_call(zend_op_array *op_array, zend_op *fcall, zend_op *opline, zend_function *func) +static void zend_try_inline_call(zend_op_array *op_array, const zend_op *fcall, zend_op *opline, const zend_function *func) { const uint32_t no_discard = RETURN_VALUE_USED(opline) ? 0 : ZEND_ACC_NODISCARD; @@ -153,7 +153,7 @@ static bool has_known_send_mode(const optimizer_call_info *info, uint32_t arg_nu void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) { zend_op *opline = op_array->opcodes; - zend_op *end = opline + op_array->last; + const zend_op *end = opline + op_array->last; int call = 0; void *checkpoint; optimizer_call_info *call_stack; @@ -237,7 +237,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) } call_stack[call].func = NULL; call_stack[call].opline = NULL; - call_stack[call].try_inline = 0; + call_stack[call].try_inline = false; call_stack[call].func_arg_num = (uint32_t)-1; break; case ZEND_FETCH_FUNC_ARG: @@ -265,7 +265,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) && opline->op2_type == IS_UNUSED) { /* FETCH_DIM_FUNC_ARG supports UNUSED op2, while FETCH_DIM_R does not. * Performing the replacement would create an invalid opcode. */ - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; break; } @@ -279,7 +279,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) break; case ZEND_SEND_VAL_EX: if (opline->op2_type == IS_CONST) { - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; break; } @@ -291,7 +291,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) break; case ZEND_CHECK_FUNC_ARG: if (opline->op2_type == IS_CONST) { - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; call_stack[call - 1].func_arg_num = (uint32_t)-1; break; } @@ -305,7 +305,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) /* Don't transform SEND_FUNC_ARG if any FETCH opcodes weren't transformed. */ if (call_stack[call - 1].last_check_func_arg_opline == NULL) { if (opline->op2_type == IS_CONST) { - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; } break; } @@ -314,7 +314,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) ZEND_FALLTHROUGH; case ZEND_SEND_VAR_EX: if (opline->op2_type == IS_CONST) { - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; break; } @@ -329,7 +329,7 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) break; case ZEND_SEND_VAR_NO_REF_EX: if (opline->op2_type == IS_CONST) { - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; break; } @@ -347,14 +347,14 @@ void zend_optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) case ZEND_SEND_VAR: case ZEND_SEND_REF: if (opline->op2_type == IS_CONST) { - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; break; } break; case ZEND_SEND_UNPACK: case ZEND_SEND_USER: case ZEND_SEND_ARRAY: - call_stack[call - 1].try_inline = 0; + call_stack[call - 1].try_inline = false; break; default: break; diff --git a/Zend/Optimizer/pass1.c b/Zend/Optimizer/pass1.c index fe92db583fcd9..4be966c25d896 100644 --- a/Zend/Optimizer/pass1.c +++ b/Zend/Optimizer/pass1.c @@ -149,7 +149,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) if (opline->op2_type == IS_CONST && Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) { /* substitute persistent constants */ - if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &result, 1)) { + if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP2_LITERAL(opline)), &result, true)) { if (!ctx->constants || !zend_optimizer_get_collected_constant(ctx->constants, &ZEND_OP2_LITERAL(opline), &result)) { break; } @@ -171,7 +171,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) if (Z_TYPE_P(c) == IS_CONSTANT_AST) { zend_ast *ast = Z_ASTVAL_P(c); if (ast->kind != ZEND_AST_CONSTANT - || !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &result, 1) + || !zend_optimizer_get_persistent_constant(zend_ast_get_constant_name(ast), &result, true) || Z_TYPE(result) == IS_CONSTANT_AST) { break; } @@ -193,7 +193,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) if (send1_opline->opcode != ZEND_SEND_VAL || send1_opline->op1_type != IS_CONST) { /* don't collect constants after unknown function call */ - collect_constants = 0; + collect_constants = false; break; } if (send1_opline->op2.num == 2) { @@ -205,7 +205,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) if (send1_opline->opcode != ZEND_SEND_VAL || send1_opline->op1_type != IS_CONST) { /* don't collect constants after unknown function call */ - collect_constants = 0; + collect_constants = false; break; } } @@ -217,7 +217,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) init_opline->op2_type != IS_CONST || Z_TYPE(ZEND_OP2_LITERAL(init_opline)) != IS_STRING) { /* don't collect constants after unknown function call */ - collect_constants = 0; + collect_constants = false; break; } @@ -261,9 +261,19 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) } /* don't collect constants after any other function call */ - collect_constants = 0; + collect_constants = false; break; } + case ZEND_DO_UCALL: + case ZEND_DO_FCALL: + case ZEND_DO_FCALL_BY_NAME: + case ZEND_FRAMELESS_ICALL_0: + case ZEND_FRAMELESS_ICALL_1: + case ZEND_FRAMELESS_ICALL_2: + case ZEND_FRAMELESS_ICALL_3: + /* don't collect constants after any UCALL/FCALL/FRAMELESS ICALL */ + collect_constants = 0; + break; case ZEND_STRLEN: if (opline->op1_type == IS_CONST && zend_optimizer_eval_strlen(&result, &ZEND_OP1_LITERAL(opline)) == SUCCESS) { @@ -271,7 +281,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) } break; case ZEND_DEFINED: - if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &result, 0)) { + if (!zend_optimizer_get_persistent_constant(Z_STR(ZEND_OP1_LITERAL(opline)), &result, false)) { break; } ZVAL_TRUE(&result); @@ -309,7 +319,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) } } } - collect_constants = 0; + collect_constants = false; break; case ZEND_JMPZ: @@ -331,7 +341,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) break; } } - collect_constants = 0; + collect_constants = false; break; case ZEND_RETURN: @@ -354,7 +364,7 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx) case ZEND_VERIFY_NEVER_TYPE: case ZEND_BIND_INIT_STATIC_OR_JMP: case ZEND_JMP_FRAMELESS: - collect_constants = 0; + collect_constants = false; break; } opline++; diff --git a/Zend/Optimizer/pass3.c b/Zend/Optimizer/pass3.c index 2cbd0e3406521..5c31de7bc49c4 100644 --- a/Zend/Optimizer/pass3.c +++ b/Zend/Optimizer/pass3.c @@ -37,10 +37,10 @@ static zend_always_inline bool in_hitlist(zend_op *target, zend_op **jmp_hitlist for (i = 0; i < jmp_hitlist_count; i++) { if (jmp_hitlist[i] == target) { - return 1; + return true; } } - return 0; + return false; } #define CHECK_LOOP(target) \ diff --git a/Zend/Optimizer/sccp.c b/Zend/Optimizer/sccp.c index 7e2fc2db1b256..38a28dcd48894 100644 --- a/Zend/Optimizer/sccp.c +++ b/Zend/Optimizer/sccp.c @@ -244,7 +244,7 @@ static bool can_replace_op1( case ZEND_SEND_ARRAY: case ZEND_SEND_USER: case ZEND_FE_RESET_RW: - return 0; + return false; /* Do not accept CONST */ case ZEND_ROPE_ADD: case ZEND_ROPE_END: @@ -254,7 +254,7 @@ static bool can_replace_op1( case ZEND_MAKE_REF: case ZEND_UNSET_CV: case ZEND_ISSET_ISEMPTY_CV: - return 0; + return false; case ZEND_INIT_ARRAY: case ZEND_ADD_ARRAY_ELEMENT: return !(opline->extended_value & ZEND_ARRAY_ELEMENT_REF); @@ -262,18 +262,18 @@ static bool can_replace_op1( return !(op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE); case ZEND_VERIFY_RETURN_TYPE: // TODO: This would require a non-local change ??? - return 0; + return false; case ZEND_OP_DATA: return (opline - 1)->opcode != ZEND_ASSIGN_OBJ_REF && (opline - 1)->opcode != ZEND_ASSIGN_STATIC_PROP_REF; default: if (ssa_op->op1_def != -1) { ZEND_UNREACHABLE(); - return 0; + return false; } } - return 1; + return true; } static bool can_replace_op2( @@ -284,9 +284,9 @@ static bool can_replace_op2( case ZEND_BIND_LEXICAL: case ZEND_FE_FETCH_R: case ZEND_FE_FETCH_RW: - return 0; + return false; } - return 1; + return true; } static bool try_replace_op1( @@ -295,11 +295,11 @@ static bool try_replace_op1( zval zv; ZVAL_COPY(&zv, value); if (zend_optimizer_update_op1_const(ctx->scdf.op_array, opline, &zv)) { - return 1; + return true; } zval_ptr_dtor_nogc(&zv); } - return 0; + return false; } static bool try_replace_op2( @@ -308,11 +308,11 @@ static bool try_replace_op2( zval zv; ZVAL_COPY(&zv, value); if (zend_optimizer_update_op2_const(ctx->scdf.op_array, opline, &zv)) { - return 1; + return true; } zval_ptr_dtor_nogc(&zv); } - return 0; + return false; } static inline zend_result ct_eval_binary_op(zval *result, uint8_t binop, zval *op1, zval *op2) { @@ -718,7 +718,7 @@ static inline zend_result ct_eval_in_array(zval *result, uint32_t extended_value if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { res = zend_hash_index_exists(ht, Z_LVAL_P(op1)); } else { - res = 0; + res = false; } } else if (Z_TYPE_P(op1) <= IS_FALSE) { res = zend_hash_exists(ht, ZSTR_EMPTY_ALLOC()); @@ -726,11 +726,11 @@ static inline zend_result ct_eval_in_array(zval *result, uint32_t extended_value zend_string *key; zval key_tmp; - res = 0; + res = false; ZEND_HASH_MAP_FOREACH_STR_KEY(ht, key) { ZVAL_STR(&key_tmp, key); if (zend_compare(op1, &key_tmp) == 0) { - res = 1; + res = true; break; } } ZEND_HASH_FOREACH_END(); @@ -1655,7 +1655,6 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o { zend_call_info *call; zval *name, *args[3] = {NULL}; - int i; if (!ctx->call_map) { SET_RESULT_BOT(result); @@ -1677,7 +1676,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o break; } - for (i = 0; i < call->num_args; i++) { + for (uint32_t i = 0; i < call->num_args; i++) { zend_op *opline = call->arg_info[i].opline; if (opline->opcode != ZEND_SEND_VAL && opline->opcode != ZEND_SEND_VAR) { SET_RESULT_BOT(result); @@ -2043,7 +2042,7 @@ static void join_phi_values(zval *a, zval *b, bool escape) { } } -static void sccp_visit_phi(scdf_ctx *scdf, zend_ssa_phi *phi) { +static void sccp_visit_phi(scdf_ctx *scdf, const zend_ssa_phi *phi) { sccp_ctx *ctx = (sccp_ctx *) scdf; zend_ssa *ssa = scdf->ssa; ZEND_ASSERT(phi->ssa_var >= 0); @@ -2093,7 +2092,6 @@ static int remove_call(sccp_ctx *ctx, zend_op *opline, zend_ssa_op *ssa_op) zend_ssa *ssa = ctx->scdf.ssa; zend_op_array *op_array = ctx->scdf.op_array; zend_call_info *call; - int i; ZEND_ASSERT(ctx->call_map); call = ctx->call_map[opline - op_array->opcodes]; @@ -2103,7 +2101,7 @@ static int remove_call(sccp_ctx *ctx, zend_op *opline, zend_ssa_op *ssa_op) zend_ssa_remove_instr(ssa, call->caller_init_opline, &ssa->ops[call->caller_init_opline - op_array->opcodes]); - for (i = 0; i < call->num_args; i++) { + for (uint32_t i = 0; i < call->num_args; i++) { zend_ssa_remove_instr(ssa, call->arg_info[i].opline, &ssa->ops[call->arg_info[i].opline - op_array->opcodes]); } @@ -2127,11 +2125,11 @@ static int remove_call(sccp_ctx *ctx, zend_op *opline, zend_ssa_op *ssa_op) * we need to collect. * d) The ordinary DCE pass cannot collect construction of dead non-escaping arrays and objects. */ -static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var, zval *value) +static uint32_t try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var, zval *value) { zend_ssa *ssa = ctx->scdf.ssa; zend_op_array *op_array = ctx->scdf.op_array; - int removed_ops = 0; + uint32_t removed_ops = 0; if (var->definition >= 0) { zend_op *opline = &op_array->opcodes[var->definition]; @@ -2375,12 +2373,12 @@ static int try_remove_definition(sccp_ctx *ctx, int var_num, zend_ssa_var *var, /* This will try to replace uses of SSA variables we have determined to be constant. Not all uses * can be replaced, because some instructions don't accept constant operands or only accept them * if they have a certain type. */ -static int replace_constant_operands(sccp_ctx *ctx) { +static uint32_t replace_constant_operands(sccp_ctx *ctx) { zend_ssa *ssa = ctx->scdf.ssa; zend_op_array *op_array = ctx->scdf.op_array; int i; zval tmp; - int removed_ops = 0; + uint32_t removed_ops = 0; /* We iterate the variables backwards, so we can eliminate sequences like INIT_ROPE * and INIT_ARRAY. */ @@ -2473,10 +2471,10 @@ static void sccp_context_free(sccp_ctx *sccp) { } } -int sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_array, zend_ssa *ssa, zend_call_info **call_map) +uint32_t sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_array, zend_ssa *ssa, zend_call_info **call_map) { sccp_ctx sccp; - int removed_ops = 0; + uint32_t removed_ops = 0; void *checkpoint = zend_arena_checkpoint(ctx->arena); sccp_context_init(ctx, &sccp, ssa, op_array, call_map); diff --git a/Zend/Optimizer/scdf.c b/Zend/Optimizer/scdf.c index 54925e8287b62..e5c40b8c90cf9 100644 --- a/Zend/Optimizer/scdf.c +++ b/Zend/Optimizer/scdf.c @@ -70,9 +70,8 @@ void scdf_mark_edge_feasible(scdf_ctx *scdf, int from, int to) { } else { /* Block is already executable, only a new edge became feasible. * Reevaluate phi nodes to account for changed source operands. */ - zend_ssa_block *ssa_block = &scdf->ssa->blocks[to]; - zend_ssa_phi *phi; - for (phi = ssa_block->phis; phi; phi = phi->next) { + const zend_ssa_block *ssa_block = &scdf->ssa->blocks[to]; + for (const zend_ssa_phi *phi = ssa_block->phis; phi; phi = phi->next) { zend_bitset_excl(scdf->phi_var_worklist, phi->ssa_var); scdf->handlers.visit_phi(scdf, phi); } @@ -101,7 +100,7 @@ void scdf_init(zend_optimizer_ctx *ctx, scdf_ctx *scdf, zend_op_array *op_array, } void scdf_solve(scdf_ctx *scdf, const char *name) { - zend_ssa *ssa = scdf->ssa; + const zend_ssa *ssa = scdf->ssa; DEBUG_PRINT("Start SCDF solve (%s)\n", name); while (!zend_bitset_empty(scdf->instr_worklist, scdf->instr_worklist_len) || !zend_bitset_empty(scdf->phi_var_worklist, scdf->phi_var_worklist_len) @@ -109,7 +108,7 @@ void scdf_solve(scdf_ctx *scdf, const char *name) { ) { int i; while ((i = zend_bitset_pop_first(scdf->phi_var_worklist, scdf->phi_var_worklist_len)) >= 0) { - zend_ssa_phi *phi = ssa->vars[i].definition_phi; + const zend_ssa_phi *phi = ssa->vars[i].definition_phi; ZEND_ASSERT(phi); if (zend_bitset_in(scdf->executable_blocks, phi->block)) { scdf->handlers.visit_phi(scdf, phi); @@ -140,17 +139,14 @@ void scdf_solve(scdf_ctx *scdf, const char *name) { while ((i = zend_bitset_pop_first(scdf->block_worklist, scdf->block_worklist_len)) >= 0) { /* This block is now live. Interpret phis and instructions in it. */ zend_basic_block *block = &ssa->cfg.blocks[i]; - zend_ssa_block *ssa_block = &ssa->blocks[i]; + const zend_ssa_block *ssa_block = &ssa->blocks[i]; DEBUG_PRINT("Pop block %d from worklist\n", i); zend_bitset_incl(scdf->executable_blocks, i); - { - zend_ssa_phi *phi; - for (phi = ssa_block->phis; phi; phi = phi->next) { - zend_bitset_excl(scdf->phi_var_worklist, phi->ssa_var); - scdf->handlers.visit_phi(scdf, phi); - } + for (const zend_ssa_phi *phi = ssa_block->phis; phi; phi = phi->next) { + zend_bitset_excl(scdf->phi_var_worklist, phi->ssa_var); + scdf->handlers.visit_phi(scdf, phi); } if (block->len == 0) { @@ -158,7 +154,7 @@ void scdf_solve(scdf_ctx *scdf, const char *name) { scdf_mark_edge_feasible(scdf, i, block->successors[0]); } else { zend_op *opline = NULL; - int j, end = block->start + block->len; + uint32_t j, end = block->start + block->len; for (j = block->start; j < end; j++) { opline = &scdf->op_array->opcodes[j]; zend_bitset_excl(scdf->instr_worklist, j); @@ -185,7 +181,7 @@ void scdf_solve(scdf_ctx *scdf, const char *name) { * not eliminate the latter. While it cannot be reached, the FREE opcode of the loop var * is necessary for the correctness of temporary compaction. */ static bool is_live_loop_var_free( - scdf_ctx *scdf, const zend_op *opline, const zend_ssa_op *ssa_op) { + const scdf_ctx *scdf, const zend_op *opline, const zend_ssa_op *ssa_op) { if (!zend_optimizer_is_loop_var_free(opline)) { return false; } @@ -195,7 +191,7 @@ static bool is_live_loop_var_free( return false; } - zend_ssa_var *ssa_var = &scdf->ssa->vars[var]; + const zend_ssa_var *ssa_var = &scdf->ssa->vars[var]; uint32_t def_block; if (ssa_var->definition >= 0) { def_block = scdf->ssa->cfg.map[ssa_var->definition]; @@ -205,7 +201,7 @@ static bool is_live_loop_var_free( return zend_bitset_in(scdf->executable_blocks, def_block); } -static bool kept_alive_by_loop_var_free(scdf_ctx *scdf, const zend_basic_block *block) { +static bool kept_alive_by_loop_var_free(const scdf_ctx *scdf, const zend_basic_block *block) { const zend_op_array *op_array = scdf->op_array; const zend_cfg *cfg = &scdf->ssa->cfg; if (!(cfg->flags & ZEND_FUNC_FREE_LOOP_VAR)) { @@ -220,7 +216,7 @@ static bool kept_alive_by_loop_var_free(scdf_ctx *scdf, const zend_basic_block * return false; } -static uint32_t cleanup_loop_var_free_block(scdf_ctx *scdf, zend_basic_block *block) { +static uint32_t cleanup_loop_var_free_block(const scdf_ctx *scdf, const zend_basic_block *block) { zend_ssa *ssa = scdf->ssa; const zend_op_array *op_array = scdf->op_array; const zend_cfg *cfg = &ssa->cfg; @@ -256,12 +252,12 @@ static uint32_t cleanup_loop_var_free_block(scdf_ctx *scdf, zend_basic_block *bl /* Removes unreachable blocks. This will remove both the instructions (and phis) in the * blocks, as well as remove them from the successor / predecessor lists and mark them * unreachable. Blocks already marked unreachable are not removed. */ -uint32_t scdf_remove_unreachable_blocks(scdf_ctx *scdf) { +uint32_t scdf_remove_unreachable_blocks(const scdf_ctx *scdf) { zend_ssa *ssa = scdf->ssa; int i; uint32_t removed_ops = 0; for (i = 0; i < ssa->cfg.blocks_count; i++) { - zend_basic_block *block = &ssa->cfg.blocks[i]; + const zend_basic_block *block = &ssa->cfg.blocks[i]; if (!zend_bitset_in(scdf->executable_blocks, i) && (block->flags & ZEND_BB_REACHABLE)) { if (!kept_alive_by_loop_var_free(scdf, block)) { removed_ops += block->len; diff --git a/Zend/Optimizer/scdf.h b/Zend/Optimizer/scdf.h index 0d90147e84cb1..49222880f22b8 100644 --- a/Zend/Optimizer/scdf.h +++ b/Zend/Optimizer/scdf.h @@ -39,7 +39,7 @@ typedef struct _scdf_ctx { void (*visit_instr)( struct _scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_op); void (*visit_phi)( - struct _scdf_ctx *scdf, zend_ssa_phi *phi); + struct _scdf_ctx *scdf, const zend_ssa_phi *phi); void (*mark_feasible_successors)( struct _scdf_ctx *scdf, int block_num, zend_basic_block *block, zend_op *opline, zend_ssa_op *ssa_op); @@ -49,10 +49,10 @@ typedef struct _scdf_ctx { void scdf_init(zend_optimizer_ctx *ctx, scdf_ctx *scdf, zend_op_array *op_array, zend_ssa *ssa); void scdf_solve(scdf_ctx *scdf, const char *name); -uint32_t scdf_remove_unreachable_blocks(scdf_ctx *scdf); +uint32_t scdf_remove_unreachable_blocks(const scdf_ctx *scdf); /* Add uses to worklist */ -static inline void scdf_add_to_worklist(scdf_ctx *scdf, int var_num) { +static inline void scdf_add_to_worklist(const scdf_ctx *scdf, int var_num) { const zend_ssa *ssa = scdf->ssa; const zend_ssa_var *var = &ssa->vars[var_num]; int use; @@ -66,7 +66,7 @@ static inline void scdf_add_to_worklist(scdf_ctx *scdf, int var_num) { } /* This should usually not be necessary, however it's used for type narrowing. */ -static inline void scdf_add_def_to_worklist(scdf_ctx *scdf, int var_num) { +static inline void scdf_add_def_to_worklist(const scdf_ctx *scdf, int var_num) { const zend_ssa_var *var = &scdf->ssa->vars[var_num]; if (var->definition >= 0) { zend_bitset_incl(scdf->instr_worklist, var->definition); diff --git a/Zend/Optimizer/ssa_integrity.c b/Zend/Optimizer/ssa_integrity.c index b525f8d5ee226..793fb1c06c8b0 100644 --- a/Zend/Optimizer/ssa_integrity.c +++ b/Zend/Optimizer/ssa_integrity.c @@ -25,20 +25,20 @@ static inline bool is_in_use_chain(zend_ssa *ssa, int var, int check) { int use; FOREACH_USE(&ssa->vars[var], use) { if (use == check) { - return 1; + return true; } } FOREACH_USE_END(); - return 0; + return false; } static inline bool is_in_phi_use_chain(zend_ssa *ssa, int var, zend_ssa_phi *check) { zend_ssa_phi *phi; FOREACH_PHI_USE(&ssa->vars[var], phi) { if (phi == check) { - return 1; + return true; } } FOREACH_PHI_USE_END(); - return 0; + return false; } static inline bool is_used_by_op(zend_ssa *ssa, int op, int check) { @@ -59,30 +59,30 @@ static inline bool is_in_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi, int check int source; FOREACH_PHI_SOURCE(phi, source) { if (source == check) { - return 1; + return true; } } FOREACH_PHI_SOURCE_END(); - return 0; + return false; } static inline bool is_in_predecessors(zend_cfg *cfg, zend_basic_block *block, int check) { int i, *predecessors = &cfg->predecessors[block->predecessor_offset]; for (i = 0; i < block->predecessors_count; i++) { if (predecessors[i] == check) { - return 1; + return true; } } - return 0; + return false; } static inline bool is_in_successors(zend_basic_block *block, int check) { int s; for (s = 0; s < block->successors_count; s++) { if (block->successors[s] == check) { - return 1; + return true; } } - return 0; + return false; } static inline bool is_var_type(uint8_t type) { diff --git a/Zend/Optimizer/zend_call_graph.c b/Zend/Optimizer/zend_call_graph.c index 8a2f8ea2a7e1a..645edd2f99914 100644 --- a/Zend/Optimizer/zend_call_graph.c +++ b/Zend/Optimizer/zend_call_graph.c @@ -146,7 +146,7 @@ ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32 case ZEND_SEND_USER: if (call_info) { if (opline->op2_type == IS_CONST) { - call_info->named_args = 1; + call_info->named_args = true; break; } @@ -160,7 +160,7 @@ ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32 case ZEND_SEND_ARRAY: case ZEND_SEND_UNPACK: if (call_info) { - call_info->send_unpack = 1; + call_info->send_unpack = true; } break; } @@ -169,26 +169,26 @@ ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32 free_alloca(call_stack, use_heap); } -static bool zend_is_indirectly_recursive(zend_op_array *root, zend_op_array *op_array, zend_bitset visited) +static bool zend_is_indirectly_recursive(const zend_op_array *root, const zend_op_array *op_array, zend_bitset visited) { - zend_func_info *func_info; + const zend_func_info *func_info; zend_call_info *call_info; - bool ret = 0; + bool ret = false; if (op_array == root) { - return 1; + return true; } func_info = ZEND_FUNC_INFO(op_array); if (zend_bitset_in(visited, func_info->num)) { - return 0; + return false; } zend_bitset_incl(visited, func_info->num); call_info = func_info->caller_info; while (call_info) { if (zend_is_indirectly_recursive(root, call_info->caller_op_array, visited)) { - call_info->recursive = 1; - ret = 1; + call_info->recursive = true; + ret = true; } call_info = call_info->next_caller; } @@ -197,16 +197,15 @@ static bool zend_is_indirectly_recursive(zend_op_array *root, zend_op_array *op_ static void zend_analyze_recursion(zend_call_graph *call_graph) { - zend_op_array *op_array; + const zend_op_array *op_array; zend_func_info *func_info; zend_call_info *call_info; - int i; - int set_len = zend_bitset_len(call_graph->op_arrays_count); + uint32_t set_len = zend_bitset_len(call_graph->op_arrays_count); zend_bitset visited; ALLOCA_FLAG(use_heap); visited = ZEND_BITSET_ALLOCA(set_len, use_heap); - for (i = 0; i < call_graph->op_arrays_count; i++) { + for (uint32_t i = 0; i < call_graph->op_arrays_count; i++) { op_array = call_graph->op_arrays[i]; func_info = call_graph->func_infos + i; call_info = func_info->caller_info; @@ -216,12 +215,12 @@ static void zend_analyze_recursion(zend_call_graph *call_graph) continue; } if (call_info->caller_op_array == op_array) { - call_info->recursive = 1; + call_info->recursive = true; func_info->flags |= ZEND_FUNC_RECURSIVE | ZEND_FUNC_RECURSIVE_DIRECTLY; } else { memset(visited, 0, sizeof(zend_ulong) * set_len); if (zend_is_indirectly_recursive(op_array, call_info->caller_op_array, visited)) { - call_info->recursive = 1; + call_info->recursive = true; func_info->flags |= ZEND_FUNC_RECURSIVE | ZEND_FUNC_RECURSIVE_INDIRECTLY; } } @@ -252,9 +251,7 @@ ZEND_API void zend_build_call_graph(zend_arena **arena, zend_script *script, zen ZEND_API void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph) /* {{{ */ { - int i; - - for (i = 0; i < call_graph->op_arrays_count; i++) { + for (uint32_t i = 0; i < call_graph->op_arrays_count; i++) { zend_analyze_calls(arena, script, 0, call_graph->op_arrays[i], call_graph->func_infos + i); } zend_analyze_recursion(call_graph); @@ -262,7 +259,7 @@ ZEND_API void zend_analyze_call_graph(zend_arena **arena, zend_script *script, z } /* }}} */ -ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array) /* {{{ */ +ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, const zend_func_info *info, const zend_op_array *op_array) /* {{{ */ { zend_call_info **map, *call; if (!info->callee_info) { @@ -272,13 +269,12 @@ ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info map = zend_arena_calloc(arena, sizeof(zend_call_info *), op_array->last); for (call = info->callee_info; call; call = call->next_callee) { - int i; map[call->caller_init_opline - op_array->opcodes] = call; if (call->caller_call_opline) { map[call->caller_call_opline - op_array->opcodes] = call; } if (!call->is_frameless) { - for (i = 0; i < call->num_args; i++) { + for (uint32_t i = 0; i < call->num_args; i++) { if (call->arg_info[i].opline) { map[call->arg_info[i].opline - op_array->opcodes] = call; } diff --git a/Zend/Optimizer/zend_call_graph.h b/Zend/Optimizer/zend_call_graph.h index b2cbb6822bcf3..8810dc1a560e7 100644 --- a/Zend/Optimizer/zend_call_graph.h +++ b/Zend/Optimizer/zend_call_graph.h @@ -39,12 +39,12 @@ struct _zend_call_info { bool named_args; /* Function has named arguments */ bool is_prototype; /* An overridden child method may be called */ bool is_frameless; /* A frameless function sends arguments through operands */ - int num_args; /* Number of arguments, excluding named and variadic arguments */ + uint32_t num_args; /* Number of arguments, excluding named and variadic arguments */ zend_send_arg_info arg_info[1]; }; struct _zend_func_info { - int num; + uint32_t num; uint32_t flags; zend_ssa ssa; /* Static Single Assignment Form */ zend_call_info *caller_info; /* where this function is called from */ @@ -54,7 +54,7 @@ struct _zend_func_info { }; typedef struct _zend_call_graph { - int op_arrays_count; + uint32_t op_arrays_count; zend_op_array **op_arrays; zend_func_info *func_infos; } zend_call_graph; @@ -63,7 +63,7 @@ BEGIN_EXTERN_C() ZEND_API void zend_build_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph); ZEND_API void zend_analyze_call_graph(zend_arena **arena, zend_script *script, zend_call_graph *call_graph); -ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, zend_func_info *info, const zend_op_array *op_array); +ZEND_API zend_call_info **zend_build_call_map(zend_arena **arena, const zend_func_info *info, const zend_op_array *op_array); ZEND_API void zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_flags, zend_op_array *op_array, zend_func_info *func_info); END_EXTERN_C() diff --git a/Zend/Optimizer/zend_cfg.c b/Zend/Optimizer/zend_cfg.c index a0d08b67aa70c..32d5f49ef7df4 100644 --- a/Zend/Optimizer/zend_cfg.c +++ b/Zend/Optimizer/zend_cfg.c @@ -274,13 +274,12 @@ ZEND_API void zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, { uint32_t flags = 0; uint32_t i; - int j; uint32_t *block_map; zend_function *fn; int blocks_count = 0; zend_basic_block *blocks; zval *zv; - bool extra_entry_block = 0; + bool extra_entry_block = false; cfg->flags = build_flags & (ZEND_CFG_STACKLESS|ZEND_CFG_RECV_ENTRY); @@ -445,11 +444,11 @@ ZEND_API void zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, /* If the entry block has predecessors, we may need to split it */ if ((build_flags & ZEND_CFG_NO_ENTRY_PREDECESSORS) && op_array->last > 0 && block_map[0] > 1) { - extra_entry_block = 1; + extra_entry_block = true; } if (op_array->last_try_catch) { - for (j = 0; j < op_array->last_try_catch; j++) { + for (uint32_t j = 0; j < op_array->last_try_catch; j++) { BB_START(op_array->try_catch_array[j].try_op); if (op_array->try_catch_array[j].catch_op) { BB_START(op_array->try_catch_array[j].catch_op); @@ -494,7 +493,7 @@ ZEND_API void zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, blocks_count++; /* Build CFG, Step 3: Calculate successors */ - for (j = 0; j < blocks_count; j++) { + for (int j = 0; j < blocks_count; j++) { zend_basic_block *block = &blocks[j]; zend_op *opline; if (block->len == 0) { diff --git a/Zend/Optimizer/zend_cfg.h b/Zend/Optimizer/zend_cfg.h index 93d455060686e..1f3885f511f5d 100644 --- a/Zend/Optimizer/zend_cfg.h +++ b/Zend/Optimizer/zend_cfg.h @@ -46,12 +46,12 @@ typedef struct _zend_basic_block { uint32_t len; /* number of opcodes */ int successors_count; /* number of successors */ int predecessors_count; /* number of predecessors */ - int predecessor_offset; /* offset of 1-st predecessor */ - int idom; /* immediate dominator block */ + int predecessor_offset; /* offset of 1-st predecessor, or -1 */ + int idom; /* immediate dominator block, or -1 */ int loop_header; /* closest loop header, or -1 */ - int level; /* steps away from the entry in the dom. tree */ - int children; /* list of dominated blocks */ - int next_child; /* next dominated block */ + int level; /* steps away from the entry in the dom. tree, or -1 */ + int children; /* list of dominated blocks, or -1 */ + int next_child; /* next dominated block, or -1 */ int successors_storage[2]; /* up to 2 successor blocks */ } zend_basic_block; diff --git a/Zend/Optimizer/zend_dfg.c b/Zend/Optimizer/zend_dfg.c index 101523141be94..c14d67e873a24 100644 --- a/Zend/Optimizer/zend_dfg.c +++ b/Zend/Optimizer/zend_dfg.c @@ -19,7 +19,7 @@ #include "zend_compile.h" #include "zend_dfg.h" -static zend_always_inline void _zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def) /* {{{ */ +static zend_always_inline void zend_dfg_add_use_def_op_impl(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def) /* {{{ */ { uint32_t var_num; const zend_op *next; @@ -245,20 +245,19 @@ static zend_always_inline void _zend_dfg_add_use_def_op(const zend_op_array *op_ ZEND_API void zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def) /* {{{ */ { - _zend_dfg_add_use_def_op(op_array, opline, build_flags, use, def); + zend_dfg_add_use_def_op_impl(op_array, opline, build_flags, use, def); } /* }}} */ -void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg *dfg, uint32_t build_flags) /* {{{ */ +void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, const zend_dfg *dfg, uint32_t build_flags) /* {{{ */ { - int set_size; + uint32_t set_size = dfg->size; zend_basic_block *blocks = cfg->blocks; int blocks_count = cfg->blocks_count; zend_bitset tmp, def, use, in, out; int k; int j; - set_size = dfg->size; tmp = dfg->tmp; def = dfg->def; use = dfg->use; @@ -267,7 +266,7 @@ void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg /* Collect "def" and "use" sets */ for (j = 0; j < blocks_count; j++) { - zend_op *opline, *end; + const zend_op *opline, *end; zend_bitset b_use, b_def; if ((blocks[j].flags & ZEND_BB_REACHABLE) == 0) { @@ -280,7 +279,7 @@ void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg b_def = DFG_BITSET(def, set_size, j); for (; opline < end; opline++) { if (opline->opcode != ZEND_OP_DATA) { - _zend_dfg_add_use_def_op(op_array, opline, build_flags, b_use, b_def); + zend_dfg_add_use_def_op_impl(op_array, opline, build_flags, b_use, b_def); } } } @@ -318,7 +317,7 @@ void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg /* Add predecessors of changed block to worklist */ { - int *predecessors = &cfg->predecessors[blocks[j].predecessor_offset]; + const int *predecessors = &cfg->predecessors[blocks[j].predecessor_offset]; for (k = 0; k < blocks[j].predecessors_count; k++) { zend_bitset_incl(worklist, predecessors[k]); } diff --git a/Zend/Optimizer/zend_dfg.h b/Zend/Optimizer/zend_dfg.h index b59dc62790901..af3d761ba29f8 100644 --- a/Zend/Optimizer/zend_dfg.h +++ b/Zend/Optimizer/zend_dfg.h @@ -43,7 +43,7 @@ typedef struct _zend_dfg { BEGIN_EXTERN_C() -void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg *dfg, uint32_t build_flags); +void zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, const zend_dfg *dfg, uint32_t build_flags); ZEND_API void zend_dfg_add_use_def_op(const zend_op_array *op_array, const zend_op *opline, uint32_t build_flags, zend_bitset use, zend_bitset def); END_EXTERN_C() diff --git a/Zend/Optimizer/zend_dump.c b/Zend/Optimizer/zend_dump.c index 64deb7085edf3..9c51ad223e060 100644 --- a/Zend/Optimizer/zend_dump.c +++ b/Zend/Optimizer/zend_dump.c @@ -30,11 +30,11 @@ void zend_dump_ht(HashTable *ht) zend_ulong index; zend_string *key; zval *val; - bool first = 1; + bool first = true; ZEND_HASH_FOREACH_KEY_VAL(ht, index, key, val) { if (first) { - first = 0; + first = false; } else { fprintf(stderr, ", "); } @@ -188,36 +188,36 @@ static void zend_dump_range(const zend_ssa_range *r) static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_instanceof, uint32_t dump_flags) { - bool first = 1; + bool first = true; fprintf(stderr, " ["); if (info & MAY_BE_GUARD) { fprintf(stderr, "!"); } if (info & MAY_BE_UNDEF) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "undef"); } if (info & MAY_BE_INDIRECT) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "ind"); } if (info & MAY_BE_REF) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "ref"); } if (dump_flags & ZEND_DUMP_RC_INFERENCE) { if (info & MAY_BE_RC1) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "rc1"); } if (info & MAY_BE_RCN) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "rcn"); } } if (info & MAY_BE_CLASS) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "class"); if (ce) { if (is_instanceof) { @@ -227,37 +227,37 @@ static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_inst } } } else if ((info & MAY_BE_ANY) == MAY_BE_ANY) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "any"); } else { if (info & MAY_BE_NULL) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "null"); } if ((info & MAY_BE_FALSE) && (info & MAY_BE_TRUE)) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "bool"); } else if (info & MAY_BE_FALSE) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "false"); } else if (info & MAY_BE_TRUE) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "true"); } if (info & MAY_BE_LONG) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "long"); } if (info & MAY_BE_DOUBLE) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "double"); } if (info & MAY_BE_STRING) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "string"); } if (info & MAY_BE_ARRAY) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); if (info & MAY_BE_PACKED_GUARD) { fprintf(stderr, "!"); } @@ -268,18 +268,18 @@ static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_inst } else if (MAY_BE_HASH_ONLY(info)) { fprintf(stderr, "hash "); } else if ((info & MAY_BE_ARRAY_KEY_ANY) != MAY_BE_ARRAY_KEY_ANY && (info & MAY_BE_ARRAY_KEY_ANY) != 0) { - bool afirst = 1; + bool afirst = true; fprintf(stderr, "["); if (info & MAY_BE_ARRAY_EMPTY) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "empty"); } if (MAY_BE_PACKED(info)) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "packed"); } if (MAY_BE_HASH(info)) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "hash"); } fprintf(stderr, "] "); @@ -288,71 +288,71 @@ static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_inst if ((info & (MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_KEY_STRING)) != 0 && ((info & MAY_BE_ARRAY_KEY_LONG) == 0 || (info & MAY_BE_ARRAY_KEY_STRING) == 0)) { - bool afirst = 1; + bool afirst = true; fprintf(stderr, " ["); if (info & MAY_BE_ARRAY_KEY_LONG) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "long"); } if (info & MAY_BE_ARRAY_KEY_STRING) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "string"); } fprintf(stderr, "]"); } if (info & (MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF)) { - bool afirst = 1; + bool afirst = true; fprintf(stderr, " of ["); if ((info & MAY_BE_ARRAY_OF_ANY) == MAY_BE_ARRAY_OF_ANY) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "any"); } else { if (info & MAY_BE_ARRAY_OF_NULL) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "null"); } if (info & MAY_BE_ARRAY_OF_FALSE) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "false"); } if (info & MAY_BE_ARRAY_OF_TRUE) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "true"); } if (info & MAY_BE_ARRAY_OF_LONG) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "long"); } if (info & MAY_BE_ARRAY_OF_DOUBLE) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "double"); } if (info & MAY_BE_ARRAY_OF_STRING) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "string"); } if (info & MAY_BE_ARRAY_OF_ARRAY) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "array"); } if (info & MAY_BE_ARRAY_OF_OBJECT) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "object"); } if (info & MAY_BE_ARRAY_OF_RESOURCE) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "resource"); } } if (info & MAY_BE_ARRAY_OF_REF) { - if (afirst) afirst = 0; else fprintf(stderr, ", "); + if (afirst) afirst = false; else fprintf(stderr, ", "); fprintf(stderr, "ref"); } fprintf(stderr, "]"); } } if (info & MAY_BE_OBJECT) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "object"); if (ce) { if (is_instanceof) { @@ -363,7 +363,7 @@ static void zend_dump_type_info(uint32_t info, zend_class_entry *ce, int is_inst } } if (info & MAY_BE_RESOURCE) { - if (first) first = 0; else fprintf(stderr, ", "); + if (first) first = false; else fprintf(stderr, ", "); fprintf(stderr, "resource"); } } @@ -1056,7 +1056,7 @@ ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_fl } if (op_array->last_live_range && (dump_flags & ZEND_DUMP_LIVE_RANGES)) { fprintf(stderr, "LIVE RANGES:\n"); - for (int i = 0; i < op_array->last_live_range; i++) { + for (uint32_t i = 0; i < op_array->last_live_range; i++) { fprintf(stderr, " %u: %04u - %04u ", EX_VAR_TO_NUM(op_array->live_range[i].var & ~ZEND_LIVE_MASK), @@ -1083,7 +1083,7 @@ ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_fl } if (op_array->last_try_catch) { fprintf(stderr, "EXCEPTION TABLE:\n"); - for (int i = 0; i < op_array->last_try_catch; i++) { + for (uint32_t i = 0; i < op_array->last_try_catch; i++) { fprintf(stderr, " BB%u", cfg->map[op_array->try_catch_array[i].try_op]); if (op_array->try_catch_array[i].catch_op) { @@ -1116,7 +1116,7 @@ ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_fl } if (op_array->last_live_range && (dump_flags & ZEND_DUMP_LIVE_RANGES)) { fprintf(stderr, "LIVE RANGES:\n"); - for (int i = 0; i < op_array->last_live_range; i++) { + for (uint32_t i = 0; i < op_array->last_live_range; i++) { fprintf(stderr, " %u: %04u - %04u ", EX_VAR_TO_NUM(op_array->live_range[i].var & ~ZEND_LIVE_MASK), @@ -1143,7 +1143,7 @@ ZEND_API void zend_dump_op_array(const zend_op_array *op_array, uint32_t dump_fl } if (op_array->last_try_catch) { fprintf(stderr, "EXCEPTION TABLE:\n"); - for (int i = 0; i < op_array->last_try_catch; i++) { + for (uint32_t i = 0; i < op_array->last_try_catch; i++) { fprintf(stderr, " %04u", op_array->try_catch_array[i].try_op); @@ -1216,14 +1216,14 @@ void zend_dump_ssa_variables(const zend_op_array *op_array, const zend_ssa *ssa, static void zend_dump_var_set(const zend_op_array *op_array, const char *name, zend_bitset set) { - bool first = 1; + bool first = true; uint32_t i; fprintf(stderr, " ; %s = {", name); for (i = 0; i < op_array->last_var + op_array->T; i++) { if (zend_bitset_in(set, i)) { if (first) { - first = 0; + first = false; } else { fprintf(stderr, ", "); } diff --git a/Zend/Optimizer/zend_func_info.c b/Zend/Optimizer/zend_func_info.c index 121d2d2cfe570..f3b0d663dd6df 100644 --- a/Zend/Optimizer/zend_func_info.c +++ b/Zend/Optimizer/zend_func_info.c @@ -57,7 +57,7 @@ static uint32_t zend_range_info(const zend_call_info *call_info, const zend_ssa && (call_info->num_args == 2 || call_info->num_args == 3) && ssa && !(ssa->cfg.flags & ZEND_SSA_TSSA)) { - zend_op_array *op_array = call_info->caller_op_array; + const zend_op_array *op_array = call_info->caller_op_array; uint32_t t1 = _ssa_op1_info(op_array, ssa, call_info->arg_info[0].opline, ssa->ops ? &ssa->ops[call_info->arg_info[0].opline - op_array->opcodes] : NULL); uint32_t t2 = _ssa_op1_info(op_array, ssa, call_info->arg_info[1].opline, @@ -116,7 +116,7 @@ uint32_t zend_get_internal_func_info( return 0; } - func_info_t *info = Z_PTR_P(zv); + const func_info_t *info = Z_PTR_P(zv); if (info->info_func) { return call_info ? info->info_func(call_info, ssa) : 0; } else { @@ -136,7 +136,7 @@ ZEND_API uint32_t zend_get_func_info( uint32_t ret = 0; const zend_function *callee_func = call_info->callee_func; *ce = NULL; - *ce_is_instanceof = 0; + *ce_is_instanceof = false; if (callee_func->type == ZEND_INTERNAL_FUNCTION) { uint32_t internal_ret = zend_get_internal_func_info(callee_func, call_info, ssa); @@ -178,7 +178,7 @@ ZEND_API uint32_t zend_get_func_info( } else { if (!call_info->is_prototype) { // FIXME: the order of functions matters!!! - zend_func_info *info = ZEND_FUNC_INFO((zend_op_array*)callee_func); + const zend_func_info *info = ZEND_FUNC_INFO((zend_op_array*)callee_func); if (info) { ret = info->return_info.type; *ce = info->return_info.ce; @@ -198,13 +198,13 @@ ZEND_API uint32_t zend_get_func_info( return ret; } -static void zend_func_info_add(const func_info_t *func_infos, size_t n) +static void zend_func_info_add(const func_info_t *new_func_infos, size_t n) { for (size_t i = 0; i < n; i++) { - zend_string *key = zend_string_init_interned(func_infos[i].name, func_infos[i].name_len, 1); + zend_string *key = zend_string_init_interned(new_func_infos[i].name, new_func_infos[i].name_len, 1); - if (zend_hash_add_ptr(&func_info, key, (void**)&func_infos[i]) == NULL) { - fprintf(stderr, "ERROR: Duplicate function info for \"%s\"\n", func_infos[i].name); + if (zend_hash_add_ptr(&func_info, key, (void**)&new_func_infos[i]) == NULL) { + fprintf(stderr, "ERROR: Duplicate function info for \"%s\"\n", new_func_infos[i].name); } zend_string_release_ex(key, 1); diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index b2479a57b6e98..54670c804d006 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -266,7 +266,7 @@ typedef struct _zend_scc_iterator { }; } zend_scc_iterator; -static int zend_scc_next(const zend_op_array *op_array, zend_ssa *ssa, int var, zend_scc_iterator *iterator) /* {{{ */ +static int zend_scc_next(const zend_op_array *op_array, const zend_ssa *ssa, int var, zend_scc_iterator *iterator) /* {{{ */ { zend_ssa_phi *phi; int use, var2; @@ -487,14 +487,14 @@ ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa) / #endif -ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa) /* {{{ */ +ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, const zend_ssa *ssa) /* {{{ */ { zend_ssa_var *ssa_vars = ssa->vars; - zend_ssa_op *ssa_ops = ssa->ops; + const zend_ssa_op *ssa_ops = ssa->ops; int ssa_vars_count = ssa->vars_count; zend_bitset worklist; int i, j, use; - zend_ssa_phi *p; + const zend_ssa_phi *p; ALLOCA_FLAG(use_heap); if (!op_array->function_name || !ssa->vars || !ssa->ops) { @@ -1068,7 +1068,7 @@ static bool zend_inference_calc_binary_op_range( return 0; } -static bool zend_inference_calc_range(const zend_op_array *op_array, const zend_ssa *ssa, int var, int widening, int narrowing, zend_ssa_range *tmp) +static bool zend_inference_calc_range(const zend_op_array *op_array, const zend_ssa *ssa, int var, int widening, bool narrowing, zend_ssa_range *tmp) { uint32_t line; const zend_op *opline; @@ -1597,7 +1597,7 @@ ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, cons return 0; } -static void zend_inference_init_range(const zend_op_array *op_array, zend_ssa *ssa, int var, bool underflow, zend_long min, zend_long max, bool overflow) +static void zend_inference_init_range(const zend_op_array *op_array, const zend_ssa *ssa, int var, bool underflow, zend_long min, zend_long max, bool overflow) { if (underflow) { min = ZEND_LONG_MIN; @@ -1645,7 +1645,7 @@ static bool zend_inference_widening_meet(zend_ssa_var_info *var_info, zend_ssa_r return 1; } -static bool zend_ssa_range_widening(const zend_op_array *op_array, zend_ssa *ssa, int var, int scc) +static bool zend_ssa_range_widening(const zend_op_array *op_array, const zend_ssa *ssa, int var, int scc) { zend_ssa_range tmp; @@ -1690,7 +1690,7 @@ static bool zend_inference_narrowing_meet(zend_ssa_var_info *var_info, zend_ssa_ return 1; } -static bool zend_ssa_range_narrowing(const zend_op_array *op_array, zend_ssa *ssa, int var, int scc) +static bool zend_ssa_range_narrowing(const zend_op_array *op_array, const zend_ssa *ssa, int var, int scc) { zend_ssa_range tmp; @@ -1735,7 +1735,7 @@ static void zend_infer_ranges_warmup(const zend_op_array *op_array, zend_ssa *ss zend_bitset worklist = do_alloca(sizeof(zend_ulong) * worklist_len * 2, use_heap); zend_bitset visited = worklist + worklist_len; #ifdef NEG_RANGE - int has_inner_cycles = 0; + bool has_inner_cycles = false; memset(worklist, 0, sizeof(zend_ulong) * worklist_len); memset(visited, 0, sizeof(zend_ulong) * worklist_len); @@ -1743,7 +1743,7 @@ static void zend_infer_ranges_warmup(const zend_op_array *op_array, zend_ssa *ss while (j >= 0) { if (!zend_bitset_in(visited, j) && zend_check_inner_cycles(op_array, ssa, worklist, visited, j)) { - has_inner_cycles = 1; + has_inner_cycles = true; break; } j = next_scc_var[j]; @@ -1862,7 +1862,7 @@ static void zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* { } else if (zend_inference_calc_range(op_array, ssa, j, 0, 1, &tmp)) { zend_inference_init_range(op_array, ssa, j, tmp.underflow, tmp.min, tmp.max, tmp.overflow); } else { - zend_inference_init_range(op_array, ssa, j, 1, ZEND_LONG_MIN, ZEND_LONG_MAX, 1); + zend_inference_init_range(op_array, ssa, j, true, ZEND_LONG_MIN, ZEND_LONG_MAX, true); } } else { /* Find SCC entry points */ @@ -1897,7 +1897,8 @@ static void zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* { for (j = scc_var[scc]; j >= 0; j = next_scc_var[j]) { if (!ssa->var_info[j].has_range && !(ssa->var_info[j].type & MAY_BE_REF)) { - zend_inference_init_range(op_array, ssa, j, 1, ZEND_LONG_MIN, ZEND_LONG_MAX, 1); + zend_inference_init_range(op_array, ssa, j, true, ZEND_LONG_MIN, ZEND_LONG_MAX, + true); FOR_EACH_VAR_USAGE(j, ADD_SCC_VAR); } } @@ -2028,10 +2029,10 @@ static uint32_t get_ssa_alias_types(zend_ssa_alias_kind alias) { } \ } while (0) -static void add_usages(const zend_op_array *op_array, zend_ssa *ssa, zend_bitset worklist, int var) +static void add_usages(const zend_op_array *op_array, const zend_ssa *ssa, zend_bitset worklist, int var) { if (ssa->vars[var].phi_use_chain) { - zend_ssa_phi *p = ssa->vars[var].phi_use_chain; + const zend_ssa_phi *p = ssa->vars[var].phi_use_chain; do { zend_bitset_incl(worklist, p->ssa_var); p = zend_ssa_next_use_phi(ssa, var, p); @@ -2039,7 +2040,7 @@ static void add_usages(const zend_op_array *op_array, zend_ssa *ssa, zend_bitset } if (ssa->vars[var].use_chain >= 0) { int use = ssa->vars[var].use_chain; - zend_ssa_op *op; + const zend_ssa_op *op; do { op = ssa->ops + use; @@ -2081,7 +2082,7 @@ static void add_usages(const zend_op_array *op_array, zend_ssa *ssa, zend_bitset } } -static void emit_type_narrowing_warning(const zend_op_array *op_array, zend_ssa *ssa, int var) +static void emit_type_narrowing_warning(const zend_op_array *op_array, const zend_ssa *ssa, int var) { int def_op_num = ssa->vars[var].definition; const zend_op *def_opline = def_op_num >= 0 ? &op_array->opcodes[def_op_num] : NULL; @@ -2129,7 +2130,7 @@ ZEND_API uint32_t ZEND_FASTCALL zend_array_type_info(const zval *zv) } -ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert) +ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool write, bool insert) { uint32_t tmp = 0; @@ -2257,7 +2258,7 @@ static uint32_t assign_dim_result_type( /* For binary ops that have compound assignment operators */ static uint32_t binary_op_result_type( - zend_ssa *ssa, uint8_t opcode, uint32_t t1, uint32_t t2, int result_var, + const zend_ssa *ssa, uint8_t opcode, uint32_t t1, uint32_t t2, int result_var, zend_long optimization_level) { uint32_t tmp = 0; uint32_t t1_type = (t1 & MAY_BE_ANY) | (t1 & MAY_BE_UNDEF ? MAY_BE_NULL : 0); @@ -2434,7 +2435,7 @@ static const zend_property_info *lookup_prop_info(const zend_class_entry *ce, ze return NULL; } -static const zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) +static const zend_property_info *zend_fetch_prop_info(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op *ssa_op) { const zend_property_info *prop_info = NULL; if (opline->op2_type == IS_CONST) { @@ -2461,9 +2462,9 @@ static const zend_property_info *zend_fetch_static_prop_info(const zend_script * { const zend_property_info *prop_info = NULL; if (opline->op1_type == IS_CONST) { - zend_class_entry *ce = NULL; + const zend_class_entry *ce = NULL; if (opline->op2_type == IS_UNUSED) { - int fetch_type = opline->op2.num & ZEND_FETCH_CLASS_MASK; + uint32_t fetch_type = opline->op2.num & ZEND_FETCH_CLASS_MASK; switch (fetch_type) { case ZEND_FETCH_CLASS_SELF: case ZEND_FETCH_CLASS_STATIC: @@ -2478,12 +2479,12 @@ static const zend_property_info *zend_fetch_static_prop_info(const zend_script * break; } } else if (opline->op2_type == IS_CONST) { - zval *zv = CRT_CONSTANT(opline->op2); + const zval *zv = CRT_CONSTANT(opline->op2); ce = zend_optimizer_get_class_entry(script, op_array, Z_STR_P(zv + 1)); } if (ce) { - zval *zv = CRT_CONSTANT(opline->op1); + const zval *zv = CRT_CONSTANT(opline->op1); prop_info = lookup_prop_info(ce, Z_STR_P(zv), op_array->scope); if (prop_info && !(prop_info->flags & ZEND_ACC_STATIC)) { prop_info = NULL; @@ -2505,13 +2506,13 @@ static uint32_t zend_fetch_prop_type(const zend_script *script, const zend_prope return zend_convert_type(script, prop_info->type, pce); } -static bool result_may_be_separated(zend_ssa *ssa, zend_ssa_op *ssa_op) +static bool result_may_be_separated(const zend_ssa *ssa, const zend_ssa_op *ssa_op) { int tmp_var = ssa_op->result_def; if (ssa->vars[tmp_var].use_chain >= 0 && !ssa->vars[tmp_var].phi_use_chain) { - zend_ssa_op *use_op = &ssa->ops[ssa->vars[tmp_var].use_chain]; + const zend_ssa_op *use_op = &ssa->ops[ssa->vars[tmp_var].use_chain]; /* TODO: analyze instructions between ssa_op and use_op */ if (use_op == ssa_op + 1) { @@ -3027,7 +3028,7 @@ static zend_always_inline zend_result _zend_update_type_info( break; case ZEND_ASSIGN_OBJ: if (opline->op1_type == IS_CV) { - zend_class_entry *ce = ssa_var_info[ssa_op->op1_use].ce; + const zend_class_entry *ce = ssa_var_info[ssa_op->op1_use].ce; bool add_rc = (t1 & (MAY_BE_OBJECT|MAY_BE_REF)) && (!ce || ce->__set /* Non-default write_property may be set within create_object. */ @@ -4119,15 +4120,16 @@ ZEND_API zend_result zend_update_type_info( const zend_op_array *op_array, zend_ssa *ssa, const zend_script *script, - zend_op *opline, + const zend_op *opline, zend_ssa_op *ssa_op, const zend_op **ssa_opcodes, zend_long optimization_level) { - return _zend_update_type_info(op_array, ssa, script, NULL, opline, ssa_op, ssa_opcodes, optimization_level, 0); + return _zend_update_type_info(op_array, ssa, script, NULL, opline, ssa_op, ssa_opcodes, optimization_level, + false); } -static uint32_t get_class_entry_rank(zend_class_entry *ce) { +static uint32_t get_class_entry_rank(const zend_class_entry *ce) { uint32_t rank = 0; if (ce->ce_flags & ZEND_ACC_LINKED) { while (ce->parent) { @@ -4140,7 +4142,7 @@ static uint32_t get_class_entry_rank(zend_class_entry *ce) { /* Compute least common ancestor on class inheritance tree only */ static zend_class_entry *join_class_entries( - zend_class_entry *ce1, zend_class_entry *ce2, int *is_instanceof) { + zend_class_entry *ce1, zend_class_entry *ce2, bool *is_instanceof) { uint32_t rank1, rank2; if (ce1 == ce2) { return ce1; @@ -4168,12 +4170,12 @@ static zend_class_entry *join_class_entries( } if (ce1) { - *is_instanceof = 1; + *is_instanceof = true; } return ce1; } -static bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) { +static bool safe_instanceof(const zend_class_entry *ce1, const zend_class_entry *ce2) { if (ce1 == ce2) { return 1; } @@ -4186,7 +4188,7 @@ static bool safe_instanceof(zend_class_entry *ce1, zend_class_entry *ce2) { static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_bitset worklist, zend_long optimization_level) { - zend_basic_block *blocks = ssa->cfg.blocks; + const zend_basic_block *blocks = ssa->cfg.blocks; zend_ssa_var *ssa_vars = ssa->vars; zend_ssa_var_info *ssa_var_info = ssa->var_info; int ssa_vars_count = ssa->vars_count; @@ -4202,11 +4204,11 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend zend_ssa_phi *p = ssa_vars[j].definition_phi; if (p->pi >= 0) { zend_class_entry *ce = ssa_var_info[p->sources[0]].ce; - int is_instanceof = ssa_var_info[p->sources[0]].is_instanceof; + bool is_instanceof = ssa_var_info[p->sources[0]].is_instanceof; tmp = get_ssa_var_info(ssa, p->sources[0]); if (!p->has_range_constraint) { - zend_ssa_type_constraint *constraint = &p->constraint.type; + const zend_ssa_type_constraint *constraint = &p->constraint.type; tmp &= constraint->type_mask; if (!(tmp & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) { tmp &= ~(MAY_BE_RC1|MAY_BE_RCN); @@ -4214,7 +4216,7 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend if ((tmp & MAY_BE_OBJECT) && constraint->ce && ce != constraint->ce) { if (!ce) { ce = constraint->ce; - is_instanceof = 1; + is_instanceof = true; } else if (is_instanceof && safe_instanceof(constraint->ce, ce)) { ce = constraint->ce; } else { @@ -4231,8 +4233,8 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend UPDATE_SSA_OBJ_TYPE(ce, is_instanceof, j); } } else { - int first = 1; - int is_instanceof = 0; + bool first = true; + bool is_instanceof = false; zend_class_entry *ce = NULL; tmp = 0; @@ -4249,7 +4251,7 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend if (first) { ce = info->ce; is_instanceof = info->is_instanceof; - first = 0; + first = false; } else { is_instanceof |= info->is_instanceof; ce = join_class_entries(ce, info->ce, &is_instanceof); @@ -4260,7 +4262,7 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend } } else if (ssa_vars[j].definition >= 0) { i = ssa_vars[j].definition; - if (_zend_update_type_info(op_array, ssa, script, worklist, op_array->opcodes + i, ssa->ops + i, NULL, optimization_level, 1) == FAILURE) { + if (_zend_update_type_info(op_array, ssa, script, worklist, op_array->opcodes + i, ssa->ops + i, NULL, optimization_level, true) == FAILURE) { return FAILURE; } } @@ -4268,18 +4270,18 @@ static zend_result zend_infer_types_ex(const zend_op_array *op_array, const zend return SUCCESS; } -static bool is_narrowable_instr(zend_op *opline) { +static bool is_narrowable_instr(const zend_op *opline) { return opline->opcode == ZEND_ADD || opline->opcode == ZEND_SUB || opline->opcode == ZEND_MUL || opline->opcode == ZEND_DIV; } -static bool is_effective_op1_double_cast(zend_op *opline, zval *op2) { +static bool is_effective_op1_double_cast(const zend_op *opline, const zval *op2) { return (opline->opcode == ZEND_ADD && Z_LVAL_P(op2) == 0) || (opline->opcode == ZEND_SUB && Z_LVAL_P(op2) == 0) || (opline->opcode == ZEND_MUL && Z_LVAL_P(op2) == 1) || (opline->opcode == ZEND_DIV && Z_LVAL_P(op2) == 1); } -static bool is_effective_op2_double_cast(zend_op *opline, zval *op1) { +static bool is_effective_op2_double_cast(const zend_op *opline, const zval *op1) { /* In PHP it holds that (double)(0-$int) is bitwise identical to 0.0-(double)$int, * so allowing SUB here is fine. */ return (opline->opcode == ZEND_ADD && Z_LVAL_P(op1) == 0) @@ -4491,19 +4493,18 @@ static zend_result zend_type_narrowing(const zend_op_array *op_array, const zend return SUCCESS; } -static bool is_recursive_tail_call(const zend_op_array *op_array, - zend_op *opline) +static bool is_recursive_tail_call(const zend_op_array *op_array, const zend_op *opline) { - zend_func_info *info = ZEND_FUNC_INFO(op_array); + const zend_func_info *info = ZEND_FUNC_INFO(op_array); if (info->ssa.ops && info->ssa.vars && info->call_map && info->ssa.ops[opline - op_array->opcodes].op1_use >= 0 && info->ssa.vars[info->ssa.ops[opline - op_array->opcodes].op1_use].definition >= 0) { - zend_op *op = op_array->opcodes + info->ssa.vars[info->ssa.ops[opline - op_array->opcodes].op1_use].definition; + const zend_op *op = op_array->opcodes + info->ssa.vars[info->ssa.ops[opline - op_array->opcodes].op1_use].definition; if (op->opcode == ZEND_DO_UCALL) { - zend_call_info *call_info = info->call_map[op - op_array->opcodes]; + const zend_call_info *call_info = info->call_map[op - op_array->opcodes]; if (call_info && op_array == &call_info->callee_func->op_array) { return 1; } @@ -4519,7 +4520,7 @@ uint32_t zend_get_return_info_from_signature_only( if (func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE && (use_tentative_return_info || !ZEND_ARG_TYPE_IS_TENTATIVE(func->common.arg_info - 1)) ) { - zend_arg_info *ret_info = func->common.arg_info - 1; + const zend_arg_info *ret_info = func->common.arg_info - 1; type = zend_fetch_arg_info_type(script, ret_info, ce); *ce_is_instanceof = ce != NULL; } else { @@ -4534,7 +4535,7 @@ uint32_t zend_get_return_info_from_signature_only( && !(func->common.fn_flags & ZEND_ACC_GENERATOR)) { type |= MAY_BE_REF; *ce = NULL; - *ce_is_instanceof = 0; + *ce_is_instanceof = false; } return type; } @@ -4547,7 +4548,7 @@ ZEND_API void zend_init_func_return_info( zend_ssa_range tmp_range = {0, 0, 0, 0}; bool is_instanceof = false; ret->type = zend_get_return_info_from_signature_only( - (zend_function *) op_array, script, &ret->ce, &is_instanceof, /* use_tentative_return_info */ 1); + (zend_function *) op_array, script, &ret->ce, &is_instanceof, /* use_tentative_return_info */ true); ret->is_instanceof = is_instanceof; ret->range = tmp_range; ret->has_range = 0; @@ -4555,21 +4556,21 @@ ZEND_API void zend_init_func_return_info( static void zend_func_return_info(const zend_op_array *op_array, const zend_script *script, - int recursive, - int widening, + bool recursive, + bool widening, zend_ssa_var_info *ret) { - zend_func_info *info = ZEND_FUNC_INFO(op_array); - zend_ssa *ssa = &info->ssa; + const zend_func_info *info = ZEND_FUNC_INFO(op_array); + const zend_ssa *ssa = &info->ssa; int blocks_count = info->ssa.cfg.blocks_count; - zend_basic_block *blocks = info->ssa.cfg.blocks; + const zend_basic_block *blocks = info->ssa.cfg.blocks; int j; uint32_t t1; uint32_t tmp = 0; zend_class_entry *tmp_ce = NULL; int tmp_is_instanceof = -1; zend_class_entry *arg_ce; - int arg_is_instanceof; + bool arg_is_instanceof; zend_ssa_range tmp_range = {0, 0, 0, 0}; int tmp_has_range = -1; @@ -4593,7 +4594,7 @@ static void zend_func_return_info(const zend_op_array *op_array, zend_op *opline = op_array->opcodes + blocks[j].start + blocks[j].len - 1; if (opline->opcode == ZEND_RETURN || opline->opcode == ZEND_RETURN_BY_REF) { - zend_ssa_op *ssa_op = ssa->ops ? &ssa->ops[opline - op_array->opcodes] : NULL; + const zend_ssa_op *ssa_op = ssa->ops ? &ssa->ops[opline - op_array->opcodes] : NULL; if (!recursive && ssa_op && info->ssa.var_info && ssa_op->op1_use >= 0 && info->ssa.var_info[ssa_op->op1_use].recursive) { @@ -4624,7 +4625,7 @@ static void zend_func_return_info(const zend_op_array *op_array, arg_is_instanceof = info->ssa.var_info[ssa_op->op1_use].is_instanceof; } else { arg_ce = NULL; - arg_is_instanceof = 0; + arg_is_instanceof = false; } if (tmp_is_instanceof < 0) { @@ -4640,7 +4641,7 @@ static void zend_func_return_info(const zend_op_array *op_array, } if (opline->op1_type == IS_CONST) { - zval *zv = CRT_CONSTANT(opline->op1); + const zval *zv = CRT_CONSTANT(opline->op1); if (Z_TYPE_P(zv) == IS_LONG) { if (tmp_has_range < 0) { @@ -4743,7 +4744,7 @@ static zend_result zend_infer_types(const zend_op_array *op_array, const zend_sc return SUCCESS; } -static void zend_mark_cv_references(const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa) +static void zend_mark_cv_references(const zend_op_array *op_array, const zend_script *script, const zend_ssa *ssa) { int var, def; const zend_op *opline; diff --git a/Zend/Optimizer/zend_inference.h b/Zend/Optimizer/zend_inference.h index 666abc586592e..1b626fa2ee227 100644 --- a/Zend/Optimizer/zend_inference.h +++ b/Zend/Optimizer/zend_inference.h @@ -217,11 +217,11 @@ static zend_always_inline bool zend_sub_will_overflow(zend_long a, zend_long b) BEGIN_EXTERN_C() -ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, zend_ssa *ssa); +ZEND_API void zend_ssa_find_false_dependencies(const zend_op_array *op_array, const zend_ssa *ssa); ZEND_API void zend_ssa_find_sccs(const zend_op_array *op_array, zend_ssa *ssa); ZEND_API zend_result zend_ssa_inference(zend_arena **raena, const zend_op_array *op_array, const zend_script *script, zend_ssa *ssa, zend_long optimization_level); -ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, int write, int insert); +ZEND_API uint32_t zend_array_element_type(uint32_t t1, uint8_t op_type, bool write, bool insert); ZEND_API bool zend_inference_propagate_range(const zend_op_array *op_array, const zend_ssa *ssa, const zend_op *opline, const zend_ssa_op* ssa_op, int var, zend_ssa_range *tmp); @@ -238,7 +238,7 @@ ZEND_API bool zend_may_throw(const zend_op *opline, const zend_ssa_op *ssa_op, c ZEND_API zend_result zend_update_type_info( const zend_op_array *op_array, zend_ssa *ssa, const zend_script *script, - zend_op *opline, zend_ssa_op *ssa_op, const zend_op **ssa_opcodes, + const zend_op *opline, zend_ssa_op *ssa_op, const zend_op **ssa_opcodes, zend_long optimization_level); END_EXTERN_C() diff --git a/Zend/Optimizer/zend_optimizer.c b/Zend/Optimizer/zend_optimizer.c index 80eabe97c3217..b57ad3ad4268e 100644 --- a/Zend/Optimizer/zend_optimizer.c +++ b/Zend/Optimizer/zend_optimizer.c @@ -41,7 +41,7 @@ struct { int last; } zend_optimizer_registered_passes = {{NULL}, 0}; -void zend_optimizer_collect_constant(zend_optimizer_ctx *ctx, zval *name, zval* value) +void zend_optimizer_collect_constant(zend_optimizer_ctx *ctx, const zval *name, zval* value) { if (!ctx->constants) { ctx->constants = zend_arena_alloc(&ctx->arena, sizeof(HashTable)); @@ -103,11 +103,11 @@ zend_result zend_optimizer_eval_strlen(zval *result, const zval *op1) /* {{{ */ /* }}} */ zend_result zend_optimizer_eval_special_func_call( - zval *result, zend_string *name, zend_string *arg) { + zval *result, const zend_string *name, zend_string *arg) { if (zend_string_equals_literal(name, "function_exists") || zend_string_equals_literal(name, "is_callable")) { zend_string *lc_name = zend_string_tolower(arg); - zend_internal_function *func = zend_hash_find_ptr(EG(function_table), lc_name); + const zend_internal_function *func = zend_hash_find_ptr(EG(function_table), lc_name); zend_string_release_ex(lc_name, 0); if (func && func->type == ZEND_INTERNAL_FUNCTION @@ -145,7 +145,7 @@ zend_result zend_optimizer_eval_special_func_call( return FAILURE; } if (zend_string_equals_literal(name, "constant")) { - return zend_optimizer_get_persistent_constant(arg, result, 1) ? SUCCESS : FAILURE; + return zend_optimizer_get_persistent_constant(arg, result, true) ? SUCCESS : FAILURE; } if (zend_string_equals_literal(name, "dirname")) { if (!IS_ABSOLUTE_PATH(ZSTR_VAL(arg), ZSTR_LEN(arg))) { @@ -180,18 +180,18 @@ zend_result zend_optimizer_eval_special_func_call( return FAILURE; } -bool zend_optimizer_get_collected_constant(HashTable *constants, zval *name, zval* value) +bool zend_optimizer_get_collected_constant(const HashTable *constants, const zval *name, zval* value) { zval *val; if ((val = zend_hash_find(constants, Z_STR_P(name))) != NULL) { ZVAL_COPY(value, val); - return 1; + return true; } - return 0; + return false; } -void zend_optimizer_convert_to_free_op1(zend_op_array *op_array, zend_op *opline) +void zend_optimizer_convert_to_free_op1(const zend_op_array *op_array, zend_op *opline) { if (opline->op1_type == IS_CV) { opline->opcode = ZEND_CHECK_VAR; @@ -210,9 +210,9 @@ void zend_optimizer_convert_to_free_op1(zend_op_array *op_array, zend_op *opline } } -int zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv) +uint32_t zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv) { - int i = op_array->last_literal; + uint32_t i = op_array->last_literal; op_array->last_literal++; op_array->literals = (zval*)erealloc(op_array->literals, op_array->last_literal * sizeof(zval)); ZVAL_COPY_VALUE(&op_array->literals[i], zv); @@ -220,7 +220,7 @@ int zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv) return i; } -static inline int zend_optimizer_add_literal_string(zend_op_array *op_array, zend_string *str) { +static inline uint32_t zend_optimizer_add_literal_string(zend_op_array *op_array, zend_string *str) { zval zv; ZVAL_STR(&zv, str); zend_string_hash_val(str); @@ -263,7 +263,7 @@ bool zend_optimizer_update_op1_const(zend_op_array *op_array, switch ((opline-1)->opcode) { case ZEND_ASSIGN_OBJ_REF: case ZEND_ASSIGN_STATIC_PROP_REF: - return 0; + return false; } opline->op1.constant = zend_optimizer_add_literal(op_array, val); break; @@ -271,7 +271,7 @@ bool zend_optimizer_update_op1_const(zend_op_array *op_array, case ZEND_CHECK_VAR: MAKE_NOP(opline); zval_ptr_dtor_nogc(val); - return 1; + return true; case ZEND_SEND_VAR_EX: case ZEND_SEND_FUNC_ARG: case ZEND_FETCH_DIM_W: @@ -286,7 +286,7 @@ bool zend_optimizer_update_op1_const(zend_op_array *op_array, case ZEND_SEPARATE: case ZEND_SEND_VAR_NO_REF: case ZEND_SEND_VAR_NO_REF_EX: - return 0; + return false; case ZEND_CATCH: REQUIRES_STRING(val); drop_leading_backslash(val); @@ -368,10 +368,10 @@ bool zend_optimizer_update_op1_const(zend_op_array *op_array, case ZEND_VERIFY_RETURN_TYPE: /* This would require a non-local change. * zend_optimizer_replace_by_const() supports this. */ - return 0; + return false; case ZEND_COPY_TMP: case ZEND_FETCH_CLASS_NAME: - return 0; + return false; case ZEND_ECHO: { zval zv; @@ -382,7 +382,7 @@ bool zend_optimizer_update_op1_const(zend_op_array *op_array, opline->op1.constant = zend_optimizer_add_literal(op_array, val); if (Z_TYPE_P(val) == IS_STRING && Z_STRLEN_P(val) == 0) { MAKE_NOP(opline); - return 1; + return true; } /* TODO: In a subsequent pass, *after* this step and compacting nops, combine consecutive ZEND_ECHOs using the block information from ssa->cfg */ /* (e.g. for ext/opcache/tests/opt/sccp_010.phpt) */ @@ -412,7 +412,7 @@ bool zend_optimizer_update_op1_const(zend_op_array *op_array, if (Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING) { zend_string_hash_val(Z_STR(ZEND_OP1_LITERAL(opline))); } - return 1; + return true; } bool zend_optimizer_update_op2_const(zend_op_array *op_array, @@ -424,7 +424,7 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array, switch (opline->opcode) { case ZEND_ASSIGN_REF: case ZEND_FAST_CALL: - return 0; + return false; case ZEND_FETCH_CLASS: case ZEND_INSTANCEOF: REQUIRES_STRING(val); @@ -478,13 +478,13 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array, case ZEND_INIT_DYNAMIC_CALL: if (Z_TYPE_P(val) == IS_STRING) { if (zend_memrchr(Z_STRVAL_P(val), ':', Z_STRLEN_P(val))) { - return 0; + return false; } if (zend_optimizer_classify_function(Z_STR_P(val), opline->extended_value)) { /* Dynamic call to various special functions must stay dynamic, * otherwise would drop a warning */ - return 0; + return false; } opline->opcode = ZEND_INIT_FCALL_BY_NAME; @@ -594,7 +594,7 @@ bool zend_optimizer_update_op2_const(zend_op_array *op_array, if (Z_TYPE(ZEND_OP2_LITERAL(opline)) == IS_STRING) { zend_string_hash_val(Z_STR(ZEND_OP2_LITERAL(opline))); } - return 1; + return true; } bool zend_optimizer_replace_by_const(zend_op_array *op_array, @@ -603,7 +603,7 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array, uint32_t var, zval *val) { - zend_op *end = op_array->opcodes + op_array->last; + const zend_op *end = op_array->opcodes + op_array->last; while (opline < end) { if (opline->op1_type == type && @@ -622,7 +622,7 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array, case ZEND_MATCH: case ZEND_MATCH_ERROR: case ZEND_JMP_NULL: { - zend_op *end = op_array->opcodes + op_array->last; + const zend_op *end = op_array->opcodes + op_array->last; while (opline < end) { if (opline->op1_type == type && opline->op1.var == var) { /* If this opcode doesn't keep the operand alive, we're done. Check @@ -641,7 +641,7 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array, Z_TRY_ADDREF_P(val); if (!zend_optimizer_update_op1_const(op_array, opline, val)) { zval_ptr_dtor(val); - return 0; + return false; } if (is_last) { break; @@ -650,13 +650,13 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array, opline++; } zval_ptr_dtor_nogc(val); - return 1; + return true; } case ZEND_VERIFY_RETURN_TYPE: { - zend_arg_info *ret_info = op_array->arg_info - 1; + const zend_arg_info *ret_info = op_array->arg_info - 1; if (!ZEND_TYPE_CONTAINS_CODE(ret_info->type, Z_TYPE_P(val)) || (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE)) { - return 0; + return false; } MAKE_NOP(opline); @@ -681,11 +681,11 @@ bool zend_optimizer_replace_by_const(zend_op_array *op_array, opline++; } - return 1; + return true; } /* Update jump offsets after a jump was migrated to another opline */ -void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, zend_op *opline) { +void zend_optimizer_migrate_jump(const zend_op_array *op_array, zend_op *new_opline, zend_op *opline) { switch (new_opline->opcode) { case ZEND_JMP: case ZEND_FAST_CALL: @@ -718,7 +718,7 @@ void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, z case ZEND_SWITCH_STRING: case ZEND_MATCH: { - HashTable *jumptable = Z_ARRVAL(ZEND_OP2_LITERAL(opline)); + const HashTable *jumptable = Z_ARRVAL(ZEND_OP2_LITERAL(opline)); zval *zv; ZEND_HASH_FOREACH_VAL(jumptable, zv) { Z_LVAL_P(zv) = ZEND_OPLINE_NUM_TO_OFFSET(op_array, new_opline, ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, Z_LVAL_P(zv))); @@ -730,7 +730,7 @@ void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, z } /* Shift jump offsets based on shiftlist */ -void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_t *shiftlist) { +void zend_optimizer_shift_jump(const zend_op_array *op_array, zend_op *opline, const uint32_t *shiftlist) { switch (opline->opcode) { case ZEND_JMP: case ZEND_FAST_CALL: @@ -763,7 +763,7 @@ void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_ case ZEND_SWITCH_STRING: case ZEND_MATCH: { - HashTable *jumptable = Z_ARRVAL(ZEND_OP2_LITERAL(opline)); + const HashTable *jumptable = Z_ARRVAL(ZEND_OP2_LITERAL(opline)); zval *zv; ZEND_HASH_FOREACH_VAL(jumptable, zv) { Z_LVAL_P(zv) = ZEND_OPLINE_NUM_TO_OFFSET(op_array, opline, ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, Z_LVAL_P(zv)) - shiftlist[ZEND_OFFSET_TO_OPLINE_NUM(op_array, opline, Z_LVAL_P(zv))]); @@ -774,12 +774,12 @@ void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_ } } -static bool zend_optimizer_ignore_class(zval *ce_zv, zend_string *filename) +static bool zend_optimizer_ignore_class(zval *ce_zv, const zend_string *filename) { - zend_class_entry *ce = Z_PTR_P(ce_zv); + const zend_class_entry *ce = Z_PTR_P(ce_zv); if (ce->ce_flags & ZEND_ACC_PRELOADED) { - Bucket *ce_bucket = (Bucket*)((uintptr_t)ce_zv - XtOffsetOf(Bucket, val)); + const Bucket *ce_bucket = (const Bucket*)((uintptr_t)ce_zv - XtOffsetOf(Bucket, val)); size_t offset = ce_bucket - EG(class_table)->arData; if (offset < EG(persistent_classes_count)) { return false; @@ -789,15 +789,15 @@ static bool zend_optimizer_ignore_class(zval *ce_zv, zend_string *filename) && (!ce->info.user.filename || ce->info.user.filename != filename); } -static bool zend_optimizer_ignore_function(zval *fbc_zv, zend_string *filename) +static bool zend_optimizer_ignore_function(zval *fbc_zv, const zend_string *filename) { - zend_function *fbc = Z_PTR_P(fbc_zv); + const zend_function *fbc = Z_PTR_P(fbc_zv); if (fbc->type == ZEND_INTERNAL_FUNCTION) { return false; } else if (fbc->type == ZEND_USER_FUNCTION) { if (fbc->op_array.fn_flags & ZEND_ACC_PRELOADED) { - Bucket *fbc_bucket = (Bucket*)((uintptr_t)fbc_zv - XtOffsetOf(Bucket, val)); + const Bucket *fbc_bucket = (const Bucket*)((uintptr_t)fbc_zv - XtOffsetOf(Bucket, val)); size_t offset = fbc_bucket - EG(function_table)->arData; if (offset < EG(persistent_functions_count)) { return false; @@ -832,7 +832,7 @@ zend_class_entry *zend_optimizer_get_class_entry( zend_class_entry *zend_optimizer_get_class_entry_from_op1( const zend_script *script, const zend_op_array *op_array, const zend_op *opline) { if (opline->op1_type == IS_CONST) { - zval *op1 = CRT_CONSTANT(opline->op1); + const zval *op1 = CRT_CONSTANT(opline->op1); if (Z_TYPE_P(op1) == IS_STRING) { return zend_optimizer_get_class_entry(script, op_array, Z_STR_P(op1 + 1)); } @@ -855,7 +855,7 @@ const zend_class_constant *zend_fetch_class_const_info( return NULL; } if (opline->op1_type == IS_CONST) { - zval *op1 = CRT_CONSTANT(opline->op1); + const zval *op1 = CRT_CONSTANT(opline->op1); if (Z_TYPE_P(op1) == IS_STRING) { if (script) { ce = zend_optimizer_get_class_entry(script, op_array, Z_STR_P(op1 + 1)); @@ -869,7 +869,7 @@ const zend_class_constant *zend_fetch_class_const_info( } else if (opline->op1_type == IS_UNUSED && op_array->scope && !(op_array->scope->ce_flags & ZEND_ACC_TRAIT) && !(op_array->fn_flags & ZEND_ACC_TRAIT_CLONE)) { - int fetch_type = opline->op1.num & ZEND_FETCH_CLASS_MASK; + uint32_t fetch_type = opline->op1.num & ZEND_FETCH_CLASS_MASK; if (fetch_type == ZEND_FETCH_CLASS_SELF) { ce = op_array->scope; } else if (fetch_type == ZEND_FETCH_CLASS_STATIC) { @@ -899,9 +899,9 @@ const zend_class_constant *zend_fetch_class_const_info( } zend_function *zend_optimizer_get_called_func( - zend_script *script, zend_op_array *op_array, zend_op *opline, bool *is_prototype) + const zend_script *script, const zend_op_array *op_array, zend_op *opline, bool *is_prototype) { - *is_prototype = 0; + *is_prototype = false; switch (opline->opcode) { case ZEND_INIT_FCALL: { @@ -920,7 +920,7 @@ zend_function *zend_optimizer_get_called_func( case ZEND_INIT_FCALL_BY_NAME: case ZEND_INIT_NS_FCALL_BY_NAME: if (opline->op2_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_STRING) { - zval *function_name = CRT_CONSTANT(opline->op2) + 1; + const zval *function_name = CRT_CONSTANT(opline->op2) + 1; zend_function *func; zval *func_zv; if (script && (func = zend_hash_find_ptr(&script->function_table, Z_STR_P(function_name)))) { @@ -934,7 +934,7 @@ zend_function *zend_optimizer_get_called_func( break; case ZEND_INIT_STATIC_METHOD_CALL: if (opline->op2_type == IS_CONST && Z_TYPE_P(CRT_CONSTANT(opline->op2)) == IS_STRING) { - zend_class_entry *ce = zend_optimizer_get_class_entry_from_op1( + const zend_class_entry *ce = zend_optimizer_get_class_entry_from_op1( script, op_array, opline); if (ce) { zend_string *func_name = Z_STR_P(CRT_CONSTANT(opline->op2) + 1); @@ -978,13 +978,13 @@ zend_function *zend_optimizer_get_called_func( } break; case ZEND_INIT_PARENT_PROPERTY_HOOK_CALL: { - zend_class_entry *scope = op_array->scope; + const zend_class_entry *scope = op_array->scope; ZEND_ASSERT(scope != NULL); if ((scope->ce_flags & ZEND_ACC_LINKED) && scope->parent) { - zend_class_entry *parent_scope = scope->parent; + const zend_class_entry *parent_scope = scope->parent; zend_string *prop_name = Z_STR_P(CRT_CONSTANT(opline->op1)); zend_property_hook_kind hook_kind = opline->op2.num; - zend_property_info *prop_info = zend_get_property_info(parent_scope, prop_name, /* silent */ true); + const zend_property_info *prop_info = zend_get_property_info(parent_scope, prop_name, /* silent */ true); if (prop_info && prop_info != ZEND_WRONG_PROPERTY_INFO @@ -1001,7 +1001,7 @@ zend_function *zend_optimizer_get_called_func( } case ZEND_NEW: { - zend_class_entry *ce = zend_optimizer_get_class_entry_from_op1( + const zend_class_entry *ce = zend_optimizer_get_class_entry_from_op1( script, op_array, opline); if (ce && ce->type == ZEND_USER_CLASS) { return ce->constructor; @@ -1012,7 +1012,7 @@ zend_function *zend_optimizer_get_called_func( return NULL; } -uint32_t zend_optimizer_classify_function(zend_string *name, uint32_t num_args) { +uint32_t zend_optimizer_classify_function(const zend_string *name, uint32_t num_args) { if (zend_string_equals_literal(name, "extract")) { return ZEND_FUNC_INDIRECT_VAR_ACCESS; } else if (zend_string_equals_literal(name, "compact")) { @@ -1164,12 +1164,12 @@ static void zend_optimize(zend_op_array *op_array, static void zend_revert_pass_two(zend_op_array *op_array) { - zend_op *opline, *end; + zend_op *opline; ZEND_ASSERT((op_array->fn_flags & ZEND_ACC_DONE_PASS_TWO) != 0); opline = op_array->opcodes; - end = opline + op_array->last; + const zend_op *end = opline + op_array->last; while (opline < end) { if (opline->op1_type == IS_CONST) { ZEND_PASS_TWO_UNDO_CONSTANT(op_array, opline, opline->op1); @@ -1302,7 +1302,7 @@ static void zend_redo_pass_two(zend_op_array *op_array) op_array->fn_flags |= ZEND_ACC_DONE_PASS_TWO; } -static void zend_redo_pass_two_ex(zend_op_array *op_array, zend_ssa *ssa) +static void zend_redo_pass_two_ex(zend_op_array *op_array, const zend_ssa *ssa) { zend_op *opline, *end; #if ZEND_USE_ABS_JMP_ADDR && !ZEND_USE_ABS_CONST_ADDR @@ -1331,7 +1331,7 @@ static void zend_redo_pass_two_ex(zend_op_array *op_array, zend_ssa *ssa) opline = op_array->opcodes; end = opline + op_array->last; while (opline < end) { - zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes]; + const zend_ssa_op *ssa_op = &ssa->ops[opline - op_array->opcodes]; uint32_t op1_info = opline->op1_type == IS_UNUSED ? 0 : (OP1_INFO() & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_KEY_ANY)); uint32_t op2_info = opline->op1_type == IS_UNUSED ? 0 : (OP2_INFO() & (MAY_BE_UNDEF|MAY_BE_ANY|MAY_BE_REF|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_KEY_ANY)); uint32_t res_info = @@ -1461,13 +1461,13 @@ static void zend_optimize_op_array(zend_op_array *op_array, } } -static void zend_adjust_fcall_stack_size(zend_op_array *op_array, zend_optimizer_ctx *ctx) +static void zend_adjust_fcall_stack_size(const zend_op_array *op_array, const zend_optimizer_ctx *ctx) { zend_function *func; - zend_op *opline, *end; + zend_op *opline; opline = op_array->opcodes; - end = opline + op_array->last; + const zend_op* end = opline + op_array->last; while (opline < end) { if (opline->opcode == ZEND_INIT_FCALL) { func = zend_hash_find_ptr( @@ -1481,12 +1481,12 @@ static void zend_adjust_fcall_stack_size(zend_op_array *op_array, zend_optimizer } } -static void zend_adjust_fcall_stack_size_graph(zend_op_array *op_array) +static void zend_adjust_fcall_stack_size_graph(const zend_op_array *op_array) { - zend_func_info *func_info = ZEND_FUNC_INFO(op_array); + const zend_func_info *func_info = ZEND_FUNC_INFO(op_array); if (func_info) { - zend_call_info *call_info =func_info->callee_info; + const zend_call_info *call_info =func_info->callee_info; while (call_info) { zend_op *opline = call_info->caller_init_opline; @@ -1500,13 +1500,13 @@ static void zend_adjust_fcall_stack_size_graph(zend_op_array *op_array) } } -static bool needs_live_range(zend_op_array *op_array, zend_op *def_opline) { - zend_func_info *func_info = ZEND_FUNC_INFO(op_array); - zend_ssa_op *ssa_op = &func_info->ssa.ops[def_opline - op_array->opcodes]; +static bool needs_live_range(const zend_op_array *op_array, const zend_op *def_opline) { + const zend_func_info *func_info = ZEND_FUNC_INFO(op_array); + const zend_ssa_op *ssa_op = &func_info->ssa.ops[def_opline - op_array->opcodes]; int ssa_var = ssa_op->result_def; if (ssa_var < 0) { /* Be conservative. */ - return 1; + return true; } /* If the variable is used by a PHI, this may be the assignment of the final branch of a @@ -1543,7 +1543,7 @@ void zend_foreach_op_array(zend_script *script, zend_op_array_func_t func, void if (Z_TYPE_P(zv) == IS_ALIAS_PTR) { continue; } - zend_class_entry *ce = Z_CE_P(zv); + const zend_class_entry *ce = Z_CE_P(zv); ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, op_array) { if (op_array->scope == ce && op_array->type == ZEND_USER_FUNCTION @@ -1558,7 +1558,7 @@ void zend_foreach_op_array(zend_script *script, zend_op_array_func_t func, void zend_function **hooks = property->hooks; if (property->ce == ce && property->hooks) { for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) { - zend_function *hook = hooks[i]; + const zend_function *hook = hooks[i]; if (hook && hook->common.scope == ce && !(hooks[i]->op_array.fn_flags & ZEND_ACC_TRAIT_CLONE)) { zend_foreach_op_array_helper(&hooks[i]->op_array, func, context); } @@ -1609,7 +1609,7 @@ ZEND_API void zend_optimize_script(zend_script *script, zend_long optimization_l zend_call_graph call_graph; zend_build_call_graph(&ctx.arena, script, &call_graph); - int i; + uint32_t i; zend_func_info *func_info; for (i = 0; i < call_graph.op_arrays_count; i++) { @@ -1718,20 +1718,22 @@ ZEND_API void zend_optimize_script(zend_script *script, zend_long optimization_l if (Z_TYPE_P(zv) == IS_ALIAS_PTR) { continue; } - zend_class_entry *ce = Z_CE_P(zv); + const zend_class_entry *ce = Z_CE_P(zv); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&ce->function_table, name, op_array) { if (op_array->scope != ce && op_array->type == ZEND_USER_FUNCTION) { - zend_op_array *orig_op_array = + const zend_op_array *orig_op_array = zend_hash_find_ptr(&op_array->scope->function_table, name); ZEND_ASSERT(orig_op_array != NULL); if (orig_op_array != op_array) { uint32_t fn_flags = op_array->fn_flags; + uint32_t fn_flags2 = op_array->fn_flags2; zend_function *prototype = op_array->prototype; HashTable *ht = op_array->static_variables; *op_array = *orig_op_array; op_array->fn_flags = fn_flags; + op_array->fn_flags2 = fn_flags2; op_array->prototype = prototype; op_array->static_variables = ht; } diff --git a/Zend/Optimizer/zend_optimizer_internal.h b/Zend/Optimizer/zend_optimizer_internal.h index 896fe8fb47289..869275811e3da 100644 --- a/Zend/Optimizer/zend_optimizer_internal.h +++ b/Zend/Optimizer/zend_optimizer_internal.h @@ -78,17 +78,17 @@ static inline bool zend_optimizer_is_loop_var_free(const zend_op *opline) { || (opline->opcode == ZEND_FREE && opline->extended_value == ZEND_FREE_SWITCH); } -void zend_optimizer_convert_to_free_op1(zend_op_array *op_array, zend_op *opline); -int zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv); -bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, int copy); -void zend_optimizer_collect_constant(zend_optimizer_ctx *ctx, zval *name, zval* value); -bool zend_optimizer_get_collected_constant(HashTable *constants, zval *name, zval* value); +void zend_optimizer_convert_to_free_op1(const zend_op_array *op_array, zend_op *opline); +uint32_t zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv); +bool zend_optimizer_get_persistent_constant(zend_string *name, zval *result, bool copy); +void zend_optimizer_collect_constant(zend_optimizer_ctx *ctx, const zval *name, zval* value); +bool zend_optimizer_get_collected_constant(const HashTable *constants, const zval *name, zval* value); zend_result zend_optimizer_eval_binary_op(zval *result, uint8_t opcode, zval *op1, zval *op2); zend_result zend_optimizer_eval_unary_op(zval *result, uint8_t opcode, zval *op1); zend_result zend_optimizer_eval_cast(zval *result, uint32_t type, zval *op1); zend_result zend_optimizer_eval_strlen(zval *result, const zval *op1); zend_result zend_optimizer_eval_special_func_call( - zval *result, zend_string *name, zend_string *arg); + zval *result, const zend_string *name, zend_string *arg); bool zend_optimizer_update_op1_const(zend_op_array *op_array, zend_op *opline, zval *val); @@ -120,11 +120,11 @@ void zend_optimizer_nop_removal(zend_op_array *op_array, zend_optimizer_ctx *ctx void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx *ctx); void zend_optimizer_compact_vars(zend_op_array *op_array); zend_function *zend_optimizer_get_called_func( - zend_script *script, zend_op_array *op_array, zend_op *opline, bool *is_prototype); -uint32_t zend_optimizer_classify_function(zend_string *name, uint32_t num_args); -void zend_optimizer_migrate_jump(zend_op_array *op_array, zend_op *new_opline, zend_op *opline); -void zend_optimizer_shift_jump(zend_op_array *op_array, zend_op *opline, uint32_t *shiftlist); -int sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_array, zend_ssa *ssa, zend_call_info **call_map); + const zend_script *script, const zend_op_array *op_array, zend_op *opline, bool *is_prototype); +uint32_t zend_optimizer_classify_function(const zend_string *name, uint32_t num_args); +void zend_optimizer_migrate_jump(const zend_op_array *op_array, zend_op *new_opline, zend_op *opline); +void zend_optimizer_shift_jump(const zend_op_array *op_array, zend_op *opline, const uint32_t *shiftlist); +uint32_t sccp_optimize_op_array(zend_optimizer_ctx *ctx, zend_op_array *op_array, zend_ssa *ssa, zend_call_info **call_map); int dce_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *optimizer_ctx, zend_ssa *ssa, bool reorder_dtor_effects); zend_result zend_ssa_escape_analysis(const zend_script *script, zend_op_array *op_array, zend_ssa *ssa); diff --git a/Zend/Optimizer/zend_ssa.c b/Zend/Optimizer/zend_ssa.c index 886bb467b444f..99978da9d7e80 100644 --- a/Zend/Optimizer/zend_ssa.c +++ b/Zend/Optimizer/zend_ssa.c @@ -52,10 +52,10 @@ static bool will_rejoin( /* The other successor dominates this predecessor, * so we will get the original value from it. */ if (dominates(cfg->blocks, other_successor, predecessor)) { - return 1; + return true; } } - return 0; + return false; } static bool needs_pi(const zend_op_array *op_array, const zend_dfg *dfg, const zend_ssa *ssa, int from, int to, int var) /* {{{ */ @@ -65,7 +65,7 @@ static bool needs_pi(const zend_op_array *op_array, const zend_dfg *dfg, const z if (!DFG_ISSET(dfg->in, dfg->size, to, var)) { /* Variable is not live, certainly won't benefit from pi */ - return 0; + return false; } /* Make sure that both successors of the from block aren't the same. Pi nodes are associated @@ -73,13 +73,13 @@ static bool needs_pi(const zend_op_array *op_array, const zend_dfg *dfg, const z from_block = &ssa->cfg.blocks[from]; ZEND_ASSERT(from_block->successors_count == 2); if (from_block->successors[0] == from_block->successors[1]) { - return 0; + return false; } to_block = &ssa->cfg.blocks[to]; if (to_block->predecessors_count == 1) { /* Always place pi if one predecessor (an if branch) */ - return 1; + return true; } /* Check whether we will rejoin with the original value coming from the other successor, @@ -91,7 +91,7 @@ static bool needs_pi(const zend_op_array *op_array, const zend_dfg *dfg, const z /* }}} */ static zend_ssa_phi *add_pi( - zend_arena **arena, const zend_op_array *op_array, zend_dfg *dfg, zend_ssa *ssa, + zend_arena **arena, const zend_op_array *op_array, const zend_dfg *dfg, const zend_ssa *ssa, int from, int to, int var) /* {{{ */ { zend_ssa_phi *phi; @@ -131,7 +131,7 @@ static zend_ssa_phi *add_pi( static void pi_range( zend_ssa_phi *phi, int min_var, int max_var, zend_long min, zend_long max, - char underflow, char overflow, char negative) /* {{{ */ + bool underflow, bool overflow, bool negative) /* {{{ */ { zend_ssa_range_constraint *constraint = &phi->constraint.range; constraint->min_var = min_var; @@ -148,16 +148,16 @@ static void pi_range( /* }}} */ static inline void pi_range_equals(zend_ssa_phi *phi, int var, zend_long val) { - pi_range(phi, var, var, val, val, 0, 0, 0); + pi_range(phi, var, var, val, val, false, false, false); } static inline void pi_range_not_equals(zend_ssa_phi *phi, int var, zend_long val) { - pi_range(phi, var, var, val, val, 0, 0, 1); + pi_range(phi, var, var, val, val, false, false, true); } static inline void pi_range_min(zend_ssa_phi *phi, int var, zend_long val) { - pi_range(phi, var, -1, val, ZEND_LONG_MAX, 0, 1, 0); + pi_range(phi, var, -1, val, ZEND_LONG_MAX, false, true, false); } static inline void pi_range_max(zend_ssa_phi *phi, int var, zend_long val) { - pi_range(phi, -1, var, ZEND_LONG_MIN, val, 1, 0, 0); + pi_range(phi, -1, var, ZEND_LONG_MIN, val, true, false, false); } static void pi_type_mask(zend_ssa_phi *phi, uint32_t type_mask) { @@ -241,8 +241,8 @@ static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_f */ static void place_essa_pis( zend_arena **arena, const zend_script *script, const zend_op_array *op_array, - uint32_t build_flags, zend_ssa *ssa, zend_dfg *dfg) /* {{{ */ { - zend_basic_block *blocks = ssa->cfg.blocks; + uint32_t build_flags, const zend_ssa *ssa, const zend_dfg *dfg) /* {{{ */ { + const zend_basic_block *blocks = ssa->cfg.blocks; int j, blocks_count = ssa->cfg.blocks_count; for (j = 0; j < blocks_count; j++) { zend_ssa_phi *pi; @@ -819,12 +819,12 @@ ZEND_API int zend_ssa_rename_op(const zend_op_array *op_array, const zend_op *op static void zend_ssa_rename_in_block(const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa, int *var, int n) /* {{{ */ { - zend_basic_block *blocks = ssa->cfg.blocks; - zend_ssa_block *ssa_blocks = ssa->blocks; + const zend_basic_block *blocks = ssa->cfg.blocks; + const zend_ssa_block *ssa_blocks = ssa->blocks; zend_ssa_op *ssa_ops = ssa->ops; int ssa_vars_count = ssa->vars_count; int i, j; - zend_op *opline, *end; + const zend_op *opline, *end; if (ssa_blocks[n].phis) { zend_ssa_phi *phi = ssa_blocks[n].phis; @@ -849,7 +849,7 @@ static void zend_ssa_rename_in_block(const zend_op_array *op_array, uint32_t bui } } - zend_ssa_op *fe_fetch_ssa_op = blocks[n].len != 0 + const zend_ssa_op *fe_fetch_ssa_op = blocks[n].len != 0 && ((end-1)->opcode == ZEND_FE_FETCH_R || (end-1)->opcode == ZEND_FE_FETCH_RW) && (end-1)->op2_type == IS_CV ? &ssa_ops[blocks[n].start + blocks[n].len - 1] : NULL; @@ -995,7 +995,7 @@ backtrack:; ZEND_API zend_result zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa) /* {{{ */ { - zend_basic_block *blocks = ssa->cfg.blocks; + const zend_basic_block *blocks = ssa->cfg.blocks; zend_ssa_block *ssa_blocks; int blocks_count = ssa->cfg.blocks_count; uint32_t set_size; @@ -1259,7 +1259,7 @@ ZEND_API void zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_ } /* }}} */ -void zend_ssa_unlink_use_chain(zend_ssa *ssa, int op, int var) /* {{{ */ +void zend_ssa_unlink_use_chain(const zend_ssa *ssa, int op, int var) /* {{{ */ { if (ssa->vars[var].use_chain == op) { ssa->vars[var].use_chain = zend_ssa_next_use(ssa->ops, var, op); @@ -1298,7 +1298,7 @@ void zend_ssa_unlink_use_chain(zend_ssa *ssa, int op, int var) /* {{{ */ } /* }}} */ -void zend_ssa_replace_use_chain(zend_ssa *ssa, int op, int new_op, int var) /* {{{ */ +void zend_ssa_replace_use_chain(const zend_ssa *ssa, int op, int new_op, int var) /* {{{ */ { if (ssa->vars[var].use_chain == op) { ssa->vars[var].use_chain = new_op; @@ -1338,7 +1338,7 @@ void zend_ssa_replace_use_chain(zend_ssa *ssa, int op, int new_op, int var) /* { } /* }}} */ -void zend_ssa_remove_instr(zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op) /* {{{ */ +void zend_ssa_remove_instr(const zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op) /* {{{ */ { if (ssa_op->result_use >= 0) { zend_ssa_unlink_use_chain(ssa, ssa_op - ssa->ops, ssa_op->result_use); @@ -1369,7 +1369,7 @@ void zend_ssa_remove_instr(zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op) } /* }}} */ -static inline zend_ssa_phi **zend_ssa_next_use_phi_ptr(zend_ssa *ssa, int var, zend_ssa_phi *p) /* {{{ */ +static inline zend_ssa_phi **zend_ssa_next_use_phi_ptr(const zend_ssa *ssa, int var, zend_ssa_phi *p) /* {{{ */ { if (p->pi >= 0) { return &p->use_chains[0]; @@ -1388,7 +1388,7 @@ static inline zend_ssa_phi **zend_ssa_next_use_phi_ptr(zend_ssa *ssa, int var, z /* May be called even if source is not used in the phi (useful when removing uses in a phi * with multiple identical operands) */ -static inline void zend_ssa_remove_use_of_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int source, zend_ssa_phi *next_use_phi) /* {{{ */ +static inline void zend_ssa_remove_use_of_phi_source(const zend_ssa *ssa, const zend_ssa_phi *phi, int source, zend_ssa_phi *next_use_phi) /* {{{ */ { zend_ssa_phi **cur = &ssa->vars[source].phi_use_chain; while (*cur && *cur != phi) { @@ -1400,7 +1400,7 @@ static inline void zend_ssa_remove_use_of_phi_source(zend_ssa *ssa, zend_ssa_phi } /* }}} */ -static void zend_ssa_remove_uses_of_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ +static void zend_ssa_remove_uses_of_phi_sources(const zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ { int source; FOREACH_PHI_SOURCE(phi, source) { @@ -1409,7 +1409,7 @@ static void zend_ssa_remove_uses_of_phi_sources(zend_ssa *ssa, zend_ssa_phi *phi } /* }}} */ -static void zend_ssa_remove_phi_from_block(zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ +static void zend_ssa_remove_phi_from_block(const zend_ssa *ssa, const zend_ssa_phi *phi) /* {{{ */ { zend_ssa_block *block = &ssa->blocks[phi->block]; zend_ssa_phi **cur = &block->phis; @@ -1438,7 +1438,7 @@ void zend_ssa_remove_defs_of_instr(zend_ssa *ssa, zend_ssa_op *ssa_op) /* {{{ */ } /* }}} */ -static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, int pred_offset, int predecessors_count) /* {{{ */ +static inline void zend_ssa_remove_phi_source(const zend_ssa *ssa, const zend_ssa_phi *phi, int pred_offset, int predecessors_count) /* {{{ */ { int j, var_num = phi->sources[pred_offset]; zend_ssa_phi *next_phi = phi->use_chains[pred_offset]; @@ -1467,7 +1467,7 @@ static inline void zend_ssa_remove_phi_source(zend_ssa *ssa, zend_ssa_phi *phi, } /* }}} */ -void zend_ssa_remove_phi(zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ +void zend_ssa_remove_phi(const zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ { ZEND_ASSERT(phi->ssa_var >= 0); ZEND_ASSERT(ssa->vars[phi->ssa_var].use_chain < 0 @@ -1479,7 +1479,7 @@ void zend_ssa_remove_phi(zend_ssa *ssa, zend_ssa_phi *phi) /* {{{ */ } /* }}} */ -void zend_ssa_remove_uses_of_var(zend_ssa *ssa, int var_num) /* {{{ */ +void zend_ssa_remove_uses_of_var(const zend_ssa *ssa, int var_num) /* {{{ */ { zend_ssa_var *var = &ssa->vars[var_num]; zend_ssa_phi *phi; @@ -1515,7 +1515,7 @@ void zend_ssa_remove_uses_of_var(zend_ssa *ssa, int var_num) /* {{{ */ void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to) /* {{{ */ { zend_basic_block *next_block = &ssa->cfg.blocks[to]; - zend_ssa_block *next_ssa_block = &ssa->blocks[to]; + const zend_ssa_block *next_ssa_block = &ssa->blocks[to]; zend_ssa_phi *phi; int j; @@ -1540,7 +1540,7 @@ void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to) /* {{{ */ for (phi = next_ssa_block->phis; phi; phi = phi->next) { if (phi->pi >= 0) { if (phi->pi == from) { - zend_ssa_rename_var_uses(ssa, phi->ssa_var, phi->sources[0], /* update_types */ 0); + zend_ssa_rename_var_uses(ssa, phi->ssa_var, phi->sources[0], /* update_types */ false); zend_ssa_remove_phi(ssa, phi); } } else { @@ -1558,10 +1558,10 @@ void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to) /* {{{ */ } /* }}} */ -void zend_ssa_remove_block(zend_op_array *op_array, zend_ssa *ssa, int i) /* {{{ */ +void zend_ssa_remove_block(const zend_op_array *op_array, zend_ssa *ssa, int i) /* {{{ */ { zend_basic_block *block = &ssa->cfg.blocks[i]; - zend_ssa_block *ssa_block = &ssa->blocks[i]; + const zend_ssa_block *ssa_block = &ssa->blocks[i]; zend_ssa_phi *phi; int j; @@ -1671,15 +1671,15 @@ void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, bool update_types /* If the op already uses the new var, don't add the op to the use * list again. Instead move the use_chain to the correct operand. */ - bool add_to_use_chain = 1; + bool add_to_use_chain = true; if (ssa_op->result_use == new) { - add_to_use_chain = 0; + add_to_use_chain = false; } else if (ssa_op->op1_use == new) { if (ssa_op->result_use == old) { ssa_op->res_use_chain = ssa_op->op1_use_chain; ssa_op->op1_use_chain = -1; } - add_to_use_chain = 0; + add_to_use_chain = false; } else if (ssa_op->op2_use == new) { if (ssa_op->result_use == old) { ssa_op->res_use_chain = ssa_op->op2_use_chain; @@ -1688,7 +1688,7 @@ void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, bool update_types ssa_op->op1_use_chain = ssa_op->op2_use_chain; ssa_op->op2_use_chain = -1; } - add_to_use_chain = 0; + add_to_use_chain = false; } /* Perform the actual renaming */ @@ -1723,7 +1723,7 @@ void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, bool update_types /* Update phi use chains */ FOREACH_PHI_USE(old_var, phi) { int j; - bool after_first_new_source = 0; + bool after_first_new_source = false; /* If the phi already uses the new var, find its use chain, as we may * need to move it to a different source operand. */ @@ -1737,7 +1737,7 @@ void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, bool update_types for (j = 0; j < ssa->cfg.blocks[phi->block].predecessors_count; j++) { if (phi->sources[j] == new) { - after_first_new_source = 1; + after_first_new_source = true; } else if (phi->sources[j] == old) { phi->sources[j] = new; @@ -1751,7 +1751,7 @@ void zend_ssa_rename_var_uses(zend_ssa *ssa, int old, int new, bool update_types phi->use_chains[j] = new_var->phi_use_chain; new_var->phi_use_chain = phi; } - after_first_new_source = 1; + after_first_new_source = true; } else { phi->use_chains[j] = NULL; } diff --git a/Zend/Optimizer/zend_ssa.h b/Zend/Optimizer/zend_ssa.h index 5995adcb14986..0696d2bba8671 100644 --- a/Zend/Optimizer/zend_ssa.h +++ b/Zend/Optimizer/zend_ssa.h @@ -147,15 +147,15 @@ BEGIN_EXTERN_C() ZEND_API zend_result zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_array *op_array, uint32_t build_flags, zend_ssa *ssa); ZEND_API void zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_array, zend_ssa *ssa); ZEND_API int zend_ssa_rename_op(const zend_op_array *op_array, const zend_op *opline, uint32_t k, uint32_t build_flags, int ssa_vars_count, zend_ssa_op *ssa_ops, int *var); -void zend_ssa_unlink_use_chain(zend_ssa *ssa, int op, int var); -void zend_ssa_replace_use_chain(zend_ssa *ssa, int op, int new_op, int var); +void zend_ssa_unlink_use_chain(const zend_ssa *ssa, int op, int var); +void zend_ssa_replace_use_chain(const zend_ssa *ssa, int op, int new_op, int var); void zend_ssa_remove_predecessor(zend_ssa *ssa, int from, int to); void zend_ssa_remove_defs_of_instr(zend_ssa *ssa, zend_ssa_op *ssa_op); -void zend_ssa_remove_instr(zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op); -void zend_ssa_remove_phi(zend_ssa *ssa, zend_ssa_phi *phi); -void zend_ssa_remove_uses_of_var(zend_ssa *ssa, int var_num); -void zend_ssa_remove_block(zend_op_array *op_array, zend_ssa *ssa, int b); +void zend_ssa_remove_instr(const zend_ssa *ssa, zend_op *opline, zend_ssa_op *ssa_op); +void zend_ssa_remove_phi(const zend_ssa *ssa, zend_ssa_phi *phi); +void zend_ssa_remove_uses_of_var(const zend_ssa *ssa, int var_num); +void zend_ssa_remove_block(const zend_op_array *op_array, zend_ssa *ssa, int b); void zend_ssa_rename_var_uses(zend_ssa *ssa, int old_var, int new_var, bool update_types); void zend_ssa_remove_block_from_cfg(zend_ssa *ssa, int b); @@ -240,21 +240,21 @@ static zend_always_inline void zend_ssa_rename_defs_of_instr(zend_ssa *ssa, zend /* Rename def to use if possible. Mark variable as not defined otherwise. */ if (ssa_op->op1_def >= 0) { if (ssa_op->op1_use >= 0) { - zend_ssa_rename_var_uses(ssa, ssa_op->op1_def, ssa_op->op1_use, 1); + zend_ssa_rename_var_uses(ssa, ssa_op->op1_def, ssa_op->op1_use, true); } ssa->vars[ssa_op->op1_def].definition = -1; ssa_op->op1_def = -1; } if (ssa_op->op2_def >= 0) { if (ssa_op->op2_use >= 0) { - zend_ssa_rename_var_uses(ssa, ssa_op->op2_def, ssa_op->op2_use, 1); + zend_ssa_rename_var_uses(ssa, ssa_op->op2_def, ssa_op->op2_use, true); } ssa->vars[ssa_op->op2_def].definition = -1; ssa_op->op2_def = -1; } if (ssa_op->result_def >= 0) { if (ssa_op->result_use >= 0) { - zend_ssa_rename_var_uses(ssa, ssa_op->result_def, ssa_op->result_use, 1); + zend_ssa_rename_var_uses(ssa, ssa_op->result_def, ssa_op->result_use, true); } ssa->vars[ssa_op->result_def].definition = -1; ssa_op->result_def = -1; diff --git a/Zend/Optimizer/zend_worklist.h b/Zend/Optimizer/zend_worklist.h index f47d01bd1579b..85e7b111d5c94 100644 --- a/Zend/Optimizer/zend_worklist.h +++ b/Zend/Optimizer/zend_worklist.h @@ -97,12 +97,12 @@ static inline bool zend_worklist_push(zend_worklist *worklist, int i) ZEND_ASSERT(i >= 0 && i < worklist->stack.capacity); if (zend_bitset_in(worklist->visited, i)) { - return 0; + return false; } zend_bitset_incl(worklist->visited, i); zend_worklist_stack_push(&worklist->stack, i); - return 1; + return true; } static inline int zend_worklist_peek(const zend_worklist *worklist) diff --git a/Zend/tests/asymmetric_visibility/virtual_get_only.phpt b/Zend/tests/asymmetric_visibility/virtual_get_only.phpt index 3eaada70329d4..a3f6f980bdfe3 100644 --- a/Zend/tests/asymmetric_visibility/virtual_get_only.phpt +++ b/Zend/tests/asymmetric_visibility/virtual_get_only.phpt @@ -11,4 +11,4 @@ class Foo { ?> --EXPECTF-- -Fatal error: Read-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d +Fatal error: get-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d diff --git a/Zend/tests/asymmetric_visibility/virtual_set_only.phpt b/Zend/tests/asymmetric_visibility/virtual_set_only.phpt index 18abb7ac046a4..7d1d2bc7cb99f 100644 --- a/Zend/tests/asymmetric_visibility/virtual_set_only.phpt +++ b/Zend/tests/asymmetric_visibility/virtual_set_only.phpt @@ -11,4 +11,4 @@ class Foo { ?> --EXPECTF-- -Fatal error: Write-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d +Fatal error: set-only virtual property Foo::$bar must not specify asymmetric visibility in %s on line %d diff --git a/Zend/tests/closures/fcc-cache.phpt b/Zend/tests/closures/fcc-cache.phpt new file mode 100644 index 0000000000000..3b47a2410d143 --- /dev/null +++ b/Zend/tests/closures/fcc-cache.phpt @@ -0,0 +1,8 @@ +--TEST-- +FCCs are cached and shared +--FILE-- + +--EXPECT-- +bool(true) diff --git a/Zend/tests/closures/gh19653_3.phpt b/Zend/tests/closures/gh19653_3.phpt new file mode 100644 index 0000000000000..7a9ac589182c3 --- /dev/null +++ b/Zend/tests/closures/gh19653_3.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-19653 (Closure named argument unpacking between temporary closures can cause a crash) - temporary method variation +--EXTENSIONS-- +zend_test +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Error: Unknown named parameter $tmpMethodParamName in %s:%d +Stack trace: +#0 %s(%d): usage1(Object(Closure)) +#1 {main} + thrown in %s on line %d diff --git a/Zend/tests/exit/exit_as_function.phpt b/Zend/tests/exit/exit_as_function.phpt index fb95b9f288171..726cf1f0d7a94 100644 --- a/Zend/tests/exit/exit_as_function.phpt +++ b/Zend/tests/exit/exit_as_function.phpt @@ -19,10 +19,10 @@ foreach ($values as $value) { } ?> ---EXPECT-- +--EXPECTF-- string(4) "exit" string(3) "die" -object(Closure)#1 (2) { +object(Closure)#%d (2) { ["function"]=> string(4) "exit" ["parameter"]=> @@ -31,7 +31,7 @@ object(Closure)#1 (2) { string(10) "" } } -object(Closure)#2 (2) { +object(Closure)#%d (2) { ["function"]=> string(4) "exit" ["parameter"]=> diff --git a/Zend/tests/first_class_callable/constexpr/namespace_004.phpt b/Zend/tests/first_class_callable/constexpr/namespace_004.phpt index 0fc23422199d5..6fe99593bf95d 100644 --- a/Zend/tests/first_class_callable/constexpr/namespace_004.phpt +++ b/Zend/tests/first_class_callable/constexpr/namespace_004.phpt @@ -26,7 +26,7 @@ foo(); ?> --EXPECTF-- -object(Closure)#1 (2) { +object(Closure)#%d (2) { ["function"]=> string(6) "strrev" ["parameter"]=> @@ -36,7 +36,7 @@ object(Closure)#1 (2) { } } string(3) "cba" -object(Closure)#2 (2) { +object(Closure)#%d (2) { ["function"]=> string(6) "strrev" ["parameter"]=> @@ -46,7 +46,7 @@ object(Closure)#2 (2) { } } string(3) "cba" -object(Closure)#2 (2) { +object(Closure)#%d (2) { ["function"]=> string(6) "strrev" ["parameter"]=> @@ -56,7 +56,7 @@ object(Closure)#2 (2) { } } string(3) "cba" -object(Closure)#1 (2) { +object(Closure)#%d (2) { ["function"]=> string(6) "strrev" ["parameter"]=> diff --git a/Zend/tests/first_class_callable/first_class_callable_optimization.phpt b/Zend/tests/first_class_callable/first_class_callable_optimization.phpt index 707b6a7299a4a..169f6dfd62cc2 100644 --- a/Zend/tests/first_class_callable/first_class_callable_optimization.phpt +++ b/Zend/tests/first_class_callable/first_class_callable_optimization.phpt @@ -10,12 +10,12 @@ var_dump(test1(...)); var_dump(test2(...)); ?> ---EXPECT-- -object(Closure)#1 (1) { +--EXPECTF-- +object(Closure)#%d (1) { ["function"]=> string(5) "test1" } -object(Closure)#1 (1) { +object(Closure)#%d (1) { ["function"]=> string(5) "test2" } diff --git a/Zend/tests/functions/zend_call_function_deprecated_frame.phpt b/Zend/tests/functions/zend_call_function_deprecated_frame.phpt new file mode 100644 index 0000000000000..ce2943a876e2b --- /dev/null +++ b/Zend/tests/functions/zend_call_function_deprecated_frame.phpt @@ -0,0 +1,25 @@ +--TEST-- +Deprecated function notice promoted to exception within zend_call_function() +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Exception: Function foo() is deprecated in %s:%d +Stack trace: +#0 [internal function]: {closure:%s:%d}(16384, 'Function foo() ...', '%s', %d) +#1 %s(%d): array_map(Object(Closure), Array) +#2 {main} + thrown in %s on line %d diff --git a/Zend/tests/gh20714.phpt b/Zend/tests/gh20714.phpt new file mode 100644 index 0000000000000..10ffde555f896 --- /dev/null +++ b/Zend/tests/gh20714.phpt @@ -0,0 +1,29 @@ +--TEST-- +GH-20714: Uncatchable exception thrown in generator +--CREDITS-- +Grégoire Paris (greg0ire) +--FILE-- + +--EXPECT-- +Caught diff --git a/Zend/tests/inheritance/argument_restriction_001.phpt b/Zend/tests/inheritance/argument_restriction_001.phpt index 2c54636a58178..6eb3ff8d27062 100644 --- a/Zend/tests/inheritance/argument_restriction_001.phpt +++ b/Zend/tests/inheritance/argument_restriction_001.phpt @@ -13,4 +13,4 @@ class Sub extends Base { } ?> --EXPECTF-- -Fatal error: Declaration of & Sub::test() must be compatible with & Base::test($foo, array $bar, $option = null, $extra = 'llllllllll...') in %s on line %d +Fatal error: Declaration of &Sub::test() must be compatible with &Base::test($foo, array $bar, $option = null, $extra = 'llllllllll...') in %s on line %d diff --git a/Zend/tests/magic_methods/trampoline_closure_named_arguments.phpt b/Zend/tests/magic_methods/trampoline_closure_named_arguments.phpt index e4ccaf16e63a6..3be14f6145ace 100644 --- a/Zend/tests/magic_methods/trampoline_closure_named_arguments.phpt +++ b/Zend/tests/magic_methods/trampoline_closure_named_arguments.phpt @@ -42,7 +42,7 @@ var_dump($type); var_dump($type->getName()); ?> ---EXPECT-- +--EXPECTF-- -- Non-static cases -- string(4) "test" array(3) { @@ -69,7 +69,7 @@ array(4) { ["a"]=> int(123) ["b"]=> - object(Test)#1 (0) { + object(Test)#%d (0) { } } string(4) "test" @@ -77,7 +77,7 @@ array(2) { ["a"]=> int(123) ["b"]=> - object(Test)#1 (0) { + object(Test)#%d (0) { } } string(4) "test" @@ -114,7 +114,7 @@ array(4) { ["a"]=> int(123) ["b"]=> - object(Test)#1 (0) { + object(Test)#%d (0) { } } string(10) "testStatic" @@ -122,7 +122,7 @@ array(2) { ["a"]=> int(123) ["b"]=> - object(Test)#1 (0) { + object(Test)#%d (0) { } } string(10) "testStatic" @@ -136,12 +136,12 @@ array(1) { -- Reflection tests -- array(1) { [0]=> - object(ReflectionParameter)#4 (1) { + object(ReflectionParameter)#%d (1) { ["name"]=> string(9) "arguments" } } bool(true) -object(ReflectionNamedType)#5 (0) { +object(ReflectionNamedType)#%d (0) { } string(5) "mixed" diff --git a/Zend/tests/objects/objects_005.phpt b/Zend/tests/objects/objects_005.phpt index 9b9a41465f95b..7749a39d986fb 100644 --- a/Zend/tests/objects/objects_005.phpt +++ b/Zend/tests/objects/objects_005.phpt @@ -19,4 +19,4 @@ class test3 extends test { ?> --EXPECTF-- -Fatal error: Declaration of test3::foo() must be compatible with & test::foo() in %s on line %d +Fatal error: Declaration of test3::foo() must be compatible with &test::foo() in %s on line %d diff --git a/Zend/tests/oss-fuzz-465488618.phpt b/Zend/tests/oss-fuzz-465488618.phpt new file mode 100644 index 0000000000000..517c481b33e0a --- /dev/null +++ b/Zend/tests/oss-fuzz-465488618.phpt @@ -0,0 +1,16 @@ +--TEST-- +OSS-Fuzz #465488618: Dump function signature with dynamic class const lookup default argument +--FILE-- + +--EXPECTF-- +Fatal error: Declaration of B::test(string $x = ) must be compatible with A::test(int $x) in %s on line %d diff --git a/Zend/tests/oss_fuzz_454273637.phpt b/Zend/tests/oss_fuzz_454273637.phpt new file mode 100644 index 0000000000000..fbcdb57ed2a16 --- /dev/null +++ b/Zend/tests/oss_fuzz_454273637.phpt @@ -0,0 +1,8 @@ +--TEST-- +OSS-Fuzz #454273637 (UAF with printf optimization and const output) +--FILE-- + +--EXPECT-- +% diff --git a/Zend/tests/property_hooks/bug001.phpt b/Zend/tests/property_hooks/bug001.phpt index 5328506d476cb..62291019b3338 100644 --- a/Zend/tests/property_hooks/bug001.phpt +++ b/Zend/tests/property_hooks/bug001.phpt @@ -27,4 +27,4 @@ try { ?> --EXPECT-- bool(true) -Property C::$x is read-only +Cannot write to get-only virtual property C::$x diff --git a/Zend/tests/property_hooks/bug008.phpt b/Zend/tests/property_hooks/bug008.phpt index 9c321cfe16e14..38fe709a38a3f 100644 --- a/Zend/tests/property_hooks/bug008.phpt +++ b/Zend/tests/property_hooks/bug008.phpt @@ -18,7 +18,7 @@ $foo->bar = 'bar'; ?> --EXPECTF-- -Fatal error: Uncaught Error: Property Foo::$bar is read-only in %s:%d +Fatal error: Uncaught Error: Cannot write to get-only virtual property Foo::$bar in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/Zend/tests/property_hooks/get.phpt b/Zend/tests/property_hooks/get.phpt index 0cb0a6b7c76be..6d4b005843eaf 100644 --- a/Zend/tests/property_hooks/get.phpt +++ b/Zend/tests/property_hooks/get.phpt @@ -21,4 +21,4 @@ try { ?> --EXPECT-- int(42) -Property Test::$prop is read-only +Cannot write to get-only virtual property Test::$prop diff --git a/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt b/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt index 84eb968263546..2c507d862be6f 100644 --- a/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt +++ b/Zend/tests/property_hooks/get_by_ref_implemented_by_val.phpt @@ -15,4 +15,4 @@ class A implements I { ?> --EXPECTF-- -Fatal error: Declaration of A::$prop::get() must be compatible with & I::$prop::get() in %s on line %d +Fatal error: Declaration of A::$prop::get() must be compatible with &I::$prop::get() in %s on line %d diff --git a/Zend/tests/property_hooks/override_add_get.phpt b/Zend/tests/property_hooks/override_add_get.phpt index 28dbd047c0718..df2739e6086c3 100644 --- a/Zend/tests/property_hooks/override_add_get.phpt +++ b/Zend/tests/property_hooks/override_add_get.phpt @@ -31,7 +31,7 @@ var_dump($b->prop); ?> --EXPECT-- A::A::$prop::set -Property A::$prop is write-only +Cannot read from set-only virtual property A::$prop B::B::$prop::set B::B::$prop::get int(42) diff --git a/Zend/tests/property_hooks/override_add_set.phpt b/Zend/tests/property_hooks/override_add_set.phpt index 6b490d4d87f94..e13de15f0b822 100644 --- a/Zend/tests/property_hooks/override_add_set.phpt +++ b/Zend/tests/property_hooks/override_add_set.phpt @@ -30,7 +30,7 @@ var_dump($b->prop); ?> --EXPECT-- -Property A::$prop is read-only +Cannot write to get-only virtual property A::$prop A::A::$prop::get int(42) B::B::$prop::set diff --git a/Zend/tests/property_hooks/set.phpt b/Zend/tests/property_hooks/set.phpt index 04e36ae85411f..2928aee6cedee 100644 --- a/Zend/tests/property_hooks/set.phpt +++ b/Zend/tests/property_hooks/set.phpt @@ -28,5 +28,5 @@ try { ?> --EXPECT-- int(42) -Property Test::$prop is write-only -Property Test::$prop is write-only +Cannot read from set-only virtual property Test::$prop +Cannot read from set-only virtual property Test::$prop diff --git a/Zend/tests/property_hooks/type_compatibility.phpt b/Zend/tests/property_hooks/type_compatibility.phpt index 8bfb7b0cadd59..def1fc77dc9ce 100644 --- a/Zend/tests/property_hooks/type_compatibility.phpt +++ b/Zend/tests/property_hooks/type_compatibility.phpt @@ -1,5 +1,5 @@ --TEST-- -Relaxed type compatibility for read-only and write-only properties +Relaxed type compatibility for get-only and set-only properties --FILE-- testTmpMethodWithArgInfo(null); + +echo new ReflectionFunction($o->testTmpMethodWithArgInfo(...)); + +?> +--EXPECT-- +Closure [ public method testTmpMethodWithArgInfo ] { + + - Parameters [2] { + Parameter #0 [ Foo|Bar|null $tmpMethodParamName = null ] + Parameter #1 [ string $tmpMethodParamWithStringDefaultValue = "tmpMethodParamWithStringDefaultValue" ] + } +} diff --git a/Zend/tests/weakrefs/weakmap_by_ref_dimension_assign.phpt b/Zend/tests/weakrefs/weakmap_by_ref_dimension_assign.phpt new file mode 100644 index 0000000000000..6444de7eea6ba --- /dev/null +++ b/Zend/tests/weakrefs/weakmap_by_ref_dimension_assign.phpt @@ -0,0 +1,13 @@ +--TEST-- +By-ref assign of WeakMap dimension +--FILE-- + +--EXPECT-- +int(1) diff --git a/Zend/zend.c b/Zend/zend.c index 045d25134f8c9..c46c8e9ada86c 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -38,6 +38,8 @@ #include "zend_call_stack.h" #include "zend_max_execution_timer.h" #include "zend_hrtime.h" +#include "zend_enum.h" +#include "zend_closures.h" #include "Optimizer/zend_optimizer.h" #include "php.h" #include "php_globals.h" @@ -553,7 +555,7 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /* } GC_PROTECT_RECURSION(Z_ARRVAL_P(expr)); } - print_hash(buf, Z_ARRVAL_P(expr), indent, 0); + print_hash(buf, Z_ARRVAL_P(expr), indent, false); GC_TRY_UNPROTECT_RECURSION(Z_ARRVAL_P(expr)); break; case IS_OBJECT: @@ -583,12 +585,12 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /* } if ((properties = zend_get_properties_for(expr, ZEND_PROP_PURPOSE_DEBUG)) == NULL) { - print_hash(buf, (HashTable*) &zend_empty_array, indent, 1); + print_hash(buf, (HashTable*) &zend_empty_array, indent, true); break; } ZEND_GUARD_OR_GC_PROTECT_RECURSION(guard, DEBUG, zobj); - print_hash(buf, properties, indent, 1); + print_hash(buf, properties, indent, true); ZEND_GUARD_OR_GC_UNPROTECT_RECURSION(guard, DEBUG, zobj); zend_release_properties(properties); @@ -641,7 +643,7 @@ static FILE *zend_fopen_wrapper(zend_string *filename, zend_string **opened_path /* }}} */ #ifdef ZTS -static bool short_tags_default = 1; +static bool short_tags_default = true; static uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT; #else # define short_tags_default 1 @@ -817,7 +819,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{ executor_globals->saved_fpu_cw = 0; #endif executor_globals->saved_fpu_cw_ptr = NULL; - executor_globals->active = 0; + executor_globals->active = false; executor_globals->bailout = NULL; executor_globals->error_handling = EH_NORMAL; executor_globals->exception_class = NULL; @@ -910,7 +912,7 @@ static bool php_auto_globals_create_globals(zend_string *name) /* {{{ */ { /* While we keep registering $GLOBALS as an auto-global, we do not create an * actual variable for it. Access to it handled specially by the compiler. */ - return 0; + return false; } /* }}} */ @@ -1026,7 +1028,7 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */ executor_globals = ts_resource(executor_globals_id); compiler_globals_dtor(compiler_globals); - compiler_globals->in_compilation = 0; + compiler_globals->in_compilation = false; compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable)); compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable)); @@ -1054,6 +1056,7 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */ ZVAL_UNDEF(&EG(last_fatal_error_backtrace)); zend_interned_strings_init(); + zend_object_handlers_startup(); zend_startup_builtin_functions(); zend_register_standard_constants(); zend_register_auto_global(zend_string_init_interned("GLOBALS", sizeof("GLOBALS") - 1, 1), 1, php_auto_globals_create_globals); @@ -1077,6 +1080,9 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */ tsrm_set_new_thread_end_handler(zend_new_thread_end_handler); tsrm_set_shutdown_handler(zend_interned_strings_dtor); #endif + + zend_enum_startup(); + zend_closure_startup(); } /* }}} */ @@ -1501,12 +1507,10 @@ ZEND_API ZEND_COLD void zend_error_zstr_at( /* Report about uncaught exception in case of fatal errors */ if (EG(exception)) { - zend_execute_data *ex; - const zend_op *opline; - if (type & E_FATAL_ERRORS) { - ex = EG(current_execute_data); - opline = NULL; + zend_execute_data *ex = EG(current_execute_data); + const zend_op *opline = NULL; + while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { ex = ex->prev_execute_data; } diff --git a/Zend/zend.h b/Zend/zend.h index e2e500022a85e..8957241ccfb37 100644 --- a/Zend/zend.h +++ b/Zend/zend.h @@ -20,7 +20,7 @@ #ifndef ZEND_H #define ZEND_H -#define ZEND_VERSION "4.5.1-dev" +#define ZEND_VERSION "4.6.0-dev" #define ZEND_ENGINE_3 @@ -152,11 +152,12 @@ struct _zend_class_entry { zend_class_entry *parent; zend_string *parent_name; }; - int refcount; + uint32_t refcount; uint32_t ce_flags; + uint32_t ce_flags2; int default_properties_count; - int default_static_members_count; + uint32_t default_static_members_count; zval *default_properties_table; zval *default_static_members_table; ZEND_MAP_PTR_DEF(zval *, static_members_table); @@ -441,7 +442,7 @@ typedef struct { BEGIN_EXTERN_C() ZEND_API void zend_save_error_handling(zend_error_handling *current); ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current); -ZEND_API void zend_restore_error_handling(zend_error_handling *saved); +ZEND_API void zend_restore_error_handling(const zend_error_handling *saved); ZEND_API void zend_begin_record_errors(void); ZEND_API void zend_emit_recorded_errors(void); ZEND_API void zend_emit_recorded_errors_ex(uint32_t num_errors, zend_error_info **errors); diff --git a/Zend/zend_API.c b/Zend/zend_API.c index b5c8b7a1dd490..0881a169dfa7d 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -20,6 +20,7 @@ */ #include "zend.h" +#include "zend_compile.h" #include "zend_execute.h" #include "zend_API.h" #include "zend_hash.h" @@ -76,28 +77,6 @@ ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *ar } /* }}} */ -ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array) /* {{{ */ -{ - zval *param_ptr; - uint32_t arg_count; - - param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1); - arg_count = ZEND_CALL_NUM_ARGS(EG(current_execute_data)); - - if (param_count>arg_count) { - return FAILURE; - } - - while (param_count-->0) { - Z_TRY_ADDREF_P(param_ptr); - zend_hash_next_index_insert_new(Z_ARRVAL_P(argument_array), param_ptr); - param_ptr++; - } - - return SUCCESS; -} -/* }}} */ - ZEND_API ZEND_COLD void zend_wrong_param_count(void) /* {{{ */ { const char *space; @@ -107,7 +86,7 @@ ZEND_API ZEND_COLD void zend_wrong_param_count(void) /* {{{ */ } /* }}} */ -ZEND_API ZEND_COLD void zend_wrong_property_read(zval *object, zval *property) +ZEND_API ZEND_COLD void zend_wrong_property_read(const zval *object, zval *property) { zend_string *tmp_property_name; zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name); @@ -247,7 +226,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, uint32_t num, char *name, zend_expected_type expected_type, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, uint32_t num, char *name, zend_expected_type expected_type, const zval *arg) /* {{{ */ { switch (error_code) { case ZPP_ERROR_WRONG_CALLBACK: @@ -288,7 +267,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(uint32_t num, zend_expected_type expected_type, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(uint32_t num, zend_expected_type expected_type, const zval *arg) /* {{{ */ { static const char * const expected_error[] = { Z_EXPECTED_TYPES(Z_EXPECTED_TYPE_STR) @@ -309,7 +288,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(uint32_t n } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(uint32_t num, const char *name, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(uint32_t num, const char *name, const zval *arg) /* {{{ */ { if (EG(exception)) { return; @@ -319,7 +298,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(uint32_t } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error(uint32_t num, const char *name, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error(uint32_t num, const char *name, const zval *arg) /* {{{ */ { if (EG(exception)) { return; @@ -329,7 +308,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error(u } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_error(uint32_t num, const char *name, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_error(uint32_t num, const char *name, const zval *arg) /* {{{ */ { if (EG(exception)) { return; @@ -339,7 +318,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_error(u } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null_error(uint32_t num, const char *name, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null_error(uint32_t num, const char *name, const zval *arg) /* {{{ */ { if (EG(exception)) { return; @@ -349,7 +328,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error(uint32_t num, const char *name, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error(uint32_t num, const char *name, const zval *arg) /* {{{ */ { if (EG(exception)) { return; @@ -359,7 +338,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error } /* }}} */ -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_null_error(uint32_t num, const char *name, zval *arg) /* {{{ */ +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_null_error(uint32_t num, const char *name, const zval *arg) /* {{{ */ { if (EG(exception)) { return; @@ -452,7 +431,7 @@ ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num) zend_argument_value_error(arg_num, "must not be empty"); } -ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string *new_name, zend_class_entry *old_ce) +ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string *new_name, const zend_class_entry *old_ce) { if (old_ce->type == ZEND_INTERNAL_CLASS) { zend_error(type, "Cannot redeclare %s %s", @@ -467,7 +446,7 @@ ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string } } -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(int type, const zend_class_entry *old_ce) { zend_class_redeclaration_error_ex(type, old_ce->name, old_ce); } @@ -502,7 +481,7 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **p /* }}} */ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32_t arg_num) { - zend_function *func = zend_active_function(); + const zend_function *func = zend_active_function(); ZEND_ASSERT(arg_num > 0); uint32_t arg_offset = arg_num - 1; if (arg_offset >= func->common.num_args) { @@ -510,7 +489,7 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32 arg_offset = func->common.num_args; } - zend_arg_info *arg_info = &func->common.arg_info[arg_offset]; + const zend_arg_info *arg_info = &func->common.arg_info[arg_offset]; zend_string *func_name = get_active_function_or_method_name(); const char *arg_name = get_active_function_arg_name(arg_num); @@ -614,9 +593,6 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, zend_long return 0; } } - if (UNEXPECTED(EG(exception))) { - return 0; - } } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) { if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("int", arg_num)) { return 0; @@ -663,9 +639,6 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, double * return 0; } } - if (UNEXPECTED(EG(exception))) { - return 0; - } } else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) { if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("float", arg_num)) { return 0; @@ -818,8 +791,8 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec { const char *spec_walk = *spec; char c = *spec_walk++; - bool check_null = 0; - bool separate = 0; + bool check_null = false; + bool separate = false; zval *real_arg = arg; /* scan through modifiers */ @@ -828,9 +801,9 @@ static const char *zend_parse_arg_impl(zval *arg, va_list *va, const char **spec if (*spec_walk == '/') { SEPARATE_ZVAL_NOREF(arg); real_arg = arg; - separate = 1; + separate = true; } else if (*spec_walk == '!') { - check_null = 1; + check_null = true; } else { break; } @@ -1140,7 +1113,7 @@ ZEND_API zend_result zend_parse_parameter(int flags, uint32_t arg_num, zval *arg } static ZEND_COLD void zend_parse_parameters_debug_error(const char *msg) { - zend_function *active_function = EG(current_execute_data)->func; + const zend_function *active_function = EG(current_execute_data)->func; const char *class_name = active_function->common.scope ? ZSTR_VAL(active_function->common.scope->name) : ""; zend_error_noreturn(E_CORE_ERROR, "%s%s%s(): %s", @@ -1157,8 +1130,8 @@ static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, uint32_t max_num_args = 0; uint32_t post_varargs = 0; zval *arg; - bool have_varargs = 0; - bool have_optional_args = 0; + bool have_varargs = false; + bool have_optional_args = false; zval **varargs = NULL; uint32_t *n_varargs = NULL; @@ -1180,7 +1153,7 @@ static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, case '|': min_num_args = max_num_args; - have_optional_args = 1; + have_optional_args = true; break; case '/': @@ -1195,7 +1168,7 @@ static zend_result zend_parse_va_args(uint32_t num_args, const char *type_spec, "only one varargs specifier (* or +) is permitted"); return FAILURE; } - have_varargs = 1; + have_varargs = true; /* we expect at least one parameter in varargs */ if (c == '+') { max_num_args++; @@ -1396,7 +1369,7 @@ ZEND_API zend_result zend_parse_method_parameters_ex(int flags, uint32_t num_arg /* This function should be called after the constructor has been called * because it may call __set from the uninitialized object otherwise. */ -ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ +ZEND_API void zend_merge_properties(const zval *obj, const HashTable *properties) /* {{{ */ { zend_object *zobj = Z_OBJ_P(obj); zend_object_write_property_t write_property = zobj->handlers->write_property; @@ -1418,7 +1391,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties) /* {{{ */ } /* }}} */ -static zend_class_mutable_data *zend_allocate_mutable_data(zend_class_entry *class_type) /* {{{ */ +static zend_class_mutable_data *zend_allocate_mutable_data(const zend_class_entry *class_type) /* {{{ */ { zend_class_mutable_data *mutable_data; @@ -1434,7 +1407,7 @@ static zend_class_mutable_data *zend_allocate_mutable_data(zend_class_entry *cla } /* }}} */ -ZEND_API HashTable *zend_separate_class_constants_table(zend_class_entry *class_type) /* {{{ */ +ZEND_API HashTable *zend_separate_class_constants_table(const zend_class_entry *class_type) /* {{{ */ { zend_class_mutable_data *mutable_data; HashTable *constants_table; @@ -1474,7 +1447,7 @@ ZEND_API HashTable *zend_separate_class_constants_table(zend_class_entry *class_ return constants_table; } -static zend_result update_property(zval *val, zend_property_info *prop_info) { +static zend_result update_property(zval *val, const zend_property_info *prop_info) { if (ZEND_TYPE_IS_SET(prop_info->type)) { zval tmp; @@ -1709,10 +1682,9 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti if (object->ce->default_properties_count) { zval *prop; zend_string *key; - zend_property_info *property_info; ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(properties, key, prop) { - property_info = zend_get_property_info(object->ce, key, 1); + const zend_property_info *property_info = zend_get_property_info(object->ce, key, 1); if (property_info != ZEND_WRONG_PROPERTY_INFO && property_info && (property_info->flags & ZEND_ACC_STATIC) == 0) { @@ -1736,12 +1708,12 @@ ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properti } /* }}} */ -ZEND_API void object_properties_load(zend_object *object, HashTable *properties) /* {{{ */ +ZEND_API void object_properties_load(zend_object *object, const HashTable *properties) /* {{{ */ { zval *prop, tmp; zend_string *key; zend_long h; - zend_property_info *property_info; + const zend_property_info *property_info; ZEND_HASH_FOREACH_KEY_VAL(properties, h, key, prop) { if (key) { @@ -2792,7 +2764,7 @@ static void zend_check_magic_method_no_return_type( } } -ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, zend_string *lcname, int error_type) /* {{{ */ +ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, const zend_function *fptr, const zend_string *lcname, int error_type) /* {{{ */ { if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') { @@ -2889,7 +2861,7 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce, } /* }}} */ -ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, zend_string *lcname) +ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, const zend_string *lcname) { if (ZSTR_VAL(lcname)[0] != '_' || ZSTR_VAL(lcname)[1] != '_') { /* pass */ @@ -2956,6 +2928,80 @@ static zend_always_inline void zend_normalize_internal_type(zend_type *type) { } ZEND_TYPE_FOREACH_END(); } +static void zend_convert_internal_arg_info_type(zend_type *type, bool persistent) +{ + if (ZEND_TYPE_HAS_LITERAL_NAME(*type)) { + // gen_stubs.php does not support codegen for compound types. As a + // temporary workaround, we support union types by splitting + // the type name on `|` characters if necessary. + const char *class_name = ZEND_TYPE_LITERAL_NAME(*type); + type->type_mask &= ~_ZEND_TYPE_LITERAL_NAME_BIT; + + size_t num_types = 1; + const char *p = class_name; + while ((p = strchr(p, '|'))) { + num_types++; + p++; + } + + if (num_types == 1) { + /* Simple class type */ + zend_string *str = zend_string_init_interned(class_name, strlen(class_name), persistent); + zend_alloc_ce_cache(str); + ZEND_TYPE_SET_PTR(*type, str); + type->type_mask |= _ZEND_TYPE_NAME_BIT; + } else { + /* Union type */ + zend_type_list *list = pemalloc(ZEND_TYPE_LIST_SIZE(num_types), persistent); + list->num_types = num_types; + ZEND_TYPE_SET_LIST(*type, list); + ZEND_TYPE_FULL_MASK(*type) |= _ZEND_TYPE_UNION_BIT; + + const char *start = class_name; + uint32_t j = 0; + while (true) { + const char *end = strchr(start, '|'); + zend_string *str = zend_string_init_interned(start, end ? end - start : strlen(start), persistent); + zend_alloc_ce_cache(str); + list->types[j] = (zend_type) ZEND_TYPE_INIT_CLASS(str, 0, 0); + if (!end) { + break; + } + start = end + 1; + j++; + } + } + } + if (ZEND_TYPE_IS_ITERABLE_FALLBACK(*type)) { + /* Warning generated an extension load warning which is emitted for every test + zend_error(E_CORE_WARNING, "iterable type is now a compile time alias for array|Traversable," + " regenerate the argument info via the php-src gen_stub build script"); + */ + zend_type legacy_iterable = ZEND_TYPE_INIT_CLASS_MASK( + ZSTR_KNOWN(ZEND_STR_TRAVERSABLE), + (type->type_mask | MAY_BE_ARRAY) + ); + *type = legacy_iterable; + } +} + +ZEND_API void zend_convert_internal_arg_info(zend_arg_info *new_arg_info, const zend_internal_arg_info *arg_info, bool is_return_info, bool persistent) +{ + if (!is_return_info) { + new_arg_info->name = zend_string_init_interned(arg_info->name, strlen(arg_info->name), persistent); + if (arg_info->default_value) { + new_arg_info->default_value = zend_string_init_interned(arg_info->default_value, strlen(arg_info->default_value), persistent); + } else { + new_arg_info->default_value = NULL; + } + } else { + new_arg_info->name = NULL; + new_arg_info->default_value = NULL; + } + new_arg_info->type = arg_info->type; + zend_convert_internal_arg_info_type(&new_arg_info->type, persistent); +} + /* registers all functions in *library_functions in the function hash */ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend_function_entry *functions, HashTable *function_table, int type) /* {{{ */ { @@ -2967,6 +3013,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend int error_type; zend_string *lowercase_name; size_t fname_len; + const zend_internal_arg_info *internal_arg_info; if (type==MODULE_PERSISTENT) { error_type = E_CORE_WARNING; @@ -3023,7 +3070,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend if (ptr->arg_info) { zend_internal_function_info *info = (zend_internal_function_info*)ptr->arg_info; - internal_function->arg_info = (zend_internal_arg_info*)ptr->arg_info+1; + internal_arg_info = ptr->arg_info+1; internal_function->num_args = ptr->num_args; /* Currently you cannot denote that the function can accept less arguments than num_args */ if (info->required_num_args == (uintptr_t)-1) { @@ -3053,7 +3100,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend zend_error(E_CORE_WARNING, "Missing arginfo for %s%s%s()", scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname); - internal_function->arg_info = NULL; + internal_arg_info = NULL; internal_function->num_args = 0; internal_function->required_num_args = 0; } @@ -3064,13 +3111,11 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend !(internal_function->fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) { zend_error(E_CORE_WARNING, "%s::__toString() implemented without string return type", ZSTR_VAL(scope->name)); - internal_function->arg_info = (zend_internal_arg_info *) arg_info_toString + 1; + internal_arg_info = (zend_internal_arg_info *) arg_info_toString + 1; internal_function->fn_flags |= ZEND_ACC_HAS_RETURN_TYPE; internal_function->num_args = internal_function->required_num_args = 0; } - - zend_set_function_arg_flags((zend_function*)internal_function); if (ptr->flags & ZEND_ACC_ABSTRACT) { if (scope) { /* This is a class that must be abstract itself. Here we set the check info. */ @@ -3135,17 +3180,17 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend } /* If types of arguments have to be checked */ - if (reg_function->arg_info && num_args) { + if (internal_arg_info && num_args) { uint32_t i; for (i = 0; i < num_args; i++) { - zend_internal_arg_info *arg_info = ®_function->arg_info[i]; + const zend_internal_arg_info *arg_info = &internal_arg_info[i]; ZEND_ASSERT(arg_info->name && "Parameter must have a name"); if (ZEND_TYPE_IS_SET(arg_info->type)) { reg_function->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS; } #if ZEND_DEBUG for (uint32_t j = 0; j < i; j++) { - if (!strcmp(arg_info->name, reg_function->arg_info[j].name)) { + if (!strcmp(arg_info->name, internal_arg_info[j].name)) { zend_error_noreturn(E_CORE_ERROR, "Duplicate parameter name $%s for function %s%s%s()", arg_info->name, scope ? ZSTR_VAL(scope->name) : "", scope ? "::" : "", ptr->fname); @@ -3155,78 +3200,24 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend } } - /* Rebuild arginfos if parameter/property types and/or a return type are used */ - if (reg_function->arg_info && - (reg_function->fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS))) { - /* convert "const char*" class type names into "zend_string*" */ + /* Convert zend_internal_arg_info to zend_arg_info */ + if (internal_arg_info) { uint32_t i; - zend_internal_arg_info *arg_info = reg_function->arg_info - 1; - zend_internal_arg_info *new_arg_info; + const zend_internal_arg_info *arg_info = internal_arg_info - 1; + zend_arg_info *new_arg_info; /* Treat return type as an extra argument */ num_args++; - new_arg_info = malloc(sizeof(zend_internal_arg_info) * num_args); - memcpy(new_arg_info, arg_info, sizeof(zend_internal_arg_info) * num_args); + new_arg_info = malloc(sizeof(zend_arg_info) * num_args); reg_function->arg_info = new_arg_info + 1; for (i = 0; i < num_args; i++) { - if (ZEND_TYPE_HAS_LITERAL_NAME(new_arg_info[i].type)) { - // gen_stubs.php does not support codegen for DNF types in arg infos. - // As a temporary workaround, we split the type name on `|` characters, - // converting it to an union type if necessary. - const char *class_name = ZEND_TYPE_LITERAL_NAME(new_arg_info[i].type); - new_arg_info[i].type.type_mask &= ~_ZEND_TYPE_LITERAL_NAME_BIT; - - size_t num_types = 1; - const char *p = class_name; - while ((p = strchr(p, '|'))) { - num_types++; - p++; - } - - if (num_types == 1) { - /* Simple class type */ - zend_string *str = zend_string_init_interned(class_name, strlen(class_name), 1); - zend_alloc_ce_cache(str); - ZEND_TYPE_SET_PTR(new_arg_info[i].type, str); - new_arg_info[i].type.type_mask |= _ZEND_TYPE_NAME_BIT; - } else { - /* Union type */ - zend_type_list *list = malloc(ZEND_TYPE_LIST_SIZE(num_types)); - list->num_types = num_types; - ZEND_TYPE_SET_LIST(new_arg_info[i].type, list); - ZEND_TYPE_FULL_MASK(new_arg_info[i].type) |= _ZEND_TYPE_UNION_BIT; - - const char *start = class_name; - uint32_t j = 0; - while (true) { - const char *end = strchr(start, '|'); - zend_string *str = zend_string_init_interned(start, end ? end - start : strlen(start), 1); - zend_alloc_ce_cache(str); - list->types[j] = (zend_type) ZEND_TYPE_INIT_CLASS(str, 0, 0); - if (!end) { - break; - } - start = end + 1; - j++; - } - } - } - if (ZEND_TYPE_IS_ITERABLE_FALLBACK(new_arg_info[i].type)) { - /* Warning generated an extension load warning which is emitted for every test - zend_error(E_CORE_WARNING, "iterable type is now a compile time alias for array|Traversable," - " regenerate the argument info via the php-src gen_stub build script"); - */ - zend_type legacy_iterable = ZEND_TYPE_INIT_CLASS_MASK( - ZSTR_KNOWN(ZEND_STR_TRAVERSABLE), - (new_arg_info[i].type.type_mask | MAY_BE_ARRAY) - ); - new_arg_info[i].type = legacy_iterable; - } - - zend_normalize_internal_type(&new_arg_info[i].type); + zend_convert_internal_arg_info(&new_arg_info[i], &arg_info[i], + i == 0, true); } } + zend_set_function_arg_flags((zend_function*)reg_function); + if (scope) { zend_check_magic_method_implementation( scope, (zend_function *)reg_function, lowercase_name, E_CORE_ERROR); @@ -3306,7 +3297,7 @@ static void clean_module_classes(int module_number) /* {{{ */ /* Child classes may reuse structures from parent classes, so destroy in reverse order. */ Bucket *bucket; ZEND_HASH_REVERSE_FOREACH_BUCKET(EG(class_table), bucket) { - zend_class_entry *ce = Z_CE(bucket->val); + const zend_class_entry *ce = Z_CE(bucket->val); if (ce->type == ZEND_INTERNAL_CLASS && ce->info.internal.module->module_number == module_number) { zend_hash_del_bucket(EG(class_table), bucket); } @@ -3317,8 +3308,8 @@ static void clean_module_classes(int module_number) /* {{{ */ static int clean_module_function(zval *el, void *arg) /* {{{ */ { - zend_function *fe = (zend_function *) Z_PTR_P(el); - zend_module_entry *module = (zend_module_entry *) arg; + const zend_function *fe = (zend_function *) Z_PTR_P(el); + const zend_module_entry *module = arg; if (fe->common.type == ZEND_INTERNAL_FUNCTION && fe->internal_function.module == module) { return ZEND_HASH_APPLY_REMOVE; } else { @@ -3406,7 +3397,7 @@ ZEND_API void zend_activate_modules(void) /* {{{ */ zend_module_entry **p = module_request_startup_handlers; while (*p) { - zend_module_entry *module = *p; + const zend_module_entry *module = *p; if (module->request_startup_func(module->type, module->module_number)==FAILURE) { zend_error(E_WARNING, "request_startup() for %s module failed", module->name); @@ -3435,7 +3426,7 @@ ZEND_API void zend_deactivate_modules(void) /* {{{ */ zend_module_entry **p = module_request_shutdown_handlers; while (*p) { - zend_module_entry *module = *p; + const zend_module_entry *module = *p; zend_try { module->request_shutdown_func(module->type, module->module_number); } zend_end_try(); @@ -3484,7 +3475,7 @@ ZEND_API void zend_post_deactivate_modules(void) /* {{{ */ zend_module_entry **p = module_post_deactivate_handlers; while (*p) { - zend_module_entry *module = *p; + const zend_module_entry *module = *p; module->post_deactivate_func(); p++; @@ -3500,7 +3491,7 @@ ZEND_API int zend_next_free_module(void) /* {{{ */ } /* }}} */ -static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, uint32_t ce_flags) /* {{{ */ +static zend_class_entry *do_register_internal_class(const zend_class_entry *orig_class_entry, uint32_t ce_flags) /* {{{ */ { zend_class_entry *class_entry = malloc(sizeof(zend_class_entry)); zend_string *lowercase_name; @@ -3536,14 +3527,14 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class * If both parent_ce and parent_name are NULL it does a regular class registration * If parent_name is specified but not found NULL is returned */ -ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce) /* {{{ */ +ZEND_API zend_class_entry *zend_register_internal_class_ex(const zend_class_entry *class_entry, zend_class_entry *parent_ce) /* {{{ */ { return zend_register_internal_class_with_flags(class_entry, parent_ce, 0); } /* }}} */ ZEND_API zend_class_entry *zend_register_internal_class_with_flags( - zend_class_entry *class_entry, + const zend_class_entry *class_entry, zend_class_entry *parent_ce, uint32_t ce_flags ) { @@ -3581,13 +3572,13 @@ ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_inter /* A class that contains at least one abstract method automatically becomes an abstract class. */ -ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *orig_class_entry) /* {{{ */ +ZEND_API zend_class_entry *zend_register_internal_class(const zend_class_entry *orig_class_entry) /* {{{ */ { return do_register_internal_class(orig_class_entry, 0); } /* }}} */ -ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry) /* {{{ */ +ZEND_API zend_class_entry *zend_register_internal_interface(const zend_class_entry *orig_class_entry) /* {{{ */ { return do_register_internal_class(orig_class_entry, ZEND_ACC_INTERFACE); } @@ -3600,7 +3591,7 @@ ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_ /* TODO: Move this out of here in 7.4. */ if (persistent && EG(current_module) && EG(current_module)->type == MODULE_TEMPORARY) { - persistent = 0; + persistent = false; } if (name[0] == '\\') { @@ -3634,29 +3625,6 @@ ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_ } /* }}} */ -// TODO num_symbol_tables as unsigned int? -ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, bool is_ref, int num_symbol_tables, ...) /* {{{ */ -{ - HashTable *symbol_table; - va_list symbol_table_list; - - if (num_symbol_tables <= 0) return FAILURE; - - if (is_ref) { - ZVAL_MAKE_REF(symbol); - } - - va_start(symbol_table_list, num_symbol_tables); - while (num_symbol_tables-- > 0) { - symbol_table = va_arg(symbol_table_list, HashTable *); - zend_hash_str_update(symbol_table, name, name_length, symbol); - Z_TRY_ADDREF_P(symbol); - } - va_end(symbol_table_list); - return SUCCESS; -} -/* }}} */ - /* Disabled functions support */ static void zend_disable_function(const char *function_name, size_t function_name_length) @@ -3707,12 +3675,12 @@ ZEND_API void zend_disable_functions(const char *function_list) /* {{{ */ } /* }}} */ -static zend_always_inline zend_class_entry *get_scope(zend_execute_data *frame) +static zend_always_inline zend_class_entry *get_scope(const zend_execute_data *frame) { return frame && frame->func ? frame->func->common.scope : NULL; } -static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error, bool suppress_deprecation) /* {{{ */ +static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *scope, const zend_execute_data *frame, zend_fcall_info_cache *fcc, bool *strict_class, char **error, bool suppress_deprecation) /* {{{ */ { bool ret = false; zend_class_entry *ce; @@ -3723,7 +3691,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc ZSTR_ALLOCA_ALLOC(lcname, name_len, use_heap); zend_str_tolower_copy(ZSTR_VAL(lcname), ZSTR_VAL(name), name_len); - *strict_class = 0; + *strict_class = false; if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_SELF))) { if (!scope) { if (error) *error = estrdup("cannot access \"self\" when no class scope is active"); @@ -3758,7 +3726,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc if (!fcc->object) { fcc->object = zend_get_this_object(frame); } - *strict_class = 1; + *strict_class = true; ret = true; } } else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_STATIC))) { @@ -3775,18 +3743,18 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc if (!fcc->object) { fcc->object = zend_get_this_object(frame); } - *strict_class = 1; + *strict_class = true; ret = true; } } else if ((ce = zend_lookup_class(name)) != NULL) { - zend_class_entry *scope = get_scope(frame); + const zend_class_entry *frame_scope = get_scope(frame); fcc->calling_scope = ce; - if (scope && !fcc->object) { + if (frame_scope && !fcc->object) { zend_object *object = zend_get_this_object(frame); if (object && - instanceof_function(object->ce, scope) && - instanceof_function(scope, ce)) { + instanceof_function(object->ce, frame_scope) && + instanceof_function(frame_scope, ce)) { fcc->object = object; fcc->called_scope = object->ce; } else { @@ -3795,7 +3763,7 @@ static bool zend_is_callable_check_class(zend_string *name, zend_class_entry *sc } else { fcc->called_scope = fcc->object ? fcc->object->ce : ce; } - *strict_class = 1; + *strict_class = true; ret = true; } else { if (error) zend_spprintf(error, 0, "class \"%.*s\" not found", (int)name_len, ZSTR_VAL(name)); @@ -3816,10 +3784,10 @@ ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc) { } } -static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error, bool suppress_deprecation) /* {{{ */ +static zend_always_inline bool zend_is_callable_check_func(const zval *callable, const zend_execute_data *frame, zend_fcall_info_cache *fcc, bool strict_class, char **error, bool suppress_deprecation) /* {{{ */ { zend_class_entry *ce_org = fcc->calling_scope; - bool retval = 0; + bool retval = false; zend_string *mname, *cname; zend_string *lmname; const char *colon; @@ -3901,7 +3869,7 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ } else { fcc->called_scope = fcc->object ? fcc->object->ce : fcc->calling_scope; } - strict_class = 1; + strict_class = true; } else if (!zend_is_callable_check_class(cname, scope, frame, fcc, &strict_class, error, suppress_deprecation || ce_org != NULL)) { zend_string_release_ex(cname, 0); return 0; @@ -3939,11 +3907,11 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ zend_string_equals_literal(lmname, ZEND_CONSTRUCTOR_FUNC_NAME)) { fcc->function_handler = fcc->calling_scope->constructor; if (fcc->function_handler) { - retval = 1; + retval = true; } } else if ((zv = zend_hash_find(ftable, lmname)) != NULL) { fcc->function_handler = Z_PTR_P(zv); - retval = 1; + retval = true; if ((fcc->function_handler->op_array.fn_flags & ZEND_ACC_CHANGED) && !strict_class) { scope = get_scope(frame); @@ -3968,7 +3936,7 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ scope = get_scope(frame); ZEND_ASSERT(!(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC)); if (!zend_check_method_accessible(fcc->function_handler, scope)) { - retval = 0; + retval = false; fcc->function_handler = NULL; goto get_function_via_handler; } @@ -3977,9 +3945,9 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ get_function_via_handler: if (fcc->object && fcc->calling_scope == ce_org) { if (strict_class && ce_org->__call) { - fcc->function_handler = zend_get_call_trampoline_func(ce_org, mname, 0); + fcc->function_handler = zend_get_call_trampoline_func(ce_org->__call, mname); call_via_handler = 1; - retval = 1; + retval = true; } else { fcc->function_handler = fcc->object->handlers->get_method(&fcc->object, mname, NULL); if (fcc->function_handler) { @@ -3988,7 +3956,7 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ !instanceof_function(ce_org, fcc->function_handler->common.scope))) { zend_release_fcall_info_cache(fcc); } else { - retval = 1; + retval = true; call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; } } @@ -4000,7 +3968,7 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ fcc->function_handler = zend_std_get_static_method(fcc->calling_scope, mname, NULL); } if (fcc->function_handler) { - retval = 1; + retval = true; call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; if (call_via_handler && !fcc->object) { zend_object *object = zend_get_this_object(frame); @@ -4016,12 +3984,12 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ if (retval) { if (fcc->calling_scope && !call_via_handler) { if (fcc->function_handler->common.fn_flags & ZEND_ACC_ABSTRACT) { - retval = 0; + retval = false; if (error) { zend_spprintf(error, 0, "cannot call abstract method %s::%s()", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); } } else if (!fcc->object && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) { - retval = 0; + retval = false; if (error) { zend_spprintf(error, 0, "non-static method %s::%s() cannot be called statically", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); } @@ -4037,7 +4005,7 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ } zend_spprintf(error, 0, "cannot access %s method %s::%s()", zend_visibility_string(fcc->function_handler->common.fn_flags), ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); } - retval = 0; + retval = false; } } } @@ -4062,7 +4030,7 @@ static zend_always_inline bool zend_is_callable_check_func(zval *callable, zend_ } /* }}} */ -ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object) /* {{{ */ +ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, const zend_object *object) /* {{{ */ { try_again: switch (Z_TYPE_P(callable)) { @@ -4074,8 +4042,8 @@ ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *obj case IS_ARRAY: { - zval *method = NULL; - zval *obj = NULL; + const zval *method = NULL; + const zval *obj = NULL; if (zend_hash_num_elements(Z_ARRVAL_P(callable)) == 2) { obj = zend_hash_index_find_deref(Z_ARRVAL_P(callable), 0); @@ -4096,7 +4064,7 @@ ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *obj } case IS_OBJECT: { - zend_class_entry *ce = Z_OBJCE_P(callable); + const zend_class_entry *ce = Z_OBJCE_P(callable); if (ce == zend_ce_closure) { const zend_function *fn = zend_get_closure_method_def(Z_OBJ_P(callable)); @@ -4127,12 +4095,12 @@ ZEND_API zend_string *zend_get_callable_name(zval *callable) /* {{{ */ /* }}} */ ZEND_API bool zend_is_callable_at_frame( - zval *callable, zend_object *object, zend_execute_data *frame, + const zval *callable, zend_object *object, const zend_execute_data *frame, uint32_t check_flags, zend_fcall_info_cache *fcc, char **error) /* {{{ */ { bool ret; zend_fcall_info_cache fcc_local; - bool strict_class = 0; + bool strict_class = false; if (fcc == NULL) { fcc = &fcc_local; @@ -4240,7 +4208,7 @@ ZEND_API bool zend_is_callable_at_frame( ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error) /* {{{ */ { /* Determine callability at the first parent user frame. */ - zend_execute_data *frame = EG(current_execute_data); + const zend_execute_data *frame = EG(current_execute_data); while (frame && (!frame->func || !ZEND_USER_CODE(frame->func->type))) { frame = frame->prev_execute_data; } @@ -4258,24 +4226,6 @@ ZEND_API bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string } /* }}} */ -ZEND_API bool zend_make_callable(zval *callable, zend_string **callable_name) /* {{{ */ -{ - zend_fcall_info_cache fcc; - - if (zend_is_callable_ex(callable, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, callable_name, &fcc, NULL)) { - if (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) { - zval_ptr_dtor_str(callable); - array_init(callable); - add_next_index_str(callable, zend_string_copy(fcc.calling_scope->name)); - add_next_index_str(callable, zend_string_copy(fcc.function_handler->common.function_name)); - } - zend_release_fcall_info_cache(&fcc); - return 1; - } - return 0; -} -/* }}} */ - ZEND_API zend_result zend_fcall_info_init(zval *callable, uint32_t check_flags, zend_fcall_info *fci, zend_fcall_info_cache *fcc, zend_string **callable_name, char **error) /* {{{ */ { if (!zend_is_callable_ex(callable, NULL, check_flags, callable_name, fcc, error)) { @@ -4324,7 +4274,7 @@ ZEND_API void zend_fcall_info_args_save(zend_fcall_info *fci, uint32_t *param_co ZEND_API void zend_fcall_info_args_restore(zend_fcall_info *fci, uint32_t param_count, zval *params) /* {{{ */ { - zend_fcall_info_args_clear(fci, 1); + zend_fcall_info_args_clear(fci, true); fci->param_count = param_count; fci->params = params; } @@ -4454,19 +4404,13 @@ ZEND_API void zend_get_callable_zval_from_fcc(const zend_fcall_info_cache *fcc, ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */ { - zend_string *lname; size_t name_len = strlen(module_name); - zend_module_entry *module; - - lname = zend_string_alloc(name_len, 0); - zend_str_tolower_copy(ZSTR_VAL(lname), module_name, name_len); - module = zend_hash_find_ptr(&module_registry, lname); - zend_string_efree(lname); + zend_module_entry *module = zend_hash_str_find_ptr_lc(&module_registry, module_name, name_len); return module ? module->version : NULL; } /* }}} */ -static zend_always_inline bool is_persistent_class(zend_class_entry *ce) { +static zend_always_inline bool is_persistent_class(const zend_class_entry *ce) { return (ce->type & ZEND_INTERNAL_CLASS) && ce->info.internal.module->type == MODULE_PERSISTENT; } @@ -5152,7 +5096,7 @@ ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope } /* }}} */ -ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv) /* {{{ */ +ZEND_API zval *zend_read_property_ex(const zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv) /* {{{ */ { zval *value; const zend_class_entry *old_scope = EG(fake_scope); @@ -5166,7 +5110,7 @@ ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *objec } /* }}} */ -ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv) /* {{{ */ +ZEND_API zval *zend_read_property(const zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv) /* {{{ */ { zval *value; zend_string *str; @@ -5218,7 +5162,7 @@ ZEND_API void zend_replace_error_handling(zend_error_handling_t error_handling, } /* }}} */ -ZEND_API void zend_restore_error_handling(zend_error_handling *saved) /* {{{ */ +ZEND_API void zend_restore_error_handling(const zend_error_handling *saved) /* {{{ */ { EG(error_handling) = saved->handling; EG(exception_class) = saved->exception; @@ -5318,48 +5262,43 @@ static zend_string *try_parse_string(const char *str, size_t len, char quote) { } ZEND_API zend_result zend_get_default_from_internal_arg_info( - zval *default_value_zval, zend_internal_arg_info *arg_info) + zval *default_value_zval, const zend_arg_info *arg_info) { - const char *default_value = arg_info->default_value; + const zend_string *default_value = arg_info->default_value; if (!default_value) { return FAILURE; } /* Avoid going through the full AST machinery for some simple and common cases. */ - size_t default_value_len = strlen(default_value); zend_ulong lval; - if (default_value_len == sizeof("null")-1 - && !memcmp(default_value, "null", sizeof("null")-1)) { + if (zend_string_equals_literal(default_value, "null")) { ZVAL_NULL(default_value_zval); return SUCCESS; - } else if (default_value_len == sizeof("true")-1 - && !memcmp(default_value, "true", sizeof("true")-1)) { + } else if (zend_string_equals_literal(default_value, "true")) { ZVAL_TRUE(default_value_zval); return SUCCESS; - } else if (default_value_len == sizeof("false")-1 - && !memcmp(default_value, "false", sizeof("false")-1)) { + } else if (zend_string_equals_literal(default_value, "false")) { ZVAL_FALSE(default_value_zval); return SUCCESS; - } else if (default_value_len >= 2 - && (default_value[0] == '\'' || default_value[0] == '"') - && default_value[default_value_len - 1] == default_value[0]) { + } else if (ZSTR_LEN(default_value) >= 2 + && (ZSTR_VAL(default_value)[0] == '\'' || ZSTR_VAL(default_value)[0] == '"') + && ZSTR_VAL(default_value)[ZSTR_LEN(default_value) - 1] == ZSTR_VAL(default_value)[0]) { zend_string *str = try_parse_string( - default_value + 1, default_value_len - 2, default_value[0]); + ZSTR_VAL(default_value) + 1, ZSTR_LEN(default_value) - 2, ZSTR_VAL(default_value)[0]); if (str) { ZVAL_STR(default_value_zval, str); return SUCCESS; } - } else if (default_value_len == sizeof("[]")-1 - && !memcmp(default_value, "[]", sizeof("[]")-1)) { + } else if (zend_string_equals_literal(default_value, "[]")) { ZVAL_EMPTY_ARRAY(default_value_zval); return SUCCESS; - } else if (ZEND_HANDLE_NUMERIC_STR(default_value, default_value_len, lval)) { + } else if (ZEND_HANDLE_NUMERIC(default_value, lval)) { ZVAL_LONG(default_value_zval, lval); return SUCCESS; } #if 0 - fprintf(stderr, "Evaluating %s via AST\n", default_value); + fprintf(stderr, "Evaluating %s via AST\n", ZSTR_VAL(default_value)); #endif - return get_default_via_ast(default_value_zval, default_value); + return get_default_via_ast(default_value_zval, ZSTR_VAL(default_value)); } diff --git a/Zend/zend_API.h b/Zend/zend_API.h index 8cde8317530e4..c1ccbf13666a5 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -347,9 +347,6 @@ ZEND_API void zend_set_dl_use_deepbind(bool use_deepbind); ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array); -/* internal function to efficiently copy parameters when executing __call() */ -ZEND_API zend_result zend_copy_parameters_array(uint32_t param_count, zval *argument_array); - #define zend_get_parameters_array(ht, param_count, argument_array) \ zend_get_parameters_array_ex(param_count, argument_array) #define zend_parse_parameters_none() \ @@ -387,13 +384,13 @@ ZEND_API void zend_startup_modules(void); ZEND_API void zend_collect_module_handlers(void); ZEND_API void zend_destroy_modules(void); ZEND_API void zend_check_magic_method_implementation( - const zend_class_entry *ce, const zend_function *fptr, zend_string *lcname, int error_type); -ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, zend_string *lcname); + const zend_class_entry *ce, const zend_function *fptr, const zend_string *lcname, int error_type); +ZEND_API void zend_add_magic_method(zend_class_entry *ce, zend_function *fptr, const zend_string *lcname); -ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *class_entry); -ZEND_API zend_class_entry *zend_register_internal_class_ex(zend_class_entry *class_entry, zend_class_entry *parent_ce); -ZEND_API zend_class_entry *zend_register_internal_class_with_flags(zend_class_entry *class_entry, zend_class_entry *parent_ce, uint32_t flags); -ZEND_API zend_class_entry *zend_register_internal_interface(zend_class_entry *orig_class_entry); +ZEND_API zend_class_entry *zend_register_internal_class(const zend_class_entry *class_entry); +ZEND_API zend_class_entry *zend_register_internal_class_ex(const zend_class_entry *class_entry, zend_class_entry *parent_ce); +ZEND_API zend_class_entry *zend_register_internal_class_with_flags(const zend_class_entry *class_entry, zend_class_entry *parent_ce, uint32_t flags); +ZEND_API zend_class_entry *zend_register_internal_interface(const zend_class_entry *orig_class_entry); ZEND_API void zend_class_implements(zend_class_entry *class_entry, int num_interfaces, ...); ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_len, zend_class_entry *ce, bool persistent); @@ -407,20 +404,19 @@ static zend_always_inline zend_result zend_register_class_alias(const char *name ZEND_API void zend_disable_functions(const char *function_list); ZEND_API ZEND_COLD void zend_wrong_param_count(void); -ZEND_API ZEND_COLD void zend_wrong_property_read(zval *object, zval *property); +ZEND_API ZEND_COLD void zend_wrong_property_read(const zval *object, zval *property); #define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0) #define IS_CALLABLE_SUPPRESS_DEPRECATIONS (1<<1) ZEND_API void zend_release_fcall_info_cache(zend_fcall_info_cache *fcc); -ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, zend_object *object); +ZEND_API zend_string *zend_get_callable_name_ex(zval *callable, const zend_object *object); ZEND_API zend_string *zend_get_callable_name(zval *callable); ZEND_API bool zend_is_callable_at_frame( - zval *callable, zend_object *object, zend_execute_data *frame, + const zval *callable, zend_object *object, const zend_execute_data *frame, uint32_t check_flags, zend_fcall_info_cache *fcc, char **error); ZEND_API bool zend_is_callable_ex(zval *callable, zend_object *object, uint32_t check_flags, zend_string **callable_name, zend_fcall_info_cache *fcc, char **error); ZEND_API bool zend_is_callable(zval *callable, uint32_t check_flags, zend_string **callable_name); -ZEND_API bool zend_make_callable(zval *callable, zend_string **callable_name); ZEND_API const char *zend_get_module_version(const char *module_name); ZEND_API zend_result zend_get_module_started(const char *module_name); @@ -447,7 +443,7 @@ ZEND_API void zend_declare_class_constant_string(zend_class_entry *ce, const cha ZEND_API zend_result zend_update_class_constant(zend_class_constant *c, const zend_string *name, zend_class_entry *scope); ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type); -ZEND_API HashTable *zend_separate_class_constants_table(zend_class_entry *class_type); +ZEND_API HashTable *zend_separate_class_constants_table(const zend_class_entry *class_type); static zend_always_inline HashTable *zend_class_constants_table(zend_class_entry *ce) { if ((ce->ce_flags & ZEND_ACC_HAS_AST_CONSTANTS) && ZEND_MAP_PTR(ce->mutable_data)) { @@ -513,8 +509,8 @@ ZEND_API zend_result zend_update_static_property_double(zend_class_entry *scope, ZEND_API zend_result zend_update_static_property_string(zend_class_entry *scope, const char *name, size_t name_length, const char *value); ZEND_API zend_result zend_update_static_property_stringl(zend_class_entry *scope, const char *name, size_t name_length, const char *value, size_t value_length); -ZEND_API zval *zend_read_property_ex(zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv); -ZEND_API zval *zend_read_property(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv); +ZEND_API zval *zend_read_property_ex(const zend_class_entry *scope, zend_object *object, zend_string *name, bool silent, zval *rv); +ZEND_API zval *zend_read_property(const zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, bool silent, zval *rv); ZEND_API zval *zend_read_static_property_ex(zend_class_entry *scope, zend_string *name, bool silent); ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *name, size_t name_length, bool silent); @@ -527,9 +523,7 @@ ZEND_API const char *zend_get_type_by_const(int type); #define getThis() (hasThis() ? ZEND_THIS : NULL) #define ZEND_IS_METHOD_CALL() (EX(func)->common.scope != NULL) -#define WRONG_PARAM_COUNT ZEND_WRONG_PARAM_COUNT() #define ZEND_NUM_ARGS() EX_NUM_ARGS() -#define ZEND_WRONG_PARAM_COUNT() { zend_wrong_param_count(); return; } #ifndef ZEND_WIN32 #define DLEXPORT @@ -543,9 +537,9 @@ ZEND_API zend_result object_init_with_constructor(zval *arg, zend_class_entry *c ZEND_API zend_result object_and_properties_init(zval *arg, zend_class_entry *ce, HashTable *properties); ZEND_API void object_properties_init(zend_object *object, zend_class_entry *class_type); ZEND_API void object_properties_init_ex(zend_object *object, HashTable *properties); -ZEND_API void object_properties_load(zend_object *object, HashTable *properties); +ZEND_API void object_properties_load(zend_object *object, const HashTable *properties); -ZEND_API void zend_merge_properties(zval *obj, HashTable *properties); +ZEND_API void zend_merge_properties(const zval *obj, const HashTable *properties); ZEND_API void add_assoc_long_ex(zval *arg, const char *key, size_t key_len, zend_long n); ZEND_API void add_assoc_null_ex(zval *arg, const char *key, size_t key_len); @@ -888,8 +882,6 @@ ZEND_API zend_result zend_call_method_if_exists( zend_object *object, zend_string *method_name, zval *retval, uint32_t param_count, zval *params); -ZEND_API zend_result zend_set_hash_symbol(zval *symbol, const char *name, size_t name_length, bool is_ref, int num_symbol_tables, ...); - ZEND_API zend_result zend_delete_global_variable(zend_string *name); ZEND_API zend_array *zend_rebuild_symbol_table(void); @@ -900,7 +892,7 @@ ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval * static zend_always_inline zend_result zend_forbid_dynamic_call(void) { - zend_execute_data *ex = EG(current_execute_data); + const zend_execute_data *ex = EG(current_execute_data); ZEND_ASSERT(ex != NULL && ex->func != NULL); if (ZEND_CALL_INFO(ex) & ZEND_CALL_DYNAMIC) { @@ -930,8 +922,12 @@ ZEND_API bool zend_is_iterable(const zval *iterable); ZEND_API bool zend_is_countable(const zval *countable); +ZEND_API void zend_convert_internal_arg_info(zend_arg_info *new_arg_info, + const zend_internal_arg_info *arg_info, bool is_return_info, + bool permanent); + ZEND_API zend_result zend_get_default_from_internal_arg_info( - zval *default_value_zval, zend_internal_arg_info *arg_info); + zval *default_value_zval, const zend_arg_info *arg_info); END_EXTERN_C() @@ -951,10 +947,6 @@ static zend_always_inline bool zend_char_has_nul_byte(const char *s, size_t know return known_length != strlen(s); } -/* Compatibility with PHP 8.1 and below */ -#define CHECK_ZVAL_NULL_PATH(p) zend_str_has_nul_byte(Z_STR_P(p)) -#define CHECK_NULL_PATH(p, l) zend_char_has_nul_byte(p, l) - #define ZVAL_STRINGL(z, s, l) do { \ ZVAL_NEW_STR(z, zend_string_init(s, l, 0)); \ } while (0) @@ -1066,7 +1058,6 @@ static zend_always_inline bool zend_char_has_nul_byte(const char *s, size_t know #define RETURN_THROWS() do { ZEND_ASSERT(EG(exception)); (void) return_value; return; } while (0) #define HASH_OF(p) (Z_TYPE_P(p)==IS_ARRAY ? Z_ARRVAL_P(p) : ((Z_TYPE_P(p)==IS_OBJECT ? Z_OBJ_HT_P(p)->get_properties(Z_OBJ_P(p)) : NULL))) -#define ZVAL_IS_NULL(z) (Z_TYPE_P(z) == IS_NULL) /* For compatibility */ #define ZEND_MINIT ZEND_MODULE_STARTUP_N @@ -1557,14 +1548,14 @@ typedef enum _zend_expected_type { ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_none_error(void); ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameters_count_error(uint32_t min_num_args, uint32_t max_num_args); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, uint32_t num, char *name, zend_expected_type expected_type, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(uint32_t num, zend_expected_type expected_type, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(uint32_t num, const char *name, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error(uint32_t num, const char *name, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_error(uint32_t num, const char *name, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null_error(uint32_t num, const char *name, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error(uint32_t num, const char *name, zval *arg); -ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_null_error(uint32_t num, const char *name, zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_error(int error_code, uint32_t num, char *name, zend_expected_type expected_type, const zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_type_error(uint32_t num, zend_expected_type expected_type, const zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_error(uint32_t num, const char *name, const zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_null_error(uint32_t num, const char *name, const zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_error(uint32_t num, const char *name, const zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_long_or_null_error(uint32_t num, const char *name, const zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_error(uint32_t num, const char *name, const zval *arg); +ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_parameter_class_or_string_or_null_error(uint32_t num, const char *name, const zval *arg); ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(uint32_t num, char *error); ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_or_null_error(uint32_t num, char *error); ZEND_API ZEND_COLD void ZEND_FASTCALL zend_unexpected_extra_named_error(void); @@ -1573,8 +1564,8 @@ ZEND_API ZEND_COLD void zend_argument_error(zend_class_entry *error_ce, uint32_t 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_argument_must_not_be_empty_error(uint32_t arg_num); -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); +ZEND_API ZEND_COLD void zend_class_redeclaration_error(int type, const zend_class_entry *old_ce); +ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string *new_name, const zend_class_entry *old_ce); #define ZPP_ERROR_OK 0 #define ZPP_ERROR_FAILURE 1 diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index f3dfe0f9df57a..1157dc98fa615 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2627,7 +2627,7 @@ ZEND_API bool is_zend_mm(void) #if ZEND_MM_CUSTOM return !AG(mm_heap)->use_custom_heap; #else - return 1; + return true; #endif } diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index 9cb3c7aae4a1f..30bd4a9c05dd0 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -558,7 +558,7 @@ static zend_class_entry *zend_ast_fetch_class(zend_ast *ast, zend_class_entry *s return zend_fetch_class_with_scope(zend_ast_get_str(ast), (ast->attr >> ZEND_CONST_EXPR_NEW_FETCH_TYPE_SHIFT) | ZEND_FETCH_CLASS_EXCEPTION, scope); } -ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner( +static zend_result ZEND_FASTCALL zend_ast_evaluate_inner( zval *result, zend_ast *ast, zend_class_entry *scope, @@ -589,7 +589,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_ex( return r; } -ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner( +static zend_result ZEND_FASTCALL zend_ast_evaluate_inner( zval *result, zend_ast *ast, zend_class_entry *scope, @@ -1124,12 +1124,12 @@ ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate_inner( if (!(fptr->common.fn_flags & ZEND_ACC_STATIC)) { zend_non_static_method_call(fptr); - + return FAILURE; } if ((fptr->common.fn_flags & ZEND_ACC_ABSTRACT)) { zend_abstract_method_call(fptr); - + return FAILURE; } else if (fptr->common.scope->ce_flags & ZEND_ACC_TRAIT) { zend_error(E_DEPRECATED, @@ -1575,9 +1575,9 @@ static ZEND_COLD bool zend_ast_valid_var_char(char ch) (c < '0' || c > '9') && (c < 'A' || c > 'Z') && (c < 'a' || c > 'z')) { - return 0; + return false; } - return 1; + return true; } static ZEND_COLD bool zend_ast_valid_var_name(const char *s, size_t len) @@ -1586,13 +1586,13 @@ static ZEND_COLD bool zend_ast_valid_var_name(const char *s, size_t len) size_t i; if (len == 0) { - return 0; + return false; } c = (unsigned char)s[0]; if (c != '_' && c < 127 && (c < 'A' || c > 'Z') && (c < 'a' || c > 'z')) { - return 0; + return false; } for (i = 1; i < len; i++) { c = (unsigned char)s[i]; @@ -1600,10 +1600,10 @@ static ZEND_COLD bool zend_ast_valid_var_name(const char *s, size_t len) (c < '0' || c > '9') && (c < 'A' || c > 'Z') && (c < 'a' || c > 'z')) { - return 0; + return false; } } - return 1; + return true; } static ZEND_COLD bool zend_ast_var_needs_braces(char ch) @@ -2139,7 +2139,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_CLASS: decl = (const zend_ast_decl *) ast; if (decl->child[3]) { - zend_ast_export_attributes(str, decl->child[3], indent, 1); + zend_ast_export_attributes(str, decl->child[3], indent, true); } if (decl->flags & ZEND_ACC_INTERFACE) { smart_str_appends(str, "interface "); @@ -2173,11 +2173,11 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_EXPR_LIST: case ZEND_AST_PARAM_LIST: simple_list: - zend_ast_export_list(str, zend_ast_get_list(ast), 1, 20, indent); + zend_ast_export_list(str, zend_ast_get_list(ast), true, 20, indent); break; case ZEND_AST_ARRAY: smart_str_appendc(str, '['); - zend_ast_export_list(str, zend_ast_get_list(ast), 1, 20, indent); + zend_ast_export_list(str, zend_ast_get_list(ast), true, 20, indent); smart_str_appendc(str, ']'); break; case ZEND_AST_ENCAPS_LIST: @@ -2195,7 +2195,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_SWITCH_LIST: case ZEND_AST_CATCH_LIST: case ZEND_AST_MATCH_ARM_LIST: - zend_ast_export_list(str, zend_ast_get_list(ast), 0, 0, indent); + zend_ast_export_list(str, zend_ast_get_list(ast), false, 0, indent); break; case ZEND_AST_CLOSURE_USES: smart_str_appends(str, " use("); @@ -2207,7 +2207,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio zend_ast *prop_ast = ast->child[1]; if (ast->child[2]) { - zend_ast_export_attributes(str, ast->child[2], indent, 1); + zend_ast_export_attributes(str, ast->child[2], indent, true); } zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_PROPERTY); @@ -2236,13 +2236,13 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio str, ast_list->child[ast_list->children - 1], indent, - 1 + true ); /* So that the list printing doesn't try to print the attributes, * use zend_ast_export_list_ex() to override the number of children * to print. */ smart_str_appends(str, "const "); - zend_ast_export_list_ex(str, ast_list, 1, 20, indent, ast_list->children - 1); + zend_ast_export_list_ex(str, ast_list, true, 20, indent, ast_list->children - 1); break; } smart_str_appends(str, "const "); @@ -2250,7 +2250,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio } case ZEND_AST_CLASS_CONST_GROUP: if (ast->child[1]) { - zend_ast_export_attributes(str, ast->child[1], indent, 1); + zend_ast_export_attributes(str, ast->child[1], indent, true); } zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CONSTANT); @@ -2534,7 +2534,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio if (ast->child[0]->kind == ZEND_AST_CLASS) { const zend_ast_decl *decl = (const zend_ast_decl *) ast->child[0]; if (decl->child[3]) { - zend_ast_export_attributes(str, decl->child[3], indent, 0); + zend_ast_export_attributes(str, decl->child[3], indent, false); } smart_str_appends(str, "class"); if (!zend_ast_is_list(ast->child[1]) @@ -2635,7 +2635,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_MATCH_ARM: zend_ast_export_indent(str, indent); if (ast->child[0]) { - zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), 1, 0, indent); + zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), true, 0, indent); smart_str_appends(str, " => "); } else { smart_str_appends(str, "default => "); @@ -2646,7 +2646,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio case ZEND_AST_DECLARE: smart_str_appends(str, "declare("); ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_CONST_DECL); - zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), 1, 0, indent); + zend_ast_export_list(str, zend_ast_get_list(ast->child[0]), true, 0, indent); smart_str_appendc(str, ')'); if (ast->child[1]) { smart_str_appends(str, " {\n"); @@ -2793,7 +2793,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio break; case ZEND_AST_PARAM: if (ast->child[3]) { - zend_ast_export_attributes(str, ast->child[3], indent, 0); + zend_ast_export_attributes(str, ast->child[3], indent, false); } zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CPP); if (ast->attr & ZEND_ACC_FINAL) { @@ -2821,7 +2821,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio break; case ZEND_AST_ENUM_CASE: if (ast->child[3]) { - zend_ast_export_attributes(str, ast->child[3], indent, 1); + zend_ast_export_attributes(str, ast->child[3], indent, true); } smart_str_appends(str, "case "); zend_ast_export_name(str, ast->child[0], 0, indent); diff --git a/Zend/zend_attributes.c b/Zend/zend_attributes.c index b69e192701e48..cba95810ba496 100644 --- a/Zend/zend_attributes.c +++ b/Zend/zend_attributes.c @@ -38,7 +38,7 @@ static zend_object_handlers attributes_object_handlers_sensitive_parameter_value static HashTable internal_attributes; -uint32_t zend_attribute_attribute_get_flags(zend_attribute *attr, zend_class_entry *scope) +uint32_t zend_attribute_attribute_get_flags(const zend_attribute *attr, zend_class_entry *scope) { // TODO: More proper signature validation: Too many args, incorrect arg names. if (attr->argc > 0) { @@ -265,7 +265,7 @@ ZEND_METHOD(NoDiscard, __construct) } } -static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset) +static zend_attribute *get_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset) { if (attributes) { zend_attribute *attr; @@ -280,7 +280,7 @@ static zend_attribute *get_attribute(HashTable *attributes, zend_string *lcname, return NULL; } -static zend_attribute *get_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset) +static zend_attribute *get_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset) { if (attributes) { zend_attribute *attr; @@ -295,27 +295,27 @@ static zend_attribute *get_attribute_str(HashTable *attributes, const char *str, return NULL; } -ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname) +ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname) { return get_attribute(attributes, lcname, 0); } -ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len) +ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len) { return get_attribute_str(attributes, str, len, 0); } -ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset) +ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset) { return get_attribute(attributes, lcname, offset + 1); } -ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset) +ZEND_API zend_attribute *zend_get_parameter_attribute_str(const HashTable *attributes, const char *str, size_t len, uint32_t offset) { return get_attribute_str(attributes, str, len, offset + 1); } -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_value(zval *ret, const zend_attribute *attr, uint32_t i, zend_class_entry *scope) { if (i >= attr->argc) { return FAILURE; @@ -447,7 +447,7 @@ ZEND_API zend_string *zend_get_attribute_target_names(uint32_t flags) return smart_str_extract(&str); } -ZEND_API bool zend_is_attribute_repeated(HashTable *attributes, zend_attribute *attr) +ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr) { zend_attribute *other; diff --git a/Zend/zend_attributes.h b/Zend/zend_attributes.h index 10227c2d1e8ef..f8b61ac9d1666 100644 --- a/Zend/zend_attributes.h +++ b/Zend/zend_attributes.h @@ -77,17 +77,17 @@ typedef struct _zend_internal_attribute { zend_string* (*validator)(zend_attribute *attr, uint32_t target, zend_class_entry *scope); } zend_internal_attribute; -ZEND_API zend_attribute *zend_get_attribute(HashTable *attributes, zend_string *lcname); -ZEND_API zend_attribute *zend_get_attribute_str(HashTable *attributes, const char *str, size_t len); +ZEND_API zend_attribute *zend_get_attribute(const HashTable *attributes, const zend_string *lcname); +ZEND_API zend_attribute *zend_get_attribute_str(const HashTable *attributes, const char *str, size_t len); -ZEND_API zend_attribute *zend_get_parameter_attribute(HashTable *attributes, zend_string *lcname, uint32_t offset); -ZEND_API zend_attribute *zend_get_parameter_attribute_str(HashTable *attributes, const char *str, size_t len, uint32_t offset); +ZEND_API zend_attribute *zend_get_parameter_attribute(const HashTable *attributes, const zend_string *lcname, uint32_t offset); +ZEND_API zend_attribute *zend_get_parameter_attribute_str(const 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_value(zval *ret, const 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); +ZEND_API bool zend_is_attribute_repeated(const HashTable *attributes, const zend_attribute *attr); ZEND_API zend_internal_attribute *zend_mark_internal_attribute(zend_class_entry *ce); ZEND_API zend_internal_attribute *zend_internal_attribute_register(zend_class_entry *ce, uint32_t flags); @@ -97,7 +97,7 @@ 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); +uint32_t zend_attribute_attribute_get_flags(const zend_attribute *attr, zend_class_entry *scope); END_EXTERN_C() @@ -119,13 +119,13 @@ static zend_always_inline zend_attribute *zend_add_parameter_attribute(zend_func return zend_add_attribute(&func->common.attributes, name, argc, flags, offset + 1, 0); } -static zend_always_inline zend_attribute *zend_add_property_attribute(zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc) +static zend_always_inline zend_attribute *zend_add_property_attribute(const zend_class_entry *ce, zend_property_info *info, zend_string *name, uint32_t argc) { uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; return zend_add_attribute(&info->attributes, name, argc, flags, 0, 0); } -static zend_always_inline zend_attribute *zend_add_class_constant_attribute(zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc) +static zend_always_inline zend_attribute *zend_add_class_constant_attribute(const zend_class_entry *ce, zend_class_constant *c, zend_string *name, uint32_t argc) { uint32_t flags = ce->type != ZEND_USER_CLASS ? ZEND_ATTRIBUTE_PERSISTENT : 0; return zend_add_attribute(&c->attributes, name, argc, flags, 0, 0); diff --git a/Zend/zend_attributes_arginfo.h b/Zend/zend_attributes_arginfo.h index 05f7eeb3e5d45..ec8d8de4ee508 100644 --- a/Zend/zend_attributes_arginfo.h +++ b/Zend/zend_attributes_arginfo.h @@ -95,67 +95,67 @@ static zend_class_entry *register_class_Attribute(void) zval const_TARGET_CLASS_value; ZVAL_LONG(&const_TARGET_CLASS_value, ZEND_ATTRIBUTE_TARGET_CLASS); - zend_string *const_TARGET_CLASS_name = zend_string_init_interned("TARGET_CLASS", sizeof("TARGET_CLASS") - 1, 1); + zend_string *const_TARGET_CLASS_name = zend_string_init_interned("TARGET_CLASS", sizeof("TARGET_CLASS") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_CLASS_name, &const_TARGET_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_CLASS_name); + zend_string_release_ex(const_TARGET_CLASS_name, true); zval const_TARGET_FUNCTION_value; ZVAL_LONG(&const_TARGET_FUNCTION_value, ZEND_ATTRIBUTE_TARGET_FUNCTION); - zend_string *const_TARGET_FUNCTION_name = zend_string_init_interned("TARGET_FUNCTION", sizeof("TARGET_FUNCTION") - 1, 1); + zend_string *const_TARGET_FUNCTION_name = zend_string_init_interned("TARGET_FUNCTION", sizeof("TARGET_FUNCTION") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_FUNCTION_name, &const_TARGET_FUNCTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_FUNCTION_name); + zend_string_release_ex(const_TARGET_FUNCTION_name, true); zval const_TARGET_METHOD_value; ZVAL_LONG(&const_TARGET_METHOD_value, ZEND_ATTRIBUTE_TARGET_METHOD); - zend_string *const_TARGET_METHOD_name = zend_string_init_interned("TARGET_METHOD", sizeof("TARGET_METHOD") - 1, 1); + zend_string *const_TARGET_METHOD_name = zend_string_init_interned("TARGET_METHOD", sizeof("TARGET_METHOD") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_METHOD_name, &const_TARGET_METHOD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_METHOD_name); + zend_string_release_ex(const_TARGET_METHOD_name, true); zval const_TARGET_PROPERTY_value; ZVAL_LONG(&const_TARGET_PROPERTY_value, ZEND_ATTRIBUTE_TARGET_PROPERTY); - zend_string *const_TARGET_PROPERTY_name = zend_string_init_interned("TARGET_PROPERTY", sizeof("TARGET_PROPERTY") - 1, 1); + zend_string *const_TARGET_PROPERTY_name = zend_string_init_interned("TARGET_PROPERTY", sizeof("TARGET_PROPERTY") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_PROPERTY_name, &const_TARGET_PROPERTY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_PROPERTY_name); + zend_string_release_ex(const_TARGET_PROPERTY_name, true); zval const_TARGET_CLASS_CONSTANT_value; ZVAL_LONG(&const_TARGET_CLASS_CONSTANT_value, ZEND_ATTRIBUTE_TARGET_CLASS_CONST); - zend_string *const_TARGET_CLASS_CONSTANT_name = zend_string_init_interned("TARGET_CLASS_CONSTANT", sizeof("TARGET_CLASS_CONSTANT") - 1, 1); + zend_string *const_TARGET_CLASS_CONSTANT_name = zend_string_init_interned("TARGET_CLASS_CONSTANT", sizeof("TARGET_CLASS_CONSTANT") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_CLASS_CONSTANT_name, &const_TARGET_CLASS_CONSTANT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_CLASS_CONSTANT_name); + zend_string_release_ex(const_TARGET_CLASS_CONSTANT_name, true); zval const_TARGET_PARAMETER_value; ZVAL_LONG(&const_TARGET_PARAMETER_value, ZEND_ATTRIBUTE_TARGET_PARAMETER); - zend_string *const_TARGET_PARAMETER_name = zend_string_init_interned("TARGET_PARAMETER", sizeof("TARGET_PARAMETER") - 1, 1); + zend_string *const_TARGET_PARAMETER_name = zend_string_init_interned("TARGET_PARAMETER", sizeof("TARGET_PARAMETER") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_PARAMETER_name, &const_TARGET_PARAMETER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_PARAMETER_name); + zend_string_release_ex(const_TARGET_PARAMETER_name, true); zval const_TARGET_CONSTANT_value; ZVAL_LONG(&const_TARGET_CONSTANT_value, ZEND_ATTRIBUTE_TARGET_CONST); - zend_string *const_TARGET_CONSTANT_name = zend_string_init_interned("TARGET_CONSTANT", sizeof("TARGET_CONSTANT") - 1, 1); + zend_string *const_TARGET_CONSTANT_name = zend_string_init_interned("TARGET_CONSTANT", sizeof("TARGET_CONSTANT") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_CONSTANT_name, &const_TARGET_CONSTANT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_CONSTANT_name); + zend_string_release_ex(const_TARGET_CONSTANT_name, true); zval const_TARGET_ALL_value; ZVAL_LONG(&const_TARGET_ALL_value, ZEND_ATTRIBUTE_TARGET_ALL); - zend_string *const_TARGET_ALL_name = zend_string_init_interned("TARGET_ALL", sizeof("TARGET_ALL") - 1, 1); + zend_string *const_TARGET_ALL_name = zend_string_init_interned("TARGET_ALL", sizeof("TARGET_ALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_TARGET_ALL_name, &const_TARGET_ALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TARGET_ALL_name); + zend_string_release_ex(const_TARGET_ALL_name, true); zval const_IS_REPEATABLE_value; ZVAL_LONG(&const_IS_REPEATABLE_value, ZEND_ATTRIBUTE_IS_REPEATABLE); - zend_string *const_IS_REPEATABLE_name = zend_string_init_interned("IS_REPEATABLE", sizeof("IS_REPEATABLE") - 1, 1); + zend_string *const_IS_REPEATABLE_name = zend_string_init_interned("IS_REPEATABLE", sizeof("IS_REPEATABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_REPEATABLE_name, &const_IS_REPEATABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_REPEATABLE_name); + zend_string_release_ex(const_IS_REPEATABLE_name, true); zval property_flags_default_value; ZVAL_UNDEF(&property_flags_default_value); - zend_string *property_flags_name = zend_string_init("flags", sizeof("flags") - 1, 1); + zend_string *property_flags_name = zend_string_init("flags", sizeof("flags") - 1, true); zend_declare_typed_property(class_entry, property_flags_name, &property_flags_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_flags_name); + zend_string_release_ex(property_flags_name, true); - zend_string *attribute_name_Attribute_class_Attribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_Attribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_Attribute_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_Attribute_0, 1); - zend_string_release(attribute_name_Attribute_class_Attribute_0); + zend_string_release_ex(attribute_name_Attribute_class_Attribute_0, true); ZVAL_LONG(&attribute_Attribute_class_Attribute_0->args[0].value, ZEND_ATTRIBUTE_TARGET_CLASS); return class_entry; @@ -168,9 +168,9 @@ static zend_class_entry *register_class_ReturnTypeWillChange(void) INIT_CLASS_ENTRY(ce, "ReturnTypeWillChange", class_ReturnTypeWillChange_methods); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL); - zend_string *attribute_name_Attribute_class_ReturnTypeWillChange_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_ReturnTypeWillChange_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_ReturnTypeWillChange_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_ReturnTypeWillChange_0, 1); - zend_string_release(attribute_name_Attribute_class_ReturnTypeWillChange_0); + zend_string_release_ex(attribute_name_Attribute_class_ReturnTypeWillChange_0, true); ZVAL_LONG(&attribute_Attribute_class_ReturnTypeWillChange_0->args[0].value, ZEND_ATTRIBUTE_TARGET_METHOD); return class_entry; @@ -183,9 +183,9 @@ static zend_class_entry *register_class_AllowDynamicProperties(void) INIT_CLASS_ENTRY(ce, "AllowDynamicProperties", class_AllowDynamicProperties_methods); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL); - zend_string *attribute_name_Attribute_class_AllowDynamicProperties_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_AllowDynamicProperties_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_AllowDynamicProperties_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_AllowDynamicProperties_0, 1); - zend_string_release(attribute_name_Attribute_class_AllowDynamicProperties_0); + zend_string_release_ex(attribute_name_Attribute_class_AllowDynamicProperties_0, true); ZVAL_LONG(&attribute_Attribute_class_AllowDynamicProperties_0->args[0].value, ZEND_ATTRIBUTE_TARGET_CLASS); return class_entry; @@ -198,9 +198,9 @@ static zend_class_entry *register_class_SensitiveParameter(void) INIT_CLASS_ENTRY(ce, "SensitiveParameter", class_SensitiveParameter_methods); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES); - zend_string *attribute_name_Attribute_class_SensitiveParameter_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_SensitiveParameter_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_SensitiveParameter_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_SensitiveParameter_0, 1); - zend_string_release(attribute_name_Attribute_class_SensitiveParameter_0); + zend_string_release_ex(attribute_name_Attribute_class_SensitiveParameter_0, true); ZVAL_LONG(&attribute_Attribute_class_SensitiveParameter_0->args[0].value, ZEND_ATTRIBUTE_TARGET_PARAMETER); return class_entry; @@ -227,9 +227,9 @@ static zend_class_entry *register_class_Override(void) INIT_CLASS_ENTRY(ce, "Override", class_Override_methods); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES); - zend_string *attribute_name_Attribute_class_Override_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_Override_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_Override_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_Override_0, 1); - zend_string_release(attribute_name_Attribute_class_Override_0); + zend_string_release_ex(attribute_name_Attribute_class_Override_0, true); ZVAL_LONG(&attribute_Attribute_class_Override_0->args[0].value, ZEND_ATTRIBUTE_TARGET_METHOD | ZEND_ATTRIBUTE_TARGET_PROPERTY); return class_entry; @@ -250,9 +250,9 @@ static zend_class_entry *register_class_Deprecated(void) ZVAL_UNDEF(&property_since_default_value); zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_SINCE), &property_since_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string *attribute_name_Attribute_class_Deprecated_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_Deprecated_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_Deprecated_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_Deprecated_0, 1); - zend_string_release(attribute_name_Attribute_class_Deprecated_0); + zend_string_release_ex(attribute_name_Attribute_class_Deprecated_0, true); ZVAL_LONG(&attribute_Attribute_class_Deprecated_0->args[0].value, ZEND_ATTRIBUTE_TARGET_METHOD | ZEND_ATTRIBUTE_TARGET_FUNCTION | ZEND_ATTRIBUTE_TARGET_CLASS_CONST | ZEND_ATTRIBUTE_TARGET_CONST | ZEND_ATTRIBUTE_TARGET_CLASS); return class_entry; @@ -269,9 +269,9 @@ static zend_class_entry *register_class_NoDiscard(void) ZVAL_UNDEF(&property_message_default_value); zend_declare_typed_property(class_entry, ZSTR_KNOWN(ZEND_STR_MESSAGE), &property_message_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string *attribute_name_Attribute_class_NoDiscard_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_NoDiscard_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_NoDiscard_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_NoDiscard_0, 1); - zend_string_release(attribute_name_Attribute_class_NoDiscard_0); + zend_string_release_ex(attribute_name_Attribute_class_NoDiscard_0, true); ZVAL_LONG(&attribute_Attribute_class_NoDiscard_0->args[0].value, ZEND_ATTRIBUTE_TARGET_METHOD | ZEND_ATTRIBUTE_TARGET_FUNCTION); return class_entry; @@ -284,9 +284,9 @@ static zend_class_entry *register_class_DelayedTargetValidation(void) INIT_CLASS_ENTRY(ce, "DelayedTargetValidation", NULL); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES); - zend_string *attribute_name_Attribute_class_DelayedTargetValidation_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_DelayedTargetValidation_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_DelayedTargetValidation_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_DelayedTargetValidation_0, 1); - zend_string_release(attribute_name_Attribute_class_DelayedTargetValidation_0); + zend_string_release_ex(attribute_name_Attribute_class_DelayedTargetValidation_0, true); ZVAL_LONG(&attribute_Attribute_class_DelayedTargetValidation_0->args[0].value, ZEND_ATTRIBUTE_TARGET_ALL); return class_entry; diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c index 0d8be49af857a..a4ece3061d5d0 100644 --- a/Zend/zend_builtin_functions.c +++ b/Zend/zend_builtin_functions.c @@ -503,7 +503,7 @@ ZEND_FUNCTION(error_reporting) static bool validate_constant_array_argument(HashTable *ht, int argument_number) /* {{{ */ { - bool ret = 1; + bool ret = true; zval *val; GC_PROTECT_RECURSION(ht); @@ -512,10 +512,10 @@ static bool validate_constant_array_argument(HashTable *ht, int argument_number) if (Z_TYPE_P(val) == IS_ARRAY && Z_REFCOUNTED_P(val)) { if (Z_IS_RECURSIVE_P(val)) { zend_argument_value_error(argument_number, "cannot be a recursive array"); - ret = 0; + ret = false; break; } else if (!validate_constant_array_argument(Z_ARRVAL_P(val), argument_number)) { - ret = 0; + ret = false; break; } } @@ -555,7 +555,7 @@ static void copy_constant_array(zval *dst, zval *src) /* {{{ */ ZEND_FUNCTION(define) { zend_string *name; - zval *val, val_free; + zval *val; bool non_cs = 0; zend_constant c; @@ -575,23 +575,16 @@ ZEND_FUNCTION(define) zend_error(E_WARNING, "define(): Argument #3 ($case_insensitive) is ignored since declaration of case-insensitive constants is no longer supported"); } - ZVAL_UNDEF(&val_free); - - if (Z_TYPE_P(val) == IS_ARRAY) { - if (Z_REFCOUNTED_P(val)) { - if (!validate_constant_array_argument(Z_ARRVAL_P(val), 2)) { - RETURN_THROWS(); - } else { - copy_constant_array(&c.value, val); - goto register_constant; - } + if (Z_TYPE_P(val) == IS_ARRAY && Z_REFCOUNTED_P(val)) { + if (!validate_constant_array_argument(Z_ARRVAL_P(val), 2)) { + RETURN_THROWS(); + } else { + copy_constant_array(&c.value, val); } + } else { + ZVAL_COPY(&c.value, val); } - ZVAL_COPY(&c.value, val); - zval_ptr_dtor(&val_free); - -register_constant: /* non persistent */ ZEND_CONSTANT_SET_FLAGS(&c, 0, PHP_USER_CONSTANT); c.name = zend_string_copy(name); @@ -824,8 +817,8 @@ ZEND_FUNCTION(get_class_vars) } scope = zend_get_executed_scope(); - add_class_vars(scope, ce, 0, return_value); - add_class_vars(scope, ce, 1, return_value); + add_class_vars(scope, ce, false, return_value); + add_class_vars(scope, ce, true, return_value); } /* }}} */ @@ -1631,7 +1624,7 @@ static void add_zendext_info(zend_extension *ext, void *arg) /* {{{ */ /* {{{ Return an array containing names of loaded extensions */ ZEND_FUNCTION(get_loaded_extensions) { - bool zendext = 0; + bool zendext = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &zendext) == FAILURE) { RETURN_THROWS(); @@ -1654,7 +1647,7 @@ ZEND_FUNCTION(get_loaded_extensions) /* {{{ Return an array containing the names and values of all defined constants */ ZEND_FUNCTION(get_defined_constants) { - bool categorize = 0; + bool categorize = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &categorize) == FAILURE) { RETURN_THROWS(); @@ -1722,6 +1715,18 @@ ZEND_FUNCTION(get_defined_constants) } /* }}} */ +static bool backtrace_is_arg_sensitive(const zend_execute_data *call, uint32_t offset) +{ + zend_attribute *attribute = zend_get_parameter_attribute_str( + call->func->common.attributes, + "sensitiveparameter", + sizeof("sensitiveparameter") - 1, + offset + ); + + return attribute != NULL; +} + static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) /* {{{ */ { uint32_t num_args = ZEND_CALL_NUM_ARGS(call); @@ -1745,14 +1750,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / zend_string *arg_name = call->func->op_array.vars[i]; zval original_arg; zval *arg = zend_hash_find_ex_ind(call->symbol_table, arg_name, 1); - zend_attribute *attribute = zend_get_parameter_attribute_str( - call->func->common.attributes, - "sensitiveparameter", - sizeof("sensitiveparameter") - 1, - i - ); - - bool is_sensitive = attribute != NULL; + bool is_sensitive = backtrace_is_arg_sensitive(call, i); if (arg) { ZVAL_DEREF(arg); @@ -1763,8 +1761,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_known_function(Z_OBJCE_P(&redacted_arg)->constructor, Z_OBJ_P(&redacted_arg), Z_OBJCE_P(&redacted_arg), NULL, 1, &original_arg, NULL); + object_init_with_constructor(&redacted_arg, zend_ce_sensitive_parameter_value, 1, &original_arg, NULL); ZEND_HASH_FILL_SET(&redacted_arg); } else { Z_TRY_ADDREF_P(&original_arg); @@ -1777,13 +1774,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / } else { while (i < first_extra_arg) { zval original_arg; - zend_attribute *attribute = zend_get_parameter_attribute_str( - call->func->common.attributes, - "sensitiveparameter", - sizeof("sensitiveparameter") - 1, - i - ); - bool is_sensitive = attribute != NULL; + bool is_sensitive = backtrace_is_arg_sensitive(call, i); if (EXPECTED(Z_TYPE_INFO_P(p) != IS_UNDEF)) { zval *arg = p; @@ -1795,8 +1786,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_known_function(Z_OBJCE_P(&redacted_arg)->constructor, Z_OBJ_P(&redacted_arg), Z_OBJCE_P(&redacted_arg), NULL, 1, &original_arg, NULL); + object_init_with_constructor(&redacted_arg, zend_ce_sensitive_parameter_value, 1, &original_arg, NULL); ZEND_HASH_FILL_SET(&redacted_arg); } else { Z_TRY_ADDREF_P(&original_arg); @@ -1816,13 +1806,7 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / bool is_sensitive = 0; if (i < call->func->common.num_args || call->func->common.fn_flags & ZEND_ACC_VARIADIC) { - zend_attribute *attribute = zend_get_parameter_attribute_str( - call->func->common.attributes, - "sensitiveparameter", - sizeof("sensitiveparameter") - 1, - MIN(i, call->func->common.num_args) - ); - is_sensitive = attribute != NULL; + is_sensitive = backtrace_is_arg_sensitive(call, MIN(i, call->func->common.num_args)); } if (EXPECTED(Z_TYPE_INFO_P(p) != IS_UNDEF)) { @@ -1835,8 +1819,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_known_function(Z_OBJCE_P(&redacted_arg)->constructor, Z_OBJ_P(&redacted_arg), Z_OBJCE_P(&redacted_arg), NULL, 1, &original_arg, NULL); + object_init_with_constructor(&redacted_arg, zend_ce_sensitive_parameter_value, 1, &original_arg, NULL); ZEND_HASH_FILL_SET(&redacted_arg); } else { Z_TRY_ADDREF_P(&original_arg); @@ -1861,21 +1844,14 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array) / zend_string *name; zval *arg; - zend_attribute *attribute = zend_get_parameter_attribute_str( - call->func->common.attributes, - "sensitiveparameter", - sizeof("sensitiveparameter") - 1, - call->func->common.num_args - ); - bool is_sensitive = attribute != NULL; + bool is_sensitive = backtrace_is_arg_sensitive(call, call->func->common.num_args); SEPARATE_ARRAY(arg_array); ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(call->extra_named_params, name, arg) { ZVAL_DEREF(arg); 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, arg); + object_init_with_constructor(&redacted_arg, zend_ce_sensitive_parameter_value, 1, arg, NULL); zend_hash_add_new(Z_ARRVAL_P(arg_array), name, &redacted_arg); } else { Z_TRY_ADDREF_P(arg); @@ -1912,7 +1888,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int { zend_execute_data *call, *last_call = NULL; zend_object *object; - bool fake_frame = 0; + bool fake_frame = false; int lineno, frameno = 0; zend_function *func; zend_string *filename; @@ -2148,7 +2124,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int } } else { /* i know this is kinda ugly, but i'm trying to avoid extra cycles in the main execution loop */ - bool build_filename_arg = 1; + bool build_filename_arg = true; zend_string *pseudo_function_name; uint32_t include_kind = 0; if (prev && prev->func && ZEND_USER_CODE(prev->func->common.type) && prev->opline->opcode == ZEND_INCLUDE_OR_EVAL) { @@ -2158,7 +2134,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int switch (include_kind) { case ZEND_EVAL: pseudo_function_name = ZSTR_KNOWN(ZEND_STR_EVAL); - build_filename_arg = 0; + build_filename_arg = false; break; case ZEND_INCLUDE: pseudo_function_name = ZSTR_KNOWN(ZEND_STR_INCLUDE); @@ -2180,7 +2156,7 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int } pseudo_function_name = ZSTR_KNOWN(ZEND_STR_UNKNOWN); - build_filename_arg = 0; + build_filename_arg = false; break; } @@ -2214,9 +2190,9 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int && prev->func && ZEND_USER_CODE(prev->func->common.type) && prev->opline->opcode == ZEND_INCLUDE_OR_EVAL) { - fake_frame = 1; + fake_frame = true; } else { - fake_frame = 0; + fake_frame = false; include_filename = filename; last_call = call; call = prev; @@ -2286,9 +2262,9 @@ ZEND_FUNCTION(get_extension_funcs) if (module->functions) { /* avoid BC break, if functions list is empty, will return an empty array */ array_init(return_value); - array = 1; + array = true; } else { - array = 0; + array = false; } ZEND_HASH_MAP_FOREACH_PTR(CG(function_table), zif) { @@ -2296,7 +2272,7 @@ ZEND_FUNCTION(get_extension_funcs) && zif->internal_function.module == module) { if (!array) { array_init(return_value); - array = 1; + array = true; } add_next_index_str(return_value, zend_string_copy(zif->common.function_name)); } diff --git a/Zend/zend_builtin_functions_arginfo.h b/Zend/zend_builtin_functions_arginfo.h index cf349b551ac21..17484eb03f253 100644 --- a/Zend/zend_builtin_functions_arginfo.h +++ b/Zend/zend_builtin_functions_arginfo.h @@ -387,9 +387,9 @@ static zend_class_entry *register_class_stdClass(void) INIT_CLASS_ENTRY(ce, "stdClass", NULL); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES); - zend_string *attribute_name_AllowDynamicProperties_class_stdClass_0 = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); + zend_string *attribute_name_AllowDynamicProperties_class_stdClass_0 = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, true); zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class_stdClass_0, 0); - zend_string_release(attribute_name_AllowDynamicProperties_class_stdClass_0); + zend_string_release_ex(attribute_name_AllowDynamicProperties_class_stdClass_0, true); return class_entry; } diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 4a6b5a5218849..05b6862044816 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -82,7 +82,7 @@ static bool zend_valid_closure_binding( if (newthis) { if (func->common.fn_flags & ZEND_ACC_STATIC) { zend_error(E_WARNING, "Cannot bind an instance to a static closure, this will be an error in PHP 9"); - return 0; + return false; } if (is_fake_closure && func->common.scope && @@ -92,23 +92,23 @@ static bool zend_valid_closure_binding( ZSTR_VAL(func->common.scope->name), ZSTR_VAL(func->common.function_name), ZSTR_VAL(Z_OBJCE_P(newthis)->name)); - return 0; + return false; } } else if (is_fake_closure && func->common.scope && !(func->common.fn_flags & ZEND_ACC_STATIC)) { zend_error(E_WARNING, "Cannot unbind $this of method, this will be an error in PHP 9"); - return 0; + return false; } else if (!is_fake_closure && !Z_ISUNDEF(closure->this_ptr) && (func->common.fn_flags & ZEND_ACC_USES_THIS)) { zend_error(E_WARNING, "Cannot unbind $this of closure using $this, this will be an error in PHP 9"); - return 0; + return false; } if (scope && scope != func->common.scope && scope->type == ZEND_INTERNAL_CLASS) { /* rebinding to internal class is not allowed */ zend_error(E_WARNING, "Cannot bind closure to scope of internal class %s, this will be an error in PHP 9", ZSTR_VAL(scope->name)); - return 0; + return false; } if (is_fake_closure && scope != func->common.scope) { @@ -117,10 +117,10 @@ static bool zend_valid_closure_binding( } else { zend_error(E_WARNING, "Cannot rebind scope of closure created from method, this will be an error in PHP 9"); } - return 0; + return false; } - return 1; + return true; } /* }}} */ @@ -287,6 +287,19 @@ ZEND_METHOD(Closure, bindTo) do_closure_bind(return_value, ZEND_THIS, newthis, scope_obj, scope_str); } +static void zend_copy_parameters_array(const uint32_t param_count, HashTable *argument_array) /* {{{ */ +{ + zval *param_ptr = ZEND_CALL_ARG(EG(current_execute_data), 1); + + ZEND_ASSERT(param_count <= ZEND_CALL_NUM_ARGS(EG(current_execute_data))); + + for (uint32_t i = 0; i < param_count; i++) { + Z_TRY_ADDREF_P(param_ptr); + zend_hash_next_index_insert_new(argument_array, param_ptr); + param_ptr++; + } +} + static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { zend_fcall_info fci; zend_fcall_info_cache fcc; @@ -310,14 +323,14 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ { array_init_size(&fci.params[1], ZEND_NUM_ARGS() + zend_hash_num_elements(EX(extra_named_params))); /* Avoid conversion from packed to mixed later. */ zend_hash_real_init_mixed(Z_ARRVAL(fci.params[1])); - zend_copy_parameters_array(ZEND_NUM_ARGS(), &fci.params[1]); + zend_copy_parameters_array(ZEND_NUM_ARGS(), Z_ARRVAL(fci.params[1])); ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(EX(extra_named_params), name, named_param_zval) { Z_TRY_ADDREF_P(named_param_zval); zend_hash_add_new(Z_ARRVAL(fci.params[1]), name, named_param_zval); } ZEND_HASH_FOREACH_END(); } else if (ZEND_NUM_ARGS()) { array_init_size(&fci.params[1], ZEND_NUM_ARGS()); - zend_copy_parameters_array(ZEND_NUM_ARGS(), &fci.params[1]); + zend_copy_parameters_array(ZEND_NUM_ARGS(), Z_ARRVAL(fci.params[1])); } else { ZVAL_EMPTY_ARRAY(&fci.params[1]); } @@ -497,7 +510,7 @@ ZEND_API zend_function *zend_get_closure_invoke_method(zend_object *object) /* { * ZEND_ACC_USER_ARG_INFO flag to prevent invalid usage by Reflection */ invoke->type = ZEND_INTERNAL_FUNCTION; invoke->internal_function.fn_flags = - ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | (closure->func.common.fn_flags & keep_flags); + ZEND_ACC_PUBLIC | ZEND_ACC_CALL_VIA_HANDLER | ZEND_ACC_NEVER_CACHE | (closure->func.common.fn_flags & keep_flags); if (closure->func.type != ZEND_INTERNAL_FUNCTION || (closure->func.common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { invoke->internal_function.fn_flags |= ZEND_ACC_USER_ARG_INFO; @@ -605,7 +618,6 @@ static HashTable *zend_closure_get_debug_info(zend_object *object, int *is_temp) zval val; struct _zend_arg_info *arg_info = closure->func.common.arg_info; HashTable *debug_info; - bool zstr_args = (closure->func.type == ZEND_USER_FUNCTION) || (closure->func.common.fn_flags & ZEND_ACC_USER_ARG_INFO); *is_temp = 1; @@ -681,15 +693,9 @@ static HashTable *zend_closure_get_debug_info(zend_object *object, int *is_temp) zend_string *name; zval info; ZEND_ASSERT(arg_info->name && "Argument should have name"); - if (zstr_args) { - name = zend_strpprintf(0, "%s$%s", - ZEND_ARG_SEND_MODE(arg_info) ? "&" : "", - ZSTR_VAL(arg_info->name)); - } else { - name = zend_strpprintf(0, "%s$%s", - ZEND_ARG_SEND_MODE(arg_info) ? "&" : "", - ((zend_internal_arg_info*)arg_info)->name); - } + name = zend_strpprintf(0, "%s$%s", + ZEND_ARG_SEND_MODE(arg_info) ? "&" : "", + ZSTR_VAL(arg_info->name)); ZVAL_NEW_STR(&info, zend_strpprintf(0, "%s", i >= required ? "" : "")); zend_hash_update(Z_ARRVAL(val), name, &info); zend_string_release_ex(name, 0); @@ -872,10 +878,9 @@ ZEND_API void zend_create_fake_closure(zval *res, zend_function *func, zend_clas } /* }}} */ -/* __call and __callStatic name the arguments "$arguments" in the docs. */ -static zend_internal_arg_info trampoline_arg_info[] = {ZEND_ARG_VARIADIC_TYPE_INFO(false, arguments, IS_MIXED, false)}; +static zend_arg_info trampoline_arg_info[1]; -void zend_closure_from_frame(zval *return_value, zend_execute_data *call) { /* {{{ */ +void zend_closure_from_frame(zval *return_value, const zend_execute_data *call) { /* {{{ */ zval instance; zend_internal_function trampoline; zend_function *mptr = call->func; @@ -938,3 +943,11 @@ void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val) /* { ZVAL_COPY_VALUE(var, val); } /* }}} */ + +void zend_closure_startup(void) +{ + /* __call and __callStatic name the arguments "$arguments" in the docs. */ + trampoline_arg_info[0].name = zend_string_init_interned("arguments", strlen("arguments"), true); + trampoline_arg_info[0].type = (zend_type)ZEND_TYPE_INIT_CODE(IS_MIXED, false, _ZEND_ARG_INFO_FLAGS(false, 1, 0)); + trampoline_arg_info[0].default_value = NULL; +} diff --git a/Zend/zend_closures.h b/Zend/zend_closures.h index ced1b5ba48c15..a118044c6e248 100644 --- a/Zend/zend_closures.h +++ b/Zend/zend_closures.h @@ -28,10 +28,11 @@ BEGIN_EXTERN_C() #define ZEND_CLOSURE_OBJECT(op_array) \ ((zend_object*)((char*)(op_array) - sizeof(zend_object))) +void zend_closure_startup(void); void zend_register_closure_ce(void); void zend_closure_bind_var(zval *closure_zv, zend_string *var_name, zval *var); void zend_closure_bind_var_ex(zval *closure_zv, uint32_t offset, zval *val); -void zend_closure_from_frame(zval *closure_zv, zend_execute_data *frame); +void zend_closure_from_frame(zval *closure_zv, const zend_execute_data *frame); extern ZEND_API zend_class_entry *zend_ce_closure; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 8be1ee14f4859..5eba2ec1366fa 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -28,6 +28,7 @@ #include "zend_API.h" #include "zend_exceptions.h" #include "zend_interfaces.h" +#include "zend_types.h" #include "zend_virtual_cwd.h" #include "zend_multibyte.h" #include "zend_language_scanner.h" @@ -348,7 +349,7 @@ void zend_oparray_context_begin(zend_oparray_context *prev_context, zend_op_arra } /* }}} */ -void zend_oparray_context_end(zend_oparray_context *prev_context) /* {{{ */ +void zend_oparray_context_end(const zend_oparray_context *prev_context) /* {{{ */ { if (CG(context).brk_cont_array) { efree(CG(context).brk_cont_array); @@ -411,7 +412,7 @@ void zend_file_context_begin(zend_file_context *prev_context) /* {{{ */ } /* }}} */ -void zend_file_context_end(zend_file_context *prev_context) /* {{{ */ +void zend_file_context_end(const zend_file_context *prev_context) /* {{{ */ { zend_end_namespace(); zend_hash_destroy(&FC(seen_symbols)); @@ -446,7 +447,7 @@ static void zend_register_seen_symbol(zend_string *name, uint32_t kind) { } static bool zend_have_seen_symbol(zend_string *name, uint32_t kind) { - zval *zv = zend_hash_find(&FC(seen_symbols), name); + const zval *zv = zend_hash_find(&FC(seen_symbols), name); return zv && (Z_LVAL_P(zv) & kind) != 0; } @@ -518,7 +519,7 @@ ZEND_API zend_string *zend_get_compiled_filename(void) /* {{{ */ } /* }}} */ -ZEND_API int zend_get_compiled_lineno(void) /* {{{ */ +ZEND_API uint32_t zend_get_compiled_lineno(void) /* {{{ */ { return CG(zend_lineno); } @@ -536,7 +537,7 @@ static zend_always_inline uint32_t get_temporary_variable(void) /* {{{ */ } /* }}} */ -static int lookup_cv(zend_string *name) /* {{{ */{ +static uint32_t lookup_cv(zend_string *name) /* {{{ */{ zend_op_array *op_array = CG(active_op_array); int i = 0; zend_ulong hash_value = zend_string_hash_val(name); @@ -571,7 +572,7 @@ zend_string *zval_make_interned_string(zval *zv) } /* Common part of zend_add_literal and zend_append_individual_literal */ -static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int literal_position) /* {{{ */ +static inline void zend_insert_literal(const zend_op_array *op_array, zval *zv, int literal_position) /* {{{ */ { zval *lit = CT_CONSTANT_EX(op_array, literal_position); if (Z_TYPE_P(zv) == IS_STRING) { @@ -588,7 +589,7 @@ static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int li static int zend_add_literal(zval *zv) /* {{{ */ { zend_op_array *op_array = CG(active_op_array); - int i = op_array->last_literal; + uint32_t i = op_array->last_literal; op_array->last_literal++; if (i >= CG(context).literals_size) { while (i >= CG(context).literals_size) { @@ -951,7 +952,7 @@ uint32_t zend_modifier_token_to_flag(zend_modifier_target target, uint32_t token uint32_t zend_modifier_list_to_flags(zend_modifier_target target, zend_ast *modifiers) { uint32_t flags = 0; - zend_ast_list *modifier_list = zend_ast_get_list(modifiers); + const zend_ast_list *modifier_list = zend_ast_get_list(modifiers); for (uint32_t i = 0; i < modifier_list->children; i++) { uint32_t token = (uint32_t) Z_LVAL_P(zend_ast_get_zval(modifier_list->child[i])); @@ -1050,20 +1051,20 @@ uint32_t zend_add_member_modifier(uint32_t flags, uint32_t new_flag, zend_modifi } /* }}} */ -ZEND_API zend_string *zend_create_member_string(zend_string *class_name, zend_string *member_name) { +ZEND_API zend_string *zend_create_member_string(const zend_string *class_name, const zend_string *member_name) { return zend_string_concat3( ZSTR_VAL(class_name), ZSTR_LEN(class_name), "::", sizeof("::") - 1, ZSTR_VAL(member_name), ZSTR_LEN(member_name)); } -static zend_string *zend_concat_names(char *name1, size_t name1_len, char *name2, size_t name2_len) { +static zend_string *zend_concat_names(const char *name1, size_t name1_len, const char *name2, size_t name2_len) { return zend_string_concat3(name1, name1_len, "\\", 1, name2, name2_len); } static zend_string *zend_prefix_with_ns(zend_string *name) { if (FC(current_namespace)) { - zend_string *ns = FC(current_namespace); + const zend_string *ns = FC(current_namespace); return zend_concat_names(ZSTR_VAL(ns), ZSTR_LEN(ns), ZSTR_VAL(name), ZSTR_LEN(name)); } else { return zend_string_copy(name); @@ -1072,24 +1073,24 @@ static zend_string *zend_prefix_with_ns(zend_string *name) { static zend_string *zend_resolve_non_class_name( zend_string *name, uint32_t type, bool *is_fully_qualified, - bool case_sensitive, HashTable *current_import_sub + bool case_sensitive, const HashTable *current_import_sub ) { - char *compound; - *is_fully_qualified = 0; + const char *compound; + *is_fully_qualified = false; if (ZSTR_VAL(name)[0] == '\\') { /* Remove \ prefix (only relevant if this is a string rather than a label) */ - *is_fully_qualified = 1; + *is_fully_qualified = true; return zend_string_init(ZSTR_VAL(name) + 1, ZSTR_LEN(name) - 1, 0); } if (type == ZEND_NAME_FQ) { - *is_fully_qualified = 1; + *is_fully_qualified = true; return zend_string_copy(name); } if (type == ZEND_NAME_RELATIVE) { - *is_fully_qualified = 1; + *is_fully_qualified = true; return zend_prefix_with_ns(name); } @@ -1103,20 +1104,20 @@ static zend_string *zend_resolve_non_class_name( } if (import_name) { - *is_fully_qualified = 1; + *is_fully_qualified = true; return zend_string_copy(import_name); } } compound = memchr(ZSTR_VAL(name), '\\', ZSTR_LEN(name)); if (compound) { - *is_fully_qualified = 1; + *is_fully_qualified = true; } if (compound && FC(imports)) { /* If the first part of a qualified name is an alias, substitute it. */ size_t len = compound - ZSTR_VAL(name); - zend_string *import_name = zend_hash_str_find_ptr_lc(FC(imports), ZSTR_VAL(name), len); + const zend_string *import_name = zend_hash_str_find_ptr_lc(FC(imports), ZSTR_VAL(name), len); if (import_name) { return zend_concat_names( @@ -1131,18 +1132,18 @@ static zend_string *zend_resolve_non_class_name( static zend_string *zend_resolve_function_name(zend_string *name, uint32_t type, bool *is_fully_qualified) { return zend_resolve_non_class_name( - name, type, is_fully_qualified, 0, FC(imports_function)); + name, type, is_fully_qualified, false, FC(imports_function)); } static zend_string *zend_resolve_const_name(zend_string *name, uint32_t type, bool *is_fully_qualified) { return zend_resolve_non_class_name( - name, type, is_fully_qualified, 1, FC(imports_const)); + name, type, is_fully_qualified, true, FC(imports_const)); } static zend_string *zend_resolve_class_name(zend_string *name, uint32_t type) /* {{{ */ { - char *compound; + const char *compound; if (ZEND_FETCH_CLASS_DEFAULT != zend_get_class_fetch_type(name)) { if (type == ZEND_NAME_FQ) { @@ -1180,7 +1181,7 @@ static zend_string *zend_resolve_class_name(zend_string *name, uint32_t type) /* if (compound) { /* If the first part of a qualified name is an alias, substitute it. */ size_t len = compound - ZSTR_VAL(name); - zend_string *import_name = + const zend_string *import_name = zend_hash_str_find_ptr_lc(FC(imports), ZSTR_VAL(name), len); if (import_name) { @@ -1205,7 +1206,7 @@ static zend_string *zend_resolve_class_name(zend_string *name, uint32_t type) /* static zend_string *zend_resolve_class_name_ast(zend_ast *ast) /* {{{ */ { - zval *class_name = zend_ast_get_zval(ast); + const zval *class_name = zend_ast_get_zval(ast); if (Z_TYPE_P(class_name) != IS_STRING) { zend_error_noreturn(E_COMPILE_ERROR, "Illegal class name"); } @@ -1224,8 +1225,6 @@ static void str_dtor(zval *zv) /* {{{ */ { } /* }}} */ -static bool zend_is_call(zend_ast *ast); - static uint32_t zend_add_try_element(uint32_t try_op) /* {{{ */ { zend_op_array *op_array = CG(active_op_array); @@ -1263,14 +1262,14 @@ ZEND_API void function_add_ref(zend_function *function) /* {{{ */ } /* }}} */ -static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zend_string *lcname, zend_op_array *op_array, bool compile_time) /* {{{ */ +static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(const zend_string *lcname, const zend_op_array *op_array, bool compile_time) /* {{{ */ { - zval *zv = zend_hash_find_known_hash(compile_time ? CG(function_table) : EG(function_table), lcname); + const zval *zv = zend_hash_find_known_hash(compile_time ? CG(function_table) : EG(function_table), lcname); int error_level = compile_time ? E_COMPILE_ERROR : E_ERROR; - zend_function *old_function; + const zend_function *old_function; ZEND_ASSERT(zv != NULL); - old_function = (zend_function*)Z_PTR_P(zv); + old_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 function %s() (previously declared in %s:%d)", @@ -1283,11 +1282,11 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zen } } -ZEND_API zend_result do_bind_function(zend_function *func, zval *lcname) /* {{{ */ +ZEND_API zend_result do_bind_function(zend_function *func, const zval *lcname) /* {{{ */ { zend_function *added_func = zend_hash_add_ptr(EG(function_table), Z_STR_P(lcname), func); if (UNEXPECTED(!added_func)) { - do_bind_function_error(Z_STR_P(lcname), &func->op_array, 0); + do_bind_function_error(Z_STR_P(lcname), &func->op_array, false); return FAILURE; } @@ -1303,7 +1302,7 @@ ZEND_API zend_result do_bind_function(zend_function *func, zval *lcname) /* {{{ /* }}} */ ZEND_API zend_class_entry *zend_bind_class_in_slot( - zval *class_table_slot, zval *lcname, zend_string *lc_parent_name) + zval *class_table_slot, const zval *lcname, zend_string *lc_parent_name) { zend_class_entry *ce = Z_PTR_P(class_table_slot); bool is_preloaded = @@ -1345,7 +1344,6 @@ ZEND_API zend_class_entry *zend_bind_class_in_slot( ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /* {{{ */ { - zend_class_entry *ce; zval *rtd_key, *zv; rtd_key = lcname + 1; @@ -1353,7 +1351,7 @@ ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name) /* zv = zend_hash_find_known_hash(EG(class_table), Z_STR_P(rtd_key)); if (UNEXPECTED(!zv)) { - ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(lcname)); + const zend_class_entry *ce = zend_hash_find_ptr(EG(class_table), Z_STR_P(lcname)); ZEND_ASSERT(ce); zend_class_redeclaration_error(E_COMPILE_ERROR, ce); return FAILURE; @@ -1382,7 +1380,7 @@ static zend_string *add_type_string(zend_string *type, zend_string *new_type, bo return result; } -static zend_string *resolve_class_name(zend_string *name, zend_class_entry *scope) { +static zend_string *resolve_class_name(zend_string *name, const zend_class_entry *scope) { if (scope) { if (zend_string_equals_ci(name, ZSTR_KNOWN(ZEND_STR_SELF))) { name = scope->name; @@ -1464,7 +1462,7 @@ zend_string *zend_type_to_string_resolved(const zend_type type, zend_class_entry zend_string *name = ZSTR_KNOWN(ZEND_STR_STATIC); // During compilation of eval'd code the called scope refers to the scope calling the eval if (scope && !zend_is_compiling()) { - zend_class_entry *called_scope = zend_get_called_scope(EG(current_execute_data)); + const zend_class_entry *called_scope = zend_get_called_scope(EG(current_execute_data)); if (called_scope) { name = called_scope->name; } @@ -1542,7 +1540,7 @@ static void zend_mark_function_as_generator(void) /* {{{ */ ZEND_TYPE_FOREACH(return_type, single_type) { if (ZEND_TYPE_HAS_NAME(*single_type) && is_generator_compatible_class_type(ZEND_TYPE_NAME(*single_type))) { - valid_type = 1; + valid_type = true; break; } } ZEND_TYPE_FOREACH_END(); @@ -1618,7 +1616,7 @@ ZEND_API zend_result zend_unmangle_property_name_ex(const zend_string *name, con } /* }}} */ -static bool array_is_const_ex(zend_array *array, uint32_t *max_checks) +static bool array_is_const_ex(const zend_array *array, uint32_t *max_checks) { if (zend_hash_num_elements(array) > *max_checks) { return false; @@ -1641,13 +1639,13 @@ static bool array_is_const_ex(zend_array *array, uint32_t *max_checks) return true; } -static bool array_is_const(zend_array *array) +static bool array_is_const(const zend_array *array) { uint32_t max_checks = 50; return array_is_const_ex(array, &max_checks); } -static bool can_ct_eval_const(zend_constant *c) { +static bool can_ct_eval_const(const zend_constant *c) { if (ZEND_CONSTANT_FLAGS(c) & CONST_DEPRECATED) { return 0; } @@ -1716,7 +1714,7 @@ static inline bool zend_is_scope_known(void) /* {{{ */ } /* }}} */ -static inline bool class_name_refers_to_active_ce(zend_string *class_name, uint32_t fetch_type) /* {{{ */ +static inline bool class_name_refers_to_active_ce(const zend_string *class_name, uint32_t fetch_type) /* {{{ */ { if (!CG(active_class_entry)) { return 0; @@ -1784,7 +1782,7 @@ static void zend_ensure_valid_class_fetch_type(uint32_t fetch_type) /* {{{ */ static bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_ast *class_ast) /* {{{ */ { uint32_t fetch_type; - zval *class_name; + const zval *class_name; if (class_ast->kind != ZEND_AST_ZVAL) { return 0; @@ -1824,7 +1822,7 @@ static bool zend_try_compile_const_expr_resolve_class_name(zval *zv, zend_ast *c /* }}} */ /* We don't use zend_verify_const_access because we need to deal with unlinked classes. */ -static bool zend_verify_ct_const_access(zend_class_constant *c, zend_class_entry *scope) +static bool zend_verify_ct_const_access(const zend_class_constant *c, const zend_class_entry *scope) { if (ZEND_CLASS_CONST_FLAGS(c) & ZEND_ACC_DEPRECATED) { return 0; @@ -1869,7 +1867,7 @@ static bool zend_try_ct_eval_class_const(zval *zv, zend_string *class_name, zend if (class_name_refers_to_active_ce(class_name, fetch_type)) { cc = zend_hash_find_ptr(&CG(active_class_entry)->constants_table, name); } else if (fetch_type == ZEND_FETCH_CLASS_DEFAULT && !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION)) { - zend_class_entry *ce = zend_hash_find_ptr_lc(CG(class_table), class_name); + const zend_class_entry *ce = zend_hash_find_ptr_lc(CG(class_table), class_name); if (ce) { cc = zend_hash_find_ptr(&ce->constants_table, name); } else { @@ -2048,6 +2046,7 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_hand ce->refcount = 1; ce->ce_flags = ZEND_ACC_CONSTANTS_UPDATED; + ce->ce_flags2 = 0; if (CG(compiler_options) & ZEND_COMPILE_GUARDS) { ce->ce_flags |= ZEND_ACC_USE_GUARDS; @@ -2540,7 +2539,7 @@ static uint32_t zend_short_circuiting_checkpoint(void) return zend_stack_count(&CG(short_circuiting_opnums)); } -static void zend_short_circuiting_commit(uint32_t checkpoint, znode *result, zend_ast *ast) +static void zend_short_circuiting_commit(uint32_t checkpoint, znode *result, const zend_ast *ast) { bool is_short_circuited = zend_ast_kind_is_short_circuited(ast->kind) || ast->kind == ZEND_AST_ISSET || ast->kind == ZEND_AST_EMPTY; @@ -2606,7 +2605,7 @@ static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */ zend_hash_index_update_mem( CG(memoized_exprs), (uintptr_t) expr, &memoized_result, sizeof(znode)); } else if (memoize_mode == ZEND_MEMOIZE_FETCH) { - znode *memoized_result = zend_hash_index_find_ptr(CG(memoized_exprs), (uintptr_t) expr); + const znode *memoized_result = zend_hash_index_find_ptr(CG(memoized_exprs), (uintptr_t) expr); *result = *memoized_result; if (result->op_type == IS_CONST) { Z_TRY_ADDREF(result->u.constant); @@ -2618,7 +2617,7 @@ static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */ /* }}} */ static void zend_emit_return_type_check( - znode *expr, zend_arg_info *return_info, bool implicit) /* {{{ */ + znode *expr, const zend_arg_info *return_info, bool implicit) /* {{{ */ { zend_type type = return_info->type; if (ZEND_TYPE_IS_SET(type)) { @@ -2697,7 +2696,7 @@ void zend_emit_final_return(bool return_one) /* {{{ */ return; } - zend_emit_return_type_check(NULL, return_info, 1); + zend_emit_return_type_check(NULL, return_info, true); } zn.op_type = IS_CONST; @@ -2712,7 +2711,7 @@ void zend_emit_final_return(bool return_one) /* {{{ */ } /* }}} */ -static inline bool zend_is_variable(zend_ast *ast) /* {{{ */ +static inline bool zend_is_variable(const zend_ast *ast) /* {{{ */ { return ast->kind == ZEND_AST_VAR || ast->kind == ZEND_AST_DIM @@ -2722,7 +2721,7 @@ static inline bool zend_is_variable(zend_ast *ast) /* {{{ */ } /* }}} */ -static inline bool zend_is_call(zend_ast *ast) /* {{{ */ +static inline bool zend_is_call(const zend_ast *ast) /* {{{ */ { return ast->kind == ZEND_AST_CALL || ast->kind == ZEND_AST_METHOD_CALL @@ -2732,13 +2731,13 @@ static inline bool zend_is_call(zend_ast *ast) /* {{{ */ } /* }}} */ -static inline bool zend_is_variable_or_call(zend_ast *ast) /* {{{ */ +static inline bool zend_is_variable_or_call(const zend_ast *ast) /* {{{ */ { return zend_is_variable(ast) || zend_is_call(ast); } /* }}} */ -static inline bool zend_is_unticked_stmt(zend_ast *ast) /* {{{ */ +static inline bool zend_is_unticked_stmt(const zend_ast *ast) /* {{{ */ { return ast->kind == ZEND_AST_STMT_LIST || ast->kind == ZEND_AST_LABEL || ast->kind == ZEND_AST_PROP_DECL || ast->kind == ZEND_AST_CLASS_CONST_GROUP @@ -2746,7 +2745,7 @@ static inline bool zend_is_unticked_stmt(zend_ast *ast) /* {{{ */ } /* }}} */ -static inline bool zend_can_write_to_variable(zend_ast *ast) /* {{{ */ +static inline bool zend_can_write_to_variable(const zend_ast *ast) /* {{{ */ { while ( ast->kind == ZEND_AST_DIM @@ -2782,7 +2781,7 @@ static inline void zend_handle_numeric_op(znode *node) /* {{{ */ } /* }}} */ -static inline void zend_handle_numeric_dim(zend_op *opline, znode *dim_node) /* {{{ */ +static inline void zend_handle_numeric_dim(const zend_op *opline, znode *dim_node) /* {{{ */ { if (Z_TYPE(dim_node->u.constant) == IS_STRING) { zend_ulong index; @@ -2868,7 +2867,7 @@ static void zend_compile_class_ref(znode *result, zend_ast *name_ast, uint32_t f } /* }}} */ -static zend_result zend_try_compile_cv(znode *result, zend_ast *ast, uint32_t type) /* {{{ */ +static zend_result zend_try_compile_cv(znode *result, const zend_ast *ast, uint32_t type) /* {{{ */ { zend_ast *name_ast = ast->child[0]; if (name_ast->kind == ZEND_AST_ZVAL) { @@ -2909,7 +2908,7 @@ static zend_result zend_try_compile_cv(znode *result, zend_ast *ast, uint32_t ty } /* }}} */ -static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ +static zend_op *zend_compile_simple_var_no_cv(znode *result, const zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ { zend_ast *name_ast = ast->child[0]; znode name_node; @@ -2947,10 +2946,10 @@ static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint } /* }}} */ -static bool is_this_fetch(zend_ast *ast) /* {{{ */ +static bool is_this_fetch(const zend_ast *ast) /* {{{ */ { if (ast->kind == ZEND_AST_VAR && ast->child[0]->kind == ZEND_AST_ZVAL) { - zval *name = zend_ast_get_zval(ast->child[0]); + const zval *name = zend_ast_get_zval(ast->child[0]); return Z_TYPE_P(name) == IS_STRING && zend_string_equals(Z_STR_P(name), ZSTR_KNOWN(ZEND_STR_THIS)); } @@ -2961,25 +2960,25 @@ static bool is_this_fetch(zend_ast *ast) /* {{{ */ static bool is_globals_fetch(const zend_ast *ast) { if (ast->kind == ZEND_AST_VAR && ast->child[0]->kind == ZEND_AST_ZVAL) { - zval *name = zend_ast_get_zval(ast->child[0]); + const zval *name = zend_ast_get_zval(ast->child[0]); return Z_TYPE_P(name) == IS_STRING && zend_string_equals_literal(Z_STR_P(name), "GLOBALS"); } return 0; } -static bool is_global_var_fetch(zend_ast *ast) +static bool is_global_var_fetch(const zend_ast *ast) { return ast->kind == ZEND_AST_DIM && is_globals_fetch(ast->child[0]); } static bool this_guaranteed_exists(void) /* {{{ */ { - zend_oparray_context *ctx = &CG(context); + const 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; + const zend_op_array *op_array = ctx->op_array; if (op_array->fn_flags & ZEND_ACC_STATIC) { return false; } else if (op_array->scope) { @@ -2993,7 +2992,7 @@ static bool this_guaranteed_exists(void) /* {{{ */ } /* }}} */ -static zend_op *zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ +static zend_op *zend_compile_simple_var(znode *result, const zend_ast *ast, uint32_t type, bool delayed) /* {{{ */ { if (is_this_fetch(ast)) { zend_op *opline = zend_emit_op(result, ZEND_FETCH_THIS, NULL, NULL); @@ -3017,7 +3016,7 @@ static zend_op *zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t t } /* }}} */ -static void zend_separate_if_call_and_write(znode *node, zend_ast *ast, uint32_t type) /* {{{ */ +static void zend_separate_if_call_and_write(znode *node, const zend_ast *ast, uint32_t type) /* {{{ */ { if (type != BP_VAR_R && type != BP_VAR_IS @@ -3035,7 +3034,7 @@ static void zend_separate_if_call_and_write(znode *node, zend_ast *ast, uint32_t } /* }}} */ -static inline void zend_emit_assign_znode(zend_ast *var_ast, znode *value_node) /* {{{ */ +static inline void zend_emit_assign_znode(zend_ast *var_ast, const znode *value_node) /* {{{ */ { znode dummy_node; zend_ast *assign_ast = zend_ast_create(ZEND_AST_ASSIGN, var_ast, @@ -3069,7 +3068,7 @@ static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t return opline; } else { zend_short_circuiting_mark_inner(var_ast); - opline = zend_delayed_compile_var(&var_node, var_ast, type, 0); + opline = zend_delayed_compile_var(&var_node, var_ast, type, false); if (opline) { if (type == BP_VAR_W && (opline->opcode == ZEND_FETCH_STATIC_PROP_W || opline->opcode == ZEND_FETCH_OBJ_W)) { opline->extended_value |= ZEND_FETCH_DIM_WRITE; @@ -3137,7 +3136,7 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t * check for a nullsafe access. */ } else { zend_short_circuiting_mark_inner(obj_ast); - opline = zend_delayed_compile_var(&obj_node, obj_ast, type, 0); + opline = zend_delayed_compile_var(&obj_node, obj_ast, type, false); if (opline && (opline->opcode == ZEND_FETCH_DIM_W || opline->opcode == ZEND_FETCH_DIM_RW || opline->opcode == ZEND_FETCH_DIM_FUNC_ARG @@ -3243,7 +3242,7 @@ static zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t } /* }}} */ -static void zend_verify_list_assign_target(zend_ast *var_ast, zend_ast_attr array_style) /* {{{ */ { +static void zend_verify_list_assign_target(const zend_ast *var_ast, zend_ast_attr array_style) /* {{{ */ { if (var_ast->kind == ZEND_AST_ARRAY) { if (var_ast->attr == ZEND_ARRAY_SYNTAX_LONG) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot assign to array(), use [] instead"); @@ -3257,12 +3256,12 @@ static void zend_verify_list_assign_target(zend_ast *var_ast, zend_ast_attr arra } /* }}} */ -static inline void zend_emit_assign_ref_znode(zend_ast *var_ast, znode *value_node); +static inline void zend_emit_assign_ref_znode(zend_ast *var_ast, const znode *value_node); /* Propagate refs used on leaf elements to the surrounding list() structures. */ static bool zend_propagate_list_refs(zend_ast *ast) { /* {{{ */ - zend_ast_list *list = zend_ast_get_list(ast); - bool has_refs = 0; + const zend_ast_list *list = zend_ast_get_list(ast); + bool has_refs = false; uint32_t i; for (i = 0; i < list->children; ++i) { @@ -3281,10 +3280,10 @@ static bool zend_propagate_list_refs(zend_ast *ast) { /* {{{ */ } /* }}} */ -static bool list_is_keyed(zend_ast_list *list) +static bool list_is_keyed(const zend_ast_list *list) { for (uint32_t i = 0; i < list->children; i++) { - zend_ast *child = list->child[i]; + const zend_ast *child = list->child[i]; if (child) { return child->kind == ZEND_AST_ARRAY_ELEM && child->child[1] != NULL; } @@ -3297,7 +3296,7 @@ static void zend_compile_list_assign( { zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; - bool has_elems = 0; + bool has_elems = false; bool is_keyed = list_is_keyed(list); if (list->children && expr_node->op_type == IS_CONST && Z_TYPE(expr_node->u.constant) == IS_STRING) { @@ -3326,7 +3325,7 @@ static void zend_compile_list_assign( var_ast = elem_ast->child[0]; key_ast = elem_ast->child[1]; - has_elems = 1; + has_elems = true; if (is_keyed) { if (key_ast == NULL) { @@ -3405,7 +3404,7 @@ static void zend_ensure_writable_variable(const zend_ast *ast) /* {{{ */ /* }}} */ /* Detects $a... = $a pattern */ -static bool zend_is_assign_to_self(zend_ast *var_ast, zend_ast *expr_ast) /* {{{ */ +static bool zend_is_assign_to_self(const zend_ast *var_ast, const zend_ast *expr_ast) /* {{{ */ { if (expr_ast->kind != ZEND_AST_VAR || expr_ast->child[0]->kind != ZEND_AST_ZVAL) { return 0; @@ -3431,13 +3430,13 @@ static bool zend_is_assign_to_self(zend_ast *var_ast, zend_ast *expr_ast) /* {{{ /* }}} */ static void zend_compile_expr_with_potential_assign_to_self( - znode *expr_node, zend_ast *expr_ast, zend_ast *var_ast) { + znode *expr_node, zend_ast *expr_ast, const zend_ast *var_ast) { if (zend_is_assign_to_self(var_ast, expr_ast) && !is_this_fetch(expr_ast)) { /* $a[0] = $a should evaluate the right $a first */ znode cv_node; if (zend_try_compile_cv(&cv_node, expr_ast, BP_VAR_R) == FAILURE) { - zend_compile_simple_var_no_cv(expr_node, expr_ast, BP_VAR_R, 0); + zend_compile_simple_var_no_cv(expr_node, expr_ast, BP_VAR_R, false); } else { zend_emit_op_tmp(expr_node, ZEND_QM_ASSIGN, &cv_node, NULL); } @@ -3465,7 +3464,7 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */ switch (kind) { case ZEND_AST_VAR: offset = zend_delayed_compile_begin(); - zend_delayed_compile_var(&var_node, var_ast, BP_VAR_W, 0); + zend_delayed_compile_var(&var_node, var_ast, BP_VAR_W, false); zend_compile_expr(&expr_node, expr_ast); zend_delayed_compile_end(offset); CG(zend_lineno) = zend_ast_get_lineno(var_ast); @@ -3473,7 +3472,7 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */ return; case ZEND_AST_STATIC_PROP: offset = zend_delayed_compile_begin(); - zend_delayed_compile_var(result, var_ast, BP_VAR_W, 0); + zend_delayed_compile_var(result, var_ast, BP_VAR_W, false); zend_compile_expr(&expr_node, expr_ast); opline = zend_delayed_compile_end(offset); @@ -3517,7 +3516,7 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */ zend_assert_not_short_circuited(expr_ast); } - zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1); + zend_compile_var(&expr_node, expr_ast, BP_VAR_W, true); /* MAKE_REF is usually not necessary for CVs. However, if there are * self-assignments, this forces the RHS to evaluate first. */ zend_emit_op(&expr_node, ZEND_MAKE_REF, &expr_node, NULL); @@ -3527,7 +3526,7 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */ znode cv_node; if (zend_try_compile_cv(&cv_node, expr_ast, BP_VAR_R) == FAILURE) { - zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, 0); + zend_compile_simple_var_no_cv(&expr_node, expr_ast, BP_VAR_R, false); } else { zend_emit_op_tmp(&expr_node, ZEND_QM_ASSIGN, &cv_node, NULL); } @@ -3562,8 +3561,8 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */ } offset = zend_delayed_compile_begin(); - zend_delayed_compile_var(&target_node, target_ast, BP_VAR_W, 1); - zend_compile_var(&source_node, source_ast, BP_VAR_W, 1); + zend_delayed_compile_var(&target_node, target_ast, BP_VAR_W, true); + zend_compile_var(&source_node, source_ast, BP_VAR_W, true); if ((target_ast->kind != ZEND_AST_VAR || target_ast->child[0]->kind != ZEND_AST_ZVAL) @@ -3605,7 +3604,7 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static inline void zend_emit_assign_ref_znode(zend_ast *var_ast, znode *value_node) /* {{{ */ +static inline void zend_emit_assign_ref_znode(zend_ast *var_ast, const znode *value_node) /* {{{ */ { znode dummy_node; zend_ast *assign_ast = zend_ast_create(ZEND_AST_ASSIGN_REF, var_ast, @@ -3632,7 +3631,7 @@ static void zend_compile_compound_assign(znode *result, zend_ast *ast) /* {{{ */ switch (kind) { case ZEND_AST_VAR: offset = zend_delayed_compile_begin(); - zend_delayed_compile_var(&var_node, var_ast, BP_VAR_RW, 0); + zend_delayed_compile_var(&var_node, var_ast, BP_VAR_RW, false); zend_compile_expr(&expr_node, expr_ast); zend_delayed_compile_end(offset); opline = zend_emit_op_tmp(result, ZEND_ASSIGN_OP, &var_node, &expr_node); @@ -3640,7 +3639,7 @@ static void zend_compile_compound_assign(znode *result, zend_ast *ast) /* {{{ */ return; case ZEND_AST_STATIC_PROP: offset = zend_delayed_compile_begin(); - zend_delayed_compile_var(result, var_ast, BP_VAR_RW, 0); + zend_delayed_compile_var(result, var_ast, BP_VAR_RW, false); zend_compile_expr(&expr_node, expr_ast); opline = zend_delayed_compile_end(offset); @@ -3687,23 +3686,12 @@ static void zend_compile_compound_assign(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static uint32_t zend_get_arg_num(zend_function *fn, zend_string *arg_name) { +static uint32_t zend_get_arg_num(const zend_function *fn, const zend_string *arg_name) { // TODO: Caching? - if (fn->type == ZEND_USER_FUNCTION) { - for (uint32_t i = 0; i < fn->common.num_args; i++) { - zend_arg_info *arg_info = &fn->op_array.arg_info[i]; - if (zend_string_equals(arg_info->name, arg_name)) { - return i + 1; - } - } - } else { - ZEND_ASSERT(fn->common.num_args == 0 || fn->internal_function.arg_info); - for (uint32_t i = 0; i < fn->common.num_args; i++) { - zend_internal_arg_info *arg_info = &fn->internal_function.arg_info[i]; - size_t len = strlen(arg_info->name); - if (zend_string_equals_cstr(arg_name, arg_info->name, len)) { - return i + 1; - } + for (uint32_t i = 0; i < fn->common.num_args; i++) { + zend_arg_info *arg_info = &fn->op_array.arg_info[i]; + if (zend_string_equals(arg_info->name, arg_name)) { + return i + 1; } } @@ -3712,20 +3700,20 @@ static uint32_t zend_get_arg_num(zend_function *fn, zend_string *arg_name) { } static uint32_t zend_compile_args( - zend_ast *ast, zend_function *fbc, bool *may_have_extra_named_args) /* {{{ */ + zend_ast *ast, const zend_function *fbc, bool *may_have_extra_named_args) /* {{{ */ { - zend_ast_list *args = zend_ast_get_list(ast); + const zend_ast_list *args = zend_ast_get_list(ast); uint32_t i; - bool uses_arg_unpack = 0; + bool uses_arg_unpack = false; uint32_t arg_count = 0; /* number of arguments not including unpacks */ /* Whether named arguments are used syntactically, to enforce language level limitations. * May not actually use named argument passing. */ - bool uses_named_args = 0; + bool uses_named_args = false; /* Whether there may be any undef arguments due to the use of named arguments. */ - bool may_have_undef = 0; + bool may_have_undef = false; /* Whether there may be any extra named arguments collected into a variadic. */ - *may_have_extra_named_args = 0; + *may_have_extra_named_args = false; for (i = 0; i < args->children; ++i) { zend_ast *arg = args->child[i]; @@ -3743,12 +3731,12 @@ static uint32_t zend_compile_args( } /* Unpack may contain named arguments. */ - may_have_undef = 1; + may_have_undef = true; if (!fbc || (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) { - *may_have_extra_named_args = 1; + *may_have_extra_named_args = true; } - uses_arg_unpack = 1; + uses_arg_unpack = true; fbc = NULL; zend_compile_expr(&arg_node, arg->child[0]); @@ -3760,7 +3748,7 @@ static uint32_t zend_compile_args( } if (arg->kind == ZEND_AST_NAMED_ARG) { - uses_named_args = 1; + uses_named_args = true; arg_name = zval_make_interned_string(zend_ast_get_zval(arg->child[0])); arg = arg->child[1]; @@ -3772,15 +3760,15 @@ static uint32_t zend_compile_args( arg_count++; } else { // TODO: We could track which arguments were passed, even if out of order. - may_have_undef = 1; + may_have_undef = true; if (arg_num == (uint32_t) -1 && (fbc->common.fn_flags & ZEND_ACC_VARIADIC)) { - *may_have_extra_named_args = 1; + *may_have_extra_named_args = true; } } } else { arg_num = (uint32_t) -1; - may_have_undef = 1; - *may_have_extra_named_args = 1; + may_have_undef = true; + *may_have_extra_named_args = true; } } else { if (uses_arg_unpack) { @@ -3799,7 +3787,7 @@ static uint32_t zend_compile_args( /* Treat passing of $GLOBALS the same as passing a call. * This will error at runtime if the argument is by-ref. */ if (zend_is_call(arg) || is_globals_fetch(arg)) { - zend_compile_var(&arg_node, arg, BP_VAR_R, 0); + zend_compile_var(&arg_node, arg, BP_VAR_R, false); if (arg_node.op_type & (IS_CONST|IS_TMP_VAR)) { /* Function call was converted into builtin instruction */ if (!fbc || ARG_MUST_BE_SENT_BY_REF(fbc, arg_num)) { @@ -3826,10 +3814,10 @@ static uint32_t zend_compile_args( } else if (zend_is_variable(arg) && !zend_ast_is_short_circuited(arg)) { if (fbc && arg_num != (uint32_t) -1) { if (ARG_SHOULD_BE_SENT_BY_REF(fbc, arg_num)) { - zend_compile_var(&arg_node, arg, BP_VAR_W, 1); + zend_compile_var(&arg_node, arg, BP_VAR_W, true); opcode = ZEND_SEND_REF; } else { - zend_compile_var(&arg_node, arg, BP_VAR_R, 0); + zend_compile_var(&arg_node, arg, BP_VAR_R, false); opcode = (arg_node.op_type == IS_TMP_VAR) ? ZEND_SEND_VAL : ZEND_SEND_VAR; } } else { @@ -3855,7 +3843,7 @@ static uint32_t zend_compile_args( } else { opline->op2.num = arg_num; } - zend_compile_var(&arg_node, arg, BP_VAR_FUNC_ARG, 1); + zend_compile_var(&arg_node, arg, BP_VAR_FUNC_ARG, true); opcode = ZEND_SEND_FUNC_ARG; } while (0); } @@ -3914,7 +3902,7 @@ static uint32_t zend_compile_args( } /* }}} */ -ZEND_API uint8_t zend_get_call_op(const zend_op *init_op, zend_function *fbc, bool result_used) /* {{{ */ +ZEND_API uint8_t zend_get_call_op(const zend_op *init_op, const zend_function *fbc, bool result_used) /* {{{ */ { uint32_t no_discard = result_used ? 0 : ZEND_ACC_NODISCARD; @@ -3947,7 +3935,7 @@ ZEND_API uint8_t zend_get_call_op(const zend_op *init_op, zend_function *fbc, bo } /* }}} */ -static bool zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *fbc, uint32_t lineno) /* {{{ */ +static bool zend_compile_call_common(znode *result, zend_ast *args_ast, const zend_function *fbc, uint32_t lineno) /* {{{ */ { zend_op *opline; uint32_t opnum_init = get_next_op_number() - 1; @@ -3955,16 +3943,25 @@ static bool zend_compile_call_common(znode *result, zend_ast *args_ast, zend_fun if (args_ast->kind == ZEND_AST_CALLABLE_CONVERT) { opline = &CG(active_op_array)->opcodes[opnum_init]; opline->extended_value = 0; + /* opcode array may be reallocated, so don't access opcode field after zend_emit_op_tmp(). */ + uint8_t opcode = opline->opcode; - if (opline->opcode == ZEND_NEW) { - zend_error_noreturn(E_COMPILE_ERROR, "Cannot create Closure for new expression"); + if (opcode == ZEND_NEW) { + zend_error_noreturn(E_COMPILE_ERROR, "Cannot create Closure for new expression"); } - if (opline->opcode == ZEND_INIT_FCALL) { + if (opcode == ZEND_INIT_FCALL) { opline->op1.num = zend_vm_calc_used_stack(0, fbc); } - zend_emit_op_tmp(result, ZEND_CALLABLE_CONVERT, NULL, NULL); + zend_op *callable_convert_op = zend_emit_op_tmp(result, ZEND_CALLABLE_CONVERT, NULL, NULL); + if (opcode == ZEND_INIT_FCALL + || opcode == ZEND_INIT_FCALL_BY_NAME + || opcode == ZEND_INIT_NS_FCALL_BY_NAME) { + callable_convert_op->extended_value = zend_alloc_cache_slot(); + } else { + callable_convert_op->extended_value = (uint32_t)-1; + } return true; } @@ -4046,11 +4043,11 @@ static void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast } /* }}} */ -static inline bool zend_args_contain_unpack_or_named(zend_ast_list *args) /* {{{ */ +static inline bool zend_args_contain_unpack_or_named(const zend_ast_list *args) /* {{{ */ { uint32_t i; for (i = 0; i < args->children; ++i) { - zend_ast *arg = args->child[i]; + const zend_ast *arg = args->child[i]; if (arg->kind == ZEND_AST_UNPACK || arg->kind == ZEND_AST_NAMED_ARG) { return 1; } @@ -4059,7 +4056,7 @@ static inline bool zend_args_contain_unpack_or_named(zend_ast_list *args) /* {{{ } /* }}} */ -static zend_result zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_strlen(znode *result, const zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -4079,7 +4076,7 @@ static zend_result zend_compile_func_strlen(znode *result, zend_ast_list *args) } /* }}} */ -static zend_result zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +static zend_result zend_compile_func_typecheck(znode *result, const zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -4099,7 +4096,7 @@ static zend_result zend_compile_func_typecheck(znode *result, zend_ast_list *arg } /* }}} */ -static zend_result zend_compile_func_is_scalar(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_is_scalar(znode *result, const zend_ast_list *args) /* {{{ */ { znode arg_node; zend_op *opline; @@ -4114,7 +4111,7 @@ static zend_result zend_compile_func_is_scalar(znode *result, zend_ast_list *arg return SUCCESS; } -static zend_result zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /* {{{ */ +static zend_result zend_compile_func_cast(znode *result, const zend_ast_list *args, uint32_t type) /* {{{ */ { znode arg_node; zend_op *opline; @@ -4134,7 +4131,7 @@ static zend_result zend_compile_func_cast(znode *result, zend_ast_list *args, ui } /* }}} */ -static zend_result zend_compile_func_defined(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_defined(znode *result, const zend_ast_list *args) /* {{{ */ { zend_string *name; zend_op *opline; @@ -4149,7 +4146,7 @@ static zend_result zend_compile_func_defined(znode *result, zend_ast_list *args) return FAILURE; } - if (zend_try_ct_eval_const(&result->u.constant, name, 0)) { + if (zend_try_ct_eval_const(&result->u.constant, name, false)) { zend_string_release_ex(name, 0); zval_ptr_dtor(&result->u.constant); ZVAL_TRUE(&result->u.constant); @@ -4208,11 +4205,11 @@ static zend_result zend_compile_func_ord(znode *result, const zend_ast_list *arg /* We can only calculate the stack size for functions that have been fully compiled, otherwise * additional CV or TMP slots may still be added. This prevents the use of INIT_FCALL for * directly or indirectly recursive function calls. */ -static bool fbc_is_finalized(zend_function *fbc) { +static bool fbc_is_finalized(const zend_function *fbc) { return !ZEND_USER_CODE(fbc->type) || (fbc->common.fn_flags & ZEND_ACC_DONE_PASS_TWO); } -static bool zend_compile_ignore_class(zend_class_entry *ce, zend_string *filename) +static bool zend_compile_ignore_class(const zend_class_entry *ce, const zend_string *filename) { if (ce->type == ZEND_INTERNAL_CLASS) { return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_CLASSES; @@ -4222,7 +4219,7 @@ static bool zend_compile_ignore_class(zend_class_entry *ce, zend_string *filenam } } -static bool zend_compile_ignore_function(zend_function *fbc, zend_string *filename) +static bool zend_compile_ignore_function(const zend_function *fbc, const zend_string *filename) { if (fbc->type == ZEND_INTERNAL_FUNCTION) { return CG(compiler_options) & ZEND_COMPILE_IGNORE_INTERNAL_FUNCTIONS; @@ -4337,7 +4334,7 @@ static zend_result zend_compile_func_cufa(znode *result, zend_ast_list *args, ze /* }}} */ /* cuf = call_user_func */ -static zend_result zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +static zend_result zend_compile_func_cuf(znode *result, const zend_ast_list *args, zend_string *lcname) /* {{{ */ { uint32_t i; @@ -4363,7 +4360,7 @@ static zend_result zend_compile_func_cuf(znode *result, zend_ast_list *args, zen } /* }}} */ -static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string *name, zend_function *fbc, uint32_t lineno) /* {{{ */ +static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string *name, const zend_function *fbc, uint32_t lineno) /* {{{ */ { if (EG(assertions) >= 0) { znode name_node; @@ -4415,7 +4412,7 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string static zend_result zend_compile_func_in_array(znode *result, zend_ast_list *args) /* {{{ */ { - bool strict = 0; + bool strict = false; znode array, needly; zend_op *opline; @@ -4450,7 +4447,7 @@ static zend_result zend_compile_func_in_array(znode *result, zend_ast_list *args } if (zend_hash_num_elements(Z_ARRVAL(array.u.constant)) > 0) { - bool ok = 1; + bool ok = true; zval *val, tmp; HashTable *src = Z_ARRVAL(array.u.constant); HashTable *dst = zend_new_array(zend_hash_num_elements(src)); @@ -4465,7 +4462,7 @@ static zend_result zend_compile_func_in_array(znode *result, zend_ast_list *args zend_hash_index_add(dst, Z_LVAL_P(val), &tmp); } else { zend_array_destroy(dst); - ok = 0; + ok = false; break; } } ZEND_HASH_FOREACH_END(); @@ -4474,7 +4471,7 @@ static zend_result zend_compile_func_in_array(znode *result, zend_ast_list *args if (Z_TYPE_P(val) != IS_STRING || is_numeric_string(Z_STRVAL_P(val), Z_STRLEN_P(val), NULL, NULL, 0)) { zend_array_destroy(dst); - ok = 0; + ok = false; break; } zend_hash_add(dst, Z_STR_P(val), &tmp); @@ -4498,7 +4495,7 @@ static zend_result zend_compile_func_in_array(znode *result, zend_ast_list *args } /* }}} */ -static zend_result zend_compile_func_count(znode *result, zend_ast_list *args, zend_string *lcname) /* {{{ */ +static zend_result zend_compile_func_count(znode *result, const zend_ast_list *args, const zend_string *lcname) /* {{{ */ { znode arg_node; zend_op *opline; @@ -4515,7 +4512,7 @@ static zend_result zend_compile_func_count(znode *result, zend_ast_list *args, z } /* }}} */ -static zend_result zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_get_class(znode *result, const zend_ast_list *args) /* {{{ */ { if (args->children == 0) { zend_emit_op_tmp(result, ZEND_GET_CLASS, NULL, NULL); @@ -4533,7 +4530,7 @@ static zend_result zend_compile_func_get_class(znode *result, zend_ast_list *arg } /* }}} */ -static zend_result zend_compile_func_get_called_class(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_get_called_class(znode *result, const zend_ast_list *args) /* {{{ */ { if (args->children != 0) { return FAILURE; @@ -4544,7 +4541,7 @@ static zend_result zend_compile_func_get_called_class(znode *result, zend_ast_li } /* }}} */ -static zend_result zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_gettype(znode *result, const zend_ast_list *args) /* {{{ */ { znode arg_node; @@ -4558,7 +4555,7 @@ static zend_result zend_compile_func_gettype(znode *result, zend_ast_list *args) } /* }}} */ -static zend_result zend_compile_func_num_args(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_num_args(znode *result, const zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_NUM_ARGS, NULL, NULL); @@ -4569,7 +4566,7 @@ static zend_result zend_compile_func_num_args(znode *result, zend_ast_list *args } /* }}} */ -static zend_result zend_compile_func_get_args(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_get_args(znode *result, const zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 0) { zend_emit_op_tmp(result, ZEND_FUNC_GET_ARGS, NULL, NULL); @@ -4580,7 +4577,7 @@ static zend_result zend_compile_func_get_args(znode *result, zend_ast_list *args } /* }}} */ -static zend_result zend_compile_func_array_key_exists(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_array_key_exists(znode *result, const zend_ast_list *args) /* {{{ */ { znode subject, needle; @@ -4596,7 +4593,7 @@ static zend_result zend_compile_func_array_key_exists(znode *result, zend_ast_li } /* }}} */ -static zend_result zend_compile_func_array_slice(znode *result, zend_ast_list *args) /* {{{ */ +static zend_result zend_compile_func_array_slice(znode *result, const zend_ast_list *args) /* {{{ */ { if (CG(active_op_array)->function_name && args->children == 2 @@ -4609,8 +4606,8 @@ static zend_result zend_compile_func_array_slice(znode *result, zend_ast_list *a zend_string *orig_name = zend_ast_get_str(args->child[0]->child[0]); bool is_fully_qualified; zend_string *name = zend_resolve_function_name(orig_name, args->child[0]->child[0]->attr, &is_fully_qualified); - zend_ast_list *list = zend_ast_get_list(args->child[0]->child[1]); - zval *zv = zend_ast_get_zval(args->child[1]); + const zend_ast_list *list = zend_ast_get_list(args->child[0]->child[1]); + const zval *zv = zend_ast_get_zval(args->child[1]); znode first; if (zend_string_equals_literal_ci(name, "func_get_args") @@ -4629,7 +4626,7 @@ static zend_result zend_compile_func_array_slice(znode *result, zend_ast_list *a } /* }}} */ -static uint32_t find_frameless_function_offset(uint32_t arity, void *handler) +static uint32_t find_frameless_function_offset(uint32_t arity, const void *handler) { void **handlers = zend_flf_handlers; void **current = handlers; @@ -4643,7 +4640,7 @@ static uint32_t find_frameless_function_offset(uint32_t arity, void *handler) return (uint32_t)-1; } -static const zend_frameless_function_info *find_frameless_function_info(zend_ast_list *args, zend_function *fbc, uint32_t type) +static const zend_frameless_function_info *find_frameless_function_info(const zend_ast_list *args, const zend_function *fbc, uint32_t type) { if (zend_execute_internal) { return NULL; @@ -4684,9 +4681,9 @@ static const zend_frameless_function_info *find_frameless_function_info(zend_ast return NULL; } -static uint32_t zend_compile_frameless_icall_ex(znode *result, zend_ast_list *args, zend_function *fbc, const zend_frameless_function_info *frameless_function_info, uint32_t type) +static uint32_t zend_compile_frameless_icall_ex(znode *result, const zend_ast_list *args, const zend_function *fbc, const zend_frameless_function_info *frameless_function_info, uint32_t type) { - int lineno = CG(zend_lineno); + uint32_t lineno = CG(zend_lineno); uint32_t num_args = frameless_function_info->num_args; uint32_t offset = find_frameless_function_offset(num_args, frameless_function_info->handler); znode arg_zvs[3]; @@ -4694,7 +4691,7 @@ static uint32_t zend_compile_frameless_icall_ex(znode *result, zend_ast_list *ar if (i < args->children) { zend_compile_expr(&arg_zvs[i], args->child[i]); } else { - zend_internal_arg_info *arg_info = (zend_internal_arg_info *)&fbc->common.arg_info[i]; + const zend_arg_info *arg_info = &fbc->common.arg_info[i]; arg_zvs[i].op_type = IS_CONST; if (zend_get_default_from_internal_arg_info(&arg_zvs[i].u.constant, arg_info) == FAILURE) { ZEND_UNREACHABLE(); @@ -4718,7 +4715,7 @@ static uint32_t zend_compile_frameless_icall_ex(znode *result, zend_ast_list *ar return opnum; } -static uint32_t zend_compile_frameless_icall(znode *result, zend_ast_list *args, zend_function *fbc, uint32_t type) +static uint32_t zend_compile_frameless_icall(znode *result, const zend_ast_list *args, const zend_function *fbc, uint32_t type) { const zend_frameless_function_info *frameless_function_info = find_frameless_function_info(args, fbc, type); if (!frameless_function_info) { @@ -4728,12 +4725,12 @@ static uint32_t zend_compile_frameless_icall(znode *result, zend_ast_list *args, return zend_compile_frameless_icall_ex(result, args, fbc, frameless_function_info, type); } -static void zend_compile_ns_call(znode *result, znode *name_node, zend_ast *args_ast, uint32_t lineno, uint32_t type) /* {{{ */ +static void zend_compile_ns_call(znode *result, const znode *name_node, zend_ast *args_ast, uint32_t lineno, uint32_t type) /* {{{ */ { int name_constants = zend_add_ns_func_name_literal(Z_STR(name_node->u.constant)); /* Find frameless function with same name. */ - zend_function *frameless_function = NULL; + const zend_function *frameless_function = NULL; if (args_ast->kind != ZEND_AST_CALLABLE_CONVERT && !zend_args_contain_unpack_or_named(zend_ast_get_list(args_ast)) /* Avoid blowing up op count with nested frameless branches. */ @@ -4958,7 +4955,62 @@ static zend_result zend_compile_func_sprintf(znode *result, zend_ast_list *args) return SUCCESS; } -static zend_result zend_compile_func_clone(znode *result, zend_ast_list *args) +static zend_result zend_compile_func_printf(znode *result, zend_ast_list *args) /* {{{ */ +{ + /* Special case: printf with a single constant string argument and no format specifiers. + * In this case, just emit ECHO and return the string length if needed. */ + if (args->children == 1) { + zend_eval_const_expr(&args->child[0]); + if (args->child[0]->kind != ZEND_AST_ZVAL) { + return FAILURE; + } + zval *format_string = zend_ast_get_zval(args->child[0]); + if (Z_TYPE_P(format_string) != IS_STRING) { + return FAILURE; + } + /* Check if there are any format specifiers */ + if (!memchr(Z_STRVAL_P(format_string), '%', Z_STRLEN_P(format_string))) { + /* No format specifiers - just emit ECHO and return string length */ + znode format_node; + zend_compile_expr(&format_node, args->child[0]); + zend_emit_op(NULL, ZEND_ECHO, &format_node, NULL); + + /* Return the string length as a constant if the result is used */ + result->op_type = IS_CONST; + ZVAL_LONG(&result->u.constant, Z_STRLEN_P(format_string)); + return SUCCESS; + } + } + + /* Fall back to sprintf optimization for format strings with specifiers */ + znode rope_result; + if (zend_compile_func_sprintf(&rope_result, args) != SUCCESS) { + return FAILURE; + } + + /* printf() returns the amount of bytes written, so just an ECHO of the + * resulting sprintf() optimisation might not be enough. At this early + * stage we can't detect if the result is actually used, so we just emit + * the opcodes and let them be cleaned up by the dead code elimination + * pass in the Zend Optimizer if the result of the printf() is in fact + * unused */ + znode copy; + if (rope_result.op_type != IS_CONST) { + /* Note: ZEND_COPY_TMP is only valid for TMPVAR. */ + ZEND_ASSERT(rope_result.op_type == IS_TMP_VAR); + zend_emit_op_tmp(©, ZEND_COPY_TMP, &rope_result, NULL); + zend_emit_op(NULL, ZEND_ECHO, &rope_result, NULL); + zend_emit_op_tmp(result, ZEND_STRLEN, ©, NULL); + } else { + zend_emit_op(NULL, ZEND_ECHO, &rope_result, NULL); + result->op_type = IS_CONST; + ZVAL_LONG(&result->u.constant, Z_STRLEN(rope_result.u.constant)); + } + + return SUCCESS; +} + +static zend_result zend_compile_func_clone(znode *result, const zend_ast_list *args) { znode arg_node; @@ -4972,7 +5024,7 @@ static zend_result zend_compile_func_clone(znode *result, zend_ast_list *args) return SUCCESS; } -static zend_result zend_try_compile_special_func_ex(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ +static zend_result zend_try_compile_special_func_ex(znode *result, zend_string *lcname, zend_ast_list *args, uint32_t type) /* {{{ */ { if (zend_string_equals_literal(lcname, "strlen")) { return zend_compile_func_strlen(result, args); @@ -5040,6 +5092,8 @@ static zend_result zend_try_compile_special_func_ex(znode *result, zend_string * return zend_compile_func_array_key_exists(result, args); } else if (zend_string_equals_literal(lcname, "sprintf")) { return zend_compile_func_sprintf(result, args); + } else if (zend_string_equals_literal(lcname, "printf")) { + return zend_compile_func_printf(result, args); } else if (zend_string_equals(lcname, ZSTR_KNOWN(ZEND_STR_CLONE))) { return zend_compile_func_clone(result, args); } else { @@ -5047,7 +5101,7 @@ static zend_result zend_try_compile_special_func_ex(znode *result, zend_string * } } -static zend_result zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */ +static zend_result zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_list *args, const zend_function *fbc, uint32_t type) /* {{{ */ { if (CG(compiler_options) & ZEND_COMPILE_NO_BUILTINS) { return FAILURE; @@ -5063,7 +5117,7 @@ static zend_result zend_try_compile_special_func(znode *result, zend_string *lcn return FAILURE; } - if (zend_try_compile_special_func_ex(result, lcname, args, fbc, type) == SUCCESS) { + if (zend_try_compile_special_func_ex(result, lcname, args, type) == SUCCESS) { return SUCCESS; } @@ -5090,11 +5144,11 @@ static zend_string *zend_copy_unmangled_prop_name(zend_string *prop_name) } } -static bool zend_compile_parent_property_hook_call(znode *result, zend_ast *ast, uint32_t type) +static bool zend_compile_parent_property_hook_call(znode *result, const zend_ast *ast, uint32_t type) { ZEND_ASSERT(ast->kind == ZEND_AST_STATIC_CALL); - zend_ast *class_ast = ast->child[0]; + const zend_ast *class_ast = ast->child[0]; zend_ast *method_ast = ast->child[1]; /* Recognize parent::$prop::get() pattern. */ @@ -5149,13 +5203,12 @@ static bool zend_compile_parent_property_hook_call(znode *result, zend_ast *ast, opline->op1.constant = zend_add_literal_string(&property_name); opline->op2.num = hook_kind; - zend_function *fbc = NULL; - zend_compile_call_common(result, args_ast, fbc, zend_ast_get_lineno(method_ast)); + zend_compile_call_common(result, args_ast, NULL, zend_ast_get_lineno(method_ast)); return true; } -static void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{{ */ +static void zend_compile_call(znode *result, const zend_ast *ast, uint32_t type) /* {{{ */ { zend_ast *name_ast = ast->child[0]; zend_ast *args_ast = ast->child[1]; @@ -5183,14 +5236,11 @@ static void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{ } { - zval *name = &name_node.u.constant; - zend_string *lcname; - zend_function *fbc; - zend_op *opline; - - lcname = zend_string_tolower(Z_STR_P(name)); + const zval *name = &name_node.u.constant; + zend_string *lcname = zend_string_tolower(Z_STR_P(name)); zval *fbc_zv = zend_hash_find(CG(function_table), lcname); - fbc = fbc_zv ? Z_PTR_P(fbc_zv) : NULL; + const zend_function *fbc = fbc_zv ? Z_PTR_P(fbc_zv) : NULL; + zend_op *opline; /* Special assert() handling should apply independently of compiler flags. */ if (fbc && zend_string_equals_literal(lcname, "assert") && !is_callable_convert) { @@ -5225,7 +5275,7 @@ static void zend_compile_call(znode *result, zend_ast *ast, uint32_t type) /* {{ /* Store offset to function from symbol table in op2.extra. */ if (fbc->type == ZEND_INTERNAL_FUNCTION) { - Bucket *fbc_bucket = (Bucket*)((uintptr_t)fbc_zv - XtOffsetOf(Bucket, val)); + const Bucket *fbc_bucket = (const Bucket*)((uintptr_t)fbc_zv - XtOffsetOf(Bucket, val)); Z_EXTRA_P(CT_CONSTANT(opline->op2)) = fbc_bucket - CG(function_table)->arData; } @@ -5242,7 +5292,7 @@ static void zend_compile_method_call(znode *result, zend_ast *ast, uint32_t type znode obj_node, method_node; zend_op *opline; - zend_function *fbc = NULL; + const zend_function *fbc = NULL; bool nullsafe = ast->kind == ZEND_AST_NULLSAFE_METHOD_CALL; uint32_t short_circuiting_checkpoint = zend_short_circuiting_checkpoint(); @@ -5302,23 +5352,33 @@ static void zend_compile_method_call(znode *result, zend_ast *ast, uint32_t type } /* }}} */ -static bool zend_is_constructor(zend_string *name) /* {{{ */ +static bool zend_is_constructor(const zend_string *name) /* {{{ */ { return zend_string_equals_literal_ci(name, ZEND_CONSTRUCTOR_FUNC_NAME); } /* }}} */ -static zend_function *zend_get_compatible_func_or_null(zend_class_entry *ce, zend_string *lcname) /* {{{ */ +static bool is_func_accessible(const zend_function *fbc) { - zend_function *fbc = zend_hash_find_ptr(&ce->function_table, lcname); - if (!fbc || (fbc->common.fn_flags & ZEND_ACC_PUBLIC) || ce == CG(active_class_entry)) { - return fbc; + if ((fbc->common.fn_flags & ZEND_ACC_PUBLIC) || fbc->common.scope == CG(active_class_entry)) { + return true; } if (!(fbc->common.fn_flags & ZEND_ACC_PRIVATE) && (fbc->common.scope->ce_flags & ZEND_ACC_LINKED) && (!CG(active_class_entry) || (CG(active_class_entry)->ce_flags & ZEND_ACC_LINKED)) && zend_check_protected(zend_get_function_root_class(fbc), CG(active_class_entry))) { + return true; + } + + return false; +} + +static const zend_function *zend_get_compatible_func_or_null(const zend_class_entry *ce, zend_string *lcname) /* {{{ */ +{ + const zend_function *fbc = zend_hash_find_ptr(&ce->function_table, lcname); + + if (!fbc || is_func_accessible(fbc)) { return fbc; } @@ -5334,7 +5394,7 @@ static void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type znode class_node, method_node; zend_op *opline; - zend_function *fbc = NULL; + const zend_function *fbc = NULL; if (zend_compile_parent_property_hook_call(result, ast, type)) { return; @@ -5402,7 +5462,7 @@ static void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type } /* }}} */ -static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel); +static void zend_compile_class_decl(znode *result, const zend_ast *ast, bool toplevel); static void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */ { @@ -5414,23 +5474,47 @@ static void zend_compile_new(znode *result, zend_ast *ast) /* {{{ */ if (class_ast->kind == ZEND_AST_CLASS) { /* anon class declaration */ - zend_compile_class_decl(&class_node, class_ast, 0); + zend_compile_class_decl(&class_node, class_ast, false); } else { zend_compile_class_ref(&class_node, class_ast, ZEND_FETCH_CLASS_EXCEPTION); } opline = zend_emit_op(result, ZEND_NEW, NULL, NULL); - if (class_node.op_type == IS_CONST) { - opline->op1_type = IS_CONST; - opline->op1.constant = zend_add_class_name_literal( - Z_STR(class_node.u.constant)); + zend_set_class_name_op1(opline, &class_node); + + if (opline->op1_type == IS_CONST) { opline->op2.num = zend_alloc_cache_slot(); - } else { - SET_NODE(opline->op1, &class_node); } - zend_compile_call_common(&ctor_result, args_ast, NULL, ast->lineno); + zend_class_entry *ce = NULL; + if (opline->op1_type == IS_CONST) { + zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op1) + 1); + ce = zend_hash_find_ptr(CG(class_table), lcname); + if (ce) { + if (zend_compile_ignore_class(ce, CG(active_op_array)->filename)) { + ce = NULL; + } + } else if (CG(active_class_entry) + && zend_string_equals_ci(CG(active_class_entry)->name, lcname)) { + ce = CG(active_class_entry); + } + } else if (opline->op1_type == IS_UNUSED + && (opline->op1.num & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_SELF + && zend_is_scope_known()) { + ce = CG(active_class_entry); + } + + + const zend_function *fbc = NULL; + if (ce + && ce->default_object_handlers->get_constructor == zend_std_get_constructor + && ce->constructor + && is_func_accessible(ce->constructor)) { + fbc = ce->constructor; + } + + zend_compile_call_common(&ctor_result, args_ast, fbc, ast->lineno); zend_do_free(&ctor_result); } /* }}} */ @@ -5549,7 +5633,7 @@ static void zend_compile_static_var(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_unset(zend_ast *ast) /* {{{ */ +static void zend_compile_unset(const zend_ast *ast) /* {{{ */ { zend_ast *var_ast = ast->child[0]; znode var_node; @@ -5579,7 +5663,7 @@ static void zend_compile_unset(zend_ast *ast) /* {{{ */ } else if (zend_try_compile_cv(&var_node, var_ast, BP_VAR_UNSET) == SUCCESS) { opline = zend_emit_op(NULL, ZEND_UNSET_CV, &var_node, NULL); } else { - opline = zend_compile_simple_var_no_cv(NULL, var_ast, BP_VAR_UNSET, 0); + opline = zend_compile_simple_var_no_cv(NULL, var_ast, BP_VAR_UNSET, false); opline->opcode = ZEND_UNSET_VAR; } return; @@ -5589,11 +5673,11 @@ static void zend_compile_unset(zend_ast *ast) /* {{{ */ return; case ZEND_AST_PROP: case ZEND_AST_NULLSAFE_PROP: - opline = zend_compile_prop(NULL, var_ast, BP_VAR_UNSET, 0); + opline = zend_compile_prop(NULL, var_ast, BP_VAR_UNSET, false); opline->opcode = ZEND_UNSET_OBJ; return; case ZEND_AST_STATIC_PROP: - opline = zend_compile_static_prop(NULL, var_ast, BP_VAR_UNSET, 0, 0); + opline = zend_compile_static_prop(NULL, var_ast, BP_VAR_UNSET, false, false); opline->opcode = ZEND_UNSET_STATIC_PROP; return; EMPTY_SWITCH_DEFAULT_CASE() @@ -5603,7 +5687,7 @@ static void zend_compile_unset(zend_ast *ast) /* {{{ */ static bool zend_handle_loops_and_finally_ex(zend_long depth, znode *return_value) /* {{{ */ { - zend_loop_var *base; + const zend_loop_var *base; zend_loop_var *loop_var = zend_stack_top(&CG(loop_var_stack)); if (!loop_var) { @@ -5658,7 +5742,7 @@ static bool zend_handle_loops_and_finally(znode *return_value) /* {{{ */ static bool zend_has_finally_ex(zend_long depth) /* {{{ */ { - zend_loop_var *base; + const zend_loop_var *base; zend_loop_var *loop_var = zend_stack_top(&CG(loop_var_stack)); if (!loop_var) { @@ -5688,7 +5772,7 @@ static bool zend_has_finally(void) /* {{{ */ } /* }}} */ -static void zend_compile_return(zend_ast *ast) /* {{{ */ +static void zend_compile_return(const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; bool is_generator = (CG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) != 0; @@ -5699,7 +5783,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */ if (is_generator) { /* For generators the by-ref flag refers to yields, not returns */ - by_ref = 0; + by_ref = false; } if (!expr_ast) { @@ -5707,7 +5791,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */ ZVAL_NULL(&expr_node.u.constant); } else if (by_ref && zend_is_variable(expr_ast)) { zend_assert_not_short_circuited(expr_ast); - zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1); + zend_compile_var(&expr_node, expr_ast, BP_VAR_W, true); } else { zend_compile_expr(&expr_node, expr_ast); } @@ -5726,7 +5810,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */ /* Generator return types are handled separately */ if (!is_generator && (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) { zend_emit_return_type_check( - expr_ast ? &expr_node : NULL, CG(active_op_array)->arg_info - 1, 0); + expr_ast ? &expr_node : NULL, CG(active_op_array)->arg_info - 1, false); } uint32_t opnum_before_finally = get_next_op_number(); @@ -5740,7 +5824,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */ && !is_generator && (CG(active_op_array)->fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) { zend_emit_return_type_check( - expr_ast ? &expr_node : NULL, CG(active_op_array)->arg_info - 1, 0); + expr_ast ? &expr_node : NULL, CG(active_op_array)->arg_info - 1, false); } opline = zend_emit_op(NULL, by_ref ? ZEND_RETURN_BY_REF : ZEND_RETURN, @@ -5756,7 +5840,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_void_cast(znode *result, zend_ast *ast) +static void zend_compile_void_cast(znode *result, const zend_ast *ast) { zend_ast *expr_ast = ast->child[0]; znode expr_node; @@ -5776,7 +5860,7 @@ static void zend_compile_void_cast(znode *result, zend_ast *ast) } } -static void zend_compile_echo(zend_ast *ast) /* {{{ */ +static void zend_compile_echo(const zend_ast *ast) /* {{{ */ { zend_op *opline; zend_ast *expr_ast = ast->child[0]; @@ -5789,7 +5873,7 @@ static void zend_compile_echo(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_throw(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_throw(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; @@ -5806,7 +5890,7 @@ static void zend_compile_throw(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_break_continue(zend_ast *ast) /* {{{ */ +static void zend_compile_break_continue(const zend_ast *ast) /* {{{ */ { zend_ast *depth_ast = ast->child[0]; @@ -5816,7 +5900,7 @@ static void zend_compile_break_continue(zend_ast *ast) /* {{{ */ ZEND_ASSERT(ast->kind == ZEND_AST_BREAK || ast->kind == ZEND_AST_CONTINUE); if (depth_ast) { - zval *depth_zv; + const zval *depth_zv; if (depth_ast->kind != ZEND_AST_ZVAL) { zend_error_noreturn(E_COMPILE_ERROR, "'%s' operator with non-integer operand " "is no longer supported", ast->kind == ZEND_AST_BREAK ? "break" : "continue"); @@ -5886,7 +5970,7 @@ static void zend_compile_break_continue(zend_ast *ast) /* {{{ */ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline) /* {{{ */ { zend_label *dest; - int current, remove_oplines = opline->op1.num; + int remove_oplines = opline->op1.num; zval *label; uint32_t opnum = opline - op_array->opcodes; @@ -5903,7 +5987,7 @@ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline) /* {{{ */ zval_ptr_dtor_str(label); ZVAL_NULL(label); - current = opline->extended_value; + uint32_t current = opline->extended_value; for (; current != dest->brk_cont; current = CG(context).brk_cont_array[current].parent) { if (current == -1) { CG(in_compilation) = 1; @@ -5917,7 +6001,7 @@ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline) /* {{{ */ } for (current = 0; current < op_array->last_try_catch; ++current) { - zend_try_catch_element *elem = &op_array->try_catch_array[current]; + const zend_try_catch_element *elem = &op_array->try_catch_array[current]; if (elem->try_op > opnum) { break; } @@ -5944,7 +6028,7 @@ void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline) /* {{{ */ } /* }}} */ -static void zend_compile_goto(zend_ast *ast) /* {{{ */ +static void zend_compile_goto(const zend_ast *ast) /* {{{ */ { zend_ast *label_ast = ast->child[0]; znode label_node; @@ -5961,7 +6045,7 @@ static void zend_compile_goto(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_label(zend_ast *ast) /* {{{ */ +static void zend_compile_label(const zend_ast *ast) /* {{{ */ { zend_string *label = zend_ast_get_str(ast->child[0]); zend_label dest; @@ -5980,7 +6064,7 @@ static void zend_compile_label(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_while(zend_ast *ast) /* {{{ */ +static void zend_compile_while(const zend_ast *ast) /* {{{ */ { zend_ast *cond_ast = ast->child[0]; zend_ast *stmt_ast = ast->child[1]; @@ -5989,7 +6073,7 @@ static void zend_compile_while(zend_ast *ast) /* {{{ */ opnum_jmp = zend_emit_jump(0); - zend_begin_loop(ZEND_NOP, NULL, 0); + zend_begin_loop(ZEND_NOP, NULL, false); opnum_start = get_next_op_number(); zend_compile_stmt(stmt_ast); @@ -6004,7 +6088,7 @@ static void zend_compile_while(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_do_while(zend_ast *ast) /* {{{ */ +static void zend_compile_do_while(const zend_ast *ast) /* {{{ */ { zend_ast *stmt_ast = ast->child[0]; zend_ast *cond_ast = ast->child[1]; @@ -6012,7 +6096,7 @@ static void zend_compile_do_while(zend_ast *ast) /* {{{ */ znode cond_node; uint32_t opnum_start, opnum_cond; - zend_begin_loop(ZEND_NOP, NULL, 0); + zend_begin_loop(ZEND_NOP, NULL, false); opnum_start = get_next_op_number(); zend_compile_stmt(stmt_ast); @@ -6028,7 +6112,7 @@ static void zend_compile_do_while(zend_ast *ast) /* {{{ */ static void zend_compile_for_expr_list(znode *result, zend_ast *ast) /* {{{ */ { - zend_ast_list *list; + const zend_ast_list *list; uint32_t i; result->op_type = IS_CONST; @@ -6054,7 +6138,7 @@ static void zend_compile_for_expr_list(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_for(zend_ast *ast) /* {{{ */ +static void zend_compile_for(const zend_ast *ast) /* {{{ */ { zend_ast *init_ast = ast->child[0]; zend_ast *cond_ast = ast->child[1]; @@ -6069,7 +6153,7 @@ static void zend_compile_for(zend_ast *ast) /* {{{ */ opnum_jmp = zend_emit_jump(0); - zend_begin_loop(ZEND_NOP, NULL, 0); + zend_begin_loop(ZEND_NOP, NULL, false); opnum_start = get_next_op_number(); zend_compile_stmt(stmt_ast); @@ -6115,11 +6199,11 @@ static void zend_compile_foreach(zend_ast *ast) /* {{{ */ } if (value_ast->kind == ZEND_AST_ARRAY && zend_propagate_list_refs(value_ast)) { - by_ref = 1; + by_ref = true; } if (by_ref && is_variable) { - zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1); + zend_compile_var(&expr_node, expr_ast, BP_VAR_W, true); } else { zend_compile_expr(&expr_node, expr_ast); } @@ -6131,7 +6215,7 @@ static void zend_compile_foreach(zend_ast *ast) /* {{{ */ opnum_reset = get_next_op_number(); opline = zend_emit_op(&reset_node, by_ref ? ZEND_FE_RESET_RW : ZEND_FE_RESET_R, &expr_node, NULL); - zend_begin_loop(ZEND_FE_FREE, &reset_node, 0); + zend_begin_loop(ZEND_FE_FREE, &reset_node, false); opnum_fetch = get_next_op_number(); opline = zend_emit_op(NULL, by_ref ? ZEND_FE_FETCH_RW : ZEND_FE_FETCH_R, &reset_node, NULL); @@ -6182,7 +6266,7 @@ static void zend_compile_foreach(zend_ast *ast) /* {{{ */ static void zend_compile_if(zend_ast *ast) /* {{{ */ { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; uint32_t *jmp_opnums = NULL; @@ -6191,7 +6275,7 @@ static void zend_compile_if(zend_ast *ast) /* {{{ */ } for (i = 0; i < list->children; ++i) { - zend_ast *elem_ast = list->child[i]; + const zend_ast *elem_ast = list->child[i]; zend_ast *cond_ast = elem_ast->child[0]; zend_ast *stmt_ast = elem_ast->child[1]; @@ -6232,13 +6316,13 @@ static void zend_compile_if(zend_ast *ast) /* {{{ */ } /* }}} */ -static uint8_t determine_switch_jumptable_type(zend_ast_list *cases) { +static uint8_t determine_switch_jumptable_type(const zend_ast_list *cases) { uint32_t i; uint8_t common_type = IS_UNDEF; for (i = 0; i < cases->children; i++) { zend_ast *case_ast = cases->child[i]; zend_ast **cond_ast = &case_ast->child[0]; - zval *cond_zv; + const zval *cond_zv; if (!case_ast->child[0]) { /* Skip default clause */ continue; @@ -6273,7 +6357,7 @@ static uint8_t determine_switch_jumptable_type(zend_ast_list *cases) { return common_type; } -static bool should_use_jumptable(zend_ast_list *cases, uint8_t jumptable_type) { +static bool should_use_jumptable(const zend_ast_list *cases, uint8_t jumptable_type) { if (CG(compiler_options) & ZEND_COMPILE_NO_JUMPTABLES) { return 0; } @@ -6294,7 +6378,7 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */ zend_ast_list *cases = zend_ast_get_list(ast->child[1]); uint32_t i; - bool has_default_case = 0; + bool has_default_case = false; znode expr_node, case_node; zend_op *opline; @@ -6304,7 +6388,7 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */ zend_compile_expr(&expr_node, expr_ast); - zend_begin_loop(ZEND_FREE, &expr_node, 1); + zend_begin_loop(ZEND_FREE, &expr_node, true); case_node.op_type = IS_TMP_VAR; case_node.u.op.var = get_temporary_variable(); @@ -6344,7 +6428,7 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */ zend_error_noreturn(E_COMPILE_ERROR, "Switch statements may only contain one default clause"); } - has_default_case = 1; + has_default_case = true; continue; } @@ -6427,26 +6511,26 @@ static void zend_compile_switch(zend_ast *ast) /* {{{ */ } /* }}} */ -static uint32_t count_match_conds(zend_ast_list *arms) +static uint32_t count_match_conds(const zend_ast_list *arms) { uint32_t num_conds = 0; for (uint32_t i = 0; i < arms->children; i++) { - zend_ast *arm_ast = arms->child[i]; + const zend_ast *arm_ast = arms->child[i]; if (arm_ast->child[0] == NULL) { continue; } - zend_ast_list *conds = zend_ast_get_list(arm_ast->child[0]); + const zend_ast_list *conds = zend_ast_get_list(arm_ast->child[0]); num_conds += conds->children; } return num_conds; } -static bool can_match_use_jumptable(zend_ast_list *arms) { +static bool can_match_use_jumptable(const zend_ast_list *arms) { for (uint32_t i = 0; i < arms->children; i++) { - zend_ast *arm_ast = arms->child[i]; + const zend_ast *arm_ast = arms->child[i]; if (!arm_ast->child[0]) { /* Skip default arm */ continue; @@ -6461,7 +6545,7 @@ static bool can_match_use_jumptable(zend_ast_list *arms) { return 0; } - zval *cond_zv = zend_ast_get_zval(*cond_ast); + const zval *cond_zv = zend_ast_get_zval(*cond_ast); if (Z_TYPE_P(cond_zv) != IS_LONG && Z_TYPE_P(cond_zv) != IS_STRING) { return 0; } @@ -6478,8 +6562,7 @@ static bool zend_is_pipe_optimizable_callable_name(zend_ast *ast) * pipe optimization that uses a temporary znode for the reference elimination. * Therefore, disable the optimization for assert. * Note that "assert" as a name is always treated as fully qualified. */ - zend_string *str = zend_ast_get_str(ast); - return !zend_string_equals_literal_ci(str, "assert"); + return !zend_string_equals_literal_ci(zend_ast_get_str(ast), "assert"); } return true; @@ -6547,7 +6630,7 @@ static void zend_compile_match(znode *result, zend_ast *ast) { zend_ast *expr_ast = ast->child[0]; zend_ast_list *arms = zend_ast_get_list(ast->child[1]); - bool has_default_arm = 0; + bool has_default_arm = false; uint32_t opnum_match = (uint32_t)-1; znode expr_node; @@ -6572,7 +6655,7 @@ static void zend_compile_match(znode *result, zend_ast *ast) zend_error_noreturn(E_COMPILE_ERROR, "Match expressions may only contain one default arm"); } - has_default_arm = 1; + has_default_arm = true; } } @@ -6625,7 +6708,7 @@ static void zend_compile_match(znode *result, zend_ast *ast) opnum_default_jmp = zend_emit_jump(0); } - bool is_first_case = 1; + bool is_first_case = true; uint32_t cond_count = 0; uint32_t *jmp_end_opnums = safe_emalloc(sizeof(uint32_t), arms->children, 0); @@ -6697,7 +6780,7 @@ static void zend_compile_match(znode *result, zend_ast *ast) if (is_first_case) { zend_emit_op_tmp(result, ZEND_QM_ASSIGN, &body_node, NULL); - is_first_case = 0; + is_first_case = false; } else { zend_op *opline_qm_assign = zend_emit_op(NULL, ZEND_QM_ASSIGN, &body_node, NULL); SET_NODE(opline_qm_assign->result, result); @@ -6729,10 +6812,10 @@ static void zend_compile_match(znode *result, zend_ast *ast) efree(jmp_end_opnums); } -static void zend_compile_try(zend_ast *ast) /* {{{ */ +static void zend_compile_try(const zend_ast *ast) /* {{{ */ { zend_ast *try_ast = ast->child[0]; - zend_ast_list *catches = zend_ast_get_list(ast->child[1]); + const zend_ast_list *catches = zend_ast_get_list(ast->child[1]); zend_ast *finally_ast = ast->child[2]; uint32_t i, j; @@ -6783,8 +6866,8 @@ static void zend_compile_try(zend_ast *ast) /* {{{ */ } for (i = 0; i < catches->children; ++i) { - zend_ast *catch_ast = catches->child[i]; - zend_ast_list *classes = zend_ast_get_list(catch_ast->child[0]); + const zend_ast *catch_ast = catches->child[i]; + const zend_ast_list *classes = zend_ast_get_list(catch_ast->child[0]); zend_ast *var_ast = catch_ast->child[1]; zend_ast *stmt_ast = catch_ast->child[2]; zend_string *var_name = var_ast ? zval_make_interned_string(zend_ast_get_zval(var_ast)) : NULL; @@ -6906,13 +6989,13 @@ static void zend_compile_try(zend_ast *ast) /* {{{ */ /* Encoding declarations must already be handled during parsing */ bool zend_handle_encoding_declaration(zend_ast *ast) /* {{{ */ { - zend_ast_list *declares = zend_ast_get_list(ast); + const zend_ast_list *declares = zend_ast_get_list(ast); uint32_t i; for (i = 0; i < declares->children; ++i) { - zend_ast *declare_ast = declares->child[i]; + const zend_ast *declare_ast = declares->child[i]; zend_ast *name_ast = declare_ast->child[0]; zend_ast *value_ast = declare_ast->child[1]; - zend_string *name = zend_ast_get_str(name_ast); + const zend_string *name = zend_ast_get_str(name_ast); if (zend_string_equals_literal_ci(name, "encoding")) { if (value_ast->kind != ZEND_AST_ZVAL) { @@ -6956,10 +7039,10 @@ bool zend_handle_encoding_declaration(zend_ast *ast) /* {{{ */ /* }}} */ /* Check whether this is the first statement, not counting declares. */ -static zend_result zend_is_first_statement(zend_ast *ast, bool allow_nop) /* {{{ */ +static zend_result zend_is_first_statement(const zend_ast *ast, bool allow_nop) /* {{{ */ { uint32_t i = 0; - zend_ast_list *file_ast = zend_ast_get_list(CG(ast)); + const zend_ast_list *file_ast = zend_ast_get_list(CG(ast)); while (i < file_ast->children) { if (file_ast->child[i] == ast) { @@ -6977,9 +7060,9 @@ static zend_result zend_is_first_statement(zend_ast *ast, bool allow_nop) /* {{{ } /* }}} */ -static void zend_compile_declare(zend_ast *ast) /* {{{ */ +static void zend_compile_declare(const zend_ast *ast) /* {{{ */ { - zend_ast_list *declares = zend_ast_get_list(ast->child[0]); + const zend_ast_list *declares = zend_ast_get_list(ast->child[0]); zend_ast *stmt_ast = ast->child[1]; zend_declarables orig_declarables = FC(declarables); uint32_t i; @@ -7001,7 +7084,7 @@ static void zend_compile_declare(zend_ast *ast) /* {{{ */ zval_ptr_dtor_nogc(&value_zv); } else if (zend_string_equals_literal_ci(name, "encoding")) { - if (FAILURE == zend_is_first_statement(ast, /* allow_nop */ 0)) { + if (FAILURE == zend_is_first_statement(ast, /* allow_nop */ false)) { zend_error_noreturn(E_COMPILE_ERROR, "Encoding declaration pragma must be " "the very first statement in the script"); } @@ -7043,7 +7126,7 @@ static void zend_compile_declare(zend_ast *ast) /* {{{ */ static void zend_compile_stmt_list(zend_ast *ast) /* {{{ */ { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; for (i = 0; i < list->children; ++i) { zend_compile_stmt(list->child[i]); @@ -7169,9 +7252,9 @@ static void zend_are_intersection_types_redundant(const zend_type left_type, con { ZEND_ASSERT(ZEND_TYPE_IS_INTERSECTION(left_type)); ZEND_ASSERT(ZEND_TYPE_IS_INTERSECTION(right_type)); - zend_type_list *l_type_list = ZEND_TYPE_LIST(left_type); - zend_type_list *r_type_list = ZEND_TYPE_LIST(right_type); - zend_type_list *smaller_type_list, *larger_type_list; + const zend_type_list *l_type_list = ZEND_TYPE_LIST(left_type); + const zend_type_list *r_type_list = ZEND_TYPE_LIST(right_type); + const zend_type_list *smaller_type_list, *larger_type_list; bool flipped = false; if (r_type_list->num_types < l_type_list->num_types) { @@ -7261,7 +7344,7 @@ static zend_type zend_compile_typename_ex( } if (ast->kind == ZEND_AST_TYPE_UNION) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); zend_type_list *type_list; bool is_composite = false; bool has_only_iterable_class = true; @@ -7377,7 +7460,7 @@ static zend_type zend_compile_typename_ex( ZSTR_VAL(type_str)); } } else if (ast->kind == ZEND_AST_TYPE_INTERSECTION) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); zend_type_list *type_list; /* Allocate the type list directly on the arena as it must be a type @@ -7507,20 +7590,20 @@ static void zend_compile_attributes( zend_attribute *attr; zend_internal_attribute *config; - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t g, i, j; ZEND_ASSERT(ast->kind == ZEND_AST_ATTRIBUTE_LIST); for (g = 0; g < list->children; g++) { - zend_ast_list *group = zend_ast_get_list(list->child[g]); + const zend_ast_list *group = zend_ast_get_list(list->child[g]); ZEND_ASSERT(group->kind == ZEND_AST_ATTRIBUTE_GROUP); for (i = 0; i < group->children; i++) { ZEND_ASSERT(group->child[i]->kind == ZEND_AST_ATTRIBUTE); - zend_ast *el = group->child[i]; + const zend_ast *el = group->child[i]; if (el->child[1] && el->child[1]->kind == ZEND_AST_CALLABLE_CONVERT) { @@ -7553,7 +7636,7 @@ static void zend_compile_attributes( if (args) { ZEND_ASSERT(args->kind == ZEND_AST_ARG_LIST); - bool uses_named_args = 0; + bool uses_named_args = false; for (j = 0; j < args->children; j++) { zend_ast **arg_ast_ptr = &args->child[j]; zend_ast *arg_ast = *arg_ast_ptr; @@ -7566,7 +7649,7 @@ static void zend_compile_attributes( if (arg_ast->kind == ZEND_AST_NAMED_ARG) { attr->args[j].name = zend_string_copy(zend_ast_get_str(arg_ast->child[0])); arg_ast_ptr = &arg_ast->child[1]; - uses_named_args = 1; + uses_named_args = true; for (uint32_t k = 0; k < j; k++) { if (attr->args[k].name && @@ -7589,7 +7672,7 @@ static void zend_compile_attributes( if (*attributes != NULL) { /* Allow delaying target validation for forward compatibility. */ - zend_attribute *delayed_target_validation = NULL; + const zend_attribute *delayed_target_validation = NULL; if (target == ZEND_ATTRIBUTE_TARGET_PARAMETER) { ZEND_ASSERT(offset >= 1); /* zend_get_parameter_attribute_str will add 1 too */ @@ -7650,10 +7733,10 @@ static void zend_compile_attributes( static void zend_compile_property_hooks( zend_property_info *prop_info, zend_string *prop_name, - zend_ast *prop_type_ast, zend_ast_list *hooks); + zend_ast *prop_type_ast, const zend_ast_list *hooks); typedef struct { - zend_string *property_name; + const zend_string *property_name; bool uses_property; } find_property_usage_context; @@ -7665,14 +7748,14 @@ static void zend_property_hook_find_property_usage(zend_ast **ast_ptr, void *_co if (ast == NULL) { return; } else if (ast->kind == ZEND_AST_PROP || ast->kind == ZEND_AST_NULLSAFE_PROP) { - zend_ast *object_ast = ast->child[0]; + const zend_ast *object_ast = ast->child[0]; zend_ast *property_ast = ast->child[1]; if (object_ast->kind == ZEND_AST_VAR && object_ast->child[0]->kind == ZEND_AST_ZVAL && property_ast->kind == ZEND_AST_ZVAL) { - zval *object = zend_ast_get_zval(object_ast->child[0]); - zval *property = zend_ast_get_zval(property_ast); + const zval *object = zend_ast_get_zval(object_ast->child[0]); + const zval *property = zend_ast_get_zval(property_ast); if (Z_TYPE_P(object) == IS_STRING && Z_TYPE_P(property) == IS_STRING && zend_string_equals_literal(Z_STR_P(object), "this") @@ -7690,7 +7773,7 @@ static void zend_property_hook_find_property_usage(zend_ast **ast_ptr, void *_co } } -static bool zend_property_hook_uses_property(zend_string *property_name, zend_string *hook_name, zend_ast *hook_ast) +static bool zend_property_hook_uses_property(const zend_string *property_name, const zend_string *hook_name, zend_ast *hook_ast) { if (zend_string_equals_literal_ci(hook_name, "set") && hook_ast->kind == ZEND_AST_PROPERTY_HOOK_SHORT_BODY) { @@ -7702,7 +7785,7 @@ static bool zend_property_hook_uses_property(zend_string *property_name, zend_st return context.uses_property; } -static bool zend_property_is_virtual(zend_class_entry *ce, zend_string *property_name, zend_ast *hooks_ast, uint32_t flags) +static bool zend_property_is_virtual(const zend_class_entry *ce, const zend_string *property_name, zend_ast *hooks_ast, uint32_t flags) { if (ce->ce_flags & ZEND_ACC_INTERFACE) { return true; @@ -7713,9 +7796,9 @@ static bool zend_property_is_virtual(zend_class_entry *ce, zend_string *property bool is_virtual = true; - zend_ast_list *hooks = zend_ast_get_list(hooks_ast); + const zend_ast_list *hooks = zend_ast_get_list(hooks_ast); for (uint32_t i = 0; i < hooks->children; i++) { - zend_ast_decl *hook = (zend_ast_decl *) hooks->child[i]; + const zend_ast_decl *hook = (const zend_ast_decl *) hooks->child[i]; zend_ast *body = hook->child[2]; if (body && zend_property_hook_uses_property(property_name, hook->name, body)) { is_virtual = false; @@ -7840,6 +7923,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 arg_info = &arg_infos[i]; arg_info->name = zend_string_copy(name); arg_info->type = (zend_type) ZEND_TYPE_INIT_NONE(0); + arg_info->default_value = NULL; if (attributes_ast) { zend_compile_attributes( @@ -7916,16 +8000,16 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 } if (is_promoted) { - zend_op_array *op_array = CG(active_op_array); - zend_class_entry *scope = op_array->scope; + const zend_op_array *active_op_array = CG(active_op_array); + zend_class_entry *scope = active_op_array->scope; bool is_ctor = - scope && zend_is_constructor(op_array->function_name); + scope && zend_is_constructor(active_op_array->function_name); if (!is_ctor) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare promoted property outside a constructor"); } - if ((op_array->fn_flags & ZEND_ACC_ABSTRACT) + if ((active_op_array->fn_flags & ZEND_ACC_ABSTRACT) || (scope->ce_flags & ZEND_ACC_INTERFACE)) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare promoted property in an abstract constructor"); @@ -7980,7 +8064,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 property_flags | (zend_property_is_virtual(scope, name, hooks_ast, property_flags) ? ZEND_ACC_VIRTUAL : 0) | ZEND_ACC_PROMOTED, doc_comment, type); if (hooks_ast) { - zend_ast_list *hooks = zend_ast_get_list(hooks_ast); + const zend_ast_list *hooks = zend_ast_get_list(hooks_ast); zend_compile_property_hooks(prop, name, type_ast, hooks); } if (attributes_ast) { @@ -8035,7 +8119,7 @@ static void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast, uint32 static void zend_compile_closure_binding(znode *closure, zend_op_array *op_array, zend_ast *uses_ast) /* {{{ */ { - zend_ast_list *list = zend_ast_get_list(uses_ast); + const zend_ast_list *list = zend_ast_get_list(uses_ast); uint32_t i; if (!list->children) { @@ -8083,6 +8167,8 @@ typedef struct { bool varvars_used; } closure_info; +static void find_implicit_binds(closure_info *info, zend_ast *params_ast, zend_ast *stmt_ast); + static void find_implicit_binds_recursively(closure_info *info, zend_ast *ast) { if (!ast) { return; @@ -8104,21 +8190,21 @@ static void find_implicit_binds_recursively(closure_info *info, zend_ast *ast) { zend_hash_add_empty_element(&info->uses, name); } else { - info->varvars_used = 1; + info->varvars_used = true; find_implicit_binds_recursively(info, name_ast); } } else if (zend_ast_is_list(ast)) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; for (i = 0; i < list->children; i++) { find_implicit_binds_recursively(info, list->child[i]); } } else if (ast->kind == ZEND_AST_CLOSURE) { /* For normal closures add the use() list. */ - zend_ast_decl *closure_ast = (zend_ast_decl *) ast; + const zend_ast_decl *closure_ast = (const zend_ast_decl *) ast; zend_ast *uses_ast = closure_ast->child[1]; if (uses_ast) { - zend_ast_list *uses_list = zend_ast_get_list(uses_ast); + const zend_ast_list *uses_list = zend_ast_get_list(uses_ast); uint32_t i; for (i = 0; i < uses_list->children; i++) { zend_hash_add_empty_element(&info->uses, zend_ast_get_str(uses_list->child[i])); @@ -8126,8 +8212,16 @@ static void find_implicit_binds_recursively(closure_info *info, zend_ast *ast) { } } else if (ast->kind == ZEND_AST_ARROW_FUNC) { /* For arrow functions recursively check the expression. */ - zend_ast_decl *closure_ast = (zend_ast_decl *) ast; - find_implicit_binds_recursively(info, closure_ast->child[2]); + const zend_ast_decl *closure_ast = (const zend_ast_decl *) ast; + closure_info inner_info; + find_implicit_binds(&inner_info, closure_ast->child[0], closure_ast->child[2]); + if (inner_info.varvars_used) { + info->varvars_used = true; + } + if (zend_hash_num_elements(&inner_info.uses)) { + zend_hash_copy(&info->uses, &inner_info.uses, NULL); + } + zend_hash_destroy(&inner_info.uses); } else if (!zend_ast_is_special(ast)) { uint32_t i, children = zend_ast_get_num_children(ast); for (i = 0; i < children; i++) { @@ -8138,22 +8232,23 @@ static void find_implicit_binds_recursively(closure_info *info, zend_ast *ast) { static void find_implicit_binds(closure_info *info, zend_ast *params_ast, zend_ast *stmt_ast) { - zend_ast_list *param_list = zend_ast_get_list(params_ast); + const zend_ast_list *param_list = zend_ast_get_list(params_ast); uint32_t i; zend_hash_init(&info->uses, param_list->children, NULL, NULL, 0); + info->varvars_used = false; find_implicit_binds_recursively(info, stmt_ast); /* Remove variables that are parameters */ for (i = 0; i < param_list->children; i++) { - zend_ast *param_ast = param_list->child[i]; + const zend_ast *param_ast = param_list->child[i]; zend_hash_del(&info->uses, zend_ast_get_str(param_ast->child[1])); } } static void compile_implicit_lexical_binds( - closure_info *info, znode *closure, zend_op_array *op_array) + const closure_info *info, znode *closure, zend_op_array *op_array) { zend_string *var_name; zend_op *opline; @@ -8181,8 +8276,8 @@ static void compile_implicit_lexical_binds( static void zend_compile_closure_uses(zend_ast *ast) /* {{{ */ { - zend_op_array *op_array = CG(active_op_array); - zend_ast_list *list = zend_ast_get_list(ast); + const zend_op_array *op_array = CG(active_op_array); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; for (i = 0; i < list->children; ++i) { @@ -8213,7 +8308,7 @@ static void zend_compile_closure_uses(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_implicit_closure_uses(closure_info *info) +static void zend_compile_implicit_closure_uses(const closure_info *info) { zend_string *var_name; ZEND_HASH_MAP_FOREACH_STR_KEY(&info->uses, var_name) @@ -8338,7 +8433,7 @@ enum func_decl_level { FUNC_DECL_LEVEL_CONSTEXPR, }; -static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_ast_decl *decl, enum func_decl_level level) /* {{{ */ +static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array, const zend_ast_decl *decl, enum func_decl_level level) /* {{{ */ { zend_string *unqualified_name, *name, *lcname; zend_op *opline; @@ -8350,7 +8445,7 @@ static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_string *class = zend_empty_string; zend_string *separator = zend_empty_string; zend_string *function = filename; - char *parens = ""; + const char *parens = ""; if (CG(active_op_array) && CG(active_op_array)->function_name) { if (CG(active_op_array)->fn_flags & ZEND_ACC_CLOSURE) { @@ -8388,7 +8483,7 @@ static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array, lcname = zend_string_tolower(name); if (FC(imports_function)) { - zend_string *import_name = + const 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 redeclare function %s() (previously declared as local import)", @@ -8451,7 +8546,6 @@ static zend_op_array *zend_compile_func_decl_ex( zend_op_array *op_array = zend_arena_alloc(&CG(arena), sizeof(zend_op_array)); zend_oparray_context orig_oparray_context; closure_info info; - memset(&info, 0, sizeof(closure_info)); init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE); @@ -8503,7 +8597,7 @@ static zend_op_array *zend_compile_func_decl_ex( zend_compile_attributes(&op_array->attributes, decl->child[4], 0, target, 0); - zend_attribute *override_attribute = zend_get_attribute_str( + const zend_attribute *override_attribute = zend_get_attribute_str( op_array->attributes, "override", sizeof("override")-1 @@ -8513,7 +8607,7 @@ static zend_op_array *zend_compile_func_decl_ex( op_array->fn_flags |= ZEND_ACC_OVERRIDE; } - zend_attribute *deprecated_attribute = zend_get_attribute_str( + const zend_attribute *deprecated_attribute = zend_get_attribute_str( op_array->attributes, "deprecated", sizeof("deprecated")-1 @@ -8561,7 +8655,7 @@ static zend_op_array *zend_compile_func_decl_ex( if (ast->kind == ZEND_AST_ARROW_FUNC && decl->child[2]->kind != ZEND_AST_RETURN) { bool needs_return = true; if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { - zend_arg_info *return_info = CG(active_op_array)->arg_info - 1; + const zend_arg_info *return_info = CG(active_op_array)->arg_info - 1; needs_return = !ZEND_TYPE_CONTAINS_CODE(return_info->type, IS_NEVER); } if (needs_return) { @@ -8579,7 +8673,7 @@ static zend_op_array *zend_compile_func_decl_ex( ZEND_ASSERT(!is_hook); if (op_array->fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { - zend_arg_info *return_info = CG(active_op_array)->arg_info - 1; + const zend_arg_info *return_info = CG(active_op_array)->arg_info - 1; if (ZEND_TYPE_CONTAINS_CODE(return_info->type, IS_VOID)) { zend_error_noreturn(E_COMPILE_ERROR, "A void %s does not return a value, but #[\\NoDiscard] requires a return value", @@ -8612,7 +8706,7 @@ static zend_op_array *zend_compile_func_decl_ex( CG(zend_lineno) = decl->end_lineno; zend_do_extended_stmt(NULL); - zend_emit_final_return(0); + zend_emit_final_return(false); pass_two(CG(active_op_array)); zend_oparray_context_end(&orig_oparray_context); @@ -8639,7 +8733,7 @@ static zend_op_array *zend_compile_func_decl(znode *result, zend_ast *ast, enum return zend_compile_func_decl_ex(result, ast, level, /* property_info */ NULL, (zend_property_hook_kind)-1); } -zend_property_hook_kind zend_get_property_hook_kind_from_name(zend_string *name) { +zend_property_hook_kind zend_get_property_hook_kind_from_name(const zend_string *name) { if (zend_string_equals_literal_ci(name, "get")) { return ZEND_PROPERTY_HOOK_GET; } else if (zend_string_equals_literal_ci(name, "set")) { @@ -8651,7 +8745,7 @@ zend_property_hook_kind zend_get_property_hook_kind_from_name(zend_string *name) static void zend_compile_property_hooks( zend_property_info *prop_info, zend_string *prop_name, - zend_ast *prop_type_ast, zend_ast_list *hooks) + zend_ast *prop_type_ast, const zend_ast_list *hooks) { zend_class_entry *ce = CG(active_class_entry); @@ -8735,12 +8829,12 @@ static void zend_compile_property_hooks( *return_type_ast_ptr = prop_type_ast; } else if (hook_kind == ZEND_PROPERTY_HOOK_SET) { if (hook->child[0]) { - zend_ast_list *param_list = zend_ast_get_list(hook->child[0]); + const zend_ast_list *param_list = zend_ast_get_list(hook->child[0]); if (param_list->children != 1) { zend_error_noreturn(E_COMPILE_ERROR, "%s hook of property %s::$%s must accept exactly one parameters", ZSTR_VAL(name), ZSTR_VAL(ce->name), ZSTR_VAL(prop_name)); } - zend_ast *value_param_ast = param_list->child[0]; + const zend_ast *value_param_ast = param_list->child[0]; if (value_param_ast->attr & ZEND_PARAM_REF) { zend_error_noreturn(E_COMPILE_ERROR, "Parameter $%s of %s hook %s::$%s must not be pass-by-reference", ZSTR_VAL(zend_ast_get_str(value_param_ast->child[1])), ZSTR_VAL(name), ZSTR_VAL(ce->name), ZSTR_VAL(prop_name)); @@ -8831,7 +8925,7 @@ static void zend_compile_property_hooks( static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t flags, zend_ast *attr_ast) /* {{{ */ { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); zend_class_entry *ce = CG(active_class_entry); uint32_t i, children = list->children; @@ -8966,7 +9060,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f if (attr_ast) { zend_compile_attributes(&info->attributes, attr_ast, 0, ZEND_ATTRIBUTE_TARGET_PROPERTY, 0); - zend_attribute *override_attribute = zend_get_attribute_str(info->attributes, "override", sizeof("override")-1); + const zend_attribute *override_attribute = zend_get_attribute_str(info->attributes, "override", sizeof("override")-1); if (override_attribute) { info->flags |= ZEND_ACC_OVERRIDE; } @@ -8977,7 +9071,7 @@ static void zend_compile_prop_decl(zend_ast *ast, zend_ast *type_ast, uint32_t f } /* }}} */ -static void zend_compile_prop_group(zend_ast *ast) /* {{{ */ +static void zend_compile_prop_group(const zend_ast *ast) /* {{{ */ { zend_ast *type_ast = ast->child[0]; zend_ast *prop_ast = ast->child[1]; @@ -8999,7 +9093,7 @@ static void zend_check_trait_alias_modifiers(uint32_t attr) /* {{{ */ static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_ast *attr_ast, zend_ast *type_ast) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); zend_class_entry *ce = CG(active_class_entry); uint32_t i, children = list->children; @@ -9048,7 +9142,7 @@ static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_as if (attr_ast) { zend_compile_attributes(&c->attributes, attr_ast, 0, ZEND_ATTRIBUTE_TARGET_CLASS_CONST, 0); - zend_attribute *deprecated = zend_get_attribute_str(c->attributes, "deprecated", sizeof("deprecated")-1); + const zend_attribute *deprecated = zend_get_attribute_str(c->attributes, "deprecated", sizeof("deprecated")-1); if (deprecated) { ZEND_CLASS_CONST_FLAGS(c) |= ZEND_ACC_DEPRECATED; @@ -9061,7 +9155,7 @@ static void zend_compile_class_const_decl(zend_ast *ast, uint32_t flags, zend_as } } -static void zend_compile_class_const_group(zend_ast *ast) /* {{{ */ +static void zend_compile_class_const_group(const zend_ast *ast) /* {{{ */ { zend_ast *const_ast = ast->child[0]; zend_ast *attr_ast = ast->child[1]; @@ -9071,7 +9165,7 @@ static void zend_compile_class_const_group(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_method_ref(zend_ast *ast, zend_trait_method_reference *method_ref) /* {{{ */ +static void zend_compile_method_ref(const zend_ast *ast, zend_trait_method_reference *method_ref) /* {{{ */ { zend_ast *class_ast = ast->child[0]; zend_ast *method_ast = ast->child[1]; @@ -9086,11 +9180,11 @@ static void zend_compile_method_ref(zend_ast *ast, zend_trait_method_reference * } /* }}} */ -static void zend_compile_trait_precedence(zend_ast *ast) /* {{{ */ +static void zend_compile_trait_precedence(const zend_ast *ast) /* {{{ */ { - zend_ast *method_ref_ast = ast->child[0]; + const zend_ast *method_ref_ast = ast->child[0]; zend_ast *insteadof_ast = ast->child[1]; - zend_ast_list *insteadof_list = zend_ast_get_list(insteadof_ast); + const zend_ast_list *insteadof_list = zend_ast_get_list(insteadof_ast); uint32_t i; zend_trait_precedence *precedence = emalloc(sizeof(zend_trait_precedence) + (insteadof_list->children - 1) * sizeof(zend_string*)); @@ -9107,9 +9201,9 @@ static void zend_compile_trait_precedence(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_trait_alias(zend_ast *ast) /* {{{ */ +static void zend_compile_trait_alias(const zend_ast *ast) /* {{{ */ { - zend_ast *method_ref_ast = ast->child[0]; + const zend_ast *method_ref_ast = ast->child[0]; zend_ast *alias_ast = ast->child[1]; uint32_t modifiers = ast->attr; @@ -9131,9 +9225,9 @@ static void zend_compile_trait_alias(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_use_trait(zend_ast *ast) /* {{{ */ +static void zend_compile_use_trait(const zend_ast *ast) /* {{{ */ { - zend_ast_list *traits = zend_ast_get_list(ast->child[0]); + const zend_ast_list *traits = zend_ast_get_list(ast->child[0]); zend_ast_list *adaptations = ast->child[1] ? zend_ast_get_list(ast->child[1]) : NULL; zend_class_entry *ce = CG(active_class_entry); uint32_t i; @@ -9160,7 +9254,7 @@ static void zend_compile_use_trait(zend_ast *ast) /* {{{ */ } for (i = 0; i < adaptations->children; ++i) { - zend_ast *adaptation_ast = adaptations->child[i]; + const zend_ast *adaptation_ast = adaptations->child[i]; switch (adaptation_ast->kind) { case ZEND_AST_TRAIT_PRECEDENCE: zend_compile_trait_precedence(adaptation_ast); @@ -9176,7 +9270,7 @@ static void zend_compile_use_trait(zend_ast *ast) /* {{{ */ static void zend_compile_implements(zend_ast *ast) /* {{{ */ { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); zend_class_entry *ce = CG(active_class_entry); zend_class_name *interface_names; uint32_t i; @@ -9195,7 +9289,7 @@ static void zend_compile_implements(zend_ast *ast) /* {{{ */ } /* }}} */ -static zend_string *zend_generate_anon_class_name(zend_ast_decl *decl) +static zend_string *zend_generate_anon_class_name(const zend_ast_decl *decl) { zend_string *filename = CG(active_op_array)->filename; uint32_t start_lineno = decl->start_lineno; @@ -9205,7 +9299,7 @@ static zend_string *zend_generate_anon_class_name(zend_ast_decl *decl) if (decl->child[0]) { prefix = zend_resolve_const_class_name_reference(decl->child[0], "class name"); } else if (decl->child[1]) { - zend_ast_list *list = zend_ast_get_list(decl->child[1]); + const zend_ast_list *list = zend_ast_get_list(decl->child[1]); prefix = zend_resolve_const_class_name_reference(list->child[0], "interface name"); } @@ -9235,9 +9329,9 @@ static void zend_compile_enum_backing_type(zend_class_entry *ce, zend_ast *enum_ zend_type_release(type, 0); } -static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel) /* {{{ */ +static void zend_compile_class_decl(znode *result, const zend_ast *ast, bool toplevel) /* {{{ */ { - zend_ast_decl *decl = (zend_ast_decl *) ast; + const zend_ast_decl *decl = (const zend_ast_decl *) ast; zend_ast *extends_ast = decl->child[0]; zend_ast *implements_ast = decl->child[1]; zend_ast *stmt_ast = decl->child[2]; @@ -9293,7 +9387,7 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel) ce->type = ZEND_USER_CLASS; ce->name = name; - zend_initialize_class_data(ce, 1); + zend_initialize_class_data(ce, true); if (!(decl->flags & ZEND_ACC_ANON_CLASS)) { zend_alloc_ce_cache(ce->name); } @@ -9557,7 +9651,7 @@ static char *zend_get_use_type_str(uint32_t type) /* {{{ */ } /* }}} */ -static void zend_check_already_in_use(uint32_t type, zend_string *old_name, zend_string *new_name, zend_string *check_name) /* {{{ */ +static void zend_check_already_in_use(uint32_t type, const zend_string *old_name, const zend_string *new_name, const zend_string *check_name) /* {{{ */ { if (zend_string_equals_ci(old_name, check_name)) { return; @@ -9570,7 +9664,7 @@ static void zend_check_already_in_use(uint32_t type, zend_string *old_name, zend static void zend_compile_use(zend_ast *ast) /* {{{ */ { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; zend_string *current_ns = FC(current_namespace); uint32_t type = ast->attr; @@ -9578,7 +9672,7 @@ static void zend_compile_use(zend_ast *ast) /* {{{ */ bool case_sensitive = type == ZEND_SYMBOL_CONST; for (i = 0; i < list->children; ++i) { - zend_ast *use_ast = list->child[i]; + const zend_ast *use_ast = list->child[i]; zend_ast *old_name_ast = use_ast->child[0]; zend_ast *new_name_ast = use_ast->child[1]; zend_string *old_name = zend_ast_get_str(old_name_ast); @@ -9641,11 +9735,11 @@ static void zend_compile_use(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_group_use(zend_ast *ast) /* {{{ */ +static void zend_compile_group_use(const zend_ast *ast) /* {{{ */ { uint32_t i; - zend_string *ns = zend_ast_get_str(ast->child[0]); - zend_ast_list *list = zend_ast_get_list(ast->child[1]); + const zend_string *ns = zend_ast_get_str(ast->child[0]); + const zend_ast_list *list = zend_ast_get_list(ast->child[1]); for (i = 0; i < list->children; i++) { zend_ast *inline_use, *use = list->child[i]; @@ -9735,7 +9829,7 @@ static void zend_compile_const_decl(zend_ast *ast) /* {{{ */ } /* }}}*/ -static void zend_compile_namespace(zend_ast *ast) /* {{{ */ +static void zend_compile_namespace(const zend_ast *ast) /* {{{ */ { zend_ast *name_ast = ast->child[0]; zend_ast *stmt_ast = ast->child[1]; @@ -9763,7 +9857,7 @@ static void zend_compile_namespace(zend_ast *ast) /* {{{ */ bool is_first_namespace = (!with_bracket && !FC(current_namespace)) || (with_bracket && !FC(has_bracketed_namespaces)); - if (is_first_namespace && FAILURE == zend_is_first_statement(ast, /* allow_nop */ 1)) { + if (is_first_namespace && FAILURE == zend_is_first_statement(ast, /* allow_nop */ true)) { zend_error_noreturn(E_COMPILE_ERROR, "Namespace declaration statement has to be " "the very first statement or after any declare call in the script"); } @@ -9798,12 +9892,11 @@ static void zend_compile_namespace(zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_halt_compiler(zend_ast *ast) /* {{{ */ +static void zend_compile_halt_compiler(const zend_ast *ast) /* {{{ */ { zend_ast *offset_ast = ast->child[0]; zend_long offset = Z_LVAL_P(zend_ast_get_zval(offset_ast)); - zend_string *filename, *name; const char const_name[] = "__COMPILER_HALT_OFFSET__"; if (FC(has_bracketed_namespaces) && FC(in_namespace)) { @@ -9811,9 +9904,9 @@ static void zend_compile_halt_compiler(zend_ast *ast) /* {{{ */ "__HALT_COMPILER() can only be used from the outermost scope"); } - filename = zend_get_compiled_filename(); - name = zend_mangle_property_name(const_name, sizeof(const_name) - 1, - ZSTR_VAL(filename), ZSTR_LEN(filename), 0); + const zend_string *filename = zend_get_compiled_filename(); + zend_string *name = zend_mangle_property_name(const_name, sizeof(const_name) - 1, + ZSTR_VAL(filename), ZSTR_LEN(filename), false); /* Avoid repeated declaration of the __COMPILER_HALT_OFFSET__ constant in * case this file was already included. */ @@ -9824,10 +9917,10 @@ static void zend_compile_halt_compiler(zend_ast *ast) /* {{{ */ } /* }}} */ -static bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */ +static bool zend_try_ct_eval_magic_const(zval *zv, const zend_ast *ast) /* {{{ */ { - zend_op_array *op_array = CG(active_op_array); - zend_class_entry *ce = CG(active_class_entry); + const zend_op_array *op_array = CG(active_op_array); + const zend_class_entry *ce = CG(active_class_entry); switch (ast->attr) { case T_LINE: @@ -9838,7 +9931,7 @@ static bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast) /* {{{ */ break; case T_DIR: { - zend_string *filename = CG(compiled_filename); + const zend_string *filename = CG(compiled_filename); zend_string *dirname = zend_string_init(ZSTR_VAL(filename), ZSTR_LEN(filename), 0); #ifdef ZEND_WIN32 ZSTR_LEN(dirname) = php_win32_ioutil_dirname(ZSTR_VAL(dirname), ZSTR_LEN(dirname)); @@ -10027,7 +10120,7 @@ static inline bool zend_try_ct_eval_binary_op(zval *result, uint32_t opcode, zva return 0; } - binary_op_type fn = get_binary_op(opcode); + const binary_op_type fn = get_binary_op(opcode); fn(result, op1, op2); return 1; } @@ -10057,7 +10150,7 @@ static inline bool zend_try_ct_eval_unary_op(zval *result, uint32_t opcode, zval return 0; } - unary_op_type fn = get_unary_op(opcode); + const unary_op_type fn = get_unary_op(opcode); fn(result, op); return 1; } @@ -10073,7 +10166,7 @@ static inline bool zend_try_ct_eval_unary_pm(zval *result, zend_ast_kind kind, z static inline void zend_ct_eval_greater(zval *result, zend_ast_kind kind, zval *op1, zval *op2) /* {{{ */ { - binary_op_type fn = kind == ZEND_AST_GREATER + const binary_op_type fn = kind == ZEND_AST_GREATER ? is_smaller_function : is_smaller_or_equal_function; fn(result, op2, op1); } @@ -10081,10 +10174,10 @@ static inline void zend_ct_eval_greater(zval *result, zend_ast_kind kind, zval * static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); zend_ast *last_elem_ast = NULL; uint32_t i; - bool is_constant = 1; + bool is_constant = true; if (ast->attr == ZEND_ARRAY_SYNTAX_LIST) { zend_error(E_COMPILE_ERROR, "Cannot use list() as standalone expression"); @@ -10109,13 +10202,13 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ if (elem_ast->attr /* by_ref */ || elem_ast->child[0]->kind != ZEND_AST_ZVAL || (elem_ast->child[1] && elem_ast->child[1]->kind != ZEND_AST_ZVAL) ) { - is_constant = 0; + is_constant = false; } } else { zend_eval_const_expr(&elem_ast->child[0]); if (elem_ast->child[0]->kind != ZEND_AST_ZVAL) { - is_constant = 0; + is_constant = false; } } @@ -10133,14 +10226,14 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ array_init_size(result, list->children); for (i = 0; i < list->children; ++i) { - zend_ast *elem_ast = list->child[i]; + const zend_ast *elem_ast = list->child[i]; zend_ast *value_ast = elem_ast->child[0]; zend_ast *key_ast; zval *value = zend_ast_get_zval(value_ast); if (elem_ast->kind == ZEND_AST_UNPACK) { if (Z_TYPE_P(value) == IS_ARRAY) { - HashTable *ht = Z_ARRVAL_P(value); + const HashTable *ht = Z_ARRVAL_P(value); zval *val; zend_string *key; @@ -10164,7 +10257,7 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */ key_ast = elem_ast->child[1]; if (key_ast) { - zval *key = zend_ast_get_zval(key_ast); + const zval *key = zend_ast_get_zval(key_ast); switch (Z_TYPE_P(key)) { case IS_LONG: zend_hash_index_update(Z_ARRVAL_P(result), Z_LVAL_P(key), value); @@ -10303,7 +10396,7 @@ static void zend_compile_greater(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_unary_op(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_unary_op(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; uint32_t opcode = ast->attr; @@ -10399,7 +10492,7 @@ static void zend_compile_short_circuiting(znode *result, zend_ast *ast) /* {{{ * } /* }}} */ -static void zend_compile_post_incdec(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_post_incdec(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *var_ast = ast->child[0]; ZEND_ASSERT(ast->kind == ZEND_AST_POST_INC || ast->kind == ZEND_AST_POST_DEC); @@ -10407,16 +10500,16 @@ static void zend_compile_post_incdec(znode *result, zend_ast *ast) /* {{{ */ zend_ensure_writable_variable(var_ast); if (var_ast->kind == ZEND_AST_PROP || var_ast->kind == ZEND_AST_NULLSAFE_PROP) { - zend_op *opline = zend_compile_prop(NULL, var_ast, BP_VAR_RW, 0); + zend_op *opline = zend_compile_prop(NULL, var_ast, BP_VAR_RW, false); opline->opcode = ast->kind == ZEND_AST_POST_INC ? ZEND_POST_INC_OBJ : ZEND_POST_DEC_OBJ; zend_make_tmp_result(result, opline); } else if (var_ast->kind == ZEND_AST_STATIC_PROP) { - zend_op *opline = zend_compile_static_prop(NULL, var_ast, BP_VAR_RW, 0, 0); + zend_op *opline = zend_compile_static_prop(NULL, var_ast, BP_VAR_RW, false, false); opline->opcode = ast->kind == ZEND_AST_POST_INC ? ZEND_POST_INC_STATIC_PROP : ZEND_POST_DEC_STATIC_PROP; zend_make_tmp_result(result, opline); } else { znode var_node; - zend_op *opline = zend_compile_var(&var_node, var_ast, BP_VAR_RW, 0); + zend_op *opline = zend_compile_var(&var_node, var_ast, BP_VAR_RW, false); if (opline && opline->opcode == ZEND_FETCH_DIM_RW) { opline->extended_value = ZEND_FETCH_DIM_INCDEC; } @@ -10426,7 +10519,7 @@ static void zend_compile_post_incdec(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_pre_incdec(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_pre_incdec(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *var_ast = ast->child[0]; ZEND_ASSERT(ast->kind == ZEND_AST_PRE_INC || ast->kind == ZEND_AST_PRE_DEC); @@ -10434,18 +10527,18 @@ static void zend_compile_pre_incdec(znode *result, zend_ast *ast) /* {{{ */ zend_ensure_writable_variable(var_ast); if (var_ast->kind == ZEND_AST_PROP || var_ast->kind == ZEND_AST_NULLSAFE_PROP) { - zend_op *opline = zend_compile_prop(result, var_ast, BP_VAR_RW, 0); + zend_op *opline = zend_compile_prop(result, var_ast, BP_VAR_RW, false); opline->opcode = ast->kind == ZEND_AST_PRE_INC ? ZEND_PRE_INC_OBJ : ZEND_PRE_DEC_OBJ; opline->result_type = IS_TMP_VAR; result->op_type = IS_TMP_VAR; } else if (var_ast->kind == ZEND_AST_STATIC_PROP) { - zend_op *opline = zend_compile_static_prop(result, var_ast, BP_VAR_RW, 0, 0); + zend_op *opline = zend_compile_static_prop(result, var_ast, BP_VAR_RW, false, false); opline->opcode = ast->kind == ZEND_AST_PRE_INC ? ZEND_PRE_INC_STATIC_PROP : ZEND_PRE_DEC_STATIC_PROP; opline->result_type = IS_TMP_VAR; result->op_type = IS_TMP_VAR; } else { znode var_node; - zend_op *opline = zend_compile_var(&var_node, var_ast, BP_VAR_RW, 0); + zend_op *opline = zend_compile_var(&var_node, var_ast, BP_VAR_RW, false); if (opline && opline->opcode == ZEND_FETCH_DIM_RW) { opline->extended_value = ZEND_FETCH_DIM_INCDEC; } @@ -10455,7 +10548,7 @@ static void zend_compile_pre_incdec(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_cast(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_cast(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; znode expr_node; @@ -10568,7 +10661,7 @@ static void zend_compile_coalesce(znode *result, zend_ast *ast) /* {{{ */ zend_op *opline; uint32_t opnum; - zend_compile_var(&expr_node, expr_ast, BP_VAR_IS, 0); + zend_compile_var(&expr_node, expr_ast, BP_VAR_IS, false); opnum = get_next_op_number(); zend_emit_op_tmp(result, ZEND_COALESCE, &expr_node, NULL); @@ -10599,7 +10692,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */ znode var_node_is, var_node_w, default_node, assign_node, *node; zend_op *opline; uint32_t coalesce_opnum; - bool need_frees = 0; + bool need_frees = false; /* Remember expressions compiled during the initial BP_VAR_IS lookup, * to avoid double-evaluation when we compile again with BP_VAR_W. */ @@ -10615,7 +10708,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */ zend_hash_init(CG(memoized_exprs), 0, NULL, znode_dtor, 0); CG(memoize_mode) = ZEND_MEMOIZE_COMPILE; - zend_compile_var(&var_node_is, var_ast, BP_VAR_IS, 0); + zend_compile_var(&var_node_is, var_ast, BP_VAR_IS, false); coalesce_opnum = get_next_op_number(); zend_emit_op_tmp(result, ZEND_COALESCE, &var_node_is, NULL); @@ -10628,7 +10721,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */ } CG(memoize_mode) = ZEND_MEMOIZE_FETCH; - zend_compile_var(&var_node_w, var_ast, BP_VAR_W, 0); + zend_compile_var(&var_node_w, var_ast, BP_VAR_W, false); /* Reproduce some of the zend_compile_assign() opcode fixup logic here. */ opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1]; @@ -10668,7 +10761,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */ ZEND_HASH_FOREACH_PTR(CG(memoized_exprs), node) { if (node->op_type == IS_TMP_VAR || node->op_type == IS_VAR) { - need_frees = 1; + need_frees = true; break; } } ZEND_HASH_FOREACH_END(); @@ -10694,7 +10787,7 @@ static void zend_compile_assign_coalesce(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_print(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_print(znode *result, const zend_ast *ast) /* {{{ */ { zend_op *opline; zend_ast *expr_ast = ast->child[0]; @@ -10730,7 +10823,7 @@ static void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */ if (value_ast) { if (returns_by_ref && zend_is_variable(value_ast)) { zend_assert_not_short_circuited(value_ast); - zend_compile_var(&value_node, value_ast, BP_VAR_W, 1); + zend_compile_var(&value_node, value_ast, BP_VAR_W, true); } else { zend_compile_expr(&value_node, value_ast); } @@ -10745,7 +10838,7 @@ static void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_yield_from(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_yield_from(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; znode expr_node; @@ -10794,7 +10887,7 @@ static void zend_compile_instanceof(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_include_or_eval(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_include_or_eval(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; znode expr_node; @@ -10810,7 +10903,7 @@ static void zend_compile_include_or_eval(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_isset_or_empty(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *var_ast = ast->child[0]; @@ -10863,7 +10956,7 @@ static void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */ } else if (zend_try_compile_cv(&var_node, var_ast, BP_VAR_IS) == SUCCESS) { opline = zend_emit_op(result, ZEND_ISSET_ISEMPTY_CV, &var_node, NULL); } else { - opline = zend_compile_simple_var_no_cv(result, var_ast, BP_VAR_IS, 0); + opline = zend_compile_simple_var_no_cv(result, var_ast, BP_VAR_IS, false); opline->opcode = ZEND_ISSET_ISEMPTY_VAR; } break; @@ -10873,11 +10966,11 @@ static void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */ break; case ZEND_AST_PROP: case ZEND_AST_NULLSAFE_PROP: - opline = zend_compile_prop(result, var_ast, BP_VAR_IS, 0); + opline = zend_compile_prop(result, var_ast, BP_VAR_IS, false); opline->opcode = ZEND_ISSET_ISEMPTY_PROP_OBJ; break; case ZEND_AST_STATIC_PROP: - opline = zend_compile_static_prop(result, var_ast, BP_VAR_IS, 0, 0); + opline = zend_compile_static_prop(result, var_ast, BP_VAR_IS, false, false); opline->opcode = ZEND_ISSET_ISEMPTY_STATIC_PROP; break; EMPTY_SWITCH_DEFAULT_CASE() @@ -10890,7 +10983,7 @@ static void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_silence(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_silence(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; znode silence_node; @@ -10900,7 +10993,7 @@ static void zend_compile_silence(znode *result, zend_ast *ast) /* {{{ */ if (expr_ast->kind == ZEND_AST_VAR) { /* For @$var we need to force a FETCH instruction, otherwise the CV access will * happen outside the silenced section. */ - zend_compile_simple_var_no_cv(result, expr_ast, BP_VAR_R, 0 ); + zend_compile_simple_var_no_cv(result, expr_ast, BP_VAR_R, false ); } else { zend_compile_expr(result, expr_ast); } @@ -10909,7 +11002,7 @@ static void zend_compile_silence(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_shell_exec(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_shell_exec(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; @@ -10934,7 +11027,7 @@ static void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */ zend_ast_list *list = zend_ast_get_list(ast); zend_op *opline; uint32_t i, opnum_init = -1; - bool packed = 1; + bool packed = true; if (zend_try_ct_eval_array(&result->u.constant, ast)) { result->op_type = IS_CONST; @@ -10978,7 +11071,7 @@ static void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */ if (by_ref) { zend_ensure_writable_variable(value_ast); - zend_compile_var(&value_node, value_ast, BP_VAR_W, 1); + zend_compile_var(&value_node, value_ast, BP_VAR_W, true); } else { zend_compile_expr(&value_node, value_ast); } @@ -10995,7 +11088,7 @@ static void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */ opline->extended_value |= by_ref; if (key_ast && key_node.op_type == IS_CONST && Z_TYPE(key_node.u.constant) == IS_STRING) { - packed = 0; + packed = false; } } @@ -11008,7 +11101,7 @@ static void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_const(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *name_ast = ast->child[0]; @@ -11022,7 +11115,7 @@ static void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */ zend_ast *last = CG(ast); while (last && last->kind == ZEND_AST_STMT_LIST) { - zend_ast_list *list = zend_ast_get_list(last); + const zend_ast_list *list = zend_ast_get_list(last); if (list->children == 0) { break; } @@ -11048,11 +11141,11 @@ static void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */ if (is_fully_qualified || !FC(current_namespace)) { opline->op1.num = 0; opline->op2.constant = zend_add_const_name_literal( - resolved_name, 0); + resolved_name, false); } else { opline->op1.num = IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE; opline->op2.constant = zend_add_const_name_literal( - resolved_name, 1); + resolved_name, true); } opline->extended_value = zend_alloc_cache_slot(); } @@ -11099,7 +11192,7 @@ static void zend_compile_class_const(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_class_name(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_class_name(znode *result, const zend_ast *ast) /* {{{ */ { zend_ast *class_ast = ast->child[0]; @@ -11294,7 +11387,7 @@ static void zend_compile_encaps_list(znode *result, zend_ast *ast) /* {{{ */ } /* }}} */ -static void zend_compile_magic_const(znode *result, zend_ast *ast) /* {{{ */ +static void zend_compile_magic_const(znode *result, const zend_ast *ast) /* {{{ */ { zend_op *opline; @@ -11469,7 +11562,7 @@ static void zend_compile_const_expr_new(zend_ast **ast_ptr) zend_ast *class_ast = (*ast_ptr)->child[0]; zend_compile_const_expr_class_reference(class_ast); - zend_ast *args_ast = (*ast_ptr)->child[1]; + const zend_ast *args_ast = (*ast_ptr)->child[1]; if (args_ast->kind == ZEND_AST_CALLABLE_CONVERT) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot create Closure for new expression"); } @@ -11478,7 +11571,7 @@ static void zend_compile_const_expr_new(zend_ast **ast_ptr) static void zend_compile_const_expr_closure(zend_ast **ast_ptr) { zend_ast_decl *closure_ast = (zend_ast_decl *) *ast_ptr; - zend_ast *uses_ast = closure_ast->child[1]; + const zend_ast *uses_ast = closure_ast->child[1]; if (!(closure_ast->flags & ZEND_ACC_STATIC)) { zend_error_noreturn(E_COMPILE_ERROR, "Closures in constant expressions must be static"); @@ -11552,7 +11645,7 @@ static void zend_compile_const_expr_args(zend_ast **ast_ptr) zend_ast_list *list = zend_ast_get_list(*ast_ptr); bool uses_named_args = false; for (uint32_t i = 0; i < list->children; i++) { - zend_ast *arg = list->child[i]; + const zend_ast *arg = list->child[i]; if (arg->kind == ZEND_AST_UNPACK) { zend_error_noreturn(E_COMPILE_ERROR, "Argument unpacking in constant expressions is not supported"); @@ -11576,7 +11669,7 @@ typedef struct { static void zend_compile_const_expr(zend_ast **ast_ptr, void *context) /* {{{ */ { - const_expr_context *ctx = (const_expr_context *) context; + const const_expr_context *ctx = context; zend_ast *ast = *ast_ptr; if (ast == NULL || ast->kind == ZEND_AST_ZVAL) { return; @@ -11655,7 +11748,7 @@ void zend_compile_top_stmt(zend_ast *ast) /* {{{ */ } if (ast->kind == ZEND_AST_STMT_LIST) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); uint32_t i; for (i = 0; i < list->children; ++i) { zend_compile_top_stmt(list->child[i]); @@ -11669,7 +11762,7 @@ void zend_compile_top_stmt(zend_ast *ast) /* {{{ */ CG(zend_lineno) = ((zend_ast_decl *) ast)->end_lineno; } else if (ast->kind == ZEND_AST_CLASS) { CG(zend_lineno) = ast->lineno; - zend_compile_class_decl(NULL, ast, 1); + zend_compile_class_decl(NULL, ast, true); CG(zend_lineno) = ((zend_ast_decl *) ast)->end_lineno; } else { zend_compile_stmt(ast); @@ -11762,7 +11855,7 @@ static void zend_compile_stmt(zend_ast *ast) /* {{{ */ zend_compile_use_trait(ast); break; case ZEND_AST_CLASS: - zend_compile_class_decl(NULL, ast, 0); + zend_compile_class_decl(NULL, ast, false); break; case ZEND_AST_GROUP_USE: zend_compile_group_use(ast); @@ -11827,7 +11920,7 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */ case ZEND_AST_NULLSAFE_METHOD_CALL: case ZEND_AST_STATIC_CALL: case ZEND_AST_PARENT_PROPERTY_HOOK_CALL: - zend_compile_var(result, ast, BP_VAR_R, 0); + zend_compile_var(result, ast, BP_VAR_R, false); return; case ZEND_AST_ASSIGN: zend_compile_assign(result, ast); @@ -11968,14 +12061,14 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty switch (ast->kind) { case ZEND_AST_VAR: - return zend_compile_simple_var(result, ast, type, 0); + return zend_compile_simple_var(result, ast, type, false); case ZEND_AST_DIM: return zend_compile_dim(result, ast, type, by_ref); case ZEND_AST_PROP: case ZEND_AST_NULLSAFE_PROP: return zend_compile_prop(result, ast, type, by_ref); case ZEND_AST_STATIC_PROP: - return zend_compile_static_prop(result, ast, type, by_ref, 0); + return zend_compile_static_prop(result, ast, type, by_ref, false); case ZEND_AST_CALL: zend_compile_call(result, ast, type); return NULL; @@ -12019,7 +12112,7 @@ static zend_op *zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t switch (ast->kind) { case ZEND_AST_VAR: - return zend_compile_simple_var(result, ast, type, 1); + return zend_compile_simple_var(result, ast, type, true); case ZEND_AST_DIM: return zend_delayed_compile_dim(result, ast, type, by_ref); case ZEND_AST_PROP: @@ -12032,9 +12125,9 @@ static zend_op *zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t return opline; } case ZEND_AST_STATIC_PROP: - return zend_compile_static_prop(result, ast, type, by_ref, 1); + return zend_compile_static_prop(result, ast, type, by_ref, true); default: - return zend_compile_var(result, ast, type, 0); + return zend_compile_var(result, ast, type, false); } } /* }}} */ @@ -12047,7 +12140,7 @@ bool zend_try_ct_eval_cast(zval *result, uint32_t type, zval *op1) } switch (type) { case _IS_BOOL: - ZVAL_BOOL(result, zval_is_true(op1)); + ZVAL_BOOL(result, zend_is_true(op1)); return true; case IS_LONG: if (Z_TYPE_P(op1) == IS_DOUBLE && !ZEND_DOUBLE_FITS_LONG(Z_DVAL_P((op1)))) { @@ -12210,7 +12303,7 @@ static void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ case ZEND_AST_DIM: { /* constant expression should be always read context ... */ - zval *container, *dim; + const zval *container, *dim; if (ast->child[1] == NULL) { zend_error_noreturn(E_COMPILE_ERROR, "Cannot use [] for reading"); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index c07fa9bfa7d7e..d2a3b47bf92f4 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -197,8 +197,8 @@ 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; + uint32_t vars_size; + uint32_t literals_size; uint32_t fast_call_var; uint32_t try_catch_offset; int current_brk_cont; @@ -341,6 +341,11 @@ typedef struct _zend_oparray_context { /* Class cannot be serialized or unserialized | | | */ #define ZEND_ACC_NOT_SERIALIZABLE (1 << 29) /* X | | | */ /* | | | */ +/* Class Flags 2 (ce_flags2) (unused: 0-31) | | | */ +/* ========================= | | | */ +/* | | | */ +/* #define ZEND_ACC2_EXAMPLE (1 << 0) X | | | */ +/* | | | */ /* Function Flags (unused: 30) | | | */ /* ============== | | | */ /* | | | */ @@ -407,6 +412,11 @@ typedef struct _zend_oparray_context { /* | | | */ /* op_array uses strict mode types | | | */ #define ZEND_ACC_STRICT_TYPES (1U << 31) /* | X | | */ +/* | | | */ +/* Function Flags 2 (fn_flags2) (unused: 0-31) | | | */ +/* ============================ | | | */ +/* | | | */ +/* #define ZEND_ACC2_EXAMPLE (1 << 0) | X | | */ #define ZEND_ACC_PPP_MASK (ZEND_ACC_PUBLIC | ZEND_ACC_PROTECTED | ZEND_ACC_PRIVATE) #define ZEND_ACC_PPP_SET_MASK (ZEND_ACC_PUBLIC_SET | ZEND_ACC_PROTECTED_SET | ZEND_ACC_PRIVATE_SET) @@ -443,7 +453,7 @@ static zend_always_inline uint32_t zend_visibility_to_set_visibility(uint32_t vi // Must not clash with ZEND_SHORT_CIRCUITING_CHAIN_MASK #define ZEND_JMP_NULL_BP_VAR_IS 4 -char *zend_visibility_string(uint32_t fn_flags); +const char *zend_visibility_string(uint32_t fn_flags); #define ZEND_PROPERTY_HOOK_COUNT 2 #define ZEND_PROPERTY_HOOK_STRUCT_SIZE (sizeof(zend_function*) * ZEND_PROPERTY_HOOK_COUNT) @@ -451,7 +461,7 @@ char *zend_visibility_string(uint32_t fn_flags); /* Stored in zend_property_info.offset, not returned by zend_get_property_offset(). */ #define ZEND_VIRTUAL_PROPERTY_OFFSET ((uint32_t)-1) -zend_property_hook_kind zend_get_property_hook_kind_from_name(zend_string *name); +zend_property_hook_kind zend_get_property_hook_kind_from_name(const zend_string *name); typedef struct _zend_property_info { uint32_t offset; /* property offset for object properties or @@ -527,12 +537,13 @@ struct _zend_op_array { ZEND_MAP_PTR_DEF(void **, run_time_cache); zend_string *doc_comment; uint32_t T; /* number of temporary variables */ + uint32_t fn_flags2; const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */ /* END of common elements */ - int cache_size; /* number of run_time_cache_slots * sizeof(void*) */ - int last_var; /* number of CV variables */ - uint32_t last; /* number of opcodes */ + uint32_t cache_size; /* number of run_time_cache_slots * sizeof(void*) */ + int last_var; /* number of CV variables */ + uint32_t last; /* number of opcodes */ zend_op *opcodes; ZEND_MAP_PTR_DEF(HashTable *, static_variables_ptr); @@ -541,8 +552,8 @@ struct _zend_op_array { uint32_t *refcount; - int last_live_range; - int last_try_catch; + uint32_t last_live_range; + uint32_t last_try_catch; zend_live_range *live_range; zend_try_catch_element *try_catch_array; @@ -550,7 +561,7 @@ struct _zend_op_array { uint32_t line_start; uint32_t line_end; - int last_literal; + uint32_t last_literal; uint32_t num_dynamic_func_defs; zval *literals; @@ -581,11 +592,12 @@ typedef struct _zend_internal_function { zend_function *prototype; uint32_t num_args; uint32_t required_num_args; - zend_internal_arg_info *arg_info; + zend_arg_info *arg_info; HashTable *attributes; ZEND_MAP_PTR_DEF(void **, run_time_cache); zend_string *doc_comment; uint32_t T; /* number of temporary variables */ + uint32_t fn_flags2; const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */ /* END of common elements */ @@ -615,6 +627,7 @@ union _zend_function { ZEND_MAP_PTR_DEF(void **, run_time_cache); zend_string *doc_comment; uint32_t T; /* number of temporary variables */ + uint32_t fn_flags2; const zend_property_info *prop_info; /* The corresponding prop_info if this is a hook. */ } common; @@ -867,9 +880,9 @@ void shutdown_compiler(void); void zend_init_compiler_data_structures(void); 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_oparray_context_end(const 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); +void zend_file_context_end(const zend_file_context *prev_context); extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type); extern ZEND_API zend_op_array *(*zend_compile_string)(zend_string *source_string, const char *filename, zend_compile_position position); @@ -881,7 +894,7 @@ void shutdown_scanner(void); ZEND_API zend_string *zend_set_compiled_filename(zend_string *new_compiled_filename); ZEND_API void zend_restore_compiled_filename(zend_string *original_compiled_filename); ZEND_API zend_string *zend_get_compiled_filename(void); -ZEND_API int zend_get_compiled_lineno(void); +ZEND_API uint32_t zend_get_compiled_lineno(void); ZEND_API size_t zend_get_scanned_file_offset(void); ZEND_API zend_string *zend_get_compiled_variable_name(const zend_op_array *op_array, uint32_t var); @@ -920,8 +933,8 @@ uint32_t zend_modifier_list_to_flags(zend_modifier_target target, zend_ast *modi bool zend_handle_encoding_declaration(zend_ast *ast); ZEND_API zend_class_entry *zend_bind_class_in_slot( - zval *class_table_slot, zval *lcname, zend_string *lc_parent_name); -ZEND_API zend_result do_bind_function(zend_function *func, zval *lcname); + zval *class_table_slot, const zval *lcname, zend_string *lc_parent_name); +ZEND_API zend_result do_bind_function(zend_function *func, const zval *lcname); ZEND_API zend_result do_bind_class(zval *lcname, zend_string *lc_parent_name); void zend_resolve_goto_label(zend_op_array *op_array, zend_op *opline); @@ -950,7 +963,7 @@ ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle); ZEND_API void zend_cleanup_mutable_class_data(zend_class_entry *ce); ZEND_API void zend_cleanup_internal_class_data(zend_class_entry *ce); ZEND_API void zend_type_release(zend_type type, bool persistent); -ZEND_API zend_string *zend_create_member_string(zend_string *class_name, zend_string *member_name); +ZEND_API zend_string *zend_create_member_string(const zend_string *class_name, const zend_string *member_name); ZEND_API ZEND_COLD void zend_user_exception_handler(void); @@ -963,7 +976,8 @@ ZEND_API ZEND_COLD void zend_user_exception_handler(void); } \ } while (0) -void zend_free_internal_arg_info(zend_internal_function *function); +ZEND_API void zend_free_internal_arg_info(zend_internal_function *function, + bool permanent); ZEND_API void destroy_zend_function(zend_function *function); ZEND_API void zend_function_dtor(zval *zv); ZEND_API void destroy_zend_class(zval *zv); @@ -983,7 +997,7 @@ static zend_always_inline const char *zend_get_unmangled_property_name(const zen #define ZEND_FUNCTION_DTOR zend_function_dtor #define ZEND_CLASS_DTOR destroy_zend_class -typedef bool (*zend_needs_live_range_cb)(zend_op_array *op_array, zend_op *opline); +typedef bool (*zend_needs_live_range_cb)(const zend_op_array *op_array, const zend_op *opline); ZEND_API void zend_recalc_live_ranges( zend_op_array *op_array, zend_needs_live_range_cb needs_live_range); @@ -992,7 +1006,7 @@ ZEND_API bool zend_is_compiling(void); ZEND_API char *zend_make_compiled_string_description(const char *name); ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_handlers); uint32_t zend_get_class_fetch_type(const zend_string *name); -ZEND_API uint8_t zend_get_call_op(const zend_op *init_op, zend_function *fbc, bool result_used); +ZEND_API uint8_t zend_get_call_op(const zend_op *init_op, const zend_function *fbc, bool result_used); ZEND_API bool zend_is_smart_branch(const zend_op *opline); typedef bool (*zend_auto_global_callback)(zend_string *name); diff --git a/Zend/zend_cpuinfo.c b/Zend/zend_cpuinfo.c index 6264031ceba42..9f8f1354be061 100644 --- a/Zend/zend_cpuinfo.c +++ b/Zend/zend_cpuinfo.c @@ -93,21 +93,21 @@ static unsigned get_xcr0_eax(void) { static bool is_avx_supported(void) { if (!(cpuinfo.ecx & ZEND_CPU_FEATURE_AVX)) { /* No support for AVX */ - return 0; + return false; } if (!(cpuinfo.ecx & ZEND_CPU_FEATURE_OSXSAVE)) { /* The operating system does not support XSAVE. */ - return 0; + return false; } if ((get_xcr0_eax() & 0x6) != 0x6) { /* XCR0 SSE and AVX bits must be set. */ - return 0; + return false; } - return 1; + return true; } #else static bool is_avx_supported(void) { - return 0; + return false; } #endif diff --git a/Zend/zend_enum.c b/Zend/zend_enum.c index ae9e7b701213f..00fbab22a056e 100644 --- a/Zend/zend_enum.c +++ b/Zend/zend_enum.c @@ -36,6 +36,10 @@ ZEND_API zend_class_entry *zend_ce_unit_enum; ZEND_API zend_class_entry *zend_ce_backed_enum; ZEND_API zend_object_handlers zend_enum_object_handlers; +static zend_arg_info zarginfo_class_UnitEnum_cases[sizeof(arginfo_class_UnitEnum_cases)/sizeof(zend_internal_arg_info)]; +static zend_arg_info zarginfo_class_BackedEnum_from[sizeof(arginfo_class_BackedEnum_from)/sizeof(zend_internal_arg_info)]; +static zend_arg_info zarginfo_class_BackedEnum_tryFrom[sizeof(arginfo_class_BackedEnum_tryFrom)/sizeof(zend_internal_arg_info)]; + zend_object *zend_enum_new(zval *result, zend_class_entry *ce, zend_string *case_name, zval *backing_value_zv) { zend_object *zobj = zend_objects_new(ce); @@ -446,7 +450,7 @@ void zend_enum_register_funcs(zend_class_entry *ce) cases_function->function_name = ZSTR_KNOWN(ZEND_STR_CASES); cases_function->fn_flags = fn_flags; cases_function->doc_comment = NULL; - cases_function->arg_info = (zend_internal_arg_info *) (arginfo_class_UnitEnum_cases + 1); + cases_function->arg_info = zarginfo_class_UnitEnum_cases + 1; zend_enum_register_func(ce, ZEND_STR_CASES, cases_function); if (ce->enum_backing_type != IS_UNDEF) { @@ -457,7 +461,7 @@ void zend_enum_register_funcs(zend_class_entry *ce) from_function->doc_comment = NULL; from_function->num_args = 1; from_function->required_num_args = 1; - from_function->arg_info = (zend_internal_arg_info *) (arginfo_class_BackedEnum_from + 1); + from_function->arg_info = zarginfo_class_BackedEnum_from + 1; zend_enum_register_func(ce, ZEND_STR_FROM, from_function); zend_internal_function *try_from_function = zend_arena_calloc(&CG(arena), sizeof(zend_internal_function), 1); @@ -467,7 +471,7 @@ void zend_enum_register_funcs(zend_class_entry *ce) try_from_function->doc_comment = NULL; try_from_function->num_args = 1; try_from_function->required_num_args = 1; - try_from_function->arg_info = (zend_internal_arg_info *) (arginfo_class_BackedEnum_tryFrom + 1); + try_from_function->arg_info = zarginfo_class_BackedEnum_tryFrom + 1; zend_enum_register_func(ce, ZEND_STR_TRYFROM_LOWERCASE, try_from_function); } } @@ -633,3 +637,16 @@ ZEND_API zend_object *zend_enum_get_case_cstr(zend_class_entry *ce, const char * zend_class_constant *c = zend_hash_str_find_ptr(CE_CONSTANTS_TABLE(ce), name, strlen(name)); return zend_enum_case_from_class_constant(c); } + +void zend_enum_startup(void) +{ + for (size_t i = 0; i < sizeof(zarginfo_class_UnitEnum_cases)/sizeof(zend_arg_info); i++) { + zend_convert_internal_arg_info(&zarginfo_class_UnitEnum_cases[i], &arginfo_class_UnitEnum_cases[i], i == 0, true); + } + for (size_t i = 0; i < sizeof(zarginfo_class_BackedEnum_from)/sizeof(zend_arg_info); i++) { + zend_convert_internal_arg_info(&zarginfo_class_BackedEnum_from[i], &arginfo_class_BackedEnum_from[i], i == 0, true); + } + for (size_t i = 0; i < sizeof(zarginfo_class_BackedEnum_tryFrom)/sizeof(zend_arg_info); i++) { + zend_convert_internal_arg_info(&zarginfo_class_BackedEnum_tryFrom[i], &arginfo_class_BackedEnum_tryFrom[i], i == 0, true); + } +} diff --git a/Zend/zend_enum.h b/Zend/zend_enum.h index 7b3b0184b4eb5..d6c820189475a 100644 --- a/Zend/zend_enum.h +++ b/Zend/zend_enum.h @@ -30,6 +30,7 @@ extern ZEND_API zend_class_entry *zend_ce_unit_enum; extern ZEND_API zend_class_entry *zend_ce_backed_enum; extern ZEND_API zend_object_handlers zend_enum_object_handlers; +void zend_enum_startup(void); void zend_register_enum_ce(void); void zend_enum_add_interfaces(zend_class_entry *ce); zend_result zend_enum_build_backed_enum_table(zend_class_entry *ce); diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index 77b754c91086c..191d8f7fe6aec 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -400,7 +400,7 @@ ZEND_METHOD(ErrorException, __construct) { zend_string *message = NULL, *filename = NULL; zend_long code = 0, severity = E_ERROR, lineno; - bool lineno_is_null = 1; + bool lineno_is_null = true; zval tmp, *object, *previous = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|SllS!l!O!", &message, &code, &severity, &filename, &lineno, &lineno_is_null, &previous, zend_ce_throwable) == FAILURE) { diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 5665cc0c3f784..518cbb98fc0f8 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -136,8 +136,7 @@ static ZEND_FUNCTION(pass) { } -ZEND_BEGIN_ARG_INFO_EX(zend_pass_function_arg_info, 0, 0, 0) -ZEND_END_ARG_INFO() +static zend_arg_info zend_pass_function_arg_info[1] = {0}; ZEND_API const zend_internal_function zend_pass_function = { ZEND_INTERNAL_FUNCTION, /* type */ @@ -148,11 +147,12 @@ ZEND_API const zend_internal_function zend_pass_function = { NULL, /* prototype */ 0, /* num_args */ 0, /* required_num_args */ - (zend_internal_arg_info *) zend_pass_function_arg_info + 1, /* arg_info */ + zend_pass_function_arg_info + 1, /* arg_info */ NULL, /* attributes */ NULL, /* run_time_cache */ NULL, /* doc_comment */ 0, /* T */ + 0, /* fn_flags2 */ NULL, /* prop_info */ ZEND_FN(pass), /* handler */ NULL, /* module */ @@ -746,36 +746,36 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg) if (type == IS_LONG) { zend_string_release(Z_STR_P(arg)); ZVAL_LONG(arg, lval); - return 1; + return true; } if (type == IS_DOUBLE) { zend_string_release(Z_STR_P(arg)); ZVAL_DOUBLE(arg, dval); - return 1; + return true; } } else if (zend_parse_arg_long_weak(arg, &lval, 0)) { zval_ptr_dtor(arg); ZVAL_LONG(arg, lval); - return 1; + return true; } else if (UNEXPECTED(EG(exception))) { - return 0; + return false; } } if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, 0)) { zval_ptr_dtor(arg); ZVAL_DOUBLE(arg, dval); - return 1; + return true; } if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, &str, 0)) { /* on success "arg" is converted to IS_STRING */ - return 1; + return true; } if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, 0)) { zval_ptr_dtor(arg); ZVAL_BOOL(arg, bval); - return 1; + return true; } - return 0; + return false; } #if ZEND_DEBUG @@ -800,18 +800,18 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask, /* Pass (uint32_t)-1 as arg_num to indicate to ZPP not to emit any deprecation notice, * this is needed because the version with side effects also uses 0 (e.g. for typed properties) */ if ((type_mask & MAY_BE_LONG) && zend_parse_arg_long_weak(arg, &lval, (uint32_t)-1)) { - return 1; + return true; } if ((type_mask & MAY_BE_DOUBLE) && zend_parse_arg_double_weak(arg, &dval, (uint32_t)-1)) { - return 1; + return true; } if ((type_mask & MAY_BE_STRING) && can_convert_to_string(arg)) { - return 1; + return true; } if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, &bval, (uint32_t)-1)) { - return 1; + return true; } - return 0; + return false; } #endif @@ -1051,7 +1051,7 @@ static zend_always_inline bool i_zend_check_property_type(const zend_property_in uint32_t type_mask = ZEND_TYPE_FULL_MASK(info->type); ZEND_ASSERT(!(type_mask & (MAY_BE_CALLABLE|MAY_BE_STATIC|MAY_BE_NEVER|MAY_BE_VOID))); - return zend_verify_scalar_type_hint(type_mask, property, strict, 0); + return zend_verify_scalar_type_hint(type_mask, property, strict, false); } static zend_always_inline bool i_zend_verify_property_type(const zend_property_info *info, zval *property, bool strict) @@ -1246,7 +1246,7 @@ static zend_always_inline bool zend_verify_recv_arg_type(const zend_function *zf cur_arg_info = &zf->common.arg_info[arg_num-1]; if (ZEND_TYPE_IS_SET(cur_arg_info->type) - && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, zf->common.scope, 0, 0))) { + && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, zf->common.scope, false, false))) { zend_verify_arg_error(zf, cur_arg_info, arg_num, arg); return 0; } @@ -1258,7 +1258,7 @@ static zend_always_inline bool zend_verify_variadic_arg_type( const zend_function *zf, const zend_arg_info *arg_info, uint32_t arg_num, zval *arg) { ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type)); - if (UNEXPECTED(!zend_check_type(&arg_info->type, arg, zf->common.scope, 0, 0))) { + if (UNEXPECTED(!zend_check_type(&arg_info->type, arg, zf->common.scope, false, false))) { zend_verify_arg_error(zf, arg_info, arg_num, arg); return 0; } @@ -1283,7 +1283,7 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ } if (ZEND_TYPE_IS_SET(cur_arg_info->type) - && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, fbc->common.scope, 0, /* is_internal */ 1))) { + && UNEXPECTED(!zend_check_type(&cur_arg_info->type, arg, fbc->common.scope, false, /* is_internal */ true))) { return 0; } arg++; @@ -1479,7 +1479,7 @@ static ZEND_COLD void zend_verify_void_return_error(const zend_function *zf, con ZEND_API bool zend_verify_internal_return_type(const zend_function *zf, zval *ret) { - const zend_internal_arg_info *ret_info = zf->internal_function.arg_info - 1; + const zend_arg_info *ret_info = zf->internal_function.arg_info - 1; if (ZEND_TYPE_FULL_MASK(ret_info->type) & MAY_BE_VOID) { if (UNEXPECTED(Z_TYPE_P(ret) != IS_NULL)) { @@ -1489,7 +1489,7 @@ ZEND_API bool zend_verify_internal_return_type(const zend_function *zf, zval *re return 1; } - if (UNEXPECTED(!zend_check_type(&ret_info->type, ret, NULL, 1, /* is_internal */ 1))) { + if (UNEXPECTED(!zend_check_type(&ret_info->type, ret, NULL, true, /* is_internal */ true))) { zend_verify_internal_return_error(zf, ret); return 0; } @@ -4345,7 +4345,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_fcall_interrupt(zend_execute_data *ca */ static zend_never_inline void zend_copy_extra_args(EXECUTE_DATA_D) { - zend_op_array *op_array = &EX(func)->op_array; + const zend_op_array *op_array = &EX(func)->op_array; uint32_t first_extra_arg = op_array->num_args; uint32_t num_args = EX_NUM_ARGS(); zval *src; @@ -4925,7 +4925,7 @@ static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, zval_ptr_dtor_nogc(var); } else if (kind == ZEND_LIVE_ROPE) { zend_string **rope = (zend_string **)var; - zend_op *last = EX(func)->op_array.opcodes + op_num; + const zend_op *last = EX(func)->op_array.opcodes + op_num; while ((last->opcode != ZEND_ROPE_ADD && last->opcode != ZEND_ROPE_INIT) || last->result.var != var_num) { ZEND_ASSERT(last >= EX(func)->op_array.opcodes); @@ -4934,7 +4934,7 @@ static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, if (last->opcode == ZEND_ROPE_INIT) { zend_string_release_ex(*rope, 0); } else { - int j = last->extended_value; + uint32_t j = last->extended_value; do { zend_string_release_ex(rope[j], 0); } while (j--); @@ -4981,7 +4981,7 @@ ZEND_API HashTable *zend_unfinished_execution_gc_ex(zend_execute_data *execute_d return NULL; } - zend_op_array *op_array = &EX(func)->op_array; + const zend_op_array *op_array = &EX(func)->op_array; if (!(EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE)) { uint32_t i, num_cvs = EX(func)->op_array.last_var; @@ -4992,7 +4992,7 @@ ZEND_API HashTable *zend_unfinished_execution_gc_ex(zend_execute_data *execute_d if (EX_CALL_INFO() & ZEND_CALL_FREE_EXTRA_ARGS) { zval *zv = EX_VAR_NUM(op_array->last_var + op_array->T); - zval *end = zv + (EX_NUM_ARGS() - op_array->num_args); + const zval *end = zv + (EX_NUM_ARGS() - op_array->num_args); while (zv != end) { zend_get_gc_buffer_add_zval(gc_buffer, zv++); } @@ -5461,7 +5461,7 @@ static zend_never_inline zend_result ZEND_FASTCALL zend_quick_check_constant( } /* }}} */ static zend_always_inline uint32_t zend_get_arg_offset_by_name( - zend_function *fbc, zend_string *arg_name, void **cache_slot) { + const zend_function *fbc, const zend_string *arg_name, void **cache_slot) { /* Due to closures, the `fbc` address isn't unique if the memory address is reused. * The argument info will be however and uniquely positions the arguments. * We do support NULL arg_info, so we have to distinguish that from an uninitialized cache slot. */ @@ -5473,28 +5473,17 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name( // TODO: Use a hash table? uint32_t num_args = fbc->common.num_args; - if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) - || EXPECTED(fbc->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { - for (uint32_t i = 0; i < num_args; i++) { - zend_arg_info *arg_info = &fbc->common.arg_info[i]; - if (zend_string_equals(arg_name, arg_info->name)) { - if (fbc->type == ZEND_USER_FUNCTION && (!fbc->op_array.refcount || !(fbc->op_array.fn_flags & ZEND_ACC_CLOSURE))) { - *cache_slot = unique_id; - *(uintptr_t *)(cache_slot + 1) = i; - } - return i; - } - } - } else { - ZEND_ASSERT(num_args == 0 || fbc->internal_function.arg_info); - for (uint32_t i = 0; i < num_args; i++) { - zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i]; - size_t len = strlen(arg_info->name); - if (zend_string_equals_cstr(arg_name, arg_info->name, len)) { + for (uint32_t i = 0; i < num_args; i++) { + const zend_arg_info *arg_info = &fbc->common.arg_info[i]; + if (zend_string_equals(arg_name, arg_info->name)) { + if ((fbc->type == ZEND_USER_FUNCTION + && (!fbc->op_array.refcount || !(fbc->op_array.fn_flags & ZEND_ACC_CLOSURE))) + || (fbc->type == ZEND_INTERNAL_FUNCTION + && !(fbc->common.fn_flags & ZEND_ACC_NEVER_CACHE))) { *cache_slot = unique_id; *(uintptr_t *)(cache_slot + 1) = i; - return i; } + return i; } } @@ -5502,7 +5491,7 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name( if ((fbc->type == ZEND_USER_FUNCTION && (!fbc->op_array.refcount || !(fbc->op_array.fn_flags & ZEND_ACC_CLOSURE))) || (fbc->type == ZEND_INTERNAL_FUNCTION - && !(fbc->common.fn_flags & ZEND_ACC_USER_ARG_INFO))) { + && !(fbc->common.fn_flags & ZEND_ACC_NEVER_CACHE))) { *cache_slot = unique_id; *(uintptr_t *)(cache_slot + 1) = fbc->common.num_args; } @@ -5516,7 +5505,7 @@ zval * ZEND_FASTCALL zend_handle_named_arg( zend_execute_data **call_ptr, zend_string *arg_name, uint32_t *arg_num_ptr, void **cache_slot) { zend_execute_data *call = *call_ptr; - zend_function *fbc = call->func; + const zend_function *fbc = call->func; uint32_t arg_offset = zend_get_arg_offset_by_name(fbc, arg_name, cache_slot); if (UNEXPECTED(arg_offset == (uint32_t) -1)) { zend_throw_error(NULL, "Unknown named parameter $%s", ZSTR_VAL(arg_name)); @@ -5602,7 +5591,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal continue; } - zend_op *opline = &op_array->opcodes[i]; + const zend_op *opline = &op_array->opcodes[i]; if (EXPECTED(opline->opcode == ZEND_RECV_INIT)) { zval *default_value = RT_CONSTANT(opline, opline->op2); if (Z_OPT_TYPE_P(default_value) == IS_CONSTANT_AST) { @@ -5660,7 +5649,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal continue; } - zend_internal_arg_info *arg_info = &fbc->internal_function.arg_info[i]; + zend_arg_info *arg_info = &fbc->internal_function.arg_info[i]; if (i < fbc->common.required_num_args) { zend_execute_data *old = start_fake_frame(call, NULL); zend_argument_error(zend_ce_argument_count_error, i + 1, "not passed"); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index c08adf2a41b90..8858f9fce96ae 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -48,11 +48,11 @@ ZEND_API void zend_init_code_execute_data(zend_execute_data *execute_data, zend_ ZEND_API void zend_execute(zend_op_array *op_array, zval *return_value); ZEND_API void execute_ex(zend_execute_data *execute_data); ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value); -ZEND_API bool zend_is_valid_class_name(zend_string *name); +ZEND_API bool zend_is_valid_class_name(const zend_string *name); ZEND_API zend_class_entry *zend_lookup_class(zend_string *name); ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *lcname, uint32_t flags); -ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex); -ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex); +ZEND_API zend_class_entry *zend_get_called_scope(const zend_execute_data *ex); +ZEND_API zend_object *zend_get_this_object(const zend_execute_data *ex); ZEND_API zend_result zend_eval_string(const char *str, zval *retval_ptr, const char *string_name); ZEND_API zend_result zend_eval_stringl(const char *str, size_t str_len, zval *retval_ptr, const char *string_name); ZEND_API zend_result zend_eval_string_ex(const char *str, zval *retval_ptr, const char *string_name, bool handle_exceptions); @@ -359,7 +359,7 @@ static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame_ex(ui } } -static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, zend_function *func) +static zend_always_inline uint32_t zend_vm_calc_used_stack(uint32_t num_args, const zend_function *func) { uint32_t used_stack = ZEND_CALL_FRAME_SLOT + num_args + func->common.T; @@ -453,11 +453,11 @@ ZEND_API const char *get_active_class_name(const char **space); ZEND_API const char *get_active_function_name(void); ZEND_API const char *get_active_function_arg_name(uint32_t arg_num); ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t arg_num); -ZEND_API zend_function *zend_active_function_ex(zend_execute_data *execute_data); +ZEND_API const zend_function *zend_active_function_ex(const zend_execute_data *execute_data); -static zend_always_inline zend_function *zend_active_function(void) +static zend_always_inline const zend_function *zend_active_function(void) { - zend_function *func = EG(current_execute_data)->func; + const zend_function *func = EG(current_execute_data)->func; if (ZEND_USER_CODE(func->type)) { return zend_active_function_ex(EG(current_execute_data)); } else { diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 0719fcbbed1ce..e134d3d496b6d 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -88,7 +88,7 @@ static void zend_handle_sigsegv(void) /* {{{ */ /* }}} */ #endif -static void zend_extension_activator(zend_extension *extension) /* {{{ */ +static void zend_extension_activator(const zend_extension *extension) /* {{{ */ { if (extension->activate) { extension->activate(); @@ -96,7 +96,7 @@ static void zend_extension_activator(zend_extension *extension) /* {{{ */ } /* }}} */ -static void zend_extension_deactivator(zend_extension *extension) /* {{{ */ +static void zend_extension_deactivator(const zend_extension *extension) /* {{{ */ { if (extension->deactivate) { extension->deactivate(); @@ -113,14 +113,14 @@ static int clean_non_persistent_constant_full(zval *zv) /* {{{ */ static int clean_non_persistent_function_full(zval *zv) /* {{{ */ { - zend_function *function = Z_PTR_P(zv); + const zend_function *function = Z_PTR_P(zv); return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; } /* }}} */ static int clean_non_persistent_class_full(zval *zv) /* {{{ */ { - zend_class_entry *ce = Z_PTR_P(zv); + const zend_class_entry *ce = Z_PTR_P(zv); return (ce->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; } /* }}} */ @@ -203,6 +203,8 @@ void init_executor(void) /* {{{ */ zend_fiber_init(); zend_weakrefs_init(); + zend_hash_init(&EG(callable_convert_cache), 8, NULL, ZVAL_PTR_DTOR, 0); + EG(active) = 1; } /* }}} */ @@ -229,7 +231,7 @@ static void zend_unclean_zval_ptr_dtor(zval *zv) /* {{{ */ } /* }}} */ -static ZEND_COLD void zend_throw_or_error(int fetch_type, zend_class_entry *exception_ce, const char *format, ...) /* {{{ */ +static ZEND_COLD void zend_throw_or_error(uint32_t fetch_type, zend_class_entry *exception_ce, const char *format, ...) /* {{{ */ { va_list va; char *message = NULL; @@ -270,9 +272,6 @@ void shutdown_destructors(void) /* {{{ */ /* Free values held by the executor. */ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown) { - zend_string *key; - zval *zv; - EG(flags) |= EG_FLAGS_IN_RESOURCE_SHUTDOWN; zend_close_rsrc_list(&EG(regular_list)); @@ -280,12 +279,15 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown) EG(active) = 0; if (!fast_shutdown) { + zval *zv; + zend_hash_graceful_reverse_destroy(&EG(symbol_table)); /* Constants may contain objects, destroy them before the object store. */ if (EG(full_tables_cleanup)) { zend_hash_reverse_apply(EG(zend_constants), clean_non_persistent_constant_full); } else { + zend_string *key; ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_VAL(EG(zend_constants), key, zv) { zend_constant *c = Z_PTR_P(zv); if (_idx == EG(persistent_constants_count)) { @@ -418,6 +420,8 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown) zend_stack_clean(&EG(user_error_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1); zend_stack_clean(&EG(user_exception_handlers), (void (*)(void *))ZVAL_PTR_DTOR, 1); + zend_hash_clean(&EG(callable_convert_cache)); + #if ZEND_DEBUG if (!CG(unclean_shutdown)) { gc_collect_cycles(); @@ -432,8 +436,6 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown) void shutdown_executor(void) /* {{{ */ { - zend_string *key; - zval *zv; #if ZEND_DEBUG bool fast_shutdown = 0; #elif defined(__SANITIZE_ADDRESS__) @@ -475,6 +477,8 @@ void shutdown_executor(void) /* {{{ */ zend_hash_reverse_apply(EG(function_table), clean_non_persistent_function_full); zend_hash_reverse_apply(EG(class_table), clean_non_persistent_class_full); } else { + zend_string *key; + zval *zv; ZEND_HASH_MAP_REVERSE_FOREACH_STR_KEY_VAL(EG(function_table), key, zv) { zend_function *func = Z_PTR_P(zv); if (_idx == EG(persistent_functions_count)) { @@ -514,6 +518,8 @@ void shutdown_executor(void) /* {{{ */ if (EG(ht_iterators) != EG(ht_iterators_slots)) { efree(EG(ht_iterators)); } + + zend_hash_destroy(&EG(callable_convert_cache)); } #if ZEND_DEBUG @@ -534,7 +540,7 @@ void shutdown_executor(void) /* {{{ */ /* return class name and "::" or "". */ ZEND_API const char *get_active_class_name(const char **space) /* {{{ */ { - zend_function *func; + const zend_function *func; if (!zend_is_executing()) { if (space) { @@ -549,7 +555,7 @@ ZEND_API const char *get_active_class_name(const char **space) /* {{{ */ case ZEND_USER_FUNCTION: case ZEND_INTERNAL_FUNCTION: { - zend_class_entry *ce = func->common.scope; + const zend_class_entry *ce = func->common.scope; if (space) { *space = ce ? "::" : ""; @@ -567,7 +573,7 @@ ZEND_API const char *get_active_class_name(const char **space) /* {{{ */ ZEND_API const char *get_active_function_name(void) /* {{{ */ { - zend_function *func; + const zend_function *func; if (!zend_is_executing()) { return NULL; @@ -577,7 +583,7 @@ ZEND_API const char *get_active_function_name(void) /* {{{ */ switch (func->type) { case ZEND_USER_FUNCTION: { - zend_string *function_name = func->common.function_name; + const zend_string *function_name = func->common.function_name; if (function_name) { return ZSTR_VAL(function_name); @@ -595,9 +601,9 @@ ZEND_API const char *get_active_function_name(void) /* {{{ */ } /* }}} */ -ZEND_API zend_function *zend_active_function_ex(zend_execute_data *execute_data) +ZEND_API const zend_function *zend_active_function_ex(const zend_execute_data *execute_data) { - zend_function *func = EX(func); + const zend_function *func = EX(func); /* Resolve function if op is a frameless call. */ if (ZEND_USER_CODE(func->type)) { @@ -634,7 +640,7 @@ ZEND_API const char *get_active_function_arg_name(uint32_t arg_num) /* {{{ */ return NULL; } - zend_function *func = zend_active_function(); + const zend_function *func = zend_active_function(); return get_function_arg_name(func, arg_num); } @@ -646,17 +652,13 @@ ZEND_API const char *get_function_arg_name(const zend_function *func, uint32_t a return NULL; } - if (func->type == ZEND_USER_FUNCTION || (func->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { - return ZSTR_VAL(func->common.arg_info[arg_num - 1].name); - } else { - return ((zend_internal_arg_info*) func->common.arg_info)[arg_num - 1].name; - } + return ZSTR_VAL(func->common.arg_info[arg_num - 1].name); } /* }}} */ ZEND_API const char *zend_get_executed_filename(void) /* {{{ */ { - zend_string *filename = zend_get_executed_filename_ex(); + const zend_string *filename = zend_get_executed_filename_ex(); return filename != NULL ? ZSTR_VAL(filename) : "[no active file]"; } /* }}} */ @@ -668,7 +670,7 @@ ZEND_API zend_string *zend_get_executed_filename_ex(void) /* {{{ */ return filename_override; } - zend_execute_data *ex = EG(current_execute_data); + const zend_execute_data *ex = EG(current_execute_data); while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { ex = ex->prev_execute_data; @@ -688,7 +690,7 @@ ZEND_API uint32_t zend_get_executed_lineno(void) /* {{{ */ return lineno_override; } - zend_execute_data *ex = EG(current_execute_data); + const zend_execute_data *ex = EG(current_execute_data); while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) { ex = ex->prev_execute_data; @@ -711,7 +713,7 @@ ZEND_API uint32_t zend_get_executed_lineno(void) /* {{{ */ ZEND_API zend_class_entry *zend_get_executed_scope(void) /* {{{ */ { - zend_execute_data *ex = EG(current_execute_data); + const zend_execute_data *ex = EG(current_execute_data); while (1) { if (!ex) { @@ -737,7 +739,7 @@ ZEND_API zend_result ZEND_FASTCALL zval_update_constant_with_ctx(zval *p, zend_c if (ast->kind == ZEND_AST_CONSTANT) { zend_string *name = zend_ast_get_constant_name(ast); - zval *zv = zend_get_constant_ex(name, scope, ast->attr); + const zval *zv = zend_get_constant_ex(name, scope, ast->attr); if (UNEXPECTED(zv == NULL)) { return FAILURE; } @@ -806,7 +808,6 @@ zend_result _call_user_function_impl(zval *object, zval *function_name, zval *re zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /* {{{ */ { - uint32_t i; zend_execute_data *call; zend_fcall_info_cache fci_cache_local; zend_function *func; @@ -857,22 +858,21 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ call_info = ZEND_CALL_TOP_FUNCTION | ZEND_CALL_DYNAMIC | ZEND_CALL_HAS_THIS; } - call = zend_vm_stack_push_call_frame(call_info, - func, fci->param_count, object_or_called_scope); - if (UNEXPECTED(func->common.fn_flags & ZEND_ACC_DEPRECATED)) { zend_deprecated_function(func); if (UNEXPECTED(EG(exception))) { - zend_vm_stack_free_call_frame(call); return SUCCESS; } } - for (i=0; iparam_count; i++) { + call = zend_vm_stack_push_call_frame(call_info, + func, fci->param_count, object_or_called_scope); + + for (uint32_t i = 0; i < fci->param_count; i++) { zval *param = ZEND_CALL_ARG(call, i+1); zval *arg = &fci->params[i]; - bool must_wrap = 0; + bool must_wrap = false; if (UNEXPECTED(Z_ISUNDEF_P(arg))) { /* Allow forwarding undef slots. This is only used by Closure::__invoke(). */ ZVAL_UNDEF(param); @@ -886,7 +886,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ /* By-value send is not allowed -- emit a warning, * and perform the call with the value wrapped in a reference. */ zend_param_must_be_ref(func, i + 1); - must_wrap = 1; + must_wrap = true; if (UNEXPECTED(EG(exception))) { ZEND_CALL_NUM_ARGS(call) = i; cleanup_args: @@ -920,13 +920,13 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ zend_string *name; zval *arg; uint32_t arg_num = ZEND_CALL_NUM_ARGS(call) + 1; - bool have_named_params = 0; + bool have_named_params = false; ZEND_HASH_FOREACH_STR_KEY_VAL(fci->named_params, name, arg) { - bool must_wrap = 0; + bool must_wrap = false; zval *target; if (name) { void *cache_slot[2] = {NULL, NULL}; - have_named_params = 1; + have_named_params = true; target = zend_handle_named_arg(&call, name, &arg_num, cache_slot); if (!target) { goto cleanup_args; @@ -948,7 +948,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_ /* By-value send is not allowed -- emit a warning, * and perform the call with the value wrapped in a reference. */ zend_param_must_be_ref(func, arg_num); - must_wrap = 1; + must_wrap = true; if (UNEXPECTED(EG(exception))) { goto cleanup_args; } @@ -1156,7 +1156,7 @@ static const uint32_t valid_chars[8] = { 0xffffffff, }; -ZEND_API bool zend_is_valid_class_name(zend_string *name) { +ZEND_API bool zend_is_valid_class_name(const zend_string *name) { for (size_t i = 0; i < ZSTR_LEN(name); i++) { unsigned char c = ZSTR_VAL(name)[i]; if (!ZEND_BIT_TEST(valid_chars, c)) { @@ -1296,7 +1296,7 @@ ZEND_API zend_class_entry *zend_lookup_class(zend_string *name) /* {{{ */ } /* }}} */ -ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex) /* {{{ */ +ZEND_API zend_class_entry *zend_get_called_scope(const zend_execute_data *ex) /* {{{ */ { while (ex) { if (Z_TYPE(ex->This) == IS_OBJECT) { @@ -1314,7 +1314,7 @@ ZEND_API zend_class_entry *zend_get_called_scope(zend_execute_data *ex) /* {{{ * } /* }}} */ -ZEND_API zend_object *zend_get_this_object(zend_execute_data *ex) /* {{{ */ +ZEND_API zend_object *zend_get_this_object(const zend_execute_data *ex) /* {{{ */ { while (ex) { if (Z_TYPE(ex->This) == IS_OBJECT) { @@ -1428,14 +1428,14 @@ ZEND_API ZEND_NORETURN void ZEND_FASTCALL zend_timeout(void) /* {{{ */ function. */ if (EG(hard_timeout) > 0) { zend_atomic_bool_store_ex(&EG(timed_out), false); - zend_set_timeout_ex(EG(hard_timeout), 1); + zend_set_timeout_ex(EG(hard_timeout), true); /* XXX Abused, introduce an additional flag if the value needs to be kept. */ EG(hard_timeout) = 0; } # endif #else zend_atomic_bool_store_ex(&EG(timed_out), false); - zend_set_timeout_ex(0, 1); + zend_set_timeout_ex(0, true); #endif zend_error_noreturn(E_ERROR, "Maximum execution time of " ZEND_LONG_FMT " second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s"); @@ -1520,7 +1520,7 @@ static void zend_timeout_handler(int dummy) /* {{{ */ #ifndef ZTS if (EG(hard_timeout) > 0) { /* Set hard timeout */ - zend_set_timeout_ex(EG(hard_timeout), 1); + zend_set_timeout_ex(EG(hard_timeout), true); } #endif } @@ -1687,7 +1687,7 @@ void zend_unset_timeout(void) /* {{{ */ } /* }}} */ -static ZEND_COLD void report_class_fetch_error(zend_string *class_name, uint32_t fetch_type) +static ZEND_COLD void report_class_fetch_error(const zend_string *class_name, uint32_t fetch_type) { if (fetch_type & ZEND_FETCH_CLASS_SILENT) { return; @@ -1856,7 +1856,7 @@ ZEND_API zend_array *zend_rebuild_symbol_table(void) /* {{{ */ ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data) /* {{{ */ { - zend_op_array *op_array = &execute_data->func->op_array; + const zend_op_array *op_array = &execute_data->func->op_array; HashTable *ht = execute_data->symbol_table; /* copy real values from symbol table into CV slots and create @@ -1871,7 +1871,7 @@ ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data) /* {{{ * if (zv) { if (Z_TYPE_P(zv) == IS_INDIRECT) { - zval *val = Z_INDIRECT_P(zv); + const zval *val = Z_INDIRECT_P(zv); ZVAL_COPY_VALUE(var, val); } else { @@ -1891,7 +1891,7 @@ ZEND_API void zend_attach_symbol_table(zend_execute_data *execute_data) /* {{{ * ZEND_API void zend_detach_symbol_table(zend_execute_data *execute_data) /* {{{ */ { - zend_op_array *op_array = &execute_data->func->op_array; + const zend_op_array *op_array = &execute_data->func->op_array; HashTable *ht = execute_data->symbol_table; /* copy real values from CV slots into symbol table */ @@ -1925,7 +1925,7 @@ ZEND_API zend_result zend_set_local_var(zend_string *name, zval *value, bool for if (execute_data) { if (!(EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE)) { zend_ulong h = zend_string_hash_val(name); - zend_op_array *op_array = &execute_data->func->op_array; + const zend_op_array *op_array = &execute_data->func->op_array; if (EXPECTED(op_array->last_var)) { zend_string **str = op_array->vars; @@ -1968,7 +1968,7 @@ ZEND_API zend_result zend_set_local_var_str(const char *name, size_t len, zval * if (execute_data) { if (!(EX_CALL_INFO() & ZEND_CALL_HAS_SYMBOL_TABLE)) { zend_ulong h = zend_hash_func(name, len); - zend_op_array *op_array = &execute_data->func->op_array; + const zend_op_array *op_array = &execute_data->func->op_array; if (EXPECTED(op_array->last_var)) { zend_string **str = op_array->vars; zend_string **end = str + op_array->last_var; diff --git a/Zend/zend_extensions.h b/Zend/zend_extensions.h index 54b19f93ba879..4de8ad5414c2a 100644 --- a/Zend/zend_extensions.h +++ b/Zend/zend_extensions.h @@ -44,7 +44,7 @@ You can use the following macro to check the extension API version for compatibi /* The first number is the engine version and the rest is the date (YYYYMMDD). * This way engine 2/3 API no. is always greater than engine 1 API no.. */ -#define ZEND_EXTENSION_API_NO 420250925 +#define ZEND_EXTENSION_API_NO 420250926 typedef struct _zend_extension_version_info { int zend_extension_api_no; diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index e15f97ecfe802..527ddd4b1931e 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -512,10 +512,10 @@ static void root_buffer_dtor(zend_gc_globals *gc_globals) static void gc_globals_ctor_ex(zend_gc_globals *gc_globals) { - gc_globals->gc_enabled = 0; - gc_globals->gc_active = 0; - gc_globals->gc_protected = 1; - gc_globals->gc_full = 0; + gc_globals->gc_enabled = false; + gc_globals->gc_active = false; + gc_globals->gc_protected = true; + gc_globals->gc_full = false; gc_globals->buf = NULL; gc_globals->unused = GC_INVALID; @@ -1974,8 +1974,8 @@ static zend_never_inline void gc_call_destructors_in_fiber(uint32_t end) ZEND_API int zend_gc_collect_cycles(void) { int total_count = 0; - bool should_rerun_gc = 0; - bool did_rerun_gc = 0; + bool should_rerun_gc = false; + bool did_rerun_gc = false; zend_hrtime_t start_time = zend_hrtime(); if (GC_G(num_roots) && !GC_G(gc_active)) { @@ -2029,7 +2029,7 @@ ZEND_API int zend_gc_collect_cycles(void) * modify any refcounts, so we have no real way to detect this situation * short of rerunning full GC tracing. What we do instead is to only run * destructors at this point and automatically re-run GC afterwards. */ - should_rerun_gc = 1; + should_rerun_gc = true; /* Mark all roots for which a dtor will be invoked as DTOR_GARBAGE. Additionally * color them purple. This serves a double purpose: First, they should be @@ -2155,7 +2155,7 @@ ZEND_API int zend_gc_collect_cycles(void) * up. We do this only once: If we encounter more destructors on the second run, we'll not * run GC another time. */ if (should_rerun_gc && !did_rerun_gc) { - did_rerun_gc = 1; + did_rerun_gc = true; goto rerun_gc; } diff --git a/Zend/zend_gdb.c b/Zend/zend_gdb.c index 102b0b3181999..5975d8c29c099 100644 --- a/Zend/zend_gdb.c +++ b/Zend/zend_gdb.c @@ -109,7 +109,7 @@ ZEND_API void zend_gdb_unregister_all(void) ZEND_API bool zend_gdb_present(void) { - bool ret = 0; + bool ret = false; #if defined(__linux__) /* netbsd while having this procfs part, does not hold the tracer pid */ int fd = open("/proc/self/status", O_RDONLY); @@ -133,7 +133,7 @@ ZEND_API bool zend_gdb_present(void) snprintf(buf, sizeof(buf), "/proc/%d/exe", (int)pid); if (readlink(buf, out, sizeof(out) - 1) > 0) { if (strstr(out, "gdb")) { - ret = 1; + ret = true; } } } diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 4b4b0910e5f64..d85c0f2da4a94 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -244,7 +244,6 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */ zend_generator *current_generator = zend_generator_get_current(generator); zend_execute_data *ex = generator->execute_data; uint32_t op_num, try_catch_offset; - int i; /* If current_generator is running in a fiber, there are 2 cases to consider: * - If generator is also marked with ZEND_GENERATOR_IN_FIBER, then the @@ -281,7 +280,7 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */ if (EXPECTED(!ex) || EXPECTED(!(ex->func->op_array.fn_flags & ZEND_ACC_HAS_FINALLY_BLOCK)) || CG(unclean_shutdown)) { - zend_generator_close(generator, 0); + zend_generator_close(generator, false); return; } @@ -289,7 +288,7 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */ try_catch_offset = -1; /* Find the innermost try/catch that we are inside of. */ - for (i = 0; i < ex->func->op_array.last_try_catch; i++) { + for (uint32_t i = 0; i < ex->func->op_array.last_try_catch; i++) { zend_try_catch_element *try_catch = &ex->func->op_array.try_catch_array[i]; if (op_num < try_catch->try_op) { break; @@ -313,7 +312,9 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */ zend_object *old_exception = NULL; const zend_op *old_opline_before_exception = NULL; if (EG(exception)) { - if (EG(current_execute_data)) { + if (EG(current_execute_data) + && EG(current_execute_data)->opline + && EG(current_execute_data)->opline->opcode == ZEND_HANDLE_EXCEPTION) { EG(current_execute_data)->opline = EG(opline_before_exception); old_opline_before_exception = EG(opline_before_exception); } @@ -330,7 +331,7 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */ zend_generator_resume(generator); if (old_exception) { - if (EG(current_execute_data)) { + if (old_opline_before_exception) { EG(current_execute_data)->opline = EG(exception_op); EG(opline_before_exception) = old_opline_before_exception; } @@ -363,7 +364,7 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */ try_catch_offset--; } - zend_generator_close(generator, 0); + zend_generator_close(generator, false); } /* }}} */ @@ -371,7 +372,7 @@ static void zend_generator_free_storage(zend_object *object) /* {{{ */ { zend_generator *generator = (zend_generator*) object; - zend_generator_close(generator, 0); + zend_generator_close(generator, false); if (generator->func && (generator->func->common.fn_flags & ZEND_ACC_CLOSURE)) { OBJ_RELEASE(ZEND_CLOSURE_OBJECT(generator->func)); @@ -868,7 +869,7 @@ ZEND_API void zend_generator_resume(zend_generator *orig_generator) /* {{{ */ * its calling frame (see above in if (check_yield_from). */ if (UNEXPECTED(EG(exception) != NULL)) { if (generator == orig_generator) { - zend_generator_close(generator, 0); + zend_generator_close(generator, false); if (!EG(current_execute_data)) { zend_throw_exception_internal(NULL); } else if (EG(current_execute_data)->func && diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 48b978b535014..ef81ae5faaf25 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -88,7 +88,7 @@ struct _zend_compiler_globals { zend_string *compiled_filename; - int zend_lineno; + uint32_t zend_lineno; zend_op_array *active_op_array; @@ -204,7 +204,7 @@ struct _zend_executor_globals { zend_execute_data *current_observed_frame; - int ticks_count; + uint32_t ticks_count; zend_long precision; @@ -319,6 +319,8 @@ struct _zend_executor_globals { zend_strtod_state strtod_state; + HashTable callable_convert_cache; + void *reserved[ZEND_MAX_RESERVED_RESOURCES]; }; @@ -341,7 +343,7 @@ struct _zend_ini_scanner_globals { zend_stack state_stack; zend_string *filename; - int lineno; + uint32_t lineno; /* Modes are: ZEND_INI_SCANNER_NORMAL, ZEND_INI_SCANNER_RAW, ZEND_INI_SCANNER_TYPED */ int scanner_mode; diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 6978beaa402e3..c00397e9fe9e3 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -281,14 +281,14 @@ ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_ ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void) { HashTable *ht = emalloc(sizeof(HashTable)); - _zend_hash_init_int(ht, HT_MIN_SIZE, ZVAL_PTR_DTOR, 0); + _zend_hash_init_int(ht, HT_MIN_SIZE, ZVAL_PTR_DTOR, false); return ht; } ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t nSize) { HashTable *ht = emalloc(sizeof(HashTable)); - _zend_hash_init_int(ht, nSize, ZVAL_PTR_DTOR, 0); + _zend_hash_init_int(ht, nSize, ZVAL_PTR_DTOR, false); return ht; } @@ -296,7 +296,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(const zval *val1, const zval *va { zval *zv; HashTable *ht = emalloc(sizeof(HashTable)); - _zend_hash_init_int(ht, HT_MIN_SIZE, ZVAL_PTR_DTOR, 0); + _zend_hash_init_int(ht, HT_MIN_SIZE, ZVAL_PTR_DTOR, false); ht->nNumUsed = ht->nNumOfElements = ht->nNextFreeElement = 2; zend_hash_real_init_packed_ex(ht); @@ -1062,6 +1062,13 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *st return _zend_hash_str_add_or_update_i(ht, str, len, h, pData, HASH_ADD_NEW); } +ZEND_API zval* ZEND_FASTCALL zend_hash_str_lookup(HashTable *ht, const char *str, size_t len) +{ + zend_ulong h = zend_hash_func(str, len); + + return _zend_hash_str_add_or_update_i(ht, str, len, h, NULL, HASH_LOOKUP); +} + ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h) { zval dummy; @@ -2375,7 +2382,7 @@ static zend_always_inline void zend_array_dup_packed_elements(const HashTable *s const zval *end = p + source->nNumUsed; do { - if (!zend_array_dup_value(source, p, q, 1, with_holes)) { + if (!zend_array_dup_value(source, p, q, true, with_holes)) { if (with_holes) { ZVAL_UNDEF(q); } @@ -2400,13 +2407,13 @@ static zend_always_inline uint32_t zend_array_dup_elements(const HashTable *sour } do { - if (!zend_array_dup_element(source, target, idx, p, q, 0, static_keys, with_holes)) { + if (!zend_array_dup_element(source, target, idx, p, q, false, static_keys, with_holes)) { uint32_t target_idx = idx; idx++; p++; if (EXPECTED(!HT_HAS_ITERATORS(target))) { while (p != end) { - if (zend_array_dup_element(source, target, target_idx, p, q, 0, static_keys, with_holes)) { + if (zend_array_dup_element(source, target, target_idx, p, q, false, static_keys, with_holes)) { if (source->nInternalPointer == idx) { target->nInternalPointer = target_idx; } @@ -2419,7 +2426,7 @@ static zend_always_inline uint32_t zend_array_dup_elements(const HashTable *sour uint32_t iter_pos = zend_hash_iterators_lower_pos(target, idx); while (p != end) { - if (zend_array_dup_element(source, target, target_idx, p, q, 0, static_keys, with_holes)) { + if (zend_array_dup_element(source, target, target_idx, p, q, false, static_keys, with_holes)) { if (source->nInternalPointer == idx) { target->nInternalPointer = target_idx; } @@ -2496,9 +2503,9 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(const HashTable *source) HT_HASH_RESET_PACKED(target); if (HT_IS_WITHOUT_HOLES(target)) { - zend_array_dup_packed_elements(source, target, 0); + zend_array_dup_packed_elements(source, target, false); } else { - zend_array_dup_packed_elements(source, target, 1); + zend_array_dup_packed_elements(source, target, true); } } else { /* Indirects are removed during duplication, remove HASH_FLAG_HAS_EMPTY_IND accordingly. */ @@ -2515,15 +2522,15 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(const HashTable *source) if (HT_HAS_STATIC_KEYS_ONLY(target)) { if (HT_IS_WITHOUT_HOLES(source)) { - idx = zend_array_dup_elements(source, target, 1, 0); + idx = zend_array_dup_elements(source, target, true, false); } else { - idx = zend_array_dup_elements(source, target, 1, 1); + idx = zend_array_dup_elements(source, target, true, true); } } else { if (HT_IS_WITHOUT_HOLES(source)) { - idx = zend_array_dup_elements(source, target, 0, 0); + idx = zend_array_dup_elements(source, target, false, false); } else { - idx = zend_array_dup_elements(source, target, 0, 1); + idx = zend_array_dup_elements(source, target, false, true); } } target->nNumUsed = idx; @@ -2851,7 +2858,6 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable * } -/* This function should be made binary safe */ ZEND_API zend_hash_key_type ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos) { uint32_t idx; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 57020bbcad0b2..70d9721cb7a17 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -218,6 +218,7 @@ static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_stri /* Find or add NULL, if doesn't exist */ ZEND_API zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key); ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h); +ZEND_API zval* ZEND_FASTCALL zend_hash_str_lookup(HashTable *ht, const char *str, size_t len); #define ZEND_HASH_INDEX_LOOKUP(_ht, _h, _ret) do { \ if (EXPECTED(HT_IS_PACKED(_ht))) { \ @@ -473,6 +474,17 @@ static zend_always_inline bool zend_hash_str_exists_ind(const HashTable *ht, con Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF); } +static zend_always_inline zval *zend_symtable_add(HashTable *ht, zend_string *key, zval *pData) +{ + zend_ulong idx; + + if (ZEND_HANDLE_NUMERIC(key, idx)) { + return zend_hash_index_add(ht, idx, pData); + } else { + return zend_hash_add(ht, key, pData); + } +} + static zend_always_inline zval *zend_symtable_add_new(HashTable *ht, zend_string *key, zval *pData) { zend_ulong idx; diff --git a/Zend/zend_hrtime.c b/Zend/zend_hrtime.c index 7fa36b1b654f4..773e0525cadd9 100644 --- a/Zend/zend_hrtime.c +++ b/Zend/zend_hrtime.c @@ -27,6 +27,8 @@ # include # include +ZEND_API clockid_t zend_hrtime_posix_clock_id = CLOCK_MONOTONIC; + #elif ZEND_HRTIME_PLATFORM_WINDOWS # define WIN32_LEAN_AND_MEAN @@ -66,5 +68,24 @@ void zend_startup_hrtime(void) mach_timebase_info(&zend_hrtime_timerlib_info); +#elif ZEND_HRTIME_PLATFORM_POSIX + + struct timespec ts; + +#ifdef CLOCK_MONOTONIC_RAW + if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC_RAW, &ts))) { + zend_hrtime_posix_clock_id = CLOCK_MONOTONIC_RAW; + return; + } +#endif + + if (EXPECTED(0 == clock_gettime(zend_hrtime_posix_clock_id, &ts))) { + return; + } + + // zend_error mechanism is not initialized at that point + fprintf(stderr, "No working CLOCK_MONOTONIC* found, this should never happen\n"); + abort(); + #endif } diff --git a/Zend/zend_hrtime.h b/Zend/zend_hrtime.h index 994dd6da169ed..f3bc4deeaf502 100644 --- a/Zend/zend_hrtime.h +++ b/Zend/zend_hrtime.h @@ -72,6 +72,10 @@ ZEND_API extern double zend_hrtime_timer_scale; # include ZEND_API extern mach_timebase_info_data_t zend_hrtime_timerlib_info; +#elif ZEND_HRTIME_PLATFORM_POSIX + +ZEND_API extern clockid_t zend_hrtime_posix_clock_id; + #endif #define ZEND_NANO_IN_SEC UINT64_C(1000000000) @@ -92,10 +96,8 @@ static zend_always_inline zend_hrtime_t zend_hrtime(void) return (zend_hrtime_t)mach_absolute_time() * zend_hrtime_timerlib_info.numer / zend_hrtime_timerlib_info.denom; #elif ZEND_HRTIME_PLATFORM_POSIX struct timespec ts = { .tv_sec = 0, .tv_nsec = 0 }; - if (EXPECTED(0 == clock_gettime(CLOCK_MONOTONIC, &ts))) { - return ((zend_hrtime_t) ts.tv_sec * (zend_hrtime_t)ZEND_NANO_IN_SEC) + ts.tv_nsec; - } - return 0; + clock_gettime(zend_hrtime_posix_clock_id, &ts); + return ((zend_hrtime_t) ts.tv_sec * (zend_hrtime_t)ZEND_NANO_IN_SEC) + ts.tv_nsec; #elif ZEND_HRTIME_PLATFORM_HPUX return (zend_hrtime_t) gethrtime(); #elif ZEND_HRTIME_PLATFORM_AIX diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 89e51cb7f0754..3c3931cdca164 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -200,7 +200,7 @@ static void do_inherit_parent_constructor(zend_class_entry *ce) /* {{{ */ } /* }}} */ -char *zend_visibility_string(uint32_t fn_flags) /* {{{ */ +const char *zend_visibility_string(uint32_t fn_flags) /* {{{ */ { if (fn_flags & ZEND_ACC_PUBLIC) { return "public"; @@ -312,7 +312,7 @@ static zend_class_entry *lookup_class(zend_class_entry *scope, zend_string *name /* Instanceof that's safe to use on unlinked classes. */ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_entry *ce2) { if (ce1 == ce2) { - return 1; + return true; } if (ce1->ce_flags & ZEND_ACC_LINKED) { @@ -331,7 +331,7 @@ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_en /* It's not sufficient to only check the parent chain itself, as need to do a full * recursive instanceof in case the parent interfaces haven't been copied yet. */ if (parent_ce && unlinked_instanceof(parent_ce, ce2)) { - return 1; + return true; } } @@ -342,7 +342,7 @@ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_en * check here, as the parent interfaces might not have been fully copied yet. */ for (i = 0; i < ce1->num_interfaces; i++) { if (unlinked_instanceof(ce1->interfaces[i], ce2)) { - return 1; + return true; } } } else { @@ -352,19 +352,19 @@ static bool unlinked_instanceof(const zend_class_entry *ce1, const zend_class_en ZEND_FETCH_CLASS_ALLOW_UNLINKED | ZEND_FETCH_CLASS_NO_AUTOLOAD); /* Avoid recursing if class implements itself. */ if (ce && ce != ce1 && unlinked_instanceof(ce, ce2)) { - return 1; + return true; } } } } - return 0; + return false; } static bool zend_type_permits_self( const zend_type type, const zend_class_entry *scope, zend_class_entry *self) { if (ZEND_TYPE_FULL_MASK(type) & MAY_BE_OBJECT) { - return 1; + return true; } /* Any types that may satisfy self must have already been loaded at this point @@ -376,11 +376,11 @@ static bool zend_type_permits_self( zend_string *name = resolve_class_name(scope, ZEND_TYPE_NAME(*single_type)); const zend_class_entry *ce = lookup_class(self, name); if (ce && unlinked_instanceof(self, ce)) { - return 1; + return true; } } } ZEND_TYPE_FOREACH_END(); - return 0; + return false; } static void track_class_dependency(zend_class_entry *ce, zend_string *class_name) @@ -475,7 +475,7 @@ static inheritance_status zend_is_class_subtype_of_type( zend_class_entry *fe_scope, zend_string *fe_class_name, zend_class_entry *proto_scope, const zend_type proto_type) { zend_class_entry *fe_ce = NULL; - bool have_unresolved = 0; + bool have_unresolved = false; /* If the parent has 'object' as a return type, any class satisfies the co-variant check */ if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_OBJECT) { @@ -484,7 +484,7 @@ static inheritance_status zend_is_class_subtype_of_type( * are not classes (such as typedefs). */ if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name); if (!fe_ce) { - have_unresolved = 1; + have_unresolved = true; } else { track_class_dependency(fe_ce, fe_class_name); return INHERITANCE_SUCCESS; @@ -495,7 +495,7 @@ static inheritance_status zend_is_class_subtype_of_type( if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_CALLABLE) { if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name); if (!fe_ce) { - have_unresolved = 1; + have_unresolved = true; } else if (fe_ce == zend_ce_closure) { track_class_dependency(fe_ce, fe_class_name); return INHERITANCE_SUCCESS; @@ -506,7 +506,7 @@ static inheritance_status zend_is_class_subtype_of_type( if ((ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_STATIC) && (fe_scope->ce_flags & ZEND_ACC_FINAL)) { if (!fe_ce) fe_ce = lookup_class(fe_scope, fe_class_name); if (!fe_ce) { - have_unresolved = 1; + have_unresolved = true; } else if (fe_ce == fe_scope) { track_class_dependency(fe_ce, fe_class_name); return INHERITANCE_SUCCESS; @@ -530,7 +530,7 @@ static inheritance_status zend_is_class_subtype_of_type( } continue; case INHERITANCE_UNRESOLVED: - have_unresolved = 1; + have_unresolved = true; continue; case INHERITANCE_SUCCESS: if (!is_intersection) { @@ -562,7 +562,7 @@ static inheritance_status zend_is_class_subtype_of_type( } if (!fe_ce || !proto_ce) { - have_unresolved = 1; + have_unresolved = true; continue; } if (unlinked_instanceof(fe_ce, proto_ce)) { @@ -916,7 +916,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration( smart_str str = {0}; if (fptr->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE) { - smart_str_appends(&str, "& "); + smart_str_appendc(&str, '&'); } if (fptr->common.scope) { @@ -942,7 +942,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration( num_args++; } for (uint32_t i = 0; i < num_args;) { - zend_append_type_hint(&str, scope, arg_info, 0); + zend_append_type_hint(&str, scope, arg_info, false); if (ZEND_ARG_SEND_MODE(arg_info)) { smart_str_appendc(&str, '&'); @@ -953,18 +953,14 @@ static ZEND_COLD zend_string *zend_get_function_declaration( } smart_str_appendc(&str, '$'); - if (fptr->type == ZEND_INTERNAL_FUNCTION) { - smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->name); - } else { - smart_str_appendl(&str, ZSTR_VAL(arg_info->name), ZSTR_LEN(arg_info->name)); - } + smart_str_append(&str, arg_info->name); if (i >= required && !ZEND_ARG_IS_VARIADIC(arg_info)) { smart_str_appends(&str, " = "); if (fptr->type == ZEND_INTERNAL_FUNCTION) { - if (((zend_internal_arg_info*)arg_info)->default_value) { - smart_str_appends(&str, ((zend_internal_arg_info*)arg_info)->default_value); + if (arg_info->default_value) { + smart_str_append(&str, arg_info->default_value); } else { smart_str_appends(&str, ""); } @@ -1011,7 +1007,9 @@ static ZEND_COLD zend_string *zend_get_function_declaration( zend_ast *ast = Z_ASTVAL_P(zv); if (ast->kind == ZEND_AST_CONSTANT) { smart_str_append(&str, zend_ast_get_constant_name(ast)); - } else if (ast->kind == ZEND_AST_CLASS_CONST) { + } else if (ast->kind == ZEND_AST_CLASS_CONST + && ast->child[1]->kind == ZEND_AST_ZVAL + && Z_TYPE_P(zend_ast_get_zval(ast->child[1])) == IS_STRING) { smart_str_append(&str, zend_ast_get_str(ast->child[0])); smart_str_appends(&str, "::"); smart_str_append(&str, zend_ast_get_str(ast->child[1])); @@ -1039,7 +1037,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration( if (fptr->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { smart_str_appends(&str, ": "); - zend_append_type_hint(&str, scope, fptr->common.arg_info - 1, 1); + zend_append_type_hint(&str, scope, fptr->common.arg_info - 1, true); } smart_str_0(&str); @@ -1784,7 +1782,7 @@ ZEND_API void zend_verify_hooked_property(const zend_class_entry *ce, zend_prope && (prop_info->flags & ZEND_ACC_PPP_SET_MASK) && (!prop_info->hooks[ZEND_PROPERTY_HOOK_GET] || !prop_info->hooks[ZEND_PROPERTY_HOOK_SET])) { const char *prefix = !prop_info->hooks[ZEND_PROPERTY_HOOK_GET] - ? "Write-only" : "Read-only"; + ? "set-only" : "get-only"; zend_error_noreturn(E_COMPILE_ERROR, "%s virtual property %s::$%s must not specify asymmetric visibility", prefix, ZSTR_VAL(ce->name), ZSTR_VAL(prop_name)); @@ -2036,7 +2034,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par } zend_function *func; ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&parent_ce->function_table, key, func) { - do_inherit_method(key, func, ce, 0, flags); + do_inherit_method(key, func, ce, false, flags); } ZEND_HASH_FOREACH_END(); } @@ -2189,7 +2187,7 @@ static void do_interface_implementation(zend_class_entry *ce, zend_class_entry * } ZEND_HASH_FOREACH_END(); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(&iface->function_table, key, func) { - do_inherit_method(key, func, ce, 1, flags); + do_inherit_method(key, func, ce, true, flags); } ZEND_HASH_FOREACH_END(); zend_hash_extend(&ce->properties_info, diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 689e76794df34..8d26cd65579df 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -332,7 +332,7 @@ ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */ ZEND_API zend_result zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */ { - return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0); + return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, false); } /* }}} */ @@ -342,7 +342,7 @@ ZEND_API zend_result zend_alter_ini_entry_chars(zend_string *name, const char *v zend_string *new_value; new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST)); - ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0); + ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, false); zend_string_release(new_value); return ret; } @@ -515,7 +515,7 @@ ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length); if (ini_entry) { if (exists) { - *exists = 1; + *exists = true; } if (orig && ini_entry->modified) { @@ -525,7 +525,7 @@ ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool } } else { if (exists) { - *exists = 0; + *exists = false; } return NULL; } @@ -534,7 +534,7 @@ ZEND_API zend_string *zend_ini_str_ex(const char *name, size_t name_length, bool ZEND_API zend_string *zend_ini_str(const char *name, size_t name_length, bool orig) /* {{{ */ { - bool exists = 1; + bool exists = true; zend_string *return_value; return_value = zend_ini_str_ex(name, name_length, orig, &exists); diff --git a/Zend/zend_ini_parser.y b/Zend/zend_ini_parser.y index 5f788f152fb6a..748ccd2235a6d 100644 --- a/Zend/zend_ini_parser.y +++ b/Zend/zend_ini_parser.y @@ -205,7 +205,7 @@ static ZEND_COLD void ini_error(const char *msg) error_buf_len = 128 + (int)strlen(msg) + (int)strlen(currently_parsed_filename); /* should be more than enough */ error_buf = (char *) emalloc(error_buf_len); - sprintf(error_buf, "%s in %s on line %d\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno()); + sprintf(error_buf, "%s in %s on line %" PRIu32 "\n", msg, currently_parsed_filename, zend_ini_scanner_get_lineno()); } else { error_buf = estrdup("Invalid configuration directive\n"); } diff --git a/Zend/zend_ini_scanner.h b/Zend/zend_ini_scanner.h index 62546413c7cb2..9a6c84fce4292 100644 --- a/Zend/zend_ini_scanner.h +++ b/Zend/zend_ini_scanner.h @@ -30,7 +30,7 @@ typedef struct _zend_file_handle zend_file_handle; #define ZEND_INI_SCANNER_TYPED 2 /* Typed mode. */ BEGIN_EXTERN_C() -ZEND_COLD int zend_ini_scanner_get_lineno(void); +ZEND_COLD uint32_t zend_ini_scanner_get_lineno(void); ZEND_COLD const char *zend_ini_scanner_get_filename(void); zend_result zend_ini_open_file_for_scanning(zend_file_handle *fh, int scanner_mode); zend_result zend_ini_prepare_string_for_scanning(const char *str, int scanner_mode); diff --git a/Zend/zend_ini_scanner.l b/Zend/zend_ini_scanner.l index b87f4e33cc8f8..5f9b77e6a3d8a 100644 --- a/Zend/zend_ini_scanner.l +++ b/Zend/zend_ini_scanner.l @@ -145,10 +145,10 @@ ZEND_API zend_ini_scanner_globals ini_scanner_globals; if (SCNG(scanner_mode) == ZEND_INI_SCANNER_TYPED && \ (YYSTATE == STATE(ST_VALUE) || YYSTATE == STATE(ST_RAW))) {\ zend_ini_copy_typed_value(ini_lval, type, str, len); \ - Z_EXTRA_P(ini_lval) = 0; \ } else { \ zend_ini_copy_value(ini_lval, str, len); \ } \ + Z_EXTRA_P(ini_lval) = 0; \ return type; \ } @@ -230,7 +230,7 @@ void shutdown_ini_scanner(void) /* }}} */ /* {{{ zend_ini_scanner_get_lineno() */ -ZEND_COLD int zend_ini_scanner_get_lineno(void) +ZEND_COLD uint32_t zend_ini_scanner_get_lineno(void) { return SCNG(lineno); } diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c index ce9cc00fdfb95..404dd9db893ea 100644 --- a/Zend/zend_interfaces.c +++ b/Zend/zend_interfaces.c @@ -496,7 +496,7 @@ static zend_object *zend_internal_iterator_create(zend_class_entry *ce) { zend_internal_iterator *intern = emalloc(sizeof(zend_internal_iterator)); zend_object_std_init(&intern->std, ce); intern->iter = NULL; - intern->rewind_called = 0; + intern->rewind_called = false; return &intern->std; } @@ -537,7 +537,7 @@ static zend_internal_iterator *zend_internal_iterator_fetch(zval *This) { static zend_result zend_internal_iterator_ensure_rewound(zend_internal_iterator *intern) { if (!intern->rewind_called) { zend_object_iterator *iter = intern->iter; - intern->rewind_called = 1; + intern->rewind_called = true; if (iter->funcs->rewind) { iter->funcs->rewind(iter); if (UNEXPECTED(EG(exception))) { @@ -630,7 +630,7 @@ ZEND_METHOD(InternalIterator, rewind) { RETURN_THROWS(); } - intern->rewind_called = 1; + intern->rewind_called = true; if (!intern->iter->funcs->rewind) { /* Allow calling rewind() if no iteration has happened yet, * even if the iterator does not support rewinding. */ diff --git a/Zend/zend_language_scanner.h b/Zend/zend_language_scanner.h index 612c845479272..c494564ba2349 100644 --- a/Zend/zend_language_scanner.h +++ b/Zend/zend_language_scanner.h @@ -20,6 +20,7 @@ #ifndef ZEND_SCANNER_H #define ZEND_SCANNER_H +/* The zend_php_scanner_event enum is declared in zend_globals and we don't want everything to include zend_language_scanner.h */ #include "zend_globals.h" typedef struct _zend_lex_state { @@ -71,7 +72,7 @@ typedef struct _zend_heredoc_label { /* Track locations of unclosed {, [, (, etc. for better syntax error reporting */ typedef struct _zend_nest_location { char text; - int lineno; + uint32_t lineno; } zend_nest_location; BEGIN_EXTERN_C() diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 3ecb2f8d0ee45..1e26ddbd99199 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -30,6 +30,7 @@ #include "zend_language_scanner_defs.h" #include +#include #include "zend.h" #ifdef ZEND_WIN32 # include @@ -600,7 +601,7 @@ static zend_op_array *zend_compile(int type) CG(ast_arena) = zend_arena_create(1024 * 32); if (!zendparse()) { - int last_lineno = CG(zend_lineno); + uint32_t last_lineno = CG(zend_lineno); zend_file_context original_file_context; zend_oparray_context original_oparray_context; zend_op_array *original_active_op_array = CG(active_op_array); @@ -1140,7 +1141,7 @@ skip_escape_conversion: unsigned char *str; // TODO: avoid realocation ??? s = Z_STRVAL_P(zendlval); - SCNG(output_filter)(&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval)); + SCNG(output_filter)(&str, &sz, (unsigned char *)s, Z_STRLEN_P(zendlval)); zval_ptr_dtor(zendlval); ZVAL_STRINGL(zendlval, (char *) str, sz); efree(str); @@ -1172,7 +1173,7 @@ static bool strip_multiline_string_indentation( const char *str = Z_STRVAL_P(zendlval), *end = str + Z_STRLEN_P(zendlval); char *copy = Z_STRVAL_P(zendlval); - int newline_count = 0; + uint32_t newline_count = 0; size_t newline_len; const char *nl; @@ -1253,7 +1254,7 @@ static void copy_heredoc_label_stack(void *void_heredoc_label) } /* Check that { }, [ ], ( ) are nested correctly */ -static void report_bad_nesting(char opening, int opening_lineno, char closing) +static void report_bad_nesting(char opening, uint32_t opening_lineno, char closing) { char buf[256]; size_t used = 0; @@ -1361,7 +1362,7 @@ int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem) { int token; int offset; -int start_line = CG(zend_lineno); +uint32_t start_line = CG(zend_lineno); ZVAL_UNDEF(zendlval); restart: @@ -2499,7 +2500,7 @@ inline_char_handler: if (YYCURSOR < YYLIMIT) { YYCURSOR++; } else { - zend_throw_exception_ex(zend_ce_parse_error, 0, "Unterminated comment starting line %d", CG(zend_lineno)); + zend_throw_exception_ex(zend_ce_parse_error, 0, "Unterminated comment starting line %" PRIu32, CG(zend_lineno)); if (PARSER_MODE()) { RETURN_TOKEN(T_ERROR); } @@ -2616,7 +2617,7 @@ skip_escape_conversion: zend_string *new_str; s = Z_STRVAL_P(zendlval); // TODO: avoid reallocation ??? - SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, (size_t)Z_STRLEN_P(zendlval)); + SCNG(output_filter)((unsigned char **)&str, &sz, (unsigned char *)s, Z_STRLEN_P(zendlval)); new_str = zend_string_init(str, sz, 0); if (str != s) { efree(str); diff --git a/Zend/zend_long.h b/Zend/zend_long.h index 3796f1c5ababb..fef237701f3bd 100644 --- a/Zend/zend_long.h +++ b/Zend/zend_long.h @@ -51,9 +51,6 @@ typedef int32_t zend_off_t; #endif -/* Conversion macros. */ -#define ZEND_LTOA_BUF_LEN 65 - #ifdef ZEND_ENABLE_ZVAL_LONG64 # define ZEND_LONG_FMT "%" PRId64 # define ZEND_ULONG_FMT "%" PRIu64 @@ -61,7 +58,6 @@ typedef int32_t zend_off_t; # define ZEND_LONG_FMT_SPEC PRId64 # define ZEND_ULONG_FMT_SPEC PRIu64 # ifdef ZEND_WIN32 -# define ZEND_LTOA(i, s, len) _i64toa_s((i), (s), (len), 10) # define ZEND_ATOL(s) _atoi64((s)) # define ZEND_STRTOL(s0, s1, base) _strtoi64((s0), (s1), (base)) # define ZEND_STRTOUL(s0, s1, base) _strtoui64((s0), (s1), (base)) @@ -69,11 +65,6 @@ typedef int32_t zend_off_t; # define ZEND_STRTOUL_PTR _strtoui64 # define ZEND_ABS _abs64 # else -# define ZEND_LTOA(i, s, len) \ - do { \ - int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \ - (s)[st] = '\0'; \ - } while (0) # define ZEND_ATOL(s) atoll((s)) # define ZEND_STRTOL(s0, s1, base) strtoll((s0), (s1), (base)) # define ZEND_STRTOUL(s0, s1, base) strtoull((s0), (s1), (base)) @@ -90,14 +81,8 @@ typedef int32_t zend_off_t; # define ZEND_LONG_FMT_SPEC PRId32 # define ZEND_ULONG_FMT_SPEC PRIu32 # ifdef ZEND_WIN32 -# define ZEND_LTOA(i, s, len) _ltoa_s((i), (s), (len), 10) # define ZEND_ATOL(s) atol((s)) # else -# define ZEND_LTOA(i, s, len) \ - do { \ - int st = snprintf((s), (len), ZEND_LONG_FMT, (i)); \ - (s)[st] = '\0'; \ - } while (0) # define ZEND_ATOL(s) atol((s)) # endif # define ZEND_STRTOL_PTR strtol diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index 2d8cf88e1d12e..a8076c0fb9058 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -31,7 +31,7 @@ #define ZEND_MODULE_INFO_FUNC_ARGS zend_module_entry *zend_module #define ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU zend_module -#define ZEND_MODULE_API_NO 20250925 +#define ZEND_MODULE_API_NO 20250926 #ifdef ZTS #define USING_ZTS 1 #else diff --git a/Zend/zend_multibyte.c b/Zend/zend_multibyte.c index 9459920b6332b..f61ed79fd1f7a 100644 --- a/Zend/zend_multibyte.c +++ b/Zend/zend_multibyte.c @@ -35,7 +35,7 @@ static const char *dummy_encoding_name_getter(const zend_encoding *encoding) static bool dummy_encoding_lexer_compatibility_checker(const zend_encoding *encoding) { - return 0; + return false; } static const zend_encoding *dummy_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size) @@ -195,7 +195,7 @@ ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *ne return SUCCESS; } - if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length, &list, &size, 1)) { + if (FAILURE == zend_multibyte_parse_encoding_list(new_value, new_value_length, &list, &size, true)) { return FAILURE; } diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 672579132f5f0..88b7b1112d7b1 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -46,6 +46,9 @@ #define IN_ISSET ZEND_GUARD_PROPERTY_ISSET #define IN_HOOK ZEND_GUARD_PROPERTY_HOOK +static zend_arg_info zend_call_trampoline_arginfo[1] = {{0}}; +static zend_arg_info zend_property_hook_arginfo[1] = {{0}}; + static zend_always_inline bool zend_objects_check_stack_limit(void) { #ifdef ZEND_CHECK_STACK_LIMIT @@ -106,8 +109,7 @@ ZEND_API HashTable *rebuild_object_properties_internal(zend_object *zobj) /* {{{ /* Implements the fast path for array cast */ ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /* {{{ */ { - zend_property_info *prop_info; - zend_class_entry *ce = zobj->ce; + const zend_class_entry *ce = zobj->ce; HashTable *ht; zval* prop; int i; @@ -118,7 +120,7 @@ ZEND_API HashTable *zend_std_build_object_properties_array(zend_object *zobj) /* if (ce->default_properties_count) { zend_hash_real_init_mixed(ht); for (i = 0; i < ce->default_properties_count; i++) { - prop_info = ce->properties_info_table[i]; + const zend_property_info *prop_info = ce->properties_info_table[i]; if (!prop_info) { continue; @@ -192,7 +194,7 @@ ZEND_API HashTable *zend_std_get_gc(zend_object *zobj, zval **table, int *n) /* ZEND_API HashTable *zend_std_get_debug_info(zend_object *object, int *is_temp) /* {{{ */ { - zend_class_entry *ce = object->ce; + const zend_class_entry *ce = object->ce; zval retval; HashTable *ht; @@ -334,7 +336,7 @@ static ZEND_COLD zend_never_inline bool zend_deprecated_dynamic_property( zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated", ZSTR_VAL(obj->ce->name), ZSTR_VAL(member)); if (UNEXPECTED(GC_DELREF(obj) == 0)) { - zend_class_entry *ce = obj->ce; + const zend_class_entry *ce = obj->ce; zend_objects_store_del(obj); if (!EG(exception)) { /* We cannot continue execution and have to throw an exception */ @@ -347,7 +349,7 @@ static ZEND_COLD zend_never_inline bool zend_deprecated_dynamic_property( } static ZEND_COLD zend_never_inline void zend_readonly_property_unset_error( - zend_class_entry *ce, zend_string *member) { + const zend_class_entry *ce, const zend_string *member) { zend_throw_error(NULL, "Cannot unset readonly property %s::$%s", ZSTR_VAL(ce->name), ZSTR_VAL(member)); } @@ -680,7 +682,7 @@ static ZEND_FUNCTION(zend_parent_hook_set_trampoline); static bool zend_is_in_hook(const zend_property_info *prop_info) { - zend_execute_data *execute_data = EG(current_execute_data); + const zend_execute_data *execute_data = EG(current_execute_data); if (!execute_data || !EX(func) || !EX(func)->common.prop_info) { return false; } @@ -711,7 +713,7 @@ static bool zend_should_call_hook(const zend_property_info *prop_info, const zen return true; } -static ZEND_COLD void zend_throw_no_prop_backing_value_access(zend_string *class_name, zend_string *prop_name, bool is_read) +static ZEND_COLD void zend_throw_no_prop_backing_value_access(const zend_string *class_name, const zend_string *prop_name, bool is_read) { zend_throw_error(NULL, "Must not %s virtual property %s::$%s", is_read ? "read from" : "write to", @@ -719,7 +721,7 @@ static ZEND_COLD void zend_throw_no_prop_backing_value_access(zend_string *class } static bool zend_call_get_hook( - const zend_property_info *prop_info, zend_string *prop_name, + const zend_property_info *prop_info, const zend_string *prop_name, zend_function *get, zend_object *zobj, zval *rv) { if (!zend_should_call_hook(prop_info, zobj)) { @@ -814,7 +816,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int zend_function *get = prop_info->hooks[ZEND_PROPERTY_HOOK_GET]; if (!get) { if (prop_info->flags & ZEND_ACC_VIRTUAL) { - zend_throw_error(NULL, "Property %s::$%s is write-only", + zend_throw_error(NULL, "Cannot read from set-only virtual property %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name)); return &EG(uninitialized_zval); } @@ -842,7 +844,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int goto exit; } - zend_class_entry *ce = zobj->ce; + const zend_class_entry *ce = zobj->ce; if (!zend_call_get_hook(prop_info, name, get, zobj, rv)) { if (EG(exception)) { @@ -850,7 +852,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int } /* Reads from backing store can only occur in hooks, and hence will always remain simple. */ - zend_execute_data *execute_data = EG(current_execute_data); + const zend_execute_data *execute_data = EG(current_execute_data); if (cache_slot && EX(opline) && EX(opline)->opcode == ZEND_FETCH_OBJ_R && EX(opline)->op1_type == IS_UNUSED) { ZEND_SET_PROPERTY_HOOK_SIMPLE_READ(cache_slot); } @@ -996,7 +998,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int /* }}} */ static zend_always_inline bool property_uses_strict_types(void) { - zend_execute_data *execute_data = EG(current_execute_data); + const zend_execute_data *execute_data = EG(current_execute_data); return execute_data && execute_data->func && ZEND_CALL_USES_STRICT_TYPES(EG(current_execute_data)); @@ -1155,7 +1157,7 @@ found:; if (!set) { if (prop_info->flags & ZEND_ACC_VIRTUAL) { - zend_throw_error(NULL, "Property %s::$%s is read-only", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name)); + zend_throw_error(NULL, "Cannot write to get-only virtual property %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name)); variable_ptr = &EG(error_zval); goto exit; } @@ -1274,7 +1276,7 @@ found:; } /* }}} */ -static ZEND_COLD zend_never_inline void zend_bad_array_access(zend_class_entry *ce) /* {{{ */ +static ZEND_COLD zend_never_inline void zend_bad_array_access(const zend_class_entry *ce) /* {{{ */ { zend_throw_error(NULL, "Cannot use object of type %s as array", ZSTR_VAL(ce->name)); } @@ -1282,7 +1284,7 @@ static ZEND_COLD zend_never_inline void zend_bad_array_access(zend_class_entry * ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int type, zval *rv) /* {{{ */ { - zend_class_entry *ce = object->ce; + const zend_class_entry *ce = object->ce; zval tmp_offset; /* arrayaccess_funcs_ptr is set if (and only if) the class implements zend_ce_arrayaccess */ @@ -1333,7 +1335,7 @@ ZEND_API zval *zend_std_read_dimension(zend_object *object, zval *offset, int ty ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval *value) /* {{{ */ { - zend_class_entry *ce = object->ce; + const zend_class_entry *ce = object->ce; zval tmp_offset; zend_class_arrayaccess_funcs *funcs = ce->arrayaccess_funcs_ptr; @@ -1356,7 +1358,7 @@ ZEND_API void zend_std_write_dimension(zend_object *object, zval *offset, zval * // todo: make zend_std_has_dimension return bool as well ZEND_API int zend_std_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */ { - zend_class_entry *ce = object->ce; + const zend_class_entry *ce = object->ce; zval retval, tmp_offset; bool result; @@ -1610,7 +1612,7 @@ ZEND_API void zend_std_unset_property(zend_object *zobj, zend_string *name, void ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset) /* {{{ */ { - zend_class_entry *ce = object->ce; + const zend_class_entry *ce = object->ce; zval tmp_offset; zend_class_arrayaccess_funcs *funcs = ce->arrayaccess_funcs_ptr; @@ -1626,7 +1628,7 @@ ZEND_API void zend_std_unset_dimension(zend_object *object, zval *offset) /* {{{ } /* }}} */ -static zend_never_inline zend_function *zend_get_parent_private_method(zend_class_entry *scope, zend_class_entry *ce, zend_string *function_name) /* {{{ */ +static zend_never_inline zend_function *zend_get_parent_private_method(const zend_class_entry *scope, const zend_class_entry *ce, zend_string *function_name) /* {{{ */ { zval *func; zend_function *fbc; @@ -1674,19 +1676,17 @@ ZEND_API bool zend_check_protected(const zend_class_entry *ce, const zend_class_ } /* }}} */ -ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce, zend_string *method_name, bool is_static) /* {{{ */ +ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func( + const zend_function *fbc, zend_string *method_name) /* {{{ */ { size_t mname_len; zend_op_array *func; - zend_function *fbc = is_static ? ce->__callstatic : ce->__call; /* We use non-NULL value to avoid useless run_time_cache allocation. * The low bit must be zero, to not be interpreted as a MAP_PTR offset. */ static const void *dummy = (void*)(intptr_t)2; static const zend_arg_info arg_info[1] = {{0}}; - ZEND_ASSERT(fbc); - if (EXPECTED(EG(trampoline).common.function_name == NULL)) { func = &EG(trampoline).op_array; } else { @@ -1700,12 +1700,10 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE | ZEND_ACC_PUBLIC | ZEND_ACC_VARIADIC - | (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD)); + | (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED|ZEND_ACC_NODISCARD|ZEND_ACC_STATIC)); + func->fn_flags2 = 0; /* Attributes outlive the trampoline because they are created by the compiler. */ func->attributes = fbc->common.attributes; - if (is_static) { - func->fn_flags |= ZEND_ACC_STATIC; - } func->opcodes = &EG(call_trampoline_op); ZEND_MAP_PTR_INIT(func->run_time_cache, (void**)dummy); func->scope = fbc->common.scope; @@ -1751,7 +1749,7 @@ static ZEND_FUNCTION(zend_parent_hook_get_trampoline) } zval rv; - zval *retval = obj->handlers->read_property(obj, prop_name, BP_VAR_R, NULL, &rv); + const zval *retval = obj->handlers->read_property(obj, prop_name, BP_VAR_R, NULL, &rv); if (retval == &rv) { RETVAL_COPY_VALUE(retval); } else { @@ -1787,9 +1785,6 @@ ZEND_API zend_function *zend_get_property_hook_trampoline( const zend_property_info *prop_info, zend_property_hook_kind kind, zend_string *prop_name) { - static const zend_internal_arg_info arg_info[2] = { - { .name = "value" } - }; zend_function *func; if (EXPECTED(EG(trampoline).common.function_name == NULL)) { func = &EG(trampoline); @@ -1804,6 +1799,7 @@ ZEND_API zend_function *zend_get_property_hook_trampoline( func->common.arg_flags[1] = 0; func->common.arg_flags[2] = 0; func->common.fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE; + func->common.fn_flags2 = 0; func->common.function_name = zend_string_concat3( "$", 1, ZSTR_VAL(prop_name), ZSTR_LEN(prop_name), kind == ZEND_PROPERTY_HOOK_GET ? "::get" : "::set", 5); @@ -1814,7 +1810,7 @@ ZEND_API zend_function *zend_get_property_hook_trampoline( func->common.scope = prop_info->ce; func->common.prototype = NULL; func->common.prop_info = prop_info; - func->common.arg_info = (zend_arg_info *) arg_info; + func->common.arg_info = zend_property_hook_arginfo; func->internal_function.handler = kind == ZEND_PROPERTY_HOOK_GET ? ZEND_FN(zend_parent_hook_get_trampoline) : ZEND_FN(zend_parent_hook_set_trampoline); @@ -1826,12 +1822,6 @@ ZEND_API zend_function *zend_get_property_hook_trampoline( return func; } -static zend_always_inline zend_function *zend_get_user_call_function(zend_class_entry *ce, zend_string *method_name) /* {{{ */ -{ - return zend_get_call_trampoline_func(ce, method_name, 0); -} -/* }}} */ - ZEND_API ZEND_COLD zend_never_inline void zend_bad_method_call(const zend_function *fbc, const zend_string *method_name, const zend_class_entry *scope) /* {{{ */ { zend_throw_error(NULL, "Call to %s method %s::%s() from %s%s", @@ -1855,7 +1845,6 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string * zval *func; zend_function *fbc; zend_string *lc_method_name; - zend_class_entry *scope; ALLOCA_FLAG(use_heap); if (EXPECTED(key != NULL)) { @@ -1873,7 +1862,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string * ZSTR_ALLOCA_FREE(lc_method_name, use_heap); } if (zobj->ce->__call) { - return zend_get_user_call_function(zobj->ce, method_name); + return zend_get_call_trampoline_func(zobj->ce->__call, method_name); } else { return NULL; } @@ -1883,7 +1872,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string * /* Check access level */ if (fbc->op_array.fn_flags & (ZEND_ACC_CHANGED|ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) { - scope = zend_get_executed_scope(); + const zend_class_entry *scope = zend_get_executed_scope(); if (fbc->common.scope != scope) { if (fbc->op_array.fn_flags & ZEND_ACC_CHANGED) { @@ -1899,7 +1888,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string * if (UNEXPECTED(fbc->op_array.fn_flags & ZEND_ACC_PRIVATE) || UNEXPECTED(!zend_check_protected(zend_get_function_root_class(fbc), scope))) { if (zobj->ce->__call) { - fbc = zend_get_user_call_function(zobj->ce, method_name); + fbc = zend_get_call_trampoline_func(zobj->ce->__call, method_name); } else { zend_bad_method_call(fbc, method_name, scope); fbc = NULL; @@ -1920,14 +1909,8 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string * } /* }}} */ -static zend_always_inline zend_function *zend_get_user_callstatic_function(zend_class_entry *ce, zend_string *method_name) /* {{{ */ -{ - return zend_get_call_trampoline_func(ce, method_name, 1); -} -/* }}} */ - static zend_always_inline zend_function *get_static_method_fallback( - zend_class_entry *ce, zend_string *function_name) + const zend_class_entry *ce, zend_string *function_name) { zend_object *object; if (ce->__call && @@ -1937,15 +1920,15 @@ static zend_always_inline zend_function *get_static_method_fallback( * see: tests/classes/__call_004.phpt */ ZEND_ASSERT(object->ce->__call); - return zend_get_user_call_function(object->ce, function_name); + return zend_get_call_trampoline_func(object->ce->__call, function_name); } else if (ce->__callstatic) { - return zend_get_user_callstatic_function(ce, function_name); + return zend_get_call_trampoline_func(ce->__callstatic, function_name); } else { return NULL; } } -ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name, const zval *key) /* {{{ */ +ZEND_API zend_function *zend_std_get_static_method(const zend_class_entry *ce, zend_string *function_name, const zval *key) /* {{{ */ { zend_string *lc_function_name; if (EXPECTED(key != NULL)) { @@ -1959,7 +1942,7 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st if (EXPECTED(func)) { fbc = Z_FUNC_P(func); if (!(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) { - zend_class_entry *scope = zend_get_executed_scope(); + const zend_class_entry *scope = zend_get_executed_scope(); ZEND_ASSERT(!(fbc->common.fn_flags & ZEND_ACC_PUBLIC)); if (!zend_check_method_accessible(fbc, scope)) { zend_function *fallback_fbc = get_static_method_fallback(ce, function_name); @@ -2006,7 +1989,6 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_st ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */ { - int i; zval *p; if (class_type->default_static_members_count && !CE_STATIC_MEMBERS(class_type)) { @@ -2015,7 +1997,7 @@ ZEND_API void zend_class_init_statics(zend_class_entry *class_type) /* {{{ */ } ZEND_MAP_PTR_SET(class_type->static_members_table, emalloc(sizeof(zval) * class_type->default_static_members_count)); - for (i = 0; i < class_type->default_static_members_count; i++) { + for (uint32_t i = 0; i < class_type->default_static_members_count; i++) { p = &class_type->default_static_members_table[i]; if (Z_TYPE_P(p) == IS_INDIRECT) { zval *q = &CE_STATIC_MEMBERS(class_type->parent)[i]; @@ -2350,7 +2332,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has if (!get) { if (prop_info->flags & ZEND_ACC_VIRTUAL) { - zend_throw_error(NULL, "Property %s::$%s is write-only", + zend_throw_error(NULL, "Cannot read from set-only virtual property %s::$%s", ZSTR_VAL(zobj->ce->name), ZSTR_VAL(name)); return 0; } else { @@ -2425,7 +2407,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has if (!value || (Z_PROP_FLAG_P(value) & IS_PROP_LAZY)) { zobj = zend_lazy_object_init(zobj); if (!zobj) { - result = 0; + result = false; goto exit; } @@ -2443,7 +2425,7 @@ ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has } } - result = 0; + result = false; goto exit; } /* }}} */ @@ -2458,7 +2440,7 @@ ZEND_API zend_result zend_std_cast_object_tostring(zend_object *readobj, zval *w { switch (type) { case IS_STRING: { - zend_class_entry *ce = readobj->ce; + const zend_class_entry *ce = readobj->ce; if (ce->__tostring) { zval retval; GC_ADDREF(readobj); @@ -2491,7 +2473,7 @@ ZEND_API zend_result zend_std_cast_object_tostring(zend_object *readobj, zval *w ZEND_API zend_result zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, bool check_only) /* {{{ */ { zend_class_entry *ce = obj->ce; - zval *func = zend_hash_find_known_hash(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE)); + const zval *func = zend_hash_find_known_hash(&ce->function_table, ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE)); if (func == NULL) { return FAILURE; @@ -2592,3 +2574,8 @@ ZEND_API const zend_object_handlers std_object_handlers = { zend_std_compare_objects, /* compare */ NULL, /* get_properties_for */ }; + +void zend_object_handlers_startup(void) { + zend_call_trampoline_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_ARGS); + zend_property_hook_arginfo[0].name = ZSTR_KNOWN(ZEND_STR_VALUE); +} diff --git a/Zend/zend_object_handlers.h b/Zend/zend_object_handlers.h index 84d0b57d7aa28..3e922343eb15a 100644 --- a/Zend/zend_object_handlers.h +++ b/Zend/zend_object_handlers.h @@ -248,7 +248,7 @@ extern const ZEND_API zend_object_handlers std_object_handlers; #define ZEND_PROPERTY_EXISTS 0x2 /* Property exists */ ZEND_API void zend_class_init_statics(zend_class_entry *ce); -ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zend_string *function_name_strval, const zval *key); +ZEND_API zend_function *zend_std_get_static_method(const zend_class_entry *ce, zend_string *function_name_strval, const zval *key); ZEND_API zval *zend_std_get_static_property_with_info(zend_class_entry *ce, zend_string *property_name, int type, struct _zend_property_info **prop_info); ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *property_name, int type); ZEND_API ZEND_COLD bool zend_std_unset_static_property(const zend_class_entry *ce, const zend_string *property_name); @@ -312,9 +312,7 @@ ZEND_API bool zend_check_protected(const zend_class_entry *ce, const zend_class_ ZEND_API zend_result zend_check_property_access(const zend_object *zobj, zend_string *prop_info_name, bool is_dynamic); -ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce, zend_string *method_name, bool is_static); - -ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member); +ZEND_API ZEND_ATTRIBUTE_NONNULL zend_function *zend_get_call_trampoline_func(const zend_function *fbc, zend_string *method_name); ZEND_API uint32_t *zend_get_property_guard(zend_object *zobj, zend_string *member); @@ -336,6 +334,8 @@ ZEND_API zend_function *zend_get_property_hook_trampoline( ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_property_info *prop_info); +void zend_object_handlers_startup(void); + #define zend_release_properties(ht) do { \ if (ht) { \ zend_array_release(ht); \ diff --git a/Zend/zend_observer.c b/Zend/zend_observer.c index 15722eb6b2eb3..bee20bdbc20dc 100644 --- a/Zend/zend_observer.c +++ b/Zend/zend_observer.c @@ -115,8 +115,8 @@ ZEND_API void zend_observer_shutdown(void) static void zend_observer_fcall_install(zend_execute_data *execute_data) { - zend_llist *list = &zend_observers_fcall_list; - zend_function *function = execute_data->func; + const zend_llist *list = &zend_observers_fcall_list; + const zend_function *function = execute_data->func; ZEND_ASSERT(RUN_TIME_CACHE(&function->common)); zend_observer_fcall_begin_handler *begin_handlers = ZEND_OBSERVER_DATA(function), *begin_handlers_start = begin_handlers; @@ -126,7 +126,7 @@ static void zend_observer_fcall_install(zend_execute_data *execute_data) *end_handlers = ZEND_OBSERVER_NOT_OBSERVED; bool has_handlers = false; - for (zend_llist_element *element = list->head; element; element = element->next) { + for (const zend_llist_element *element = list->head; element; element = element->next) { zend_observer_fcall_init init; memcpy(&init, element->data, sizeof init); zend_observer_fcall_handlers handlers = init(execute_data); @@ -157,7 +157,7 @@ static void zend_observer_fcall_install(zend_execute_data *execute_data) * the previous next handler is now at the place where the current handler was. * Hence, the next handler executed will be the one after the next handler. * Callees must thus invoke the next handler themselves, with the same arguments they were passed. */ -static bool zend_observer_remove_handler(void **first_handler, void *old_handler, void **next_handler) { +static bool zend_observer_remove_handler(void **first_handler, const void *old_handler, void **next_handler) { size_t registered_observers = zend_observers_fcall_list.count; void **last_handler = first_handler + registered_observers - 1; @@ -179,7 +179,7 @@ static bool zend_observer_remove_handler(void **first_handler, void *old_handler return false; } -ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin) { +ZEND_API void zend_observer_add_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin) { size_t registered_observers = zend_observers_fcall_list.count; zend_observer_fcall_begin_handler *first_handler = ZEND_OBSERVER_DATA(function), *last_handler = first_handler + registered_observers - 1; if (*first_handler == ZEND_OBSERVER_NOT_OBSERVED || *first_handler == ZEND_OBSERVER_NONE_OBSERVED) { @@ -196,7 +196,7 @@ ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_obse } } -ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next) { +ZEND_API bool zend_observer_remove_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next) { void **begin_handlers = (void **)ZEND_OBSERVER_DATA(function); if (zend_observer_remove_handler(begin_handlers, begin, (void**)next)) { // Ensure invariant: ZEND_OBSERVER_NONE_OBSERVED in begin_handlers if both are not observed @@ -211,7 +211,7 @@ ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_o return false; } -ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observer_fcall_end_handler end) { +ZEND_API void zend_observer_add_end_handler(const zend_function *function, zend_observer_fcall_end_handler end) { size_t registered_observers = zend_observers_fcall_list.count; void **begin_handler = (void **)ZEND_OBSERVER_DATA(function); zend_observer_fcall_end_handler *end_handler = (zend_observer_fcall_end_handler *)begin_handler + registered_observers; @@ -226,7 +226,7 @@ ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observ *end_handler = end; } -ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next) { +ZEND_API bool zend_observer_remove_end_handler(const zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next) { size_t registered_observers = zend_observers_fcall_list.count; void **begin_handlers = (void **)ZEND_OBSERVER_DATA(function); void **end_handlers = begin_handlers + registered_observers; @@ -241,7 +241,7 @@ ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_obs } static inline zend_execute_data **prev_observed_frame(zend_execute_data *execute_data) { - zend_function *func = EX(func); + const zend_function *func = EX(func); ZEND_ASSERT(func); return (zend_execute_data **)&Z_PTR_P(EX_VAR_NUM((ZEND_USER_CODE(func->type) ? func->op_array.last_var : ZEND_CALL_NUM_ARGS(execute_data)) + func->common.T - 1)); } @@ -256,7 +256,7 @@ static void ZEND_FASTCALL _zend_observe_fcall_begin(zend_execute_data *execute_d ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_data *execute_data, zend_observer_fcall_begin_handler *handler) { - zend_observer_fcall_begin_handler *possible_handlers_end = handler + zend_observers_fcall_list.count; + const zend_observer_fcall_begin_handler *possible_handlers_end = handler + zend_observers_fcall_list.count; if (!*handler) { zend_observer_fcall_install(execute_data); @@ -265,7 +265,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_da } } - zend_observer_fcall_end_handler *end_handler = (zend_observer_fcall_end_handler *)possible_handlers_end; + const zend_observer_fcall_end_handler *end_handler = (const zend_observer_fcall_end_handler *)possible_handlers_end; if (*end_handler != ZEND_OBSERVER_NOT_OBSERVED) { *prev_observed_frame(execute_data) = EG(current_observed_frame); EG(current_observed_frame) = execute_data; @@ -294,7 +294,7 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin(zend_execute_data *execute } static inline void call_end_observers(zend_execute_data *execute_data, zval *return_value) { - zend_function *func = EX(func); + const zend_function *func = EX(func); ZEND_ASSERT(func); zend_observer_fcall_end_handler *handler = (zend_observer_fcall_end_handler *)ZEND_OBSERVER_DATA(func) + zend_observers_fcall_list.count; @@ -340,7 +340,7 @@ ZEND_API void ZEND_FASTCALL _zend_observer_function_declared_notify(zend_op_arra return; } - for (zend_llist_element *element = zend_observer_function_declared_callbacks.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_function_declared_callbacks.head; element; element = element->next) { zend_observer_function_declared_cb callback = *(zend_observer_function_declared_cb *) (element->data); callback(op_array, name); } @@ -358,7 +358,7 @@ ZEND_API void ZEND_FASTCALL _zend_observer_class_linked_notify(zend_class_entry return; } - for (zend_llist_element *element = zend_observer_class_linked_callbacks.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_class_linked_callbacks.head; element; element = element->next) { zend_observer_class_linked_cb callback = *(zend_observer_class_linked_cb *) (element->data); callback(ce, name); } @@ -372,7 +372,7 @@ ZEND_API void zend_observer_error_register(zend_observer_error_cb cb) ZEND_API void _zend_observer_error_notify(int type, zend_string *error_filename, uint32_t error_lineno, zend_string *message) { - for (zend_llist_element *element = zend_observer_error_callbacks.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_error_callbacks.head; element; element = element->next) { zend_observer_error_cb callback = *(zend_observer_error_cb *) (element->data); callback(type, error_filename, error_lineno, message); } @@ -395,12 +395,11 @@ ZEND_API void zend_observer_fiber_destroy_register(zend_observer_fiber_destroy_h ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context *initializing) { - zend_llist_element *element; zend_observer_fiber_init_handler callback; initializing->top_observed_frame = NULL; - for (element = zend_observer_fiber_init.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_fiber_init.head; element; element = element->next) { callback = *(zend_observer_fiber_init_handler *) element->data; callback(initializing); } @@ -408,14 +407,13 @@ ZEND_API void ZEND_FASTCALL zend_observer_fiber_init_notify(zend_fiber_context * ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context *from, zend_fiber_context *to) { - zend_llist_element *element; zend_observer_fiber_switch_handler callback; if (from->status == ZEND_FIBER_STATUS_DEAD) { zend_observer_fcall_end_all(); // fiber is either finished (call will do nothing) or has bailed out } - for (element = zend_observer_fiber_switch.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_fiber_switch.head; element; element = element->next) { callback = *(zend_observer_fiber_switch_handler *) element->data; callback(from, to); } @@ -426,10 +424,9 @@ ZEND_API void ZEND_FASTCALL zend_observer_fiber_switch_notify(zend_fiber_context ZEND_API void ZEND_FASTCALL zend_observer_fiber_destroy_notify(zend_fiber_context *destroying) { - zend_llist_element *element; zend_observer_fiber_destroy_handler callback; - for (element = zend_observer_fiber_destroy.head; element; element = element->next) { + for (const zend_llist_element *element = zend_observer_fiber_destroy.head; element; element = element->next) { callback = *(zend_observer_fiber_destroy_handler *) element->data; callback(destroying); } diff --git a/Zend/zend_observer.h b/Zend/zend_observer.h index bb8964692c370..cfec5200055af 100644 --- a/Zend/zend_observer.h +++ b/Zend/zend_observer.h @@ -74,10 +74,10 @@ ZEND_API void zend_observer_fcall_register(zend_observer_fcall_init); // Call during runtime, but only if you have used zend_observer_fcall_register. // You must not have more than one begin and one end handler active at the same time. Remove the old one first, if there is an existing one. -ZEND_API void zend_observer_add_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin); -ZEND_API bool zend_observer_remove_begin_handler(zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next); -ZEND_API void zend_observer_add_end_handler(zend_function *function, zend_observer_fcall_end_handler end); -ZEND_API bool zend_observer_remove_end_handler(zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next); +ZEND_API void zend_observer_add_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin); +ZEND_API bool zend_observer_remove_begin_handler(const zend_function *function, zend_observer_fcall_begin_handler begin, zend_observer_fcall_begin_handler *next); +ZEND_API void zend_observer_add_end_handler(const zend_function *function, zend_observer_fcall_end_handler end); +ZEND_API bool zend_observer_remove_end_handler(const zend_function *function, zend_observer_fcall_end_handler end, zend_observer_fcall_end_handler *next); ZEND_API void zend_observer_startup(void); // Called by engine before MINITs ZEND_API void zend_observer_post_startup(void); // Called by engine after MINITs @@ -88,13 +88,13 @@ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin(zend_execute_data *execute /* prechecked: the call is actually observed. */ ZEND_API void ZEND_FASTCALL zend_observer_fcall_begin_prechecked(zend_execute_data *execute_data, zend_observer_fcall_begin_handler *observer_data); -static zend_always_inline bool zend_observer_handler_is_unobserved(zend_observer_fcall_begin_handler *handler) { +static zend_always_inline bool zend_observer_handler_is_unobserved(const zend_observer_fcall_begin_handler *handler) { return *handler == ZEND_OBSERVER_NONE_OBSERVED; } /* Initial check for observers has not happened yet or no observers are installed. */ -static zend_always_inline bool zend_observer_fcall_has_no_observers(zend_execute_data *execute_data, bool allow_generator, zend_observer_fcall_begin_handler **handler) { - zend_function *function = EX(func); +static zend_always_inline bool zend_observer_fcall_has_no_observers(const zend_execute_data *execute_data, bool allow_generator, zend_observer_fcall_begin_handler **handler) { + const zend_function *function = EX(func); void *ZEND_MAP_PTR(runtime_cache) = ZEND_MAP_PTR(function->common.run_time_cache); if (function->common.fn_flags & (ZEND_ACC_CALL_VIA_TRAMPOLINE | (allow_generator ? 0 : ZEND_ACC_GENERATOR))) { diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index f3631104c62c3..5e9e7b20d869b 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -84,6 +84,7 @@ void init_op_array(zend_op_array *op_array, uint8_t type, int initial_ops_size) op_array->last_try_catch = 0; op_array->fn_flags = 0; + op_array->fn_flags2 = 0; op_array->last_literal = 0; op_array->literals = NULL; @@ -123,21 +124,32 @@ ZEND_API void zend_type_release(zend_type type, bool persistent) { } } -void zend_free_internal_arg_info(zend_internal_function *function) { - if ((function->fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS)) && - function->arg_info) { +ZEND_API void zend_free_internal_arg_info(zend_internal_function *function, + bool persistent) { + if (function->arg_info) { + ZEND_ASSERT((persistent || (function->fn_flags & ZEND_ACC_NEVER_CACHE)) + && "Functions with non-persistent arg_info must be flagged ZEND_ACC_NEVER_CACHE"); uint32_t i; uint32_t num_args = function->num_args + 1; - zend_internal_arg_info *arg_info = function->arg_info - 1; + zend_arg_info *arg_info = function->arg_info - 1; if (function->fn_flags & ZEND_ACC_VARIADIC) { num_args++; } for (i = 0 ; i < num_args; i++) { - zend_type_release(arg_info[i].type, /* persistent */ 1); + bool is_return_info = i == 0; + if (!is_return_info) { + zend_string_release_ex(arg_info[i].name, persistent); + if (arg_info[i].default_value) { + zend_string_release_ex(arg_info[i].default_value, + persistent); + } + } + zend_type_release(arg_info[i].type, persistent); } - free(arg_info); + + pefree(arg_info, persistent); } } @@ -156,7 +168,7 @@ ZEND_API void zend_function_dtor(zval *zv) /* For methods this will be called explicitly. */ if (!function->common.scope) { - zend_free_internal_arg_info(&function->internal_function); + zend_free_internal_arg_info(&function->internal_function, true); if (function->common.attributes) { zend_hash_release(function->common.attributes); @@ -396,7 +408,7 @@ ZEND_API void destroy_zend_class(zval *zv) if (prop_info->attributes) { zend_hash_release(prop_info->attributes); } - zend_type_release(prop_info->type, /* persistent */ 0); + zend_type_release(prop_info->type, /* persistent */ false); if (prop_info->hooks) { for (uint32_t i = 0; i < ZEND_PROPERTY_HOOK_COUNT; i++) { if (prop_info->hooks[i]) { @@ -463,7 +475,7 @@ ZEND_API void destroy_zend_class(zval *zv) ZEND_HASH_MAP_FOREACH_PTR(&ce->properties_info, prop_info) { if (prop_info->ce == ce) { zend_string_release(prop_info->name); - zend_type_release(prop_info->type, /* persistent */ 1); + zend_type_release(prop_info->type, /* persistent */ true); if (prop_info->attributes) { zend_hash_release(prop_info->attributes); } @@ -473,12 +485,9 @@ ZEND_API void destroy_zend_class(zval *zv) zend_hash_destroy(&ce->properties_info); zend_string_release_ex(ce->name, 1); - /* TODO: eliminate this loop for classes without functions with arg_info / attributes */ ZEND_HASH_MAP_FOREACH_PTR(&ce->function_table, fn) { if (fn->common.scope == ce) { - if (fn->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS)) { - zend_free_internal_arg_info(&fn->internal_function); - } + zend_free_internal_arg_info(&fn->internal_function, true); if (fn->common.attributes) { zend_hash_release(fn->common.attributes); @@ -639,7 +648,7 @@ ZEND_API void destroy_op_array(zend_op_array *op_array) if (arg_info[i].name) { zend_string_release_ex(arg_info[i].name, 0); } - zend_type_release(arg_info[i].type, /* persistent */ 0); + zend_type_release(arg_info[i].type, /* persistent */ false); } efree(arg_info); } @@ -686,9 +695,7 @@ static void zend_extension_op_array_handler(zend_extension *extension, zend_op_a static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num, uint32_t dst_num) { - int i; - - for (i = 0; i < op_array->last_try_catch; i++) { + for (uint32_t i = 0; i < op_array->last_try_catch; i++) { if ((op_num < op_array->try_catch_array[i].finally_op || op_num >= op_array->try_catch_array[i].finally_end) && (dst_num >= op_array->try_catch_array[i].finally_op && @@ -905,14 +912,14 @@ static bool keeps_op1_alive(zend_op *opline) { || opline->opcode == ZEND_FETCH_LIST_W || opline->opcode == ZEND_COPY_TMP || opline->opcode == ZEND_EXT_STMT) { - return 1; + return true; } ZEND_ASSERT(opline->opcode != ZEND_FE_FETCH_R && opline->opcode != ZEND_FE_FETCH_RW && opline->opcode != ZEND_VERIFY_RETURN_TYPE && opline->opcode != ZEND_BIND_LEXICAL && opline->opcode != ZEND_ROPE_ADD); - return 0; + return false; } /* Live ranges must be sorted by increasing start opline */ diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 36df6915db6a7..2550fcbeb1cde 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -377,7 +377,7 @@ static zend_always_inline zend_result zendi_try_convert_scalar_to_number(zval *o static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval *op, bool *failed) /* {{{ */ { - *failed = 0; + *failed = false; try_again: switch (Z_TYPE_P(op)) { case IS_NULL: @@ -389,7 +389,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval * double dval = Z_DVAL_P(op); zend_long lval = zend_dval_to_lval_safe(dval); if (UNEXPECTED(EG(exception))) { - *failed = 1; + *failed = true; } return lval; } @@ -405,7 +405,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval * type = is_numeric_string_ex(Z_STRVAL_P(op), Z_STRLEN_P(op), &lval, &dval, /* allow errors */ true, NULL, &trailing_data); if (type == 0) { - *failed = 1; + *failed = true; return 0; } if (UNEXPECTED(trailing_data)) { @@ -414,7 +414,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval * } zend_error(E_WARNING, "A non-numeric value encountered"); if (UNEXPECTED(EG(exception))) { - *failed = 1; + *failed = true; zend_tmp_string_release(op_str); return 0; } @@ -435,7 +435,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval * if (!zend_is_long_compatible(dval, lval)) { zend_incompatible_string_to_long_error(op_str); if (UNEXPECTED(EG(exception))) { - *failed = 1; + *failed = true; } } zend_string_release(op_str); @@ -447,7 +447,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval * zval dst; if (Z_OBJ_HT_P(op)->cast_object(Z_OBJ_P(op), &dst, IS_LONG) == FAILURE || EG(exception)) { - *failed = 1; + *failed = true; return 0; } ZEND_ASSERT(Z_TYPE(dst) == IS_LONG); @@ -455,7 +455,7 @@ static zend_never_inline zend_long ZEND_FASTCALL zendi_try_get_long(const zval * } case IS_RESOURCE: case IS_ARRAY: - *failed = 1; + *failed = true; return 0; case IS_REFERENCE: op = Z_REFVAL_P(op); @@ -1106,13 +1106,13 @@ static zend_always_inline zend_string* __zval_get_string_func(zval *op, bool try ZEND_API zend_string* ZEND_FASTCALL zval_get_string_func(zval *op) /* {{{ */ { - return __zval_get_string_func(op, 0); + return __zval_get_string_func(op, false); } /* }}} */ ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op) /* {{{ */ { - return __zval_get_string_func(op, 1); + return __zval_get_string_func(op, true); } /* }}} */ @@ -1593,7 +1593,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, } } ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(ZEND_BOOL_XOR); - op1_val = zval_is_true(op1); + op1_val = zend_is_true(op1); } } while (0); do { @@ -1613,7 +1613,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_xor_function(zval *result, zval *op1, } } ZEND_TRY_BINARY_OP2_OBJECT_OPERATION(ZEND_BOOL_XOR); - op2_val = zval_is_true(op2); + op2_val = zend_is_true(op2); } } while (0); @@ -1641,7 +1641,7 @@ ZEND_API zend_result ZEND_FASTCALL boolean_not_function(zval *result, zval *op1) } ZEND_TRY_UNARY_OBJECT_OPERATION(ZEND_BOOL_NOT); - ZVAL_BOOL(result, !zval_is_true(op1)); + ZVAL_BOOL(result, !zend_is_true(op1)); } return SUCCESS; } @@ -2433,13 +2433,13 @@ ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2) /* {{{ */ converted = true; } } else if (Z_TYPE_P(op1) < IS_TRUE) { - return zval_is_true(op2) ? -1 : 0; + return zend_is_true(op2) ? -1 : 0; } else if (Z_TYPE_P(op1) == IS_TRUE) { - return zval_is_true(op2) ? 0 : 1; + return zend_is_true(op2) ? 0 : 1; } else if (Z_TYPE_P(op2) < IS_TRUE) { - return zval_is_true(op1) ? 1 : 0; + return zend_is_true(op1) ? 1 : 0; } else if (Z_TYPE_P(op2) == IS_TRUE) { - return zval_is_true(op1) ? 0 : -1; + return zend_is_true(op1) ? 0 : -1; } else { op1 = _zendi_convert_scalar_to_number_silent(op1, &op1_copy); op2 = _zendi_convert_scalar_to_number_silent(op2, &op2_copy); diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index a3bf19fca8f27..ff31c84c41e5e 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -390,23 +390,12 @@ static zend_always_inline bool try_convert_to_string(zval *op) { return _try_convert_to_string(op); } -/* Compatibility macros for 7.2 and below */ -#define _zval_get_long(op) zval_get_long(op) -#define _zval_get_double(op) zval_get_double(op) -#define _zval_get_string(op) zval_get_string(op) -#define _zval_get_long_func(op) zval_get_long_func(op) -#define _zval_get_double_func(op) zval_get_double_func(op) -#define _zval_get_string_func(op) zval_get_string_func(op) - #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op)); } ZEND_API bool ZEND_FASTCALL zend_is_true(const zval *op); ZEND_API bool ZEND_FASTCALL zend_object_is_true(const zval *op); -#define zval_is_true(op) \ - zend_is_true(op) - static zend_always_inline bool i_zend_is_true(const zval *op) { bool result = 0; diff --git a/Zend/zend_ptr_stack.c b/Zend/zend_ptr_stack.c index 80c77e11d73e6..fdabdeb61cef7 100644 --- a/Zend/zend_ptr_stack.c +++ b/Zend/zend_ptr_stack.c @@ -30,7 +30,7 @@ ZEND_API void zend_ptr_stack_init_ex(zend_ptr_stack *stack, bool persistent) ZEND_API void zend_ptr_stack_init(zend_ptr_stack *stack) { - zend_ptr_stack_init_ex(stack, 0); + zend_ptr_stack_init_ex(stack, false); } diff --git a/Zend/zend_simd.h b/Zend/zend_simd.h index 9bd16ce9e9afb..2f0df203733ca 100644 --- a/Zend/zend_simd.h +++ b/Zend/zend_simd.h @@ -1,17 +1,17 @@ /******************************************************************************** * MIT License * Copyright (c) 2025 Saki Takamachi - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -22,389 +22,389 @@ *********************************************************************************/ - #ifndef XSSE_H - #define XSSE_H - - #define XSSE_VERSION 10000 - - #ifdef _MSC_VER - # define XSSE_FORCE_INLINE __forceinline - #elif defined(__GNUC__) || defined(__clang__) - # define XSSE_FORCE_INLINE inline __attribute__((always_inline)) - # define XSSE_HAS_MACRO_EXTENSION - #else - # define XSSE_FORCE_INLINE inline - #endif - - - #if defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) - #include - #define XSSE2 - - - #elif defined(__aarch64__) || defined(_M_ARM64) - #include - #define XSSE2 - - typedef int8x16_t __m128i; - - - /***************************************************************************** - * Load / Store * - *****************************************************************************/ - - #define _mm_set_epi8(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) \ - ((int8x16_t) { \ - (int8_t) (x15), (int8_t) (x14), (int8_t) (x13), (int8_t) (x12), \ - (int8_t) (x11), (int8_t) (x10), (int8_t) (x9), (int8_t) (x8), \ - (int8_t) (x7), (int8_t) (x6), (int8_t) (x5), (int8_t) (x4), \ - (int8_t) (x3), (int8_t) (x2), (int8_t) (x1), (int8_t) (x0) }) - #define _mm_set_epi16(x0, x1, x2, x3, x4, x5, x6, x7) \ - (vreinterpretq_s8_s16((int16x8_t) { \ - (int16_t) (x7), (int16_t) (x6), (int16_t) (x5), (int16_t) (x4), \ - (int16_t) (x3), (int16_t) (x2), (int16_t) (x1), (int16_t) (x0) })) - #define _mm_set_epi32(x0, x1, x2, x3) \ - (vreinterpretq_s8_s32((int32x4_t) { (int32_t) (x3), (int32_t) (x2), (int32_t) (x1), (int32_t) (x0) })) - #define _mm_set_epi64x(x0, x1) (vreinterpretq_s8_s64((int64x2_t) { (int64_t) (x1), (int64_t) (x0) })) - #define _mm_set1_epi8(x) (vdupq_n_s8((int8_t) (x))) - #define _mm_set1_epi16(x) (vreinterpretq_s8_s16(vdupq_n_s16((int16_t) (x)))) - #define _mm_set1_epi32(x) (vreinterpretq_s8_s32(vdupq_n_s32((int32_t) (x)))) - #define _mm_set1_epi64x(x) (vreinterpretq_s8_s64(vdupq_n_s64((int64_t) (x)))) - - #define _mm_setr_epi8(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) \ - ((int8x16_t) { \ - (int8_t) (x0), (int8_t) (x1), (int8_t) (x2), (int8_t) (x3), \ - (int8_t) (x4), (int8_t) (x5), (int8_t) (x6), (int8_t) (x7), \ - (int8_t) (x8), (int8_t) (x9), (int8_t) (x10), (int8_t) (x11), \ - (int8_t) (x12), (int8_t) (x13), (int8_t) (x14), (int8_t) (x15) }) - #define _mm_setr_epi16(x0, x1, x2, x3, x4, x5, x6, x7) \ - (vreinterpretq_s8_s16((int16x8_t) { \ - (int16_t) (x0), (int16_t) (x1), (int16_t) (x2), (int16_t) (x3), \ - (int16_t) (x4), (int16_t) (x5), (int16_t) (x6), (int16_t) (x7) })) - #define _mm_setr_epi32(x0, x1, x2, x3) \ - (vreinterpretq_s8_s32((int32x4_t) { (int32_t) (x0), (int32_t) (x1), (int32_t) (x2), (int32_t) (x3) })) - - #define _mm_setzero_si128() (vdupq_n_s8(0)) - - #define _mm_load_si128(x) (vld1q_s8((const int8_t *) (x))) - #define _mm_loadu_si128(x) _mm_load_si128(x) - - #define _mm_store_si128(to, x) (vst1q_s8((int8_t *) (to), x)) - #define _mm_storeu_si128(to, x) _mm_store_si128(to, x) - #define _mm_stream_si128(to, x) _mm_store_si128(to, x) - #define _mm_stream_si32(to, x) (*(volatile int32_t *)(to) = (int32_t)(x)) - - - /***************************************************************************** - * Bit shift / Bit wise * - *****************************************************************************/ - - #define _mm_or_si128(a, b) (vorrq_s8((a), (b))) - #define _mm_xor_si128(a, b) (veorq_s8((a), (b))) - #define _mm_and_si128(a, b) (vandq_s8((a), (b))) - #define _mm_andnot_si128(a, b) (vbicq_s8((b), (a))) - - #define _mm_slli_epi16(x, count) (vreinterpretq_s8_u16(vshlq_n_u16(vreinterpretq_u16_s8(x), (count)))) - #define _mm_slli_epi32(x, count) (vreinterpretq_s8_u32(vshlq_n_u32(vreinterpretq_u32_s8(x), (count)))) - #define _mm_slli_epi64(x, count) (vreinterpretq_s8_u64(vshlq_n_u64(vreinterpretq_u64_s8(x), (count)))) - static XSSE_FORCE_INLINE __m128i _mm_sll_epi16(__m128i x, __m128i count) - { - uint16_t shift = (uint16_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFF); - return vreinterpretq_s8_u16( - vshlq_u16(vreinterpretq_u16_s8(x), vdupq_n_s16((int16_t) shift)) - ); - } - static XSSE_FORCE_INLINE __m128i _mm_sll_epi32(__m128i x, __m128i count) - { - uint32_t shift = (uint32_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFFFFFF); - return vreinterpretq_s8_u32( - vshlq_u32(vreinterpretq_u32_s8(x), vdupq_n_s32((int32_t) shift)) - ); - } - static XSSE_FORCE_INLINE __m128i _mm_sll_epi64(__m128i x, __m128i count) - { - uint64_t shift = (uint64_t) vgetq_lane_s64(vreinterpretq_s64_s8(count), 0); - return vreinterpretq_s8_u64( - vshlq_u64(vreinterpretq_u64_s8(x), vdupq_n_s64((int64_t) shift)) - ); - } - - #define _mm_slli_si128(x, imm) \ - ((imm) >= 16 ? vdupq_n_s8(0) : vreinterpretq_s8_u8(vextq_u8(vdupq_n_u8(0), vreinterpretq_u8_s8(x), 16 - (imm)))) - - #define _mm_srai_epi16(x, count) (vreinterpretq_s8_s16(vshrq_n_s16(vreinterpretq_s16_s8(x), (count)))) - #define _mm_srai_epi32(x, count) (vreinterpretq_s8_s32(vshrq_n_s32(vreinterpretq_s32_s8(x), (count)))) - static inline __m128i _mm_sra_epi16(__m128i x, __m128i count) - { - uint16_t shift = (uint16_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFF); - return vreinterpretq_s8_s16( - vshlq_s16(vreinterpretq_s16_s8(x), vdupq_n_s16(-(int16_t) shift)) - ); - } - static inline __m128i _mm_sra_epi32(__m128i x, __m128i count) - { - uint32_t shift = (uint32_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFFFFFF); - return vreinterpretq_s8_s32( - vshlq_s32(vreinterpretq_s32_s8(x), vdupq_n_s32(-(int32_t) shift)) - ); - } - - #define _mm_srli_epi16(x, count) (vreinterpretq_s8_u16(vshrq_n_u16(vreinterpretq_u16_s8(x), (count)))) - #define _mm_srli_epi32(x, count) (vreinterpretq_s8_u32(vshrq_n_u32(vreinterpretq_u32_s8(x), (count)))) - #define _mm_srli_epi64(x, count) (vreinterpretq_s8_u64(vshrq_n_u64(vreinterpretq_u64_s8(x), (count)))) - static XSSE_FORCE_INLINE __m128i _mm_srl_epi16(__m128i x, __m128i count) - { - uint16_t shift = (uint16_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFF); - return vreinterpretq_s8_u16( - vshlq_u16(vreinterpretq_u16_s8(x), vdupq_n_s16(-(int16_t) shift)) - ); - } - static XSSE_FORCE_INLINE __m128i _mm_srl_epi32(__m128i x, __m128i count) - { - uint32_t shift = (uint32_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFFFFFF); - return vreinterpretq_s8_u32( - vshlq_u32(vreinterpretq_u32_s8(x), vdupq_n_s32(-(int32_t) shift)) - ); - } - static XSSE_FORCE_INLINE __m128i _mm_srl_epi64(__m128i x, __m128i count) - { - uint64_t shift = (uint64_t) vgetq_lane_s64(vreinterpretq_s64_s8(count), 0); - return vreinterpretq_s8_u64( - vshlq_u64(vreinterpretq_u64_s8(x), vdupq_n_s64(-(int64_t) shift)) - ); - } - - #define _mm_srli_si128(x, imm) \ - ((imm) >= 16 ? vdupq_n_s8(0) : vreinterpretq_s8_u8(vextq_u8(vreinterpretq_u8_s8(x), vdupq_n_u8(0), (imm)))) - - - /***************************************************************************** - * Integer Arithmetic Operations * - *****************************************************************************/ - - /** - * In practice, there is no problem, but a runtime error for signed integer overflow is triggered by UBSAN, - * so perform the calculation as unsigned. Since it is optimized at compile time, there are no unnecessary casts at runtime. - */ - #define _mm_add_epi8(a, b) (vreinterpretq_s8_u8(vaddq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) - #define _mm_add_epi16(a, b) (vreinterpretq_s8_u16(vaddq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) - #define _mm_add_epi32(a, b) (vreinterpretq_s8_u32(vaddq_u32(vreinterpretq_u32_s8(a), vreinterpretq_u32_s8(b)))) - #define _mm_add_epi64(a, b) (vreinterpretq_s8_u64(vaddq_u64(vreinterpretq_u64_s8(a), vreinterpretq_u64_s8(b)))) - - #define _mm_adds_epi8(a, b) (vqaddq_s8((a), (b))) - #define _mm_adds_epi16(a, b) (vreinterpretq_s8_s16(vqaddq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_adds_epu8(a, b) (vreinterpretq_s8_u8(vqaddq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) - #define _mm_adds_epu16(a, b) (vreinterpretq_s8_u16(vqaddq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) - - #define _mm_avg_epu8(a, b) (vreinterpretq_s8_u8(vrhaddq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) - #define _mm_avg_epu16(a, b) (vreinterpretq_s8_u16(vrhaddq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) - - static XSSE_FORCE_INLINE __m128i _mm_madd_epi16(__m128i a, __m128i b) - { - int32x4_t mul_lo = vmull_s16(vget_low_s16(vreinterpretq_s16_s8(a)), vget_low_s16(vreinterpretq_s16_s8(b))); - int32x4_t mul_hi = vmull_s16(vget_high_s16(vreinterpretq_s16_s8(a)), vget_high_s16(vreinterpretq_s16_s8(b))); - - return vreinterpretq_s8_s32(vcombine_s32( - vpadd_s32(vget_low_s32(mul_lo), vget_high_s32(mul_lo)), - vpadd_s32(vget_low_s32(mul_hi), vget_high_s32(mul_hi)) - )); - } - - #define _mm_max_epu8(a, b) (vreinterpretq_s8_u8(vmaxq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) - #define _mm_max_epi16(a, b) (vreinterpretq_s8_s16(vmaxq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_min_epu8(a, b) (vreinterpretq_s8_u8(vminq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) - #define _mm_min_epi16(a, b) (vreinterpretq_s8_s16(vminq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - - static XSSE_FORCE_INLINE __m128i _mm_mulhi_epi16(__m128i a, __m128i b) - { - int32x4_t lo = vmull_s16(vget_low_s16(vreinterpretq_s16_s8(a)), vget_low_s16(vreinterpretq_s16_s8(b))); - int32x4_t hi = vmull_s16(vget_high_s16(vreinterpretq_s16_s8(a)), vget_high_s16(vreinterpretq_s16_s8(b))); - return vreinterpretq_s8_s16(vcombine_s16(vshrn_n_s32(lo, 16), vshrn_n_s32(hi, 16))); - } - static XSSE_FORCE_INLINE __m128i _mm_mulhi_epu16(__m128i a, __m128i b) - { - uint32x4_t lo = vmull_u16(vget_low_u16(vreinterpretq_u16_s8(a)), vget_low_u16(vreinterpretq_u16_s8(b))); - uint32x4_t hi = vmull_u16(vget_high_u16(vreinterpretq_u16_s8(a)), vget_high_u16(vreinterpretq_u16_s8(b))); - return vreinterpretq_s8_u16(vcombine_u16(vshrn_n_u32(lo, 16), vshrn_n_u32(hi, 16))); - } - static XSSE_FORCE_INLINE __m128i _mm_mullo_epi16(__m128i a, __m128i b) - { - int32x4_t lo = vmull_s16(vget_low_s16(vreinterpretq_s16_s8(a)), vget_low_s16(vreinterpretq_s16_s8(b))); - int32x4_t hi = vmull_s16(vget_high_s16(vreinterpretq_s16_s8(a)), vget_high_s16(vreinterpretq_s16_s8(b))); - return vreinterpretq_s8_s16(vcombine_s16(vmovn_s32(lo), vmovn_s32(hi))); - } - static XSSE_FORCE_INLINE __m128i _mm_mul_epu32(__m128i a, __m128i b) - { - uint32x4_t evens = vuzpq_u32(vreinterpretq_u32_s8(a), vreinterpretq_u32_s8(b)).val[0]; - return vreinterpretq_s8_u64(vmull_u32(vget_low_u32(evens), vget_high_u32(evens))); - } - static XSSE_FORCE_INLINE __m128i _mm_sad_epu8(__m128i a, __m128i b) - { - uint16x8_t abs_diffs_16 = vpaddlq_u8(vabdq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b))); - uint32x4_t abs_diffs_32 = vpaddlq_u16(abs_diffs_16); - uint64x2_t abs_diffs_64 = vpaddlq_u32(abs_diffs_32); - - return vreinterpretq_s8_u16((uint16x8_t) { - (int16_t) vgetq_lane_u64(abs_diffs_64, 0), 0, 0, 0, - (int16_t) vgetq_lane_u64(abs_diffs_64, 1), 0, 0, 0 - }); - } - - #define _mm_sub_epi8(a, b) (vreinterpretq_s8_u8(vsubq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) - #define _mm_sub_epi16(a, b) (vreinterpretq_s8_u16(vsubq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) - #define _mm_sub_epi32(a, b) (vreinterpretq_s8_u32(vsubq_u32(vreinterpretq_u32_s8(a), vreinterpretq_u32_s8(b)))) - #define _mm_sub_epi64(a, b) (vreinterpretq_s8_u64(vsubq_u64(vreinterpretq_u64_s8(a), vreinterpretq_u64_s8(b)))) - - #define _mm_subs_epi8(a, b) (vqsubq_s8((a), (b))) - #define _mm_subs_epi16(a, b) (vreinterpretq_s8_s16(vqsubq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_subs_epu8(a, b) (vreinterpretq_s8_u8(vqsubq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) - #define _mm_subs_epu16(a, b) (vreinterpretq_s8_u16(vqsubq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) - - - /***************************************************************************** - * Comparison * - *****************************************************************************/ - - #define _mm_cmpeq_epi8(a, b) (vreinterpretq_s8_u8(vceqq_s8((a), (b)))) - #define _mm_cmpeq_epi16(a, b) (vreinterpretq_s8_u16(vceqq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_cmpeq_epi32(a, b) (vreinterpretq_s8_u32(vceqq_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) - - #define _mm_cmplt_epi8(a, b) (vreinterpretq_s8_u8(vcltq_s8((a), (b)))) - #define _mm_cmplt_epi16(a, b) (vreinterpretq_s8_u16(vcltq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_cmplt_epi32(a, b) (vreinterpretq_s8_u32(vcltq_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) - - #define _mm_cmpgt_epi8(a, b) (vreinterpretq_s8_u8(vcgtq_s8((a), (b)))) - #define _mm_cmpgt_epi16(a, b) (vreinterpretq_s8_u16(vcgtq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_cmpgt_epi32(a, b) (vreinterpretq_s8_u32(vcgtq_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) - - - /***************************************************************************** - * Convert * - *****************************************************************************/ - - #define _mm_cvtsi32_si128(x) (vreinterpretq_s8_s32((int32x4_t) { (int32_t) (x), 0, 0, 0 })) - #define _mm_cvtsi64_si128(x) (vreinterpretq_s8_s64((int64x2_t) { (int64_t) (x), 0 })) - #define _mm_cvtsi128_si32(x) (vgetq_lane_s32(vreinterpretq_s32_s8(x), 0)) - #define _mm_cvtsi128_si64(x) (vgetq_lane_s64(vreinterpretq_s64_s8(x), 0)) - - - /***************************************************************************** - * Others * - *****************************************************************************/ - - #define _mm_packs_epi16(a, b) (vcombine_s8(vqmovn_s16(vreinterpretq_s16_s8(a)), vqmovn_s16(vreinterpretq_s16_s8(b)))) - #define _mm_packs_epi32(a, b) \ - (vreinterpretq_s8_s16(vcombine_s16(vqmovn_s32(vreinterpretq_s32_s8(a)), vqmovn_s32(vreinterpretq_s32_s8(b))))) - #define _mm_packus_epi16(a, b) \ - (vreinterpretq_s8_u8(vcombine_u8(vqmovun_s16(vreinterpretq_s16_s8(a)), vqmovun_s16(vreinterpretq_s16_s8(b))))) - - #define _mm_extract_epi16(x, imm) (vgetq_lane_s16(vreinterpretq_s16_s8(x), (imm))) - #define _mm_insert_epi16(x, val, imm) (vreinterpretq_s8_s16(vsetq_lane_s16((int16_t) (val), vreinterpretq_s16_s8(x), (imm)))) - - static XSSE_FORCE_INLINE int _mm_movemask_epi8(__m128i x) - { - /** - * based on code from - * https://community.arm.com/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/porting-x86-vector-bitmask-optimizations-to-arm-neon - */ - uint16x8_t high_bits = vreinterpretq_u16_u8(vshrq_n_u8(vreinterpretq_u8_s8(x), 7)); - uint32x4_t paired16 = vreinterpretq_u32_u16(vsraq_n_u16(high_bits, high_bits, 7)); - uint64x2_t paired32 = vreinterpretq_u64_u32(vsraq_n_u32(paired16, paired16, 14)); - uint8x16_t paired64 = vreinterpretq_u8_u64(vsraq_n_u64(paired32, paired32, 28)); - return vgetq_lane_u8(paired64, 0) | ((int) vgetq_lane_u8(paired64, 8) << 8); - } - - #define _MM_SHUFFLE(a, b, c, d) (((a) << 6) | ((b) << 4) | ((c) << 2) | (d)) - #ifdef XSSE_HAS_MACRO_EXTENSION - #define _mm_shuffle_epi32(x, imm) __extension__({ \ - int32x4_t __xsse_tmp = vreinterpretq_s32_s8(x); \ - vreinterpretq_s8_s32((int32x4_t) { \ - (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 0) & 0x3), \ - (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 2) & 0x3), \ - (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 4) & 0x3), \ - (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 6) & 0x3) \ - }); \ - }) - #define _mm_shufflehi_epi16(x, imm) __extension__({ \ - int16x8_t __xsse_tmp = vreinterpretq_s16_s8(x); \ - vreinterpretq_s8_s16(vcombine_s16( \ - vget_low_s16(__xsse_tmp), \ - (int16x4_t) { \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 0) & 0x3) + 4), \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 2) & 0x3) + 4), \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 4) & 0x3) + 4), \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 6) & 0x3) + 4) \ - } \ - )); \ - }) - #define _mm_shufflelo_epi16(x, imm) __extension__({ \ - int16x8_t __xsse_tmp = vreinterpretq_s16_s8(x); \ - vreinterpretq_s8_s16(vcombine_s16( \ - (int16x4_t) { \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 0) & 0x3)), \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 2) & 0x3)), \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 4) & 0x3)), \ - (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 6) & 0x3)) \ - }, \ - vget_high_s16(__xsse_tmp) \ - )); \ - }) - #else - static XSSE_FORCE_INLINE __m128i _mm_shuffle_epi32(__m128i x, int imm) - { - int32x4_t vec = vreinterpretq_s32_s8(x); - int32_t arr[4]; - vst1q_s32(arr, vec); - - return vreinterpretq_s8_s32((int32x4_t) { - arr[(imm >> 0) & 0x3], - arr[(imm >> 2) & 0x3], - arr[(imm >> 4) & 0x3], - arr[(imm >> 6) & 0x3] - }); - } - static XSSE_FORCE_INLINE __m128i _mm_shufflehi_epi16(__m128i x, int imm) - { - int16x8_t vec = vreinterpretq_s16_s8(x); - int16_t arr[8]; - vst1q_s16(arr, vec); - - return vreinterpretq_s8_s16((int16x8_t) { - arr[0], arr[1], arr[2], arr[3], - arr[((imm >> 0) & 0x3) + 4], - arr[((imm >> 2) & 0x3) + 4], - arr[((imm >> 4) & 0x3) + 4], - arr[((imm >> 6) & 0x3) + 4] - }); - } - static XSSE_FORCE_INLINE __m128i _mm_shufflelo_epi16(__m128i x, int imm) - { - int16x8_t vec = vreinterpretq_s16_s8(x); - int16_t arr[8]; - vst1q_s16(arr, vec); - - return vreinterpretq_s8_s16((int16x8_t) { - arr[((imm >> 0) & 0x3)], - arr[((imm >> 2) & 0x3)], - arr[((imm >> 4) & 0x3)], - arr[((imm >> 6) & 0x3)], - arr[4], arr[5], arr[6], arr[7] - }); - } - #endif - - #define _mm_unpackhi_epi8(a, b) (vzip2q_s8((a), (b))) - #define _mm_unpackhi_epi16(a, b) (vreinterpretq_s8_s16(vzip2q_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_unpackhi_epi32(a, b) (vreinterpretq_s8_s32(vzip2q_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) - #define _mm_unpackhi_epi64(a, b) (vreinterpretq_s8_s64(vzip2q_s64(vreinterpretq_s64_s8(a), vreinterpretq_s64_s8(b)))) - - #define _mm_unpacklo_epi8(a, b) (vzip1q_s8((a), (b))) - #define _mm_unpacklo_epi16(a, b) (vreinterpretq_s8_s16(vzip1q_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) - #define _mm_unpacklo_epi32(a, b) (vreinterpretq_s8_s32(vzip1q_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) - #define _mm_unpacklo_epi64(a, b) (vreinterpretq_s8_s64(vzip1q_s64(vreinterpretq_s64_s8(a), vreinterpretq_s64_s8(b)))) - - #define _mm_move_epi64(x) (vreinterpretq_s8_s64((int64x2_t) { vgetq_lane_s64(vreinterpretq_s64_s8(x), 0), 0 })) - - #endif - - #endif /* XSSE_H */ +#ifndef XSSE_H +#define XSSE_H + +#define XSSE_VERSION 10000 + +#ifdef _MSC_VER +# define XSSE_FORCE_INLINE __forceinline +#elif defined(__GNUC__) || defined(__clang__) +# define XSSE_FORCE_INLINE inline __attribute__((always_inline)) +# define XSSE_HAS_MACRO_EXTENSION +#else +# define XSSE_FORCE_INLINE inline +#endif + + +#if defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) +#include +#define XSSE2 + + +#elif defined(__aarch64__) || defined(_M_ARM64) +#include +#define XSSE2 + +typedef int8x16_t __m128i; + + +/***************************************************************************** + * Load / Store * + *****************************************************************************/ + +#define _mm_set_epi8(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) \ + ((int8x16_t) { \ + (int8_t) (x15), (int8_t) (x14), (int8_t) (x13), (int8_t) (x12), \ + (int8_t) (x11), (int8_t) (x10), (int8_t) (x9), (int8_t) (x8), \ + (int8_t) (x7), (int8_t) (x6), (int8_t) (x5), (int8_t) (x4), \ + (int8_t) (x3), (int8_t) (x2), (int8_t) (x1), (int8_t) (x0) }) +#define _mm_set_epi16(x0, x1, x2, x3, x4, x5, x6, x7) \ + (vreinterpretq_s8_s16((int16x8_t) { \ + (int16_t) (x7), (int16_t) (x6), (int16_t) (x5), (int16_t) (x4), \ + (int16_t) (x3), (int16_t) (x2), (int16_t) (x1), (int16_t) (x0) })) +#define _mm_set_epi32(x0, x1, x2, x3) \ + (vreinterpretq_s8_s32((int32x4_t) { (int32_t) (x3), (int32_t) (x2), (int32_t) (x1), (int32_t) (x0) })) +#define _mm_set_epi64x(x0, x1) (vreinterpretq_s8_s64((int64x2_t) { (int64_t) (x1), (int64_t) (x0) })) +#define _mm_set1_epi8(x) (vdupq_n_s8((int8_t) (x))) +#define _mm_set1_epi16(x) (vreinterpretq_s8_s16(vdupq_n_s16((int16_t) (x)))) +#define _mm_set1_epi32(x) (vreinterpretq_s8_s32(vdupq_n_s32((int32_t) (x)))) +#define _mm_set1_epi64x(x) (vreinterpretq_s8_s64(vdupq_n_s64((int64_t) (x)))) + +#define _mm_setr_epi8(x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) \ + ((int8x16_t) { \ + (int8_t) (x0), (int8_t) (x1), (int8_t) (x2), (int8_t) (x3), \ + (int8_t) (x4), (int8_t) (x5), (int8_t) (x6), (int8_t) (x7), \ + (int8_t) (x8), (int8_t) (x9), (int8_t) (x10), (int8_t) (x11), \ + (int8_t) (x12), (int8_t) (x13), (int8_t) (x14), (int8_t) (x15) }) +#define _mm_setr_epi16(x0, x1, x2, x3, x4, x5, x6, x7) \ + (vreinterpretq_s8_s16((int16x8_t) { \ + (int16_t) (x0), (int16_t) (x1), (int16_t) (x2), (int16_t) (x3), \ + (int16_t) (x4), (int16_t) (x5), (int16_t) (x6), (int16_t) (x7) })) +#define _mm_setr_epi32(x0, x1, x2, x3) \ + (vreinterpretq_s8_s32((int32x4_t) { (int32_t) (x0), (int32_t) (x1), (int32_t) (x2), (int32_t) (x3) })) + +#define _mm_setzero_si128() (vdupq_n_s8(0)) + +#define _mm_load_si128(x) (vld1q_s8((const int8_t *) (x))) +#define _mm_loadu_si128(x) _mm_load_si128(x) + +#define _mm_store_si128(to, x) (vst1q_s8((int8_t *) (to), x)) +#define _mm_storeu_si128(to, x) _mm_store_si128(to, x) +#define _mm_stream_si128(to, x) _mm_store_si128(to, x) +#define _mm_stream_si32(to, x) (*(volatile int32_t *)(to) = (int32_t)(x)) + + +/***************************************************************************** + * Bit shift / Bit wise * + *****************************************************************************/ + +#define _mm_or_si128(a, b) (vorrq_s8((a), (b))) +#define _mm_xor_si128(a, b) (veorq_s8((a), (b))) +#define _mm_and_si128(a, b) (vandq_s8((a), (b))) +#define _mm_andnot_si128(a, b) (vbicq_s8((b), (a))) + +#define _mm_slli_epi16(x, count) (vreinterpretq_s8_u16(vshlq_n_u16(vreinterpretq_u16_s8(x), (count)))) +#define _mm_slli_epi32(x, count) (vreinterpretq_s8_u32(vshlq_n_u32(vreinterpretq_u32_s8(x), (count)))) +#define _mm_slli_epi64(x, count) (vreinterpretq_s8_u64(vshlq_n_u64(vreinterpretq_u64_s8(x), (count)))) +static XSSE_FORCE_INLINE __m128i _mm_sll_epi16(__m128i x, __m128i count) +{ + uint16_t shift = (uint16_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFF); + return vreinterpretq_s8_u16( + vshlq_u16(vreinterpretq_u16_s8(x), vdupq_n_s16((int16_t) shift)) + ); +} +static XSSE_FORCE_INLINE __m128i _mm_sll_epi32(__m128i x, __m128i count) +{ + uint32_t shift = (uint32_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFFFFFF); + return vreinterpretq_s8_u32( + vshlq_u32(vreinterpretq_u32_s8(x), vdupq_n_s32((int32_t) shift)) + ); +} +static XSSE_FORCE_INLINE __m128i _mm_sll_epi64(__m128i x, __m128i count) +{ + uint64_t shift = (uint64_t) vgetq_lane_s64(vreinterpretq_s64_s8(count), 0); + return vreinterpretq_s8_u64( + vshlq_u64(vreinterpretq_u64_s8(x), vdupq_n_s64((int64_t) shift)) + ); +} + +#define _mm_slli_si128(x, imm) \ + ((imm) >= 16 ? vdupq_n_s8(0) : vreinterpretq_s8_u8(vextq_u8(vdupq_n_u8(0), vreinterpretq_u8_s8(x), 16 - (imm)))) + +#define _mm_srai_epi16(x, count) (vreinterpretq_s8_s16(vshrq_n_s16(vreinterpretq_s16_s8(x), (count)))) +#define _mm_srai_epi32(x, count) (vreinterpretq_s8_s32(vshrq_n_s32(vreinterpretq_s32_s8(x), (count)))) +static inline __m128i _mm_sra_epi16(__m128i x, __m128i count) +{ + uint16_t shift = (uint16_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFF); + return vreinterpretq_s8_s16( + vshlq_s16(vreinterpretq_s16_s8(x), vdupq_n_s16(-(int16_t) shift)) + ); +} +static inline __m128i _mm_sra_epi32(__m128i x, __m128i count) +{ + uint32_t shift = (uint32_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFFFFFF); + return vreinterpretq_s8_s32( + vshlq_s32(vreinterpretq_s32_s8(x), vdupq_n_s32(-(int32_t) shift)) + ); +} + +#define _mm_srli_epi16(x, count) (vreinterpretq_s8_u16(vshrq_n_u16(vreinterpretq_u16_s8(x), (count)))) +#define _mm_srli_epi32(x, count) (vreinterpretq_s8_u32(vshrq_n_u32(vreinterpretq_u32_s8(x), (count)))) +#define _mm_srli_epi64(x, count) (vreinterpretq_s8_u64(vshrq_n_u64(vreinterpretq_u64_s8(x), (count)))) +static XSSE_FORCE_INLINE __m128i _mm_srl_epi16(__m128i x, __m128i count) +{ + uint16_t shift = (uint16_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFF); + return vreinterpretq_s8_u16( + vshlq_u16(vreinterpretq_u16_s8(x), vdupq_n_s16(-(int16_t) shift)) + ); +} +static XSSE_FORCE_INLINE __m128i _mm_srl_epi32(__m128i x, __m128i count) +{ + uint32_t shift = (uint32_t) (vgetq_lane_s64(vreinterpretq_s64_s8(count), 0) & 0xFFFFFFFF); + return vreinterpretq_s8_u32( + vshlq_u32(vreinterpretq_u32_s8(x), vdupq_n_s32(-(int32_t) shift)) + ); +} +static XSSE_FORCE_INLINE __m128i _mm_srl_epi64(__m128i x, __m128i count) +{ + uint64_t shift = (uint64_t) vgetq_lane_s64(vreinterpretq_s64_s8(count), 0); + return vreinterpretq_s8_u64( + vshlq_u64(vreinterpretq_u64_s8(x), vdupq_n_s64(-(int64_t) shift)) + ); +} + +#define _mm_srli_si128(x, imm) \ + ((imm) >= 16 ? vdupq_n_s8(0) : vreinterpretq_s8_u8(vextq_u8(vreinterpretq_u8_s8(x), vdupq_n_u8(0), (imm)))) + + +/***************************************************************************** + * Integer Arithmetic Operations * + *****************************************************************************/ + +/** + * In practice, there is no problem, but a runtime error for signed integer overflow is triggered by UBSAN, + * so perform the calculation as unsigned. Since it is optimized at compile time, there are no unnecessary casts at runtime. + */ +#define _mm_add_epi8(a, b) (vreinterpretq_s8_u8(vaddq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) +#define _mm_add_epi16(a, b) (vreinterpretq_s8_u16(vaddq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) +#define _mm_add_epi32(a, b) (vreinterpretq_s8_u32(vaddq_u32(vreinterpretq_u32_s8(a), vreinterpretq_u32_s8(b)))) +#define _mm_add_epi64(a, b) (vreinterpretq_s8_u64(vaddq_u64(vreinterpretq_u64_s8(a), vreinterpretq_u64_s8(b)))) + +#define _mm_adds_epi8(a, b) (vqaddq_s8((a), (b))) +#define _mm_adds_epi16(a, b) (vreinterpretq_s8_s16(vqaddq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_adds_epu8(a, b) (vreinterpretq_s8_u8(vqaddq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) +#define _mm_adds_epu16(a, b) (vreinterpretq_s8_u16(vqaddq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) + +#define _mm_avg_epu8(a, b) (vreinterpretq_s8_u8(vrhaddq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) +#define _mm_avg_epu16(a, b) (vreinterpretq_s8_u16(vrhaddq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) + +static XSSE_FORCE_INLINE __m128i _mm_madd_epi16(__m128i a, __m128i b) +{ + int32x4_t mul_lo = vmull_s16(vget_low_s16(vreinterpretq_s16_s8(a)), vget_low_s16(vreinterpretq_s16_s8(b))); + int32x4_t mul_hi = vmull_s16(vget_high_s16(vreinterpretq_s16_s8(a)), vget_high_s16(vreinterpretq_s16_s8(b))); + + return vreinterpretq_s8_s32(vcombine_s32( + vpadd_s32(vget_low_s32(mul_lo), vget_high_s32(mul_lo)), + vpadd_s32(vget_low_s32(mul_hi), vget_high_s32(mul_hi)) + )); +} + +#define _mm_max_epu8(a, b) (vreinterpretq_s8_u8(vmaxq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) +#define _mm_max_epi16(a, b) (vreinterpretq_s8_s16(vmaxq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_min_epu8(a, b) (vreinterpretq_s8_u8(vminq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) +#define _mm_min_epi16(a, b) (vreinterpretq_s8_s16(vminq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) + +static XSSE_FORCE_INLINE __m128i _mm_mulhi_epi16(__m128i a, __m128i b) +{ + int32x4_t lo = vmull_s16(vget_low_s16(vreinterpretq_s16_s8(a)), vget_low_s16(vreinterpretq_s16_s8(b))); + int32x4_t hi = vmull_s16(vget_high_s16(vreinterpretq_s16_s8(a)), vget_high_s16(vreinterpretq_s16_s8(b))); + return vreinterpretq_s8_s16(vcombine_s16(vshrn_n_s32(lo, 16), vshrn_n_s32(hi, 16))); +} +static XSSE_FORCE_INLINE __m128i _mm_mulhi_epu16(__m128i a, __m128i b) +{ + uint32x4_t lo = vmull_u16(vget_low_u16(vreinterpretq_u16_s8(a)), vget_low_u16(vreinterpretq_u16_s8(b))); + uint32x4_t hi = vmull_u16(vget_high_u16(vreinterpretq_u16_s8(a)), vget_high_u16(vreinterpretq_u16_s8(b))); + return vreinterpretq_s8_u16(vcombine_u16(vshrn_n_u32(lo, 16), vshrn_n_u32(hi, 16))); +} +static XSSE_FORCE_INLINE __m128i _mm_mullo_epi16(__m128i a, __m128i b) +{ + int32x4_t lo = vmull_s16(vget_low_s16(vreinterpretq_s16_s8(a)), vget_low_s16(vreinterpretq_s16_s8(b))); + int32x4_t hi = vmull_s16(vget_high_s16(vreinterpretq_s16_s8(a)), vget_high_s16(vreinterpretq_s16_s8(b))); + return vreinterpretq_s8_s16(vcombine_s16(vmovn_s32(lo), vmovn_s32(hi))); +} +static XSSE_FORCE_INLINE __m128i _mm_mul_epu32(__m128i a, __m128i b) +{ + uint32x4_t evens = vuzpq_u32(vreinterpretq_u32_s8(a), vreinterpretq_u32_s8(b)).val[0]; + return vreinterpretq_s8_u64(vmull_u32(vget_low_u32(evens), vget_high_u32(evens))); +} +static XSSE_FORCE_INLINE __m128i _mm_sad_epu8(__m128i a, __m128i b) +{ + uint16x8_t abs_diffs_16 = vpaddlq_u8(vabdq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b))); + uint32x4_t abs_diffs_32 = vpaddlq_u16(abs_diffs_16); + uint64x2_t abs_diffs_64 = vpaddlq_u32(abs_diffs_32); + + return vreinterpretq_s8_u16((uint16x8_t) { + (int16_t) vgetq_lane_u64(abs_diffs_64, 0), 0, 0, 0, + (int16_t) vgetq_lane_u64(abs_diffs_64, 1), 0, 0, 0 + }); +} + +#define _mm_sub_epi8(a, b) (vreinterpretq_s8_u8(vsubq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) +#define _mm_sub_epi16(a, b) (vreinterpretq_s8_u16(vsubq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) +#define _mm_sub_epi32(a, b) (vreinterpretq_s8_u32(vsubq_u32(vreinterpretq_u32_s8(a), vreinterpretq_u32_s8(b)))) +#define _mm_sub_epi64(a, b) (vreinterpretq_s8_u64(vsubq_u64(vreinterpretq_u64_s8(a), vreinterpretq_u64_s8(b)))) + +#define _mm_subs_epi8(a, b) (vqsubq_s8((a), (b))) +#define _mm_subs_epi16(a, b) (vreinterpretq_s8_s16(vqsubq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_subs_epu8(a, b) (vreinterpretq_s8_u8(vqsubq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))) +#define _mm_subs_epu16(a, b) (vreinterpretq_s8_u16(vqsubq_u16(vreinterpretq_u16_s8(a), vreinterpretq_u16_s8(b)))) + + +/***************************************************************************** + * Comparison * + *****************************************************************************/ + +#define _mm_cmpeq_epi8(a, b) (vreinterpretq_s8_u8(vceqq_s8((a), (b)))) +#define _mm_cmpeq_epi16(a, b) (vreinterpretq_s8_u16(vceqq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_cmpeq_epi32(a, b) (vreinterpretq_s8_u32(vceqq_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) + +#define _mm_cmplt_epi8(a, b) (vreinterpretq_s8_u8(vcltq_s8((a), (b)))) +#define _mm_cmplt_epi16(a, b) (vreinterpretq_s8_u16(vcltq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_cmplt_epi32(a, b) (vreinterpretq_s8_u32(vcltq_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) + +#define _mm_cmpgt_epi8(a, b) (vreinterpretq_s8_u8(vcgtq_s8((a), (b)))) +#define _mm_cmpgt_epi16(a, b) (vreinterpretq_s8_u16(vcgtq_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_cmpgt_epi32(a, b) (vreinterpretq_s8_u32(vcgtq_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) + + +/***************************************************************************** + * Convert * + *****************************************************************************/ + +#define _mm_cvtsi32_si128(x) (vreinterpretq_s8_s32((int32x4_t) { (int32_t) (x), 0, 0, 0 })) +#define _mm_cvtsi64_si128(x) (vreinterpretq_s8_s64((int64x2_t) { (int64_t) (x), 0 })) +#define _mm_cvtsi128_si32(x) (vgetq_lane_s32(vreinterpretq_s32_s8(x), 0)) +#define _mm_cvtsi128_si64(x) (vgetq_lane_s64(vreinterpretq_s64_s8(x), 0)) + + +/***************************************************************************** + * Others * + *****************************************************************************/ + +#define _mm_packs_epi16(a, b) (vcombine_s8(vqmovn_s16(vreinterpretq_s16_s8(a)), vqmovn_s16(vreinterpretq_s16_s8(b)))) +#define _mm_packs_epi32(a, b) \ + (vreinterpretq_s8_s16(vcombine_s16(vqmovn_s32(vreinterpretq_s32_s8(a)), vqmovn_s32(vreinterpretq_s32_s8(b))))) +#define _mm_packus_epi16(a, b) \ + (vreinterpretq_s8_u8(vcombine_u8(vqmovun_s16(vreinterpretq_s16_s8(a)), vqmovun_s16(vreinterpretq_s16_s8(b))))) + +#define _mm_extract_epi16(x, imm) (vgetq_lane_s16(vreinterpretq_s16_s8(x), (imm))) +#define _mm_insert_epi16(x, val, imm) (vreinterpretq_s8_s16(vsetq_lane_s16((int16_t) (val), vreinterpretq_s16_s8(x), (imm)))) + +static XSSE_FORCE_INLINE int _mm_movemask_epi8(__m128i x) +{ + /** + * based on code from + * https://community.arm.com/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/porting-x86-vector-bitmask-optimizations-to-arm-neon + */ + uint16x8_t high_bits = vreinterpretq_u16_u8(vshrq_n_u8(vreinterpretq_u8_s8(x), 7)); + uint32x4_t paired16 = vreinterpretq_u32_u16(vsraq_n_u16(high_bits, high_bits, 7)); + uint64x2_t paired32 = vreinterpretq_u64_u32(vsraq_n_u32(paired16, paired16, 14)); + uint8x16_t paired64 = vreinterpretq_u8_u64(vsraq_n_u64(paired32, paired32, 28)); + return vgetq_lane_u8(paired64, 0) | ((int) vgetq_lane_u8(paired64, 8) << 8); +} + +#define _MM_SHUFFLE(a, b, c, d) (((a) << 6) | ((b) << 4) | ((c) << 2) | (d)) +#ifdef XSSE_HAS_MACRO_EXTENSION +#define _mm_shuffle_epi32(x, imm) __extension__({ \ + int32x4_t __xsse_tmp = vreinterpretq_s32_s8(x); \ + vreinterpretq_s8_s32((int32x4_t) { \ + (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 0) & 0x3), \ + (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 2) & 0x3), \ + (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 4) & 0x3), \ + (int32_t) vgetq_lane_s32(__xsse_tmp, ((imm) >> 6) & 0x3) \ + }); \ + }) +#define _mm_shufflehi_epi16(x, imm) __extension__({ \ + int16x8_t __xsse_tmp = vreinterpretq_s16_s8(x); \ + vreinterpretq_s8_s16(vcombine_s16( \ + vget_low_s16(__xsse_tmp), \ + (int16x4_t) { \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 0) & 0x3) + 4), \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 2) & 0x3) + 4), \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 4) & 0x3) + 4), \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 6) & 0x3) + 4) \ + } \ + )); \ + }) +#define _mm_shufflelo_epi16(x, imm) __extension__({ \ + int16x8_t __xsse_tmp = vreinterpretq_s16_s8(x); \ + vreinterpretq_s8_s16(vcombine_s16( \ + (int16x4_t) { \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 0) & 0x3)), \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 2) & 0x3)), \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 4) & 0x3)), \ + (int16_t) vgetq_lane_s16(__xsse_tmp, (((imm) >> 6) & 0x3)) \ + }, \ + vget_high_s16(__xsse_tmp) \ + )); \ + }) +#else +static XSSE_FORCE_INLINE __m128i _mm_shuffle_epi32(__m128i x, int imm) +{ + int32x4_t vec = vreinterpretq_s32_s8(x); + int32_t arr[4]; + vst1q_s32(arr, vec); + + return vreinterpretq_s8_s32((int32x4_t) { + arr[(imm >> 0) & 0x3], + arr[(imm >> 2) & 0x3], + arr[(imm >> 4) & 0x3], + arr[(imm >> 6) & 0x3] + }); +} +static XSSE_FORCE_INLINE __m128i _mm_shufflehi_epi16(__m128i x, int imm) +{ + int16x8_t vec = vreinterpretq_s16_s8(x); + int16_t arr[8]; + vst1q_s16(arr, vec); + + return vreinterpretq_s8_s16((int16x8_t) { + arr[0], arr[1], arr[2], arr[3], + arr[((imm >> 0) & 0x3) + 4], + arr[((imm >> 2) & 0x3) + 4], + arr[((imm >> 4) & 0x3) + 4], + arr[((imm >> 6) & 0x3) + 4] + }); +} +static XSSE_FORCE_INLINE __m128i _mm_shufflelo_epi16(__m128i x, int imm) +{ + int16x8_t vec = vreinterpretq_s16_s8(x); + int16_t arr[8]; + vst1q_s16(arr, vec); + + return vreinterpretq_s8_s16((int16x8_t) { + arr[((imm >> 0) & 0x3)], + arr[((imm >> 2) & 0x3)], + arr[((imm >> 4) & 0x3)], + arr[((imm >> 6) & 0x3)], + arr[4], arr[5], arr[6], arr[7] + }); +} +#endif + +#define _mm_unpackhi_epi8(a, b) (vzip2q_s8((a), (b))) +#define _mm_unpackhi_epi16(a, b) (vreinterpretq_s8_s16(vzip2q_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_unpackhi_epi32(a, b) (vreinterpretq_s8_s32(vzip2q_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) +#define _mm_unpackhi_epi64(a, b) (vreinterpretq_s8_s64(vzip2q_s64(vreinterpretq_s64_s8(a), vreinterpretq_s64_s8(b)))) + +#define _mm_unpacklo_epi8(a, b) (vzip1q_s8((a), (b))) +#define _mm_unpacklo_epi16(a, b) (vreinterpretq_s8_s16(vzip1q_s16(vreinterpretq_s16_s8(a), vreinterpretq_s16_s8(b)))) +#define _mm_unpacklo_epi32(a, b) (vreinterpretq_s8_s32(vzip1q_s32(vreinterpretq_s32_s8(a), vreinterpretq_s32_s8(b)))) +#define _mm_unpacklo_epi64(a, b) (vreinterpretq_s8_s64(vzip1q_s64(vreinterpretq_s64_s8(a), vreinterpretq_s64_s8(b)))) + +#define _mm_move_epi64(x) (vreinterpretq_s8_s64((int64x2_t) { vgetq_lane_s64(vreinterpretq_s64_s8(x), 0), 0 })) + +#endif + +#endif /* XSSE_H */ diff --git a/Zend/zend_smart_str.c b/Zend/zend_smart_str.c index 501f6e6176c8b..c779ee5c97cab 100644 --- a/Zend/zend_smart_str.c +++ b/Zend/zend_smart_str.c @@ -208,8 +208,11 @@ ZEND_API void ZEND_FASTCALL smart_str_append_scalar(smart_str *dest, const zval break; case IS_TRUE: + smart_str_appendl(dest, "true", sizeof("true")-1); + break; + case IS_FALSE: - smart_str_appends(dest, Z_TYPE_P(value) == IS_TRUE ? "true" : "false"); + smart_str_appendl(dest, "false", sizeof("false")-1); break; case IS_DOUBLE: diff --git a/Zend/zend_string.c b/Zend/zend_string.c index 7291672b6b8d7..ad4b9d2d6cde1 100644 --- a/Zend/zend_string.c +++ b/Zend/zend_string.c @@ -94,7 +94,7 @@ ZEND_API void zend_interned_strings_init(void) zend_empty_string = NULL; zend_known_strings = NULL; - zend_init_interned_strings_ht(&interned_strings_permanent, 1); + zend_init_interned_strings_ht(&interned_strings_permanent, true); zend_new_interned_string = zend_new_interned_string_permanent; zend_string_init_interned = zend_string_init_interned_permanent; @@ -345,7 +345,7 @@ static zend_string* ZEND_FASTCALL zend_string_init_existing_interned_request(con ZEND_API void zend_interned_strings_activate(void) { - zend_init_interned_strings_ht(&CG(interned_strings), 0); + zend_init_interned_strings_ht(&CG(interned_strings), false); } ZEND_API void zend_interned_strings_deactivate(void) diff --git a/Zend/zend_string.h b/Zend/zend_string.h index 87f221125202c..fc7705ff78650 100644 --- a/Zend/zend_string.h +++ b/Zend/zend_string.h @@ -123,7 +123,7 @@ END_EXTERN_C() #define ZSTR_ALLOCA_FREE(str, use_heap) free_alloca(str, use_heap) -#define ZSTR_INIT_LITERAL(s, persistent) (zend_string_init((s), strlen(s), (persistent))) +#define ZSTR_INIT_LITERAL(s, persistent) (zend_string_init(("" s), sizeof(s) - 1, (persistent))) /*---*/ @@ -402,7 +402,7 @@ static zend_always_inline bool zend_string_starts_with(const zend_string *str, c } #define zend_string_starts_with_literal(str, prefix) \ - zend_string_starts_with_cstr(str, prefix, strlen(prefix)) + zend_string_starts_with_cstr(str, "" prefix, sizeof(prefix) - 1) static zend_always_inline bool zend_string_starts_with_cstr_ci(const zend_string *str, const char *prefix, size_t prefix_length) { @@ -415,7 +415,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_ci(str, prefix, strlen(prefix)) + zend_string_starts_with_cstr_ci(str, "" prefix, sizeof(prefix) - 1) /* * DJBX33A (Daniel J. Bernstein, Times 33 with Addition) diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index 88b905ffeab40..f0a15a2f4f479 100644 --- a/Zend/zend_strtod.c +++ b/Zend/zend_strtod.c @@ -4535,10 +4535,10 @@ ZEND_API char *zend_gcvt(double value, int ndigit, char dec_point, char exponent if ((decpt >= 0 && decpt > ndigit) || decpt < -3) { /* use E-style */ /* exponential format (e.g. 1.2345e+13) */ if (--decpt < 0) { - sign = 1; + sign = true; decpt = -decpt; } else { - sign = 0; + sign = false; } src = digits; *dst++ = *src++; diff --git a/Zend/zend_types.h b/Zend/zend_types.h index a3d3e4da6362d..43aa2aa86a00e 100644 --- a/Zend/zend_types.h +++ b/Zend/zend_types.h @@ -62,19 +62,8 @@ typedef enum { typedef ZEND_RESULT_CODE zend_result; -#ifdef ZEND_ENABLE_ZVAL_LONG64 -# ifdef ZEND_WIN32 -# define ZEND_SIZE_MAX _UI64_MAX -# else -# define ZEND_SIZE_MAX SIZE_MAX -# endif -#else -# if defined(ZEND_WIN32) -# define ZEND_SIZE_MAX _UI32_MAX -# else -# define ZEND_SIZE_MAX SIZE_MAX -# endif -#endif +/* This constant is deprecated, use SIZE_MAX instead */ +#define ZEND_SIZE_MAX SIZE_MAX #ifdef ZTS #define ZEND_TLS static TSRM_TLS diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h index 1cb745ca1b1dc..d90ad9951782a 100644 --- a/Zend/zend_variables.h +++ b/Zend/zend_variables.h @@ -81,9 +81,6 @@ ZEND_API void zval_ptr_dtor(zval *zval_ptr); ZEND_API void zval_ptr_safe_dtor(zval *zval_ptr); ZEND_API void zval_internal_ptr_dtor(zval *zvalue); -/* Kept for compatibility */ -#define zval_dtor(zvalue) zval_ptr_dtor_nogc(zvalue) - ZEND_API void zval_add_ref(zval *p); END_EXTERN_C() diff --git a/Zend/zend_virtual_cwd.c b/Zend/zend_virtual_cwd.c index 366e13ce9b6ba..a9fbd5667cb8d 100644 --- a/Zend/zend_virtual_cwd.c +++ b/Zend/zend_virtual_cwd.c @@ -524,18 +524,18 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim (i + 1 == len && path[i] == '.')) { /* remove double slashes and '.' */ len = EXPECTED(i > 0) ? i - 1 : 0; - is_dir = 1; + is_dir = true; continue; } else if (i + 2 == len && path[i] == '.' && path[i+1] == '.') { /* remove '..' and previous directory */ - is_dir = 1; + is_dir = true; if (link_is_dir) { *link_is_dir = 1; } if (i <= start + 1) { return start ? start : len; } - j = tsrm_realpath_r(path, start, i-1, ll, t, use_realpath, 1, NULL); + j = tsrm_realpath_r(path, start, i-1, ll, t, use_realpath, true, NULL); if (j > start && j != (size_t)-1) { j--; assert(i < MAXPATHLEN); @@ -948,7 +948,8 @@ static size_t tsrm_realpath_r(char *path, size_t start, size_t len, int *ll, tim j = start; } else { /* some leading directories may be inaccessible */ - j = tsrm_realpath_r(path, start, i-1, ll, t, save ? CWD_FILEPATH : use_realpath, 1, NULL); + j = tsrm_realpath_r(path, start, i-1, ll, t, save ? CWD_FILEPATH : use_realpath, true, + NULL); if (j > start && j != (size_t)-1) { path[j++] = DEFAULT_SLASH; } @@ -1138,7 +1139,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func add_slash = (use_realpath != CWD_REALPATH) && path_length > 0 && IS_SLASH(resolved_path[path_length-1]); t = CWDG(realpath_cache_ttl) ? 0 : -1; - path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, 0, NULL); + path_length = tsrm_realpath_r(resolved_path, start, path_length, &ll, &t, use_realpath, false, NULL); if (path_length == (size_t)-1) { #ifdef ZEND_WIN32 diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 90247b3c87b71..1b91f11662c7a 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -8020,7 +8020,7 @@ ZEND_VM_HANDLER(105, ZEND_TICKS, ANY, ANY, NUM) { USE_OPLINE - if ((uint32_t)++EG(ticks_count) >= opline->extended_value) { + if (++EG(ticks_count) >= opline->extended_value) { EG(ticks_count) = 0; if (zend_ticks_function) { SAVE_OPLINE(); @@ -8179,7 +8179,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) } uint32_t throw_op_num = throw_op - EX(func)->op_array.opcodes; - int i, current_try_catch_offset = -1; + uint32_t current_try_catch_offset = -1; if ((throw_op->opcode == ZEND_FREE || throw_op->opcode == ZEND_FE_FREE) && throw_op->extended_value & ZEND_FREE_ON_RETURN) { @@ -8190,7 +8190,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) const zend_live_range *range = find_live_range( &EX(func)->op_array, throw_op_num, throw_op->op1.var); /* free op1 of the corresponding RETURN */ - for (i = throw_op_num; i < range->end; i++) { + for (uint32_t i = throw_op_num; i < range->end; i++) { if (EX(func)->op_array.opcodes[i].opcode == ZEND_FREE || EX(func)->op_array.opcodes[i].opcode == ZEND_FE_FREE) { /* pass */ @@ -8206,7 +8206,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY) } /* Find the innermost try/catch/finally the exception was thrown in */ - for (i = 0; i < EX(func)->op_array.last_try_catch; i++) { + for (uint32_t i = 0; i < EX(func)->op_array.last_try_catch; i++) { zend_try_catch_element *try_catch = &EX(func)->op_array.try_catch_array[i]; if (try_catch->try_op > throw_op_num) { /* further blocks will not be relevant... */ @@ -9724,12 +9724,32 @@ ZEND_VM_HANDLER(167, ZEND_COPY_TMP, TMPVAR, UNUSED) ZEND_VM_NEXT_OPCODE(); } -ZEND_VM_HANDLER(202, ZEND_CALLABLE_CONVERT, UNUSED, UNUSED) +ZEND_VM_HANDLER(202, ZEND_CALLABLE_CONVERT, UNUSED, UNUSED, NUM|CACHE_SLOT) { USE_OPLINE zend_execute_data *call = EX(call); - zend_closure_from_frame(EX_VAR(opline->result.var), call); + if (opline->extended_value != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(opline->extended_value); + if (closure) { + ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); + } else { + /* Rotate the key for better hash distribution. */ + const int shift = sizeof(size_t) == 4 ? 6 : 7; + zend_ulong key = (zend_ulong)(uintptr_t)call->func; + key = (key >> shift) | (key << ((sizeof(key) * 8) - shift)); + zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), key); + if (Z_TYPE_P(closure_zv) == IS_NULL) { + zend_closure_from_frame(closure_zv, call); + } + ZEND_ASSERT(Z_TYPE_P(closure_zv) == IS_OBJECT); + closure = Z_OBJ_P(closure_zv); + ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); + CACHE_PTR(opline->extended_value, closure); + } + } else { + zend_closure_from_frame(EX_VAR(opline->result.var), call); + } if (ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS) { OBJ_RELEASE(Z_OBJ(call->This)); @@ -9780,7 +9800,7 @@ ZEND_VM_HANDLER(204, ZEND_FRAMELESS_ICALL_0, UNUSED, UNUSED, SPEC(OBSERVER)) #endif { zend_frameless_function_0 function = (zend_frameless_function_0)ZEND_FLF_HANDLER(opline); - function(EX_VAR(opline->result.var)); + function(result); } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 810c2c7ef85ca..801bf0ee69e0d 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3278,7 +3278,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_TICKS_SPEC_HA { USE_OPLINE - if ((uint32_t)++EG(ticks_count) >= opline->extended_value) { + if (++EG(ticks_count) >= opline->extended_value) { EG(ticks_count) = 0; if (zend_ticks_function) { SAVE_OPLINE(); @@ -3392,7 +3392,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_HANDLE_EXCEPT } uint32_t throw_op_num = throw_op - EX(func)->op_array.opcodes; - int i, current_try_catch_offset = -1; + uint32_t current_try_catch_offset = -1; if ((throw_op->opcode == ZEND_FREE || throw_op->opcode == ZEND_FE_FREE) && throw_op->extended_value & ZEND_FREE_ON_RETURN) { @@ -3403,7 +3403,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_HANDLE_EXCEPT const zend_live_range *range = find_live_range( &EX(func)->op_array, throw_op_num, throw_op->op1.var); /* free op1 of the corresponding RETURN */ - for (i = throw_op_num; i < range->end; i++) { + for (uint32_t i = throw_op_num; i < range->end; i++) { if (EX(func)->op_array.opcodes[i].opcode == ZEND_FREE || EX(func)->op_array.opcodes[i].opcode == ZEND_FE_FREE) { /* pass */ @@ -3419,7 +3419,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_HANDLE_EXCEPT } /* Find the innermost try/catch/finally the exception was thrown in */ - for (i = 0; i < EX(func)->op_array.last_try_catch; i++) { + for (uint32_t i = 0; i < EX(func)->op_array.last_try_catch; i++) { zend_try_catch_element *try_catch = &EX(func)->op_array.try_catch_array[i]; if (try_catch->try_op > throw_op_num) { /* further blocks will not be relevant... */ @@ -39256,7 +39256,27 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_CALLABLE_CONV USE_OPLINE zend_execute_data *call = EX(call); - zend_closure_from_frame(EX_VAR(opline->result.var), call); + if (opline->extended_value != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(opline->extended_value); + if (closure) { + ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); + } else { + /* Rotate the key for better hash distribution. */ + const int shift = sizeof(size_t) == 4 ? 6 : 7; + zend_ulong key = (zend_ulong)(uintptr_t)call->func; + key = (key >> shift) | (key << ((sizeof(key) * 8) - shift)); + zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), key); + if (Z_TYPE_P(closure_zv) == IS_NULL) { + zend_closure_from_frame(closure_zv, call); + } + ZEND_ASSERT(Z_TYPE_P(closure_zv) == IS_OBJECT); + closure = Z_OBJ_P(closure_zv); + ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); + CACHE_PTR(opline->extended_value, closure); + } + } else { + zend_closure_from_frame(EX_VAR(opline->result.var), call); + } if (ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS) { OBJ_RELEASE(Z_OBJ(call->This)); @@ -39284,7 +39304,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_FRAMELESS_ICA #endif { zend_frameless_function_0 function = (zend_frameless_function_0)ZEND_FLF_HANDLER(opline); - function(EX_VAR(opline->result.var)); + function(result); } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -39304,7 +39324,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV ZEND_FRAMELESS_ICA #endif { zend_frameless_function_0 function = (zend_frameless_function_0)ZEND_FLF_HANDLER(opline); - function(EX_VAR(opline->result.var)); + function(result); } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -59002,7 +59022,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_TICKS_SPEC_TAILCAL { USE_OPLINE - if ((uint32_t)++EG(ticks_count) >= opline->extended_value) { + if (++EG(ticks_count) >= opline->extended_value) { EG(ticks_count) = 0; if (zend_ticks_function) { SAVE_OPLINE(); @@ -59040,7 +59060,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_HANDLE_EXCEPTION_S } uint32_t throw_op_num = throw_op - EX(func)->op_array.opcodes; - int i, current_try_catch_offset = -1; + uint32_t current_try_catch_offset = -1; if ((throw_op->opcode == ZEND_FREE || throw_op->opcode == ZEND_FE_FREE) && throw_op->extended_value & ZEND_FREE_ON_RETURN) { @@ -59051,7 +59071,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_HANDLE_EXCEPTION_S const zend_live_range *range = find_live_range( &EX(func)->op_array, throw_op_num, throw_op->op1.var); /* free op1 of the corresponding RETURN */ - for (i = throw_op_num; i < range->end; i++) { + for (uint32_t i = throw_op_num; i < range->end; i++) { if (EX(func)->op_array.opcodes[i].opcode == ZEND_FREE || EX(func)->op_array.opcodes[i].opcode == ZEND_FE_FREE) { /* pass */ @@ -59067,7 +59087,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_HANDLE_EXCEPTION_S } /* Find the innermost try/catch/finally the exception was thrown in */ - for (i = 0; i < EX(func)->op_array.last_try_catch; i++) { + for (uint32_t i = 0; i < EX(func)->op_array.last_try_catch; i++) { zend_try_catch_element *try_catch = &EX(func)->op_array.try_catch_array[i]; if (try_catch->try_op > throw_op_num) { /* further blocks will not be relevant... */ @@ -94702,7 +94722,27 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_CALLABLE_CONVERT_S USE_OPLINE zend_execute_data *call = EX(call); - zend_closure_from_frame(EX_VAR(opline->result.var), call); + if (opline->extended_value != (uint32_t)-1) { + zend_object *closure = CACHED_PTR(opline->extended_value); + if (closure) { + ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); + } else { + /* Rotate the key for better hash distribution. */ + const int shift = sizeof(size_t) == 4 ? 6 : 7; + zend_ulong key = (zend_ulong)(uintptr_t)call->func; + key = (key >> shift) | (key << ((sizeof(key) * 8) - shift)); + zval *closure_zv = zend_hash_index_lookup(&EG(callable_convert_cache), key); + if (Z_TYPE_P(closure_zv) == IS_NULL) { + zend_closure_from_frame(closure_zv, call); + } + ZEND_ASSERT(Z_TYPE_P(closure_zv) == IS_OBJECT); + closure = Z_OBJ_P(closure_zv); + ZVAL_OBJ_COPY(EX_VAR(opline->result.var), closure); + CACHE_PTR(opline->extended_value, closure); + } + } else { + zend_closure_from_frame(EX_VAR(opline->result.var), call); + } if (ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS) { OBJ_RELEASE(Z_OBJ(call->This)); @@ -94730,7 +94770,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_FRAMELESS_ICALL_0_ #endif { zend_frameless_function_0 function = (zend_frameless_function_0)ZEND_FLF_HANDLER(opline); - function(EX_VAR(opline->result.var)); + function(result); } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } @@ -94750,7 +94790,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV ZEND_FRAMELESS_ICALL_0_ #endif { zend_frameless_function_0 function = (zend_frameless_function_0)ZEND_FLF_HANDLER(opline); - function(EX_VAR(opline->result.var)); + function(result); } ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION(); } diff --git a/Zend/zend_vm_opcodes.c b/Zend/zend_vm_opcodes.c index 00ad38baaafeb..936a96e55e41f 100644 --- a/Zend/zend_vm_opcodes.c +++ b/Zend/zend_vm_opcodes.c @@ -439,7 +439,7 @@ static uint32_t zend_vm_opcodes_flags[211] = { 0x00000101, 0x00000101, 0x00000101, - 0x00000101, + 0x01040101, 0x00002001, 0x00000101, 0x00000100, diff --git a/Zend/zend_weakrefs.c b/Zend/zend_weakrefs.c index 5698642a8c0dd..8c1263885bf6c 100644 --- a/Zend/zend_weakrefs.c +++ b/Zend/zend_weakrefs.c @@ -181,7 +181,7 @@ ZEND_API zval *zend_weakrefs_hash_add(HashTable *ht, zend_object *key, zval *pDa ZEND_API zend_result zend_weakrefs_hash_del(HashTable *ht, zend_object *key) { zval *zv = zend_hash_index_find(ht, zend_object_to_weakref_key(key)); if (zv) { - zend_weakref_unregister(key, ZEND_WEAKREF_ENCODE(ht, ZEND_WEAKREF_TAG_BARE_HT), 1); + zend_weakref_unregister(key, ZEND_WEAKREF_ENCODE(ht, ZEND_WEAKREF_TAG_BARE_HT), true); return SUCCESS; } return FAILURE; @@ -194,7 +194,7 @@ static void zend_weakrefs_hash_clean_ex(HashTable *ht, int type) { * Let freeing the corresponding values for WeakMap entries be done in zend_hash_clean, freeing objects sequentially. * The performance difference is notable for larger WeakMaps with worse cache locality. */ zend_weakref_unregister( - zend_weakref_key_to_object(obj_key), ZEND_WEAKREF_ENCODE(ht, type), 0); + zend_weakref_key_to_object(obj_key), ZEND_WEAKREF_ENCODE(ht, type), false); } ZEND_HASH_FOREACH_END(); zend_hash_clean(ht); } @@ -237,7 +237,7 @@ static zend_object* zend_weakref_new(zend_class_entry *ce) { static zend_always_inline bool zend_weakref_find(zend_object *referent, zval *return_value) { void *tagged_ptr = zend_hash_index_find_ptr(&EG(weakrefs), zend_object_to_weakref_key(referent)); if (!tagged_ptr) { - return 0; + return false; } void *ptr = ZEND_WEAKREF_GET_PTR(tagged_ptr); @@ -247,7 +247,7 @@ static zend_always_inline bool zend_weakref_find(zend_object *referent, zval *re found_weakref: wr = ptr; RETVAL_OBJ_COPY(&wr->std); - return 1; + return true; } if (tag == ZEND_WEAKREF_TAG_HT) { @@ -259,7 +259,7 @@ static zend_always_inline bool zend_weakref_find(zend_object *referent, zval *re } ZEND_HASH_FOREACH_END(); } - return 0; + return false; } static zend_always_inline void zend_weakref_create(zend_object *referent, zval *return_value) { @@ -285,7 +285,7 @@ static void zend_weakref_free(zend_object *zo) { zend_weakref *wr = zend_weakref_from(zo); if (wr->referent) { - zend_weakref_unregister(wr->referent, ZEND_WEAKREF_ENCODE(wr, ZEND_WEAKREF_TAG_REF), 1); + zend_weakref_unregister(wr->referent, ZEND_WEAKREF_ENCODE(wr, ZEND_WEAKREF_TAG_REF), true); } zend_object_std_dtor(&wr->std); @@ -370,18 +370,25 @@ static zval *zend_weakmap_read_dimension(zend_object *object, zval *offset, int zend_weakmap *wm = zend_weakmap_from(object); zend_object *obj_addr = Z_OBJ_P(offset); zval *zv = zend_hash_index_find(&wm->ht, zend_object_to_weakref_key(obj_addr)); - if (zv == NULL) { - if (type != BP_VAR_IS) { - zend_throw_error(NULL, - "Object %s#%d not contained in WeakMap", ZSTR_VAL(obj_addr->ce->name), obj_addr->handle); + if (type == BP_VAR_W || type == BP_VAR_RW) { + if (zv == NULL) { + zval value; + zend_weakref_register(obj_addr, ZEND_WEAKREF_ENCODE(&wm->ht, ZEND_WEAKREF_TAG_MAP)); + ZVAL_NULL(&value); + zv = zend_hash_index_add_new(&wm->ht, zend_object_to_weakref_key(obj_addr), &value); + } + ZVAL_MAKE_REF(zv); + } else { + if (zv == NULL) { + if (type != BP_VAR_IS) { + zend_throw_error(NULL, + "Object %s#%d not contained in WeakMap", ZSTR_VAL(obj_addr->ce->name), obj_addr->handle); + return NULL; + } return NULL; } - return NULL; } - if (type == BP_VAR_W || type == BP_VAR_RW) { - ZVAL_MAKE_REF(zv); - } return zv; } @@ -455,7 +462,7 @@ static void zend_weakmap_unset_dimension(zend_object *object, zval *offset) return; } - zend_weakref_unregister(obj_addr, ZEND_WEAKREF_ENCODE(&wm->ht, ZEND_WEAKREF_TAG_MAP), 1); + zend_weakref_unregister(obj_addr, ZEND_WEAKREF_ENCODE(&wm->ht, ZEND_WEAKREF_TAG_MAP), true); } static zend_result zend_weakmap_count_elements(zend_object *object, zend_long *count) @@ -769,9 +776,7 @@ ZEND_METHOD(WeakMap, offsetUnset) ZEND_METHOD(WeakMap, count) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_long count; zend_weakmap_count_elements(Z_OBJ_P(ZEND_THIS), &count); @@ -780,9 +785,7 @@ ZEND_METHOD(WeakMap, count) ZEND_METHOD(WeakMap, getIterator) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_create_internal_iterator_zval(return_value, ZEND_THIS); } diff --git a/build/gen_stub.php b/build/gen_stub.php index 8495f3612ce54..e5fbe4867525c 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -2801,7 +2801,7 @@ private function getClassConstDeclaration(EvaluatedValue $value, array $allConst $code = "\n" . $zvalCode; - $code .= "\tzend_string *const_{$constName}_name = zend_string_init_interned(\"$constName\", sizeof(\"$constName\") - 1, 1);\n"; + $code .= "\tzend_string *const_{$constName}_name = zend_string_init_interned(\"$constName\", sizeof(\"$constName\") - 1, true);\n"; $nameCode = "const_{$constName}_name"; if ($this->exposedDocComment) { @@ -2855,7 +2855,7 @@ private function getClassConstDeclaration(EvaluatedValue $value, array $allConst $code .= "#endif\n"; } - $code .= "\tzend_string_release(const_{$constName}_name);\n"; + $code .= "\tzend_string_release_ex(const_{$constName}_name, true);\n"; return $code; } @@ -3058,13 +3058,13 @@ public static function getString( // Generally strings will not be known $initFn = $interned ? 'zend_string_init_interned' : 'zend_string_init'; $result = [ - "\tzend_string *$varName = $initFn(\"$content\", sizeof(\"$content\") - 1, 1);\n", + "\tzend_string *$varName = $initFn(\"$content\", sizeof(\"$content\") - 1, true);\n", $varName, - "\tzend_string_release($varName);\n" + "\tzend_string_release_ex($varName, true);\n" ]; // For attribute values that are not freed if ($varName === '') { - $result[0] = "$initFn(\"$content\", sizeof(\"$content\") - 1, 1);\n"; + $result[0] = "$initFn(\"$content\", sizeof(\"$content\") - 1, true);\n"; } // If not set, use the current latest version $allVersions = ALL_PHP_VERSION_IDS; @@ -6048,9 +6048,10 @@ function installPhpParser(string $version, string $phpParserDir) { chdir(__DIR__); $tarName = "v$version.tar.gz"; - passthru("wget https://github.com/nikic/PHP-Parser/archive/$tarName", $exit); + $downloadUrl = "https://github.com/nikic/PHP-Parser/archive/$tarName"; + passthru("wget -O $tarName $downloadUrl", $exit); if ($exit !== 0) { - passthru("curl -LO https://github.com/nikic/PHP-Parser/archive/$tarName", $exit); + passthru("curl -LO $downloadUrl", $exit); } if ($exit !== 0) { throw new Exception("Failed to download PHP-Parser tarball"); @@ -6060,6 +6061,7 @@ function installPhpParser(string $version, string $phpParserDir) { } passthru("tar xvzf $tarName -C PHP-Parser-$version --strip-components 1", $exit); if ($exit !== 0) { + rmdir($phpParserDir); throw new Exception("Failed to extract PHP-Parser tarball"); } unlink(__DIR__ . "/$tarName"); diff --git a/configure.ac b/configure.ac index f81d8cf609054..77fc8c89cdf40 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ dnl Basic autoconf initialization, generation of config.nice. dnl ---------------------------------------------------------------------------- AC_PREREQ([2.68]) -AC_INIT([PHP],[8.5.1-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net]) +AC_INIT([PHP],[8.6.0-dev],[https://github.com/php/php-src/issues],[php],[https://www.php.net]) AC_CONFIG_SRCDIR([main/php_version.h]) AC_CONFIG_AUX_DIR([build]) AC_PRESERVE_HELP_ORDER diff --git a/docs/release-process.md b/docs/release-process.md index 08b95df53513f..e053728feb0aa 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -169,10 +169,10 @@ slightly different steps. We'll call attention where the steps differ. 4. Using your local-only release branch, bump the version numbers in `main/php_version.h`, `Zend/zend.h`, `configure.ac`, and possibly `NEWS`. - + The date for NEWS should be the date of the announcement (Thursday), *not* the date of the tagging (Tuesday). - + For examples, see [Update versions for PHP 8.1.0beta3][] (for a pre-GA example) or [Update versions for PHP 8.1.6RC1][] along with [Update NEWS for PHP 8.1.6RC1][] (for a post-GA example). @@ -506,8 +506,8 @@ slightly different steps. We'll call attention where the steps differ. You can send a PR to [toot-together](https://github.com/derickr/toot-together/) with highlights from the NEWS file yourself, if you want. - * [Annonce 8.5.0alpha1](https://github.com/derickr/toot-together/pull/42) - * [Annonce 8.5.0alpha2](https://github.com/derickr/toot-together/pull/47) + * [Announce 8.5.0alpha1](https://github.com/derickr/toot-together/pull/42) + * [Announce 8.5.0alpha2](https://github.com/derickr/toot-together/pull/47) We post to [@php@fosstodon.org](https://fosstodon.org/@php). diff --git a/docs/source/miscellaneous/stubs.rst b/docs/source/miscellaneous/stubs.rst index 616d306895542..395034afe8d5d 100644 --- a/docs/source/miscellaneous/stubs.rst +++ b/docs/source/miscellaneous/stubs.rst @@ -489,7 +489,7 @@ generated. You can include this file conditionally, such as: #endif When ``@generate-legacy-arginfo`` is passed the minimum PHP version ID that needs to be supported, -then only one arginfo file is going to be generated, and ``#if`` prepocessor directives will ensure +then only one arginfo file is going to be generated, and ``#if`` preprocessor directives will ensure compatibility with all the required PHP 8 versions. PHP Version IDs are as follows: ``80000`` for PHP 8.0, ``80100`` for PHP PHP 8.1, ``80200`` for PHP diff --git a/docs/source/miscellaneous/writing-tests.rst b/docs/source/miscellaneous/writing-tests.rst index fd09d80f1275e..4c46dad638b6c 100644 --- a/docs/source/miscellaneous/writing-tests.rst +++ b/docs/source/miscellaneous/writing-tests.rst @@ -132,7 +132,7 @@ below illustrates a minimal test. string(32) "# hello All, I sAid hi planet! #" As you can see the file is divided into several sections. The TEST section holds a one line title of -the phpt test, this should be a simple description and shouldn't ever excede one line, if you need +the phpt test, this should be a simple description and shouldn't ever exceed one line, if you need to write more explanation add comments in the body of the test case. The phpt files name is used when generating a .php file. The FILE section is used as the body of the .php file, so don't forget to open and close your php tags. The EXPECT section is the part used as a comparison to see if the @@ -580,7 +580,7 @@ Example 1 (snippet): .. code:: text --DESCRIPTION-- - This test covers both valid and invalid usages of filter_input() with INPUT_GET and INPUT_POST data and several differnet filter sanitizers. + This test covers both valid and invalid usages of filter_input() with INPUT_GET and INPUT_POST data and several different filter sanitizers. Example 1 (full): :ref:`sample001.phpt` @@ -1310,7 +1310,7 @@ Example 1 (full): :ref:`sample017.phpt` ``--FLAKY--`` ------------- -**Description:** This section identifies this test as one that occassionally fails. If the test +**Description:** This section identifies this test as one that occasionally fails. If the test actually fails, it will be retried one more time, and that result will be reported. The section should include a brief description of why the test is flaky. Reasons for this include tests that rely on relatively precise timing, or temporary disc states. Available as of PHP 8.1.22 and 8.2.9, @@ -1884,7 +1884,7 @@ sample001.phpt --DESCRIPTION-- This test covers both valid and invalid usages of filter_input() with INPUT_GET and INPUT_POST data - and several differnt filter sanitizers. + and several different filter sanitizers. --CREDITS-- Felipe Pena --INI-- diff --git a/ext/bcmath/bcmath_arginfo.h b/ext/bcmath/bcmath_arginfo.h index 9edfd5cd65760..15325603f211e 100644 --- a/ext/bcmath/bcmath_arginfo.h +++ b/ext/bcmath/bcmath_arginfo.h @@ -208,9 +208,9 @@ static zend_class_entry *register_class_BcMath_Number(zend_class_entry *class_en zval property_scale_default_value; ZVAL_UNDEF(&property_scale_default_value); - zend_string *property_scale_name = zend_string_init("scale", sizeof("scale") - 1, 1); + zend_string *property_scale_name = zend_string_init("scale", sizeof("scale") - 1, true); zend_declare_typed_property(class_entry, property_scale_name, &property_scale_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_scale_name); + zend_string_release_ex(property_scale_name, true); return class_entry; } diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index aff9d5c11b9ed..a8153d7d11938 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -352,7 +352,7 @@ PHP_FUNCTION(bzopen) RETURN_THROWS(); } - if (CHECK_ZVAL_NULL_PATH(file)) { + if (zend_str_has_nul_byte(Z_STR_P(file))) { zend_argument_type_error(1, "must not contain null bytes"); RETURN_THROWS(); } @@ -476,8 +476,15 @@ PHP_FUNCTION(bzcompress) + .01 x length of data + 600 which is the largest size the results of the compression could possibly be, at least that's what the libbz2 docs say (thanks to jeremy@nirvani.net for pointing this out). */ - // TODO Check source string length fits in unsigned int - dest_len = (unsigned int) (source_len + (0.01 * source_len) + 600); + size_t chunk_len = source_len + source_len / 100 + 600; + const size_t min = MIN(ZSTR_MAX_LEN, UINT_MAX); + + if (chunk_len < source_len || chunk_len > min) { + zend_argument_value_error(1, "must have a length less than or equal to %zu", min); + RETURN_THROWS(); + } + + dest_len = (unsigned int) chunk_len; /* Allocate the destination buffer */ dest = zend_string_alloc(dest_len, 0); @@ -504,11 +511,7 @@ PHP_FUNCTION(bzdecompress) size_t source_len; int error; bool small = 0; -#ifdef PHP_WIN32 - unsigned __int64 size = 0; -#else - unsigned long long size = 0; -#endif + uint64_t size = 0; bz_stream bzs; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &source, &source_len, &small)) { @@ -535,26 +538,22 @@ PHP_FUNCTION(bzdecompress) /* compression is better then 2:1, need to allocate more memory */ bzs.avail_out = source_len; size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; -#ifndef ZEND_ENABLE_ZVAL_LONG64 - if (size > SIZE_MAX) { + if (UNEXPECTED(size > SIZE_MAX)) { /* no reason to continue if we're going to drop it anyway */ break; } -#endif + dest = zend_string_safe_realloc(dest, 1, bzs.avail_out+1, (size_t) size, 0); bzs.next_out = ZSTR_VAL(dest) + size; } if (error == BZ_STREAM_END || error == BZ_OK) { size = (bzs.total_out_hi32 * (unsigned int) -1) + bzs.total_out_lo32; -#ifndef ZEND_ENABLE_ZVAL_LONG64 if (UNEXPECTED(size > SIZE_MAX)) { - php_error_docref(NULL, E_WARNING, "Decompressed size too big, max is %zd", SIZE_MAX); + php_error_docref(NULL, E_WARNING, "Decompressed size too big, max is %zu", SIZE_MAX); zend_string_efree(dest); RETVAL_LONG(BZ_MEM_ERROR); - } else -#endif - { + } else { dest = zend_string_safe_realloc(dest, 1, (size_t)size, 1, 0); ZSTR_LEN(dest) = (size_t)size; ZSTR_VAL(dest)[(size_t)size] = '\0'; diff --git a/ext/bz2/tests/gh20620.phpt b/ext/bz2/tests/gh20620.phpt new file mode 100644 index 0000000000000..351ba488b2bd6 --- /dev/null +++ b/ext/bz2/tests/gh20620.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug GH-20620 (bzcompress with large source) +--EXTENSIONS-- +bz2 +--SKIPIF-- + +--INI-- +memory_limit=-1 +--FILE-- +getMessage(), PHP_EOL; +} +?> +--EXPECTF-- +bzcompress(): Argument #1 ($data) must have a length less than or equal to %d diff --git a/ext/calendar/cal_unix.c b/ext/calendar/cal_unix.c index c3fe5557d244e..915da1c326ae1 100644 --- a/ext/calendar/cal_unix.c +++ b/ext/calendar/cal_unix.c @@ -28,7 +28,7 @@ PHP_FUNCTION(unixtojd) { time_t ts; zend_long tl = 0; - bool tl_is_null = 1; + bool tl_is_null = true; struct tm *ta, tmbuf; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &tl, &tl_is_null) == FAILURE) { diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c index 5e948fa1567a7..b90e461da49ce 100644 --- a/ext/calendar/calendar.c +++ b/ext/calendar/calendar.c @@ -480,7 +480,7 @@ static char *heb_number_to_chars(int n, int fl, char **ret) PHP_FUNCTION(jdtojewish) { zend_long julday, fl = 0; - bool heb = 0; + bool heb = false; int year, month, day; char *dayp, *yearp; diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c index 72c52e0fcff78..7fd8c0b33bb3e 100644 --- a/ext/calendar/easter.c +++ b/ext/calendar/easter.c @@ -34,7 +34,7 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, bool gm) zend_long year, golden, solar, lunar, pfm, dom, tmp, easter, result; zend_long method = CAL_EASTER_DEFAULT; const zend_long max_year = (zend_long)(ZEND_LONG_MAX / 5) * 4; - bool year_is_null = 1; + bool year_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l", &year, &year_is_null, &method) == FAILURE) { diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index cf44858c93b78..129db275a72ef 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -281,7 +281,7 @@ PHP_FUNCTION(com_get_active_object) char *module_name; size_t module_name_len; zend_long code_page; - bool code_page_is_null = 1; + bool code_page_is_null = true; IUnknown *unk = NULL; IDispatch *obj = NULL; HRESULT res; @@ -538,7 +538,7 @@ zend_result php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_fu } /* this will create an exception if needed */ - hr = php_com_invoke_helper(obj, dispid, flags, &disp_params, v, 0, 0); + hr = php_com_invoke_helper(obj, dispid, flags, &disp_params, v, false, false); /* release variants */ if (vargs) { @@ -649,7 +649,7 @@ zend_result php_com_do_invoke(php_com_dotnet_object *obj, zend_string *name, return FAILURE; } - return php_com_do_invoke_by_id(obj, dispid, flags, v, nargs, args, 0, allow_noarg); + return php_com_do_invoke_by_id(obj, dispid, flags, v, nargs, args, false, allow_noarg); } /* {{{ Generate a globally unique identifier (GUID) */ diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c index a5de6415b9a73..6c80bd2b9e24c 100644 --- a/ext/com_dotnet/com_misc.c +++ b/ext/com_dotnet/com_misc.c @@ -73,7 +73,7 @@ PHP_COM_DOTNET_API void php_com_wrap_variant(zval *z, VARIANT *v, VariantInit(&obj->v); VariantCopyInd(&obj->v, v); - obj->modified = 0; + obj->modified = false; if ((V_VT(&obj->v) == VT_DISPATCH) && (V_DISPATCH(&obj->v) != NULL)) { IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &obj->typeinfo); diff --git a/ext/curl/curl_arginfo.h b/ext/curl/curl_arginfo.h index b511ff077de9d..7e4a5789d599a 100644 --- a/ext/curl/curl_arginfo.h +++ b/ext/curl/curl_arginfo.h @@ -1046,9 +1046,9 @@ static zend_class_entry *register_class_CurlSharePersistentHandle(void) zval property_options_default_value; ZVAL_UNDEF(&property_options_default_value); - zend_string *property_options_name = zend_string_init("options", sizeof("options") - 1, 1); + zend_string *property_options_name = zend_string_init("options", sizeof("options") - 1, true); zend_declare_typed_property(class_entry, property_options_name, &property_options_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); - zend_string_release(property_options_name); + zend_string_release_ex(property_options_name, true); return class_entry; } diff --git a/ext/curl/curl_file_arginfo.h b/ext/curl/curl_file_arginfo.h index e409c6e772513..9ddd1f39d8986 100644 --- a/ext/curl/curl_file_arginfo.h +++ b/ext/curl/curl_file_arginfo.h @@ -64,15 +64,15 @@ static zend_class_entry *register_class_CURLFile(void) zval property_mime_default_value; ZVAL_EMPTY_STRING(&property_mime_default_value); - zend_string *property_mime_name = zend_string_init("mime", sizeof("mime") - 1, 1); + zend_string *property_mime_name = zend_string_init("mime", sizeof("mime") - 1, true); zend_declare_typed_property(class_entry, property_mime_name, &property_mime_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_mime_name); + zend_string_release_ex(property_mime_name, true); zval property_postname_default_value; ZVAL_EMPTY_STRING(&property_postname_default_value); - zend_string *property_postname_name = zend_string_init("postname", sizeof("postname") - 1, 1); + zend_string *property_postname_name = zend_string_init("postname", sizeof("postname") - 1, true); zend_declare_typed_property(class_entry, property_postname_name, &property_postname_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_postname_name); + zend_string_release_ex(property_postname_name, true); return class_entry; } @@ -86,21 +86,21 @@ static zend_class_entry *register_class_CURLStringFile(void) zval property_data_default_value; ZVAL_UNDEF(&property_data_default_value); - zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, 1); + zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, true); zend_declare_typed_property(class_entry, property_data_name, &property_data_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_data_name); + zend_string_release_ex(property_data_name, true); zval property_postname_default_value; ZVAL_UNDEF(&property_postname_default_value); - zend_string *property_postname_name = zend_string_init("postname", sizeof("postname") - 1, 1); + zend_string *property_postname_name = zend_string_init("postname", sizeof("postname") - 1, true); zend_declare_typed_property(class_entry, property_postname_name, &property_postname_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_postname_name); + zend_string_release_ex(property_postname_name, true); zval property_mime_default_value; ZVAL_UNDEF(&property_mime_default_value); - zend_string *property_mime_name = zend_string_init("mime", sizeof("mime") - 1, 1); + zend_string *property_mime_name = zend_string_init("mime", sizeof("mime") - 1, true); zend_declare_typed_property(class_entry, property_mime_name, &property_mime_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_mime_name); + zend_string_release_ex(property_mime_name, true); return class_entry; } diff --git a/ext/date/php_date.c b/ext/date/php_date.c index b6aac112b6d7d..692136bbad2ac 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -714,7 +714,7 @@ static zend_string *date_format(const char *format, size_t format_len, const tim } for (i = 0; i < format_len; i++) { - rfc_colon = 0; + rfc_colon = false; switch (format[i]) { /* day */ case 'd': length = slprintf(buffer, sizeof(buffer), "%02d", (int) t->d); break; @@ -778,7 +778,7 @@ static zend_string *date_format(const char *format, size_t format_len, const tim break; } ZEND_FALLTHROUGH; - case 'P': rfc_colon = 1; ZEND_FALLTHROUGH; + case 'P': rfc_colon = true; ZEND_FALLTHROUGH; case 'O': length = slprintf(buffer, sizeof(buffer), "%c%02d%s%02d", localtime ? ((offset->offset < 0) ? '-' : '+') : '+', localtime ? abs(offset->offset / 3600) : 0, @@ -1503,7 +1503,7 @@ static void create_date_period_interval(timelib_rel_time *interval, zval *zv) object_init_ex(zv, date_ce_interval); interval_obj = Z_PHPINTERVAL_P(zv); interval_obj->diff = timelib_rel_time_clone(interval); - interval_obj->initialized = 1; + interval_obj->initialized = true; } else { ZVAL_NULL(zv); } @@ -1899,7 +1899,7 @@ static void date_object_to_hash(php_date_obj *dateobj, HashTable *props) zval zv; /* first we add the date and time in ISO format */ - ZVAL_STR(&zv, date_format("x-m-d H:i:s.u", sizeof("x-m-d H:i:s.u")-1, dateobj->time, 1)); + ZVAL_STR(&zv, date_format("x-m-d H:i:s.u", sizeof("x-m-d H:i:s.u")-1, dateobj->time, true)); zend_hash_str_update(props, "date", sizeof("date")-1, &zv); /* then we add the timezone name (or similar) */ @@ -1979,7 +1979,7 @@ static zend_object *date_object_clone_timezone(zend_object *this_ptr) /* {{{ */ } new_obj->type = old_obj->type; - new_obj->initialized = 1; + new_obj->initialized = true; switch (new_obj->type) { case TIMELIB_ZONETYPE_ID: new_obj->tzi.tz = old_obj->tzi.tz; @@ -2874,7 +2874,7 @@ static bool php_date_initialize_from_hash(php_date_obj **dateobj, const HashTabl tzobj = Z_PHPTIMEZONE_P(php_date_instantiate(date_ce_timezone, &tmp_obj)); tzobj->type = TIMELIB_ZONETYPE_ID; tzobj->tzi.tz = tzi; - tzobj->initialized = 1; + tzobj->initialized = true; ret = php_date_initialize(*dateobj, Z_STRVAL_P(z_date), Z_STRLEN_P(z_date), NULL, &tmp_obj, 0); zval_ptr_dtor(&tmp_obj); @@ -2975,9 +2975,9 @@ static bool date_time_is_internal_property(const zend_string *name) zend_string_equals_literal(name, "timezone_type") || zend_string_equals_literal(name, "timezone") ) { - return 1; + return true; } - return 0; + return false; } static void restore_custom_datetime_properties(zval *object, const HashTable *myht) @@ -3241,7 +3241,7 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{ if (!(dateobj->time)) { date_throw_uninitialized_error(Z_OBJCE_P(object)); - return 0; + return false; } tmp_time = timelib_strtotime(modify, modify_len, &err, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper); @@ -3256,7 +3256,7 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{ err->error_messages[0].character ? err->error_messages[0].character : ' ', err->error_messages[0].message); timelib_time_dtor(tmp_time); - return 0; + return false; } memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(timelib_rel_time)); @@ -3309,7 +3309,7 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len) /* {{ dateobj->time->have_relative = 0; memset(&dateobj->time->relative, 0, sizeof(dateobj->time->relative)); - return 1; + return true; } /* }}} */ /* {{{ Alters the timestamp. */ @@ -3522,7 +3522,7 @@ static void set_timezone_from_timelib_time(php_timezone_obj *tzobj, const timeli } /* Set new values */ - tzobj->initialized = 1; + tzobj->initialized = true; tzobj->type = t->zone_type; switch (t->zone_type) { @@ -3965,7 +3965,7 @@ PHP_FUNCTION(date_diff) zval *object1, *object2; php_date_obj *dateobj1, *dateobj2; php_interval_obj *interval; - bool absolute = 0; + bool absolute = false; if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|b", &object1, date_ce_interface, &object2, date_ce_interface, &absolute) == FAILURE) { RETURN_THROWS(); @@ -3981,7 +3981,7 @@ PHP_FUNCTION(date_diff) if (absolute) { interval->diff->invert = 0; } - interval->initialized = 1; + interval->initialized = true; interval->civil_or_wall = PHP_DATE_CIVIL; } /* }}} */ @@ -4157,9 +4157,9 @@ static bool date_timezone_is_internal_property(const zend_string *name) zend_string_equals_literal(name, "timezone_type") || zend_string_equals_literal(name, "timezone") ) { - return 1; + return true; } - return 0; + return false; } static void restore_custom_datetimezone_properties(zval *object, const HashTable *myht) @@ -4330,10 +4330,10 @@ PHP_FUNCTION(timezone_transitions_get) if (timestamp_begin == ZEND_LONG_MIN) { add_nominal(); begin = 0; - found = 1; + found = true; } else { begin = 0; - found = 0; + found = false; if (tzobj->tzi.tz->bit64.timecnt > 0) { do { if (tzobj->tzi.tz->trans[begin] > timestamp_begin) { @@ -4342,7 +4342,7 @@ PHP_FUNCTION(timezone_transitions_get) } else { add_nominal(); } - found = 1; + found = true; break; } begin++; @@ -4640,7 +4640,7 @@ static void php_date_interval_initialize_from_hash(zval **return_value, php_inte } (*intobj)->diff = timelib_rel_time_clone(&time->relative); - (*intobj)->initialized = 1; + (*intobj)->initialized = true; (*intobj)->civil_or_wall = PHP_DATE_CIVIL; (*intobj)->from_string = true; (*intobj)->date_string = zend_string_copy(Z_STR_P(date_str)); @@ -4737,7 +4737,7 @@ static void php_date_interval_initialize_from_hash(zval **return_value, php_inte } } - (*intobj)->initialized = 1; + (*intobj)->initialized = true; } /* }}} */ /* {{{ */ @@ -4791,9 +4791,9 @@ static bool date_interval_is_internal_property(const zend_string *name) zend_string_equals_literal(name, "invert") || zend_string_equals_literal(name, "days") ) { - return 1; + return true; } - return 0; + return false; } static void restore_custom_dateinterval_properties(zval *object, const HashTable *myht) @@ -4852,7 +4852,7 @@ static void date_interval_instantiate_from_time(zval *return_value, timelib_time php_date_instantiate(date_ce_interval, return_value); diobj = Z_PHPINTERVAL_P(return_value); diobj->diff = timelib_rel_time_clone(&time->relative); - diobj->initialized = 1; + diobj->initialized = true; diobj->civil_or_wall = PHP_DATE_CIVIL; diobj->from_string = true; diobj->date_string = zend_string_copy(time_str); @@ -5108,7 +5108,7 @@ static bool date_period_init_finish(php_period_obj *dpobj, zend_long options, ze dpobj->recurrences = (int)recurrences; - dpobj->initialized = 1; + dpobj->initialized = true; return true; } @@ -5280,7 +5280,7 @@ PHP_METHOD(DatePeriod, getDateInterval) php_date_instantiate(date_ce_interval, return_value); diobj = Z_PHPINTERVAL_P(return_value); diobj->diff = timelib_rel_time_clone(dpobj->interval); - diobj->initialized = 1; + diobj->initialized = true; } /* }}} */ @@ -5310,18 +5310,18 @@ PHP_METHOD(DatePeriod, getIterator) static bool check_id_allowed(const char *id, zend_long what) /* {{{ */ { - if ((what & PHP_DATE_TIMEZONE_GROUP_AFRICA) && strncasecmp(id, "Africa/", 7) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_AMERICA) && strncasecmp(id, "America/", 8) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_ANTARCTICA) && strncasecmp(id, "Antarctica/", 11) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_ARCTIC) && strncasecmp(id, "Arctic/", 7) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_ASIA) && strncasecmp(id, "Asia/", 5) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_ATLANTIC) && strncasecmp(id, "Atlantic/", 9) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_AUSTRALIA) && strncasecmp(id, "Australia/", 10) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_EUROPE) && strncasecmp(id, "Europe/", 7) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_INDIAN) && strncasecmp(id, "Indian/", 7) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_PACIFIC) && strncasecmp(id, "Pacific/", 8) == 0) return 1; - if ((what & PHP_DATE_TIMEZONE_GROUP_UTC) && strncasecmp(id, "UTC", 3) == 0) return 1; - return 0; + if ((what & PHP_DATE_TIMEZONE_GROUP_AFRICA) && strncasecmp(id, "Africa/", 7) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_AMERICA) && strncasecmp(id, "America/", 8) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_ANTARCTICA) && strncasecmp(id, "Antarctica/", 11) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_ARCTIC) && strncasecmp(id, "Arctic/", 7) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_ASIA) && strncasecmp(id, "Asia/", 5) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_ATLANTIC) && strncasecmp(id, "Atlantic/", 9) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_AUSTRALIA) && strncasecmp(id, "Australia/", 10) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_EUROPE) && strncasecmp(id, "Europe/", 7) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_INDIAN) && strncasecmp(id, "Indian/", 7) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_PACIFIC) && strncasecmp(id, "Pacific/", 8) == 0) return true; + if ((what & PHP_DATE_TIMEZONE_GROUP_UTC) && strncasecmp(id, "UTC", 3) == 0) return true; + return false; } /* }}} */ /* {{{ Returns numerically index array with all timezone identifiers. */ @@ -5728,7 +5728,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con date_obj = Z_PHPDATE_P(ht_entry); if (!date_obj->time) { - return 0; + return false; } if (period_obj->start != NULL) { @@ -5737,10 +5737,10 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con period_obj->start = timelib_time_clone(date_obj->time); period_obj->start_ce = Z_OBJCE_P(ht_entry); } else if (Z_TYPE_P(ht_entry) != IS_NULL) { - return 0; + return false; } } else { - return 0; + return false; } ht_entry = zend_hash_str_find(myht, "end", sizeof("end")-1); @@ -5750,7 +5750,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con date_obj = Z_PHPDATE_P(ht_entry); if (!date_obj->time) { - return 0; + return false; } if (period_obj->end != NULL) { @@ -5758,10 +5758,10 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con } period_obj->end = timelib_time_clone(date_obj->time); } else if (Z_TYPE_P(ht_entry) != IS_NULL) { - return 0; + return false; } } else { - return 0; + return false; } ht_entry = zend_hash_str_find(myht, "current", sizeof("current")-1); @@ -5771,7 +5771,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con date_obj = Z_PHPDATE_P(ht_entry); if (!date_obj->time) { - return 0; + return false; } if (period_obj->current != NULL) { @@ -5779,10 +5779,10 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con } period_obj->current = timelib_time_clone(date_obj->time); } else if (Z_TYPE_P(ht_entry) != IS_NULL) { - return 0; + return false; } } else { - return 0; + return false; } ht_entry = zend_hash_str_find(myht, "interval", sizeof("interval")-1); @@ -5792,7 +5792,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con interval_obj = Z_PHPINTERVAL_P(ht_entry); if (!interval_obj->initialized) { - return 0; + return false; } if (period_obj->interval != NULL) { @@ -5800,10 +5800,10 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con } period_obj->interval = timelib_rel_time_clone(interval_obj->diff); } else { /* interval is required */ - return 0; + return false; } } else { - return 0; + return false; } ht_entry = zend_hash_str_find(myht, "recurrences", sizeof("recurrences")-1); @@ -5811,7 +5811,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con Z_TYPE_P(ht_entry) == IS_LONG && Z_LVAL_P(ht_entry) >= 0 && Z_LVAL_P(ht_entry) <= INT_MAX) { period_obj->recurrences = Z_LVAL_P(ht_entry); } else { - return 0; + return false; } ht_entry = zend_hash_str_find(myht, "include_start_date", sizeof("include_start_date")-1); @@ -5819,7 +5819,7 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con (Z_TYPE_P(ht_entry) == IS_FALSE || Z_TYPE_P(ht_entry) == IS_TRUE)) { period_obj->include_start_date = (Z_TYPE_P(ht_entry) == IS_TRUE); } else { - return 0; + return false; } ht_entry = zend_hash_str_find(myht, "include_end_date", sizeof("include_end_date")-1); @@ -5827,12 +5827,12 @@ static bool php_date_period_initialize_from_hash(php_period_obj *period_obj, con (Z_TYPE_P(ht_entry) == IS_FALSE || Z_TYPE_P(ht_entry) == IS_TRUE)) { period_obj->include_end_date = (Z_TYPE_P(ht_entry) == IS_TRUE); } else { - return 0; + return false; } - period_obj->initialized = 1; + period_obj->initialized = true; - return 1; + return true; } /* }}} */ /* {{{ */ @@ -5889,9 +5889,9 @@ static bool date_period_is_internal_property(const zend_string *name) zend_string_equals_literal(name, "include_start_date") || zend_string_equals_literal(name, "include_end_date") ) { - return 1; + return true; } - return 0; + return false; } /* }}} */ diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h index 873103d8ff90b..74541e13a5c19 100644 --- a/ext/date/php_date_arginfo.h +++ b/ext/date/php_date_arginfo.h @@ -876,100 +876,100 @@ static zend_class_entry *register_class_DateTimeInterface(void) zval const_ATOM_value; zend_string *const_ATOM_value_str = zend_string_init(DATE_FORMAT_RFC3339, strlen(DATE_FORMAT_RFC3339), 1); ZVAL_STR(&const_ATOM_value, const_ATOM_value_str); - zend_string *const_ATOM_name = zend_string_init_interned("ATOM", sizeof("ATOM") - 1, 1); + zend_string *const_ATOM_name = zend_string_init_interned("ATOM", sizeof("ATOM") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATOM_name, &const_ATOM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_ATOM_name); + zend_string_release_ex(const_ATOM_name, true); zval const_COOKIE_value; zend_string *const_COOKIE_value_str = zend_string_init(DATE_FORMAT_COOKIE, strlen(DATE_FORMAT_COOKIE), 1); ZVAL_STR(&const_COOKIE_value, const_COOKIE_value_str); - zend_string *const_COOKIE_name = zend_string_init_interned("COOKIE", sizeof("COOKIE") - 1, 1); + zend_string *const_COOKIE_name = zend_string_init_interned("COOKIE", sizeof("COOKIE") - 1, true); zend_declare_typed_class_constant(class_entry, const_COOKIE_name, &const_COOKIE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_COOKIE_name); + zend_string_release_ex(const_COOKIE_name, true); zval const_ISO8601_value; zend_string *const_ISO8601_value_str = zend_string_init(DATE_FORMAT_ISO8601, strlen(DATE_FORMAT_ISO8601), 1); ZVAL_STR(&const_ISO8601_value, const_ISO8601_value_str); - zend_string *const_ISO8601_name = zend_string_init_interned("ISO8601", sizeof("ISO8601") - 1, 1); + zend_string *const_ISO8601_name = zend_string_init_interned("ISO8601", sizeof("ISO8601") - 1, true); zend_declare_typed_class_constant(class_entry, const_ISO8601_name, &const_ISO8601_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_ISO8601_name); + zend_string_release_ex(const_ISO8601_name, true); zval const_ISO8601_EXPANDED_value; zend_string *const_ISO8601_EXPANDED_value_str = zend_string_init(DATE_FORMAT_ISO8601_EXPANDED, strlen(DATE_FORMAT_ISO8601_EXPANDED), 1); ZVAL_STR(&const_ISO8601_EXPANDED_value, const_ISO8601_EXPANDED_value_str); - zend_string *const_ISO8601_EXPANDED_name = zend_string_init_interned("ISO8601_EXPANDED", sizeof("ISO8601_EXPANDED") - 1, 1); + zend_string *const_ISO8601_EXPANDED_name = zend_string_init_interned("ISO8601_EXPANDED", sizeof("ISO8601_EXPANDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_ISO8601_EXPANDED_name, &const_ISO8601_EXPANDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_ISO8601_EXPANDED_name); + zend_string_release_ex(const_ISO8601_EXPANDED_name, true); zval const_RFC822_value; zend_string *const_RFC822_value_str = zend_string_init(DATE_FORMAT_RFC822, strlen(DATE_FORMAT_RFC822), 1); ZVAL_STR(&const_RFC822_value, const_RFC822_value_str); - zend_string *const_RFC822_name = zend_string_init_interned("RFC822", sizeof("RFC822") - 1, 1); + zend_string *const_RFC822_name = zend_string_init_interned("RFC822", sizeof("RFC822") - 1, true); zend_declare_typed_class_constant(class_entry, const_RFC822_name, &const_RFC822_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC822_name); + zend_string_release_ex(const_RFC822_name, true); zval const_RFC850_value; zend_string *const_RFC850_value_str = zend_string_init(DATE_FORMAT_RFC850, strlen(DATE_FORMAT_RFC850), 1); ZVAL_STR(&const_RFC850_value, const_RFC850_value_str); - zend_string *const_RFC850_name = zend_string_init_interned("RFC850", sizeof("RFC850") - 1, 1); + zend_string *const_RFC850_name = zend_string_init_interned("RFC850", sizeof("RFC850") - 1, true); zend_declare_typed_class_constant(class_entry, const_RFC850_name, &const_RFC850_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC850_name); + zend_string_release_ex(const_RFC850_name, true); zval const_RFC1036_value; zend_string *const_RFC1036_value_str = zend_string_init(DATE_FORMAT_RFC1036, strlen(DATE_FORMAT_RFC1036), 1); ZVAL_STR(&const_RFC1036_value, const_RFC1036_value_str); - zend_string *const_RFC1036_name = zend_string_init_interned("RFC1036", sizeof("RFC1036") - 1, 1); + zend_string *const_RFC1036_name = zend_string_init_interned("RFC1036", sizeof("RFC1036") - 1, true); zend_declare_typed_class_constant(class_entry, const_RFC1036_name, &const_RFC1036_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC1036_name); + zend_string_release_ex(const_RFC1036_name, true); zval const_RFC1123_value; zend_string *const_RFC1123_value_str = zend_string_init(DATE_FORMAT_RFC1123, strlen(DATE_FORMAT_RFC1123), 1); ZVAL_STR(&const_RFC1123_value, const_RFC1123_value_str); - zend_string *const_RFC1123_name = zend_string_init_interned("RFC1123", sizeof("RFC1123") - 1, 1); + zend_string *const_RFC1123_name = zend_string_init_interned("RFC1123", sizeof("RFC1123") - 1, true); zend_declare_typed_class_constant(class_entry, const_RFC1123_name, &const_RFC1123_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC1123_name); + zend_string_release_ex(const_RFC1123_name, true); zval const_RFC7231_value; zend_string *const_RFC7231_value_str = zend_string_init(DATE_FORMAT_RFC7231, strlen(DATE_FORMAT_RFC7231), 1); ZVAL_STR(&const_RFC7231_value, const_RFC7231_value_str); - zend_string *const_RFC7231_name = zend_string_init_interned("RFC7231", sizeof("RFC7231") - 1, 1); + zend_string *const_RFC7231_name = zend_string_init_interned("RFC7231", sizeof("RFC7231") - 1, true); zend_class_constant *const_RFC7231 = zend_declare_typed_class_constant(class_entry, const_RFC7231_name, &const_RFC7231_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC7231_name); + zend_string_release_ex(const_RFC7231_name, true); zval const_RFC2822_value; zend_string *const_RFC2822_value_str = zend_string_init(DATE_FORMAT_RFC2822, strlen(DATE_FORMAT_RFC2822), 1); ZVAL_STR(&const_RFC2822_value, const_RFC2822_value_str); - zend_string *const_RFC2822_name = zend_string_init_interned("RFC2822", sizeof("RFC2822") - 1, 1); + zend_string *const_RFC2822_name = zend_string_init_interned("RFC2822", sizeof("RFC2822") - 1, true); zend_declare_typed_class_constant(class_entry, const_RFC2822_name, &const_RFC2822_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC2822_name); + zend_string_release_ex(const_RFC2822_name, true); zval const_RFC3339_value; zend_string *const_RFC3339_value_str = zend_string_init(DATE_FORMAT_RFC3339, strlen(DATE_FORMAT_RFC3339), 1); ZVAL_STR(&const_RFC3339_value, const_RFC3339_value_str); - zend_string *const_RFC3339_name = zend_string_init_interned("RFC3339", sizeof("RFC3339") - 1, 1); + zend_string *const_RFC3339_name = zend_string_init_interned("RFC3339", sizeof("RFC3339") - 1, true); zend_declare_typed_class_constant(class_entry, const_RFC3339_name, &const_RFC3339_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC3339_name); + zend_string_release_ex(const_RFC3339_name, true); zval const_RFC3339_EXTENDED_value; zend_string *const_RFC3339_EXTENDED_value_str = zend_string_init(DATE_FORMAT_RFC3339_EXTENDED, strlen(DATE_FORMAT_RFC3339_EXTENDED), 1); ZVAL_STR(&const_RFC3339_EXTENDED_value, const_RFC3339_EXTENDED_value_str); - zend_string *const_RFC3339_EXTENDED_name = zend_string_init_interned("RFC3339_EXTENDED", sizeof("RFC3339_EXTENDED") - 1, 1); + zend_string *const_RFC3339_EXTENDED_name = zend_string_init_interned("RFC3339_EXTENDED", sizeof("RFC3339_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_RFC3339_EXTENDED_name, &const_RFC3339_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RFC3339_EXTENDED_name); + zend_string_release_ex(const_RFC3339_EXTENDED_name, true); zval const_RSS_value; zend_string *const_RSS_value_str = zend_string_init(DATE_FORMAT_RFC1123, strlen(DATE_FORMAT_RFC1123), 1); ZVAL_STR(&const_RSS_value, const_RSS_value_str); - zend_string *const_RSS_name = zend_string_init_interned("RSS", sizeof("RSS") - 1, 1); + zend_string *const_RSS_name = zend_string_init_interned("RSS", sizeof("RSS") - 1, true); zend_declare_typed_class_constant(class_entry, const_RSS_name, &const_RSS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_RSS_name); + zend_string_release_ex(const_RSS_name, true); zval const_W3C_value; zend_string *const_W3C_value_str = zend_string_init(DATE_FORMAT_RFC3339, strlen(DATE_FORMAT_RFC3339), 1); ZVAL_STR(&const_W3C_value, const_W3C_value_str); - zend_string *const_W3C_name = zend_string_init_interned("W3C", sizeof("W3C") - 1, 1); + zend_string *const_W3C_name = zend_string_init_interned("W3C", sizeof("W3C") - 1, true); zend_declare_typed_class_constant(class_entry, const_W3C_name, &const_W3C_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_W3C_name); + zend_string_release_ex(const_W3C_name, true); zend_attribute *attribute_Deprecated_const_RFC7231_0 = zend_add_class_constant_attribute(class_entry, const_RFC7231, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); @@ -1025,65 +1025,65 @@ static zend_class_entry *register_class_DateTimeImmutable(zend_class_entry *clas ZVAL_STR(&attribute_Deprecated_func___wakeup_0->args[1].value, attribute_Deprecated_func___wakeup_0_arg1_str); attribute_Deprecated_func___wakeup_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_modify_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_modify_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_modify_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "modify", sizeof("modify") - 1), attribute_name_NoDiscard_func_modify_0, 1); - zend_string_release(attribute_name_NoDiscard_func_modify_0); + zend_string_release_ex(attribute_name_NoDiscard_func_modify_0, true); zend_string *attribute_NoDiscard_func_modify_0_arg0_str = zend_string_init("as DateTimeImmutable::modify() does not modify the object itself", strlen("as DateTimeImmutable::modify() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_modify_0->args[0].value, attribute_NoDiscard_func_modify_0_arg0_str); attribute_NoDiscard_func_modify_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_add_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_add_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_add_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "add", sizeof("add") - 1), attribute_name_NoDiscard_func_add_0, 1); - zend_string_release(attribute_name_NoDiscard_func_add_0); + zend_string_release_ex(attribute_name_NoDiscard_func_add_0, true); zend_string *attribute_NoDiscard_func_add_0_arg0_str = zend_string_init("as DateTimeImmutable::add() does not modify the object itself", strlen("as DateTimeImmutable::add() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_add_0->args[0].value, attribute_NoDiscard_func_add_0_arg0_str); attribute_NoDiscard_func_add_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_sub_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_sub_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_sub_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "sub", sizeof("sub") - 1), attribute_name_NoDiscard_func_sub_0, 1); - zend_string_release(attribute_name_NoDiscard_func_sub_0); + zend_string_release_ex(attribute_name_NoDiscard_func_sub_0, true); zend_string *attribute_NoDiscard_func_sub_0_arg0_str = zend_string_init("as DateTimeImmutable::sub() does not modify the object itself", strlen("as DateTimeImmutable::sub() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_sub_0->args[0].value, attribute_NoDiscard_func_sub_0_arg0_str); attribute_NoDiscard_func_sub_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_settimezone_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_settimezone_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_settimezone_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "settimezone", sizeof("settimezone") - 1), attribute_name_NoDiscard_func_settimezone_0, 1); - zend_string_release(attribute_name_NoDiscard_func_settimezone_0); + zend_string_release_ex(attribute_name_NoDiscard_func_settimezone_0, true); zend_string *attribute_NoDiscard_func_settimezone_0_arg0_str = zend_string_init("as DateTimeImmutable::setTimezone() does not modify the object itself", strlen("as DateTimeImmutable::setTimezone() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_settimezone_0->args[0].value, attribute_NoDiscard_func_settimezone_0_arg0_str); attribute_NoDiscard_func_settimezone_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_settime_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_settime_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_settime_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "settime", sizeof("settime") - 1), attribute_name_NoDiscard_func_settime_0, 1); - zend_string_release(attribute_name_NoDiscard_func_settime_0); + zend_string_release_ex(attribute_name_NoDiscard_func_settime_0, true); zend_string *attribute_NoDiscard_func_settime_0_arg0_str = zend_string_init("as DateTimeImmutable::setTime() does not modify the object itself", strlen("as DateTimeImmutable::setTime() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_settime_0->args[0].value, attribute_NoDiscard_func_settime_0_arg0_str); attribute_NoDiscard_func_settime_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_setdate_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_setdate_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_setdate_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setdate", sizeof("setdate") - 1), attribute_name_NoDiscard_func_setdate_0, 1); - zend_string_release(attribute_name_NoDiscard_func_setdate_0); + zend_string_release_ex(attribute_name_NoDiscard_func_setdate_0, true); zend_string *attribute_NoDiscard_func_setdate_0_arg0_str = zend_string_init("as DateTimeImmutable::setDate() does not modify the object itself", strlen("as DateTimeImmutable::setDate() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_setdate_0->args[0].value, attribute_NoDiscard_func_setdate_0_arg0_str); attribute_NoDiscard_func_setdate_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_setisodate_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_setisodate_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_setisodate_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setisodate", sizeof("setisodate") - 1), attribute_name_NoDiscard_func_setisodate_0, 1); - zend_string_release(attribute_name_NoDiscard_func_setisodate_0); + zend_string_release_ex(attribute_name_NoDiscard_func_setisodate_0, true); zend_string *attribute_NoDiscard_func_setisodate_0_arg0_str = zend_string_init("as DateTimeImmutable::setISODate() does not modify the object itself", strlen("as DateTimeImmutable::setISODate() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_setisodate_0->args[0].value, attribute_NoDiscard_func_setisodate_0_arg0_str); attribute_NoDiscard_func_setisodate_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_settimestamp_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_settimestamp_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_settimestamp_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "settimestamp", sizeof("settimestamp") - 1), attribute_name_NoDiscard_func_settimestamp_0, 1); - zend_string_release(attribute_name_NoDiscard_func_settimestamp_0); + zend_string_release_ex(attribute_name_NoDiscard_func_settimestamp_0, true); zend_string *attribute_NoDiscard_func_settimestamp_0_arg0_str = zend_string_init("as DateTimeImmutable::setTimestamp() does not modify the object itself", strlen("as DateTimeImmutable::setTimestamp() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_settimestamp_0->args[0].value, attribute_NoDiscard_func_settimestamp_0_arg0_str); attribute_NoDiscard_func_settimestamp_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_setmicrosecond_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_setmicrosecond_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_setmicrosecond_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setmicrosecond", sizeof("setmicrosecond") - 1), attribute_name_NoDiscard_func_setmicrosecond_0, 1); - zend_string_release(attribute_name_NoDiscard_func_setmicrosecond_0); + zend_string_release_ex(attribute_name_NoDiscard_func_setmicrosecond_0, true); zend_string *attribute_NoDiscard_func_setmicrosecond_0_arg0_str = zend_string_init("as DateTimeImmutable::setMicrosecond() does not modify the object itself", strlen("as DateTimeImmutable::setMicrosecond() does not modify the object itself"), 1); ZVAL_STR(&attribute_NoDiscard_func_setmicrosecond_0->args[0].value, attribute_NoDiscard_func_setmicrosecond_0_arg0_str); attribute_NoDiscard_func_setmicrosecond_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); @@ -1100,87 +1100,87 @@ static zend_class_entry *register_class_DateTimeZone(void) zval const_AFRICA_value; ZVAL_LONG(&const_AFRICA_value, PHP_DATE_TIMEZONE_GROUP_AFRICA); - zend_string *const_AFRICA_name = zend_string_init_interned("AFRICA", sizeof("AFRICA") - 1, 1); + zend_string *const_AFRICA_name = zend_string_init_interned("AFRICA", sizeof("AFRICA") - 1, true); zend_declare_typed_class_constant(class_entry, const_AFRICA_name, &const_AFRICA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_AFRICA_name); + zend_string_release_ex(const_AFRICA_name, true); zval const_AMERICA_value; ZVAL_LONG(&const_AMERICA_value, PHP_DATE_TIMEZONE_GROUP_AMERICA); - zend_string *const_AMERICA_name = zend_string_init_interned("AMERICA", sizeof("AMERICA") - 1, 1); + zend_string *const_AMERICA_name = zend_string_init_interned("AMERICA", sizeof("AMERICA") - 1, true); zend_declare_typed_class_constant(class_entry, const_AMERICA_name, &const_AMERICA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_AMERICA_name); + zend_string_release_ex(const_AMERICA_name, true); zval const_ANTARCTICA_value; ZVAL_LONG(&const_ANTARCTICA_value, PHP_DATE_TIMEZONE_GROUP_ANTARCTICA); - zend_string *const_ANTARCTICA_name = zend_string_init_interned("ANTARCTICA", sizeof("ANTARCTICA") - 1, 1); + zend_string *const_ANTARCTICA_name = zend_string_init_interned("ANTARCTICA", sizeof("ANTARCTICA") - 1, true); zend_declare_typed_class_constant(class_entry, const_ANTARCTICA_name, &const_ANTARCTICA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ANTARCTICA_name); + zend_string_release_ex(const_ANTARCTICA_name, true); zval const_ARCTIC_value; ZVAL_LONG(&const_ARCTIC_value, PHP_DATE_TIMEZONE_GROUP_ARCTIC); - zend_string *const_ARCTIC_name = zend_string_init_interned("ARCTIC", sizeof("ARCTIC") - 1, 1); + zend_string *const_ARCTIC_name = zend_string_init_interned("ARCTIC", sizeof("ARCTIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_ARCTIC_name, &const_ARCTIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ARCTIC_name); + zend_string_release_ex(const_ARCTIC_name, true); zval const_ASIA_value; ZVAL_LONG(&const_ASIA_value, PHP_DATE_TIMEZONE_GROUP_ASIA); - zend_string *const_ASIA_name = zend_string_init_interned("ASIA", sizeof("ASIA") - 1, 1); + zend_string *const_ASIA_name = zend_string_init_interned("ASIA", sizeof("ASIA") - 1, true); zend_declare_typed_class_constant(class_entry, const_ASIA_name, &const_ASIA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ASIA_name); + zend_string_release_ex(const_ASIA_name, true); zval const_ATLANTIC_value; ZVAL_LONG(&const_ATLANTIC_value, PHP_DATE_TIMEZONE_GROUP_ATLANTIC); - zend_string *const_ATLANTIC_name = zend_string_init_interned("ATLANTIC", sizeof("ATLANTIC") - 1, 1); + zend_string *const_ATLANTIC_name = zend_string_init_interned("ATLANTIC", sizeof("ATLANTIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATLANTIC_name, &const_ATLANTIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATLANTIC_name); + zend_string_release_ex(const_ATLANTIC_name, true); zval const_AUSTRALIA_value; ZVAL_LONG(&const_AUSTRALIA_value, PHP_DATE_TIMEZONE_GROUP_AUSTRALIA); - zend_string *const_AUSTRALIA_name = zend_string_init_interned("AUSTRALIA", sizeof("AUSTRALIA") - 1, 1); + zend_string *const_AUSTRALIA_name = zend_string_init_interned("AUSTRALIA", sizeof("AUSTRALIA") - 1, true); zend_declare_typed_class_constant(class_entry, const_AUSTRALIA_name, &const_AUSTRALIA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_AUSTRALIA_name); + zend_string_release_ex(const_AUSTRALIA_name, true); zval const_EUROPE_value; ZVAL_LONG(&const_EUROPE_value, PHP_DATE_TIMEZONE_GROUP_EUROPE); - zend_string *const_EUROPE_name = zend_string_init_interned("EUROPE", sizeof("EUROPE") - 1, 1); + zend_string *const_EUROPE_name = zend_string_init_interned("EUROPE", sizeof("EUROPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_EUROPE_name, &const_EUROPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EUROPE_name); + zend_string_release_ex(const_EUROPE_name, true); zval const_INDIAN_value; ZVAL_LONG(&const_INDIAN_value, PHP_DATE_TIMEZONE_GROUP_INDIAN); - zend_string *const_INDIAN_name = zend_string_init_interned("INDIAN", sizeof("INDIAN") - 1, 1); + zend_string *const_INDIAN_name = zend_string_init_interned("INDIAN", sizeof("INDIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_INDIAN_name, &const_INDIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INDIAN_name); + zend_string_release_ex(const_INDIAN_name, true); zval const_PACIFIC_value; ZVAL_LONG(&const_PACIFIC_value, PHP_DATE_TIMEZONE_GROUP_PACIFIC); - zend_string *const_PACIFIC_name = zend_string_init_interned("PACIFIC", sizeof("PACIFIC") - 1, 1); + zend_string *const_PACIFIC_name = zend_string_init_interned("PACIFIC", sizeof("PACIFIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_PACIFIC_name, &const_PACIFIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PACIFIC_name); + zend_string_release_ex(const_PACIFIC_name, true); zval const_UTC_value; ZVAL_LONG(&const_UTC_value, PHP_DATE_TIMEZONE_GROUP_UTC); - zend_string *const_UTC_name = zend_string_init_interned("UTC", sizeof("UTC") - 1, 1); + zend_string *const_UTC_name = zend_string_init_interned("UTC", sizeof("UTC") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTC_name, &const_UTC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTC_name); + zend_string_release_ex(const_UTC_name, true); zval const_ALL_value; ZVAL_LONG(&const_ALL_value, PHP_DATE_TIMEZONE_GROUP_ALL); - zend_string *const_ALL_name = zend_string_init_interned("ALL", sizeof("ALL") - 1, 1); + zend_string *const_ALL_name = zend_string_init_interned("ALL", sizeof("ALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ALL_name, &const_ALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ALL_name); + zend_string_release_ex(const_ALL_name, true); zval const_ALL_WITH_BC_value; ZVAL_LONG(&const_ALL_WITH_BC_value, PHP_DATE_TIMEZONE_GROUP_ALL_W_BC); - zend_string *const_ALL_WITH_BC_name = zend_string_init_interned("ALL_WITH_BC", sizeof("ALL_WITH_BC") - 1, 1); + zend_string *const_ALL_WITH_BC_name = zend_string_init_interned("ALL_WITH_BC", sizeof("ALL_WITH_BC") - 1, true); zend_declare_typed_class_constant(class_entry, const_ALL_WITH_BC_name, &const_ALL_WITH_BC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ALL_WITH_BC_name); + zend_string_release_ex(const_ALL_WITH_BC_name, true); zval const_PER_COUNTRY_value; ZVAL_LONG(&const_PER_COUNTRY_value, PHP_DATE_TIMEZONE_PER_COUNTRY); - zend_string *const_PER_COUNTRY_name = zend_string_init_interned("PER_COUNTRY", sizeof("PER_COUNTRY") - 1, 1); + zend_string *const_PER_COUNTRY_name = zend_string_init_interned("PER_COUNTRY", sizeof("PER_COUNTRY") - 1, true); zend_declare_typed_class_constant(class_entry, const_PER_COUNTRY_name, &const_PER_COUNTRY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PER_COUNTRY_name); + zend_string_release_ex(const_PER_COUNTRY_name, true); zend_attribute *attribute_Deprecated_func___wakeup_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "__wakeup", sizeof("__wakeup") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); @@ -1221,61 +1221,61 @@ static zend_class_entry *register_class_DatePeriod(zend_class_entry *class_entry zval const_EXCLUDE_START_DATE_value; ZVAL_LONG(&const_EXCLUDE_START_DATE_value, PHP_DATE_PERIOD_EXCLUDE_START_DATE); - zend_string *const_EXCLUDE_START_DATE_name = zend_string_init_interned("EXCLUDE_START_DATE", sizeof("EXCLUDE_START_DATE") - 1, 1); + zend_string *const_EXCLUDE_START_DATE_name = zend_string_init_interned("EXCLUDE_START_DATE", sizeof("EXCLUDE_START_DATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXCLUDE_START_DATE_name, &const_EXCLUDE_START_DATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXCLUDE_START_DATE_name); + zend_string_release_ex(const_EXCLUDE_START_DATE_name, true); zval const_INCLUDE_END_DATE_value; ZVAL_LONG(&const_INCLUDE_END_DATE_value, PHP_DATE_PERIOD_INCLUDE_END_DATE); - zend_string *const_INCLUDE_END_DATE_name = zend_string_init_interned("INCLUDE_END_DATE", sizeof("INCLUDE_END_DATE") - 1, 1); + zend_string *const_INCLUDE_END_DATE_name = zend_string_init_interned("INCLUDE_END_DATE", sizeof("INCLUDE_END_DATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_INCLUDE_END_DATE_name, &const_INCLUDE_END_DATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INCLUDE_END_DATE_name); + zend_string_release_ex(const_INCLUDE_END_DATE_name, true); zval property_start_default_value; ZVAL_UNDEF(&property_start_default_value); - zend_string *property_start_name = zend_string_init("start", sizeof("start") - 1, 1); + zend_string *property_start_name = zend_string_init("start", sizeof("start") - 1, true); zend_string *property_start_class_DateTimeInterface = zend_string_init("DateTimeInterface", sizeof("DateTimeInterface")-1, 1); zend_declare_typed_property(class_entry, property_start_name, &property_start_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_start_class_DateTimeInterface, 0, MAY_BE_NULL)); - zend_string_release(property_start_name); + zend_string_release_ex(property_start_name, true); zval property_current_default_value; ZVAL_UNDEF(&property_current_default_value); - zend_string *property_current_name = zend_string_init("current", sizeof("current") - 1, 1); + zend_string *property_current_name = zend_string_init("current", sizeof("current") - 1, true); zend_string *property_current_class_DateTimeInterface = zend_string_init("DateTimeInterface", sizeof("DateTimeInterface")-1, 1); zend_declare_typed_property(class_entry, property_current_name, &property_current_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_current_class_DateTimeInterface, 0, MAY_BE_NULL)); - zend_string_release(property_current_name); + zend_string_release_ex(property_current_name, true); zval property_end_default_value; ZVAL_UNDEF(&property_end_default_value); - zend_string *property_end_name = zend_string_init("end", sizeof("end") - 1, 1); + zend_string *property_end_name = zend_string_init("end", sizeof("end") - 1, true); zend_string *property_end_class_DateTimeInterface = zend_string_init("DateTimeInterface", sizeof("DateTimeInterface")-1, 1); zend_declare_typed_property(class_entry, property_end_name, &property_end_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_end_class_DateTimeInterface, 0, MAY_BE_NULL)); - zend_string_release(property_end_name); + zend_string_release_ex(property_end_name, true); zval property_interval_default_value; ZVAL_UNDEF(&property_interval_default_value); - zend_string *property_interval_name = zend_string_init("interval", sizeof("interval") - 1, 1); + zend_string *property_interval_name = zend_string_init("interval", sizeof("interval") - 1, true); zend_string *property_interval_class_DateInterval = zend_string_init("DateInterval", sizeof("DateInterval")-1, 1); zend_declare_typed_property(class_entry, property_interval_name, &property_interval_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_interval_class_DateInterval, 0, MAY_BE_NULL)); - zend_string_release(property_interval_name); + zend_string_release_ex(property_interval_name, true); zval property_recurrences_default_value; ZVAL_UNDEF(&property_recurrences_default_value); - zend_string *property_recurrences_name = zend_string_init("recurrences", sizeof("recurrences") - 1, 1); + zend_string *property_recurrences_name = zend_string_init("recurrences", sizeof("recurrences") - 1, true); zend_declare_typed_property(class_entry, property_recurrences_name, &property_recurrences_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_recurrences_name); + zend_string_release_ex(property_recurrences_name, true); zval property_include_start_date_default_value; ZVAL_UNDEF(&property_include_start_date_default_value); - zend_string *property_include_start_date_name = zend_string_init("include_start_date", sizeof("include_start_date") - 1, 1); + zend_string *property_include_start_date_name = zend_string_init("include_start_date", sizeof("include_start_date") - 1, true); zend_declare_typed_property(class_entry, property_include_start_date_name, &property_include_start_date_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_include_start_date_name); + zend_string_release_ex(property_include_start_date_name, true); zval property_include_end_date_default_value; ZVAL_UNDEF(&property_include_end_date_default_value); - zend_string *property_include_end_date_name = zend_string_init("include_end_date", sizeof("include_end_date") - 1, 1); + zend_string *property_include_end_date_name = zend_string_init("include_end_date", sizeof("include_end_date") - 1, true); zend_declare_typed_property(class_entry, property_include_end_date_name, &property_include_end_date_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_include_end_date_name); + zend_string_release_ex(property_include_end_date_name, true); zend_attribute *attribute_Deprecated_func___wakeup_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "__wakeup", sizeof("__wakeup") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 60685474212f5..8963230353299 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -539,8 +539,8 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) int persistent_flag = persistent ? STREAM_OPEN_PERSISTENT : 0; char *lock_name; #ifdef PHP_WIN32 - bool restarted = 0; - bool need_creation = 0; + bool restarted = false; + bool need_creation = false; #endif zend_string *path; @@ -923,7 +923,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) lock_file_mode = "r+b"; - restarted = 1; + restarted = true; goto restart; #endif } @@ -969,14 +969,14 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) /* {{{ Opens path using the specified handler in mode persistently */ PHP_FUNCTION(dba_popen) { - php_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); + php_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); } /* }}} */ /* {{{ Opens path using the specified handler in mode*/ PHP_FUNCTION(dba_open) { - php_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + php_dba_open(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); } /* }}} */ @@ -1277,7 +1277,7 @@ PHP_FUNCTION(dba_sync) /* {{{ List configured database handlers */ PHP_FUNCTION(dba_handlers) { - bool full_info = 0; + bool full_info = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &full_info) == FAILURE) { RETURN_THROWS(); diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c index 00b99d55b0056..75a267055d96c 100644 --- a/ext/dba/dba_inifile.c +++ b/ext/dba/dba_inifile.c @@ -127,7 +127,7 @@ DBA_DELETE_FUNC(inifile) { inifile *dba = info->dbf; int res; - bool found = 0; + bool found = false; key_type ini_key; if (!key) { diff --git a/ext/dl_test/dl_test_arginfo.h b/ext/dl_test/dl_test_arginfo.h index 588d0b1b6e6e1..0b246bd0df1ee 100644 --- a/ext/dl_test/dl_test_arginfo.h +++ b/ext/dl_test/dl_test_arginfo.h @@ -57,9 +57,9 @@ static zend_class_entry *register_class_DlTestSuperClass(void) zval property_a_default_value; ZVAL_UNDEF(&property_a_default_value); - zend_string *property_a_name = zend_string_init("a", sizeof("a") - 1, 1); + zend_string *property_a_name = zend_string_init("a", sizeof("a") - 1, true); zend_declare_typed_property(class_entry, property_a_name, &property_a_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_a_name); + zend_string_release_ex(property_a_name, true); return class_entry; } diff --git a/ext/dom/attr.c b/ext/dom/attr.c index 5a0900d657eea..3107f5a21a2be 100644 --- a/ext/dom/attr.c +++ b/ext/dom/attr.c @@ -83,7 +83,7 @@ zend_result dom_attr_name_read(dom_object *obj, zval *retval) if (php_dom_follow_spec_intern(obj)) { zend_string *str = dom_node_get_node_name_attribute_or_element((xmlNodePtr) attrp, false); - ZVAL_NEW_STR(retval, str); + ZVAL_STR(retval, str); } else { ZVAL_STRING(retval, (char *) attrp->name); } diff --git a/ext/dom/document.c b/ext/dom/document.c index edf83939bf801..b46722d854c5e 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -752,7 +752,7 @@ PHP_METHOD(DOMDocument, importNode) xmlDocPtr docp; xmlNodePtr nodep, retnodep; dom_object *intern, *nodeobj; - bool recursive = 0; + bool recursive = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|b", &node, dom_node_class_entry, &recursive) == FAILURE) { RETURN_THROWS(); @@ -802,7 +802,7 @@ static void dom_modern_document_import_node(INTERNAL_FUNCTION_PARAMETERS, zend_c xmlDocPtr docp; xmlNodePtr nodep, retnodep; dom_object *intern, *nodeobj; - bool recursive = 0; + bool recursive = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|b", &node, node_ce, &recursive) != SUCCESS) { RETURN_THROWS(); @@ -1380,10 +1380,8 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source, substitute_ent = doc_props->substituteentities; recover = doc_props->recover || (options & XML_PARSE_RECOVER) == XML_PARSE_RECOVER; - xmlInitParser(); - if (mode == DOM_LOAD_FILE) { - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { zend_argument_value_error(1, "must not contain any null bytes"); return NULL; } @@ -1432,24 +1430,28 @@ xmlDocPtr dom_document_parser(zval *id, dom_load_mode mode, const char *source, ctxt->sax->warning = php_libxml_ctx_warning; } - if (validate && ! (options & XML_PARSE_DTDVALID)) { + if (validate) { options |= XML_PARSE_DTDVALID; } - if (resolve_externals && ! (options & XML_PARSE_DTDATTR)) { + if (resolve_externals) { options |= XML_PARSE_DTDATTR; } - if (substitute_ent && ! (options & XML_PARSE_NOENT)) { + if (substitute_ent) { options |= XML_PARSE_NOENT; } - if (keep_blanks == 0 && ! (options & XML_PARSE_NOBLANKS)) { + if (keep_blanks == 0) { options |= XML_PARSE_NOBLANKS; } if (recover) { options |= XML_PARSE_RECOVER; } +#if LIBXML_VERSION >= 21300 + xmlCtxtSetOptions(ctxt, options); +#else php_libxml_sanitize_parse_ctxt_options(ctxt); xmlCtxtUseOptions(ctxt, options); +#endif if (recover) { old_error_reporting = EG(error_reporting); @@ -1595,12 +1597,16 @@ PHP_METHOD(DOMDocument, save) libxml_doc_props const* doc_props = dom_get_doc_props_read_only(intern->document); bool format = doc_props->formatoutput; if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") saveempty = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = 1; + ZEND_DIAGNOSTIC_IGNORED_END } zend_long bytes = intern->document->handlers->dump_doc_to_file(file, docp, format, (const char *) docp->encoding); if (options & LIBXML_SAVE_NOEMPTYTAG) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") xmlSaveNoEmptyTags = saveempty; + ZEND_DIAGNOSTIC_IGNORED_END } if (bytes == -1) { RETURN_FALSE; @@ -1641,10 +1647,14 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry /* 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). */ + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") old_xml_save_no_empty_tags = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = (options & LIBXML_SAVE_NOEMPTYTAG) ? 1 : 0; + ZEND_DIAGNOSTIC_IGNORED_END res = intern->document->handlers->dump_node_to_str(docp, node, format, (const char *) docp->encoding); + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") xmlSaveNoEmptyTags = old_xml_save_no_empty_tags; + ZEND_DIAGNOSTIC_IGNORED_END } else { int converted_options = XML_SAVE_AS_XML; if (options & XML_SAVE_NO_DECL) { @@ -1655,10 +1665,14 @@ static void dom_document_save_xml(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry } /* Save libxml2 global, override its value, and restore after saving. */ + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") old_xml_save_no_empty_tags = xmlSaveNoEmptyTags; xmlSaveNoEmptyTags = (options & LIBXML_SAVE_NOEMPTYTAG) ? 1 : 0; + ZEND_DIAGNOSTIC_IGNORED_END res = intern->document->handlers->dump_doc_to_str(docp, converted_options, (const char *) docp->encoding); + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") xmlSaveNoEmptyTags = old_xml_save_no_empty_tags; + ZEND_DIAGNOSTIC_IGNORED_END } if (!res) { @@ -1862,7 +1876,7 @@ static void dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type) switch (type) { case DOM_LOAD_FILE: - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { PHP_LIBXML_RESTORE_GLOBALS(new_parser_ctxt); zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); @@ -1969,7 +1983,7 @@ static void dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAMETERS, int type switch (type) { case DOM_LOAD_FILE: - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); } @@ -2040,8 +2054,6 @@ PHP_METHOD(DOMDocument, relaxNGValidateSource) #endif -#ifdef LIBXML_HTML_ENABLED - static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ { char *source; @@ -2064,7 +2076,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ } if (mode == DOM_LOAD_FILE) { - if (CHECK_NULL_PATH(source, source_len)) { + if (zend_char_has_nul_byte(source, source_len)) { zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); } @@ -2088,10 +2100,16 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ ctxt->sax->error = php_libxml_ctx_error; ctxt->sax->warning = php_libxml_ctx_warning; } +#if LIBXML_VERSION >= 21400 + if (options) { + htmlCtxtSetOptions(ctxt, (int)options); + } +#else php_libxml_sanitize_parse_ctxt_options(ctxt); if (options) { htmlCtxtUseOptions(ctxt, (int)options); } +#endif htmlParseDocument(ctxt); xmlDocPtr newdoc = ctxt->myDoc; htmlFreeParserCtxt(ctxt); @@ -2234,8 +2252,6 @@ PHP_METHOD(DOMDocument, saveHTML) } /* }}} end dom_document_save_html */ -#endif /* defined(LIBXML_HTML_ENABLED) */ - /* {{{ Register extended class used to create base node type */ static void dom_document_register_node_class(INTERNAL_FUNCTION_PARAMETERS, bool modern) { diff --git a/ext/dom/documenttype.c b/ext/dom/documenttype.c index 63da0306649a9..266c895effb27 100644 --- a/ext/dom/documenttype.c +++ b/ext/dom/documenttype.c @@ -34,7 +34,11 @@ URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core- zend_result dom_documenttype_name_read(dom_object *obj, zval *retval) { DOM_PROP_NODE(xmlDtdPtr, dtdptr, obj); - ZVAL_STRING(retval, dtdptr->name ? (char *) (dtdptr->name) : ""); + if (dtdptr->name) { + ZVAL_STRING(retval, (const char *) dtdptr->name); + } else { + ZVAL_EMPTY_STRING(retval); + } return SUCCESS; } diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index 90e973723f6c6..9134b107925a2 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -127,9 +127,9 @@ static void php_dom_iterator_current_key(zend_object_iterator *iter, zval *key) if (intern->ptr != NULL) { xmlNodePtr curnode = ((php_libxml_node_ptr *)intern->ptr)->node; if (curnode->type == XML_ATTRIBUTE_NODE && php_dom_follow_spec_intern(intern)) { - ZVAL_NEW_STR(key, dom_node_get_node_name_attribute_or_element(curnode, false)); + ZVAL_STR(key, dom_node_get_node_name_attribute_or_element(curnode, false)); } else { - ZVAL_STRINGL(key, (const char *) curnode->name, xmlStrlen(curnode->name)); + ZVAL_STRINGL_FAST(key, (const char *) curnode->name, xmlStrlen(curnode->name)); } } else { ZVAL_NULL(key); diff --git a/ext/dom/element.c b/ext/dom/element.c index dbab931301599..797f215e173d1 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -122,7 +122,7 @@ zend_result dom_element_tag_name_read(dom_object *obj, zval *retval) bool uppercase = php_dom_follow_spec_intern(obj) && php_dom_ns_is_html_and_document_is_html(nodep); zend_string *result = dom_node_get_node_name_attribute_or_element((const xmlNode *) nodep, uppercase); - ZVAL_NEW_STR(retval, result); + ZVAL_STR(retval, result); return SUCCESS; } @@ -180,7 +180,7 @@ zend_result dom_element_class_name_write(dom_object *obj, zval *newval) zval *dom_get_prop_checked_offset(dom_object *obj, uint32_t offset, const char *name) { #if ZEND_DEBUG - zend_string *name_zstr = ZSTR_INIT_LITERAL(name, false); + zend_string *name_zstr = zend_string_init(name, strlen(name), false); const zend_property_info *prop_info = zend_get_property_info(obj->std.ce, name_zstr, 0); zend_string_release_ex(name_zstr, false); ZEND_ASSERT(OBJ_PROP_TO_NUM(prop_info->offset) == offset); @@ -375,7 +375,7 @@ PHP_METHOD(DOMElement, getAttributeNames) } for (xmlAttrPtr attr = nodep->properties; attr; attr = attr->next) { - ZVAL_NEW_STR(&tmp, dom_node_get_node_name_attribute_or_element((const xmlNode *) attr, false)); + ZVAL_STR(&tmp, dom_node_get_node_name_attribute_or_element((const xmlNode *) attr, false)); zend_hash_next_index_insert(ht, &tmp); } } @@ -1019,7 +1019,7 @@ static void dom_set_attribute_ns_legacy(dom_object *intern, xmlNodePtr elemp, ch name_valid = xmlValidateName(BAD_CAST localname, 0); if (name_valid != 0) { errorcode = INVALID_CHARACTER_ERR; - stricterror = 1; + stricterror = true; } else { attr = xmlHasProp(elemp, BAD_CAST localname); if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) { @@ -1210,19 +1210,17 @@ Since: DOM Level 2 */ PHP_METHOD(DOMElement, getAttributeNodeNS) { - zval *id; xmlNodePtr elemp; xmlAttrPtr attrp; dom_object *intern; size_t uri_len, name_len; char *uri, *name; - id = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!s", &uri, &uri_len, &name, &name_len) == FAILURE) { RETURN_THROWS(); } - DOM_GET_OBJ(elemp, id, xmlNodePtr, intern); + DOM_GET_OBJ(elemp, ZEND_THIS, xmlNodePtr, intern); bool follow_spec = php_dom_follow_spec_intern(intern); if (follow_spec && uri_len == 0) { @@ -1239,16 +1237,11 @@ PHP_METHOD(DOMElement, getAttributeNodeNS) /* Keep parent alive, because we're a fake child. */ GC_ADDREF(&intern->std); (void) php_dom_create_fake_namespace_decl(elemp, nsptr, return_value, intern); - } else { - RETURN_NULL(); } - } else { - RETURN_NULL(); } } else { DOM_RET_OBJ((xmlNodePtr) attrp, intern); } - } /* }}} end dom_element_get_attribute_node_ns */ diff --git a/ext/dom/inner_outer_html_mixin.c b/ext/dom/inner_outer_html_mixin.c index eee525cc47a6e..85124d41689af 100644 --- a/ext/dom/inner_outer_html_mixin.c +++ b/ext/dom/inner_outer_html_mixin.c @@ -291,8 +291,12 @@ static xmlNodePtr dom_xml_fragment_parsing_algorithm(dom_object *obj, const xmlN } parser->dict = context_node->doc->dict; +#if LIBXML_VERSION >= 21300 + xmlCtxtSetOptions(parser, XML_PARSE_IGNORE_ENC | XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NO_XXE); +#else php_libxml_sanitize_parse_ctxt_options(parser); xmlCtxtUseOptions(parser, XML_PARSE_IGNORE_ENC | XML_PARSE_NOERROR | XML_PARSE_NOWARNING); +#endif xmlCharEncodingHandlerPtr encoding = xmlFindCharEncodingHandler("UTF-8"); (void) xmlSwitchToEncoding(parser, encoding); diff --git a/ext/dom/node.c b/ext/dom/node.c index 4706b83ff7f11..de80dba202e99 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -52,6 +52,13 @@ zend_string *dom_node_get_node_name_attribute_or_element(const xmlNode *nodep, b if (nodep->ns != NULL && nodep->ns->prefix != NULL) { ret = dom_node_concatenated_name_helper(name_len, (const char *) nodep->name, strlen((const char *) nodep->ns->prefix), (const char *) nodep->ns->prefix); } else { + if (name_len == 1) { + if (uppercase) { + return ZSTR_CHAR(zend_toupper_ascii(*nodep->name)); + } else { + return ZSTR_CHAR((zend_uchar) *nodep->name); + } + } ret = zend_string_init((const char *) nodep->name, name_len, false); } if (uppercase) { @@ -89,7 +96,7 @@ zend_result dom_node_node_name_read(dom_object *obj, zval *retval) uppercase = php_dom_follow_spec_intern(obj) && php_dom_ns_is_html_and_document_is_html(nodep); ZEND_FALLTHROUGH; case XML_ATTRIBUTE_NODE: - ZVAL_NEW_STR(retval, dom_node_get_node_name_attribute_or_element(nodep, uppercase)); + ZVAL_STR(retval, dom_node_get_node_name_attribute_or_element(nodep, uppercase)); break; case XML_NAMESPACE_DECL: { xmlNsPtr ns = nodep->ns; @@ -635,7 +642,7 @@ zend_result dom_node_local_name_read(dom_object *obj, zval *retval) DOM_PROP_NODE(xmlNodePtr, nodep, obj); if (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE || nodep->type == XML_NAMESPACE_DECL) { - ZVAL_STRING(retval, (char *) (nodep->name)); + ZVAL_STRING_FAST(retval, (const char *) (nodep->name)); } else { ZVAL_NULL(retval); } @@ -1463,7 +1470,7 @@ PHP_METHOD(DOMNode, cloneNode) zval *id; xmlNode *n, *node; dom_object *intern; - bool recursive = 0; + bool recursive = false; id = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &recursive) == FAILURE) { @@ -1871,8 +1878,7 @@ static void dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAMETERS, bool modern) case XML_DOCUMENT_FRAG_NODE: case XML_DOCUMENT_TYPE_NODE: case XML_DTD_NODE: - RETURN_NULL(); - break; + return; default: lookupp = nodep->parent; } @@ -1891,8 +1897,6 @@ static void dom_node_lookup_prefix(INTERNAL_FUNCTION_PARAMETERS, bool modern) } } } - - RETURN_NULL(); } PHP_METHOD(DOMNode, lookupPrefix) @@ -2058,16 +2062,14 @@ PHP_METHOD(DOMNode, lookupNamespaceURI) prefix = NULL; } const char *ns_uri = dom_locate_a_namespace(nodep, prefix); - if (ns_uri == NULL) { - RETURN_NULL(); - } else { + if (ns_uri != NULL) { RETURN_STRING(ns_uri); } } else { if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { nodep = xmlDocGetRootElement((xmlDocPtr) nodep); if (nodep == NULL) { - RETURN_NULL(); + return; } } @@ -2076,8 +2078,6 @@ PHP_METHOD(DOMNode, lookupNamespaceURI) RETURN_STRING((char *) nsptr->href); } } - - RETURN_NULL(); } /* }}} end dom_node_lookup_namespace_uri */ @@ -2287,13 +2287,12 @@ static void dom_node_get_node_path(INTERNAL_FUNCTION_PARAMETERS, bool throw) zval *id; xmlNode *nodep; dom_object *intern; - char *value; ZEND_PARSE_PARAMETERS_NONE(); DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern); - value = (char *) xmlGetNodePath(nodep); + char *value = (char *) xmlGetNodePath(nodep); if (value == NULL) { /* This is only possible when an invalid argument is passed (e.g. namespace declaration, but that's not the case for this call site), * or on allocation failure. So in other words, this only happens on allocation failure. */ @@ -2301,7 +2300,6 @@ static void dom_node_get_node_path(INTERNAL_FUNCTION_PARAMETERS, bool throw) php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true); RETURN_THROWS(); } - RETURN_NULL(); } else { RETVAL_STRING(value); xmlFree(value); diff --git a/ext/dom/notation.c b/ext/dom/notation.c index a15fae9ee9d8e..f83b31428e16c 100644 --- a/ext/dom/notation.c +++ b/ext/dom/notation.c @@ -31,8 +31,6 @@ * Since: */ -/* {{{ attribute protos, not implemented yet */ - /* {{{ publicId string readonly=yes URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-54F2B4D0 @@ -73,6 +71,4 @@ zend_result dom_notation_system_id_read(dom_object *obj, zval *retval) /* }}} */ -/* }}} */ - #endif diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index e5239cd17379c..a39e5c1656e9e 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -714,15 +714,17 @@ static zend_object *dom_object_namespace_node_clone_obj(zend_object *zobject) zend_object *clone = dom_objects_namespace_node_new(intern->dom.std.ce); dom_object_namespace_node *clone_intern = php_dom_namespace_node_obj_from_obj(clone); - xmlNodePtr original_node = dom_object_get_node(&intern->dom); - ZEND_ASSERT(original_node->type == XML_NAMESPACE_DECL); - xmlNodePtr cloned_node = php_dom_create_fake_namespace_decl_node_ptr(original_node->parent, original_node->ns); - if (intern->parent_intern) { clone_intern->parent_intern = intern->parent_intern; GC_ADDREF(&clone_intern->parent_intern->std); } - dom_update_refcount_after_clone(&intern->dom, original_node, &clone_intern->dom, cloned_node); + + xmlNodePtr original_node = dom_object_get_node(&intern->dom); + if (original_node != NULL) { + ZEND_ASSERT(original_node->type == XML_NAMESPACE_DECL); + xmlNodePtr cloned_node = php_dom_create_fake_namespace_decl_node_ptr(original_node->parent, original_node->ns); + dom_update_refcount_after_clone(&intern->dom, original_node, &clone_intern->dom, cloned_node); + } zend_objects_clone_members(clone, &intern->dom.std); return clone; @@ -1375,9 +1377,7 @@ PHP_MINFO_FUNCTION(dom) php_info_print_table_row(2, "DOM/XML", "enabled"); php_info_print_table_row(2, "DOM/XML API Version", DOM_API_VERSION); php_info_print_table_row(2, "libxml Version", LIBXML_DOTTED_VERSION); -#ifdef LIBXML_HTML_ENABLED php_info_print_table_row(2, "HTML Support", "enabled"); -#endif #ifdef LIBXML_XPATH_ENABLED php_info_print_table_row(2, "XPath Support", "enabled"); #endif @@ -2715,20 +2715,10 @@ xmlChar *php_dom_libxml_fix_file_path(xmlChar *path) xmlDocPtr php_dom_create_html_doc(void) { -#ifdef LIBXML_HTML_ENABLED xmlDocPtr lxml_doc = htmlNewDocNoDtD(NULL, NULL); if (EXPECTED(lxml_doc)) { lxml_doc->dict = xmlDictCreate(); } -#else - /* If HTML support is not enabled, then htmlNewDocNoDtD() is not available. - * This code mimics the behaviour. */ - xmlDocPtr lxml_doc = xmlNewDoc((const xmlChar *) "1.0"); - if (EXPECTED(lxml_doc)) { - lxml_doc->type = XML_HTML_DOCUMENT_NODE; - lxml_doc->dict = xmlDictCreate(); - } -#endif return lxml_doc; } diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index 34cc4af85c568..e44f74eadeb37 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -34,10 +34,8 @@ extern zend_module_entry dom_module_entry; #include #include #include -#ifdef LIBXML_HTML_ENABLED #include #include -#endif #ifdef LIBXML_XPATH_ENABLED #include #include diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 7236e80b4d247..37a1bea62b627 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -1013,7 +1013,6 @@ public function registerNodeClass(string $baseClass, ?string $extendedClass): tr /** @tentative-return-type */ public function save(string $filename, int $options = 0): int|false {} -#ifdef LIBXML_HTML_ENABLED /** @tentative-return-type */ public function loadHTML(string $source, int $options = 0): bool {} @@ -1025,7 +1024,6 @@ public function saveHTML(?DOMNode $node = null): string|false {} /** @tentative-return-type */ public function saveHTMLFile(string $filename): int|false {} -#endif /** @tentative-return-type */ public function saveXML(?DOMNode $node = null, int $options = 0): string|false {} diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 0eddfd96469fe..1f3f9fd0a8a24 100644 --- a/ext/dom/php_dom_arginfo.h +++ b/ext/dom/php_dom_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 757889c0ca89cc8e9905ba465e0621fe89b6e716 */ + * Stub hash: e3495cb89e4466d9102abb10bf6461989b7c8ba9 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_dom_import_simplexml, 0, 1, DOMAttr|DOMElement, 0) ZEND_ARG_TYPE_INFO(0, node, IS_OBJECT, 0) @@ -404,16 +404,9 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_DOMDocument_save ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -#if defined(LIBXML_HTML_ENABLED) -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DOMDocument_loadHTML, 0, 1, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO(0, source, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") -ZEND_END_ARG_INFO() +#define arginfo_class_DOMDocument_loadHTML arginfo_class_DOMDocument_loadXML -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_DOMDocument_loadHTMLFile, 0, 1, _IS_BOOL, 0) - 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() +#define arginfo_class_DOMDocument_loadHTMLFile arginfo_class_DOMDocument_load ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_DOMDocument_saveHTML, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, node, DOMNode, 1, "null") @@ -422,7 +415,6 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_DOMDocument_saveHTMLFile, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_DOMDocument_saveXML, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, node, DOMNode, 1, "null") @@ -1228,12 +1220,10 @@ ZEND_METHOD(DOMDocument, loadXML); ZEND_METHOD(DOMDocument, normalizeDocument); ZEND_METHOD(DOMDocument, registerNodeClass); ZEND_METHOD(DOMDocument, save); -#if defined(LIBXML_HTML_ENABLED) ZEND_METHOD(DOMDocument, loadHTML); ZEND_METHOD(DOMDocument, loadHTMLFile); ZEND_METHOD(DOMDocument, saveHTML); ZEND_METHOD(DOMDocument, saveHTMLFile); -#endif ZEND_METHOD(DOMDocument, saveXML); #if defined(LIBXML_SCHEMAS_ENABLED) ZEND_METHOD(DOMDocument, schemaValidate); @@ -1496,12 +1486,10 @@ static const zend_function_entry class_DOMDocument_methods[] = { ZEND_ME(DOMDocument, normalizeDocument, arginfo_class_DOMDocument_normalizeDocument, ZEND_ACC_PUBLIC) ZEND_ME(DOMDocument, registerNodeClass, arginfo_class_DOMDocument_registerNodeClass, ZEND_ACC_PUBLIC) ZEND_ME(DOMDocument, save, arginfo_class_DOMDocument_save, ZEND_ACC_PUBLIC) -#if defined(LIBXML_HTML_ENABLED) ZEND_ME(DOMDocument, loadHTML, arginfo_class_DOMDocument_loadHTML, ZEND_ACC_PUBLIC) ZEND_ME(DOMDocument, loadHTMLFile, arginfo_class_DOMDocument_loadHTMLFile, ZEND_ACC_PUBLIC) ZEND_ME(DOMDocument, saveHTML, arginfo_class_DOMDocument_saveHTML, ZEND_ACC_PUBLIC) ZEND_ME(DOMDocument, saveHTMLFile, arginfo_class_DOMDocument_saveHTMLFile, ZEND_ACC_PUBLIC) -#endif ZEND_ME(DOMDocument, saveXML, arginfo_class_DOMDocument_saveXML, ZEND_ACC_PUBLIC) #if defined(LIBXML_SCHEMAS_ENABLED) ZEND_ME(DOMDocument, schemaValidate, arginfo_class_DOMDocument_schemaValidate, ZEND_ACC_PUBLIC) @@ -1902,35 +1890,35 @@ static zend_class_entry *register_class_DOMDocumentType(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_name = zend_string_init("entities", sizeof("entities") - 1, true); zend_string *property_entities_class_DOMNamedNodeMap = zend_string_init("DOMNamedNodeMap", sizeof("DOMNamedNodeMap")-1, 1); zend_declare_typed_property(class_entry, property_entities_name, &property_entities_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_entities_class_DOMNamedNodeMap, 0, 0)); - zend_string_release(property_entities_name); + zend_string_release_ex(property_entities_name, true); 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_name = zend_string_init("notations", sizeof("notations") - 1, true); zend_string *property_notations_class_DOMNamedNodeMap = zend_string_init("DOMNamedNodeMap", sizeof("DOMNamedNodeMap")-1, 1); zend_declare_typed_property(class_entry, property_notations_name, &property_notations_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_notations_class_DOMNamedNodeMap, 0, 0)); - zend_string_release(property_notations_name); + zend_string_release_ex(property_notations_name, true); zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); - zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, 1); + zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, true); zend_declare_typed_property(class_entry, property_publicId_name, &property_publicId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_publicId_name); + zend_string_release_ex(property_publicId_name, true); zval property_systemId_default_value; ZVAL_UNDEF(&property_systemId_default_value); - zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, 1); + zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, true); zend_declare_typed_property(class_entry, property_systemId_name, &property_systemId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_systemId_name); + zend_string_release_ex(property_systemId_name, true); zval property_internalSubset_default_value; ZVAL_UNDEF(&property_internalSubset_default_value); - zend_string *property_internalSubset_name = zend_string_init("internalSubset", sizeof("internalSubset") - 1, 1); + zend_string *property_internalSubset_name = zend_string_init("internalSubset", sizeof("internalSubset") - 1, true); zend_declare_typed_property(class_entry, property_internalSubset_name, &property_internalSubset_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_internalSubset_name); + zend_string_release_ex(property_internalSubset_name, true); return class_entry; } @@ -1984,156 +1972,156 @@ static zend_class_entry *register_class_DOMNode(void) zval const_DOCUMENT_POSITION_DISCONNECTED_value; ZVAL_LONG(&const_DOCUMENT_POSITION_DISCONNECTED_value, 0x1); - zend_string *const_DOCUMENT_POSITION_DISCONNECTED_name = zend_string_init_interned("DOCUMENT_POSITION_DISCONNECTED", sizeof("DOCUMENT_POSITION_DISCONNECTED") - 1, 1); + zend_string *const_DOCUMENT_POSITION_DISCONNECTED_name = zend_string_init_interned("DOCUMENT_POSITION_DISCONNECTED", sizeof("DOCUMENT_POSITION_DISCONNECTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_DISCONNECTED_name, &const_DOCUMENT_POSITION_DISCONNECTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_DISCONNECTED_name); + zend_string_release_ex(const_DOCUMENT_POSITION_DISCONNECTED_name, true); zval const_DOCUMENT_POSITION_PRECEDING_value; ZVAL_LONG(&const_DOCUMENT_POSITION_PRECEDING_value, 0x2); - zend_string *const_DOCUMENT_POSITION_PRECEDING_name = zend_string_init_interned("DOCUMENT_POSITION_PRECEDING", sizeof("DOCUMENT_POSITION_PRECEDING") - 1, 1); + zend_string *const_DOCUMENT_POSITION_PRECEDING_name = zend_string_init_interned("DOCUMENT_POSITION_PRECEDING", sizeof("DOCUMENT_POSITION_PRECEDING") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_PRECEDING_name, &const_DOCUMENT_POSITION_PRECEDING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_PRECEDING_name); + zend_string_release_ex(const_DOCUMENT_POSITION_PRECEDING_name, true); zval const_DOCUMENT_POSITION_FOLLOWING_value; ZVAL_LONG(&const_DOCUMENT_POSITION_FOLLOWING_value, 0x4); - zend_string *const_DOCUMENT_POSITION_FOLLOWING_name = zend_string_init_interned("DOCUMENT_POSITION_FOLLOWING", sizeof("DOCUMENT_POSITION_FOLLOWING") - 1, 1); + zend_string *const_DOCUMENT_POSITION_FOLLOWING_name = zend_string_init_interned("DOCUMENT_POSITION_FOLLOWING", sizeof("DOCUMENT_POSITION_FOLLOWING") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_FOLLOWING_name, &const_DOCUMENT_POSITION_FOLLOWING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_FOLLOWING_name); + zend_string_release_ex(const_DOCUMENT_POSITION_FOLLOWING_name, true); zval const_DOCUMENT_POSITION_CONTAINS_value; ZVAL_LONG(&const_DOCUMENT_POSITION_CONTAINS_value, 0x8); - zend_string *const_DOCUMENT_POSITION_CONTAINS_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINS", sizeof("DOCUMENT_POSITION_CONTAINS") - 1, 1); + zend_string *const_DOCUMENT_POSITION_CONTAINS_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINS", sizeof("DOCUMENT_POSITION_CONTAINS") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_CONTAINS_name, &const_DOCUMENT_POSITION_CONTAINS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_CONTAINS_name); + zend_string_release_ex(const_DOCUMENT_POSITION_CONTAINS_name, true); zval const_DOCUMENT_POSITION_CONTAINED_BY_value; ZVAL_LONG(&const_DOCUMENT_POSITION_CONTAINED_BY_value, 0x10); - zend_string *const_DOCUMENT_POSITION_CONTAINED_BY_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINED_BY", sizeof("DOCUMENT_POSITION_CONTAINED_BY") - 1, 1); + zend_string *const_DOCUMENT_POSITION_CONTAINED_BY_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINED_BY", sizeof("DOCUMENT_POSITION_CONTAINED_BY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_CONTAINED_BY_name, &const_DOCUMENT_POSITION_CONTAINED_BY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_CONTAINED_BY_name); + zend_string_release_ex(const_DOCUMENT_POSITION_CONTAINED_BY_name, true); zval const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_value; ZVAL_LONG(&const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_value, 0x20); - zend_string *const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name = zend_string_init_interned("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", sizeof("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC") - 1, 1); + zend_string *const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name = zend_string_init_interned("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", sizeof("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name, &const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name); + zend_string_release_ex(const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name, true); zval property_nodeName_default_value; ZVAL_UNDEF(&property_nodeName_default_value); - zend_string *property_nodeName_name = zend_string_init("nodeName", sizeof("nodeName") - 1, 1); + zend_string *property_nodeName_name = zend_string_init("nodeName", sizeof("nodeName") - 1, true); zend_declare_typed_property(class_entry, property_nodeName_name, &property_nodeName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_nodeName_name); + zend_string_release_ex(property_nodeName_name, true); zval property_nodeValue_default_value; ZVAL_UNDEF(&property_nodeValue_default_value); - zend_string *property_nodeValue_name = zend_string_init("nodeValue", sizeof("nodeValue") - 1, 1); + zend_string *property_nodeValue_name = zend_string_init("nodeValue", sizeof("nodeValue") - 1, true); zend_declare_typed_property(class_entry, property_nodeValue_name, &property_nodeValue_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_nodeValue_name); + zend_string_release_ex(property_nodeValue_name, true); zval property_nodeType_default_value; ZVAL_UNDEF(&property_nodeType_default_value); - zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, 1); + zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, true); zend_declare_typed_property(class_entry, property_nodeType_name, &property_nodeType_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_nodeType_name); + zend_string_release_ex(property_nodeType_name, true); 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_name = zend_string_init("parentNode", sizeof("parentNode") - 1, true); zend_string *property_parentNode_class_DOMNode = zend_string_init("DOMNode", sizeof("DOMNode")-1, 1); zend_declare_typed_property(class_entry, property_parentNode_name, &property_parentNode_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentNode_class_DOMNode, 0, MAY_BE_NULL)); - zend_string_release(property_parentNode_name); + zend_string_release_ex(property_parentNode_name, true); 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_name = zend_string_init("parentElement", sizeof("parentElement") - 1, true); zend_string *property_parentElement_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_parentElement_name, &property_parentElement_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentElement_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_parentElement_name); + zend_string_release_ex(property_parentElement_name, true); 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_name = zend_string_init("childNodes", sizeof("childNodes") - 1, true); zend_string *property_childNodes_class_DOMNodeList = zend_string_init("DOMNodeList", sizeof("DOMNodeList")-1, 1); zend_declare_typed_property(class_entry, property_childNodes_name, &property_childNodes_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_childNodes_class_DOMNodeList, 0, 0)); - zend_string_release(property_childNodes_name); + zend_string_release_ex(property_childNodes_name, true); 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_name = zend_string_init("firstChild", sizeof("firstChild") - 1, true); zend_string *property_firstChild_class_DOMNode = zend_string_init("DOMNode", sizeof("DOMNode")-1, 1); zend_declare_typed_property(class_entry, property_firstChild_name, &property_firstChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstChild_class_DOMNode, 0, MAY_BE_NULL)); - zend_string_release(property_firstChild_name); + zend_string_release_ex(property_firstChild_name, true); 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_name = zend_string_init("lastChild", sizeof("lastChild") - 1, true); zend_string *property_lastChild_class_DOMNode = zend_string_init("DOMNode", sizeof("DOMNode")-1, 1); zend_declare_typed_property(class_entry, property_lastChild_name, &property_lastChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastChild_class_DOMNode, 0, MAY_BE_NULL)); - zend_string_release(property_lastChild_name); + zend_string_release_ex(property_lastChild_name, true); 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_name = zend_string_init("previousSibling", sizeof("previousSibling") - 1, true); zend_string *property_previousSibling_class_DOMNode = zend_string_init("DOMNode", sizeof("DOMNode")-1, 1); zend_declare_typed_property(class_entry, property_previousSibling_name, &property_previousSibling_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousSibling_class_DOMNode, 0, MAY_BE_NULL)); - zend_string_release(property_previousSibling_name); + zend_string_release_ex(property_previousSibling_name, true); 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_name = zend_string_init("nextSibling", sizeof("nextSibling") - 1, true); zend_string *property_nextSibling_class_DOMNode = zend_string_init("DOMNode", sizeof("DOMNode")-1, 1); zend_declare_typed_property(class_entry, property_nextSibling_name, &property_nextSibling_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextSibling_class_DOMNode, 0, MAY_BE_NULL)); - zend_string_release(property_nextSibling_name); + zend_string_release_ex(property_nextSibling_name, true); 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_name = zend_string_init("attributes", sizeof("attributes") - 1, true); zend_string *property_attributes_class_DOMNamedNodeMap = zend_string_init("DOMNamedNodeMap", sizeof("DOMNamedNodeMap")-1, 1); zend_declare_typed_property(class_entry, property_attributes_name, &property_attributes_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_attributes_class_DOMNamedNodeMap, 0, MAY_BE_NULL)); - zend_string_release(property_attributes_name); + zend_string_release_ex(property_attributes_name, true); zval property_isConnected_default_value; ZVAL_UNDEF(&property_isConnected_default_value); - zend_string *property_isConnected_name = zend_string_init("isConnected", sizeof("isConnected") - 1, 1); + zend_string *property_isConnected_name = zend_string_init("isConnected", sizeof("isConnected") - 1, true); zend_declare_typed_property(class_entry, property_isConnected_name, &property_isConnected_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_isConnected_name); + zend_string_release_ex(property_isConnected_name, true); 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_name = zend_string_init("ownerDocument", sizeof("ownerDocument") - 1, true); zend_string *property_ownerDocument_class_DOMDocument = zend_string_init("DOMDocument", sizeof("DOMDocument")-1, 1); zend_declare_typed_property(class_entry, property_ownerDocument_name, &property_ownerDocument_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerDocument_class_DOMDocument, 0, MAY_BE_NULL)); - zend_string_release(property_ownerDocument_name); + zend_string_release_ex(property_ownerDocument_name, true); zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); - zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, 1); + zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, true); zend_declare_typed_property(class_entry, property_namespaceURI_name, &property_namespaceURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_namespaceURI_name); + zend_string_release_ex(property_namespaceURI_name, true); zval property_prefix_default_value; ZVAL_UNDEF(&property_prefix_default_value); - zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, 1); + zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, true); zend_declare_typed_property(class_entry, property_prefix_name, &property_prefix_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_prefix_name); + zend_string_release_ex(property_prefix_name, true); zval property_localName_default_value; ZVAL_UNDEF(&property_localName_default_value); - zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, 1); + zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, true); zend_declare_typed_property(class_entry, property_localName_name, &property_localName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_localName_name); + zend_string_release_ex(property_localName_name, true); zval property_baseURI_default_value; ZVAL_UNDEF(&property_baseURI_default_value); - zend_string *property_baseURI_name = zend_string_init("baseURI", sizeof("baseURI") - 1, 1); + zend_string *property_baseURI_name = zend_string_init("baseURI", sizeof("baseURI") - 1, true); zend_declare_typed_property(class_entry, property_baseURI_name, &property_baseURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_baseURI_name); + zend_string_release_ex(property_baseURI_name, true); zval property_textContent_default_value; ZVAL_UNDEF(&property_textContent_default_value); - zend_string *property_textContent_name = zend_string_init("textContent", sizeof("textContent") - 1, 1); + zend_string *property_textContent_name = zend_string_init("textContent", sizeof("textContent") - 1, true); zend_declare_typed_property(class_entry, property_textContent_name, &property_textContent_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_textContent_name); + zend_string_release_ex(property_textContent_name, true); return class_entry; } @@ -2147,66 +2135,66 @@ static zend_class_entry *register_class_DOMNameSpaceNode(void) zval property_nodeName_default_value; ZVAL_UNDEF(&property_nodeName_default_value); - zend_string *property_nodeName_name = zend_string_init("nodeName", sizeof("nodeName") - 1, 1); + zend_string *property_nodeName_name = zend_string_init("nodeName", sizeof("nodeName") - 1, true); zend_declare_typed_property(class_entry, property_nodeName_name, &property_nodeName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_nodeName_name); + zend_string_release_ex(property_nodeName_name, true); zval property_nodeValue_default_value; ZVAL_UNDEF(&property_nodeValue_default_value); - zend_string *property_nodeValue_name = zend_string_init("nodeValue", sizeof("nodeValue") - 1, 1); + zend_string *property_nodeValue_name = zend_string_init("nodeValue", sizeof("nodeValue") - 1, true); zend_declare_typed_property(class_entry, property_nodeValue_name, &property_nodeValue_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_nodeValue_name); + zend_string_release_ex(property_nodeValue_name, true); zval property_nodeType_default_value; ZVAL_UNDEF(&property_nodeType_default_value); - zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, 1); + zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, true); zend_declare_typed_property(class_entry, property_nodeType_name, &property_nodeType_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_nodeType_name); + zend_string_release_ex(property_nodeType_name, true); zval property_prefix_default_value; ZVAL_UNDEF(&property_prefix_default_value); - zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, 1); + zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, true); zend_declare_typed_property(class_entry, property_prefix_name, &property_prefix_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_prefix_name); + zend_string_release_ex(property_prefix_name, true); zval property_localName_default_value; ZVAL_UNDEF(&property_localName_default_value); - zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, 1); + zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, true); zend_declare_typed_property(class_entry, property_localName_name, &property_localName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_localName_name); + zend_string_release_ex(property_localName_name, true); zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); - zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, 1); + zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, true); zend_declare_typed_property(class_entry, property_namespaceURI_name, &property_namespaceURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_namespaceURI_name); + zend_string_release_ex(property_namespaceURI_name, true); zval property_isConnected_default_value; ZVAL_UNDEF(&property_isConnected_default_value); - zend_string *property_isConnected_name = zend_string_init("isConnected", sizeof("isConnected") - 1, 1); + zend_string *property_isConnected_name = zend_string_init("isConnected", sizeof("isConnected") - 1, true); zend_declare_typed_property(class_entry, property_isConnected_name, &property_isConnected_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_isConnected_name); + zend_string_release_ex(property_isConnected_name, true); 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_name = zend_string_init("ownerDocument", sizeof("ownerDocument") - 1, true); zend_string *property_ownerDocument_class_DOMDocument = zend_string_init("DOMDocument", sizeof("DOMDocument")-1, 1); zend_declare_typed_property(class_entry, property_ownerDocument_name, &property_ownerDocument_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerDocument_class_DOMDocument, 0, MAY_BE_NULL)); - zend_string_release(property_ownerDocument_name); + zend_string_release_ex(property_ownerDocument_name, true); 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_name = zend_string_init("parentNode", sizeof("parentNode") - 1, true); zend_string *property_parentNode_class_DOMNode = zend_string_init("DOMNode", sizeof("DOMNode")-1, 1); zend_declare_typed_property(class_entry, property_parentNode_name, &property_parentNode_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentNode_class_DOMNode, 0, MAY_BE_NULL)); - zend_string_release(property_parentNode_name); + zend_string_release_ex(property_parentNode_name, true); 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_name = zend_string_init("parentElement", sizeof("parentElement") - 1, true); zend_string *property_parentElement_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_parentElement_name, &property_parentElement_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentElement_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_parentElement_name); + zend_string_release_ex(property_parentElement_name, true); return class_entry; } @@ -2231,23 +2219,23 @@ static zend_class_entry *register_class_DOMDocumentFragment(zend_class_entry *cl 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_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, true); zend_string *property_firstElementChild_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_firstElementChild_name); + zend_string_release_ex(property_firstElementChild_name, true); 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_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, true); zend_string *property_lastElementChild_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_lastElementChild_name); + zend_string_release_ex(property_lastElementChild_name, true); zval property_childElementCount_default_value; ZVAL_UNDEF(&property_childElementCount_default_value); - zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, 1); + zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, true); zend_declare_typed_property(class_entry, property_childElementCount_name, &property_childElementCount_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_childElementCount_name); + zend_string_release_ex(property_childElementCount_name, true); return class_entry; } @@ -2262,9 +2250,9 @@ static zend_class_entry *register_class_DOMNodeList(zend_class_entry *class_entr zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); return class_entry; } @@ -2279,29 +2267,29 @@ static zend_class_entry *register_class_DOMCharacterData(zend_class_entry *class zval property_data_default_value; ZVAL_UNDEF(&property_data_default_value); - zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, 1); + zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, true); zend_declare_typed_property(class_entry, property_data_name, &property_data_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_data_name); + zend_string_release_ex(property_data_name, true); zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); 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_name = zend_string_init("previousElementSibling", sizeof("previousElementSibling") - 1, true); zend_string *property_previousElementSibling_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_previousElementSibling_name, &property_previousElementSibling_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_previousElementSibling_name); + zend_string_release_ex(property_previousElementSibling_name, true); 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_name = zend_string_init("nextElementSibling", sizeof("nextElementSibling") - 1, true); zend_string *property_nextElementSibling_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_nextElementSibling_name, &property_nextElementSibling_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_nextElementSibling_name); + zend_string_release_ex(property_nextElementSibling_name, true); return class_entry; } @@ -2319,9 +2307,9 @@ static zend_class_entry *register_class_DOMAttr(zend_class_entry *class_entry_DO zval property_specified_default_value; ZVAL_UNDEF(&property_specified_default_value); - zend_string *property_specified_name = zend_string_init("specified", sizeof("specified") - 1, 1); + zend_string *property_specified_name = zend_string_init("specified", sizeof("specified") - 1, true); zend_declare_typed_property(class_entry, property_specified_name, &property_specified_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_specified_name); + zend_string_release_ex(property_specified_name, true); zval property_value_default_value; ZVAL_UNDEF(&property_value_default_value); @@ -2329,16 +2317,16 @@ static zend_class_entry *register_class_DOMAttr(zend_class_entry *class_entry_DO 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_name = zend_string_init("ownerElement", sizeof("ownerElement") - 1, true); zend_string *property_ownerElement_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_ownerElement_name, &property_ownerElement_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerElement_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_ownerElement_name); + zend_string_release_ex(property_ownerElement_name, true); zval property_schemaTypeInfo_default_value; ZVAL_UNDEF(&property_schemaTypeInfo_default_value); - zend_string *property_schemaTypeInfo_name = zend_string_init("schemaTypeInfo", sizeof("schemaTypeInfo") - 1, 1); + zend_string *property_schemaTypeInfo_name = zend_string_init("schemaTypeInfo", sizeof("schemaTypeInfo") - 1, true); zend_declare_typed_property(class_entry, property_schemaTypeInfo_name, &property_schemaTypeInfo_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_schemaTypeInfo_name); + zend_string_release_ex(property_schemaTypeInfo_name, true); return class_entry; } @@ -2353,61 +2341,61 @@ static zend_class_entry *register_class_DOMElement(zend_class_entry *class_entry zval property_tagName_default_value; ZVAL_UNDEF(&property_tagName_default_value); - zend_string *property_tagName_name = zend_string_init("tagName", sizeof("tagName") - 1, 1); + zend_string *property_tagName_name = zend_string_init("tagName", sizeof("tagName") - 1, true); zend_declare_typed_property(class_entry, property_tagName_name, &property_tagName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_tagName_name); + zend_string_release_ex(property_tagName_name, true); zval property_className_default_value; ZVAL_UNDEF(&property_className_default_value); - zend_string *property_className_name = zend_string_init("className", sizeof("className") - 1, 1); + zend_string *property_className_name = zend_string_init("className", sizeof("className") - 1, true); zend_declare_typed_property(class_entry, property_className_name, &property_className_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_className_name); + zend_string_release_ex(property_className_name, true); zval property_id_default_value; ZVAL_UNDEF(&property_id_default_value); - zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, 1); + zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, true); zend_declare_typed_property(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_id_name); + zend_string_release_ex(property_id_name, true); zval property_schemaTypeInfo_default_value; ZVAL_UNDEF(&property_schemaTypeInfo_default_value); - zend_string *property_schemaTypeInfo_name = zend_string_init("schemaTypeInfo", sizeof("schemaTypeInfo") - 1, 1); + zend_string *property_schemaTypeInfo_name = zend_string_init("schemaTypeInfo", sizeof("schemaTypeInfo") - 1, true); zend_declare_typed_property(class_entry, property_schemaTypeInfo_name, &property_schemaTypeInfo_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_schemaTypeInfo_name); + zend_string_release_ex(property_schemaTypeInfo_name, true); 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_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, true); zend_string *property_firstElementChild_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_firstElementChild_name); + zend_string_release_ex(property_firstElementChild_name, true); 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_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, true); zend_string *property_lastElementChild_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_lastElementChild_name); + zend_string_release_ex(property_lastElementChild_name, true); zval property_childElementCount_default_value; ZVAL_UNDEF(&property_childElementCount_default_value); - zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, 1); + zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, true); zend_declare_typed_property(class_entry, property_childElementCount_name, &property_childElementCount_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_childElementCount_name); + zend_string_release_ex(property_childElementCount_name, true); 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_name = zend_string_init("previousElementSibling", sizeof("previousElementSibling") - 1, true); zend_string *property_previousElementSibling_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_previousElementSibling_name, &property_previousElementSibling_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_previousElementSibling_name); + zend_string_release_ex(property_previousElementSibling_name, true); 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_name = zend_string_init("nextElementSibling", sizeof("nextElementSibling") - 1, true); zend_string *property_nextElementSibling_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_nextElementSibling_name, &property_nextElementSibling_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_nextElementSibling_name); + zend_string_release_ex(property_nextElementSibling_name, true); return class_entry; } @@ -2422,140 +2410,140 @@ static zend_class_entry *register_class_DOMDocument(zend_class_entry *class_entr 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_name = zend_string_init("doctype", sizeof("doctype") - 1, true); zend_string *property_doctype_class_DOMDocumentType = zend_string_init("DOMDocumentType", sizeof("DOMDocumentType")-1, 1); zend_declare_typed_property(class_entry, property_doctype_name, &property_doctype_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_doctype_class_DOMDocumentType, 0, MAY_BE_NULL)); - zend_string_release(property_doctype_name); + zend_string_release_ex(property_doctype_name, true); 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_name = zend_string_init("implementation", sizeof("implementation") - 1, true); zend_string *property_implementation_class_DOMImplementation = zend_string_init("DOMImplementation", sizeof("DOMImplementation")-1, 1); zend_declare_typed_property(class_entry, property_implementation_name, &property_implementation_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_implementation_class_DOMImplementation, 0, 0)); - zend_string_release(property_implementation_name); + zend_string_release_ex(property_implementation_name, true); 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_name = zend_string_init("documentElement", sizeof("documentElement") - 1, true); zend_string *property_documentElement_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_documentElement_name, &property_documentElement_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_documentElement_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_documentElement_name); + zend_string_release_ex(property_documentElement_name, true); zval property_actualEncoding_default_value; ZVAL_UNDEF(&property_actualEncoding_default_value); - zend_string *property_actualEncoding_name = zend_string_init("actualEncoding", sizeof("actualEncoding") - 1, 1); + zend_string *property_actualEncoding_name = zend_string_init("actualEncoding", sizeof("actualEncoding") - 1, true); zend_declare_typed_property(class_entry, property_actualEncoding_name, &property_actualEncoding_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_actualEncoding_name); + zend_string_release_ex(property_actualEncoding_name, true); zval property_encoding_default_value; ZVAL_UNDEF(&property_encoding_default_value); - zend_string *property_encoding_name = zend_string_init("encoding", sizeof("encoding") - 1, 1); + zend_string *property_encoding_name = zend_string_init("encoding", sizeof("encoding") - 1, true); zend_declare_typed_property(class_entry, property_encoding_name, &property_encoding_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_encoding_name); + zend_string_release_ex(property_encoding_name, true); zval property_xmlEncoding_default_value; ZVAL_UNDEF(&property_xmlEncoding_default_value); - zend_string *property_xmlEncoding_name = zend_string_init("xmlEncoding", sizeof("xmlEncoding") - 1, 1); + zend_string *property_xmlEncoding_name = zend_string_init("xmlEncoding", sizeof("xmlEncoding") - 1, true); zend_declare_typed_property(class_entry, property_xmlEncoding_name, &property_xmlEncoding_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_xmlEncoding_name); + zend_string_release_ex(property_xmlEncoding_name, true); zval property_standalone_default_value; ZVAL_UNDEF(&property_standalone_default_value); - zend_string *property_standalone_name = zend_string_init("standalone", sizeof("standalone") - 1, 1); + zend_string *property_standalone_name = zend_string_init("standalone", sizeof("standalone") - 1, true); zend_declare_typed_property(class_entry, property_standalone_name, &property_standalone_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_standalone_name); + zend_string_release_ex(property_standalone_name, true); zval property_xmlStandalone_default_value; ZVAL_UNDEF(&property_xmlStandalone_default_value); - zend_string *property_xmlStandalone_name = zend_string_init("xmlStandalone", sizeof("xmlStandalone") - 1, 1); + zend_string *property_xmlStandalone_name = zend_string_init("xmlStandalone", sizeof("xmlStandalone") - 1, true); zend_declare_typed_property(class_entry, property_xmlStandalone_name, &property_xmlStandalone_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_xmlStandalone_name); + zend_string_release_ex(property_xmlStandalone_name, true); zval property_version_default_value; ZVAL_UNDEF(&property_version_default_value); - zend_string *property_version_name = zend_string_init("version", sizeof("version") - 1, 1); + zend_string *property_version_name = zend_string_init("version", sizeof("version") - 1, true); zend_declare_typed_property(class_entry, property_version_name, &property_version_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_version_name); + zend_string_release_ex(property_version_name, true); zval property_xmlVersion_default_value; ZVAL_UNDEF(&property_xmlVersion_default_value); - zend_string *property_xmlVersion_name = zend_string_init("xmlVersion", sizeof("xmlVersion") - 1, 1); + zend_string *property_xmlVersion_name = zend_string_init("xmlVersion", sizeof("xmlVersion") - 1, true); zend_declare_typed_property(class_entry, property_xmlVersion_name, &property_xmlVersion_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_xmlVersion_name); + zend_string_release_ex(property_xmlVersion_name, true); zval property_strictErrorChecking_default_value; ZVAL_UNDEF(&property_strictErrorChecking_default_value); - zend_string *property_strictErrorChecking_name = zend_string_init("strictErrorChecking", sizeof("strictErrorChecking") - 1, 1); + zend_string *property_strictErrorChecking_name = zend_string_init("strictErrorChecking", sizeof("strictErrorChecking") - 1, true); zend_declare_typed_property(class_entry, property_strictErrorChecking_name, &property_strictErrorChecking_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_strictErrorChecking_name); + zend_string_release_ex(property_strictErrorChecking_name, true); zval property_documentURI_default_value; ZVAL_UNDEF(&property_documentURI_default_value); - zend_string *property_documentURI_name = zend_string_init("documentURI", sizeof("documentURI") - 1, 1); + zend_string *property_documentURI_name = zend_string_init("documentURI", sizeof("documentURI") - 1, true); zend_declare_typed_property(class_entry, property_documentURI_name, &property_documentURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_documentURI_name); + zend_string_release_ex(property_documentURI_name, true); zval property_config_default_value; ZVAL_UNDEF(&property_config_default_value); - zend_string *property_config_name = zend_string_init("config", sizeof("config") - 1, 1); + zend_string *property_config_name = zend_string_init("config", sizeof("config") - 1, true); zend_declare_typed_property(class_entry, property_config_name, &property_config_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_config_name); + zend_string_release_ex(property_config_name, true); zval property_formatOutput_default_value; ZVAL_UNDEF(&property_formatOutput_default_value); - zend_string *property_formatOutput_name = zend_string_init("formatOutput", sizeof("formatOutput") - 1, 1); + zend_string *property_formatOutput_name = zend_string_init("formatOutput", sizeof("formatOutput") - 1, true); zend_declare_typed_property(class_entry, property_formatOutput_name, &property_formatOutput_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_formatOutput_name); + zend_string_release_ex(property_formatOutput_name, true); zval property_validateOnParse_default_value; ZVAL_UNDEF(&property_validateOnParse_default_value); - zend_string *property_validateOnParse_name = zend_string_init("validateOnParse", sizeof("validateOnParse") - 1, 1); + zend_string *property_validateOnParse_name = zend_string_init("validateOnParse", sizeof("validateOnParse") - 1, true); zend_declare_typed_property(class_entry, property_validateOnParse_name, &property_validateOnParse_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_validateOnParse_name); + zend_string_release_ex(property_validateOnParse_name, true); zval property_resolveExternals_default_value; ZVAL_UNDEF(&property_resolveExternals_default_value); - zend_string *property_resolveExternals_name = zend_string_init("resolveExternals", sizeof("resolveExternals") - 1, 1); + zend_string *property_resolveExternals_name = zend_string_init("resolveExternals", sizeof("resolveExternals") - 1, true); zend_declare_typed_property(class_entry, property_resolveExternals_name, &property_resolveExternals_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_resolveExternals_name); + zend_string_release_ex(property_resolveExternals_name, true); zval property_preserveWhiteSpace_default_value; ZVAL_UNDEF(&property_preserveWhiteSpace_default_value); - zend_string *property_preserveWhiteSpace_name = zend_string_init("preserveWhiteSpace", sizeof("preserveWhiteSpace") - 1, 1); + zend_string *property_preserveWhiteSpace_name = zend_string_init("preserveWhiteSpace", sizeof("preserveWhiteSpace") - 1, true); zend_declare_typed_property(class_entry, property_preserveWhiteSpace_name, &property_preserveWhiteSpace_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_preserveWhiteSpace_name); + zend_string_release_ex(property_preserveWhiteSpace_name, true); zval property_recover_default_value; ZVAL_UNDEF(&property_recover_default_value); - zend_string *property_recover_name = zend_string_init("recover", sizeof("recover") - 1, 1); + zend_string *property_recover_name = zend_string_init("recover", sizeof("recover") - 1, true); zend_declare_typed_property(class_entry, property_recover_name, &property_recover_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_recover_name); + zend_string_release_ex(property_recover_name, true); zval property_substituteEntities_default_value; ZVAL_UNDEF(&property_substituteEntities_default_value); - zend_string *property_substituteEntities_name = zend_string_init("substituteEntities", sizeof("substituteEntities") - 1, 1); + zend_string *property_substituteEntities_name = zend_string_init("substituteEntities", sizeof("substituteEntities") - 1, true); zend_declare_typed_property(class_entry, property_substituteEntities_name, &property_substituteEntities_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_substituteEntities_name); + zend_string_release_ex(property_substituteEntities_name, true); 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_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, true); zend_string *property_firstElementChild_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_firstElementChild_name, &property_firstElementChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_firstElementChild_name); + zend_string_release_ex(property_firstElementChild_name, true); 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_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, true); zend_string *property_lastElementChild_class_DOMElement = zend_string_init("DOMElement", sizeof("DOMElement")-1, 1); zend_declare_typed_property(class_entry, property_lastElementChild_name, &property_lastElementChild_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_DOMElement, 0, MAY_BE_NULL)); - zend_string_release(property_lastElementChild_name); + zend_string_release_ex(property_lastElementChild_name, true); zval property_childElementCount_default_value; ZVAL_UNDEF(&property_childElementCount_default_value); - zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, 1); + zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, true); zend_declare_typed_property(class_entry, property_childElementCount_name, &property_childElementCount_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_childElementCount_name); + zend_string_release_ex(property_childElementCount_name, true); return class_entry; } @@ -2584,9 +2572,9 @@ static zend_class_entry *register_class_DOMText(zend_class_entry *class_entry_DO zval property_wholeText_default_value; ZVAL_UNDEF(&property_wholeText_default_value); - zend_string *property_wholeText_name = zend_string_init("wholeText", sizeof("wholeText") - 1, 1); + zend_string *property_wholeText_name = zend_string_init("wholeText", sizeof("wholeText") - 1, true); zend_declare_typed_property(class_entry, property_wholeText_name, &property_wholeText_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_wholeText_name); + zend_string_release_ex(property_wholeText_name, true); return class_entry; } @@ -2601,9 +2589,9 @@ static zend_class_entry *register_class_DOMNamedNodeMap(zend_class_entry *class_ zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); return class_entry; } @@ -2617,39 +2605,39 @@ static zend_class_entry *register_class_DOMEntity(zend_class_entry *class_entry_ zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); - zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, 1); + zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, true); zend_declare_typed_property(class_entry, property_publicId_name, &property_publicId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_publicId_name); + zend_string_release_ex(property_publicId_name, true); zval property_systemId_default_value; ZVAL_UNDEF(&property_systemId_default_value); - zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, 1); + zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, true); zend_declare_typed_property(class_entry, property_systemId_name, &property_systemId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_systemId_name); + zend_string_release_ex(property_systemId_name, true); zval property_notationName_default_value; ZVAL_UNDEF(&property_notationName_default_value); - zend_string *property_notationName_name = zend_string_init("notationName", sizeof("notationName") - 1, 1); + zend_string *property_notationName_name = zend_string_init("notationName", sizeof("notationName") - 1, true); zend_declare_typed_property(class_entry, property_notationName_name, &property_notationName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_notationName_name); + zend_string_release_ex(property_notationName_name, true); zval property_actualEncoding_default_value; ZVAL_UNDEF(&property_actualEncoding_default_value); - zend_string *property_actualEncoding_name = zend_string_init("actualEncoding", sizeof("actualEncoding") - 1, 1); + zend_string *property_actualEncoding_name = zend_string_init("actualEncoding", sizeof("actualEncoding") - 1, true); zend_declare_typed_property(class_entry, property_actualEncoding_name, &property_actualEncoding_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_actualEncoding_name); + zend_string_release_ex(property_actualEncoding_name, true); zval property_encoding_default_value; ZVAL_UNDEF(&property_encoding_default_value); - zend_string *property_encoding_name = zend_string_init("encoding", sizeof("encoding") - 1, 1); + zend_string *property_encoding_name = zend_string_init("encoding", sizeof("encoding") - 1, true); zend_declare_typed_property(class_entry, property_encoding_name, &property_encoding_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_encoding_name); + zend_string_release_ex(property_encoding_name, true); zval property_version_default_value; ZVAL_UNDEF(&property_version_default_value); - zend_string *property_version_name = zend_string_init("version", sizeof("version") - 1, 1); + zend_string *property_version_name = zend_string_init("version", sizeof("version") - 1, true); zend_declare_typed_property(class_entry, property_version_name, &property_version_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_version_name); + zend_string_release_ex(property_version_name, true); return class_entry; } @@ -2673,15 +2661,15 @@ static zend_class_entry *register_class_DOMNotation(zend_class_entry *class_entr zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); - zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, 1); + zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, true); zend_declare_typed_property(class_entry, property_publicId_name, &property_publicId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_publicId_name); + zend_string_release_ex(property_publicId_name, true); zval property_systemId_default_value; ZVAL_UNDEF(&property_systemId_default_value); - zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, 1); + zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, true); zend_declare_typed_property(class_entry, property_systemId_name, &property_systemId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_systemId_name); + zend_string_release_ex(property_systemId_name, true); return class_entry; } @@ -2695,15 +2683,15 @@ static zend_class_entry *register_class_DOMProcessingInstruction(zend_class_entr zval property_target_default_value; ZVAL_UNDEF(&property_target_default_value); - zend_string *property_target_name = zend_string_init("target", sizeof("target") - 1, 1); + zend_string *property_target_name = zend_string_init("target", sizeof("target") - 1, true); zend_declare_typed_property(class_entry, property_target_name, &property_target_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_target_name); + zend_string_release_ex(property_target_name, true); zval property_data_default_value; ZVAL_UNDEF(&property_data_default_value); - zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, 1); + zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, true); zend_declare_typed_property(class_entry, property_data_name, &property_data_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_data_name); + zend_string_release_ex(property_data_name, true); return class_entry; } @@ -2718,16 +2706,16 @@ static zend_class_entry *register_class_DOMXPath(void) 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_name = zend_string_init("document", sizeof("document") - 1, true); zend_string *property_document_class_DOMDocument = zend_string_init("DOMDocument", sizeof("DOMDocument")-1, 1); zend_declare_typed_property(class_entry, property_document_name, &property_document_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_document_class_DOMDocument, 0, 0)); - zend_string_release(property_document_name); + zend_string_release_ex(property_document_name, true); zval property_registerNodeNamespaces_default_value; ZVAL_UNDEF(&property_registerNodeNamespaces_default_value); - zend_string *property_registerNodeNamespaces_name = zend_string_init("registerNodeNamespaces", sizeof("registerNodeNamespaces") - 1, 1); + zend_string *property_registerNodeNamespaces_name = zend_string_init("registerNodeNamespaces", sizeof("registerNodeNamespaces") - 1, true); zend_declare_typed_property(class_entry, property_registerNodeNamespaces_name, &property_registerNodeNamespaces_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_registerNodeNamespaces_name); + zend_string_release_ex(property_registerNodeNamespaces_name, true); return class_entry; } @@ -2772,131 +2760,131 @@ static zend_class_entry *register_class_Dom_Node(void) zval const_DOCUMENT_POSITION_DISCONNECTED_value; ZVAL_LONG(&const_DOCUMENT_POSITION_DISCONNECTED_value, 0x1); - zend_string *const_DOCUMENT_POSITION_DISCONNECTED_name = zend_string_init_interned("DOCUMENT_POSITION_DISCONNECTED", sizeof("DOCUMENT_POSITION_DISCONNECTED") - 1, 1); + zend_string *const_DOCUMENT_POSITION_DISCONNECTED_name = zend_string_init_interned("DOCUMENT_POSITION_DISCONNECTED", sizeof("DOCUMENT_POSITION_DISCONNECTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_DISCONNECTED_name, &const_DOCUMENT_POSITION_DISCONNECTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_DISCONNECTED_name); + zend_string_release_ex(const_DOCUMENT_POSITION_DISCONNECTED_name, true); zval const_DOCUMENT_POSITION_PRECEDING_value; ZVAL_LONG(&const_DOCUMENT_POSITION_PRECEDING_value, 0x2); - zend_string *const_DOCUMENT_POSITION_PRECEDING_name = zend_string_init_interned("DOCUMENT_POSITION_PRECEDING", sizeof("DOCUMENT_POSITION_PRECEDING") - 1, 1); + zend_string *const_DOCUMENT_POSITION_PRECEDING_name = zend_string_init_interned("DOCUMENT_POSITION_PRECEDING", sizeof("DOCUMENT_POSITION_PRECEDING") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_PRECEDING_name, &const_DOCUMENT_POSITION_PRECEDING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_PRECEDING_name); + zend_string_release_ex(const_DOCUMENT_POSITION_PRECEDING_name, true); zval const_DOCUMENT_POSITION_FOLLOWING_value; ZVAL_LONG(&const_DOCUMENT_POSITION_FOLLOWING_value, 0x4); - zend_string *const_DOCUMENT_POSITION_FOLLOWING_name = zend_string_init_interned("DOCUMENT_POSITION_FOLLOWING", sizeof("DOCUMENT_POSITION_FOLLOWING") - 1, 1); + zend_string *const_DOCUMENT_POSITION_FOLLOWING_name = zend_string_init_interned("DOCUMENT_POSITION_FOLLOWING", sizeof("DOCUMENT_POSITION_FOLLOWING") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_FOLLOWING_name, &const_DOCUMENT_POSITION_FOLLOWING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_FOLLOWING_name); + zend_string_release_ex(const_DOCUMENT_POSITION_FOLLOWING_name, true); zval const_DOCUMENT_POSITION_CONTAINS_value; ZVAL_LONG(&const_DOCUMENT_POSITION_CONTAINS_value, 0x8); - zend_string *const_DOCUMENT_POSITION_CONTAINS_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINS", sizeof("DOCUMENT_POSITION_CONTAINS") - 1, 1); + zend_string *const_DOCUMENT_POSITION_CONTAINS_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINS", sizeof("DOCUMENT_POSITION_CONTAINS") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_CONTAINS_name, &const_DOCUMENT_POSITION_CONTAINS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_CONTAINS_name); + zend_string_release_ex(const_DOCUMENT_POSITION_CONTAINS_name, true); zval const_DOCUMENT_POSITION_CONTAINED_BY_value; ZVAL_LONG(&const_DOCUMENT_POSITION_CONTAINED_BY_value, 0x10); - zend_string *const_DOCUMENT_POSITION_CONTAINED_BY_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINED_BY", sizeof("DOCUMENT_POSITION_CONTAINED_BY") - 1, 1); + zend_string *const_DOCUMENT_POSITION_CONTAINED_BY_name = zend_string_init_interned("DOCUMENT_POSITION_CONTAINED_BY", sizeof("DOCUMENT_POSITION_CONTAINED_BY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_CONTAINED_BY_name, &const_DOCUMENT_POSITION_CONTAINED_BY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_CONTAINED_BY_name); + zend_string_release_ex(const_DOCUMENT_POSITION_CONTAINED_BY_name, true); zval const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_value; ZVAL_LONG(&const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_value, 0x20); - zend_string *const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name = zend_string_init_interned("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", sizeof("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC") - 1, 1); + zend_string *const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name = zend_string_init_interned("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", sizeof("DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name, &const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name); + zend_string_release_ex(const_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC_name, true); zval property_nodeType_default_value; ZVAL_UNDEF(&property_nodeType_default_value); - zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, 1); + zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, true); zend_declare_typed_property(class_entry, property_nodeType_name, &property_nodeType_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_nodeType_name); + zend_string_release_ex(property_nodeType_name, true); zval property_nodeName_default_value; ZVAL_UNDEF(&property_nodeName_default_value); - zend_string *property_nodeName_name = zend_string_init("nodeName", sizeof("nodeName") - 1, 1); + zend_string *property_nodeName_name = zend_string_init("nodeName", sizeof("nodeName") - 1, true); zend_declare_typed_property(class_entry, property_nodeName_name, &property_nodeName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_nodeName_name); + zend_string_release_ex(property_nodeName_name, true); zval property_baseURI_default_value; ZVAL_UNDEF(&property_baseURI_default_value); - zend_string *property_baseURI_name = zend_string_init("baseURI", sizeof("baseURI") - 1, 1); + zend_string *property_baseURI_name = zend_string_init("baseURI", sizeof("baseURI") - 1, true); zend_declare_typed_property(class_entry, property_baseURI_name, &property_baseURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_baseURI_name); + zend_string_release_ex(property_baseURI_name, true); zval property_isConnected_default_value; ZVAL_UNDEF(&property_isConnected_default_value); - zend_string *property_isConnected_name = zend_string_init("isConnected", sizeof("isConnected") - 1, 1); + zend_string *property_isConnected_name = zend_string_init("isConnected", sizeof("isConnected") - 1, true); zend_declare_typed_property(class_entry, property_isConnected_name, &property_isConnected_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_isConnected_name); + zend_string_release_ex(property_isConnected_name, true); 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_name = zend_string_init("ownerDocument", sizeof("ownerDocument") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerDocument_class_Dom_Document, 0, MAY_BE_NULL)); - zend_string_release(property_ownerDocument_name); + zend_string_release_ex(property_ownerDocument_name, true); 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_name = zend_string_init("parentNode", sizeof("parentNode") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentNode_class_Dom_Node, 0, MAY_BE_NULL)); - zend_string_release(property_parentNode_name); + zend_string_release_ex(property_parentNode_name, true); 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_name = zend_string_init("parentElement", sizeof("parentElement") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_parentElement_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_parentElement_name); + zend_string_release_ex(property_parentElement_name, true); 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_name = zend_string_init("childNodes", sizeof("childNodes") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_childNodes_class_Dom_NodeList, 0, 0)); - zend_string_release(property_childNodes_name); + zend_string_release_ex(property_childNodes_name, true); 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_name = zend_string_init("firstChild", sizeof("firstChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstChild_class_Dom_Node, 0, MAY_BE_NULL)); - zend_string_release(property_firstChild_name); + zend_string_release_ex(property_firstChild_name, true); 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_name = zend_string_init("lastChild", sizeof("lastChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastChild_class_Dom_Node, 0, MAY_BE_NULL)); - zend_string_release(property_lastChild_name); + zend_string_release_ex(property_lastChild_name, true); 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_name = zend_string_init("previousSibling", sizeof("previousSibling") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousSibling_class_Dom_Node, 0, MAY_BE_NULL)); - zend_string_release(property_previousSibling_name); + zend_string_release_ex(property_previousSibling_name, true); 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_name = zend_string_init("nextSibling", sizeof("nextSibling") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextSibling_class_Dom_Node, 0, MAY_BE_NULL)); - zend_string_release(property_nextSibling_name); + zend_string_release_ex(property_nextSibling_name, true); zval property_nodeValue_default_value; ZVAL_UNDEF(&property_nodeValue_default_value); - zend_string *property_nodeValue_name = zend_string_init("nodeValue", sizeof("nodeValue") - 1, 1); + zend_string *property_nodeValue_name = zend_string_init("nodeValue", sizeof("nodeValue") - 1, true); zend_declare_typed_property(class_entry, property_nodeValue_name, &property_nodeValue_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_nodeValue_name); + zend_string_release_ex(property_nodeValue_name, true); zval property_textContent_default_value; ZVAL_UNDEF(&property_textContent_default_value); - zend_string *property_textContent_name = zend_string_init("textContent", sizeof("textContent") - 1, 1); + zend_string *property_textContent_name = zend_string_init("textContent", sizeof("textContent") - 1, true); zend_declare_typed_property(class_entry, property_textContent_name, &property_textContent_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_textContent_name); + zend_string_release_ex(property_textContent_name, true); return class_entry; } @@ -2911,9 +2899,9 @@ static zend_class_entry *register_class_Dom_NodeList(zend_class_entry *class_ent zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); return class_entry; } @@ -2928,9 +2916,9 @@ static zend_class_entry *register_class_Dom_NamedNodeMap(zend_class_entry *class zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); return class_entry; } @@ -2945,9 +2933,9 @@ static zend_class_entry *register_class_Dom_DtdNamedNodeMap(zend_class_entry *cl zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); return class_entry; } @@ -2962,9 +2950,9 @@ static zend_class_entry *register_class_Dom_HTMLCollection(zend_class_entry *cla zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); return class_entry; } @@ -3006,112 +2994,112 @@ static zend_class_entry *register_class_Dom_Element(zend_class_entry *class_entr zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); - zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, 1); + zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, true); zend_declare_typed_property(class_entry, property_namespaceURI_name, &property_namespaceURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_namespaceURI_name); + zend_string_release_ex(property_namespaceURI_name, true); zval property_prefix_default_value; ZVAL_UNDEF(&property_prefix_default_value); - zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, 1); + zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, true); zend_declare_typed_property(class_entry, property_prefix_name, &property_prefix_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_prefix_name); + zend_string_release_ex(property_prefix_name, true); zval property_localName_default_value; ZVAL_UNDEF(&property_localName_default_value); - zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, 1); + zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, true); zend_declare_typed_property(class_entry, property_localName_name, &property_localName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_localName_name); + zend_string_release_ex(property_localName_name, true); zval property_tagName_default_value; ZVAL_UNDEF(&property_tagName_default_value); - zend_string *property_tagName_name = zend_string_init("tagName", sizeof("tagName") - 1, 1); + zend_string *property_tagName_name = zend_string_init("tagName", sizeof("tagName") - 1, true); zend_declare_typed_property(class_entry, property_tagName_name, &property_tagName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_tagName_name); + zend_string_release_ex(property_tagName_name, true); zval property_children_default_value; ZVAL_UNDEF(&property_children_default_value); - zend_string *property_children_name = zend_string_init("children", sizeof("children") - 1, 1); + zend_string *property_children_name = zend_string_init("children", sizeof("children") - 1, true); zend_string *property_children_class_Dom_HTMLCollection = zend_string_init("Dom\\HTMLCollection", sizeof("Dom\\HTMLCollection")-1, 1); zend_declare_typed_property(class_entry, property_children_name, &property_children_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_children_class_Dom_HTMLCollection, 0, 0)); - zend_string_release(property_children_name); + zend_string_release_ex(property_children_name, true); 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_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_firstElementChild_name); + zend_string_release_ex(property_firstElementChild_name, true); 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_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_lastElementChild_name); + zend_string_release_ex(property_lastElementChild_name, true); zval property_childElementCount_default_value; ZVAL_UNDEF(&property_childElementCount_default_value); - zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, 1); + zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, true); zend_declare_typed_property(class_entry, property_childElementCount_name, &property_childElementCount_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_childElementCount_name); + zend_string_release_ex(property_childElementCount_name, true); 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_name = zend_string_init("previousElementSibling", sizeof("previousElementSibling") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_previousElementSibling_name); + zend_string_release_ex(property_previousElementSibling_name, true); 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_name = zend_string_init("nextElementSibling", sizeof("nextElementSibling") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_nextElementSibling_name); + zend_string_release_ex(property_nextElementSibling_name, true); zval property_id_default_value; ZVAL_UNDEF(&property_id_default_value); - zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, 1); + zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, true); zend_declare_typed_property(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_id_name); + zend_string_release_ex(property_id_name, true); zval property_className_default_value; ZVAL_UNDEF(&property_className_default_value); - zend_string *property_className_name = zend_string_init("className", sizeof("className") - 1, 1); + zend_string *property_className_name = zend_string_init("className", sizeof("className") - 1, true); zend_declare_typed_property(class_entry, property_className_name, &property_className_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_className_name); + zend_string_release_ex(property_className_name, true); zval property_classList_default_value; ZVAL_UNDEF(&property_classList_default_value); - zend_string *property_classList_name = zend_string_init("classList", sizeof("classList") - 1, 1); + zend_string *property_classList_name = zend_string_init("classList", sizeof("classList") - 1, true); zend_string *property_classList_class_Dom_TokenList = zend_string_init("Dom\\TokenList", sizeof("Dom\\TokenList")-1, 1); zend_declare_typed_property(class_entry, property_classList_name, &property_classList_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_classList_class_Dom_TokenList, 0, 0)); - zend_string_release(property_classList_name); + zend_string_release_ex(property_classList_name, true); 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_name = zend_string_init("attributes", sizeof("attributes") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_attributes_class_Dom_NamedNodeMap, 0, 0)); - zend_string_release(property_attributes_name); + zend_string_release_ex(property_attributes_name, true); zval property_innerHTML_default_value; ZVAL_UNDEF(&property_innerHTML_default_value); - zend_string *property_innerHTML_name = zend_string_init("innerHTML", sizeof("innerHTML") - 1, 1); + zend_string *property_innerHTML_name = zend_string_init("innerHTML", sizeof("innerHTML") - 1, true); zend_declare_typed_property(class_entry, property_innerHTML_name, &property_innerHTML_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_innerHTML_name); + zend_string_release_ex(property_innerHTML_name, true); zval property_outerHTML_default_value; ZVAL_UNDEF(&property_outerHTML_default_value); - zend_string *property_outerHTML_name = zend_string_init("outerHTML", sizeof("outerHTML") - 1, 1); + zend_string *property_outerHTML_name = zend_string_init("outerHTML", sizeof("outerHTML") - 1, true); zend_declare_typed_property(class_entry, property_outerHTML_name, &property_outerHTML_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_outerHTML_name); + zend_string_release_ex(property_outerHTML_name, true); zval property_substitutedNodeValue_default_value; ZVAL_UNDEF(&property_substitutedNodeValue_default_value); - zend_string *property_substitutedNodeValue_name = zend_string_init("substitutedNodeValue", sizeof("substitutedNodeValue") - 1, 1); + zend_string *property_substitutedNodeValue_name = zend_string_init("substitutedNodeValue", sizeof("substitutedNodeValue") - 1, true); zend_declare_typed_property(class_entry, property_substitutedNodeValue_name, &property_substitutedNodeValue_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_substitutedNodeValue_name); + zend_string_release_ex(property_substitutedNodeValue_name, true); return class_entry; } @@ -3135,21 +3123,21 @@ static zend_class_entry *register_class_Dom_Attr(zend_class_entry *class_entry_D zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); - zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, 1); + zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, true); zend_declare_typed_property(class_entry, property_namespaceURI_name, &property_namespaceURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_namespaceURI_name); + zend_string_release_ex(property_namespaceURI_name, true); zval property_prefix_default_value; ZVAL_UNDEF(&property_prefix_default_value); - zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, 1); + zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, true); zend_declare_typed_property(class_entry, property_prefix_name, &property_prefix_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_prefix_name); + zend_string_release_ex(property_prefix_name, true); zval property_localName_default_value; ZVAL_UNDEF(&property_localName_default_value); - zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, 1); + zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, true); zend_declare_typed_property(class_entry, property_localName_name, &property_localName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_localName_name); + zend_string_release_ex(property_localName_name, true); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); @@ -3161,16 +3149,16 @@ 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_name = zend_string_init("ownerElement", sizeof("ownerElement") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_ownerElement_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_ownerElement_name); + zend_string_release_ex(property_ownerElement_name, true); zval property_specified_default_value; ZVAL_UNDEF(&property_specified_default_value); - zend_string *property_specified_name = zend_string_init("specified", sizeof("specified") - 1, 1); + zend_string *property_specified_name = zend_string_init("specified", sizeof("specified") - 1, true); zend_declare_typed_property(class_entry, property_specified_name, &property_specified_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_specified_name); + zend_string_release_ex(property_specified_name, true); return class_entry; } @@ -3185,29 +3173,29 @@ static zend_class_entry *register_class_Dom_CharacterData(zend_class_entry *clas 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_name = zend_string_init("previousElementSibling", sizeof("previousElementSibling") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_previousElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_previousElementSibling_name); + zend_string_release_ex(property_previousElementSibling_name, true); 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_name = zend_string_init("nextElementSibling", sizeof("nextElementSibling") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_nextElementSibling_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_nextElementSibling_name); + zend_string_release_ex(property_nextElementSibling_name, true); zval property_data_default_value; ZVAL_UNDEF(&property_data_default_value); - zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, 1); + zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, true); zend_declare_typed_property(class_entry, property_data_name, &property_data_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_data_name); + zend_string_release_ex(property_data_name, true); zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); return class_entry; } @@ -3221,9 +3209,9 @@ static zend_class_entry *register_class_Dom_Text(zend_class_entry *class_entry_D zval property_wholeText_default_value; ZVAL_UNDEF(&property_wholeText_default_value); - zend_string *property_wholeText_name = zend_string_init("wholeText", sizeof("wholeText") - 1, 1); + zend_string *property_wholeText_name = zend_string_init("wholeText", sizeof("wholeText") - 1, true); zend_declare_typed_property(class_entry, property_wholeText_name, &property_wholeText_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_wholeText_name); + zend_string_release_ex(property_wholeText_name, true); return class_entry; } @@ -3247,9 +3235,9 @@ static zend_class_entry *register_class_Dom_ProcessingInstruction(zend_class_ent zval property_target_default_value; ZVAL_UNDEF(&property_target_default_value); - zend_string *property_target_name = zend_string_init("target", sizeof("target") - 1, 1); + zend_string *property_target_name = zend_string_init("target", sizeof("target") - 1, true); zend_declare_typed_property(class_entry, property_target_name, &property_target_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_target_name); + zend_string_release_ex(property_target_name, true); return class_entry; } @@ -3278,35 +3266,35 @@ 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_name = zend_string_init("entities", sizeof("entities") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_entities_class_Dom_DtdNamedNodeMap, 0, 0)); - zend_string_release(property_entities_name); + zend_string_release_ex(property_entities_name, true); 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_name = zend_string_init("notations", sizeof("notations") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_notations_class_Dom_DtdNamedNodeMap, 0, 0)); - zend_string_release(property_notations_name); + zend_string_release_ex(property_notations_name, true); zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); - zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, 1); + zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, true); zend_declare_typed_property(class_entry, property_publicId_name, &property_publicId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_publicId_name); + zend_string_release_ex(property_publicId_name, true); zval property_systemId_default_value; ZVAL_UNDEF(&property_systemId_default_value); - zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, 1); + zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, true); zend_declare_typed_property(class_entry, property_systemId_name, &property_systemId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_systemId_name); + zend_string_release_ex(property_systemId_name, true); zval property_internalSubset_default_value; ZVAL_UNDEF(&property_internalSubset_default_value); - zend_string *property_internalSubset_name = zend_string_init("internalSubset", sizeof("internalSubset") - 1, 1); + zend_string *property_internalSubset_name = zend_string_init("internalSubset", sizeof("internalSubset") - 1, true); zend_declare_typed_property(class_entry, property_internalSubset_name, &property_internalSubset_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_internalSubset_name); + zend_string_release_ex(property_internalSubset_name, true); return class_entry; } @@ -3321,30 +3309,30 @@ static zend_class_entry *register_class_Dom_DocumentFragment(zend_class_entry *c zval property_children_default_value; ZVAL_UNDEF(&property_children_default_value); - zend_string *property_children_name = zend_string_init("children", sizeof("children") - 1, 1); + zend_string *property_children_name = zend_string_init("children", sizeof("children") - 1, true); zend_string *property_children_class_Dom_HTMLCollection = zend_string_init("Dom\\HTMLCollection", sizeof("Dom\\HTMLCollection")-1, 1); zend_declare_typed_property(class_entry, property_children_name, &property_children_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_children_class_Dom_HTMLCollection, 0, 0)); - zend_string_release(property_children_name); + zend_string_release_ex(property_children_name, true); 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_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_firstElementChild_name); + zend_string_release_ex(property_firstElementChild_name, true); 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_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_lastElementChild_name); + zend_string_release_ex(property_lastElementChild_name, true); zval property_childElementCount_default_value; ZVAL_UNDEF(&property_childElementCount_default_value); - zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, 1); + zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, true); zend_declare_typed_property(class_entry, property_childElementCount_name, &property_childElementCount_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_childElementCount_name); + zend_string_release_ex(property_childElementCount_name, true); return class_entry; } @@ -3358,21 +3346,21 @@ static zend_class_entry *register_class_Dom_Entity(zend_class_entry *class_entry zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); - zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, 1); + zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, true); zend_declare_typed_property(class_entry, property_publicId_name, &property_publicId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_publicId_name); + zend_string_release_ex(property_publicId_name, true); zval property_systemId_default_value; ZVAL_UNDEF(&property_systemId_default_value); - zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, 1); + zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, true); zend_declare_typed_property(class_entry, property_systemId_name, &property_systemId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_systemId_name); + zend_string_release_ex(property_systemId_name, true); zval property_notationName_default_value; ZVAL_UNDEF(&property_notationName_default_value); - zend_string *property_notationName_name = zend_string_init("notationName", sizeof("notationName") - 1, 1); + zend_string *property_notationName_name = zend_string_init("notationName", sizeof("notationName") - 1, true); zend_declare_typed_property(class_entry, property_notationName_name, &property_notationName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_notationName_name); + zend_string_release_ex(property_notationName_name, true); return class_entry; } @@ -3396,15 +3384,15 @@ static zend_class_entry *register_class_Dom_Notation(zend_class_entry *class_ent zval property_publicId_default_value; ZVAL_UNDEF(&property_publicId_default_value); - zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, 1); + zend_string *property_publicId_name = zend_string_init("publicId", sizeof("publicId") - 1, true); zend_declare_typed_property(class_entry, property_publicId_name, &property_publicId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_publicId_name); + zend_string_release_ex(property_publicId_name, true); zval property_systemId_default_value; ZVAL_UNDEF(&property_systemId_default_value); - zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, 1); + zend_string *property_systemId_name = zend_string_init("systemId", sizeof("systemId") - 1, true); zend_declare_typed_property(class_entry, property_systemId_name, &property_systemId_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_systemId_name); + zend_string_release_ex(property_systemId_name, true); return class_entry; } @@ -3419,101 +3407,101 @@ static zend_class_entry *register_class_Dom_Document(zend_class_entry *class_ent zval property_children_default_value; ZVAL_UNDEF(&property_children_default_value); - zend_string *property_children_name = zend_string_init("children", sizeof("children") - 1, 1); + zend_string *property_children_name = zend_string_init("children", sizeof("children") - 1, true); zend_string *property_children_class_Dom_HTMLCollection = zend_string_init("Dom\\HTMLCollection", sizeof("Dom\\HTMLCollection")-1, 1); zend_declare_typed_property(class_entry, property_children_name, &property_children_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_children_class_Dom_HTMLCollection, 0, 0)); - zend_string_release(property_children_name); + zend_string_release_ex(property_children_name, true); 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_name = zend_string_init("firstElementChild", sizeof("firstElementChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_firstElementChild_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_firstElementChild_name); + zend_string_release_ex(property_firstElementChild_name, true); 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_name = zend_string_init("lastElementChild", sizeof("lastElementChild") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_lastElementChild_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_lastElementChild_name); + zend_string_release_ex(property_lastElementChild_name, true); zval property_childElementCount_default_value; ZVAL_UNDEF(&property_childElementCount_default_value); - zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, 1); + zend_string *property_childElementCount_name = zend_string_init("childElementCount", sizeof("childElementCount") - 1, true); zend_declare_typed_property(class_entry, property_childElementCount_name, &property_childElementCount_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_childElementCount_name); + zend_string_release_ex(property_childElementCount_name, true); 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_name = zend_string_init("implementation", sizeof("implementation") - 1, true); 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); + zend_string_release_ex(property_implementation_name, true); zval property_URL_default_value; ZVAL_UNDEF(&property_URL_default_value); - zend_string *property_URL_name = zend_string_init("URL", sizeof("URL") - 1, 1); + zend_string *property_URL_name = zend_string_init("URL", sizeof("URL") - 1, true); zend_declare_typed_property(class_entry, property_URL_name, &property_URL_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_URL_name); + zend_string_release_ex(property_URL_name, true); zval property_documentURI_default_value; ZVAL_UNDEF(&property_documentURI_default_value); - zend_string *property_documentURI_name = zend_string_init("documentURI", sizeof("documentURI") - 1, 1); + zend_string *property_documentURI_name = zend_string_init("documentURI", sizeof("documentURI") - 1, true); zend_declare_typed_property(class_entry, property_documentURI_name, &property_documentURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_documentURI_name); + zend_string_release_ex(property_documentURI_name, true); zval property_characterSet_default_value; ZVAL_UNDEF(&property_characterSet_default_value); - zend_string *property_characterSet_name = zend_string_init("characterSet", sizeof("characterSet") - 1, 1); + zend_string *property_characterSet_name = zend_string_init("characterSet", sizeof("characterSet") - 1, true); zend_declare_typed_property(class_entry, property_characterSet_name, &property_characterSet_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_characterSet_name); + zend_string_release_ex(property_characterSet_name, true); zval property_charset_default_value; ZVAL_UNDEF(&property_charset_default_value); - zend_string *property_charset_name = zend_string_init("charset", sizeof("charset") - 1, 1); + zend_string *property_charset_name = zend_string_init("charset", sizeof("charset") - 1, true); zend_declare_typed_property(class_entry, property_charset_name, &property_charset_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_charset_name); + zend_string_release_ex(property_charset_name, true); zval property_inputEncoding_default_value; ZVAL_UNDEF(&property_inputEncoding_default_value); - zend_string *property_inputEncoding_name = zend_string_init("inputEncoding", sizeof("inputEncoding") - 1, 1); + zend_string *property_inputEncoding_name = zend_string_init("inputEncoding", sizeof("inputEncoding") - 1, true); zend_declare_typed_property(class_entry, property_inputEncoding_name, &property_inputEncoding_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_inputEncoding_name); + zend_string_release_ex(property_inputEncoding_name, true); 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_name = zend_string_init("doctype", sizeof("doctype") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_doctype_class_Dom_DocumentType, 0, MAY_BE_NULL)); - zend_string_release(property_doctype_name); + zend_string_release_ex(property_doctype_name, true); 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_name = zend_string_init("documentElement", sizeof("documentElement") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_documentElement_class_Dom_Element, 0, MAY_BE_NULL)); - zend_string_release(property_documentElement_name); + zend_string_release_ex(property_documentElement_name, true); zval property_body_default_value; ZVAL_UNDEF(&property_body_default_value); - zend_string *property_body_name = zend_string_init("body", sizeof("body") - 1, 1); + zend_string *property_body_name = zend_string_init("body", sizeof("body") - 1, true); zend_string *property_body_class_Dom_HTMLElement = zend_string_init("Dom\\HTMLElement", sizeof("Dom\\HTMLElement")-1, 1); zend_declare_typed_property(class_entry, property_body_name, &property_body_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_body_class_Dom_HTMLElement, 0, MAY_BE_NULL)); - zend_string_release(property_body_name); + zend_string_release_ex(property_body_name, true); zval property_head_default_value; ZVAL_UNDEF(&property_head_default_value); - zend_string *property_head_name = zend_string_init("head", sizeof("head") - 1, 1); + zend_string *property_head_name = zend_string_init("head", sizeof("head") - 1, true); zend_string *property_head_class_Dom_HTMLElement = zend_string_init("Dom\\HTMLElement", sizeof("Dom\\HTMLElement")-1, 1); zend_declare_typed_property(class_entry, property_head_name, &property_head_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_head_class_Dom_HTMLElement, 0, MAY_BE_NULL)); - zend_string_release(property_head_name); + zend_string_release_ex(property_head_name, true); zval property_title_default_value; ZVAL_UNDEF(&property_title_default_value); - zend_string *property_title_name = zend_string_init("title", sizeof("title") - 1, 1); + zend_string *property_title_name = zend_string_init("title", sizeof("title") - 1, true); zend_declare_typed_property(class_entry, property_title_name, &property_title_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_title_name); + zend_string_release_ex(property_title_name, true); return class_entry; } @@ -3537,27 +3525,27 @@ static zend_class_entry *register_class_Dom_XMLDocument(zend_class_entry *class_ zval property_xmlEncoding_default_value; ZVAL_UNDEF(&property_xmlEncoding_default_value); - zend_string *property_xmlEncoding_name = zend_string_init("xmlEncoding", sizeof("xmlEncoding") - 1, 1); + zend_string *property_xmlEncoding_name = zend_string_init("xmlEncoding", sizeof("xmlEncoding") - 1, true); zend_declare_typed_property(class_entry, property_xmlEncoding_name, &property_xmlEncoding_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_xmlEncoding_name); + zend_string_release_ex(property_xmlEncoding_name, true); zval property_xmlStandalone_default_value; ZVAL_UNDEF(&property_xmlStandalone_default_value); - zend_string *property_xmlStandalone_name = zend_string_init("xmlStandalone", sizeof("xmlStandalone") - 1, 1); + zend_string *property_xmlStandalone_name = zend_string_init("xmlStandalone", sizeof("xmlStandalone") - 1, true); zend_declare_typed_property(class_entry, property_xmlStandalone_name, &property_xmlStandalone_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_xmlStandalone_name); + zend_string_release_ex(property_xmlStandalone_name, true); zval property_xmlVersion_default_value; ZVAL_UNDEF(&property_xmlVersion_default_value); - zend_string *property_xmlVersion_name = zend_string_init("xmlVersion", sizeof("xmlVersion") - 1, 1); + zend_string *property_xmlVersion_name = zend_string_init("xmlVersion", sizeof("xmlVersion") - 1, true); zend_declare_typed_property(class_entry, property_xmlVersion_name, &property_xmlVersion_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_xmlVersion_name); + zend_string_release_ex(property_xmlVersion_name, true); zval property_formatOutput_default_value; ZVAL_UNDEF(&property_formatOutput_default_value); - zend_string *property_formatOutput_name = zend_string_init("formatOutput", sizeof("formatOutput") - 1, 1); + zend_string *property_formatOutput_name = zend_string_init("formatOutput", sizeof("formatOutput") - 1, true); zend_declare_typed_property(class_entry, property_formatOutput_name, &property_formatOutput_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_formatOutput_name); + zend_string_release_ex(property_formatOutput_name, true); return class_entry; } @@ -3572,9 +3560,9 @@ static zend_class_entry *register_class_Dom_TokenList(zend_class_entry *class_en zval property_length_default_value; ZVAL_UNDEF(&property_length_default_value); - zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, 1); + zend_string *property_length_name = zend_string_init("length", sizeof("length") - 1, true); zend_declare_typed_property(class_entry, property_length_name, &property_length_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_length_name); + zend_string_release_ex(property_length_name, true); zval property_value_default_value; ZVAL_UNDEF(&property_value_default_value); @@ -3592,22 +3580,22 @@ static zend_class_entry *register_class_Dom_NamespaceInfo(void) zval property_prefix_default_value; ZVAL_UNDEF(&property_prefix_default_value); - zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, 1); + zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, true); zend_declare_typed_property(class_entry, property_prefix_name, &property_prefix_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_prefix_name); + zend_string_release_ex(property_prefix_name, true); zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); - zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, 1); + zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, true); zend_declare_typed_property(class_entry, property_namespaceURI_name, &property_namespaceURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_namespaceURI_name); + zend_string_release_ex(property_namespaceURI_name, true); zval property_element_default_value; ZVAL_UNDEF(&property_element_default_value); - zend_string *property_element_name = zend_string_init("element", sizeof("element") - 1, 1); + zend_string *property_element_name = zend_string_init("element", sizeof("element") - 1, true); zend_string *property_element_class_Dom_Element = zend_string_init("Dom\\Element", sizeof("Dom\\Element")-1, 1); zend_declare_typed_property(class_entry, property_element_name, &property_element_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_element_class_Dom_Element, 0, 0)); - zend_string_release(property_element_name); + zend_string_release_ex(property_element_name, true); return class_entry; } @@ -3622,16 +3610,16 @@ static zend_class_entry *register_class_Dom_XPath(void) 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_name = zend_string_init("document", sizeof("document") - 1, true); 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|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_document_class_Dom_Document, 0, 0)); - zend_string_release(property_document_name); + zend_string_release_ex(property_document_name, true); zval property_registerNodeNamespaces_default_value; ZVAL_UNDEF(&property_registerNodeNamespaces_default_value); - zend_string *property_registerNodeNamespaces_name = zend_string_init("registerNodeNamespaces", sizeof("registerNodeNamespaces") - 1, 1); + zend_string *property_registerNodeNamespaces_name = zend_string_init("registerNodeNamespaces", sizeof("registerNodeNamespaces") - 1, true); zend_declare_typed_property(class_entry, property_registerNodeNamespaces_name, &property_registerNodeNamespaces_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_registerNodeNamespaces_name); + zend_string_release_ex(property_registerNodeNamespaces_name, true); return class_entry; } diff --git a/ext/dom/tests/gh20722.phpt b/ext/dom/tests/gh20722.phpt new file mode 100644 index 0000000000000..38d3314618f3e --- /dev/null +++ b/ext/dom/tests/gh20722.phpt @@ -0,0 +1,13 @@ +--TEST-- +GH-20722 (Null pointer dereference in DOM namespace node cloning via clone on malformed objects) +--EXTENSIONS-- +dom +--FILE-- + +--EXPECT-- +Done diff --git a/ext/dom/tests/registerPhpFunctionNS.phpt b/ext/dom/tests/registerPhpFunctionNS.phpt index 4c4fb157000bf..2ee98168251fd 100644 --- a/ext/dom/tests/registerPhpFunctionNS.phpt +++ b/ext/dom/tests/registerPhpFunctionNS.phpt @@ -62,14 +62,14 @@ $xpath->registerPhpFunctionNS('urn:bar', 'test', 'strtolower'); var_dump($xpath->query('//a[bar:test(string(@href)) = "https://php.net"]')); ?> ---EXPECT-- +--EXPECTF-- --- Legit cases: global function callable --- object(DOMNodeList)#5 (1) { ["length"]=> int(1) } --- Legit cases: string callable --- -object(DOMNodeList)#5 (1) { +object(DOMNodeList)#%d (1) { ["length"]=> int(1) } @@ -79,12 +79,12 @@ array(1) { [0]=> string(15) "https://PHP.net" } -object(DOMNodeList)#3 (1) { +object(DOMNodeList)#%d (1) { ["length"]=> int(0) } --- Legit cases: instance class method callable --- -object(DOMNodeList)#6 (1) { +object(DOMNodeList)#%d (1) { ["length"]=> int(1) } @@ -100,7 +100,7 @@ array(1) { --- Legit cases: global function callable that returns nothing --- string(15) "https://PHP.net" --- Legit cases: multiple namespaces --- -object(DOMNodeList)#5 (1) { +object(DOMNodeList)#%d (1) { ["length"]=> int(1) } diff --git a/ext/dom/text.c b/ext/dom/text.c index ca8fcf63d3aca..4c503201c8bfe 100644 --- a/ext/dom/text.c +++ b/ext/dom/text.c @@ -96,7 +96,6 @@ Modern spec URL: https://dom.spec.whatwg.org/#dom-text-splittext */ PHP_METHOD(DOMText, splitText) { - zval *id; xmlChar *first; xmlChar *second; xmlNodePtr node; @@ -105,11 +104,10 @@ PHP_METHOD(DOMText, splitText) int length; dom_object *intern; - id = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { RETURN_THROWS(); } - DOM_GET_OBJ(node, id, xmlNodePtr, intern); + DOM_GET_OBJ(node, ZEND_THIS, xmlNodePtr, intern); if (offset < 0) { zend_argument_value_error(1, "must be greater than or equal to 0"); @@ -129,17 +127,18 @@ PHP_METHOD(DOMText, splitText) first = xmlUTF8Strndup(cur, (int)offset); second = xmlUTF8Strsub(cur, (int)offset, (int)(length - offset)); - xmlNodeSetContent(node, first); - nnode = xmlNewDocText(node->doc, second); - - xmlFree(first); - xmlFree(second); + xmlNodeSetContent(node, NULL); + node->content = first; + nnode = xmlNewDocText(node->doc, NULL); if (nnode == NULL) { + xmlFree(second); php_dom_throw_error(INVALID_STATE_ERR, /* strict */ true); RETURN_THROWS(); } + nnode->content = second; + if (node->parent != NULL) { nnode->type = XML_ELEMENT_NODE; xmlAddNextSibling(node, nnode); @@ -155,21 +154,11 @@ Since: DOM Level 3 */ PHP_METHOD(DOMText, isWhitespaceInElementContent) { - zval *id; xmlNodePtr node; dom_object *intern; - - id = ZEND_THIS; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } - DOM_GET_OBJ(node, id, xmlNodePtr, intern); - - if (xmlIsBlankNode(node)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + ZEND_PARSE_PARAMETERS_NONE(); + DOM_GET_OBJ(node, ZEND_THIS, xmlNodePtr, intern); + RETURN_BOOL(xmlIsBlankNode(node)); } /* }}} end dom_text_is_whitespace_in_element_content */ diff --git a/ext/dom/xml_serializer.c b/ext/dom/xml_serializer.c index a4b46082b0ee5..7684057a391c0 100644 --- a/ext/dom/xml_serializer.c +++ b/ext/dom/xml_serializer.c @@ -1097,7 +1097,10 @@ static int dom_xml_serialize_element_node( /* 14. If ns is the HTML namespace, and the node's list of children is empty, and the node's localName matches * any one of the following void elements: ... */ if (element->children == NULL) { - if (xmlSaveNoEmptyTags) { + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") + int saveNoEmptyTags = xmlSaveNoEmptyTags; + ZEND_DIAGNOSTIC_IGNORED_END + if (saveNoEmptyTags) { /* Do nothing, use the closing style. */ } else if (php_dom_ns_is_fast(element, php_dom_ns_is_html_magic_token)) { size_t name_length = strlen((const char *) element->name); diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c index eedb49b69e8f9..534908f9d1cc5 100644 --- a/ext/enchant/enchant.c +++ b/ext/enchant/enchant.c @@ -671,17 +671,18 @@ PHP_FUNCTION(enchant_dict_suggest) } PHP_ENCHANT_GET_DICT; - array_init(return_value); suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg); if (suggs && n_sugg) { - size_t i; + array_init_size(return_value, n_sugg); - for (i = 0; i < n_sugg; i++) { + for (size_t i = 0; i < n_sugg; i++) { add_next_index_string(return_value, suggs[i]); } enchant_dict_free_string_list(pdict->pdict, suggs); + } else { + RETURN_EMPTY_ARRAY(); } } /* }}} */ diff --git a/ext/exif/exif.c b/ext/exif/exif.c index d0c16413062ae..17dadc7539baf 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -2104,7 +2104,7 @@ static inline char *exif_offset_info_try_get( static inline bool exif_offset_info_contains( const exif_offset_info *info, const char *start, size_t length) { if (ptr_offset_overflows(start, length)) { - return 0; + return false; } /* start and valid_start are both inclusive, end and valid_end are both exclusive, @@ -4421,7 +4421,7 @@ static bool exif_scan_HEIF_header(image_info_type *ImageInfo, unsigned char *buf if (exif_read_from_stream_file_looped(ImageInfo->infile, (char*)(data + remain), limit - remain) == limit - remain) { exif_isobmff_parse_meta(data, data + limit, &pos); } - if ((pos.size) && + if ((pos.size >= 2) && (pos.size < ImageInfo->FileSize) && (ImageInfo->FileSize - pos.size >= pos.offset) && (php_stream_seek(ImageInfo->infile, pos.offset + 2, SEEK_SET) >= 0)) { diff --git a/ext/exif/tests/heic_iloc_underflow.phpt b/ext/exif/tests/heic_iloc_underflow.phpt new file mode 100644 index 0000000000000..9dd1878b60dd7 --- /dev/null +++ b/ext/exif/tests/heic_iloc_underflow.phpt @@ -0,0 +1,19 @@ +--TEST-- +HEIC iloc extent_length underflow +--EXTENSIONS-- +exif +--FILE-- + +--CLEAN-- + +--EXPECTF-- +Warning: exif_read_data(heic_iloc_underflow.heic): Invalid HEIF file in %s on line %d +bool(false) diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 10fc11f52e70f..d5b8eb59f0c90 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -957,7 +957,8 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v ZEND_HASH_PACKED_FOREACH_PTR(callback_data->type->func.args, arg_type) { arg_type = ZEND_FFI_TYPE(arg_type); - zend_ffi_cdata_to_zval(NULL, args[n], arg_type, BP_VAR_R, &fci.params[n], (zend_ffi_flags)(arg_type->attr & ZEND_FFI_ATTR_CONST), 0, 0); + zend_ffi_cdata_to_zval(NULL, args[n], arg_type, BP_VAR_R, &fci.params[n], (zend_ffi_flags)(arg_type->attr & ZEND_FFI_ATTR_CONST), + false, false); n++; } ZEND_HASH_FOREACH_END(); } @@ -1133,7 +1134,7 @@ static zval *zend_ffi_cdata_get(zend_object *obj, zend_string *member, int read_ return &EG(uninitialized_zval); } - zend_ffi_cdata_to_zval(cdata, cdata->ptr, type, BP_VAR_R, rv, 0, 0, 0); + zend_ffi_cdata_to_zval(cdata, cdata->ptr, type, BP_VAR_R, rv, 0, false, false); return rv; } /* }}} */ @@ -1302,7 +1303,8 @@ static zval *zend_ffi_cdata_read_field(zend_object *obj, zend_string *field_name } } ptr = (void*)(((char*)ptr) + field->offset); - zend_ffi_cdata_to_zval(NULL, ptr, field_type, read_type, rv, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)field->is_const, 0, 0); + zend_ffi_cdata_to_zval(NULL, ptr, field_type, read_type, rv, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)field->is_const, + false, false); } else { zend_ffi_bit_field_to_zval(ptr, field, rv); } @@ -1438,7 +1440,7 @@ static zval *zend_ffi_cdata_read_dim(zend_object *obj, zval *offset, int read_ty return &EG(uninitialized_zval); } - zend_ffi_cdata_to_zval(NULL, ptr, dim_type, read_type, rv, is_const, 0, 0); + zend_ffi_cdata_to_zval(NULL, ptr, dim_type, read_type, rv, is_const, false, false); return rv; } /* }}} */ @@ -1527,7 +1529,7 @@ static bool zend_ffi_ctype_name_append(zend_ffi_ctype_name_buf *buf, const char static bool zend_ffi_ctype_name(zend_ffi_ctype_name_buf *buf, const zend_ffi_type *type) /* {{{ */ { const char *name = NULL; - bool is_ptr = 0; + bool is_ptr = false; while (1) { switch (type->kind) { @@ -1587,12 +1589,12 @@ static bool zend_ffi_ctype_name(zend_ffi_ctype_name_buf *buf, const zend_ffi_typ if (!zend_ffi_ctype_name_prepend(buf, "*", 1)) { return 0; } - is_ptr = 1; + is_ptr = true; type = ZEND_FFI_TYPE(type->pointer.type); break; case ZEND_FFI_TYPE_FUNC: if (is_ptr) { - is_ptr = 0; + is_ptr = false; if (!zend_ffi_ctype_name_prepend(buf, "(", 1) || !zend_ffi_ctype_name_append(buf, ")", 1)) { return 0; @@ -1606,7 +1608,7 @@ static bool zend_ffi_ctype_name(zend_ffi_ctype_name_buf *buf, const zend_ffi_typ break; case ZEND_FFI_TYPE_ARRAY: if (is_ptr) { - is_ptr = 0; + is_ptr = false; if (!zend_ffi_ctype_name_prepend(buf, "(", 1) || !zend_ffi_ctype_name_append(buf, ")", 1)) { return 0; @@ -1984,7 +1986,8 @@ static zval *zend_ffi_cdata_it_get_current_data(zend_object_iterator *it) /* {{{ ptr = (void*)((char*)cdata->ptr + dim_type->size * iter->it.index); zval_ptr_dtor(&iter->value); - zend_ffi_cdata_to_zval(NULL, ptr, dim_type, iter->by_ref ? BP_VAR_RW : BP_VAR_R, &iter->value, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONST), 0, 0); + zend_ffi_cdata_to_zval(NULL, ptr, dim_type, iter->by_ref ? BP_VAR_RW : BP_VAR_R, &iter->value, (cdata->flags & ZEND_FFI_FLAG_CONST) | (zend_ffi_flags)(type->attr & ZEND_FFI_ATTR_CONST), + false, false); return &iter->value; } /* }}} */ @@ -2082,7 +2085,7 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp) case ZEND_FFI_TYPE_SINT32: case ZEND_FFI_TYPE_UINT64: case ZEND_FFI_TYPE_SINT64: - zend_ffi_cdata_to_zval(cdata, ptr, type, BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, 0); + zend_ffi_cdata_to_zval(cdata, ptr, type, BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, false, false); ht = zend_new_array(1); zend_hash_str_add(ht, "cdata", sizeof("cdata")-1, &tmp); *is_temp = 1; @@ -2102,7 +2105,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp) *is_temp = 1; return ht; } else { - zend_ffi_cdata_to_zval(NULL, *(void**)ptr, ZEND_FFI_TYPE(type->pointer.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, 0); + zend_ffi_cdata_to_zval(NULL, *(void**)ptr, ZEND_FFI_TYPE(type->pointer.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, + false, false); ht = zend_new_array(1); zend_hash_index_add_new(ht, 0, &tmp); *is_temp = 1; @@ -2115,7 +2119,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp) if (key) { if (!f->bits) { void *f_ptr = (void*)(((char*)ptr) + f->offset); - zend_ffi_cdata_to_zval(NULL, f_ptr, ZEND_FFI_TYPE(f->type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, type->attr & ZEND_FFI_ATTR_UNION); + zend_ffi_cdata_to_zval(NULL, f_ptr, ZEND_FFI_TYPE(f->type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, + false, type->attr & ZEND_FFI_ATTR_UNION); zend_hash_add(ht, key, &tmp); } else { zend_ffi_bit_field_to_zval(ptr, f, &tmp); @@ -2128,7 +2133,8 @@ static HashTable *zend_ffi_cdata_get_debug_info(zend_object *obj, int *is_temp) case ZEND_FFI_TYPE_ARRAY: ht = zend_new_array(type->array.length); for (n = 0; n < type->array.length; n++) { - zend_ffi_cdata_to_zval(NULL, ptr, ZEND_FFI_TYPE(type->array.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, 0, 0); + zend_ffi_cdata_to_zval(NULL, ptr, ZEND_FFI_TYPE(type->array.type), BP_VAR_R, &tmp, ZEND_FFI_FLAG_CONST, + false, false); zend_hash_index_add(ht, n, &tmp); ptr = (void*)(((char*)ptr) + ZEND_FFI_TYPE(type->array.type)->size); } @@ -2184,6 +2190,7 @@ static zend_result zend_ffi_cdata_get_closure(zend_object *obj, zend_class_entry func->common.arg_flags[1] = 0; func->common.arg_flags[2] = 0; func->common.fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE; + func->common.fn_flags2 = 0; func->common.function_name = ZSTR_KNOWN(ZEND_STR_MAGIC_INVOKE); /* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */ func->common.num_args = 0; @@ -2307,7 +2314,7 @@ static zend_object *zend_ffi_new(zend_class_entry *class_type) /* {{{ */ ffi->lib = NULL; ffi->symbols = NULL; ffi->tags = NULL; - ffi->persistent = 0; + ffi->persistent = false; return &ffi->std; } @@ -2509,7 +2516,8 @@ static zval *zend_ffi_read_var(zend_object *obj, zend_string *var_name, int read } if (sym->kind == ZEND_FFI_SYM_VAR) { - zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)sym->is_const, 0, 0); + zend_ffi_cdata_to_zval(NULL, sym->addr, ZEND_FFI_TYPE(sym->type), read_type, rv, (zend_ffi_flags)sym->is_const, + false, false); } else if (sym->kind == ZEND_FFI_SYM_FUNC) { zend_ffi_cdata *cdata; zend_ffi_type *new_type = emalloc(sizeof(zend_ffi_type)); @@ -2962,6 +2970,7 @@ static zend_function *zend_ffi_get_func(zend_object **obj, zend_string *name, co func->common.arg_flags[1] = 0; func->common.arg_flags[2] = 0; func->common.fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE; + func->common.fn_flags2 = 0; func->common.function_name = zend_string_copy(name); /* set to 0 to avoid arg_info[] allocation, because all values are passed by value anyway */ func->common.num_args = 0; @@ -3581,7 +3590,7 @@ static zend_ffi *zend_ffi_load(const char *filename, bool preload) /* {{{ */ } ffi->symbols = scope->symbols; ffi->tags = scope->tags; - ffi->persistent = 1; + ffi->persistent = true; } else { ffi = (zend_ffi*)zend_ffi_new(zend_ffi_ce); ffi->lib = handle; @@ -3764,14 +3773,14 @@ static zend_result zend_ffi_validate_var_type(const zend_ffi_type *type, bool al zend_ffi_throw_parser_error("function type is not allowed at line %d", FFI_G(line)); return FAILURE; } - return zend_ffi_validate_type(type, 0, allow_incomplete_array); + return zend_ffi_validate_type(type, false, allow_incomplete_array); } /* }}} */ void zend_ffi_validate_type_name(zend_ffi_dcl *dcl) /* {{{ */ { zend_ffi_finalize_type(dcl); - if (zend_ffi_validate_var_type(ZEND_FFI_TYPE(dcl->type), 0) == FAILURE) { + if (zend_ffi_validate_var_type(ZEND_FFI_TYPE(dcl->type), false) == FAILURE) { zend_ffi_cleanup_dcl(dcl); LONGJMP(FFI_G(bailout), FAILURE); } @@ -4708,9 +4717,8 @@ ZEND_METHOD(FFI, isNull) /* {{{ */ ZEND_METHOD(FFI_CType, getName) /* {{{ */ { zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + + ZEND_PARSE_PARAMETERS_NONE(); zend_ffi_ctype_name_buf buf; @@ -4730,9 +4738,7 @@ ZEND_METHOD(FFI_CType, getKind) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); RETURN_LONG(type->kind); @@ -4744,9 +4750,7 @@ ZEND_METHOD(FFI_CType, getSize) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); RETURN_LONG(type->size); @@ -4758,9 +4762,7 @@ ZEND_METHOD(FFI_CType, getAlignment) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); RETURN_LONG(type->align); @@ -4772,9 +4774,7 @@ ZEND_METHOD(FFI_CType, getAttributes) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); RETURN_LONG(type->attr); @@ -4786,9 +4786,7 @@ ZEND_METHOD(FFI_CType, getEnumKind) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_ENUM) { @@ -4805,9 +4803,7 @@ ZEND_METHOD(FFI_CType, getArrayElementType) /* {{{ */ zend_ffi_type *type; zend_ffi_ctype *ret; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_ARRAY) { @@ -4826,9 +4822,7 @@ ZEND_METHOD(FFI_CType, getArrayLength) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_ARRAY) { @@ -4845,9 +4839,7 @@ ZEND_METHOD(FFI_CType, getPointerType) /* {{{ */ zend_ffi_ctype *ret; zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_POINTER) { @@ -4869,9 +4861,7 @@ ZEND_METHOD(FFI_CType, getStructFieldNames) /* {{{ */ zend_string* name; zval zv; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_STRUCT) { @@ -4949,9 +4939,7 @@ ZEND_METHOD(FFI_CType, getFuncABI) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_FUNC) { @@ -4968,9 +4956,7 @@ ZEND_METHOD(FFI_CType, getFuncReturnType) /* {{{ */ zend_ffi_ctype *ret; zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_FUNC) { @@ -4989,9 +4975,7 @@ ZEND_METHOD(FFI_CType, getFuncParameterCount) /* {{{ */ const zend_ffi_ctype *ctype = (zend_ffi_ctype*)(Z_OBJ_P(ZEND_THIS)); const zend_ffi_type *type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); type = ZEND_FFI_TYPE(ctype->type); if (type->kind != ZEND_FFI_TYPE_FUNC) { @@ -5369,7 +5353,7 @@ static zend_result zend_ffi_preload_glob(const char *filename) /* {{{ */ /* pass */ } else { for(i=0 ; itype); - bool overflow = 0; + bool overflow = false; bool is_signed = (enum_type->enumeration.kind == ZEND_FFI_TYPE_SINT8 || enum_type->enumeration.kind == ZEND_FFI_TYPE_SINT16 || @@ -6009,36 +5993,36 @@ void zend_ffi_add_enum_val(zend_ffi_dcl *enum_dcl, const char *name, size_t name if (val->kind == ZEND_FFI_VAL_EMPTY) { if (is_signed) { if (*last == 0x7FFFFFFFFFFFFFFFLL) { - overflow = 1; + overflow = true; } } else { if ((*min != 0 || *max != 0) && (uint64_t)*last == 0xFFFFFFFFFFFFFFFFULL) { - overflow = 1; + overflow = true; } } value = *last + 1; } else if (val->kind == ZEND_FFI_VAL_CHAR) { if (!is_signed && val->ch < 0) { if ((uint64_t)*max > 0x7FFFFFFFFFFFFFFFULL) { - overflow = 1; + overflow = true; } else { - is_signed = 1; + is_signed = true; } } value = val->ch; } else if (val->kind == ZEND_FFI_VAL_INT32 || val->kind == ZEND_FFI_VAL_INT64) { if (!is_signed && val->i64 < 0) { if ((uint64_t)*max > 0x7FFFFFFFFFFFFFFFULL) { - overflow = 1; + overflow = true; } else { - is_signed = 1; + is_signed = true; } } value = val->i64; } else if (val->kind == ZEND_FFI_VAL_UINT32 || val->kind == ZEND_FFI_VAL_UINT64) { if (is_signed && val->u64 > 0x7FFFFFFFFFFFFFFFULL) { - overflow = 1; + overflow = true; } value = val->u64; } else { @@ -6142,7 +6126,7 @@ static zend_result zend_ffi_validate_field_type(const zend_ffi_type *type, zend_ if (type == struct_type) { zend_ffi_throw_parser_error("Struct/union can't contain an instance of itself at line %d", FFI_G(line)); return FAILURE; - } else if (zend_ffi_validate_var_type(type, 1) == FAILURE) { + } else if (zend_ffi_validate_var_type(type, true) == FAILURE) { return FAILURE; } else if (struct_type->attr & ZEND_FFI_ATTR_UNION) { if (type->attr & ZEND_FFI_ATTR_INCOMPLETE_ARRAY) { @@ -6185,7 +6169,7 @@ void zend_ffi_add_field(zend_ffi_dcl *struct_dcl, const char *name, size_t name_ } field->type = field_dcl->type; field->is_const = (bool)(field_dcl->attr & ZEND_FFI_ATTR_CONST); - field->is_nested = 0; + field->is_nested = false; field->first_bit = 0; field->bits = 0; field_dcl->type = field_type; /* reset "owned" flag */ @@ -6238,7 +6222,7 @@ void zend_ffi_add_anonymous_field(zend_ffi_dcl *struct_dcl, zend_ffi_dcl *field_ } new_field->type = field->type; new_field->is_const = field->is_const; - new_field->is_nested = 1; + new_field->is_nested = true; new_field->first_bit = field->first_bit; new_field->bits = field->bits; field->type = ZEND_FFI_TYPE(field->type); /* reset "owned" flag */ @@ -6353,7 +6337,7 @@ void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t n } field->type = field_dcl->type; field->is_const = (bool)(field_dcl->attr & ZEND_FFI_ATTR_CONST); - field->is_nested = 0; + field->is_nested = false; field_dcl->type = field_type; /* reset "owned" flag */ if (name) { @@ -6412,7 +6396,7 @@ static zend_result zend_ffi_validate_array_element_type(const zend_ffi_type *typ zend_ffi_throw_parser_error("Only the leftmost array can be undimensioned at line %d", FFI_G(line)); return FAILURE; } - return zend_ffi_validate_type(type, 0, 1); + return zend_ffi_validate_type(type, false, true); } /* }}} */ @@ -6472,7 +6456,7 @@ static zend_result zend_ffi_validate_func_ret_type(const zend_ffi_type *type) /* zend_ffi_throw_parser_error("Function returning array is not allowed at line %d", FFI_G(line)); return FAILURE; } - return zend_ffi_validate_incomplete_type(type, 1, 0); + return zend_ffi_validate_incomplete_type(type, true, false); } /* }}} */ @@ -6646,7 +6630,7 @@ void zend_ffi_add_arg(HashTable **args, const char *name, size_t name_len, zend_ new_type->pointer.type = arg_dcl->type; arg_dcl->type = ZEND_FFI_TYPE_MAKE_OWNED(new_type); } - if (zend_ffi_validate_incomplete_type(type, 1, 1) == FAILURE) { + if (zend_ffi_validate_incomplete_type(type, true, true) == FAILURE) { zend_ffi_cleanup_dcl(arg_dcl); zend_hash_destroy(*args); pefree(*args, FFI_G(persistent)); @@ -6725,7 +6709,7 @@ void zend_ffi_declare(const char *name, size_t name_len, zend_ffi_dcl *dcl) /* { zend_ffi_type *type; type = ZEND_FFI_TYPE(dcl->type); - if (zend_ffi_validate_type(type, (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) == ZEND_FFI_DCL_EXTERN, 1) == FAILURE) { + if (zend_ffi_validate_type(type, (dcl->flags & ZEND_FFI_DCL_STORAGE_CLASS) == ZEND_FFI_DCL_EXTERN, true) == FAILURE) { zend_ffi_cleanup_dcl(dcl); LONGJMP(FFI_G(bailout), FAILURE); } diff --git a/ext/ffi/ffi_arginfo.h b/ext/ffi/ffi_arginfo.h index 563c9f8b8e8b1..1485c973d9a11 100644 --- a/ext/ffi/ffi_arginfo.h +++ b/ext/ffi/ffi_arginfo.h @@ -205,9 +205,9 @@ static zend_class_entry *register_class_FFI(void) zval const___BIGGEST_ALIGNMENT___value; ZVAL_LONG(&const___BIGGEST_ALIGNMENT___value, __BIGGEST_ALIGNMENT__); - zend_string *const___BIGGEST_ALIGNMENT___name = zend_string_init_interned("__BIGGEST_ALIGNMENT__", sizeof("__BIGGEST_ALIGNMENT__") - 1, 1); + zend_string *const___BIGGEST_ALIGNMENT___name = zend_string_init_interned("__BIGGEST_ALIGNMENT__", sizeof("__BIGGEST_ALIGNMENT__") - 1, true); zend_declare_typed_class_constant(class_entry, const___BIGGEST_ALIGNMENT___name, &const___BIGGEST_ALIGNMENT___value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const___BIGGEST_ALIGNMENT___name); + zend_string_release_ex(const___BIGGEST_ALIGNMENT___name, true); return class_entry; } @@ -231,233 +231,233 @@ static zend_class_entry *register_class_FFI_CType(void) zval const_TYPE_VOID_value; ZVAL_LONG(&const_TYPE_VOID_value, ZEND_FFI_TYPE_VOID); - zend_string *const_TYPE_VOID_name = zend_string_init_interned("TYPE_VOID", sizeof("TYPE_VOID") - 1, 1); + zend_string *const_TYPE_VOID_name = zend_string_init_interned("TYPE_VOID", sizeof("TYPE_VOID") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_VOID_name, &const_TYPE_VOID_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_VOID_name); + zend_string_release_ex(const_TYPE_VOID_name, true); zval const_TYPE_FLOAT_value; ZVAL_LONG(&const_TYPE_FLOAT_value, ZEND_FFI_TYPE_FLOAT); - zend_string *const_TYPE_FLOAT_name = zend_string_init_interned("TYPE_FLOAT", sizeof("TYPE_FLOAT") - 1, 1); + zend_string *const_TYPE_FLOAT_name = zend_string_init_interned("TYPE_FLOAT", sizeof("TYPE_FLOAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_FLOAT_name, &const_TYPE_FLOAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_FLOAT_name); + zend_string_release_ex(const_TYPE_FLOAT_name, true); zval const_TYPE_DOUBLE_value; ZVAL_LONG(&const_TYPE_DOUBLE_value, ZEND_FFI_TYPE_DOUBLE); - zend_string *const_TYPE_DOUBLE_name = zend_string_init_interned("TYPE_DOUBLE", sizeof("TYPE_DOUBLE") - 1, 1); + zend_string *const_TYPE_DOUBLE_name = zend_string_init_interned("TYPE_DOUBLE", sizeof("TYPE_DOUBLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_DOUBLE_name, &const_TYPE_DOUBLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_DOUBLE_name); + zend_string_release_ex(const_TYPE_DOUBLE_name, true); #if defined(HAVE_LONG_DOUBLE) zval const_TYPE_LONGDOUBLE_value; ZVAL_LONG(&const_TYPE_LONGDOUBLE_value, ZEND_FFI_TYPE_LONGDOUBLE); - zend_string *const_TYPE_LONGDOUBLE_name = zend_string_init_interned("TYPE_LONGDOUBLE", sizeof("TYPE_LONGDOUBLE") - 1, 1); + zend_string *const_TYPE_LONGDOUBLE_name = zend_string_init_interned("TYPE_LONGDOUBLE", sizeof("TYPE_LONGDOUBLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_LONGDOUBLE_name, &const_TYPE_LONGDOUBLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_LONGDOUBLE_name); + zend_string_release_ex(const_TYPE_LONGDOUBLE_name, true); #endif zval const_TYPE_UINT8_value; ZVAL_LONG(&const_TYPE_UINT8_value, ZEND_FFI_TYPE_UINT8); - zend_string *const_TYPE_UINT8_name = zend_string_init_interned("TYPE_UINT8", sizeof("TYPE_UINT8") - 1, 1); + zend_string *const_TYPE_UINT8_name = zend_string_init_interned("TYPE_UINT8", sizeof("TYPE_UINT8") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_UINT8_name, &const_TYPE_UINT8_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_UINT8_name); + zend_string_release_ex(const_TYPE_UINT8_name, true); zval const_TYPE_SINT8_value; ZVAL_LONG(&const_TYPE_SINT8_value, ZEND_FFI_TYPE_SINT8); - zend_string *const_TYPE_SINT8_name = zend_string_init_interned("TYPE_SINT8", sizeof("TYPE_SINT8") - 1, 1); + zend_string *const_TYPE_SINT8_name = zend_string_init_interned("TYPE_SINT8", sizeof("TYPE_SINT8") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_SINT8_name, &const_TYPE_SINT8_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_SINT8_name); + zend_string_release_ex(const_TYPE_SINT8_name, true); zval const_TYPE_UINT16_value; ZVAL_LONG(&const_TYPE_UINT16_value, ZEND_FFI_TYPE_UINT16); - zend_string *const_TYPE_UINT16_name = zend_string_init_interned("TYPE_UINT16", sizeof("TYPE_UINT16") - 1, 1); + zend_string *const_TYPE_UINT16_name = zend_string_init_interned("TYPE_UINT16", sizeof("TYPE_UINT16") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_UINT16_name, &const_TYPE_UINT16_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_UINT16_name); + zend_string_release_ex(const_TYPE_UINT16_name, true); zval const_TYPE_SINT16_value; ZVAL_LONG(&const_TYPE_SINT16_value, ZEND_FFI_TYPE_SINT16); - zend_string *const_TYPE_SINT16_name = zend_string_init_interned("TYPE_SINT16", sizeof("TYPE_SINT16") - 1, 1); + zend_string *const_TYPE_SINT16_name = zend_string_init_interned("TYPE_SINT16", sizeof("TYPE_SINT16") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_SINT16_name, &const_TYPE_SINT16_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_SINT16_name); + zend_string_release_ex(const_TYPE_SINT16_name, true); zval const_TYPE_UINT32_value; ZVAL_LONG(&const_TYPE_UINT32_value, ZEND_FFI_TYPE_UINT32); - zend_string *const_TYPE_UINT32_name = zend_string_init_interned("TYPE_UINT32", sizeof("TYPE_UINT32") - 1, 1); + zend_string *const_TYPE_UINT32_name = zend_string_init_interned("TYPE_UINT32", sizeof("TYPE_UINT32") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_UINT32_name, &const_TYPE_UINT32_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_UINT32_name); + zend_string_release_ex(const_TYPE_UINT32_name, true); zval const_TYPE_SINT32_value; ZVAL_LONG(&const_TYPE_SINT32_value, ZEND_FFI_TYPE_SINT32); - zend_string *const_TYPE_SINT32_name = zend_string_init_interned("TYPE_SINT32", sizeof("TYPE_SINT32") - 1, 1); + zend_string *const_TYPE_SINT32_name = zend_string_init_interned("TYPE_SINT32", sizeof("TYPE_SINT32") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_SINT32_name, &const_TYPE_SINT32_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_SINT32_name); + zend_string_release_ex(const_TYPE_SINT32_name, true); zval const_TYPE_UINT64_value; ZVAL_LONG(&const_TYPE_UINT64_value, ZEND_FFI_TYPE_UINT64); - zend_string *const_TYPE_UINT64_name = zend_string_init_interned("TYPE_UINT64", sizeof("TYPE_UINT64") - 1, 1); + zend_string *const_TYPE_UINT64_name = zend_string_init_interned("TYPE_UINT64", sizeof("TYPE_UINT64") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_UINT64_name, &const_TYPE_UINT64_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_UINT64_name); + zend_string_release_ex(const_TYPE_UINT64_name, true); zval const_TYPE_SINT64_value; ZVAL_LONG(&const_TYPE_SINT64_value, ZEND_FFI_TYPE_SINT64); - zend_string *const_TYPE_SINT64_name = zend_string_init_interned("TYPE_SINT64", sizeof("TYPE_SINT64") - 1, 1); + zend_string *const_TYPE_SINT64_name = zend_string_init_interned("TYPE_SINT64", sizeof("TYPE_SINT64") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_SINT64_name, &const_TYPE_SINT64_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_SINT64_name); + zend_string_release_ex(const_TYPE_SINT64_name, true); zval const_TYPE_ENUM_value; ZVAL_LONG(&const_TYPE_ENUM_value, ZEND_FFI_TYPE_ENUM); - zend_string *const_TYPE_ENUM_name = zend_string_init_interned("TYPE_ENUM", sizeof("TYPE_ENUM") - 1, 1); + zend_string *const_TYPE_ENUM_name = zend_string_init_interned("TYPE_ENUM", sizeof("TYPE_ENUM") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_ENUM_name, &const_TYPE_ENUM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_ENUM_name); + zend_string_release_ex(const_TYPE_ENUM_name, true); zval const_TYPE_BOOL_value; ZVAL_LONG(&const_TYPE_BOOL_value, ZEND_FFI_TYPE_BOOL); - zend_string *const_TYPE_BOOL_name = zend_string_init_interned("TYPE_BOOL", sizeof("TYPE_BOOL") - 1, 1); + zend_string *const_TYPE_BOOL_name = zend_string_init_interned("TYPE_BOOL", sizeof("TYPE_BOOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_BOOL_name, &const_TYPE_BOOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_BOOL_name); + zend_string_release_ex(const_TYPE_BOOL_name, true); zval const_TYPE_CHAR_value; ZVAL_LONG(&const_TYPE_CHAR_value, ZEND_FFI_TYPE_CHAR); - zend_string *const_TYPE_CHAR_name = zend_string_init_interned("TYPE_CHAR", sizeof("TYPE_CHAR") - 1, 1); + zend_string *const_TYPE_CHAR_name = zend_string_init_interned("TYPE_CHAR", sizeof("TYPE_CHAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_CHAR_name, &const_TYPE_CHAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_CHAR_name); + zend_string_release_ex(const_TYPE_CHAR_name, true); zval const_TYPE_POINTER_value; ZVAL_LONG(&const_TYPE_POINTER_value, ZEND_FFI_TYPE_POINTER); - zend_string *const_TYPE_POINTER_name = zend_string_init_interned("TYPE_POINTER", sizeof("TYPE_POINTER") - 1, 1); + zend_string *const_TYPE_POINTER_name = zend_string_init_interned("TYPE_POINTER", sizeof("TYPE_POINTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_POINTER_name, &const_TYPE_POINTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_POINTER_name); + zend_string_release_ex(const_TYPE_POINTER_name, true); zval const_TYPE_FUNC_value; ZVAL_LONG(&const_TYPE_FUNC_value, ZEND_FFI_TYPE_FUNC); - zend_string *const_TYPE_FUNC_name = zend_string_init_interned("TYPE_FUNC", sizeof("TYPE_FUNC") - 1, 1); + zend_string *const_TYPE_FUNC_name = zend_string_init_interned("TYPE_FUNC", sizeof("TYPE_FUNC") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_FUNC_name, &const_TYPE_FUNC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_FUNC_name); + zend_string_release_ex(const_TYPE_FUNC_name, true); zval const_TYPE_ARRAY_value; ZVAL_LONG(&const_TYPE_ARRAY_value, ZEND_FFI_TYPE_ARRAY); - zend_string *const_TYPE_ARRAY_name = zend_string_init_interned("TYPE_ARRAY", sizeof("TYPE_ARRAY") - 1, 1); + zend_string *const_TYPE_ARRAY_name = zend_string_init_interned("TYPE_ARRAY", sizeof("TYPE_ARRAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_ARRAY_name, &const_TYPE_ARRAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_ARRAY_name); + zend_string_release_ex(const_TYPE_ARRAY_name, true); zval const_TYPE_STRUCT_value; ZVAL_LONG(&const_TYPE_STRUCT_value, ZEND_FFI_TYPE_STRUCT); - zend_string *const_TYPE_STRUCT_name = zend_string_init_interned("TYPE_STRUCT", sizeof("TYPE_STRUCT") - 1, 1); + zend_string *const_TYPE_STRUCT_name = zend_string_init_interned("TYPE_STRUCT", sizeof("TYPE_STRUCT") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_STRUCT_name, &const_TYPE_STRUCT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_STRUCT_name); + zend_string_release_ex(const_TYPE_STRUCT_name, true); zval const_ATTR_CONST_value; ZVAL_LONG(&const_ATTR_CONST_value, ZEND_FFI_ATTR_CONST); - zend_string *const_ATTR_CONST_name = zend_string_init_interned("ATTR_CONST", sizeof("ATTR_CONST") - 1, 1); + zend_string *const_ATTR_CONST_name = zend_string_init_interned("ATTR_CONST", sizeof("ATTR_CONST") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_CONST_name, &const_ATTR_CONST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_CONST_name); + zend_string_release_ex(const_ATTR_CONST_name, true); zval const_ATTR_INCOMPLETE_TAG_value; ZVAL_LONG(&const_ATTR_INCOMPLETE_TAG_value, ZEND_FFI_ATTR_INCOMPLETE_TAG); - zend_string *const_ATTR_INCOMPLETE_TAG_name = zend_string_init_interned("ATTR_INCOMPLETE_TAG", sizeof("ATTR_INCOMPLETE_TAG") - 1, 1); + zend_string *const_ATTR_INCOMPLETE_TAG_name = zend_string_init_interned("ATTR_INCOMPLETE_TAG", sizeof("ATTR_INCOMPLETE_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_INCOMPLETE_TAG_name, &const_ATTR_INCOMPLETE_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_INCOMPLETE_TAG_name); + zend_string_release_ex(const_ATTR_INCOMPLETE_TAG_name, true); zval const_ATTR_VARIADIC_value; ZVAL_LONG(&const_ATTR_VARIADIC_value, ZEND_FFI_ATTR_VARIADIC); - zend_string *const_ATTR_VARIADIC_name = zend_string_init_interned("ATTR_VARIADIC", sizeof("ATTR_VARIADIC") - 1, 1); + zend_string *const_ATTR_VARIADIC_name = zend_string_init_interned("ATTR_VARIADIC", sizeof("ATTR_VARIADIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_VARIADIC_name, &const_ATTR_VARIADIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_VARIADIC_name); + zend_string_release_ex(const_ATTR_VARIADIC_name, true); zval const_ATTR_INCOMPLETE_ARRAY_value; ZVAL_LONG(&const_ATTR_INCOMPLETE_ARRAY_value, ZEND_FFI_ATTR_INCOMPLETE_ARRAY); - zend_string *const_ATTR_INCOMPLETE_ARRAY_name = zend_string_init_interned("ATTR_INCOMPLETE_ARRAY", sizeof("ATTR_INCOMPLETE_ARRAY") - 1, 1); + zend_string *const_ATTR_INCOMPLETE_ARRAY_name = zend_string_init_interned("ATTR_INCOMPLETE_ARRAY", sizeof("ATTR_INCOMPLETE_ARRAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_INCOMPLETE_ARRAY_name, &const_ATTR_INCOMPLETE_ARRAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_INCOMPLETE_ARRAY_name); + zend_string_release_ex(const_ATTR_INCOMPLETE_ARRAY_name, true); zval const_ATTR_VLA_value; ZVAL_LONG(&const_ATTR_VLA_value, ZEND_FFI_ATTR_VLA); - zend_string *const_ATTR_VLA_name = zend_string_init_interned("ATTR_VLA", sizeof("ATTR_VLA") - 1, 1); + zend_string *const_ATTR_VLA_name = zend_string_init_interned("ATTR_VLA", sizeof("ATTR_VLA") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_VLA_name, &const_ATTR_VLA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_VLA_name); + zend_string_release_ex(const_ATTR_VLA_name, true); zval const_ATTR_UNION_value; ZVAL_LONG(&const_ATTR_UNION_value, ZEND_FFI_ATTR_UNION); - zend_string *const_ATTR_UNION_name = zend_string_init_interned("ATTR_UNION", sizeof("ATTR_UNION") - 1, 1); + zend_string *const_ATTR_UNION_name = zend_string_init_interned("ATTR_UNION", sizeof("ATTR_UNION") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_UNION_name, &const_ATTR_UNION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_UNION_name); + zend_string_release_ex(const_ATTR_UNION_name, true); zval const_ATTR_PACKED_value; ZVAL_LONG(&const_ATTR_PACKED_value, ZEND_FFI_ATTR_PACKED); - zend_string *const_ATTR_PACKED_name = zend_string_init_interned("ATTR_PACKED", sizeof("ATTR_PACKED") - 1, 1); + zend_string *const_ATTR_PACKED_name = zend_string_init_interned("ATTR_PACKED", sizeof("ATTR_PACKED") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_PACKED_name, &const_ATTR_PACKED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_PACKED_name); + zend_string_release_ex(const_ATTR_PACKED_name, true); zval const_ATTR_MS_STRUCT_value; ZVAL_LONG(&const_ATTR_MS_STRUCT_value, ZEND_FFI_ATTR_MS_STRUCT); - zend_string *const_ATTR_MS_STRUCT_name = zend_string_init_interned("ATTR_MS_STRUCT", sizeof("ATTR_MS_STRUCT") - 1, 1); + zend_string *const_ATTR_MS_STRUCT_name = zend_string_init_interned("ATTR_MS_STRUCT", sizeof("ATTR_MS_STRUCT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_MS_STRUCT_name, &const_ATTR_MS_STRUCT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_MS_STRUCT_name); + zend_string_release_ex(const_ATTR_MS_STRUCT_name, true); zval const_ATTR_GCC_STRUCT_value; ZVAL_LONG(&const_ATTR_GCC_STRUCT_value, ZEND_FFI_ATTR_GCC_STRUCT); - zend_string *const_ATTR_GCC_STRUCT_name = zend_string_init_interned("ATTR_GCC_STRUCT", sizeof("ATTR_GCC_STRUCT") - 1, 1); + zend_string *const_ATTR_GCC_STRUCT_name = zend_string_init_interned("ATTR_GCC_STRUCT", sizeof("ATTR_GCC_STRUCT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_GCC_STRUCT_name, &const_ATTR_GCC_STRUCT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_GCC_STRUCT_name); + zend_string_release_ex(const_ATTR_GCC_STRUCT_name, true); zval const_ABI_DEFAULT_value; ZVAL_LONG(&const_ABI_DEFAULT_value, ZEND_FFI_ABI_DEFAULT); - zend_string *const_ABI_DEFAULT_name = zend_string_init_interned("ABI_DEFAULT", sizeof("ABI_DEFAULT") - 1, 1); + zend_string *const_ABI_DEFAULT_name = zend_string_init_interned("ABI_DEFAULT", sizeof("ABI_DEFAULT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_DEFAULT_name, &const_ABI_DEFAULT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_DEFAULT_name); + zend_string_release_ex(const_ABI_DEFAULT_name, true); zval const_ABI_CDECL_value; ZVAL_LONG(&const_ABI_CDECL_value, ZEND_FFI_ABI_CDECL); - zend_string *const_ABI_CDECL_name = zend_string_init_interned("ABI_CDECL", sizeof("ABI_CDECL") - 1, 1); + zend_string *const_ABI_CDECL_name = zend_string_init_interned("ABI_CDECL", sizeof("ABI_CDECL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_CDECL_name, &const_ABI_CDECL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_CDECL_name); + zend_string_release_ex(const_ABI_CDECL_name, true); zval const_ABI_FASTCALL_value; ZVAL_LONG(&const_ABI_FASTCALL_value, ZEND_FFI_ABI_FASTCALL); - zend_string *const_ABI_FASTCALL_name = zend_string_init_interned("ABI_FASTCALL", sizeof("ABI_FASTCALL") - 1, 1); + zend_string *const_ABI_FASTCALL_name = zend_string_init_interned("ABI_FASTCALL", sizeof("ABI_FASTCALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_FASTCALL_name, &const_ABI_FASTCALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_FASTCALL_name); + zend_string_release_ex(const_ABI_FASTCALL_name, true); zval const_ABI_THISCALL_value; ZVAL_LONG(&const_ABI_THISCALL_value, ZEND_FFI_ABI_THISCALL); - zend_string *const_ABI_THISCALL_name = zend_string_init_interned("ABI_THISCALL", sizeof("ABI_THISCALL") - 1, 1); + zend_string *const_ABI_THISCALL_name = zend_string_init_interned("ABI_THISCALL", sizeof("ABI_THISCALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_THISCALL_name, &const_ABI_THISCALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_THISCALL_name); + zend_string_release_ex(const_ABI_THISCALL_name, true); zval const_ABI_STDCALL_value; ZVAL_LONG(&const_ABI_STDCALL_value, ZEND_FFI_ABI_STDCALL); - zend_string *const_ABI_STDCALL_name = zend_string_init_interned("ABI_STDCALL", sizeof("ABI_STDCALL") - 1, 1); + zend_string *const_ABI_STDCALL_name = zend_string_init_interned("ABI_STDCALL", sizeof("ABI_STDCALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_STDCALL_name, &const_ABI_STDCALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_STDCALL_name); + zend_string_release_ex(const_ABI_STDCALL_name, true); zval const_ABI_PASCAL_value; ZVAL_LONG(&const_ABI_PASCAL_value, ZEND_FFI_ABI_PASCAL); - zend_string *const_ABI_PASCAL_name = zend_string_init_interned("ABI_PASCAL", sizeof("ABI_PASCAL") - 1, 1); + zend_string *const_ABI_PASCAL_name = zend_string_init_interned("ABI_PASCAL", sizeof("ABI_PASCAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_PASCAL_name, &const_ABI_PASCAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_PASCAL_name); + zend_string_release_ex(const_ABI_PASCAL_name, true); zval const_ABI_REGISTER_value; ZVAL_LONG(&const_ABI_REGISTER_value, ZEND_FFI_ABI_REGISTER); - zend_string *const_ABI_REGISTER_name = zend_string_init_interned("ABI_REGISTER", sizeof("ABI_REGISTER") - 1, 1); + zend_string *const_ABI_REGISTER_name = zend_string_init_interned("ABI_REGISTER", sizeof("ABI_REGISTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_REGISTER_name, &const_ABI_REGISTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_REGISTER_name); + zend_string_release_ex(const_ABI_REGISTER_name, true); zval const_ABI_MS_value; ZVAL_LONG(&const_ABI_MS_value, ZEND_FFI_ABI_MS); - zend_string *const_ABI_MS_name = zend_string_init_interned("ABI_MS", sizeof("ABI_MS") - 1, 1); + zend_string *const_ABI_MS_name = zend_string_init_interned("ABI_MS", sizeof("ABI_MS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_MS_name, &const_ABI_MS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_MS_name); + zend_string_release_ex(const_ABI_MS_name, true); zval const_ABI_SYSV_value; ZVAL_LONG(&const_ABI_SYSV_value, ZEND_FFI_ABI_SYSV); - zend_string *const_ABI_SYSV_name = zend_string_init_interned("ABI_SYSV", sizeof("ABI_SYSV") - 1, 1); + zend_string *const_ABI_SYSV_name = zend_string_init_interned("ABI_SYSV", sizeof("ABI_SYSV") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_SYSV_name, &const_ABI_SYSV_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_SYSV_name); + zend_string_release_ex(const_ABI_SYSV_name, true); zval const_ABI_VECTORCALL_value; ZVAL_LONG(&const_ABI_VECTORCALL_value, ZEND_FFI_ABI_VECTORCALL); - zend_string *const_ABI_VECTORCALL_name = zend_string_init_interned("ABI_VECTORCALL", sizeof("ABI_VECTORCALL") - 1, 1); + zend_string *const_ABI_VECTORCALL_name = zend_string_init_interned("ABI_VECTORCALL", sizeof("ABI_VECTORCALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ABI_VECTORCALL_name, &const_ABI_VECTORCALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ABI_VECTORCALL_name); + zend_string_release_ex(const_ABI_VECTORCALL_name, true); return class_entry; } diff --git a/ext/ffi/ffi_parser.c b/ext/ffi/ffi_parser.c index 26d623a40290e..1067f80939f39 100644 --- a/ext/ffi/ffi_parser.c +++ b/ext/ffi/ffi_parser.c @@ -2634,7 +2634,7 @@ static int parse_enumerator(int sym, zend_ffi_dcl *enum_dcl, int64_t *min, int64 static int parse_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_t *name_len) { zend_ffi_dcl nested_dcl = {ZEND_FFI_DCL_CHAR, 0, 0, 0, NULL}; - bool nested = 0; + bool nested = false; if (sym == YY__STAR) { sym = parse_pointer(sym, dcl); } @@ -2650,7 +2650,7 @@ static int parse_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_ yy_error_sym("')' expected, got", sym); } sym = get_sym(); - nested = 1; + nested = true; } else { yy_error_sym("unexpected", sym); } @@ -2663,7 +2663,7 @@ static int parse_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_ static int parse_abstract_declarator(int sym, zend_ffi_dcl *dcl) { zend_ffi_dcl nested_dcl = {ZEND_FFI_DCL_CHAR, 0, 0, 0, NULL}; - bool nested = 0; + bool nested = false; if (sym == YY__STAR) { sym = parse_pointer(sym, dcl); } @@ -2677,7 +2677,7 @@ static int parse_abstract_declarator(int sym, zend_ffi_dcl *dcl) { yy_error_sym("')' expected, got", sym); } sym = get_sym(); - nested = 1; + nested = true; } if (sym == YY__LBRACK || sym == YY__LPAREN) { sym = parse_array_or_function_declarators(sym, dcl, &nested_dcl); @@ -2688,7 +2688,7 @@ static int parse_abstract_declarator(int sym, zend_ffi_dcl *dcl) { static int parse_parameter_declarator(int sym, zend_ffi_dcl *dcl, const char **name, size_t *name_len) { zend_ffi_dcl nested_dcl = {ZEND_FFI_DCL_CHAR, 0, 0, 0, NULL}; - bool nested = 0; + bool nested = false; if (sym == YY__STAR) { sym = parse_pointer(sym, dcl); } @@ -2702,7 +2702,7 @@ static int parse_parameter_declarator(int sym, zend_ffi_dcl *dcl, const char **n yy_error_sym("')' expected, got", sym); } sym = get_sym(); - nested = 1; + nested = true; } else if (sym == YY_ID) { sym = parse_ID(sym, name, name_len); } else if (sym == YY__LBRACK || sym == YY__LPAREN || sym == YY__RPAREN || sym == YY__COMMA) { diff --git a/ext/fileinfo/libmagic/config.h b/ext/fileinfo/libmagic/config.h index 4af6e06c4127d..34a10d59faa18 100644 --- a/ext/fileinfo/libmagic/config.h +++ b/ext/fileinfo/libmagic/config.h @@ -2,11 +2,7 @@ #include "php_libmagic.h" #ifndef HAVE_STDINT_H -#define HAVE_STDINT_H 1 -#endif - -#ifndef HAVE_STDINT_H -#define HAVE_STDINT_H 1 +# define HAVE_STDINT_H 1 #endif #ifndef HAVE_VISIBILITY diff --git a/ext/filter/callback_filter.c b/ext/filter/callback_filter.c index 719b66767980f..dea39c6cc7c30 100644 --- a/ext/filter/callback_filter.c +++ b/ext/filter/callback_filter.c @@ -19,22 +19,21 @@ zend_result php_filter_callback(PHP_INPUT_FILTER_PARAM_DECL) { zval retval; - int status; + zend_fcall_info_cache fcc; - if (!option_array || !zend_is_callable(option_array, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL)) { + if (!option_array || !zend_is_callable_ex(option_array, NULL, IS_CALLABLE_SUPPRESS_DEPRECATIONS, NULL, &fcc, NULL)) { zend_type_error("%s(): Option must be a valid callback", get_active_function_name()); zval_ptr_dtor(value); ZVAL_NULL(value); return SUCCESS; } - status = call_user_function(NULL, NULL, option_array, &retval, 1, value); + zend_call_known_fcc(&fcc, &retval, 1, value, NULL); + zval_ptr_dtor(value); - if (status == SUCCESS && !Z_ISUNDEF(retval)) { - zval_ptr_dtor(value); + if (!Z_ISUNDEF(retval)) { ZVAL_COPY_VALUE(value, &retval); } else { - zval_ptr_dtor(value); ZVAL_NULL(value); } return SUCCESS; diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 2dec236114182..20760e656e763 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -788,7 +788,7 @@ static bool _php_filter_validate_ipv6(const char *str, size_t str_len, int ip[8] const char *s = str; if (!memchr(str, ':', str_len)) { - return 0; + return false; } /* check for bundled IPv4 */ @@ -799,12 +799,12 @@ static bool _php_filter_validate_ipv6(const char *str, size_t str_len, int ip[8] } if (!_php_filter_validate_ipv4(ipv4, (str_len - (ipv4 - str)), ip4elm)) { - return 0; + return false; } str_len = ipv4 - str; /* length excluding ipv4 */ if (str_len < 2) { - return 0; + return false; } if (ipv4[-2] != ':') { diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 5291a1f172dac..0c1287a3e7052 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -130,7 +130,7 @@ ftpbuf_t* ftp_open(const char *host, short port, zend_long timeout_sec) /* Default Settings */ ftp->timeout_sec = timeout_sec; - ftp->nb = 0; + ftp->nb = false; size = sizeof(ftp->localaddr); memset(&ftp->localaddr, 0, size); @@ -263,8 +263,8 @@ bool ftp_login(ftpbuf_t *ftp, const char *user, const size_t user_len, const cha if (ftp->resp != 334) { return false; } else { - ftp->old_ssl = 1; - ftp->use_ssl_for_data = 1; + ftp->old_ssl = true; + ftp->use_ssl_for_data = true; } } @@ -385,7 +385,7 @@ bool ftp_reinit(ftpbuf_t *ftp) ftp_gc(ftp); - ftp->nb = 0; + ftp->nb = false; if (!ftp_putcmd(ftp, "REIN", sizeof("REIN")-1, NULL, (size_t) 0)) { return false; @@ -1193,7 +1193,7 @@ static bool ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const size_t cmd_len, con return false; } if (strpbrk(args, "\r\n")) { - return 0; + return false; } size = slprintf(data, sizeof(data), "%s %s\r\n", cmd, args); } else { @@ -1317,7 +1317,7 @@ static ssize_t my_recv_wrapper_with_restart(php_socket_t fd, void *buf, size_t s static int single_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t size) { #ifdef HAVE_FTP_SSL int err; - bool retry = 0; + bool retry = false; SSL *handle = NULL; php_socket_t fd; size_t sent; @@ -1338,11 +1338,11 @@ static int single_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t size) { switch (err) { case SSL_ERROR_NONE: - retry = 0; + retry = false; break; case SSL_ERROR_ZERO_RETURN: - retry = 0; + retry = false; SSL_shutdown(handle); break; @@ -1437,7 +1437,7 @@ static int my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len) int n, nr_bytes; #ifdef HAVE_FTP_SSL int err; - bool retry = 0; + bool retry = false; SSL *handle = NULL; php_socket_t fd; #endif @@ -1471,11 +1471,11 @@ static int my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len) switch (err) { case SSL_ERROR_NONE: - retry = 0; + retry = false; break; case SSL_ERROR_ZERO_RETURN: - retry = 0; + retry = false; SSL_shutdown(handle); break; @@ -1775,11 +1775,11 @@ static databuf_t* data_accept(databuf_t *data, ftpbuf_t *ftp) switch (err) { case SSL_ERROR_NONE: - retry = 0; + retry = false; break; case SSL_ERROR_ZERO_RETURN: - retry = 0; + retry = false; SSL_shutdown(data->ssl_handle); break; @@ -2063,7 +2063,7 @@ int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, const siz ftp->data = data; ftp->stream = outstream; ftp->lastch = 0; - ftp->nb = 1; + ftp->nb = true; return (ftp_nb_continue_read(ftp)); @@ -2123,10 +2123,10 @@ int ftp_nb_continue_read(ftpbuf_t *ftp) goto bail; } - ftp->nb = 0; + ftp->nb = false; return PHP_FTP_FINISHED; bail: - ftp->nb = 0; + ftp->nb = false; data_close(ftp); return PHP_FTP_FAILED; } @@ -2171,7 +2171,7 @@ int ftp_nb_put(ftpbuf_t *ftp, const char *path, const size_t path_len, php_strea ftp->data = data; ftp->stream = instream; ftp->lastch = 0; - ftp->nb = 1; + ftp->nb = true; return (ftp_nb_continue_write(ftp)); @@ -2200,10 +2200,10 @@ int ftp_nb_continue_write(ftpbuf_t *ftp) if (!ftp_getresp(ftp) || (ftp->resp != 226 && ftp->resp != 250)) { goto bail; } - ftp->nb = 0; + ftp->nb = false; return PHP_FTP_FINISHED; bail: data_close(ftp); - ftp->nb = 0; + ftp->nb = false; return PHP_FTP_FAILED; } diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 5a7cfe18dac82..63f5c222c1924 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -147,7 +147,7 @@ PHP_FUNCTION(ftp_connect) RETURN_THROWS(); } - const zend_long timeoutmax = (zend_long)((double) PHP_TIMEOUT_ULL_MAX / 1000000.0); + const uint64_t timeoutmax = (uint64_t)((double) PHP_TIMEOUT_ULL_MAX / 1000000.0); if (timeout_sec <= 0) { zend_argument_value_error(3, "must be greater than 0"); @@ -155,7 +155,7 @@ PHP_FUNCTION(ftp_connect) } if (timeout_sec >= timeoutmax) { - zend_argument_value_error(3, "must be less than " ZEND_LONG_FMT, timeoutmax); + zend_argument_value_error(3, "must be less than " ZEND_ULONG_FMT, timeoutmax); RETURN_THROWS(); } @@ -490,7 +490,7 @@ PHP_FUNCTION(ftp_rawlist) ftpbuf_t *ftp; char **llist, **ptr, *dir; size_t dir_len; - bool recursive = 0; + bool recursive = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os|b", &z_ftp, php_ftp_ce, &dir, &dir_len, &recursive) == FAILURE) { RETURN_THROWS(); diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index 0d024c9ea1cf3..a997238b7f75c 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -265,6 +265,10 @@ if test "$PHP_GD" != "no"; then AC_DEFINE([HAVE_GD_BUNDLED], [1], [Define to 1 if gd extension uses GD library bundled in PHP.]) + AC_DEFINE([HAVE_GD_GET_INTERPOLATION], [1], + [Define to 1 if GD library has the 'gdImageGetInterpolationMethod' + function.]) + dnl Various checks for GD features PHP_SETUP_ZLIB([GD_SHARED_LIBADD]) PHP_GD_PNG diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 5a5d51d19c09e..60b2ad65bf65e 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2976,7 +2976,8 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode) zend_long X, Y, COL; zend_string *C; gdImagePtr im; - int ch = 0, col, x, y, i; + int ch = 0, col, i; + unsigned int x, y; size_t l = 0; unsigned char *str = NULL; zend_object *font_obj = NULL; @@ -3009,21 +3010,21 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode) switch (mode) { case 0: - gdImageChar(im, font, x, y, ch, col); + gdImageChar(im, font, (int)x, (int)y, ch, col); break; case 1: php_gdimagecharup(im, font, x, y, ch, col); break; case 2: for (i = 0; (i < l); i++) { - gdImageChar(im, font, x, y, (int) ((unsigned char) str[i]), col); + gdImageChar(im, font, (int)x, (int)y, (int) ((unsigned char) str[i]), col); x += font->w; } break; case 3: { for (i = 0; (i < l); i++) { /* php_gdimagecharup(im, font, x, y, (int) str[i], col); */ - gdImageCharUp(im, font, x, y, (int) str[i], col); + gdImageCharUp(im, font, (int)x, (int)y, (int) str[i], col); y -= font->w; } break; @@ -3615,7 +3616,7 @@ PHP_FUNCTION(imagefilter) zval *tmp; typedef void (*image_filter)(INTERNAL_FUNCTION_PARAMETERS); - zend_long filtertype; + zend_long filtertype = 0; image_filter filters[] = { php_image_filter_negate , @@ -3633,9 +3634,9 @@ PHP_FUNCTION(imagefilter) php_image_filter_scatter }; - if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > IMAGE_FILTER_MAX_ARGS) { - WRONG_PARAM_COUNT; - } else if (zend_parse_parameters(2, "Ol", &tmp, gd_image_ce, &filtertype) == FAILURE) { + /* We need to do some initial ZPP parsing to be able to extract the filter value */ + if (zend_parse_parameters(MIN(2, ZEND_NUM_ARGS()), "Ol*", &tmp, gd_image_ce, &filtertype) == FAILURE) { + RETURN_THROWS(); } @@ -4396,7 +4397,7 @@ static gdIOCtx *create_output_context(zval *to_zval, uint32_t arg_num) { } close_stream = 0; } else if (Z_TYPE_P(to_zval) == IS_STRING) { - if (CHECK_ZVAL_NULL_PATH(to_zval)) { + if (zend_str_has_nul_byte(Z_STR_P(to_zval))) { zend_argument_type_error(arg_num, "must not contain null bytes"); return NULL; } diff --git a/ext/gd/tests/gh20622.phpt b/ext/gd/tests/gh20622.phpt new file mode 100644 index 0000000000000..42109ddc13e4d --- /dev/null +++ b/ext/gd/tests/gh20622.phpt @@ -0,0 +1,13 @@ +--TEST-- +GH-20622 (imagestring/imagestringup overflow/underflow) +--EXTENSIONS-- +gd +--FILE-- + +--EXPECT-- +OK diff --git a/ext/gd/tests/imagefilter_error1.phpt b/ext/gd/tests/imagefilter_error1.phpt index 6e2ccabb874a8..cc9904e320dac 100644 --- a/ext/gd/tests/imagefilter_error1.phpt +++ b/ext/gd/tests/imagefilter_error1.phpt @@ -14,6 +14,12 @@ try { } catch (TypeError $e) { echo $e->getMessage(), "\n"; } +try { + var_dump(imagefilter(20, 1)); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} ?> --EXPECT-- -Wrong parameter count for imagefilter() +imagefilter() expects at least 2 arguments, 1 given +imagefilter(): Argument #1 ($image) must be of type GdImage, int given diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index 8cf20c90fc7a2..b5451b8035e37 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -1535,7 +1535,7 @@ ZEND_FUNCTION(gmp_setbit) { zval *a_arg; zend_long index; - bool set = 1; + bool set = true; mpz_ptr gmpnum_a; if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ol|b", &a_arg, gmp_ce, &index, &set) == FAILURE) { diff --git a/ext/hash/hash.c b/ext/hash/hash.c index ec5391a623049..d255711efbed9 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -365,7 +365,7 @@ static void php_hash_do_hash( RETURN_THROWS(); } if (isfilename) { - if (CHECK_NULL_PATH(data, data_len)) { + if (zend_char_has_nul_byte(data, data_len)) { zend_argument_value_error(1, "must not contain any null bytes"); RETURN_THROWS(); } @@ -508,7 +508,7 @@ static void php_hash_do_hash_hmac( } if (isfilename) { - if (CHECK_NULL_PATH(data, data_len)) { + if (zend_char_has_nul_byte(data, data_len)) { zend_argument_value_error(2, "must not contain any null bytes"); RETURN_THROWS(); } @@ -577,13 +577,13 @@ PHP_FUNCTION(hash_hmac) zend_string *algo; char *data, *key; size_t data_len, key_len; - bool raw_output = 0; + bool raw_output = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sss|b", &algo, &data, &data_len, &key, &key_len, &raw_output) == FAILURE) { RETURN_THROWS(); } - php_hash_do_hash_hmac(return_value, algo, data, data_len, key, key_len, raw_output, 0); + php_hash_do_hash_hmac(return_value, algo, data, data_len, key, key_len, raw_output, false); } /* }}} */ @@ -594,13 +594,13 @@ PHP_FUNCTION(hash_hmac_file) zend_string *algo; char *data, *key; size_t data_len, key_len; - bool raw_output = 0; + bool raw_output = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sss|b", &algo, &data, &data_len, &key, &key_len, &raw_output) == FAILURE) { RETURN_THROWS(); } - php_hash_do_hash_hmac(return_value, algo, data, data_len, key, key_len, raw_output, 1); + php_hash_do_hash_hmac(return_value, algo, data, data_len, key, key_len, raw_output, true); } /* }}} */ @@ -778,7 +778,7 @@ PHP_FUNCTION(hash_final) { zval *zhash; php_hashcontext_object *hash; - bool raw_output = 0; + bool raw_output = false; zend_string *digest; size_t digest_len; @@ -989,7 +989,7 @@ PHP_FUNCTION(hash_pbkdf2) unsigned char *computed_salt, *digest, *temp, *result, *K1, *K2 = NULL; zend_long loops, i, j, iterations, digest_length = 0, length = 0; size_t pass_len, salt_len = 0; - bool raw_output = 0; + bool raw_output = false; const php_hash_ops *ops; void *context; HashTable *args = NULL; @@ -1227,9 +1227,9 @@ PHP_FUNCTION(mhash) } if (key) { - php_hash_do_hash_hmac(return_value, algo, data, data_len, key, key_len, 1, 0); + php_hash_do_hash_hmac(return_value, algo, data, data_len, key, key_len, true, false); } else { - php_hash_do_hash(return_value, algo, data, data_len, 1, 0, NULL); + php_hash_do_hash(return_value, algo, data, data_len, true, false, NULL); } if (algo) { diff --git a/ext/hash/xxhash/xxhash.h b/ext/hash/xxhash/xxhash.h index 259371a3addd6..a18e8c762daaa 100644 --- a/ext/hash/xxhash/xxhash.h +++ b/ext/hash/xxhash/xxhash.h @@ -1,7 +1,7 @@ /* * xxHash - Extremely Fast Hash algorithm * Header File - * Copyright (C) 2012-2020 Yann Collet + * Copyright (C) 2012-2021 Yann Collet * * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php) * @@ -32,49 +32,142 @@ * - xxHash homepage: https://www.xxhash.com * - xxHash source repository: https://github.com/Cyan4973/xxHash */ + /*! * @mainpage xxHash * + * xxHash is an extremely fast non-cryptographic hash algorithm, working at RAM speed + * limits. + * + * It is proposed in four flavors, in three families: + * 1. @ref XXH32_family + * - Classic 32-bit hash function. Simple, compact, and runs on almost all + * 32-bit and 64-bit systems. + * 2. @ref XXH64_family + * - Classic 64-bit adaptation of XXH32. Just as simple, and runs well on most + * 64-bit systems (but _not_ 32-bit systems). + * 3. @ref XXH3_family + * - Modern 64-bit and 128-bit hash function family which features improved + * strength and performance across the board, especially on smaller data. + * It benefits greatly from SIMD and 64-bit without requiring it. + * + * Benchmarks + * --- + * The reference system uses an Intel i7-9700K CPU, and runs Ubuntu x64 20.04. + * The open source benchmark program is compiled with clang v10.0 using -O3 flag. + * + * | Hash Name | ISA ext | Width | Large Data Speed | Small Data Velocity | + * | -------------------- | ------- | ----: | ---------------: | ------------------: | + * | XXH3_64bits() | @b AVX2 | 64 | 59.4 GB/s | 133.1 | + * | MeowHash | AES-NI | 128 | 58.2 GB/s | 52.5 | + * | XXH3_128bits() | @b AVX2 | 128 | 57.9 GB/s | 118.1 | + * | CLHash | PCLMUL | 64 | 37.1 GB/s | 58.1 | + * | XXH3_64bits() | @b SSE2 | 64 | 31.5 GB/s | 133.1 | + * | XXH3_128bits() | @b SSE2 | 128 | 29.6 GB/s | 118.1 | + * | RAM sequential read | | N/A | 28.0 GB/s | N/A | + * | ahash | AES-NI | 64 | 22.5 GB/s | 107.2 | + * | City64 | | 64 | 22.0 GB/s | 76.6 | + * | T1ha2 | | 64 | 22.0 GB/s | 99.0 | + * | City128 | | 128 | 21.7 GB/s | 57.7 | + * | FarmHash | AES-NI | 64 | 21.3 GB/s | 71.9 | + * | XXH64() | | 64 | 19.4 GB/s | 71.0 | + * | SpookyHash | | 64 | 19.3 GB/s | 53.2 | + * | Mum | | 64 | 18.0 GB/s | 67.0 | + * | CRC32C | SSE4.2 | 32 | 13.0 GB/s | 57.9 | + * | XXH32() | | 32 | 9.7 GB/s | 71.9 | + * | City32 | | 32 | 9.1 GB/s | 66.0 | + * | Blake3* | @b AVX2 | 256 | 4.4 GB/s | 8.1 | + * | Murmur3 | | 32 | 3.9 GB/s | 56.1 | + * | SipHash* | | 64 | 3.0 GB/s | 43.2 | + * | Blake3* | @b SSE2 | 256 | 2.4 GB/s | 8.1 | + * | HighwayHash | | 64 | 1.4 GB/s | 6.0 | + * | FNV64 | | 64 | 1.2 GB/s | 62.7 | + * | Blake2* | | 256 | 1.1 GB/s | 5.1 | + * | SHA1* | | 160 | 0.8 GB/s | 5.6 | + * | MD5* | | 128 | 0.6 GB/s | 7.8 | + * @note + * - Hashes which require a specific ISA extension are noted. SSE2 is also noted, + * even though it is mandatory on x64. + * - Hashes with an asterisk are cryptographic. Note that MD5 is non-cryptographic + * by modern standards. + * - Small data velocity is a rough average of algorithm's efficiency for small + * data. For more accurate information, see the wiki. + * - More benchmarks and strength tests are found on the wiki: + * https://github.com/Cyan4973/xxHash/wiki + * + * Usage + * ------ + * All xxHash variants use a similar API. Changing the algorithm is a trivial + * substitution. + * + * @pre + * For functions which take an input and length parameter, the following + * requirements are assumed: + * - The range from [`input`, `input + length`) is valid, readable memory. + * - The only exception is if the `length` is `0`, `input` may be `NULL`. + * - For C++, the objects must have the *TriviallyCopyable* property, as the + * functions access bytes directly as if it was an array of `unsigned char`. + * + * @anchor single_shot_example + * **Single Shot** + * + * These functions are stateless functions which hash a contiguous block of memory, + * immediately returning the result. They are the easiest and usually the fastest + * option. + * + * XXH32(), XXH64(), XXH3_64bits(), XXH3_128bits() + * + * @code{.c} + * #include + * #include "xxhash.h" + * + * // Example for a function which hashes a null terminated string with XXH32(). + * XXH32_hash_t hash_string(const char* string, XXH32_hash_t seed) + * { + * // NULL pointers are only valid if the length is zero + * size_t length = (string == NULL) ? 0 : strlen(string); + * return XXH32(string, length, seed); + * } + * @endcode + * + * @anchor streaming_example + * **Streaming** + * + * These groups of functions allow incremental hashing of unknown size, even + * more than what would fit in a size_t. + * + * XXH32_reset(), XXH64_reset(), XXH3_64bits_reset(), XXH3_128bits_reset() + * + * @code{.c} + * #include + * #include + * #include "xxhash.h" + * // Example for a function which hashes a FILE incrementally with XXH3_64bits(). + * XXH64_hash_t hashFile(FILE* f) + * { + * // Allocate a state struct. Do not just use malloc() or new. + * XXH3_state_t* state = XXH3_createState(); + * assert(state != NULL && "Out of memory!"); + * // Reset the state to start a new hashing session. + * XXH3_64bits_reset(state); + * char buffer[4096]; + * size_t count; + * // Read the file in chunks + * while ((count = fread(buffer, 1, sizeof(buffer), f)) != 0) { + * // Run update() as many times as necessary to process the data + * XXH3_64bits_update(state, buffer, count); + * } + * // Retrieve the finalized hash. This will not change the state. + * XXH64_hash_t result = XXH3_64bits_digest(state); + * // Free the state. Do not use free(). + * XXH3_freeState(state); + * return result; + * } + * @endcode + * * @file xxhash.h * xxHash prototypes and implementation */ -/* TODO: update */ -/* Notice extracted from xxHash homepage: - -xxHash is an extremely fast hash algorithm, running at RAM speed limits. -It also successfully passes all tests from the SMHasher suite. - -Comparison (single thread, Windows Seven 32 bits, using SMHasher on a Core 2 Duo @3GHz) - -Name Speed Q.Score Author -xxHash 5.4 GB/s 10 -CrapWow 3.2 GB/s 2 Andrew -MurmurHash 3a 2.7 GB/s 10 Austin Appleby -SpookyHash 2.0 GB/s 10 Bob Jenkins -SBox 1.4 GB/s 9 Bret Mulvey -Lookup3 1.2 GB/s 9 Bob Jenkins -SuperFastHash 1.2 GB/s 1 Paul Hsieh -CityHash64 1.05 GB/s 10 Pike & Alakuijala -FNV 0.55 GB/s 5 Fowler, Noll, Vo -CRC32 0.43 GB/s 9 -MD5-32 0.33 GB/s 10 Ronald L. Rivest -SHA1-32 0.28 GB/s 10 - -Q.Score is a measure of quality of the hash function. -It depends on successfully passing SMHasher test set. -10 is a perfect score. - -Note: SMHasher's CRC32 implementation is not the fastest one. -Other speed-oriented implementations can be faster, -especially in combination with PCLMUL instruction: -https://fastcompression.blogspot.com/2019/03/presenting-xxh3.html?showComment=1552696407071#c3490092340461170735 - -A 64-bit version, named XXH64, is available since r35. -It offers much better speed, but for 64-bit applications only. -Name Speed on 64 bits Speed on 32 bits -XXH64 13.8 GB/s 1.9 GB/s -XXH32 6.8 GB/s 6.0 GB/s -*/ #if defined (__cplusplus) extern "C" { @@ -84,21 +177,80 @@ extern "C" { * INLINE mode ******************************/ /*! - * XXH_INLINE_ALL (and XXH_PRIVATE_API) + * @defgroup public Public API + * Contains details on the public xxHash functions. + * @{ + */ +#ifdef XXH_DOXYGEN +/*! + * @brief Gives access to internal state declaration, required for static allocation. + * + * Incompatible with dynamic linking, due to risks of ABI changes. + * + * Usage: + * @code{.c} + * #define XXH_STATIC_LINKING_ONLY + * #include "xxhash.h" + * @endcode + */ +# define XXH_STATIC_LINKING_ONLY +/* Do not undef XXH_STATIC_LINKING_ONLY for Doxygen */ + +/*! + * @brief Gives access to internal definitions. + * + * Usage: + * @code{.c} + * #define XXH_STATIC_LINKING_ONLY + * #define XXH_IMPLEMENTATION + * #include "xxhash.h" + * @endcode + */ +# define XXH_IMPLEMENTATION +/* Do not undef XXH_IMPLEMENTATION for Doxygen */ + +/*! + * @brief Exposes the implementation and marks all functions as `inline`. + * * Use these build macros to inline xxhash into the target unit. * Inlining improves performance on small inputs, especially when the length is * expressed as a compile-time constant: * - * https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html + * https://fastcompression.blogspot.com/2018/03/xxhash-for-small-keys-impressive-power.html * * It also keeps xxHash symbols private to the unit, so they are not exported. * * Usage: + * @code{.c} * #define XXH_INLINE_ALL * #include "xxhash.h" - * + * @endcode * Do not compile and link xxhash.o as a separate object, as it is not useful. */ +# define XXH_INLINE_ALL +# undef XXH_INLINE_ALL +/*! + * @brief Exposes the implementation without marking functions as inline. + */ +# define XXH_PRIVATE_API +# undef XXH_PRIVATE_API +/*! + * @brief Emulate a namespace by transparently prefixing all symbols. + * + * If you want to include _and expose_ xxHash functions from within your own + * library, but also want to avoid symbol collisions with other libraries which + * may also include xxHash, you can use @ref XXH_NAMESPACE to automatically prefix + * any public symbol from xxhash library with the value of @ref XXH_NAMESPACE + * (therefore, avoid empty or numeric values). + * + * Note that no change is required within the calling program as long as it + * includes `xxhash.h`: Regular symbol names will be automatically translated + * by this header. + */ +# define XXH_NAMESPACE /* YOUR NAME HERE */ +# undef XXH_NAMESPACE +#endif + #if (defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API)) \ && !defined(XXH_INLINE_ALL_31684351384) /* this section should be traversed only once */ @@ -213,23 +365,15 @@ extern "C" { # undef XXHASH_H_STATIC_13879238742 #endif /* XXH_INLINE_ALL || XXH_PRIVATE_API */ - - /* **************************************************************** * Stable API *****************************************************************/ #ifndef XXHASH_H_5627135585666179 #define XXHASH_H_5627135585666179 1 - -/*! - * @defgroup public Public API - * Contains details on the public xxHash functions. - * @{ - */ -/* specific declaration modes for Windows */ +/*! @brief Marks a global symbol. */ #if !defined(XXH_INLINE_ALL) && !defined(XXH_PRIVATE_API) -# if defined(_WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) +# if defined(WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) # ifdef XXH_EXPORT # define XXH_PUBLIC_API __declspec(dllexport) # elif XXH_IMPORT @@ -240,24 +384,6 @@ extern "C" { # endif #endif -#ifdef XXH_DOXYGEN -/*! - * @brief Emulate a namespace by transparently prefixing all symbols. - * - * If you want to include _and expose_ xxHash functions from within your own - * library, but also want to avoid symbol collisions with other libraries which - * may also include xxHash, you can use XXH_NAMESPACE to automatically prefix - * any public symbol from xxhash library with the value of XXH_NAMESPACE - * (therefore, avoid empty or numeric values). - * - * Note that no change is required within the calling program as long as it - * includes `xxhash.h`: Regular symbol names will be automatically translated - * by this header. - */ -# define XXH_NAMESPACE /* YOUR NAME HERE */ -# undef XXH_NAMESPACE -#endif - #ifdef XXH_NAMESPACE # define XXH_CAT(A,B) A##B # define XXH_NAME2(A,B) XXH_CAT(A,B) @@ -317,12 +443,40 @@ extern "C" { #endif +/* ************************************* +* Compiler specifics +***************************************/ + +/* specific declaration modes for Windows */ +#if !defined(XXH_INLINE_ALL) && !defined(XXH_PRIVATE_API) +# if defined(WIN32) && defined(_MSC_VER) && (defined(XXH_IMPORT) || defined(XXH_EXPORT)) +# ifdef XXH_EXPORT +# define XXH_PUBLIC_API __declspec(dllexport) +# elif XXH_IMPORT +# define XXH_PUBLIC_API __declspec(dllimport) +# endif +# else +# define XXH_PUBLIC_API /* do nothing */ +# endif +#endif + +#if defined (__GNUC__) +# define XXH_CONSTF __attribute__((const)) +# define XXH_PUREF __attribute__((pure)) +# define XXH_MALLOCF __attribute__((malloc)) +#else +# define XXH_CONSTF /* disable */ +# define XXH_PUREF +# define XXH_MALLOCF +#endif + /* ************************************* * Version ***************************************/ #define XXH_VERSION_MAJOR 0 #define XXH_VERSION_MINOR 8 -#define XXH_VERSION_RELEASE 1 +#define XXH_VERSION_RELEASE 2 +/*! @brief Version number, encoded as two digits each */ #define XXH_VERSION_NUMBER (XXH_VERSION_MAJOR *100*100 + XXH_VERSION_MINOR *100 + XXH_VERSION_RELEASE) /*! @@ -331,16 +485,22 @@ extern "C" { * This is mostly useful when xxHash is compiled as a shared library, * since the returned value comes from the library, as opposed to header file. * - * @return `XXH_VERSION_NUMBER` of the invoked library. + * @return @ref XXH_VERSION_NUMBER of the invoked library. */ -XXH_PUBLIC_API unsigned XXH_versionNumber (void); +XXH_PUBLIC_API XXH_CONSTF unsigned XXH_versionNumber (void); /* **************************** * Common basic types ******************************/ #include /* size_t */ -typedef enum { XXH_OK=0, XXH_ERROR } XXH_errorcode; +/*! + * @brief Exit code for the streaming API. + */ +typedef enum { + XXH_OK = 0, /*!< OK */ + XXH_ERROR /*!< Error */ +} XXH_errorcode; /*-********************************************************************** @@ -364,29 +524,27 @@ typedef uint32_t XXH32_hash_t; # include # if UINT_MAX == 0xFFFFFFFFUL typedef unsigned int XXH32_hash_t; +# elif ULONG_MAX == 0xFFFFFFFFUL + typedef unsigned long XXH32_hash_t; # else -# if ULONG_MAX == 0xFFFFFFFFUL - typedef unsigned long XXH32_hash_t; -# else -# error "unsupported platform: need a 32-bit type" -# endif +# error "unsupported platform: need a 32-bit type" # endif #endif /*! * @} * - * @defgroup xxh32_family XXH32 family + * @defgroup XXH32_family XXH32 family * @ingroup public * Contains functions used in the classic 32-bit xxHash algorithm. * * @note * XXH32 is useful for older platforms, with no or poor 64-bit performance. - * Note that @ref xxh3_family provides competitive speed - * for both 32-bit and 64-bit systems, and offers true 64/128 bit hash results. + * Note that the @ref XXH3_family provides competitive speed for both 32-bit + * and 64-bit systems, and offers true 64/128 bit hash results. * - * @see @ref xxh64_family, @ref xxh3_family : Other xxHash families - * @see @ref xxh32_impl for implementation details + * @see @ref XXH64_family, @ref XXH3_family : Other xxHash families + * @see @ref XXH32_impl for implementation details * @{ */ @@ -395,6 +553,8 @@ typedef uint32_t XXH32_hash_t; * * Speed on Core 2 Duo @ 3 GHz (single thread, SMHasher benchmark): 5.4 GB/s * + * See @ref single_shot_example "Single Shot Example" for an example. + * * @param input The block of data to be hashed, at least @p length bytes in size. * @param length The length of @p input, in bytes. * @param seed The 32-bit seed to alter the hash's output predictably. @@ -412,8 +572,9 @@ typedef uint32_t XXH32_hash_t; * @see * XXH32_createState(), XXH32_update(), XXH32_digest(): Streaming version. */ -XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, XXH32_hash_t seed); +XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32 (const void* input, size_t length, XXH32_hash_t seed); +#ifndef XXH_NO_STREAM /*! * Streaming functions generate the xxHash value from an incremental input. * This method is slower than single-call functions, due to state management. @@ -436,32 +597,7 @@ XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t length, XXH32_hash_ * * When done, release the state using `XXH*_freeState()`. * - * Example code for incrementally hashing a file: - * @code{.c} - * #include - * #include - * #define BUFFER_SIZE 256 - * - * // Note: XXH64 and XXH3 use the same interface. - * XXH32_hash_t - * hashFile(FILE* stream) - * { - * XXH32_state_t* state; - * unsigned char buf[BUFFER_SIZE]; - * size_t amt; - * XXH32_hash_t hash; - * - * state = XXH32_createState(); // Create a state - * assert(state != NULL); // Error check here - * XXH32_reset(state, 0xbaad5eed); // Reset state with our seed - * while ((amt = fread(buf, 1, sizeof(buf), stream)) != 0) { - * XXH32_update(state, buf, amt); // Hash the file in chunks - * } - * hash = XXH32_digest(state); // Finalize the hash - * XXH32_freeState(state); // Clean up - * return hash; - * } - * @endcode + * @see streaming_example at the top of @ref xxhash.h for an example. */ /*! @@ -478,7 +614,7 @@ typedef struct XXH32_state_s XXH32_state_t; * Must be freed with XXH32_freeState(). * @return An allocated XXH32_state_t on success, `NULL` on failure. */ -XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void); +XXH_PUBLIC_API XXH_MALLOCF XXH32_state_t* XXH32_createState(void); /*! * @brief Frees an @ref XXH32_state_t. * @@ -546,7 +682,8 @@ XXH_PUBLIC_API XXH_errorcode XXH32_update (XXH32_state_t* statePtr, const void* * * @return The calculated xxHash32 value from that state. */ -XXH_PUBLIC_API XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr); +XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_digest (const XXH32_state_t* statePtr); +#endif /* !XXH_NO_STREAM */ /******* Canonical representation *******/ @@ -597,43 +734,72 @@ XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t * * @return The converted hash. */ -XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src); +XXH_PUBLIC_API XXH_PUREF XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src); +/*! @cond Doxygen ignores this part */ #ifdef __has_attribute # define XXH_HAS_ATTRIBUTE(x) __has_attribute(x) #else # define XXH_HAS_ATTRIBUTE(x) 0 #endif +/*! @endcond */ +/*! @cond Doxygen ignores this part */ +/* + * C23 __STDC_VERSION__ number hasn't been specified yet. For now + * leave as `201711L` (C17 + 1). + * TODO: Update to correct value when its been specified. + */ +#define XXH_C23_VN 201711L +/*! @endcond */ + +/*! @cond Doxygen ignores this part */ /* C-language Attributes are added in C23. */ -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201710L) && defined(__has_c_attribute) +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= XXH_C23_VN) && defined(__has_c_attribute) # define XXH_HAS_C_ATTRIBUTE(x) __has_c_attribute(x) #else # define XXH_HAS_C_ATTRIBUTE(x) 0 #endif +/*! @endcond */ +/*! @cond Doxygen ignores this part */ #if defined(__cplusplus) && defined(__has_cpp_attribute) # define XXH_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) #else # define XXH_HAS_CPP_ATTRIBUTE(x) 0 #endif +/*! @endcond */ +/*! @cond Doxygen ignores this part */ /* -Define XXH_FALLTHROUGH macro for annotating switch case with the 'fallthrough' attribute -introduced in CPP17 and C23. -CPP17 : https://en.cppreference.com/w/cpp/language/attributes/fallthrough -C23 : https://en.cppreference.com/w/c/language/attributes/fallthrough -*/ -#if XXH_HAS_C_ATTRIBUTE(x) -# define XXH_FALLTHROUGH [[fallthrough]] -#elif XXH_HAS_CPP_ATTRIBUTE(x) + * Define XXH_FALLTHROUGH macro for annotating switch case with the 'fallthrough' attribute + * introduced in CPP17 and C23. + * CPP17 : https://en.cppreference.com/w/cpp/language/attributes/fallthrough + * C23 : https://en.cppreference.com/w/c/language/attributes/fallthrough + */ +#if XXH_HAS_C_ATTRIBUTE(fallthrough) || XXH_HAS_CPP_ATTRIBUTE(fallthrough) # define XXH_FALLTHROUGH [[fallthrough]] #elif XXH_HAS_ATTRIBUTE(__fallthrough__) -# define XXH_FALLTHROUGH __attribute__ ((fallthrough)) +# define XXH_FALLTHROUGH __attribute__ ((__fallthrough__)) #else -# define XXH_FALLTHROUGH +# define XXH_FALLTHROUGH /* fallthrough */ #endif +/*! @endcond */ + +/*! @cond Doxygen ignores this part */ +/* + * Define XXH_NOESCAPE for annotated pointers in public API. + * https://clang.llvm.org/docs/AttributeReference.html#noescape + * As of writing this, only supported by clang. + */ +#if XXH_HAS_ATTRIBUTE(noescape) +# define XXH_NOESCAPE __attribute__((noescape)) +#else +# define XXH_NOESCAPE +#endif +/*! @endcond */ + /*! * @} @@ -671,7 +837,7 @@ typedef uint64_t XXH64_hash_t; /*! * @} * - * @defgroup xxh64_family XXH64 family + * @defgroup XXH64_family XXH64 family * @ingroup public * @{ * Contains functions used in the classic 64-bit xxHash algorithm. @@ -682,7 +848,6 @@ typedef uint64_t XXH64_hash_t; * It provides better speed for systems with vector processing capabilities. */ - /*! * @brief Calculates the 64-bit hash of @p input using xxHash64. * @@ -706,32 +871,131 @@ typedef uint64_t XXH64_hash_t; * @see * XXH64_createState(), XXH64_update(), XXH64_digest(): Streaming version. */ -XXH_PUBLIC_API XXH64_hash_t XXH64(const void* input, size_t length, XXH64_hash_t seed); +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64(XXH_NOESCAPE const void* input, size_t length, XXH64_hash_t seed); /******* Streaming *******/ +#ifndef XXH_NO_STREAM /*! * @brief The opaque state struct for the XXH64 streaming API. * * @see XXH64_state_s for details. */ typedef struct XXH64_state_s XXH64_state_t; /* incomplete type */ -XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void); + +/*! + * @brief Allocates an @ref XXH64_state_t. + * + * Must be freed with XXH64_freeState(). + * @return An allocated XXH64_state_t on success, `NULL` on failure. + */ +XXH_PUBLIC_API XXH_MALLOCF XXH64_state_t* XXH64_createState(void); + +/*! + * @brief Frees an @ref XXH64_state_t. + * + * Must be allocated with XXH64_createState(). + * @param statePtr A pointer to an @ref XXH64_state_t allocated with @ref XXH64_createState(). + * @return XXH_OK. + */ XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr); -XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dst_state, const XXH64_state_t* src_state); -XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH64_state_t* statePtr, XXH64_hash_t seed); -XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH64_state_t* statePtr, const void* input, size_t length); -XXH_PUBLIC_API XXH64_hash_t XXH64_digest (const XXH64_state_t* statePtr); +/*! + * @brief Copies one @ref XXH64_state_t to another. + * + * @param dst_state The state to copy to. + * @param src_state The state to copy from. + * @pre + * @p dst_state and @p src_state must not be `NULL` and must not overlap. + */ +XXH_PUBLIC_API void XXH64_copyState(XXH_NOESCAPE XXH64_state_t* dst_state, const XXH64_state_t* src_state); +/*! + * @brief Resets an @ref XXH64_state_t to begin a new hash. + * + * This function resets and seeds a state. Call it before @ref XXH64_update(). + * + * @param statePtr The state struct to reset. + * @param seed The 64-bit seed to alter the hash result predictably. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + */ +XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH_NOESCAPE XXH64_state_t* statePtr, XXH64_hash_t seed); + +/*! + * @brief Consumes a block of @p input to an @ref XXH64_state_t. + * + * Call this to incrementally consume blocks of data. + * + * @param statePtr The state struct to update. + * @param input The block of data to be hashed, at least @p length bytes in size. + * @param length The length of @p input, in bytes. + * + * @pre + * @p statePtr must not be `NULL`. + * @pre + * The memory between @p input and @p input + @p length must be valid, + * readable, contiguous memory. However, if @p length is `0`, @p input may be + * `NULL`. In C++, this also must be *TriviallyCopyable*. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + */ +XXH_PUBLIC_API XXH_errorcode XXH64_update (XXH_NOESCAPE XXH64_state_t* statePtr, XXH_NOESCAPE const void* input, size_t length); + +/*! + * @brief Returns the calculated hash value from an @ref XXH64_state_t. + * + * @note + * Calling XXH64_digest() will not affect @p statePtr, so you can update, + * digest, and update again. + * + * @param statePtr The state struct to calculate the hash from. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return The calculated xxHash64 value from that state. + */ +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64_digest (XXH_NOESCAPE const XXH64_state_t* statePtr); +#endif /* !XXH_NO_STREAM */ /******* Canonical representation *******/ + +/*! + * @brief Canonical (big endian) representation of @ref XXH64_hash_t. + */ typedef struct { unsigned char digest[sizeof(XXH64_hash_t)]; } XXH64_canonical_t; -XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash); -XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src); + +/*! + * @brief Converts an @ref XXH64_hash_t to a big endian @ref XXH64_canonical_t. + * + * @param dst The @ref XXH64_canonical_t pointer to be stored to. + * @param hash The @ref XXH64_hash_t to be converted. + * + * @pre + * @p dst must not be `NULL`. + */ +XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH_NOESCAPE XXH64_canonical_t* dst, XXH64_hash_t hash); + +/*! + * @brief Converts an @ref XXH64_canonical_t to a native @ref XXH64_hash_t. + * + * @param src The @ref XXH64_canonical_t to convert. + * + * @pre + * @p src must not be `NULL`. + * + * @return The converted hash. + */ +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_canonical_t* src); + +#ifndef XXH_NO_XXH3 /*! * @} * ************************************************************************ - * @defgroup xxh3_family XXH3 family + * @defgroup XXH3_family XXH3 family * @ingroup public * @{ * @@ -751,16 +1015,26 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src * * XXH3's speed benefits greatly from SIMD and 64-bit arithmetic, * but does not require it. - * Any 32-bit and 64-bit targets that can run XXH32 smoothly - * can run XXH3 at competitive speeds, even without vector support. - * Further details are explained in the implementation. - * - * Optimized implementations are provided for AVX512, AVX2, SSE2, NEON, POWER8, - * ZVector and scalar targets. This can be controlled via the XXH_VECTOR macro. + * Most 32-bit and 64-bit targets that can run XXH32 smoothly can run XXH3 + * at competitive speeds, even without vector support. Further details are + * explained in the implementation. + * + * XXH3 has a fast scalar implementation, but it also includes accelerated SIMD + * implementations for many common platforms: + * - AVX512 + * - AVX2 + * - SSE2 + * - ARM NEON + * - WebAssembly SIMD128 + * - POWER8 VSX + * - s390x ZVector + * This can be controlled via the @ref XXH_VECTOR macro, but it automatically + * selects the best version according to predefined macros. For the x86 family, an + * automatic runtime dispatcher is included separately in @ref xxh_x86dispatch.c. * * XXH3 implementation is portable: * it has a generic C90 formulation that can be compiled on any platform, - * all implementations generage exactly the same hash value on all platforms. + * all implementations generate exactly the same hash value on all platforms. * Starting from v0.8.0, it's also labelled "stable", meaning that * any future version will also generate the same hash value. * @@ -772,24 +1046,42 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src * * The API supports one-shot hashing, streaming mode, and custom secrets. */ - /*-********************************************************************** * XXH3 64-bit variant ************************************************************************/ -/* XXH3_64bits(): - * default 64-bit variant, using default secret and default seed of 0. - * It's the fastest variant. */ -XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(const void* data, size_t len); +/*! + * @brief 64-bit unseeded variant of XXH3. + * + * This is equivalent to @ref XXH3_64bits_withSeed() with a seed of 0, however + * it may have slightly better performance due to constant propagation of the + * defaults. + * + * @see + * XXH32(), XXH64(), XXH3_128bits(): equivalent for the other xxHash algorithms + * @see + * XXH3_64bits_withSeed(), XXH3_64bits_withSecret(): other seeding variants + * @see + * XXH3_64bits_reset(), XXH3_64bits_update(), XXH3_64bits_digest(): Streaming version. + */ +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits(XXH_NOESCAPE const void* input, size_t length); -/* - * XXH3_64bits_withSeed(): - * This variant generates a custom secret on the fly - * based on default secret altered using the `seed` value. +/*! + * @brief 64-bit seeded variant of XXH3 + * + * This variant generates a custom secret on the fly based on default secret + * altered using the `seed` value. + * * While this operation is decently fast, note that it's not completely free. - * Note: seed==0 produces the same results as XXH3_64bits(). + * + * @note + * seed == 0 produces the same results as @ref XXH3_64bits(). + * + * @param input The data to hash + * @param length The length + * @param seed The 64-bit seed to alter the state. */ -XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data, size_t len, XXH64_hash_t seed); +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_withSeed(XXH_NOESCAPE const void* input, size_t length, XXH64_hash_t seed); /*! * The bare minimum size for a custom secret. @@ -800,8 +1092,9 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data, size_t len, X */ #define XXH3_SECRET_SIZE_MIN 136 -/* - * XXH3_64bits_withSecret(): +/*! + * @brief 64-bit variant of XXH3 with a custom "secret". + * * It's possible to provide any blob of bytes as a "secret" to generate the hash. * This makes it more difficult for an external actor to prepare an intentional collision. * The main condition is that secretSize *must* be large enough (>= XXH3_SECRET_SIZE_MIN). @@ -817,10 +1110,11 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSeed(const void* data, size_t len, X * This is not necessarily the case when using the blob of bytes directly * because, when hashing _small_ inputs, only a portion of the secret is employed. */ -XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize); +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_withSecret(XXH_NOESCAPE const void* data, size_t len, XXH_NOESCAPE const void* secret, size_t secretSize); /******* Streaming *******/ +#ifndef XXH_NO_STREAM /* * Streaming requires state maintenance. * This operation costs memory and CPU. @@ -834,23 +1128,53 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_withSecret(const void* data, size_t len, * @see XXH3_state_s for details. */ typedef struct XXH3_state_s XXH3_state_t; -XXH_PUBLIC_API XXH3_state_t* XXH3_createState(void); +XXH_PUBLIC_API XXH_MALLOCF XXH3_state_t* XXH3_createState(void); XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_state_t* statePtr); -XXH_PUBLIC_API void XXH3_copyState(XXH3_state_t* dst_state, const XXH3_state_t* src_state); -/* - * XXH3_64bits_reset(): - * Initialize with default parameters. - * digest will be equivalent to `XXH3_64bits()`. +/*! + * @brief Copies one @ref XXH3_state_t to another. + * + * @param dst_state The state to copy to. + * @param src_state The state to copy from. + * @pre + * @p dst_state and @p src_state must not be `NULL` and must not overlap. */ -XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH3_state_t* statePtr); -/* - * XXH3_64bits_reset_withSeed(): - * Generate a custom secret from `seed`, and store it into `statePtr`. - * digest will be equivalent to `XXH3_64bits_withSeed()`. +XXH_PUBLIC_API void XXH3_copyState(XXH_NOESCAPE XXH3_state_t* dst_state, XXH_NOESCAPE const XXH3_state_t* src_state); + +/*! + * @brief Resets an @ref XXH3_state_t to begin a new hash. + * + * This function resets `statePtr` and generate a secret with default parameters. Call it before @ref XXH3_64bits_update(). + * Digest will be equivalent to `XXH3_64bits()`. + * + * @param statePtr The state struct to reset. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + * */ -XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed); -/* +XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset(XXH_NOESCAPE XXH3_state_t* statePtr); + +/*! + * @brief Resets an @ref XXH3_state_t with 64-bit seed to begin a new hash. + * + * This function resets `statePtr` and generate a secret from `seed`. Call it before @ref XXH3_64bits_update(). + * Digest will be equivalent to `XXH3_64bits_withSeed()`. + * + * @param statePtr The state struct to reset. + * @param seed The 64-bit seed to alter the state. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + * + */ +XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed); + +/*! * XXH3_64bits_reset_withSecret(): * `secret` is referenced, it _must outlive_ the hash streaming session. * Similar to one-shot API, `secretSize` must be >= `XXH3_SECRET_SIZE_MIN`, @@ -859,10 +1183,44 @@ XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, * When in doubt about the randomness of a candidate `secret`, * consider employing `XXH3_generateSecret()` instead (see below). */ -XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize); +XXH_PUBLIC_API XXH_errorcode XXH3_64bits_reset_withSecret(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize); -XXH_PUBLIC_API XXH_errorcode XXH3_64bits_update (XXH3_state_t* statePtr, const void* input, size_t length); -XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* statePtr); +/*! + * @brief Consumes a block of @p input to an @ref XXH3_state_t. + * + * Call this to incrementally consume blocks of data. + * + * @param statePtr The state struct to update. + * @param input The block of data to be hashed, at least @p length bytes in size. + * @param length The length of @p input, in bytes. + * + * @pre + * @p statePtr must not be `NULL`. + * @pre + * The memory between @p input and @p input + @p length must be valid, + * readable, contiguous memory. However, if @p length is `0`, @p input may be + * `NULL`. In C++, this also must be *TriviallyCopyable*. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + */ +XXH_PUBLIC_API XXH_errorcode XXH3_64bits_update (XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* input, size_t length); + +/*! + * @brief Returns the calculated XXH3 64-bit hash value from an @ref XXH3_state_t. + * + * @note + * Calling XXH3_64bits_digest() will not affect @p statePtr, so you can update, + * digest, and update again. + * + * @param statePtr The state struct to calculate the hash from. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return The calculated XXH3 64-bit hash value from that state. + */ +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t XXH3_64bits_digest (XXH_NOESCAPE const XXH3_state_t* statePtr); +#endif /* !XXH_NO_STREAM */ /* note : canonical representation of XXH3 is the same as XXH64 * since they both produce XXH64_hash_t values */ @@ -883,11 +1241,31 @@ typedef struct { XXH64_hash_t high64; /*!< `value >> 64` */ } XXH128_hash_t; -XXH_PUBLIC_API XXH128_hash_t XXH3_128bits(const void* data, size_t len); -XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSeed(const void* data, size_t len, XXH64_hash_t seed); -XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSecret(const void* data, size_t len, const void* secret, size_t secretSize); +/*! + * @brief Unseeded 128-bit variant of XXH3 + * + * The 128-bit variant of XXH3 has more strength, but it has a bit of overhead + * for shorter inputs. + * + * This is equivalent to @ref XXH3_128bits_withSeed() with a seed of 0, however + * it may have slightly better performance due to constant propagation of the + * defaults. + * + * @see + * XXH32(), XXH64(), XXH3_64bits(): equivalent for the other xxHash algorithms + * @see + * XXH3_128bits_withSeed(), XXH3_128bits_withSecret(): other seeding variants + * @see + * XXH3_128bits_reset(), XXH3_128bits_update(), XXH3_128bits_digest(): Streaming version. + */ +XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits(XXH_NOESCAPE const void* data, size_t len); +/*! @brief Seeded 128-bit variant of XXH3. @see XXH3_64bits_withSeed(). */ +XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_withSeed(XXH_NOESCAPE const void* data, size_t len, XXH64_hash_t seed); +/*! @brief Custom secret 128-bit variant of XXH3. @see XXH3_64bits_withSecret(). */ +XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_withSecret(XXH_NOESCAPE const void* data, size_t len, XXH_NOESCAPE const void* secret, size_t secretSize); /******* Streaming *******/ +#ifndef XXH_NO_STREAM /* * Streaming requires state maintenance. * This operation costs memory and CPU. @@ -900,12 +1278,77 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_withSecret(const void* data, size_t le * All reset and streaming functions have same meaning as their 64-bit counterpart. */ -XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset(XXH3_state_t* statePtr); -XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed); -XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize); +/*! + * @brief Resets an @ref XXH3_state_t to begin a new hash. + * + * This function resets `statePtr` and generate a secret with default parameters. Call it before @ref XXH3_128bits_update(). + * Digest will be equivalent to `XXH3_128bits()`. + * + * @param statePtr The state struct to reset. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + * + */ +XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset(XXH_NOESCAPE XXH3_state_t* statePtr); + +/*! + * @brief Resets an @ref XXH3_state_t with 64-bit seed to begin a new hash. + * + * This function resets `statePtr` and generate a secret from `seed`. Call it before @ref XXH3_128bits_update(). + * Digest will be equivalent to `XXH3_128bits_withSeed()`. + * + * @param statePtr The state struct to reset. + * @param seed The 64-bit seed to alter the state. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + * + */ +XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed); +/*! @brief Custom secret 128-bit variant of XXH3. @see XXH_64bits_reset_withSecret(). */ +XXH_PUBLIC_API XXH_errorcode XXH3_128bits_reset_withSecret(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize); + +/*! + * @brief Consumes a block of @p input to an @ref XXH3_state_t. + * + * Call this to incrementally consume blocks of data. + * + * @param statePtr The state struct to update. + * @param input The block of data to be hashed, at least @p length bytes in size. + * @param length The length of @p input, in bytes. + * + * @pre + * @p statePtr must not be `NULL`. + * @pre + * The memory between @p input and @p input + @p length must be valid, + * readable, contiguous memory. However, if @p length is `0`, @p input may be + * `NULL`. In C++, this also must be *TriviallyCopyable*. + * + * @return @ref XXH_OK on success, @ref XXH_ERROR on failure. + */ +XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update (XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* input, size_t length); -XXH_PUBLIC_API XXH_errorcode XXH3_128bits_update (XXH3_state_t* statePtr, const void* input, size_t length); -XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* statePtr); +/*! + * @brief Returns the calculated XXH3 128-bit hash value from an @ref XXH3_state_t. + * + * @note + * Calling XXH3_128bits_digest() will not affect @p statePtr, so you can update, + * digest, and update again. + * + * @param statePtr The state struct to calculate the hash from. + * + * @pre + * @p statePtr must not be `NULL`. + * + * @return The calculated XXH3 128-bit hash value from that state. + */ +XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH3_128bits_digest (XXH_NOESCAPE const XXH3_state_t* statePtr); +#endif /* !XXH_NO_STREAM */ /* Following helper functions make it possible to compare XXH128_hast_t values. * Since XXH128_hash_t is a structure, this capability is not offered by the language. @@ -915,26 +1358,48 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* statePtr); * XXH128_isEqual(): * Return: 1 if `h1` and `h2` are equal, 0 if they are not. */ -XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2); +XXH_PUBLIC_API XXH_PUREF int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2); /*! - * XXH128_cmp(): - * + * @brief Compares two @ref XXH128_hash_t * This comparator is compatible with stdlib's `qsort()`/`bsearch()`. * - * return: >0 if *h128_1 > *h128_2 - * =0 if *h128_1 == *h128_2 - * <0 if *h128_1 < *h128_2 + * @return: >0 if *h128_1 > *h128_2 + * =0 if *h128_1 == *h128_2 + * <0 if *h128_1 < *h128_2 */ -XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2); +XXH_PUBLIC_API XXH_PUREF int XXH128_cmp(XXH_NOESCAPE const void* h128_1, XXH_NOESCAPE const void* h128_2); /******* Canonical representation *******/ typedef struct { unsigned char digest[sizeof(XXH128_hash_t)]; } XXH128_canonical_t; -static zend_always_inline void XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash); -XXH_PUBLIC_API XXH128_hash_t XXH128_hashFromCanonical(const XXH128_canonical_t* src); +/*! + * @brief Converts an @ref XXH128_hash_t to a big endian @ref XXH128_canonical_t. + * + * @param dst The @ref XXH128_canonical_t pointer to be stored to. + * @param hash The @ref XXH128_hash_t to be converted. + * + * @pre + * @p dst must not be `NULL`. + */ +XXH_PUBLIC_API void XXH128_canonicalFromHash(XXH_NOESCAPE XXH128_canonical_t* dst, XXH128_hash_t hash); + +/*! + * @brief Converts an @ref XXH128_canonical_t to a native @ref XXH128_hash_t. + * + * @param src The @ref XXH128_canonical_t to convert. + * + * @pre + * @p src must not be `NULL`. + * + * @return The converted hash. + */ +XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128_hashFromCanonical(XXH_NOESCAPE const XXH128_canonical_t* src); + + +#endif /* !XXH_NO_XXH3 */ #endif /* XXH_NO_LONG_LONG */ /*! @@ -978,7 +1443,7 @@ struct XXH32_state_s { XXH32_hash_t v[4]; /*!< Accumulator lanes */ XXH32_hash_t mem32[4]; /*!< Internal buffer for partial reads. Treated as unsigned char[16]. */ XXH32_hash_t memsize; /*!< Amount of data in @ref mem32 */ - XXH32_hash_t reserved; /*!< Reserved field. Do not read or write to it, it may be removed. */ + XXH32_hash_t reserved; /*!< Reserved field. Do not read nor write to it. */ }; /* typedef'd to XXH32_state_t */ @@ -1002,9 +1467,11 @@ struct XXH64_state_s { XXH64_hash_t mem64[4]; /*!< Internal buffer for partial reads. Treated as unsigned char[32]. */ XXH32_hash_t memsize; /*!< Amount of data in @ref mem64 */ XXH32_hash_t reserved32; /*!< Reserved field, needed for padding anyways*/ - XXH64_hash_t reserved64; /*!< Reserved field. Do not read or write to it, it may be removed. */ + XXH64_hash_t reserved64; /*!< Reserved field. Do not read or write to it. */ }; /* typedef'd to XXH64_state_t */ +#ifndef XXH_NO_XXH3 + #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* >= C11 */ # include # define XXH_ALIGN(n) alignas(n) @@ -1038,6 +1505,7 @@ struct XXH64_state_s { #define XXH3_INTERNALBUFFER_SIZE 256 /*! + * @internal * @brief Default size of the secret buffer (and @ref XXH3_kSecret). * * This is the size used in @ref XXH3_kSecret and the seeded functions. @@ -1070,7 +1538,7 @@ struct XXH64_state_s { */ struct XXH3_state_s { XXH_ALIGN_MEMBER(64, XXH64_hash_t acc[8]); - /*!< The 8 accumulators. Similar to `vN` in @ref XXH32_state_s::v1 and @ref XXH64_state_s */ + /*!< The 8 accumulators. See @ref XXH32_state_s::v and @ref XXH64_state_s::v */ XXH_ALIGN_MEMBER(64, unsigned char customSecret[XXH3_SECRET_DEFAULT_SIZE]); /*!< Used to store a custom secret generated from a seed. */ XXH_ALIGN_MEMBER(64, unsigned char buffer[XXH3_INTERNALBUFFER_SIZE]); @@ -1110,69 +1578,119 @@ struct XXH3_state_s { * Note that this doesn't prepare the state for a streaming operation, * it's still necessary to use XXH3_NNbits_reset*() afterwards. */ -#define XXH3_INITSTATE(XXH3_state_ptr) { (XXH3_state_ptr)->seed = 0; } +#define XXH3_INITSTATE(XXH3_state_ptr) \ + do { \ + XXH3_state_t* tmp_xxh3_state_ptr = (XXH3_state_ptr); \ + tmp_xxh3_state_ptr->seed = 0; \ + tmp_xxh3_state_ptr->extSecret = NULL; \ + } while(0) -/* XXH128() : +/*! * simple alias to pre-selected XXH3_128bits variant */ -XXH_PUBLIC_API XXH128_hash_t XXH128(const void* data, size_t len, XXH64_hash_t seed); +XXH_PUBLIC_API XXH_PUREF XXH128_hash_t XXH128(XXH_NOESCAPE const void* data, size_t len, XXH64_hash_t seed); /* === Experimental API === */ /* Symbols defined below must be considered tied to a specific library version. */ -/* +/*! * XXH3_generateSecret(): * * Derive a high-entropy secret from any user-defined content, named customSeed. * The generated secret can be used in combination with `*_withSecret()` functions. - * The `_withSecret()` variants are useful to provide a higher level of protection than 64-bit seed, - * as it becomes much more difficult for an external actor to guess how to impact the calculation logic. + * The `_withSecret()` variants are useful to provide a higher level of protection + * than 64-bit seed, as it becomes much more difficult for an external actor to + * guess how to impact the calculation logic. * * The function accepts as input a custom seed of any length and any content, - * and derives from it a high-entropy secret of length @secretSize - * into an already allocated buffer @secretBuffer. - * @secretSize must be >= XXH3_SECRET_SIZE_MIN + * and derives from it a high-entropy secret of length @p secretSize into an + * already allocated buffer @p secretBuffer. * * The generated secret can then be used with any `*_withSecret()` variant. - * Functions `XXH3_128bits_withSecret()`, `XXH3_64bits_withSecret()`, - * `XXH3_128bits_reset_withSecret()` and `XXH3_64bits_reset_withSecret()` + * The functions @ref XXH3_128bits_withSecret(), @ref XXH3_64bits_withSecret(), + * @ref XXH3_128bits_reset_withSecret() and @ref XXH3_64bits_reset_withSecret() * are part of this list. They all accept a `secret` parameter - * which must be large enough for implementation reasons (>= XXH3_SECRET_SIZE_MIN) + * which must be large enough for implementation reasons (>= @ref XXH3_SECRET_SIZE_MIN) * _and_ feature very high entropy (consist of random-looking bytes). - * These conditions can be a high bar to meet, so - * XXH3_generateSecret() can be employed to ensure proper quality. + * These conditions can be a high bar to meet, so @ref XXH3_generateSecret() can + * be employed to ensure proper quality. * - * customSeed can be anything. It can have any size, even small ones, - * and its content can be anything, even "poor entropy" sources such as a bunch of zeroes. - * The resulting `secret` will nonetheless provide all required qualities. + * @p customSeed can be anything. It can have any size, even small ones, + * and its content can be anything, even "poor entropy" sources such as a bunch + * of zeroes. The resulting `secret` will nonetheless provide all required qualities. + * + * @pre + * - @p secretSize must be >= @ref XXH3_SECRET_SIZE_MIN + * - When @p customSeedSize > 0, supplying NULL as customSeed is undefined behavior. * - * When customSeedSize > 0, supplying NULL as customSeed is undefined behavior. + * Example code: + * @code{.c} + * #include + * #include + * #include + * #define XXH_STATIC_LINKING_ONLY // expose unstable API + * #include "xxhash.h" + * // Hashes argv[2] using the entropy from argv[1]. + * int main(int argc, char* argv[]) + * { + * char secret[XXH3_SECRET_SIZE_MIN]; + * if (argv != 3) { return 1; } + * XXH3_generateSecret(secret, sizeof(secret), argv[1], strlen(argv[1])); + * XXH64_hash_t h = XXH3_64bits_withSecret( + * argv[2], strlen(argv[2]), + * secret, sizeof(secret) + * ); + * printf("%016llx\n", (unsigned long long) h); + * } + * @endcode */ -XXH_PUBLIC_API XXH_errorcode XXH3_generateSecret(void* secretBuffer, size_t secretSize, const void* customSeed, size_t customSeedSize); - +XXH_PUBLIC_API XXH_errorcode XXH3_generateSecret(XXH_NOESCAPE void* secretBuffer, size_t secretSize, XXH_NOESCAPE const void* customSeed, size_t customSeedSize); -/* - * XXH3_generateSecret_fromSeed(): - * - * Generate the same secret as the _withSeed() variants. - * - * The resulting secret has a length of XXH3_SECRET_DEFAULT_SIZE (necessarily). - * @secretBuffer must be already allocated, of size at least XXH3_SECRET_DEFAULT_SIZE bytes. +/*! + * @brief Generate the same secret as the _withSeed() variants. * * The generated secret can be used in combination with *`*_withSecret()` and `_withSecretandSeed()` variants. - * This generator is notably useful in combination with `_withSecretandSeed()`, - * as a way to emulate a faster `_withSeed()` variant. + * + * Example C++ `std::string` hash class: + * @code{.cpp} + * #include + * #define XXH_STATIC_LINKING_ONLY // expose unstable API + * #include "xxhash.h" + * // Slow, seeds each time + * class HashSlow { + * XXH64_hash_t seed; + * public: + * HashSlow(XXH64_hash_t s) : seed{s} {} + * size_t operator()(const std::string& x) const { + * return size_t{XXH3_64bits_withSeed(x.c_str(), x.length(), seed)}; + * } + * }; + * // Fast, caches the seeded secret for future uses. + * class HashFast { + * unsigned char secret[XXH3_SECRET_SIZE_MIN]; + * public: + * HashFast(XXH64_hash_t s) { + * XXH3_generateSecret_fromSeed(secret, seed); + * } + * size_t operator()(const std::string& x) const { + * return size_t{ + * XXH3_64bits_withSecret(x.c_str(), x.length(), secret, sizeof(secret)) + * }; + * } + * }; + * @endcode + * @param secretBuffer A writable buffer of @ref XXH3_SECRET_SIZE_MIN bytes + * @param seed The seed to seed the state. */ -XXH_PUBLIC_API void XXH3_generateSecret_fromSeed(void* secretBuffer, XXH64_hash_t seed); +XXH_PUBLIC_API void XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed); -/* - * *_withSecretandSeed() : +/*! * These variants generate hash values using either - * @seed for "short" keys (< XXH3_MIDSIZE_MAX = 240 bytes) - * or @secret for "large" keys (>= XXH3_MIDSIZE_MAX). + * @p seed for "short" keys (< XXH3_MIDSIZE_MAX = 240 bytes) + * or @p secret for "large" keys (>= XXH3_MIDSIZE_MAX). * * This generally benefits speed, compared to `_withSeed()` or `_withSecret()`. * `_withSeed()` has to generate the secret on the fly for "large" keys. @@ -1181,7 +1699,7 @@ XXH_PUBLIC_API void XXH3_generateSecret_fromSeed(void* secretBuffer, XXH64_hash_ * which requires more instructions than _withSeed() variants. * Therefore, _withSecretandSeed variant combines the best of both worlds. * - * When @secret has been generated by XXH3_generateSecret_fromSeed(), + * When @p secret has been generated by XXH3_generateSecret_fromSeed(), * this variant produces *exactly* the same results as `_withSeed()` variant, * hence offering only a pure speed benefit on "large" input, * by skipping the need to regenerate the secret for every large input. @@ -1190,32 +1708,34 @@ XXH_PUBLIC_API void XXH3_generateSecret_fromSeed(void* secretBuffer, XXH64_hash_ * for example with XXH3_64bits(), which then becomes the seed, * and then employ both the seed and the secret in _withSecretandSeed(). * On top of speed, an added benefit is that each bit in the secret - * has a 50% chance to swap each bit in the output, - * via its impact to the seed. + * has a 50% chance to swap each bit in the output, via its impact to the seed. + * * This is not guaranteed when using the secret directly in "small data" scenarios, * because only portions of the secret are employed for small data. */ -XXH_PUBLIC_API XXH64_hash_t -XXH3_64bits_withSecretandSeed(const void* data, size_t len, - const void* secret, size_t secretSize, +XXH_PUBLIC_API XXH_PUREF XXH64_hash_t +XXH3_64bits_withSecretandSeed(XXH_NOESCAPE const void* data, size_t len, + XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed); - -XXH_PUBLIC_API XXH128_hash_t -XXH3_128bits_withSecretandSeed(const void* data, size_t len, - const void* secret, size_t secretSize, +/*! @copydoc XXH3_64bits_withSecretandSeed() */ +XXH_PUBLIC_API XXH_PUREF XXH128_hash_t +XXH3_128bits_withSecretandSeed(XXH_NOESCAPE const void* input, size_t length, + XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed64); - +#ifndef XXH_NO_STREAM +/*! @copydoc XXH3_64bits_withSecretandSeed() */ XXH_PUBLIC_API XXH_errorcode -XXH3_64bits_reset_withSecretandSeed(XXH3_state_t* statePtr, - const void* secret, size_t secretSize, +XXH3_64bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, + XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed64); - +/*! @copydoc XXH3_64bits_withSecretandSeed() */ XXH_PUBLIC_API XXH_errorcode -XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, - const void* secret, size_t secretSize, +XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, + XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed64); +#endif /* !XXH_NO_STREAM */ - +#endif /* !XXH_NO_XXH3 */ #endif /* XXH_NO_LONG_LONG */ #if defined(XXH_INLINE_ALL) || defined(XXH_PRIVATE_API) # define XXH_IMPLEMENTATION @@ -1269,7 +1789,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, /*! * @brief Define this to disable 64-bit code. * - * Useful if only using the @ref xxh32_family and you have a strict C90 compiler. + * Useful if only using the @ref XXH32_family and you have a strict C90 compiler. */ # define XXH_NO_LONG_LONG # undef XXH_NO_LONG_LONG /* don't actually */ @@ -1292,7 +1812,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, * Use `memcpy()`. Safe and portable. Note that most modern compilers will * eliminate the function call and treat it as an unaligned access. * - * - `XXH_FORCE_MEMORY_ACCESS=1`: `__attribute__((packed))` + * - `XXH_FORCE_MEMORY_ACCESS=1`: `__attribute__((aligned(1)))` * @par * Depends on compiler extensions and is therefore not portable. * This method is safe _if_ your compiler supports it, @@ -1312,19 +1832,47 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, * inline small `memcpy()` calls, and it might also be faster on big-endian * systems which lack a native byteswap instruction. However, some compilers * will emit literal byteshifts even if the target supports unaligned access. - * . + * * * @warning * Methods 1 and 2 rely on implementation-defined behavior. Use these with * care, as what works on one compiler/platform/optimization level may cause * another to read garbage data or even crash. * - * See http://fastcompression.blogspot.com/2015/08/accessing-unaligned-memory.html for details. + * See https://fastcompression.blogspot.com/2015/08/accessing-unaligned-memory.html for details. * * Prefer these methods in priority order (0 > 3 > 1 > 2) */ # define XXH_FORCE_MEMORY_ACCESS 0 +/*! + * @def XXH_SIZE_OPT + * @brief Controls how much xxHash optimizes for size. + * + * xxHash, when compiled, tends to result in a rather large binary size. This + * is mostly due to heavy usage to forced inlining and constant folding of the + * @ref XXH3_family to increase performance. + * + * However, some developers prefer size over speed. This option can + * significantly reduce the size of the generated code. When using the `-Os` + * or `-Oz` options on GCC or Clang, this is defined to 1 by default, + * otherwise it is defined to 0. + * + * Most of these size optimizations can be controlled manually. + * + * This is a number from 0-2. + * - `XXH_SIZE_OPT` == 0: Default. xxHash makes no size optimizations. Speed + * comes first. + * - `XXH_SIZE_OPT` == 1: Default for `-Os` and `-Oz`. xxHash is more + * conservative and disables hacks that increase code size. It implies the + * options @ref XXH_NO_INLINE_HINTS == 1, @ref XXH_FORCE_ALIGN_CHECK == 0, + * and @ref XXH3_NEON_LANES == 8 if they are not already defined. + * - `XXH_SIZE_OPT` == 2: xxHash tries to make itself as small as possible. + * Performance may cry. For example, the single shot functions just use the + * streaming API. + */ +# define XXH_SIZE_OPT 0 + /*! * @def XXH_FORCE_ALIGN_CHECK * @brief If defined to non-zero, adds a special path for aligned inputs (XXH32() @@ -1346,9 +1894,11 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, * * In these cases, the alignment check can be removed by setting this macro to 0. * Then the code will always use unaligned memory access. - * Align check is automatically disabled on x86, x64 & arm64, + * Align check is automatically disabled on x86, x64, ARM64, and some ARM chips * which are platforms known to offer good unaligned memory accesses performance. * + * It is also disabled by default when @ref XXH_SIZE_OPT >= 1. + * * This option does not affect XXH3 (only XXH32 and XXH64). */ # define XXH_FORCE_ALIGN_CHECK 0 @@ -1370,8 +1920,8 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, * XXH_NO_INLINE_HINTS marks all internal functions as static, giving the * compiler full control on whether to inline or not. * - * When not optimizing (-O0), optimizing for size (-Os, -Oz), or using - * -fno-inline with GCC or Clang, this will automatically be defined. + * When not optimizing (-O0), using `-fno-inline` with GCC or Clang, or if + * @ref XXH_SIZE_OPT >= 1, this will automatically be defined. */ # define XXH_NO_INLINE_HINTS 0 @@ -1413,34 +1963,45 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, */ # define XXH_OLD_NAMES # undef XXH_OLD_NAMES /* don't actually use, it is ugly. */ + +/*! + * @def XXH_NO_STREAM + * @brief Disables the streaming API. + * + * When xxHash is not inlined and the streaming functions are not used, disabling + * the streaming functions can improve code size significantly, especially with + * the @ref XXH3_family which tends to make constant folded copies of itself. + */ +# define XXH_NO_STREAM +# undef XXH_NO_STREAM /* don't actually */ #endif /* XXH_DOXYGEN */ /*! * @} */ #ifndef XXH_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */ - /* prefer __packed__ structures (method 1) for gcc on armv7+ and mips */ -# if !defined(__clang__) && \ -( \ - (defined(__INTEL_COMPILER) && !defined(_WIN32)) || \ - ( \ - defined(__GNUC__) && ( \ - (defined(__ARM_ARCH) && __ARM_ARCH >= 7) || \ - ( \ - defined(__mips__) && \ - (__mips <= 5 || __mips_isa_rev < 6) && \ - (!defined(__mips16) || defined(__mips_mips16e2)) \ - ) \ - ) \ - ) \ -) + /* prefer __packed__ structures (method 1) for GCC + * < ARMv7 with unaligned access (e.g. Raspbian armhf) still uses byte shifting, so we use memcpy + * which for some reason does unaligned loads. */ +# if defined(__GNUC__) && !(defined(__ARM_ARCH) && __ARM_ARCH < 7 && defined(__ARM_FEATURE_UNALIGNED)) # define XXH_FORCE_MEMORY_ACCESS 1 # endif #endif +#ifndef XXH_SIZE_OPT + /* default to 1 for -Os or -Oz */ +# if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE_SIZE__) +# define XXH_SIZE_OPT 1 +# else +# define XXH_SIZE_OPT 0 +# endif +#endif + #ifndef XXH_FORCE_ALIGN_CHECK /* can be defined externally */ -# if defined(__i386) || defined(__x86_64__) || defined(__aarch64__) \ - || defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64) /* visual */ + /* don't check on sizeopt, x86, aarch64, or arm when unaligned access is available */ +# if XXH_SIZE_OPT >= 1 || \ + defined(__i386) || defined(__x86_64__) || defined(__aarch64__) || defined(__ARM_FEATURE_UNALIGNED) \ + || defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM64) || defined(_M_ARM) /* visual */ # define XXH_FORCE_ALIGN_CHECK 0 # else # define XXH_FORCE_ALIGN_CHECK 1 @@ -1448,8 +2009,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, #endif #ifndef XXH_NO_INLINE_HINTS -# if defined(__OPTIMIZE_SIZE__) /* -Os, -Oz */ \ - || defined(__NO_INLINE__) /* -O0, -fno-inline */ +# if XXH_SIZE_OPT >= 1 || defined(__NO_INLINE__) /* -O0, -fno-inline */ # define XXH_NO_INLINE_HINTS 1 # else # define XXH_NO_INLINE_HINTS 0 @@ -1479,6 +2039,24 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, /* ************************************* * Includes & Memory related functions ***************************************/ +#if defined(XXH_NO_STREAM) +/* nothing */ +#elif defined(XXH_NO_STDLIB) + +/* When requesting to disable any mention of stdlib, + * the library loses the ability to invoked malloc / free. + * In practice, it means that functions like `XXH*_createState()` + * will always fail, and return NULL. + * This flag is useful in situations where + * xxhash.h is integrated into some kernel, embedded or limited environment + * without access to dynamic allocation. + */ + +static XXH_CONSTF void* XXH_malloc(size_t s) { (void)s; return NULL; } +static void XXH_free(void* p) { (void)p; } + +#else + /* * Modify the local functions below should you wish to use * different memory routines for malloc() and free() @@ -1489,7 +2067,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, * @internal * @brief Modify this function to use a different routine than malloc(). */ -static void* XXH_malloc(size_t s) { return malloc(s); } +static XXH_MALLOCF void* XXH_malloc(size_t s) { return malloc(s); } /*! * @internal @@ -1497,6 +2075,8 @@ static void* XXH_malloc(size_t s) { return malloc(s); } */ static void XXH_free(void* p) { free(p); } +#endif /* XXH_NO_STDLIB */ + #include /*! @@ -1571,7 +2151,11 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) # include /* note: can still be disabled with NDEBUG */ # define XXH_ASSERT(c) assert(c) #else -# define XXH_ASSERT(c) ((void)0) +# if defined(__INTEL_COMPILER) +# define XXH_ASSERT(c) XXH_ASSUME((unsigned char) (c)) +# else +# define XXH_ASSERT(c) XXH_ASSUME(c) +# endif #endif /* note: use after variable declarations */ @@ -1603,11 +2187,19 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) * XXH3_initCustomSecret_scalar(). */ #if defined(__GNUC__) || defined(__clang__) -# define XXH_COMPILER_GUARD(var) __asm__ __volatile__("" : "+r" (var)) +# define XXH_COMPILER_GUARD(var) __asm__("" : "+r" (var)) #else # define XXH_COMPILER_GUARD(var) ((void)0) #endif +/* Specifically for NEON vectors which use the "w" constraint, on + * Clang. */ +#if defined(__clang__) && defined(__ARM_ARCH) && !defined(__wasm__) +# define XXH_COMPILER_GUARD_CLANG_NEON(var) __asm__("" : "+w" (var)) +#else +# define XXH_COMPILER_GUARD_CLANG_NEON(var) ((void)0) +#endif + /* ************************************* * Basic Types ***************************************/ @@ -1622,6 +2214,7 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size) typedef XXH32_hash_t xxh_u32; #ifdef XXH_OLD_NAMES +# warning "XXH_OLD_NAMES is planned to be removed starting v0.9. If the program depends on it, consider moving away from it by employing newer type names directly" # define BYTE xxh_u8 # define U8 xxh_u8 # define U32 xxh_u32 @@ -1695,25 +2288,26 @@ static xxh_u32 XXH_read32(const void* memPtr) { return *(const xxh_u32*) memPtr; #elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1)) /* - * __pack instructions are safer but compiler specific, hence potentially - * problematic for some compilers. - * - * Currently only defined for GCC and ICC. + * __attribute__((aligned(1))) is supported by gcc and clang. Originally the + * documentation claimed that it only increased the alignment, but actually it + * can decrease it on gcc, clang, and icc: + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69502, + * https://gcc.godbolt.org/z/xYez1j67Y. */ #ifdef XXH_OLD_NAMES typedef union { xxh_u32 u32; } __attribute__((packed)) unalign; #endif static xxh_u32 XXH_read32(const void* ptr) { - typedef union { xxh_u32 u32; } __attribute__((packed)) xxh_unalign; - return ((const xxh_unalign*)ptr)->u32; + typedef __attribute__((aligned(1))) xxh_u32 xxh_unalign32; + return *((const xxh_unalign32*)ptr); } #else /* * Portable and safe solution. Generally efficient. - * see: http://fastcompression.blogspot.com/2015/08/accessing-unaligned-memory.html + * see: https://fastcompression.blogspot.com/2015/08/accessing-unaligned-memory.html */ static xxh_u32 XXH_read32(const void* memPtr) { @@ -1789,6 +2383,51 @@ static int XXH_isLittleEndian(void) # define XXH_HAS_BUILTIN(x) 0 #endif + + +/* + * C23 and future versions have standard "unreachable()". + * Once it has been implemented reliably we can add it as an + * additional case: + * + * ``` + * #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= XXH_C23_VN) + * # include + * # ifdef unreachable + * # define XXH_UNREACHABLE() unreachable() + * # endif + * #endif + * ``` + * + * Note C++23 also has std::unreachable() which can be detected + * as follows: + * ``` + * #if defined(__cpp_lib_unreachable) && (__cpp_lib_unreachable >= 202202L) + * # include + * # define XXH_UNREACHABLE() std::unreachable() + * #endif + * ``` + * NB: `__cpp_lib_unreachable` is defined in the `` header. + * We don't use that as including `` in `extern "C"` blocks + * doesn't work on GCC12 + */ + +#if XXH_HAS_BUILTIN(__builtin_unreachable) +# define XXH_UNREACHABLE() __builtin_unreachable() + +#elif defined(_MSC_VER) +# define XXH_UNREACHABLE() __assume(0) + +#else +# define XXH_UNREACHABLE() +#endif + +#if XXH_HAS_BUILTIN(__builtin_assume) +# define XXH_ASSUME(c) __builtin_assume(c) +#else +# define XXH_ASSUME(c) if (!(c)) { XXH_UNREACHABLE(); } +#endif + /*! * @internal * @def XXH_rotl32(x,r) @@ -1911,8 +2550,10 @@ XXH_PUBLIC_API unsigned XXH_versionNumber (void) { return XXH_VERSION_NUMBER; } *********************************************************************/ /*! * @} - * @defgroup xxh32_impl XXH32 implementation + * @defgroup XXH32_impl XXH32 implementation * @ingroup impl + * + * Details on the XXH32 implementation. * @{ */ /* #define instead of static const, to be used as initializers */ @@ -1946,7 +2587,7 @@ static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input) acc += input * XXH_PRIME32_2; acc = XXH_rotl32(acc, 13); acc *= XXH_PRIME32_1; -#if (defined(__SSE4_1__) || defined(__aarch64__)) && !defined(XXH_ENABLE_AUTOVECTORIZE) +#if (defined(__SSE4_1__) || defined(__aarch64__) || defined(__wasm_simd128__)) && !defined(XXH_ENABLE_AUTOVECTORIZE) /* * UGLY HACK: * A compiler fence is the only thing that prevents GCC and Clang from @@ -1976,9 +2617,12 @@ static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input) * can load data, while v3 can multiply. SSE forces them to operate * together. * - * This is also enabled on AArch64, as Clang autovectorizes it incorrectly - * and it is pointless writing a NEON implementation that is basically the - * same speed as scalar for XXH32. + * This is also enabled on AArch64, as Clang is *very aggressive* in vectorizing + * the loop. NEON is only faster on the A53, and with the newer cores, it is less + * than half the speed. + * + * Additionally, this is used on WASM SIMD128 because it JITs to the same + * SIMD instructions and has the same issue. */ XXH_COMPILER_GUARD(acc); #endif @@ -1992,17 +2636,17 @@ static xxh_u32 XXH32_round(xxh_u32 acc, xxh_u32 input) * The final mix ensures that all input bits have a chance to impact any bit in * the output digest, resulting in an unbiased distribution. * - * @param h32 The hash to avalanche. + * @param hash The hash to avalanche. * @return The avalanched hash. */ -static xxh_u32 XXH32_avalanche(xxh_u32 h32) +static xxh_u32 XXH32_avalanche(xxh_u32 hash) { - h32 ^= h32 >> 15; - h32 *= XXH_PRIME32_2; - h32 ^= h32 >> 13; - h32 *= XXH_PRIME32_3; - h32 ^= h32 >> 16; - return(h32); + hash ^= hash >> 15; + hash *= XXH_PRIME32_2; + hash ^= hash >> 13; + hash *= XXH_PRIME32_3; + hash ^= hash >> 16; + return hash; } #define XXH_get32bits(p) XXH_readLE32_align(p, align) @@ -2015,24 +2659,25 @@ static xxh_u32 XXH32_avalanche(xxh_u32 h32) * This final stage will digest them to ensure that all input bytes are present * in the final mix. * - * @param h32 The hash to finalize. + * @param hash The hash to finalize. * @param ptr The pointer to the remaining input. * @param len The remaining length, modulo 16. * @param align Whether @p ptr is aligned. * @return The finalized hash. + * @see XXH64_finalize(). */ -static xxh_u32 -XXH32_finalize(xxh_u32 h32, const xxh_u8* ptr, size_t len, XXH_alignment align) +static XXH_PUREF xxh_u32 +XXH32_finalize(xxh_u32 hash, const xxh_u8* ptr, size_t len, XXH_alignment align) { -#define XXH_PROCESS1 do { \ - h32 += (*ptr++) * XXH_PRIME32_5; \ - h32 = XXH_rotl32(h32, 11) * XXH_PRIME32_1; \ +#define XXH_PROCESS1 do { \ + hash += (*ptr++) * XXH_PRIME32_5; \ + hash = XXH_rotl32(hash, 11) * XXH_PRIME32_1; \ } while (0) -#define XXH_PROCESS4 do { \ - h32 += XXH_get32bits(ptr) * XXH_PRIME32_3; \ - ptr += 4; \ - h32 = XXH_rotl32(h32, 17) * XXH_PRIME32_4; \ +#define XXH_PROCESS4 do { \ + hash += XXH_get32bits(ptr) * XXH_PRIME32_3; \ + ptr += 4; \ + hash = XXH_rotl32(hash, 17) * XXH_PRIME32_4; \ } while (0) if (ptr==NULL) XXH_ASSERT(len == 0); @@ -2048,49 +2693,49 @@ XXH32_finalize(xxh_u32 h32, const xxh_u8* ptr, size_t len, XXH_alignment align) XXH_PROCESS1; --len; } - return XXH32_avalanche(h32); + return XXH32_avalanche(hash); } else { switch(len&15) /* or switch(bEnd - p) */ { case 12: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 8: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 4: XXH_PROCESS4; - return XXH32_avalanche(h32); + return XXH32_avalanche(hash); case 13: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 9: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 5: XXH_PROCESS4; XXH_PROCESS1; - return XXH32_avalanche(h32); + return XXH32_avalanche(hash); case 14: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 10: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 6: XXH_PROCESS4; XXH_PROCESS1; XXH_PROCESS1; - return XXH32_avalanche(h32); + return XXH32_avalanche(hash); case 15: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 11: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 7: XXH_PROCESS4; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 3: XXH_PROCESS1; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 2: XXH_PROCESS1; - XXH_FALLTHROUGH; + XXH_FALLTHROUGH; /* fallthrough */ case 1: XXH_PROCESS1; - XXH_FALLTHROUGH; - case 0: return XXH32_avalanche(h32); + XXH_FALLTHROUGH; /* fallthrough */ + case 0: return XXH32_avalanche(hash); } XXH_ASSERT(0); - return h32; /* reaching this point is deemed impossible */ + return hash; /* reaching this point is deemed impossible */ } } @@ -2110,7 +2755,7 @@ XXH32_finalize(xxh_u32 h32, const xxh_u8* ptr, size_t len, XXH_alignment align) * @param align Whether @p input is aligned. * @return The calculated hash. */ -XXH_FORCE_INLINE xxh_u32 +XXH_FORCE_INLINE XXH_PUREF xxh_u32 XXH32_endian_align(const xxh_u8* input, size_t len, xxh_u32 seed, XXH_alignment align) { xxh_u32 h32; @@ -2143,10 +2788,10 @@ XXH32_endian_align(const xxh_u8* input, size_t len, xxh_u32 seed, XXH_alignment return XXH32_finalize(h32, input, len&15, align); } -/*! @ingroup xxh32_family */ +/*! @ingroup XXH32_family */ XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t len, XXH32_hash_t seed) { -#if 0 +#if !defined(XXH_NO_STREAM) && XXH_SIZE_OPT >= 2 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ XXH32_state_t state; XXH32_reset(&state, seed); @@ -2165,42 +2810,39 @@ XXH_PUBLIC_API XXH32_hash_t XXH32 (const void* input, size_t len, XXH32_hash_t s /******* Hash streaming *******/ -/*! - * @ingroup xxh32_family - */ +#ifndef XXH_NO_STREAM +/*! @ingroup XXH32_family */ XXH_PUBLIC_API XXH32_state_t* XXH32_createState(void) { return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t)); } -/*! @ingroup xxh32_family */ +/*! @ingroup XXH32_family */ XXH_PUBLIC_API XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr) { XXH_free(statePtr); return XXH_OK; } -/*! @ingroup xxh32_family */ +/*! @ingroup XXH32_family */ XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dstState, const XXH32_state_t* srcState) { XXH_memcpy(dstState, srcState, sizeof(*dstState)); } -/*! @ingroup xxh32_family */ +/*! @ingroup XXH32_family */ XXH_PUBLIC_API XXH_errorcode XXH32_reset(XXH32_state_t* statePtr, XXH32_hash_t seed) { - XXH32_state_t state; /* using a local state to memcpy() in order to avoid strict-aliasing warnings */ - memset(&state, 0, sizeof(state)); - state.v[0] = seed + XXH_PRIME32_1 + XXH_PRIME32_2; - state.v[1] = seed + XXH_PRIME32_2; - state.v[2] = seed + 0; - state.v[3] = seed - XXH_PRIME32_1; - /* do not write into reserved, planned to be removed in a future version */ - XXH_memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved)); + XXH_ASSERT(statePtr != NULL); + memset(statePtr, 0, sizeof(*statePtr)); + statePtr->v[0] = seed + XXH_PRIME32_1 + XXH_PRIME32_2; + statePtr->v[1] = seed + XXH_PRIME32_2; + statePtr->v[2] = seed + 0; + statePtr->v[3] = seed - XXH_PRIME32_1; return XXH_OK; } -/*! @ingroup xxh32_family */ +/*! @ingroup XXH32_family */ XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t* state, const void* input, size_t len) { @@ -2255,7 +2897,7 @@ XXH32_update(XXH32_state_t* state, const void* input, size_t len) } -/*! @ingroup xxh32_family */ +/*! @ingroup XXH32_family */ XXH_PUBLIC_API XXH32_hash_t XXH32_digest(const XXH32_state_t* state) { xxh_u32 h32; @@ -2273,12 +2915,12 @@ XXH_PUBLIC_API XXH32_hash_t XXH32_digest(const XXH32_state_t* state) return XXH32_finalize(h32, (const xxh_u8*)state->mem32, state->memsize, XXH_aligned); } - +#endif /* !XXH_NO_STREAM */ /******* Canonical representation *******/ /*! - * @ingroup xxh32_family + * @ingroup XXH32_family * The default return values from XXH functions are unsigned 32 and 64 bit * integers. * @@ -2297,7 +2939,7 @@ XXH_PUBLIC_API void XXH32_canonicalFromHash(XXH32_canonical_t* dst, XXH32_hash_t if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap32(hash); XXH_memcpy(dst, &hash, sizeof(*dst)); } -/*! @ingroup xxh32_family */ +/*! @ingroup XXH32_family */ XXH_PUBLIC_API XXH32_hash_t XXH32_hashFromCanonical(const XXH32_canonical_t* src) { return XXH_readBE32(src); @@ -2338,25 +2980,26 @@ static xxh_u64 XXH_read64(const void* memPtr) #elif (defined(XXH_FORCE_MEMORY_ACCESS) && (XXH_FORCE_MEMORY_ACCESS==1)) /* - * __pack instructions are safer, but compiler specific, hence potentially - * problematic for some compilers. - * - * Currently only defined for GCC and ICC. + * __attribute__((aligned(1))) is supported by gcc and clang. Originally the + * documentation claimed that it only increased the alignment, but actually it + * can decrease it on gcc, clang, and icc: + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69502, + * https://gcc.godbolt.org/z/xYez1j67Y. */ #ifdef XXH_OLD_NAMES typedef union { xxh_u32 u32; xxh_u64 u64; } __attribute__((packed)) unalign64; #endif static xxh_u64 XXH_read64(const void* ptr) { - typedef union { xxh_u32 u32; xxh_u64 u64; } __attribute__((packed)) xxh_unalign64; - return ((const xxh_unalign64*)ptr)->u64; + typedef __attribute__((aligned(1))) xxh_u64 xxh_unalign64; + return *((const xxh_unalign64*)ptr); } #else /* * Portable and safe solution. Generally efficient. - * see: http://fastcompression.blogspot.com/2015/08/accessing-unaligned-memory.html + * see: https://fastcompression.blogspot.com/2015/08/accessing-unaligned-memory.html */ static xxh_u64 XXH_read64(const void* memPtr) { @@ -2440,8 +3083,10 @@ XXH_readLE64_align(const void* ptr, XXH_alignment align) /******* xxh64 *******/ /*! * @} - * @defgroup xxh64_impl XXH64 implementation + * @defgroup XXH64_impl XXH64 implementation * @ingroup impl + * + * Details on the XXH64 implementation. * @{ */ /* #define rather that static const, to be used as initializers */ @@ -2459,6 +3104,7 @@ XXH_readLE64_align(const void* ptr, XXH_alignment align) # define PRIME64_5 XXH_PRIME64_5 #endif +/*! @copydoc XXH32_round */ static xxh_u64 XXH64_round(xxh_u64 acc, xxh_u64 input) { acc += input * XXH_PRIME64_2; @@ -2475,43 +3121,59 @@ static xxh_u64 XXH64_mergeRound(xxh_u64 acc, xxh_u64 val) return acc; } -static xxh_u64 XXH64_avalanche(xxh_u64 h64) +/*! @copydoc XXH32_avalanche */ +static xxh_u64 XXH64_avalanche(xxh_u64 hash) { - h64 ^= h64 >> 33; - h64 *= XXH_PRIME64_2; - h64 ^= h64 >> 29; - h64 *= XXH_PRIME64_3; - h64 ^= h64 >> 32; - return h64; + hash ^= hash >> 33; + hash *= XXH_PRIME64_2; + hash ^= hash >> 29; + hash *= XXH_PRIME64_3; + hash ^= hash >> 32; + return hash; } #define XXH_get64bits(p) XXH_readLE64_align(p, align) -static xxh_u64 -XXH64_finalize(xxh_u64 h64, const xxh_u8* ptr, size_t len, XXH_alignment align) +/*! + * @internal + * @brief Processes the last 0-31 bytes of @p ptr. + * + * There may be up to 31 bytes remaining to consume from the input. + * This final stage will digest them to ensure that all input bytes are present + * in the final mix. + * + * @param hash The hash to finalize. + * @param ptr The pointer to the remaining input. + * @param len The remaining length, modulo 32. + * @param align Whether @p ptr is aligned. + * @return The finalized hash + * @see XXH32_finalize(). + */ +static XXH_PUREF xxh_u64 +XXH64_finalize(xxh_u64 hash, const xxh_u8* ptr, size_t len, XXH_alignment align) { if (ptr==NULL) XXH_ASSERT(len == 0); len &= 31; while (len >= 8) { xxh_u64 const k1 = XXH64_round(0, XXH_get64bits(ptr)); ptr += 8; - h64 ^= k1; - h64 = XXH_rotl64(h64,27) * XXH_PRIME64_1 + XXH_PRIME64_4; + hash ^= k1; + hash = XXH_rotl64(hash,27) * XXH_PRIME64_1 + XXH_PRIME64_4; len -= 8; } if (len >= 4) { - h64 ^= (xxh_u64)(XXH_get32bits(ptr)) * XXH_PRIME64_1; + hash ^= (xxh_u64)(XXH_get32bits(ptr)) * XXH_PRIME64_1; ptr += 4; - h64 = XXH_rotl64(h64, 23) * XXH_PRIME64_2 + XXH_PRIME64_3; + hash = XXH_rotl64(hash, 23) * XXH_PRIME64_2 + XXH_PRIME64_3; len -= 4; } while (len > 0) { - h64 ^= (*ptr++) * XXH_PRIME64_5; - h64 = XXH_rotl64(h64, 11) * XXH_PRIME64_1; + hash ^= (*ptr++) * XXH_PRIME64_5; + hash = XXH_rotl64(hash, 11) * XXH_PRIME64_1; --len; } - return XXH64_avalanche(h64); + return XXH64_avalanche(hash); } #ifdef XXH_OLD_NAMES @@ -2524,7 +3186,15 @@ XXH64_finalize(xxh_u64 h64, const xxh_u8* ptr, size_t len, XXH_alignment align) # undef XXH_PROCESS8_64 #endif -XXH_FORCE_INLINE xxh_u64 +/*! + * @internal + * @brief The implementation for @ref XXH64(). + * + * @param input , len , seed Directly passed from @ref XXH64(). + * @param align Whether @p input is aligned. + * @return The calculated hash. + */ +XXH_FORCE_INLINE XXH_PUREF xxh_u64 XXH64_endian_align(const xxh_u8* input, size_t len, xxh_u64 seed, XXH_alignment align) { xxh_u64 h64; @@ -2561,10 +3231,10 @@ XXH64_endian_align(const xxh_u8* input, size_t len, xxh_u64 seed, XXH_alignment } -/*! @ingroup xxh64_family */ -XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t len, XXH64_hash_t seed) +/*! @ingroup XXH64_family */ +XXH_PUBLIC_API XXH64_hash_t XXH64 (XXH_NOESCAPE const void* input, size_t len, XXH64_hash_t seed) { -#if 0 +#if !defined(XXH_NO_STREAM) && XXH_SIZE_OPT >= 2 /* Simple version, good for code maintenance, but unfortunately slow for small inputs */ XXH64_state_t state; XXH64_reset(&state, seed); @@ -2582,42 +3252,40 @@ XXH_PUBLIC_API XXH64_hash_t XXH64 (const void* input, size_t len, XXH64_hash_t s } /******* Hash Streaming *******/ - -/*! @ingroup xxh64_family*/ +#ifndef XXH_NO_STREAM +/*! @ingroup XXH64_family*/ XXH_PUBLIC_API XXH64_state_t* XXH64_createState(void) { return (XXH64_state_t*)XXH_malloc(sizeof(XXH64_state_t)); } -/*! @ingroup xxh64_family */ +/*! @ingroup XXH64_family */ XXH_PUBLIC_API XXH_errorcode XXH64_freeState(XXH64_state_t* statePtr) { XXH_free(statePtr); return XXH_OK; } -/*! @ingroup xxh64_family */ -XXH_PUBLIC_API void XXH64_copyState(XXH64_state_t* dstState, const XXH64_state_t* srcState) +/*! @ingroup XXH64_family */ +XXH_PUBLIC_API void XXH64_copyState(XXH_NOESCAPE XXH64_state_t* dstState, const XXH64_state_t* srcState) { XXH_memcpy(dstState, srcState, sizeof(*dstState)); } -/*! @ingroup xxh64_family */ -XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t* statePtr, XXH64_hash_t seed) +/*! @ingroup XXH64_family */ +XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH_NOESCAPE XXH64_state_t* statePtr, XXH64_hash_t seed) { - XXH64_state_t state; /* use a local state to memcpy() in order to avoid strict-aliasing warnings */ - memset(&state, 0, sizeof(state)); - state.v[0] = seed + XXH_PRIME64_1 + XXH_PRIME64_2; - state.v[1] = seed + XXH_PRIME64_2; - state.v[2] = seed + 0; - state.v[3] = seed - XXH_PRIME64_1; - /* do not write into reserved64, might be removed in a future version */ - XXH_memcpy(statePtr, &state, sizeof(state) - sizeof(state.reserved64)); + XXH_ASSERT(statePtr != NULL); + memset(statePtr, 0, sizeof(*statePtr)); + statePtr->v[0] = seed + XXH_PRIME64_1 + XXH_PRIME64_2; + statePtr->v[1] = seed + XXH_PRIME64_2; + statePtr->v[2] = seed + 0; + statePtr->v[3] = seed - XXH_PRIME64_1; return XXH_OK; } -/*! @ingroup xxh64_family */ +/*! @ingroup XXH64_family */ XXH_PUBLIC_API XXH_errorcode -XXH64_update (XXH64_state_t* state, const void* input, size_t len) +XXH64_update (XXH_NOESCAPE XXH64_state_t* state, XXH_NOESCAPE const void* input, size_t len) { if (input==NULL) { XXH_ASSERT(len == 0); @@ -2667,8 +3335,8 @@ XXH64_update (XXH64_state_t* state, const void* input, size_t len) } -/*! @ingroup xxh64_family */ -XXH_PUBLIC_API XXH64_hash_t XXH64_digest(const XXH64_state_t* state) +/*! @ingroup XXH64_family */ +XXH_PUBLIC_API XXH64_hash_t XXH64_digest(XXH_NOESCAPE const XXH64_state_t* state) { xxh_u64 h64; @@ -2686,20 +3354,20 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_digest(const XXH64_state_t* state) return XXH64_finalize(h64, (const xxh_u8*)state->mem64, (size_t)state->total_len, XXH_aligned); } - +#endif /* !XXH_NO_STREAM */ /******* Canonical representation *******/ -/*! @ingroup xxh64_family */ -XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH64_canonical_t* dst, XXH64_hash_t hash) +/*! @ingroup XXH64_family */ +XXH_PUBLIC_API void XXH64_canonicalFromHash(XXH_NOESCAPE XXH64_canonical_t* dst, XXH64_hash_t hash) { XXH_STATIC_ASSERT(sizeof(XXH64_canonical_t) == sizeof(XXH64_hash_t)); if (XXH_CPU_LITTLE_ENDIAN) hash = XXH_swap64(hash); XXH_memcpy(dst, &hash, sizeof(*dst)); } -/*! @ingroup xxh64_family */ -XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src) +/*! @ingroup XXH64_family */ +XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(XXH_NOESCAPE const XXH64_canonical_t* src) { return XXH_readBE64(src); } @@ -2712,7 +3380,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src ************************************************************************ */ /*! * @} - * @defgroup xxh3_impl XXH3 implementation + * @defgroup XXH3_impl XXH3 implementation * @ingroup impl * @{ */ @@ -2720,11 +3388,19 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src /* === Compiler specifics === */ #if ((defined(sun) || defined(__sun)) && __cplusplus) /* Solaris includes __STDC_VERSION__ with C++. Tested with GCC 5.5 */ -# define XXH_RESTRICT /* disable */ +# define XXH_RESTRICT /* disable */ #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* >= C99 */ # define XXH_RESTRICT restrict +#elif (defined (__GNUC__) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))) \ + || (defined (__clang__)) \ + || (defined (_MSC_VER) && (_MSC_VER >= 1400)) \ + || (defined (__INTEL_COMPILER) && (__INTEL_COMPILER >= 1300)) +/* + * There are a LOT more compilers that recognize __restrict but this + * covers the major ones. + */ +# define XXH_RESTRICT __restrict #else -/* Note: it might be useful to define __restrict or __restrict__ for some C++ compilers */ # define XXH_RESTRICT /* disable */ #endif @@ -2738,17 +3414,33 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src # define XXH_unlikely(x) (x) #endif -#if defined(__GNUC__) -# if defined(__AVX2__) -# include -# elif defined(__SSE2__) -# include -# elif defined(__ARM_NEON__) || defined(__ARM_NEON) +#ifndef XXH_HAS_INCLUDE +# ifdef __has_include +# define XXH_HAS_INCLUDE(x) __has_include(x) +# else +# define XXH_HAS_INCLUDE(x) 0 +# endif +#endif + +#if defined(__GNUC__) || defined(__clang__) +# if defined(__ARM_FEATURE_SVE) +# include +# endif +# if defined(__ARM_NEON__) || defined(__ARM_NEON) \ + || (defined(_M_ARM) && _M_ARM >= 7) \ + || defined(_M_ARM64) || defined(_M_ARM64EC) \ + || (defined(__wasm_simd128__) && XXH_HAS_INCLUDE()) /* WASM SIMD128 via SIMDe */ # define inline __inline__ /* circumvent a clang bug */ # include # undef inline +# elif defined(__AVX2__) +# include +# elif defined(__SSE2__) +# include # endif -#elif defined(_MSC_VER) +#endif + +#if defined(_MSC_VER) # include #endif @@ -2848,7 +3540,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH64_hashFromCanonical(const XXH64_canonical_t* src * Note that these are actually implemented as macros. * * If this is not defined, it is detected automatically. - * @ref XXH_X86DISPATCH overrides this. + * internal macro XXH_X86DISPATCH overrides this. */ enum XXH_VECTOR_TYPE /* fake enum */ { XXH_SCALAR = 0, /*!< Portable scalar version */ @@ -2860,14 +3552,19 @@ enum XXH_VECTOR_TYPE /* fake enum */ { */ XXH_AVX2 = 2, /*!< AVX2 for Haswell and Bulldozer */ XXH_AVX512 = 3, /*!< AVX512 for Skylake and Icelake */ - XXH_NEON = 4, /*!< NEON for most ARMv7-A and all AArch64 */ + XXH_NEON = 4, /*!< + * NEON for most ARMv7-A, all AArch64, and WASM SIMD128 + * via the SIMDeverywhere polyfill provided with the + * Emscripten SDK. + */ XXH_VSX = 5, /*!< VSX and ZVector for POWER8/z13 (64-bit) */ + XXH_SVE = 6, /*!< SVE for some ARMv8-A and ARMv9-A */ }; /*! * @ingroup tuning * @brief Selects the minimum alignment for XXH3's accumulators. * - * When using SIMD, this should match the alignment reqired for said vector + * When using SIMD, this should match the alignment required for said vector * type, so, for example, 32 for AVX2. * * Default: Auto detected. @@ -2883,23 +3580,27 @@ enum XXH_VECTOR_TYPE /* fake enum */ { # define XXH_AVX512 3 # define XXH_NEON 4 # define XXH_VSX 5 +# define XXH_SVE 6 #endif #ifndef XXH_VECTOR /* can be defined on command line */ -# if defined(__AVX512F__) -# define XXH_VECTOR XXH_AVX512 -# elif defined(__AVX2__) -# define XXH_VECTOR XXH_AVX2 -# elif defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP == 2)) -# define XXH_VECTOR XXH_SSE2 +# if defined(__ARM_FEATURE_SVE) +# define XXH_VECTOR XXH_SVE # elif ( \ defined(__ARM_NEON__) || defined(__ARM_NEON) /* gcc */ \ - || defined(_M_ARM64) || defined(_M_ARM_ARMV7VE) /* msvc */ \ + || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) /* msvc */ \ + || (defined(__wasm_simd128__) && XXH_HAS_INCLUDE()) /* wasm simd128 via SIMDe */ \ ) && ( \ defined(_WIN32) || defined(__LITTLE_ENDIAN__) /* little endian only */ \ || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) \ ) # define XXH_VECTOR XXH_NEON +# elif defined(__AVX512F__) +# define XXH_VECTOR XXH_AVX512 +# elif defined(__AVX2__) +# define XXH_VECTOR XXH_AVX2 +# elif defined(__SSE2__) || defined(_M_AMD64) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP == 2)) +# define XXH_VECTOR XXH_SSE2 # elif (defined(__PPC64__) && defined(__POWER8_VECTOR__)) \ || (defined(__s390x__) && defined(__VEC__)) \ && defined(__GNUC__) /* TODO: IBM XL */ @@ -2909,6 +3610,17 @@ enum XXH_VECTOR_TYPE /* fake enum */ { # endif #endif +/* __ARM_FEATURE_SVE is only supported by GCC & Clang. */ +#if (XXH_VECTOR == XXH_SVE) && !defined(__ARM_FEATURE_SVE) +# ifdef _MSC_VER +# pragma warning(once : 4606) +# else +# warning "__ARM_FEATURE_SVE isn't supported. Use SCALAR instead." +# endif +# undef XXH_VECTOR +# define XXH_VECTOR XXH_SCALAR +#endif + /* * Controls the alignment of the accumulator, * for compatibility with aligned vector loads, which are usually faster. @@ -2928,16 +3640,26 @@ enum XXH_VECTOR_TYPE /* fake enum */ { # define XXH_ACC_ALIGN 16 # elif XXH_VECTOR == XXH_AVX512 /* avx512 */ # define XXH_ACC_ALIGN 64 +# elif XXH_VECTOR == XXH_SVE /* sve */ +# define XXH_ACC_ALIGN 64 # endif #endif #if defined(XXH_X86DISPATCH) || XXH_VECTOR == XXH_SSE2 \ || XXH_VECTOR == XXH_AVX2 || XXH_VECTOR == XXH_AVX512 # define XXH_SEC_ALIGN XXH_ACC_ALIGN +#elif XXH_VECTOR == XXH_SVE +# define XXH_SEC_ALIGN XXH_ACC_ALIGN #else # define XXH_SEC_ALIGN 8 #endif +#if defined(__GNUC__) || defined(__clang__) +# define XXH_ALIASING __attribute__((may_alias)) +#else +# define XXH_ALIASING /* nothing */ +#endif + /* * UGLY HACK: * GCC usually generates the best code with -O3 for xxHash. @@ -2961,111 +3683,130 @@ enum XXH_VECTOR_TYPE /* fake enum */ { */ #if XXH_VECTOR == XXH_AVX2 /* AVX2 */ \ && defined(__GNUC__) && !defined(__clang__) /* GCC, not Clang */ \ - && defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) /* respect -O0 and -Os */ + && defined(__OPTIMIZE__) && XXH_SIZE_OPT <= 0 /* respect -O0 and -Os */ # pragma GCC push_options # pragma GCC optimize("-O2") #endif - #if XXH_VECTOR == XXH_NEON + /* - * NEON's setup for vmlal_u32 is a little more complicated than it is on - * SSE2, AVX2, and VSX. - * - * While PMULUDQ and VMULEUW both perform a mask, VMLAL.U32 performs an upcast. - * - * To do the same operation, the 128-bit 'Q' register needs to be split into - * two 64-bit 'D' registers, performing this operation:: + * UGLY HACK: While AArch64 GCC on Linux does not seem to care, on macOS, GCC -O3 + * optimizes out the entire hashLong loop because of the aliasing violation. * - * [ a | b ] - * | '---------. .--------' | - * | x | - * | .---------' '--------. | - * [ a & 0xFFFFFFFF | b & 0xFFFFFFFF ],[ a >> 32 | b >> 32 ] - * - * Due to significant changes in aarch64, the fastest method for aarch64 is - * completely different than the fastest method for ARMv7-A. - * - * ARMv7-A treats D registers as unions overlaying Q registers, so modifying - * D11 will modify the high half of Q5. This is similar to how modifying AH - * will only affect bits 8-15 of AX on x86. - * - * VZIP takes two registers, and puts even lanes in one register and odd lanes - * in the other. + * However, GCC is also inefficient at load-store optimization with vld1q/vst1q, + * so the only option is to mark it as aliasing. + */ +typedef uint64x2_t xxh_aliasing_uint64x2_t XXH_ALIASING; + +/*! + * @internal + * @brief `vld1q_u64` but faster and alignment-safe. * - * On ARMv7-A, this strangely modifies both parameters in place instead of - * taking the usual 3-operand form. + * On AArch64, unaligned access is always safe, but on ARMv7-a, it is only + * *conditionally* safe (`vld1` has an alignment bit like `movdq[ua]` in x86). * - * Therefore, if we want to do this, we can simply use a D-form VZIP.32 on the - * lower and upper halves of the Q register to end up with the high and low - * halves where we want - all in one instruction. + * GCC for AArch64 sees `vld1q_u8` as an intrinsic instead of a load, so it + * prohibits load-store optimizations. Therefore, a direct dereference is used. * - * vzip.32 d10, d11 @ d10 = { d10[0], d11[0] }; d11 = { d10[1], d11[1] } + * Otherwise, `vld1q_u8` is used with `vreinterpretq_u8_u64` to do a safe + * unaligned load. + */ +#if defined(__aarch64__) && defined(__GNUC__) && !defined(__clang__) +XXH_FORCE_INLINE uint64x2_t XXH_vld1q_u64(void const* ptr) /* silence -Wcast-align */ +{ + return *(xxh_aliasing_uint64x2_t const *)ptr; +} +#else +XXH_FORCE_INLINE uint64x2_t XXH_vld1q_u64(void const* ptr) +{ + return vreinterpretq_u64_u8(vld1q_u8((uint8_t const*)ptr)); +} +#endif + +/*! + * @internal + * @brief `vmlal_u32` on low and high halves of a vector. * - * Unfortunately we need inline assembly for this: Instructions modifying two - * registers at once is not possible in GCC or Clang's IR, and they have to - * create a copy. + * This is a workaround for AArch64 GCC < 11 which implemented arm_neon.h with + * inline assembly and were therefore incapable of merging the `vget_{low, high}_u32` + * with `vmlal_u32`. + */ +#if defined(__aarch64__) && defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 11 +XXH_FORCE_INLINE uint64x2_t +XXH_vmlal_low_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) +{ + /* Inline assembly is the only way */ + __asm__("umlal %0.2d, %1.2s, %2.2s" : "+w" (acc) : "w" (lhs), "w" (rhs)); + return acc; +} +XXH_FORCE_INLINE uint64x2_t +XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) +{ + /* This intrinsic works as expected */ + return vmlal_high_u32(acc, lhs, rhs); +} +#else +/* Portable intrinsic versions */ +XXH_FORCE_INLINE uint64x2_t +XXH_vmlal_low_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) +{ + return vmlal_u32(acc, vget_low_u32(lhs), vget_low_u32(rhs)); +} +/*! @copydoc XXH_vmlal_low_u32 + * Assume the compiler converts this to vmlal_high_u32 on aarch64 */ +XXH_FORCE_INLINE uint64x2_t +XXH_vmlal_high_u32(uint64x2_t acc, uint32x4_t lhs, uint32x4_t rhs) +{ + return vmlal_u32(acc, vget_high_u32(lhs), vget_high_u32(rhs)); +} +#endif + +/*! + * @ingroup tuning + * @brief Controls the NEON to scalar ratio for XXH3 * - * aarch64 requires a different approach. + * This can be set to 2, 4, 6, or 8. * - * In order to make it easier to write a decent compiler for aarch64, many - * quirks were removed, such as conditional execution. + * ARM Cortex CPUs are _very_ sensitive to how their pipelines are used. * - * NEON was also affected by this. + * For example, the Cortex-A73 can dispatch 3 micro-ops per cycle, but only 2 of those + * can be NEON. If you are only using NEON instructions, you are only using 2/3 of the CPU + * bandwidth. * - * aarch64 cannot access the high bits of a Q-form register, and writes to a - * D-form register zero the high bits, similar to how writes to W-form scalar - * registers (or DWORD registers on x86_64) work. + * This is even more noticeable on the more advanced cores like the Cortex-A76 which + * can dispatch 8 micro-ops per cycle, but still only 2 NEON micro-ops at once. * - * The formerly free vget_high intrinsics now require a vext (with a few - * exceptions) + * Therefore, to make the most out of the pipeline, it is beneficial to run 6 NEON lanes + * and 2 scalar lanes, which is chosen by default. * - * Additionally, VZIP was replaced by ZIP1 and ZIP2, which are the equivalent - * of PUNPCKL* and PUNPCKH* in SSE, respectively, in order to only modify one - * operand. + * This does not apply to Apple processors or 32-bit processors, which run better with + * full NEON. These will default to 8. Additionally, size-optimized builds run 8 lanes. * - * The equivalent of the VZIP.32 on the lower and upper halves would be this - * mess: + * This change benefits CPUs with large micro-op buffers without negatively affecting + * most other CPUs: * - * ext v2.4s, v0.4s, v0.4s, #2 // v2 = { v0[2], v0[3], v0[0], v0[1] } - * zip1 v1.2s, v0.2s, v2.2s // v1 = { v0[0], v2[0] } - * zip2 v0.2s, v0.2s, v1.2s // v0 = { v0[1], v2[1] } + * | Chipset | Dispatch type | NEON only | 6:2 hybrid | Diff. | + * |:----------------------|:--------------------|----------:|-----------:|------:| + * | Snapdragon 730 (A76) | 2 NEON/8 micro-ops | 8.8 GB/s | 10.1 GB/s | ~16% | + * | Snapdragon 835 (A73) | 2 NEON/3 micro-ops | 5.1 GB/s | 5.3 GB/s | ~5% | + * | Marvell PXA1928 (A53) | In-order dual-issue | 1.9 GB/s | 1.9 GB/s | 0% | + * | Apple M1 | 4 NEON/8 micro-ops | 37.3 GB/s | 36.1 GB/s | ~-3% | * - * Instead, we use a literal downcast, vmovn_u64 (XTN), and vshrn_n_u64 (SHRN): + * It also seems to fix some bad codegen on GCC, making it almost as fast as clang. * - * shrn v1.2s, v0.2d, #32 // v1 = (uint32x2_t)(v0 >> 32); - * xtn v0.2s, v0.2d // v0 = (uint32x2_t)(v0 & 0xFFFFFFFF); + * When using WASM SIMD128, if this is 2 or 6, SIMDe will scalarize 2 of the lanes meaning + * it effectively becomes worse 4. * - * This is available on ARMv7-A, but is less efficient than a single VZIP.32. + * @see XXH3_accumulate_512_neon() */ - -/*! - * Function-like macro: - * void XXH_SPLIT_IN_PLACE(uint64x2_t &in, uint32x2_t &outLo, uint32x2_t &outHi) - * { - * outLo = (uint32x2_t)(in & 0xFFFFFFFF); - * outHi = (uint32x2_t)(in >> 32); - * in = UNDEFINED; - * } - */ -# if !defined(XXH_NO_VZIP_HACK) /* define to disable */ \ - && defined(__GNUC__) \ - && !defined(__aarch64__) && !defined(__arm64__) && !defined(_M_ARM64) -# define XXH_SPLIT_IN_PLACE(in, outLo, outHi) \ - do { \ - /* Undocumented GCC/Clang operand modifier: %e0 = lower D half, %f0 = upper D half */ \ - /* https://github.com/gcc-mirror/gcc/blob/38cf91e5/gcc/config/arm/arm.c#L22486 */ \ - /* https://github.com/llvm-mirror/llvm/blob/2c4ca683/lib/Target/ARM/ARMAsmPrinter.cpp#L399 */ \ - __asm__("vzip.32 %e0, %f0" : "+w" (in)); \ - (outLo) = vget_low_u32 (vreinterpretq_u32_u64(in)); \ - (outHi) = vget_high_u32(vreinterpretq_u32_u64(in)); \ - } while (0) -# else -# define XXH_SPLIT_IN_PLACE(in, outLo, outHi) \ - do { \ - (outLo) = vmovn_u64 (in); \ - (outHi) = vshrn_n_u64 ((in), 32); \ - } while (0) +# ifndef XXH3_NEON_LANES +# if (defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64) || defined(_M_ARM64EC)) \ + && !defined(__APPLE__) && XXH_SIZE_OPT <= 0 +# define XXH3_NEON_LANES 6 +# else +# define XXH3_NEON_LANES XXH_ACC_NB +# endif # endif #endif /* XXH_VECTOR == XXH_NEON */ @@ -3078,27 +3819,42 @@ enum XXH_VECTOR_TYPE /* fake enum */ { * inconsistent intrinsics, spotty coverage, and multiple endiannesses. */ #if XXH_VECTOR == XXH_VSX +/* Annoyingly, these headers _may_ define three macros: `bool`, `vector`, + * and `pixel`. This is a problem for obvious reasons. + * + * These keywords are unnecessary; the spec literally says they are + * equivalent to `__bool`, `__vector`, and `__pixel` and may be undef'd + * after including the header. + * + * We use pragma push_macro/pop_macro to keep the namespace clean. */ +# pragma push_macro("bool") +# pragma push_macro("vector") +# pragma push_macro("pixel") +/* silence potential macro redefined warnings */ +# undef bool +# undef vector +# undef pixel + # if defined(__s390x__) # include # else -/* gcc's altivec.h can have the unwanted consequence to unconditionally - * #define bool, vector, and pixel keywords, - * with bad consequences for programs already using these keywords for other purposes. - * The paragraph defining these macros is skipped when __APPLE_ALTIVEC__ is defined. - * __APPLE_ALTIVEC__ is _generally_ defined automatically by the compiler, - * but it seems that, in some cases, it isn't. - * Force the build macro to be defined, so that keywords are not altered. - */ -# if defined(__GNUC__) && !defined(__APPLE_ALTIVEC__) -# define __APPLE_ALTIVEC__ -# endif # include # endif +/* Restore the original macro values, if applicable. */ +# pragma pop_macro("pixel") +# pragma pop_macro("vector") +# pragma pop_macro("bool") + typedef __vector unsigned long long xxh_u64x2; typedef __vector unsigned char xxh_u8x16; typedef __vector unsigned xxh_u32x4; +/* + * UGLY HACK: Similar to aarch64 macOS GCC, s390x GCC has the same aliasing issue. + */ +typedef xxh_u64x2 xxh_aliasing_u64x2 XXH_ALIASING; + # ifndef XXH_VSX_BE # if defined(__BIG_ENDIAN__) \ || (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) @@ -3150,8 +3906,9 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_loadu(const void *ptr) /* s390x is always big endian, no issue on this platform */ # define XXH_vec_mulo vec_mulo # define XXH_vec_mule vec_mule -# elif defined(__clang__) && XXH_HAS_BUILTIN(__builtin_altivec_vmuleuw) +# elif defined(__clang__) && XXH_HAS_BUILTIN(__builtin_altivec_vmuleuw) && !defined(__ibmxl__) /* Clang has a better way to control this, we can just use the builtin which doesn't swap. */ + /* The IBM XL Compiler (which defined __clang__) only implements the vec_* operations */ # define XXH_vec_mulo __builtin_altivec_vmulouw # define XXH_vec_mule __builtin_altivec_vmuleuw # else @@ -3172,13 +3929,28 @@ XXH_FORCE_INLINE xxh_u64x2 XXH_vec_mule(xxh_u32x4 a, xxh_u32x4 b) # endif /* XXH_vec_mulo, XXH_vec_mule */ #endif /* XXH_VECTOR == XXH_VSX */ +#if XXH_VECTOR == XXH_SVE +#define ACCRND(acc, offset) \ +do { \ + svuint64_t input_vec = svld1_u64(mask, xinput + offset); \ + svuint64_t secret_vec = svld1_u64(mask, xsecret + offset); \ + svuint64_t mixed = sveor_u64_x(mask, secret_vec, input_vec); \ + svuint64_t swapped = svtbl_u64(input_vec, kSwap); \ + svuint64_t mixed_lo = svextw_u64_x(mask, mixed); \ + svuint64_t mixed_hi = svlsr_n_u64_x(mask, mixed, 32); \ + svuint64_t mul = svmad_u64_x(mask, mixed_lo, mixed_hi, swapped); \ + acc = svadd_u64_x(mask, acc, mul); \ +} while (0) +#endif /* XXH_VECTOR == XXH_SVE */ /* prefetch * can be disabled, by declaring XXH_NO_PREFETCH build macro */ #if defined(XXH_NO_PREFETCH) # define XXH_PREFETCH(ptr) (void)(ptr) /* disabled */ #else -# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) /* _mm_prefetch() not defined outside of x86/x64 */ +# if XXH_SIZE_OPT >= 1 +# define XXH_PREFETCH(ptr) (void)(ptr) +# elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) /* _mm_prefetch() not defined outside of x86/x64 */ # include /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ # define XXH_PREFETCH(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0) # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) @@ -3215,6 +3987,8 @@ XXH_ALIGN(64) static const xxh_u8 XXH3_kSecret[XXH_SECRET_DEFAULT_SIZE] = { 0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e, }; +static const xxh_u64 PRIME_MX1 = 0x165667919E3779F9ULL; /*!< 0b0001011001010110011001111001000110011110001101110111100111111001 */ +static const xxh_u64 PRIME_MX2 = 0x9FB21C651E98DF25ULL; /*!< 0b1001111110110010000111000110010100011110100110001101111100100101 */ #ifdef XXH_OLD_NAMES # define kSecret XXH3_kSecret @@ -3243,7 +4017,6 @@ XXH_mult32to64(xxh_u64 x, xxh_u64 y) return (x & 0xFFFFFFFF) * (y & 0xFFFFFFFF); } #elif defined(_MSC_VER) && defined(_M_IX86) -# include # define XXH_mult32to64(x, y) __emulu((unsigned)(x), (unsigned)(y)) #else /* @@ -3283,7 +4056,7 @@ XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs) * In that case it is best to use the portable one. * https://github.com/Cyan4973/xxHash/issues/211#issuecomment-515575677 */ -#if defined(__GNUC__) && !defined(__wasm__) \ +#if (defined(__GNUC__) || defined(__clang__)) && !defined(__wasm__) \ && defined(__SIZEOF_INT128__) \ || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 128) @@ -3300,7 +4073,7 @@ XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs) * * This compiles to single operand MUL on x64. */ -#elif defined(_M_X64) || defined(_M_IA64) +#elif (defined(_M_X64) || defined(_M_IA64)) && !defined(_M_ARM64EC) #ifndef _MSC_VER # pragma intrinsic(_umul128) @@ -3317,7 +4090,7 @@ XXH_mult64to128(xxh_u64 lhs, xxh_u64 rhs) * * This compiles to the same MUL + UMULH as GCC/Clang's __uint128_t method. */ -#elif defined(_M_ARM64) +#elif defined(_M_ARM64) || defined(_M_ARM64EC) #ifndef _MSC_VER # pragma intrinsic(__umulh) @@ -3407,7 +4180,7 @@ XXH3_mul128_fold64(xxh_u64 lhs, xxh_u64 rhs) } /*! Seems to produce slightly better code on GCC for some reason. */ -XXH_FORCE_INLINE xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift) +XXH_FORCE_INLINE XXH_CONSTF xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift) { XXH_ASSERT(0 <= shift && shift < 64); return v64 ^ (v64 >> shift); @@ -3420,7 +4193,7 @@ XXH_FORCE_INLINE xxh_u64 XXH_xorshift64(xxh_u64 v64, int shift) static XXH64_hash_t XXH3_avalanche(xxh_u64 h64) { h64 = XXH_xorshift64(h64, 37); - h64 *= 0x165667919E3779F9ULL; + h64 *= PRIME_MX1; h64 = XXH_xorshift64(h64, 32); return h64; } @@ -3434,9 +4207,9 @@ static XXH64_hash_t XXH3_rrmxmx(xxh_u64 h64, xxh_u64 len) { /* this mix is inspired by Pelle Evensen's rrmxmx */ h64 ^= XXH_rotl64(h64, 49) ^ XXH_rotl64(h64, 24); - h64 *= 0x9FB21C651E98DF25ULL; + h64 *= PRIME_MX2; h64 ^= (h64 >> 35) + len ; - h64 *= 0x9FB21C651E98DF25ULL; + h64 *= PRIME_MX2; return XXH_xorshift64(h64, 28); } @@ -3474,7 +4247,7 @@ static XXH64_hash_t XXH3_rrmxmx(xxh_u64 h64, xxh_u64 len) * * This adds an extra layer of strength for custom secrets. */ -XXH_FORCE_INLINE XXH64_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t XXH3_len_1to3_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { XXH_ASSERT(input != NULL); @@ -3496,7 +4269,7 @@ XXH3_len_1to3_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_h } } -XXH_FORCE_INLINE XXH64_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t XXH3_len_4to8_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { XXH_ASSERT(input != NULL); @@ -3512,7 +4285,7 @@ XXH3_len_4to8_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_h } } -XXH_FORCE_INLINE XXH64_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t XXH3_len_9to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { XXH_ASSERT(input != NULL); @@ -3529,7 +4302,7 @@ XXH3_len_9to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_ } } -XXH_FORCE_INLINE XXH64_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t XXH3_len_0to16_64b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { XXH_ASSERT(len <= 16); @@ -3599,7 +4372,7 @@ XXH_FORCE_INLINE xxh_u64 XXH3_mix16B(const xxh_u8* XXH_RESTRICT input, } /* For mid range keys, XXH3 uses a Mum-hash variant. */ -XXH_FORCE_INLINE XXH64_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH64_hash_t XXH3_len_17to128_64b(const xxh_u8* XXH_RESTRICT input, size_t len, const xxh_u8* XXH_RESTRICT secret, size_t secretSize, XXH64_hash_t seed) @@ -3608,6 +4381,14 @@ XXH3_len_17to128_64b(const xxh_u8* XXH_RESTRICT input, size_t len, XXH_ASSERT(16 < len && len <= 128); { xxh_u64 acc = len * XXH_PRIME64_1; +#if XXH_SIZE_OPT >= 1 + /* Smaller and cleaner, but slightly slower. */ + unsigned int i = (unsigned int)(len - 1) / 32; + do { + acc += XXH3_mix16B(input+16 * i, secret+32*i, seed); + acc += XXH3_mix16B(input+len-16*(i+1), secret+32*i+16, seed); + } while (i-- != 0); +#else if (len > 32) { if (len > 64) { if (len > 96) { @@ -3622,14 +4403,14 @@ XXH3_len_17to128_64b(const xxh_u8* XXH_RESTRICT input, size_t len, } acc += XXH3_mix16B(input+0, secret+0, seed); acc += XXH3_mix16B(input+len-16, secret+16, seed); - +#endif return XXH3_avalanche(acc); } } #define XXH3_MIDSIZE_MAX 240 -XXH_NO_INLINE XXH64_hash_t +XXH_NO_INLINE XXH_PUREF XXH64_hash_t XXH3_len_129to240_64b(const xxh_u8* XXH_RESTRICT input, size_t len, const xxh_u8* XXH_RESTRICT secret, size_t secretSize, XXH64_hash_t seed) @@ -3641,13 +4422,17 @@ XXH3_len_129to240_64b(const xxh_u8* XXH_RESTRICT input, size_t len, #define XXH3_MIDSIZE_LASTOFFSET 17 { xxh_u64 acc = len * XXH_PRIME64_1; - int const nbRounds = (int)len / 16; - int i; + xxh_u64 acc_end; + unsigned int const nbRounds = (unsigned int)len / 16; + unsigned int i; + XXH_ASSERT(128 < len && len <= XXH3_MIDSIZE_MAX); for (i=0; i<8; i++) { acc += XXH3_mix16B(input+(16*i), secret+(16*i), seed); } - acc = XXH3_avalanche(acc); + /* last bytes */ + acc_end = XXH3_mix16B(input + len - 16, secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET, seed); XXH_ASSERT(nbRounds >= 8); + acc = XXH3_avalanche(acc); #if defined(__clang__) /* Clang */ \ && (defined(__ARM_NEON) || defined(__ARM_NEON__)) /* NEON */ \ && !defined(XXH_ENABLE_AUTOVECTORIZE) /* Define to disable */ @@ -3674,11 +4459,13 @@ XXH3_len_129to240_64b(const xxh_u8* XXH_RESTRICT input, size_t len, #pragma clang loop vectorize(disable) #endif for (i=8 ; i < nbRounds; i++) { - acc += XXH3_mix16B(input+(16*i), secret+(16*(i-8)) + XXH3_MIDSIZE_STARTOFFSET, seed); + /* + * Prevents clang for unrolling the acc loop and interleaving with this one. + */ + XXH_COMPILER_GUARD(acc); + acc_end += XXH3_mix16B(input+(16*i), secret+(16*(i-8)) + XXH3_MIDSIZE_STARTOFFSET, seed); } - /* last bytes */ - acc += XXH3_mix16B(input + len - 16, secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET, seed); - return XXH3_avalanche(acc); + return XXH3_avalanche(acc + acc_end); } } @@ -3694,6 +4481,47 @@ XXH3_len_129to240_64b(const xxh_u8* XXH_RESTRICT input, size_t len, # define ACC_NB XXH_ACC_NB #endif +#ifndef XXH_PREFETCH_DIST +# ifdef __clang__ +# define XXH_PREFETCH_DIST 320 +# else +# if (XXH_VECTOR == XXH_AVX512) +# define XXH_PREFETCH_DIST 512 +# else +# define XXH_PREFETCH_DIST 384 +# endif +# endif /* __clang__ */ +#endif /* XXH_PREFETCH_DIST */ + +/* + * These macros are to generate an XXH3_accumulate() function. + * The two arguments select the name suffix and target attribute. + * + * The name of this symbol is XXH3_accumulate_() and it calls + * XXH3_accumulate_512_(). + * + * It may be useful to hand implement this function if the compiler fails to + * optimize the inline function. + */ +#define XXH3_ACCUMULATE_TEMPLATE(name) \ +void \ +XXH3_accumulate_##name(xxh_u64* XXH_RESTRICT acc, \ + const xxh_u8* XXH_RESTRICT input, \ + const xxh_u8* XXH_RESTRICT secret, \ + size_t nbStripes) \ +{ \ + size_t n; \ + for (n = 0; n < nbStripes; n++ ) { \ + const xxh_u8* const in = input + n*XXH_STRIPE_LEN; \ + XXH_PREFETCH(in + XXH_PREFETCH_DIST); \ + XXH3_accumulate_512_##name( \ + acc, \ + in, \ + secret + n*XXH_SECRET_CONSUME_RATE); \ + } \ +} + + XXH_FORCE_INLINE void XXH_writeLE64(void* dst, xxh_u64 v64) { if (!XXH_CPU_LITTLE_ENDIAN) v64 = XXH_swap64(v64); @@ -3714,6 +4542,7 @@ XXH_FORCE_INLINE void XXH_writeLE64(void* dst, xxh_u64 v64) typedef long long xxh_i64; #endif + /* * XXH3_accumulate_512 is the tightest loop for long inputs, and it is the most optimized. * @@ -3761,7 +4590,7 @@ XXH3_accumulate_512_avx512(void* XXH_RESTRICT acc, /* data_key = data_vec ^ key_vec; */ __m512i const data_key = _mm512_xor_si512 (data_vec, key_vec); /* data_key_lo = data_key >> 32; */ - __m512i const data_key_lo = _mm512_shuffle_epi32 (data_key, (_MM_PERM_ENUM)_MM_SHUFFLE(0, 3, 0, 1)); + __m512i const data_key_lo = _mm512_srli_epi64 (data_key, 32); /* product = (data_key & 0xffffffff) * (data_key_lo & 0xffffffff); */ __m512i const product = _mm512_mul_epu32 (data_key, data_key_lo); /* xacc[0] += swap(data_vec); */ @@ -3771,6 +4600,7 @@ XXH3_accumulate_512_avx512(void* XXH_RESTRICT acc, *xacc = _mm512_add_epi64(product, sum); } } +XXH_FORCE_INLINE XXH_TARGET_AVX512 XXH3_ACCUMULATE_TEMPLATE(avx512) /* * XXH3_scrambleAcc: Scrambles the accumulators to improve mixing. @@ -3804,13 +4634,12 @@ XXH3_scrambleAcc_avx512(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) /* xacc[0] ^= (xacc[0] >> 47) */ __m512i const acc_vec = *xacc; __m512i const shifted = _mm512_srli_epi64 (acc_vec, 47); - __m512i const data_vec = _mm512_xor_si512 (acc_vec, shifted); /* xacc[0] ^= secret; */ __m512i const key_vec = _mm512_loadu_si512 (secret); - __m512i const data_key = _mm512_xor_si512 (data_vec, key_vec); + __m512i const data_key = _mm512_ternarylogic_epi32(key_vec, acc_vec, shifted, 0x96 /* key_vec ^ acc_vec ^ shifted */); /* xacc[0] *= XXH_PRIME32_1; */ - __m512i const data_key_hi = _mm512_shuffle_epi32 (data_key, (_MM_PERM_ENUM)_MM_SHUFFLE(0, 3, 0, 1)); + __m512i const data_key_hi = _mm512_srli_epi64 (data_key, 32); __m512i const prod_lo = _mm512_mul_epu32 (data_key, prime32); __m512i const prod_hi = _mm512_mul_epu32 (data_key_hi, prime32); *xacc = _mm512_add_epi64(prod_lo, _mm512_slli_epi64(prod_hi, 32)); @@ -3825,7 +4654,8 @@ XXH3_initCustomSecret_avx512(void* XXH_RESTRICT customSecret, xxh_u64 seed64) XXH_ASSERT(((size_t)customSecret & 63) == 0); (void)(&XXH_writeLE64); { int const nbRounds = XXH_SECRET_DEFAULT_SIZE / sizeof(__m512i); - __m512i const seed = _mm512_mask_set1_epi64(_mm512_set1_epi64((xxh_i64)seed64), 0xAA, (xxh_i64)(0U - seed64)); + __m512i const seed_pos = _mm512_set1_epi64((xxh_i64)seed64); + __m512i const seed = _mm512_mask_sub_epi64(seed_pos, 0xAA, _mm512_set1_epi8(0), seed_pos); const __m512i* const src = (const __m512i*) ((const void*) XXH3_kSecret); __m512i* const dest = ( __m512i*) customSecret; @@ -3833,14 +4663,7 @@ XXH3_initCustomSecret_avx512(void* XXH_RESTRICT customSecret, xxh_u64 seed64) XXH_ASSERT(((size_t)src & 63) == 0); /* control alignment */ XXH_ASSERT(((size_t)dest & 63) == 0); for (i=0; i < nbRounds; ++i) { - /* GCC has a bug, _mm512_stream_load_si512 accepts 'void*', not 'void const*', - * this will warn "discards 'const' qualifier". */ - union { - const __m512i* cp; - void* p; - } remote_const_void; - remote_const_void.cp = src + i; - dest[i] = _mm512_add_epi64(_mm512_stream_load_si512(remote_const_void.p), seed); + dest[i] = _mm512_add_epi64(_mm512_load_si512(src + i), seed); } } } @@ -3876,7 +4699,7 @@ XXH3_accumulate_512_avx2( void* XXH_RESTRICT acc, /* data_key = data_vec ^ key_vec; */ __m256i const data_key = _mm256_xor_si256 (data_vec, key_vec); /* data_key_lo = data_key >> 32; */ - __m256i const data_key_lo = _mm256_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1)); + __m256i const data_key_lo = _mm256_srli_epi64 (data_key, 32); /* product = (data_key & 0xffffffff) * (data_key_lo & 0xffffffff); */ __m256i const product = _mm256_mul_epu32 (data_key, data_key_lo); /* xacc[i] += swap(data_vec); */ @@ -3886,6 +4709,7 @@ XXH3_accumulate_512_avx2( void* XXH_RESTRICT acc, xacc[i] = _mm256_add_epi64(product, sum); } } } +XXH_FORCE_INLINE XXH_TARGET_AVX2 XXH3_ACCUMULATE_TEMPLATE(avx2) XXH_FORCE_INLINE XXH_TARGET_AVX2 void XXH3_scrambleAcc_avx2(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) @@ -3908,7 +4732,7 @@ XXH3_scrambleAcc_avx2(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) __m256i const data_key = _mm256_xor_si256 (data_vec, key_vec); /* xacc[i] *= XXH_PRIME32_1; */ - __m256i const data_key_hi = _mm256_shuffle_epi32 (data_key, _MM_SHUFFLE(0, 3, 0, 1)); + __m256i const data_key_hi = _mm256_srli_epi64 (data_key, 32); __m256i const prod_lo = _mm256_mul_epu32 (data_key, prime32); __m256i const prod_hi = _mm256_mul_epu32 (data_key_hi, prime32); xacc[i] = _mm256_add_epi64(prod_lo, _mm256_slli_epi64(prod_hi, 32)); @@ -3940,12 +4764,12 @@ XXH_FORCE_INLINE XXH_TARGET_AVX2 void XXH3_initCustomSecret_avx2(void* XXH_RESTR XXH_ASSERT(((size_t)dest & 31) == 0); /* GCC -O2 need unroll loop manually */ - dest[0] = _mm256_add_epi64(_mm256_stream_load_si256(src+0), seed); - dest[1] = _mm256_add_epi64(_mm256_stream_load_si256(src+1), seed); - dest[2] = _mm256_add_epi64(_mm256_stream_load_si256(src+2), seed); - dest[3] = _mm256_add_epi64(_mm256_stream_load_si256(src+3), seed); - dest[4] = _mm256_add_epi64(_mm256_stream_load_si256(src+4), seed); - dest[5] = _mm256_add_epi64(_mm256_stream_load_si256(src+5), seed); + dest[0] = _mm256_add_epi64(_mm256_load_si256(src+0), seed); + dest[1] = _mm256_add_epi64(_mm256_load_si256(src+1), seed); + dest[2] = _mm256_add_epi64(_mm256_load_si256(src+2), seed); + dest[3] = _mm256_add_epi64(_mm256_load_si256(src+3), seed); + dest[4] = _mm256_add_epi64(_mm256_load_si256(src+4), seed); + dest[5] = _mm256_add_epi64(_mm256_load_si256(src+5), seed); } } @@ -3992,6 +4816,7 @@ XXH3_accumulate_512_sse2( void* XXH_RESTRICT acc, xacc[i] = _mm_add_epi64(product, sum); } } } +XXH_FORCE_INLINE XXH_TARGET_SSE2 XXH3_ACCUMULATE_TEMPLATE(sse2) XXH_FORCE_INLINE XXH_TARGET_SSE2 void XXH3_scrambleAcc_sse2(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) @@ -4059,96 +4884,222 @@ XXH_FORCE_INLINE XXH_TARGET_SSE2 void XXH3_initCustomSecret_sse2(void* XXH_RESTR #if (XXH_VECTOR == XXH_NEON) +/* forward declarations for the scalar routines */ +XXH_FORCE_INLINE void +XXH3_scalarRound(void* XXH_RESTRICT acc, void const* XXH_RESTRICT input, + void const* XXH_RESTRICT secret, size_t lane); + +XXH_FORCE_INLINE void +XXH3_scalarScrambleRound(void* XXH_RESTRICT acc, + void const* XXH_RESTRICT secret, size_t lane); + +/*! + * @internal + * @brief The bulk processing loop for NEON and WASM SIMD128. + * + * The NEON code path is actually partially scalar when running on AArch64. This + * is to optimize the pipelining and can have up to 15% speedup depending on the + * CPU, and it also mitigates some GCC codegen issues. + * + * @see XXH3_NEON_LANES for configuring this and details about this optimization. + * + * NEON's 32-bit to 64-bit long multiply takes a half vector of 32-bit + * integers instead of the other platforms which mask full 64-bit vectors, + * so the setup is more complicated than just shifting right. + * + * Additionally, there is an optimization for 4 lanes at once noted below. + * + * Since, as stated, the most optimal amount of lanes for Cortexes is 6, + * there needs to be *three* versions of the accumulate operation used + * for the remaining 2 lanes. + * + * WASM's SIMD128 uses SIMDe's arm_neon.h polyfill because the intrinsics overlap + * nearly perfectly. + */ + XXH_FORCE_INLINE void XXH3_accumulate_512_neon( void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, const void* XXH_RESTRICT secret) { XXH_ASSERT((((size_t)acc) & 15) == 0); - { - uint64x2_t* const xacc = (uint64x2_t *) acc; + XXH_STATIC_ASSERT(XXH3_NEON_LANES > 0 && XXH3_NEON_LANES <= XXH_ACC_NB && XXH3_NEON_LANES % 2 == 0); + { /* GCC for darwin arm64 does not like aliasing here */ + xxh_aliasing_uint64x2_t* const xacc = (xxh_aliasing_uint64x2_t*) acc; /* We don't use a uint32x4_t pointer because it causes bus errors on ARMv7. */ - uint8_t const* const xinput = (const uint8_t *) input; - uint8_t const* const xsecret = (const uint8_t *) secret; + uint8_t const* xinput = (const uint8_t *) input; + uint8_t const* xsecret = (const uint8_t *) secret; size_t i; - for (i=0; i < XXH_STRIPE_LEN / sizeof(uint64x2_t); i++) { +#ifdef __wasm_simd128__ + /* + * On WASM SIMD128, Clang emits direct address loads when XXH3_kSecret + * is constant propagated, which results in it converting it to this + * inside the loop: + * + * a = v128.load(XXH3_kSecret + 0 + $secret_offset, offset = 0) + * b = v128.load(XXH3_kSecret + 16 + $secret_offset, offset = 0) + * ... + * + * This requires a full 32-bit address immediate (and therefore a 6 byte + * instruction) as well as an add for each offset. + * + * Putting an asm guard prevents it from folding (at the cost of losing + * the alignment hint), and uses the free offset in `v128.load` instead + * of adding secret_offset each time which overall reduces code size by + * about a kilobyte and improves performance. + */ + XXH_COMPILER_GUARD(xsecret); +#endif + /* Scalar lanes use the normal scalarRound routine */ + for (i = XXH3_NEON_LANES; i < XXH_ACC_NB; i++) { + XXH3_scalarRound(acc, input, secret, i); + } + i = 0; + /* 4 NEON lanes at a time. */ + for (; i+1 < XXH3_NEON_LANES / 2; i+=2) { /* data_vec = xinput[i]; */ - uint8x16_t data_vec = vld1q_u8(xinput + (i * 16)); + uint64x2_t data_vec_1 = XXH_vld1q_u64(xinput + (i * 16)); + uint64x2_t data_vec_2 = XXH_vld1q_u64(xinput + ((i+1) * 16)); /* key_vec = xsecret[i]; */ - uint8x16_t key_vec = vld1q_u8(xsecret + (i * 16)); - uint64x2_t data_key; - uint32x2_t data_key_lo, data_key_hi; - /* xacc[i] += swap(data_vec); */ - uint64x2_t const data64 = vreinterpretq_u64_u8(data_vec); - uint64x2_t const swapped = vextq_u64(data64, data64, 1); - xacc[i] = vaddq_u64 (xacc[i], swapped); + uint64x2_t key_vec_1 = XXH_vld1q_u64(xsecret + (i * 16)); + uint64x2_t key_vec_2 = XXH_vld1q_u64(xsecret + ((i+1) * 16)); + /* data_swap = swap(data_vec) */ + uint64x2_t data_swap_1 = vextq_u64(data_vec_1, data_vec_1, 1); + uint64x2_t data_swap_2 = vextq_u64(data_vec_2, data_vec_2, 1); /* data_key = data_vec ^ key_vec; */ - data_key = vreinterpretq_u64_u8(veorq_u8(data_vec, key_vec)); - /* data_key_lo = (uint32x2_t) (data_key & 0xFFFFFFFF); - * data_key_hi = (uint32x2_t) (data_key >> 32); - * data_key = UNDEFINED; */ - XXH_SPLIT_IN_PLACE(data_key, data_key_lo, data_key_hi); - /* xacc[i] += (uint64x2_t) data_key_lo * (uint64x2_t) data_key_hi; */ - xacc[i] = vmlal_u32 (xacc[i], data_key_lo, data_key_hi); + uint64x2_t data_key_1 = veorq_u64(data_vec_1, key_vec_1); + uint64x2_t data_key_2 = veorq_u64(data_vec_2, key_vec_2); + /* + * If we reinterpret the 64x2 vectors as 32x4 vectors, we can use a + * de-interleave operation for 4 lanes in 1 step with `vuzpq_u32` to + * get one vector with the low 32 bits of each lane, and one vector + * with the high 32 bits of each lane. + * + * The intrinsic returns a double vector because the original ARMv7-a + * instruction modified both arguments in place. AArch64 and SIMD128 emit + * two instructions from this intrinsic. + * + * [ dk11L | dk11H | dk12L | dk12H ] -> [ dk11L | dk12L | dk21L | dk22L ] + * [ dk21L | dk21H | dk22L | dk22H ] -> [ dk11H | dk12H | dk21H | dk22H ] + */ + uint32x4x2_t unzipped = vuzpq_u32( + vreinterpretq_u32_u64(data_key_1), + vreinterpretq_u32_u64(data_key_2) + ); + /* data_key_lo = data_key & 0xFFFFFFFF */ + uint32x4_t data_key_lo = unzipped.val[0]; + /* data_key_hi = data_key >> 32 */ + uint32x4_t data_key_hi = unzipped.val[1]; + /* + * Then, we can split the vectors horizontally and multiply which, as for most + * widening intrinsics, have a variant that works on both high half vectors + * for free on AArch64. A similar instruction is available on SIMD128. + * + * sum = data_swap + (u64x2) data_key_lo * (u64x2) data_key_hi + */ + uint64x2_t sum_1 = XXH_vmlal_low_u32(data_swap_1, data_key_lo, data_key_hi); + uint64x2_t sum_2 = XXH_vmlal_high_u32(data_swap_2, data_key_lo, data_key_hi); + /* + * Clang reorders + * a += b * c; // umlal swap.2d, dkl.2s, dkh.2s + * c += a; // add acc.2d, acc.2d, swap.2d + * to + * c += a; // add acc.2d, acc.2d, swap.2d + * c += b * c; // umlal acc.2d, dkl.2s, dkh.2s + * + * While it would make sense in theory since the addition is faster, + * for reasons likely related to umlal being limited to certain NEON + * pipelines, this is worse. A compiler guard fixes this. + */ + XXH_COMPILER_GUARD_CLANG_NEON(sum_1); + XXH_COMPILER_GUARD_CLANG_NEON(sum_2); + /* xacc[i] = acc_vec + sum; */ + xacc[i] = vaddq_u64(xacc[i], sum_1); + xacc[i+1] = vaddq_u64(xacc[i+1], sum_2); + } + /* Operate on the remaining NEON lanes 2 at a time. */ + for (; i < XXH3_NEON_LANES / 2; i++) { + /* data_vec = xinput[i]; */ + uint64x2_t data_vec = XXH_vld1q_u64(xinput + (i * 16)); + /* key_vec = xsecret[i]; */ + uint64x2_t key_vec = XXH_vld1q_u64(xsecret + (i * 16)); + /* acc_vec_2 = swap(data_vec) */ + uint64x2_t data_swap = vextq_u64(data_vec, data_vec, 1); + /* data_key = data_vec ^ key_vec; */ + uint64x2_t data_key = veorq_u64(data_vec, key_vec); + /* For two lanes, just use VMOVN and VSHRN. */ + /* data_key_lo = data_key & 0xFFFFFFFF; */ + uint32x2_t data_key_lo = vmovn_u64(data_key); + /* data_key_hi = data_key >> 32; */ + uint32x2_t data_key_hi = vshrn_n_u64(data_key, 32); + /* sum = data_swap + (u64x2) data_key_lo * (u64x2) data_key_hi; */ + uint64x2_t sum = vmlal_u32(data_swap, data_key_lo, data_key_hi); + /* Same Clang workaround as before */ + XXH_COMPILER_GUARD_CLANG_NEON(sum); + /* xacc[i] = acc_vec + sum; */ + xacc[i] = vaddq_u64 (xacc[i], sum); } } } +XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(neon) XXH_FORCE_INLINE void XXH3_scrambleAcc_neon(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) { XXH_ASSERT((((size_t)acc) & 15) == 0); - { uint64x2_t* xacc = (uint64x2_t*) acc; + { xxh_aliasing_uint64x2_t* xacc = (xxh_aliasing_uint64x2_t*) acc; uint8_t const* xsecret = (uint8_t const*) secret; - uint32x2_t prime = vdup_n_u32 (XXH_PRIME32_1); size_t i; - for (i=0; i < XXH_STRIPE_LEN/sizeof(uint64x2_t); i++) { + /* WASM uses operator overloads and doesn't need these. */ +#ifndef __wasm_simd128__ + /* { prime32_1, prime32_1 } */ + uint32x2_t const kPrimeLo = vdup_n_u32(XXH_PRIME32_1); + /* { 0, prime32_1, 0, prime32_1 } */ + uint32x4_t const kPrimeHi = vreinterpretq_u32_u64(vdupq_n_u64((xxh_u64)XXH_PRIME32_1 << 32)); +#endif + + /* AArch64 uses both scalar and neon at the same time */ + for (i = XXH3_NEON_LANES; i < XXH_ACC_NB; i++) { + XXH3_scalarScrambleRound(acc, secret, i); + } + for (i=0; i < XXH3_NEON_LANES / 2; i++) { /* xacc[i] ^= (xacc[i] >> 47); */ uint64x2_t acc_vec = xacc[i]; - uint64x2_t shifted = vshrq_n_u64 (acc_vec, 47); - uint64x2_t data_vec = veorq_u64 (acc_vec, shifted); + uint64x2_t shifted = vshrq_n_u64(acc_vec, 47); + uint64x2_t data_vec = veorq_u64(acc_vec, shifted); /* xacc[i] ^= xsecret[i]; */ - uint8x16_t key_vec = vld1q_u8 (xsecret + (i * 16)); - uint64x2_t data_key = veorq_u64 (data_vec, vreinterpretq_u64_u8(key_vec)); - + uint64x2_t key_vec = XXH_vld1q_u64(xsecret + (i * 16)); + uint64x2_t data_key = veorq_u64(data_vec, key_vec); /* xacc[i] *= XXH_PRIME32_1 */ - uint32x2_t data_key_lo, data_key_hi; - /* data_key_lo = (uint32x2_t) (xacc[i] & 0xFFFFFFFF); - * data_key_hi = (uint32x2_t) (xacc[i] >> 32); - * xacc[i] = UNDEFINED; */ - XXH_SPLIT_IN_PLACE(data_key, data_key_lo, data_key_hi); - { /* - * prod_hi = (data_key >> 32) * XXH_PRIME32_1; - * - * Avoid vmul_u32 + vshll_n_u32 since Clang 6 and 7 will - * incorrectly "optimize" this: - * tmp = vmul_u32(vmovn_u64(a), vmovn_u64(b)); - * shifted = vshll_n_u32(tmp, 32); - * to this: - * tmp = "vmulq_u64"(a, b); // no such thing! - * shifted = vshlq_n_u64(tmp, 32); - * - * However, unlike SSE, Clang lacks a 64-bit multiply routine - * for NEON, and it scalarizes two 64-bit multiplies instead. - * - * vmull_u32 has the same timing as vmul_u32, and it avoids - * this bug completely. - * See https://bugs.llvm.org/show_bug.cgi?id=39967 - */ - uint64x2_t prod_hi = vmull_u32 (data_key_hi, prime); - /* xacc[i] = prod_hi << 32; */ - xacc[i] = vshlq_n_u64(prod_hi, 32); - /* xacc[i] += (prod_hi & 0xFFFFFFFF) * XXH_PRIME32_1; */ - xacc[i] = vmlal_u32(xacc[i], data_key_lo, prime); - } - } } +#ifdef __wasm_simd128__ + /* SIMD128 has multiply by u64x2, use it instead of expanding and scalarizing */ + xacc[i] = data_key * XXH_PRIME32_1; +#else + /* + * Expanded version with portable NEON intrinsics + * + * lo(x) * lo(y) + (hi(x) * lo(y) << 32) + * + * prod_hi = hi(data_key) * lo(prime) << 32 + * + * Since we only need 32 bits of this multiply a trick can be used, reinterpreting the vector + * as a uint32x4_t and multiplying by { 0, prime, 0, prime } to cancel out the unwanted bits + * and avoid the shift. + */ + uint32x4_t prod_hi = vmulq_u32 (vreinterpretq_u32_u64(data_key), kPrimeHi); + /* Extract low bits for vmlal_u32 */ + uint32x2_t data_key_lo = vmovn_u64(data_key); + /* xacc[i] = prod_hi + lo(data_key) * XXH_PRIME32_1; */ + xacc[i] = vmlal_u32(vreinterpretq_u64_u32(prod_hi), data_key_lo, kPrimeLo); +#endif + } + } } - #endif #if (XXH_VECTOR == XXH_VSX) @@ -4159,23 +5110,23 @@ XXH3_accumulate_512_vsx( void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) { /* presumed aligned */ - unsigned int* const xacc = (unsigned int*) acc; - xxh_u64x2 const* const xinput = (xxh_u64x2 const*) input; /* no alignment restriction */ - xxh_u64x2 const* const xsecret = (xxh_u64x2 const*) secret; /* no alignment restriction */ + xxh_aliasing_u64x2* const xacc = (xxh_aliasing_u64x2*) acc; + xxh_u8 const* const xinput = (xxh_u8 const*) input; /* no alignment restriction */ + xxh_u8 const* const xsecret = (xxh_u8 const*) secret; /* no alignment restriction */ xxh_u64x2 const v32 = { 32, 32 }; size_t i; for (i = 0; i < XXH_STRIPE_LEN / sizeof(xxh_u64x2); i++) { /* data_vec = xinput[i]; */ - xxh_u64x2 const data_vec = XXH_vec_loadu(xinput + i); + xxh_u64x2 const data_vec = XXH_vec_loadu(xinput + 16*i); /* key_vec = xsecret[i]; */ - xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + i); + xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + 16*i); xxh_u64x2 const data_key = data_vec ^ key_vec; /* shuffled = (data_key << 32) | (data_key >> 32); */ xxh_u32x4 const shuffled = (xxh_u32x4)vec_rl(data_key, v32); /* product = ((xxh_u64x2)data_key & 0xFFFFFFFF) * ((xxh_u64x2)shuffled & 0xFFFFFFFF); */ xxh_u64x2 const product = XXH_vec_mulo((xxh_u32x4)data_key, shuffled); /* acc_vec = xacc[i]; */ - xxh_u64x2 acc_vec = (xxh_u64x2)vec_xl(0, xacc + 4 * i); + xxh_u64x2 acc_vec = xacc[i]; acc_vec += product; /* swap high and low halves */ @@ -4184,18 +5135,18 @@ XXH3_accumulate_512_vsx( void* XXH_RESTRICT acc, #else acc_vec += vec_xxpermdi(data_vec, data_vec, 2); #endif - /* xacc[i] = acc_vec; */ - vec_xst((xxh_u32x4)acc_vec, 0, xacc + 4 * i); + xacc[i] = acc_vec; } } +XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(vsx) XXH_FORCE_INLINE void XXH3_scrambleAcc_vsx(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) { XXH_ASSERT((((size_t)acc) & 15) == 0); - { xxh_u64x2* const xacc = (xxh_u64x2*) acc; - const xxh_u64x2* const xsecret = (const xxh_u64x2*) secret; + { xxh_aliasing_u64x2* const xacc = (xxh_aliasing_u64x2*) acc; + const xxh_u8* const xsecret = (const xxh_u8*) secret; /* constants */ xxh_u64x2 const v32 = { 32, 32 }; xxh_u64x2 const v47 = { 47, 47 }; @@ -4207,7 +5158,7 @@ XXH3_scrambleAcc_vsx(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) xxh_u64x2 const data_vec = acc_vec ^ (acc_vec >> v47); /* xacc[i] ^= xsecret[i]; */ - xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + i); + xxh_u64x2 const key_vec = XXH_vec_loadu(xsecret + 16*i); xxh_u64x2 const data_key = data_vec ^ key_vec; /* xacc[i] *= XXH_PRIME32_1 */ @@ -4221,40 +5172,233 @@ XXH3_scrambleAcc_vsx(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) #endif +#if (XXH_VECTOR == XXH_SVE) + +XXH_FORCE_INLINE void +XXH3_accumulate_512_sve( void* XXH_RESTRICT acc, + const void* XXH_RESTRICT input, + const void* XXH_RESTRICT secret) +{ + uint64_t *xacc = (uint64_t *)acc; + const uint64_t *xinput = (const uint64_t *)(const void *)input; + const uint64_t *xsecret = (const uint64_t *)(const void *)secret; + svuint64_t kSwap = sveor_n_u64_z(svptrue_b64(), svindex_u64(0, 1), 1); + uint64_t element_count = svcntd(); + if (element_count >= 8) { + svbool_t mask = svptrue_pat_b64(SV_VL8); + svuint64_t vacc = svld1_u64(mask, xacc); + ACCRND(vacc, 0); + svst1_u64(mask, xacc, vacc); + } else if (element_count == 2) { /* sve128 */ + svbool_t mask = svptrue_pat_b64(SV_VL2); + svuint64_t acc0 = svld1_u64(mask, xacc + 0); + svuint64_t acc1 = svld1_u64(mask, xacc + 2); + svuint64_t acc2 = svld1_u64(mask, xacc + 4); + svuint64_t acc3 = svld1_u64(mask, xacc + 6); + ACCRND(acc0, 0); + ACCRND(acc1, 2); + ACCRND(acc2, 4); + ACCRND(acc3, 6); + svst1_u64(mask, xacc + 0, acc0); + svst1_u64(mask, xacc + 2, acc1); + svst1_u64(mask, xacc + 4, acc2); + svst1_u64(mask, xacc + 6, acc3); + } else { + svbool_t mask = svptrue_pat_b64(SV_VL4); + svuint64_t acc0 = svld1_u64(mask, xacc + 0); + svuint64_t acc1 = svld1_u64(mask, xacc + 4); + ACCRND(acc0, 0); + ACCRND(acc1, 4); + svst1_u64(mask, xacc + 0, acc0); + svst1_u64(mask, xacc + 4, acc1); + } +} + +XXH_FORCE_INLINE void +XXH3_accumulate_sve(xxh_u64* XXH_RESTRICT acc, + const xxh_u8* XXH_RESTRICT input, + const xxh_u8* XXH_RESTRICT secret, + size_t nbStripes) +{ + if (nbStripes != 0) { + uint64_t *xacc = (uint64_t *)acc; + const uint64_t *xinput = (const uint64_t *)(const void *)input; + const uint64_t *xsecret = (const uint64_t *)(const void *)secret; + svuint64_t kSwap = sveor_n_u64_z(svptrue_b64(), svindex_u64(0, 1), 1); + uint64_t element_count = svcntd(); + if (element_count >= 8) { + svbool_t mask = svptrue_pat_b64(SV_VL8); + svuint64_t vacc = svld1_u64(mask, xacc + 0); + do { + /* svprfd(svbool_t, void *, enum svfprop); */ + svprfd(mask, xinput + 128, SV_PLDL1STRM); + ACCRND(vacc, 0); + xinput += 8; + xsecret += 1; + nbStripes--; + } while (nbStripes != 0); + + svst1_u64(mask, xacc + 0, vacc); + } else if (element_count == 2) { /* sve128 */ + svbool_t mask = svptrue_pat_b64(SV_VL2); + svuint64_t acc0 = svld1_u64(mask, xacc + 0); + svuint64_t acc1 = svld1_u64(mask, xacc + 2); + svuint64_t acc2 = svld1_u64(mask, xacc + 4); + svuint64_t acc3 = svld1_u64(mask, xacc + 6); + do { + svprfd(mask, xinput + 128, SV_PLDL1STRM); + ACCRND(acc0, 0); + ACCRND(acc1, 2); + ACCRND(acc2, 4); + ACCRND(acc3, 6); + xinput += 8; + xsecret += 1; + nbStripes--; + } while (nbStripes != 0); + + svst1_u64(mask, xacc + 0, acc0); + svst1_u64(mask, xacc + 2, acc1); + svst1_u64(mask, xacc + 4, acc2); + svst1_u64(mask, xacc + 6, acc3); + } else { + svbool_t mask = svptrue_pat_b64(SV_VL4); + svuint64_t acc0 = svld1_u64(mask, xacc + 0); + svuint64_t acc1 = svld1_u64(mask, xacc + 4); + do { + svprfd(mask, xinput + 128, SV_PLDL1STRM); + ACCRND(acc0, 0); + ACCRND(acc1, 4); + xinput += 8; + xsecret += 1; + nbStripes--; + } while (nbStripes != 0); + + svst1_u64(mask, xacc + 0, acc0); + svst1_u64(mask, xacc + 4, acc1); + } + } +} + +#endif + /* scalar variants - universal */ +#if defined(__aarch64__) && (defined(__GNUC__) || defined(__clang__)) +/* + * In XXH3_scalarRound(), GCC and Clang have a similar codegen issue, where they + * emit an excess mask and a full 64-bit multiply-add (MADD X-form). + * + * While this might not seem like much, as AArch64 is a 64-bit architecture, only + * big Cortex designs have a full 64-bit multiplier. + * + * On the little cores, the smaller 32-bit multiplier is used, and full 64-bit + * multiplies expand to 2-3 multiplies in microcode. This has a major penalty + * of up to 4 latency cycles and 2 stall cycles in the multiply pipeline. + * + * Thankfully, AArch64 still provides the 32-bit long multiply-add (UMADDL) which does + * not have this penalty and does the mask automatically. + */ +XXH_FORCE_INLINE xxh_u64 +XXH_mult32to64_add64(xxh_u64 lhs, xxh_u64 rhs, xxh_u64 acc) +{ + xxh_u64 ret; + /* note: %x = 64-bit register, %w = 32-bit register */ + __asm__("umaddl %x0, %w1, %w2, %x3" : "=r" (ret) : "r" (lhs), "r" (rhs), "r" (acc)); + return ret; +} +#else +XXH_FORCE_INLINE xxh_u64 +XXH_mult32to64_add64(xxh_u64 lhs, xxh_u64 rhs, xxh_u64 acc) +{ + return XXH_mult32to64((xxh_u32)lhs, (xxh_u32)rhs) + acc; +} +#endif + +/*! + * @internal + * @brief Scalar round for @ref XXH3_accumulate_512_scalar(). + * + * This is extracted to its own function because the NEON path uses a combination + * of NEON and scalar. + */ +XXH_FORCE_INLINE void +XXH3_scalarRound(void* XXH_RESTRICT acc, + void const* XXH_RESTRICT input, + void const* XXH_RESTRICT secret, + size_t lane) +{ + xxh_u64* xacc = (xxh_u64*) acc; + xxh_u8 const* xinput = (xxh_u8 const*) input; + xxh_u8 const* xsecret = (xxh_u8 const*) secret; + XXH_ASSERT(lane < XXH_ACC_NB); + XXH_ASSERT(((size_t)acc & (XXH_ACC_ALIGN-1)) == 0); + { + xxh_u64 const data_val = XXH_readLE64(xinput + lane * 8); + xxh_u64 const data_key = data_val ^ XXH_readLE64(xsecret + lane * 8); + xacc[lane ^ 1] += data_val; /* swap adjacent lanes */ + xacc[lane] = XXH_mult32to64_add64(data_key /* & 0xFFFFFFFF */, data_key >> 32, xacc[lane]); + } +} + +/*! + * @internal + * @brief Processes a 64 byte block of data using the scalar path. + */ XXH_FORCE_INLINE void XXH3_accumulate_512_scalar(void* XXH_RESTRICT acc, const void* XXH_RESTRICT input, const void* XXH_RESTRICT secret) { - xxh_u64* const xacc = (xxh_u64*) acc; /* presumed aligned */ - const xxh_u8* const xinput = (const xxh_u8*) input; /* no alignment restriction */ - const xxh_u8* const xsecret = (const xxh_u8*) secret; /* no alignment restriction */ size_t i; - XXH_ASSERT(((size_t)acc & (XXH_ACC_ALIGN-1)) == 0); + /* ARM GCC refuses to unroll this loop, resulting in a 24% slowdown on ARMv6. */ +#if defined(__GNUC__) && !defined(__clang__) \ + && (defined(__arm__) || defined(__thumb2__)) \ + && defined(__ARM_FEATURE_UNALIGNED) /* no unaligned access just wastes bytes */ \ + && XXH_SIZE_OPT <= 0 +# pragma GCC unroll 8 +#endif for (i=0; i < XXH_ACC_NB; i++) { - xxh_u64 const data_val = XXH_readLE64(xinput + 8*i); - xxh_u64 const data_key = data_val ^ XXH_readLE64(xsecret + i*8); - xacc[i ^ 1] += data_val; /* swap adjacent lanes */ - xacc[i] += XXH_mult32to64(data_key & 0xFFFFFFFF, data_key >> 32); + XXH3_scalarRound(acc, input, secret, i); } } +XXH_FORCE_INLINE XXH3_ACCUMULATE_TEMPLATE(scalar) +/*! + * @internal + * @brief Scalar scramble step for @ref XXH3_scrambleAcc_scalar(). + * + * This is extracted to its own function because the NEON path uses a combination + * of NEON and scalar. + */ XXH_FORCE_INLINE void -XXH3_scrambleAcc_scalar(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) +XXH3_scalarScrambleRound(void* XXH_RESTRICT acc, + void const* XXH_RESTRICT secret, + size_t lane) { xxh_u64* const xacc = (xxh_u64*) acc; /* presumed aligned */ const xxh_u8* const xsecret = (const xxh_u8*) secret; /* no alignment restriction */ - size_t i; XXH_ASSERT((((size_t)acc) & (XXH_ACC_ALIGN-1)) == 0); - for (i=0; i < XXH_ACC_NB; i++) { - xxh_u64 const key64 = XXH_readLE64(xsecret + 8*i); - xxh_u64 acc64 = xacc[i]; + XXH_ASSERT(lane < XXH_ACC_NB); + { + xxh_u64 const key64 = XXH_readLE64(xsecret + lane * 8); + xxh_u64 acc64 = xacc[lane]; acc64 = XXH_xorshift64(acc64, 47); acc64 ^= key64; acc64 *= XXH_PRIME32_1; - xacc[i] = acc64; + xacc[lane] = acc64; + } +} + +/*! + * @internal + * @brief Scrambles the accumulators after a large chunk has been read + */ +XXH_FORCE_INLINE void +XXH3_scrambleAcc_scalar(void* XXH_RESTRICT acc, const void* XXH_RESTRICT secret) +{ + size_t i; + for (i=0; i < XXH_ACC_NB; i++) { + XXH3_scalarScrambleRound(acc, secret, i); } } @@ -4269,15 +5413,16 @@ XXH3_initCustomSecret_scalar(void* XXH_RESTRICT customSecret, xxh_u64 seed64) const xxh_u8* kSecretPtr = XXH3_kSecret; XXH_STATIC_ASSERT((XXH_SECRET_DEFAULT_SIZE & 15) == 0); -#if defined(__clang__) && defined(__aarch64__) +#if defined(__GNUC__) && defined(__aarch64__) /* * UGLY HACK: - * Clang generates a bunch of MOV/MOVK pairs for aarch64, and they are + * GCC and Clang generate a bunch of MOV/MOVK pairs for aarch64, and they are * placed sequentially, in order, at the top of the unrolled loop. * * While MOVK is great for generating constants (2 cycles for a 64-bit - * constant compared to 4 cycles for LDR), long MOVK chains stall the - * integer pipelines: + * constant compared to 4 cycles for LDR), it fights for bandwidth with + * the arithmetic instructions. + * * I L S * MOVK * MOVK @@ -4286,7 +5431,7 @@ XXH3_initCustomSecret_scalar(void* XXH_RESTRICT customSecret, xxh_u64 seed64) * ADD * SUB STR * STR - * By forcing loads from memory (as the asm line causes Clang to assume + * By forcing loads from memory (as the asm line causes the compiler to assume * that XXH3_kSecretPtr has been changed), the pipelines are used more * efficiently: * I L S @@ -4294,23 +5439,20 @@ XXH3_initCustomSecret_scalar(void* XXH_RESTRICT customSecret, xxh_u64 seed64) * ADD LDR * SUB STR * STR + * + * See XXH3_NEON_LANES for details on the pipsline. + * * XXH3_64bits_withSeed, len == 256, Snapdragon 835 * without hack: 2654.4 MB/s * with hack: 3202.9 MB/s */ XXH_COMPILER_GUARD(kSecretPtr); #endif - /* - * Note: in debug mode, this overrides the asm optimization - * and Clang will emit MOVK chains again. - */ - XXH_ASSERT(kSecretPtr == XXH3_kSecret); - { int const nbRounds = XXH_SECRET_DEFAULT_SIZE / 16; int i; for (i=0; i < nbRounds; i++) { /* - * The asm hack causes Clang to assume that kSecretPtr aliases with + * The asm hack causes the compiler to assume that kSecretPtr aliases with * customSecret, and on aarch64, this prevented LDP from merging two * loads together for free. Putting the loads together before the stores * properly generates LDP. @@ -4323,7 +5465,7 @@ XXH3_initCustomSecret_scalar(void* XXH_RESTRICT customSecret, xxh_u64 seed64) } -typedef void (*XXH3_f_accumulate_512)(void* XXH_RESTRICT, const void*, const void*); +typedef void (*XXH3_f_accumulate)(xxh_u64* XXH_RESTRICT, const xxh_u8* XXH_RESTRICT, const xxh_u8* XXH_RESTRICT, size_t); typedef void (*XXH3_f_scrambleAcc)(void* XXH_RESTRICT, const void*); typedef void (*XXH3_f_initCustomSecret)(void* XXH_RESTRICT, xxh_u64); @@ -4331,82 +5473,63 @@ typedef void (*XXH3_f_initCustomSecret)(void* XXH_RESTRICT, xxh_u64); #if (XXH_VECTOR == XXH_AVX512) #define XXH3_accumulate_512 XXH3_accumulate_512_avx512 +#define XXH3_accumulate XXH3_accumulate_avx512 #define XXH3_scrambleAcc XXH3_scrambleAcc_avx512 #define XXH3_initCustomSecret XXH3_initCustomSecret_avx512 #elif (XXH_VECTOR == XXH_AVX2) #define XXH3_accumulate_512 XXH3_accumulate_512_avx2 +#define XXH3_accumulate XXH3_accumulate_avx2 #define XXH3_scrambleAcc XXH3_scrambleAcc_avx2 #define XXH3_initCustomSecret XXH3_initCustomSecret_avx2 #elif (XXH_VECTOR == XXH_SSE2) #define XXH3_accumulate_512 XXH3_accumulate_512_sse2 +#define XXH3_accumulate XXH3_accumulate_sse2 #define XXH3_scrambleAcc XXH3_scrambleAcc_sse2 #define XXH3_initCustomSecret XXH3_initCustomSecret_sse2 #elif (XXH_VECTOR == XXH_NEON) #define XXH3_accumulate_512 XXH3_accumulate_512_neon +#define XXH3_accumulate XXH3_accumulate_neon #define XXH3_scrambleAcc XXH3_scrambleAcc_neon #define XXH3_initCustomSecret XXH3_initCustomSecret_scalar #elif (XXH_VECTOR == XXH_VSX) #define XXH3_accumulate_512 XXH3_accumulate_512_vsx +#define XXH3_accumulate XXH3_accumulate_vsx #define XXH3_scrambleAcc XXH3_scrambleAcc_vsx #define XXH3_initCustomSecret XXH3_initCustomSecret_scalar +#elif (XXH_VECTOR == XXH_SVE) +#define XXH3_accumulate_512 XXH3_accumulate_512_sve +#define XXH3_accumulate XXH3_accumulate_sve +#define XXH3_scrambleAcc XXH3_scrambleAcc_scalar +#define XXH3_initCustomSecret XXH3_initCustomSecret_scalar + #else /* scalar */ #define XXH3_accumulate_512 XXH3_accumulate_512_scalar +#define XXH3_accumulate XXH3_accumulate_scalar #define XXH3_scrambleAcc XXH3_scrambleAcc_scalar #define XXH3_initCustomSecret XXH3_initCustomSecret_scalar #endif - - -#ifndef XXH_PREFETCH_DIST -# ifdef __clang__ -# define XXH_PREFETCH_DIST 320 -# else -# if (XXH_VECTOR == XXH_AVX512) -# define XXH_PREFETCH_DIST 512 -# else -# define XXH_PREFETCH_DIST 384 -# endif -# endif /* __clang__ */ -#endif /* XXH_PREFETCH_DIST */ - -/* - * XXH3_accumulate() - * Loops over XXH3_accumulate_512(). - * Assumption: nbStripes will not overflow the secret size - */ -XXH_FORCE_INLINE void -XXH3_accumulate( xxh_u64* XXH_RESTRICT acc, - const xxh_u8* XXH_RESTRICT input, - const xxh_u8* XXH_RESTRICT secret, - size_t nbStripes, - XXH3_f_accumulate_512 f_acc512) -{ - size_t n; - for (n = 0; n < nbStripes; n++ ) { - const xxh_u8* const in = input + n*XXH_STRIPE_LEN; - XXH_PREFETCH(in + XXH_PREFETCH_DIST); - f_acc512(acc, - in, - secret + n*XXH_SECRET_CONSUME_RATE); - } -} +#if XXH_SIZE_OPT >= 1 /* don't do SIMD for initialization */ +# undef XXH3_initCustomSecret +# define XXH3_initCustomSecret XXH3_initCustomSecret_scalar +#endif XXH_FORCE_INLINE void XXH3_hashLong_internal_loop(xxh_u64* XXH_RESTRICT acc, const xxh_u8* XXH_RESTRICT input, size_t len, const xxh_u8* XXH_RESTRICT secret, size_t secretSize, - XXH3_f_accumulate_512 f_acc512, + XXH3_f_accumulate f_acc, XXH3_f_scrambleAcc f_scramble) { size_t const nbStripesPerBlock = (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; @@ -4418,7 +5541,7 @@ XXH3_hashLong_internal_loop(xxh_u64* XXH_RESTRICT acc, XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); for (n = 0; n < nb_blocks; n++) { - XXH3_accumulate(acc, input + n*block_len, secret, nbStripesPerBlock, f_acc512); + f_acc(acc, input + n*block_len, secret, nbStripesPerBlock); f_scramble(acc, secret + secretSize - XXH_STRIPE_LEN); } @@ -4426,12 +5549,12 @@ XXH3_hashLong_internal_loop(xxh_u64* XXH_RESTRICT acc, XXH_ASSERT(len > XXH_STRIPE_LEN); { size_t const nbStripes = ((len - 1) - (block_len * nb_blocks)) / XXH_STRIPE_LEN; XXH_ASSERT(nbStripes <= (secretSize / XXH_SECRET_CONSUME_RATE)); - XXH3_accumulate(acc, input + nb_blocks*block_len, secret, nbStripes, f_acc512); + f_acc(acc, input + nb_blocks*block_len, secret, nbStripes); /* last stripe */ { const xxh_u8* const p = input + len - XXH_STRIPE_LEN; #define XXH_SECRET_LASTACC_START 7 /* not aligned on 8, last secret is different from acc & scrambler */ - f_acc512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START); + XXH3_accumulate_512(acc, p, secret + secretSize - XXH_STRIPE_LEN - XXH_SECRET_LASTACC_START); } } } @@ -4476,12 +5599,12 @@ XXH3_mergeAccs(const xxh_u64* XXH_RESTRICT acc, const xxh_u8* XXH_RESTRICT secre XXH_FORCE_INLINE XXH64_hash_t XXH3_hashLong_64b_internal(const void* XXH_RESTRICT input, size_t len, const void* XXH_RESTRICT secret, size_t secretSize, - XXH3_f_accumulate_512 f_acc512, + XXH3_f_accumulate f_acc, XXH3_f_scrambleAcc f_scramble) { XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[XXH_ACC_NB] = XXH3_INIT_ACC; - XXH3_hashLong_internal_loop(acc, (const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, f_acc512, f_scramble); + XXH3_hashLong_internal_loop(acc, (const xxh_u8*)input, len, (const xxh_u8*)secret, secretSize, f_acc, f_scramble); /* converge into final hash */ XXH_STATIC_ASSERT(sizeof(acc) == 64); @@ -4495,13 +5618,15 @@ XXH3_hashLong_64b_internal(const void* XXH_RESTRICT input, size_t len, * It's important for performance to transmit secret's size (when it's static) * so that the compiler can properly optimize the vectorized loop. * This makes a big performance difference for "medium" keys (<1 KB) when using AVX instruction set. + * When the secret size is unknown, or on GCC 12 where the mix of NO_INLINE and FORCE_INLINE + * breaks -Og, this is XXH_NO_INLINE. */ XXH3_WITH_SECRET_INLINE XXH64_hash_t XXH3_hashLong_64b_withSecret(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed64, const xxh_u8* XXH_RESTRICT secret, size_t secretLen) { (void)seed64; - return XXH3_hashLong_64b_internal(input, len, secret, secretLen, XXH3_accumulate_512, XXH3_scrambleAcc); + return XXH3_hashLong_64b_internal(input, len, secret, secretLen, XXH3_accumulate, XXH3_scrambleAcc); } /* @@ -4510,12 +5635,12 @@ XXH3_hashLong_64b_withSecret(const void* XXH_RESTRICT input, size_t len, * Note that inside this no_inline function, we do inline the internal loop, * and provide a statically defined secret size to allow optimization of vector loop. */ -XXH_NO_INLINE XXH64_hash_t +XXH_NO_INLINE XXH_PUREF XXH64_hash_t XXH3_hashLong_64b_default(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed64, const xxh_u8* XXH_RESTRICT secret, size_t secretLen) { (void)seed64; (void)secret; (void)secretLen; - return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512, XXH3_scrambleAcc); + return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate, XXH3_scrambleAcc); } /* @@ -4532,18 +5657,20 @@ XXH3_hashLong_64b_default(const void* XXH_RESTRICT input, size_t len, XXH_FORCE_INLINE XXH64_hash_t XXH3_hashLong_64b_withSeed_internal(const void* input, size_t len, XXH64_hash_t seed, - XXH3_f_accumulate_512 f_acc512, + XXH3_f_accumulate f_acc, XXH3_f_scrambleAcc f_scramble, XXH3_f_initCustomSecret f_initSec) { +#if XXH_SIZE_OPT <= 0 if (seed == 0) return XXH3_hashLong_64b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), - f_acc512, f_scramble); + f_acc, f_scramble); +#endif { XXH_ALIGN(XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE]; f_initSec(secret, seed); return XXH3_hashLong_64b_internal(input, len, secret, sizeof(secret), - f_acc512, f_scramble); + f_acc, f_scramble); } } @@ -4551,12 +5678,12 @@ XXH3_hashLong_64b_withSeed_internal(const void* input, size_t len, * It's important for performance that XXH3_hashLong is not inlined. */ XXH_NO_INLINE XXH64_hash_t -XXH3_hashLong_64b_withSeed(const void* input, size_t len, - XXH64_hash_t seed, const xxh_u8* secret, size_t secretLen) +XXH3_hashLong_64b_withSeed(const void* XXH_RESTRICT input, size_t len, + XXH64_hash_t seed, const xxh_u8* XXH_RESTRICT secret, size_t secretLen) { (void)secret; (void)secretLen; return XXH3_hashLong_64b_withSeed_internal(input, len, seed, - XXH3_accumulate_512, XXH3_scrambleAcc, XXH3_initCustomSecret); + XXH3_accumulate, XXH3_scrambleAcc, XXH3_initCustomSecret); } @@ -4588,37 +5715,37 @@ XXH3_64bits_internal(const void* XXH_RESTRICT input, size_t len, /* === Public entry point === */ -/*! @ingroup xxh3_family */ -XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(const void* input, size_t len) +/*! @ingroup XXH3_family */ +XXH_PUBLIC_API XXH64_hash_t XXH3_64bits(XXH_NOESCAPE const void* input, size_t length) { - return XXH3_64bits_internal(input, len, 0, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_default); + return XXH3_64bits_internal(input, length, 0, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_default); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH64_hash_t -XXH3_64bits_withSecret(const void* input, size_t len, const void* secret, size_t secretSize) +XXH3_64bits_withSecret(XXH_NOESCAPE const void* input, size_t length, XXH_NOESCAPE const void* secret, size_t secretSize) { - return XXH3_64bits_internal(input, len, 0, secret, secretSize, XXH3_hashLong_64b_withSecret); + return XXH3_64bits_internal(input, length, 0, secret, secretSize, XXH3_hashLong_64b_withSecret); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH64_hash_t -XXH3_64bits_withSeed(const void* input, size_t len, XXH64_hash_t seed) +XXH3_64bits_withSeed(XXH_NOESCAPE const void* input, size_t length, XXH64_hash_t seed) { - return XXH3_64bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_withSeed); + return XXH3_64bits_internal(input, length, seed, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_64b_withSeed); } XXH_PUBLIC_API XXH64_hash_t -XXH3_64bits_withSecretandSeed(const void* input, size_t len, const void* secret, size_t secretSize, XXH64_hash_t seed) +XXH3_64bits_withSecretandSeed(XXH_NOESCAPE const void* input, size_t length, XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed) { - if (len <= XXH3_MIDSIZE_MAX) - return XXH3_64bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), NULL); - return XXH3_hashLong_64b_withSecret(input, len, seed, (const xxh_u8*)secret, secretSize); + if (length <= XXH3_MIDSIZE_MAX) + return XXH3_64bits_internal(input, length, seed, XXH3_kSecret, sizeof(XXH3_kSecret), NULL); + return XXH3_hashLong_64b_withSecret(input, length, seed, (const xxh_u8*)secret, secretSize); } /* === XXH3 streaming === */ - +#ifndef XXH_NO_STREAM /* * Malloc's a pointer that is always aligned to align. * @@ -4642,7 +5769,7 @@ XXH3_64bits_withSecretandSeed(const void* input, size_t len, const void* secret, * * Align must be a power of 2 and 8 <= align <= 128. */ -static void* XXH_alignedMalloc(size_t s, size_t align) +static XXH_MALLOCF void* XXH_alignedMalloc(size_t s, size_t align) { XXH_ASSERT(align <= 128 && align >= 8); /* range check */ XXH_ASSERT((align & (align-1)) == 0); /* power of 2 */ @@ -4684,7 +5811,13 @@ static void XXH_alignedFree(void* p) XXH_free(base); } } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ +/*! + * @brief Allocate an @ref XXH3_state_t. + * + * Must be freed with XXH3_freeState(). + * @return An allocated XXH3_state_t on success, `NULL` on failure. + */ XXH_PUBLIC_API XXH3_state_t* XXH3_createState(void) { XXH3_state_t* const state = (XXH3_state_t*)XXH_alignedMalloc(sizeof(XXH3_state_t), 64); @@ -4693,16 +5826,23 @@ XXH_PUBLIC_API XXH3_state_t* XXH3_createState(void) return state; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ +/*! + * @brief Frees an @ref XXH3_state_t. + * + * Must be allocated with XXH3_createState(). + * @param statePtr A pointer to an @ref XXH3_state_t allocated with @ref XXH3_createState(). + * @return XXH_OK. + */ XXH_PUBLIC_API XXH_errorcode XXH3_freeState(XXH3_state_t* statePtr) { XXH_alignedFree(statePtr); return XXH_OK; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API void -XXH3_copyState(XXH3_state_t* dst_state, const XXH3_state_t* src_state) +XXH3_copyState(XXH_NOESCAPE XXH3_state_t* dst_state, XXH_NOESCAPE const XXH3_state_t* src_state) { XXH_memcpy(dst_state, src_state, sizeof(*dst_state)); } @@ -4734,18 +5874,18 @@ XXH3_reset_internal(XXH3_state_t* statePtr, statePtr->nbStripesPerBlock = statePtr->secretLimit / XXH_SECRET_CONSUME_RATE; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_64bits_reset(XXH3_state_t* statePtr) +XXH3_64bits_reset(XXH_NOESCAPE XXH3_state_t* statePtr) { if (statePtr == NULL) return XXH_ERROR; XXH3_reset_internal(statePtr, 0, XXH3_kSecret, XXH_SECRET_DEFAULT_SIZE); return XXH_OK; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_64bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize) +XXH3_64bits_reset_withSecret(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize) { if (statePtr == NULL) return XXH_ERROR; XXH3_reset_internal(statePtr, 0, secret, secretSize); @@ -4754,9 +5894,9 @@ XXH3_64bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t return XXH_OK; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed) +XXH3_64bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed) { if (statePtr == NULL) return XXH_ERROR; if (seed==0) return XXH3_64bits_reset(statePtr); @@ -4766,9 +5906,9 @@ XXH3_64bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed) return XXH_OK; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_64bits_reset_withSecretandSeed(XXH3_state_t* statePtr, const void* secret, size_t secretSize, XXH64_hash_t seed64) +XXH3_64bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed64) { if (statePtr == NULL) return XXH_ERROR; if (secret == NULL) return XXH_ERROR; @@ -4778,35 +5918,61 @@ XXH3_64bits_reset_withSecretandSeed(XXH3_state_t* statePtr, const void* secret, return XXH_OK; } -/* Note : when XXH3_consumeStripes() is invoked, - * there must be a guarantee that at least one more byte must be consumed from input - * so that the function can blindly consume all stripes using the "normal" secret segment */ -XXH_FORCE_INLINE void +/*! + * @internal + * @brief Processes a large input for XXH3_update() and XXH3_digest_long(). + * + * Unlike XXH3_hashLong_internal_loop(), this can process data that overlaps a block. + * + * @param acc Pointer to the 8 accumulator lanes + * @param nbStripesSoFarPtr In/out pointer to the number of leftover stripes in the block* + * @param nbStripesPerBlock Number of stripes in a block + * @param input Input pointer + * @param nbStripes Number of stripes to process + * @param secret Secret pointer + * @param secretLimit Offset of the last block in @p secret + * @param f_acc Pointer to an XXH3_accumulate implementation + * @param f_scramble Pointer to an XXH3_scrambleAcc implementation + * @return Pointer past the end of @p input after processing + */ +XXH_FORCE_INLINE const xxh_u8 * XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc, size_t* XXH_RESTRICT nbStripesSoFarPtr, size_t nbStripesPerBlock, const xxh_u8* XXH_RESTRICT input, size_t nbStripes, const xxh_u8* XXH_RESTRICT secret, size_t secretLimit, - XXH3_f_accumulate_512 f_acc512, + XXH3_f_accumulate f_acc, XXH3_f_scrambleAcc f_scramble) { - XXH_ASSERT(nbStripes <= nbStripesPerBlock); /* can handle max 1 scramble per invocation */ - XXH_ASSERT(*nbStripesSoFarPtr < nbStripesPerBlock); - if (nbStripesPerBlock - *nbStripesSoFarPtr <= nbStripes) { - /* need a scrambling operation */ - size_t const nbStripesToEndofBlock = nbStripesPerBlock - *nbStripesSoFarPtr; - size_t const nbStripesAfterBlock = nbStripes - nbStripesToEndofBlock; - XXH3_accumulate(acc, input, secret + nbStripesSoFarPtr[0] * XXH_SECRET_CONSUME_RATE, nbStripesToEndofBlock, f_acc512); - f_scramble(acc, secret + secretLimit); - XXH3_accumulate(acc, input + nbStripesToEndofBlock * XXH_STRIPE_LEN, secret, nbStripesAfterBlock, f_acc512); - *nbStripesSoFarPtr = nbStripesAfterBlock; - } else { - XXH3_accumulate(acc, input, secret + nbStripesSoFarPtr[0] * XXH_SECRET_CONSUME_RATE, nbStripes, f_acc512); + const xxh_u8* initialSecret = secret + *nbStripesSoFarPtr * XXH_SECRET_CONSUME_RATE; + /* Process full blocks */ + if (nbStripes >= (nbStripesPerBlock - *nbStripesSoFarPtr)) { + /* Process the initial partial block... */ + size_t nbStripesThisIter = nbStripesPerBlock - *nbStripesSoFarPtr; + + do { + /* Accumulate and scramble */ + f_acc(acc, input, initialSecret, nbStripesThisIter); + f_scramble(acc, secret + secretLimit); + input += nbStripesThisIter * XXH_STRIPE_LEN; + nbStripes -= nbStripesThisIter; + /* Then continue the loop with the full block size */ + nbStripesThisIter = nbStripesPerBlock; + initialSecret = secret; + } while (nbStripes >= nbStripesPerBlock); + *nbStripesSoFarPtr = 0; + } + /* Process a partial block */ + if (nbStripes > 0) { + f_acc(acc, input, initialSecret, nbStripes); + input += nbStripes * XXH_STRIPE_LEN; *nbStripesSoFarPtr += nbStripes; } + /* Return end pointer */ + return input; } #ifndef XXH3_STREAM_USE_STACK -# ifndef __clang__ /* clang doesn't need additional stack space */ +# if XXH_SIZE_OPT <= 0 && !defined(__clang__) /* clang doesn't need additional stack space */ # define XXH3_STREAM_USE_STACK 1 # endif #endif @@ -4816,7 +5982,7 @@ XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc, XXH_FORCE_INLINE XXH_errorcode XXH3_update(XXH3_state_t* XXH_RESTRICT const state, const xxh_u8* XXH_RESTRICT input, size_t len, - XXH3_f_accumulate_512 f_acc512, + XXH3_f_accumulate f_acc, XXH3_f_scrambleAcc f_scramble) { if (input==NULL) { @@ -4832,7 +5998,8 @@ XXH3_update(XXH3_state_t* XXH_RESTRICT const state, * when operating accumulators directly into state. * Operating into stack space seems to enable proper optimization. * clang, on the other hand, doesn't seem to need this trick */ - XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[8]; memcpy(acc, state->acc, sizeof(acc)); + XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[8]; + XXH_memcpy(acc, state->acc, sizeof(acc)); #else xxh_u64* XXH_RESTRICT const acc = state->acc; #endif @@ -4840,7 +6007,7 @@ XXH3_update(XXH3_state_t* XXH_RESTRICT const state, XXH_ASSERT(state->bufferedSize <= XXH3_INTERNALBUFFER_SIZE); /* small input : just fill in tmp buffer */ - if (state->bufferedSize + len <= XXH3_INTERNALBUFFER_SIZE) { + if (len <= XXH3_INTERNALBUFFER_SIZE - state->bufferedSize) { XXH_memcpy(state->buffer + state->bufferedSize, input, len); state->bufferedSize += (XXH32_hash_t)len; return XXH_OK; @@ -4862,57 +6029,20 @@ XXH3_update(XXH3_state_t* XXH_RESTRICT const state, &state->nbStripesSoFar, state->nbStripesPerBlock, state->buffer, XXH3_INTERNALBUFFER_STRIPES, secret, state->secretLimit, - f_acc512, f_scramble); + f_acc, f_scramble); state->bufferedSize = 0; } XXH_ASSERT(input < bEnd); - - /* large input to consume : ingest per full block */ - if ((size_t)(bEnd - input) > state->nbStripesPerBlock * XXH_STRIPE_LEN) { + if (bEnd - input > XXH3_INTERNALBUFFER_SIZE) { size_t nbStripes = (size_t)(bEnd - 1 - input) / XXH_STRIPE_LEN; - XXH_ASSERT(state->nbStripesPerBlock >= state->nbStripesSoFar); - /* join to current block's end */ - { size_t const nbStripesToEnd = state->nbStripesPerBlock - state->nbStripesSoFar; - XXH_ASSERT(nbStripes <= nbStripes); - XXH3_accumulate(acc, input, secret + state->nbStripesSoFar * XXH_SECRET_CONSUME_RATE, nbStripesToEnd, f_acc512); - f_scramble(acc, secret + state->secretLimit); - state->nbStripesSoFar = 0; - input += nbStripesToEnd * XXH_STRIPE_LEN; - nbStripes -= nbStripesToEnd; - } - /* consume per entire blocks */ - while(nbStripes >= state->nbStripesPerBlock) { - XXH3_accumulate(acc, input, secret, state->nbStripesPerBlock, f_acc512); - f_scramble(acc, secret + state->secretLimit); - input += state->nbStripesPerBlock * XXH_STRIPE_LEN; - nbStripes -= state->nbStripesPerBlock; - } - /* consume last partial block */ - XXH3_accumulate(acc, input, secret, nbStripes, f_acc512); - input += nbStripes * XXH_STRIPE_LEN; - XXH_ASSERT(input < bEnd); /* at least some bytes left */ - state->nbStripesSoFar = nbStripes; - /* buffer predecessor of last partial stripe */ - XXH_memcpy(state->buffer + sizeof(state->buffer) - XXH_STRIPE_LEN, input - XXH_STRIPE_LEN, XXH_STRIPE_LEN); - XXH_ASSERT(bEnd - input <= XXH_STRIPE_LEN); - } else { - /* content to consume <= block size */ - /* Consume input by a multiple of internal buffer size */ - if (bEnd - input > XXH3_INTERNALBUFFER_SIZE) { - const xxh_u8* const limit = bEnd - XXH3_INTERNALBUFFER_SIZE; - do { - XXH3_consumeStripes(acc, + input = XXH3_consumeStripes(acc, &state->nbStripesSoFar, state->nbStripesPerBlock, - input, XXH3_INTERNALBUFFER_STRIPES, - secret, state->secretLimit, - f_acc512, f_scramble); - input += XXH3_INTERNALBUFFER_SIZE; - } while (inputbuffer + sizeof(state->buffer) - XXH_STRIPE_LEN, input - XXH_STRIPE_LEN, XXH_STRIPE_LEN); - } - } + input, nbStripes, + secret, state->secretLimit, + f_acc, f_scramble); + XXH_memcpy(state->buffer + sizeof(state->buffer) - XXH_STRIPE_LEN, input - XXH_STRIPE_LEN, XXH_STRIPE_LEN); + } /* Some remaining input (always) : buffer it */ XXH_ASSERT(input < bEnd); XXH_ASSERT(bEnd - input <= XXH3_INTERNALBUFFER_SIZE); @@ -4921,19 +6051,19 @@ XXH3_update(XXH3_state_t* XXH_RESTRICT const state, state->bufferedSize = (XXH32_hash_t)(bEnd-input); #if defined(XXH3_STREAM_USE_STACK) && XXH3_STREAM_USE_STACK >= 1 /* save stack accumulators into state */ - memcpy(state->acc, acc, sizeof(acc)); + XXH_memcpy(state->acc, acc, sizeof(acc)); #endif } return XXH_OK; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_64bits_update(XXH3_state_t* state, const void* input, size_t len) +XXH3_64bits_update(XXH_NOESCAPE XXH3_state_t* state, XXH_NOESCAPE const void* input, size_t len) { return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_accumulate_512, XXH3_scrambleAcc); + XXH3_accumulate, XXH3_scrambleAcc); } @@ -4942,37 +6072,40 @@ XXH3_digest_long (XXH64_hash_t* acc, const XXH3_state_t* state, const unsigned char* secret) { + xxh_u8 lastStripe[XXH_STRIPE_LEN]; + const xxh_u8* lastStripePtr; + /* * Digest on a local copy. This way, the state remains unaltered, and it can * continue ingesting more input afterwards. */ XXH_memcpy(acc, state->acc, sizeof(state->acc)); if (state->bufferedSize >= XXH_STRIPE_LEN) { + /* Consume remaining stripes then point to remaining data in buffer */ size_t const nbStripes = (state->bufferedSize - 1) / XXH_STRIPE_LEN; size_t nbStripesSoFar = state->nbStripesSoFar; XXH3_consumeStripes(acc, &nbStripesSoFar, state->nbStripesPerBlock, state->buffer, nbStripes, secret, state->secretLimit, - XXH3_accumulate_512, XXH3_scrambleAcc); - /* last stripe */ - XXH3_accumulate_512(acc, - state->buffer + state->bufferedSize - XXH_STRIPE_LEN, - secret + state->secretLimit - XXH_SECRET_LASTACC_START); + XXH3_accumulate, XXH3_scrambleAcc); + lastStripePtr = state->buffer + state->bufferedSize - XXH_STRIPE_LEN; } else { /* bufferedSize < XXH_STRIPE_LEN */ - xxh_u8 lastStripe[XXH_STRIPE_LEN]; + /* Copy to temp buffer */ size_t const catchupSize = XXH_STRIPE_LEN - state->bufferedSize; XXH_ASSERT(state->bufferedSize > 0); /* there is always some input buffered */ XXH_memcpy(lastStripe, state->buffer + sizeof(state->buffer) - catchupSize, catchupSize); XXH_memcpy(lastStripe + catchupSize, state->buffer, state->bufferedSize); - XXH3_accumulate_512(acc, - lastStripe, - secret + state->secretLimit - XXH_SECRET_LASTACC_START); + lastStripePtr = lastStripe; } + /* Last stripe */ + XXH3_accumulate_512(acc, + lastStripePtr, + secret + state->secretLimit - XXH_SECRET_LASTACC_START); } -/*! @ingroup xxh3_family */ -XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* state) +/*! @ingroup XXH3_family */ +XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (XXH_NOESCAPE const XXH3_state_t* state) { const unsigned char* const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret; if (state->totalLen > XXH3_MIDSIZE_MAX) { @@ -4988,7 +6121,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* state) return XXH3_64bits_withSecret(state->buffer, (size_t)(state->totalLen), secret, state->secretLimit + XXH_STRIPE_LEN); } - +#endif /* !XXH_NO_STREAM */ /* ========================================== @@ -5008,7 +6141,7 @@ XXH_PUBLIC_API XXH64_hash_t XXH3_64bits_digest (const XXH3_state_t* state) * fast for a _128-bit_ hash on 32-bit (it usually clears XXH64). */ -XXH_FORCE_INLINE XXH128_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t XXH3_len_1to3_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { /* A doubled version of 1to3_64b with different constants. */ @@ -5037,7 +6170,7 @@ XXH3_len_1to3_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_ } } -XXH_FORCE_INLINE XXH128_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t XXH3_len_4to8_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { XXH_ASSERT(input != NULL); @@ -5057,14 +6190,14 @@ XXH3_len_4to8_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_ m128.low64 ^= (m128.high64 >> 3); m128.low64 = XXH_xorshift64(m128.low64, 35); - m128.low64 *= 0x9FB21C651E98DF25ULL; + m128.low64 *= PRIME_MX2; m128.low64 = XXH_xorshift64(m128.low64, 28); m128.high64 = XXH3_avalanche(m128.high64); return m128; } } -XXH_FORCE_INLINE XXH128_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t XXH3_len_9to16_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { XXH_ASSERT(input != NULL); @@ -5139,7 +6272,7 @@ XXH3_len_9to16_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64 /* * Assumption: `secret` size is >= XXH3_SECRET_SIZE_MIN */ -XXH_FORCE_INLINE XXH128_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t XXH3_len_0to16_128b(const xxh_u8* input, size_t len, const xxh_u8* secret, XXH64_hash_t seed) { XXH_ASSERT(len <= 16); @@ -5170,7 +6303,7 @@ XXH128_mix32B(XXH128_hash_t acc, const xxh_u8* input_1, const xxh_u8* input_2, } -XXH_FORCE_INLINE XXH128_hash_t +XXH_FORCE_INLINE XXH_PUREF XXH128_hash_t XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len, const xxh_u8* XXH_RESTRICT secret, size_t secretSize, XXH64_hash_t seed) @@ -5181,6 +6314,16 @@ XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len, { XXH128_hash_t acc; acc.low64 = len * XXH_PRIME64_1; acc.high64 = 0; + +#if XXH_SIZE_OPT >= 1 + { + /* Smaller, but slightly slower. */ + unsigned int i = (unsigned int)(len - 1) / 32; + do { + acc = XXH128_mix32B(acc, input+16*i, input+len-16*(i+1), secret+32*i, seed); + } while (i-- != 0); + } +#else if (len > 32) { if (len > 64) { if (len > 96) { @@ -5191,6 +6334,7 @@ XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len, acc = XXH128_mix32B(acc, input+16, input+len-32, secret+32, seed); } acc = XXH128_mix32B(acc, input, input+len-16, secret, seed); +#endif { XXH128_hash_t h128; h128.low64 = acc.low64 + acc.high64; h128.high64 = (acc.low64 * XXH_PRIME64_1) @@ -5203,7 +6347,7 @@ XXH3_len_17to128_128b(const xxh_u8* XXH_RESTRICT input, size_t len, } } -XXH_NO_INLINE XXH128_hash_t +XXH_NO_INLINE XXH_PUREF XXH128_hash_t XXH3_len_129to240_128b(const xxh_u8* XXH_RESTRICT input, size_t len, const xxh_u8* XXH_RESTRICT secret, size_t secretSize, XXH64_hash_t seed) @@ -5212,25 +6356,34 @@ XXH3_len_129to240_128b(const xxh_u8* XXH_RESTRICT input, size_t len, XXH_ASSERT(128 < len && len <= XXH3_MIDSIZE_MAX); { XXH128_hash_t acc; - int const nbRounds = (int)len / 32; - int i; + unsigned i; acc.low64 = len * XXH_PRIME64_1; acc.high64 = 0; - for (i=0; i<4; i++) { + /* + * We set as `i` as offset + 32. We do this so that unchanged + * `len` can be used as upper bound. This reaches a sweet spot + * where both x86 and aarch64 get simple agen and good codegen + * for the loop. + */ + for (i = 32; i < 160; i += 32) { acc = XXH128_mix32B(acc, - input + (32 * i), - input + (32 * i) + 16, - secret + (32 * i), + input + i - 32, + input + i - 16, + secret + i - 32, seed); } acc.low64 = XXH3_avalanche(acc.low64); acc.high64 = XXH3_avalanche(acc.high64); - XXH_ASSERT(nbRounds >= 4); - for (i=4 ; i < nbRounds; i++) { + /* + * NB: `i <= len` will duplicate the last 32-bytes if + * len % 32 was zero. This is an unfortunate necessity to keep + * the hash result stable. + */ + for (i=160; i <= len; i += 32) { acc = XXH128_mix32B(acc, - input + (32 * i), - input + (32 * i) + 16, - secret + XXH3_MIDSIZE_STARTOFFSET + (32 * (i - 4)), + input + i - 32, + input + i - 16, + secret + XXH3_MIDSIZE_STARTOFFSET + i - 160, seed); } /* last bytes */ @@ -5238,7 +6391,7 @@ XXH3_len_129to240_128b(const xxh_u8* XXH_RESTRICT input, size_t len, input + len - 16, input + len - 32, secret + XXH3_SECRET_SIZE_MIN - XXH3_MIDSIZE_LASTOFFSET - 16, - 0ULL - seed); + (XXH64_hash_t)0 - seed); { XXH128_hash_t h128; h128.low64 = acc.low64 + acc.high64; @@ -5255,12 +6408,12 @@ XXH3_len_129to240_128b(const xxh_u8* XXH_RESTRICT input, size_t len, XXH_FORCE_INLINE XXH128_hash_t XXH3_hashLong_128b_internal(const void* XXH_RESTRICT input, size_t len, const xxh_u8* XXH_RESTRICT secret, size_t secretSize, - XXH3_f_accumulate_512 f_acc512, + XXH3_f_accumulate f_acc, XXH3_f_scrambleAcc f_scramble) { XXH_ALIGN(XXH_ACC_ALIGN) xxh_u64 acc[XXH_ACC_NB] = XXH3_INIT_ACC; - XXH3_hashLong_internal_loop(acc, (const xxh_u8*)input, len, secret, secretSize, f_acc512, f_scramble); + XXH3_hashLong_internal_loop(acc, (const xxh_u8*)input, len, secret, secretSize, f_acc, f_scramble); /* converge into final hash */ XXH_STATIC_ASSERT(sizeof(acc) == 64); @@ -5278,21 +6431,24 @@ XXH3_hashLong_128b_internal(const void* XXH_RESTRICT input, size_t len, } /* - * It's important for performance that XXH3_hashLong is not inlined. + * It's important for performance that XXH3_hashLong() is not inlined. */ -XXH_NO_INLINE XXH128_hash_t +XXH_NO_INLINE XXH_PUREF XXH128_hash_t XXH3_hashLong_128b_default(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed64, const void* XXH_RESTRICT secret, size_t secretLen) { (void)seed64; (void)secret; (void)secretLen; return XXH3_hashLong_128b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), - XXH3_accumulate_512, XXH3_scrambleAcc); + XXH3_accumulate, XXH3_scrambleAcc); } /* - * It's important for performance to pass @secretLen (when it's static) + * It's important for performance to pass @p secretLen (when it's static) * to the compiler, so that it can properly optimize the vectorized loop. + * + * When the secret size is unknown, or on GCC 12 where the mix of NO_INLINE and FORCE_INLINE + * breaks -Og, this is XXH_NO_INLINE. */ XXH3_WITH_SECRET_INLINE XXH128_hash_t XXH3_hashLong_128b_withSecret(const void* XXH_RESTRICT input, size_t len, @@ -5301,24 +6457,24 @@ XXH3_hashLong_128b_withSecret(const void* XXH_RESTRICT input, size_t len, { (void)seed64; return XXH3_hashLong_128b_internal(input, len, (const xxh_u8*)secret, secretLen, - XXH3_accumulate_512, XXH3_scrambleAcc); + XXH3_accumulate, XXH3_scrambleAcc); } XXH_FORCE_INLINE XXH128_hash_t XXH3_hashLong_128b_withSeed_internal(const void* XXH_RESTRICT input, size_t len, XXH64_hash_t seed64, - XXH3_f_accumulate_512 f_acc512, + XXH3_f_accumulate f_acc, XXH3_f_scrambleAcc f_scramble, XXH3_f_initCustomSecret f_initSec) { if (seed64 == 0) return XXH3_hashLong_128b_internal(input, len, XXH3_kSecret, sizeof(XXH3_kSecret), - f_acc512, f_scramble); + f_acc, f_scramble); { XXH_ALIGN(XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE]; f_initSec(secret, seed64); return XXH3_hashLong_128b_internal(input, len, (const xxh_u8*)secret, sizeof(secret), - f_acc512, f_scramble); + f_acc, f_scramble); } } @@ -5331,7 +6487,7 @@ XXH3_hashLong_128b_withSeed(const void* input, size_t len, { (void)secret; (void)secretLen; return XXH3_hashLong_128b_withSeed_internal(input, len, seed64, - XXH3_accumulate_512, XXH3_scrambleAcc, XXH3_initCustomSecret); + XXH3_accumulate, XXH3_scrambleAcc, XXH3_initCustomSecret); } typedef XXH128_hash_t (*XXH3_hashLong128_f)(const void* XXH_RESTRICT, size_t, @@ -5361,94 +6517,93 @@ XXH3_128bits_internal(const void* input, size_t len, /* === Public XXH128 API === */ -/*! @ingroup xxh3_family */ -XXH_PUBLIC_API XXH128_hash_t XXH3_128bits(const void* input, size_t len) +/*! @ingroup XXH3_family */ +XXH_PUBLIC_API XXH128_hash_t XXH3_128bits(XXH_NOESCAPE const void* input, size_t len) { return XXH3_128bits_internal(input, len, 0, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_128b_default); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH128_hash_t -XXH3_128bits_withSecret(const void* input, size_t len, const void* secret, size_t secretSize) +XXH3_128bits_withSecret(XXH_NOESCAPE const void* input, size_t len, XXH_NOESCAPE const void* secret, size_t secretSize) { return XXH3_128bits_internal(input, len, 0, (const xxh_u8*)secret, secretSize, XXH3_hashLong_128b_withSecret); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH128_hash_t -XXH3_128bits_withSeed(const void* input, size_t len, XXH64_hash_t seed) +XXH3_128bits_withSeed(XXH_NOESCAPE const void* input, size_t len, XXH64_hash_t seed) { return XXH3_128bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_hashLong_128b_withSeed); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH128_hash_t -XXH3_128bits_withSecretandSeed(const void* input, size_t len, const void* secret, size_t secretSize, XXH64_hash_t seed) +XXH3_128bits_withSecretandSeed(XXH_NOESCAPE const void* input, size_t len, XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed) { if (len <= XXH3_MIDSIZE_MAX) return XXH3_128bits_internal(input, len, seed, XXH3_kSecret, sizeof(XXH3_kSecret), NULL); return XXH3_hashLong_128b_withSecret(input, len, seed, secret, secretSize); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH128_hash_t -XXH128(const void* input, size_t len, XXH64_hash_t seed) +XXH128(XXH_NOESCAPE const void* input, size_t len, XXH64_hash_t seed) { return XXH3_128bits_withSeed(input, len, seed); } /* === XXH3 128-bit streaming === */ - +#ifndef XXH_NO_STREAM /* * All initialization and update functions are identical to 64-bit streaming variant. * The only difference is the finalization routine. */ -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_128bits_reset(XXH3_state_t* statePtr) +XXH3_128bits_reset(XXH_NOESCAPE XXH3_state_t* statePtr) { return XXH3_64bits_reset(statePtr); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_128bits_reset_withSecret(XXH3_state_t* statePtr, const void* secret, size_t secretSize) +XXH3_128bits_reset_withSecret(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize) { return XXH3_64bits_reset_withSecret(statePtr, secret, secretSize); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_128bits_reset_withSeed(XXH3_state_t* statePtr, XXH64_hash_t seed) +XXH3_128bits_reset_withSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH64_hash_t seed) { return XXH3_64bits_reset_withSeed(statePtr, seed); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_128bits_reset_withSecretandSeed(XXH3_state_t* statePtr, const void* secret, size_t secretSize, XXH64_hash_t seed) +XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NOESCAPE const void* secret, size_t secretSize, XXH64_hash_t seed) { return XXH3_64bits_reset_withSecretandSeed(statePtr, secret, secretSize, seed); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_128bits_update(XXH3_state_t* state, const void* input, size_t len) +XXH3_128bits_update(XXH_NOESCAPE XXH3_state_t* state, XXH_NOESCAPE const void* input, size_t len) { - return XXH3_update(state, (const xxh_u8*)input, len, - XXH3_accumulate_512, XXH3_scrambleAcc); + return XXH3_64bits_update(state, input, len); } -/*! @ingroup xxh3_family */ -XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state) +/*! @ingroup XXH3_family */ +XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (XXH_NOESCAPE const XXH3_state_t* state) { const unsigned char* const secret = (state->extSecret == NULL) ? state->customSecret : state->extSecret; if (state->totalLen > XXH3_MIDSIZE_MAX) { @@ -5472,13 +6627,13 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (const XXH3_state_t* state) return XXH3_128bits_withSecret(state->buffer, (size_t)(state->totalLen), secret, state->secretLimit + XXH_STRIPE_LEN); } - +#endif /* !XXH_NO_STREAM */ /* 128-bit utility functions */ #include /* memcmp, memcpy */ /* return : 1 is equal, 0 if different */ -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2) { /* note : XXH128_hash_t is compact, it has no padding byte */ @@ -5486,11 +6641,11 @@ XXH_PUBLIC_API int XXH128_isEqual(XXH128_hash_t h1, XXH128_hash_t h2) } /* This prototype is compatible with stdlib's qsort(). - * return : >0 if *h128_1 > *h128_2 - * <0 if *h128_1 < *h128_2 - * =0 if *h128_1 == *h128_2 */ -/*! @ingroup xxh3_family */ -XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2) + * @return : >0 if *h128_1 > *h128_2 + * <0 if *h128_1 < *h128_2 + * =0 if *h128_1 == *h128_2 */ +/*! @ingroup XXH3_family */ +XXH_PUBLIC_API int XXH128_cmp(XXH_NOESCAPE const void* h128_1, XXH_NOESCAPE const void* h128_2) { XXH128_hash_t const h1 = *(const XXH128_hash_t*)h128_1; XXH128_hash_t const h2 = *(const XXH128_hash_t*)h128_2; @@ -5502,9 +6657,9 @@ XXH_PUBLIC_API int XXH128_cmp(const void* h128_1, const void* h128_2) /*====== Canonical representation ======*/ -/*! @ingroup xxh3_family */ -static zend_always_inline void -XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash) +/*! @ingroup XXH3_family */ +XXH_PUBLIC_API void +XXH128_canonicalFromHash(XXH_NOESCAPE XXH128_canonical_t* dst, XXH128_hash_t hash) { XXH_STATIC_ASSERT(sizeof(XXH128_canonical_t) == sizeof(XXH128_hash_t)); if (XXH_CPU_LITTLE_ENDIAN) { @@ -5515,9 +6670,9 @@ XXH128_canonicalFromHash(XXH128_canonical_t* dst, XXH128_hash_t hash) XXH_memcpy((char*)dst + sizeof(hash.high64), &hash.low64, sizeof(hash.low64)); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH128_hash_t -XXH128_hashFromCanonical(const XXH128_canonical_t* src) +XXH128_hashFromCanonical(XXH_NOESCAPE const XXH128_canonical_t* src) { XXH128_hash_t h; h.high64 = XXH_readBE64(src); @@ -5533,26 +6688,34 @@ XXH128_hashFromCanonical(const XXH128_canonical_t* src) */ #define XXH_MIN(x, y) (((x) > (y)) ? (y) : (x)) -static void XXH3_combine16(void* dst, XXH128_hash_t h128) +XXH_FORCE_INLINE void XXH3_combine16(void* dst, XXH128_hash_t h128) { XXH_writeLE64( dst, XXH_readLE64(dst) ^ h128.low64 ); XXH_writeLE64( (char*)dst+8, XXH_readLE64((char*)dst+8) ^ h128.high64 ); } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API XXH_errorcode -XXH3_generateSecret(void* secretBuffer, size_t secretSize, const void* customSeed, size_t customSeedSize) +XXH3_generateSecret(XXH_NOESCAPE void* secretBuffer, size_t secretSize, XXH_NOESCAPE const void* customSeed, size_t customSeedSize) { +#if (XXH_DEBUGLEVEL >= 1) XXH_ASSERT(secretBuffer != NULL); - if (secretBuffer == NULL) return XXH_ERROR; XXH_ASSERT(secretSize >= XXH3_SECRET_SIZE_MIN); +#else + /* production mode, assert() are disabled */ + if (secretBuffer == NULL) return XXH_ERROR; if (secretSize < XXH3_SECRET_SIZE_MIN) return XXH_ERROR; +#endif + if (customSeedSize == 0) { customSeed = XXH3_kSecret; customSeedSize = XXH_SECRET_DEFAULT_SIZE; } +#if (XXH_DEBUGLEVEL >= 1) XXH_ASSERT(customSeed != NULL); +#else if (customSeed == NULL) return XXH_ERROR; +#endif /* Fill secretBuffer with a copy of customSeed - repeat as needed */ { size_t pos = 0; @@ -5576,9 +6739,9 @@ XXH3_generateSecret(void* secretBuffer, size_t secretSize, const void* customSee return XXH_OK; } -/*! @ingroup xxh3_family */ +/*! @ingroup XXH3_family */ XXH_PUBLIC_API void -XXH3_generateSecret_fromSeed(void* secretBuffer, XXH64_hash_t seed) +XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed) { XXH_ALIGN(XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE]; XXH3_initCustomSecret(secret, seed); @@ -5591,7 +6754,7 @@ XXH3_generateSecret_fromSeed(void* secretBuffer, XXH64_hash_t seed) /* Pop our optimization override from above */ #if XXH_VECTOR == XXH_AVX2 /* AVX2 */ \ && defined(__GNUC__) && !defined(__clang__) /* GCC, not Clang */ \ - && defined(__OPTIMIZE__) && !defined(__OPTIMIZE_SIZE__) /* respect -O0 and -Os */ + && defined(__OPTIMIZE__) && XXH_SIZE_OPT <= 0 /* respect -O0 and -Os */ # pragma GCC pop_options #endif @@ -5606,5 +6769,5 @@ XXH3_generateSecret_fromSeed(void* secretBuffer, XXH64_hash_t seed) #if defined (__cplusplus) -} +} /* extern "C" */ #endif diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index ef2573d54481c..7c812f5af44b4 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -1825,7 +1825,7 @@ PHP_FUNCTION(iconv_substr) size_t charset_len; zend_string *str; zend_long offset, length = 0; - bool len_is_null = 1; + bool len_is_null = true; php_iconv_err_t err; diff --git a/ext/intl/ERROR_CONVENTIONS.md b/ext/intl/ERROR_CONVENTIONS.md index af2450c8186a0..432862afd6855 100644 --- a/ext/intl/ERROR_CONVENTIONS.md +++ b/ext/intl/ERROR_CONVENTIONS.md @@ -75,7 +75,7 @@ and `intl_get_error_message()`. parsing errors), not `NULL`. Constructors and factory methods are the exception; these should return `NULL`, not `FALSE`. -Not that constructors in Intl generally (always?) don't throws exceptions. They +Note that constructors in Intl generally (always?) don't throws exceptions. They instead destroy the object to that the result of new `IntlClass()` can be `NULL`. This may be surprising. diff --git a/ext/intl/breakiterator/breakiterator_arginfo.h b/ext/intl/breakiterator/breakiterator_arginfo.h index 9475f5e987fc6..afaad17f03dbf 100644 --- a/ext/intl/breakiterator/breakiterator_arginfo.h +++ b/ext/intl/breakiterator/breakiterator_arginfo.h @@ -161,117 +161,117 @@ static zend_class_entry *register_class_IntlBreakIterator(zend_class_entry *clas zval const_DONE_value; ZVAL_LONG(&const_DONE_value, BreakIterator::DONE); - zend_string *const_DONE_name = zend_string_init_interned("DONE", sizeof("DONE") - 1, 1); + zend_string *const_DONE_name = zend_string_init_interned("DONE", sizeof("DONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DONE_name, &const_DONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DONE_name); + zend_string_release_ex(const_DONE_name, true); zval const_WORD_NONE_value; ZVAL_LONG(&const_WORD_NONE_value, UBRK_WORD_NONE); - zend_string *const_WORD_NONE_name = zend_string_init_interned("WORD_NONE", sizeof("WORD_NONE") - 1, 1); + zend_string *const_WORD_NONE_name = zend_string_init_interned("WORD_NONE", sizeof("WORD_NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_NONE_name, &const_WORD_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_NONE_name); + zend_string_release_ex(const_WORD_NONE_name, true); zval const_WORD_NONE_LIMIT_value; ZVAL_LONG(&const_WORD_NONE_LIMIT_value, UBRK_WORD_NONE_LIMIT); - zend_string *const_WORD_NONE_LIMIT_name = zend_string_init_interned("WORD_NONE_LIMIT", sizeof("WORD_NONE_LIMIT") - 1, 1); + zend_string *const_WORD_NONE_LIMIT_name = zend_string_init_interned("WORD_NONE_LIMIT", sizeof("WORD_NONE_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_NONE_LIMIT_name, &const_WORD_NONE_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_NONE_LIMIT_name); + zend_string_release_ex(const_WORD_NONE_LIMIT_name, true); zval const_WORD_NUMBER_value; ZVAL_LONG(&const_WORD_NUMBER_value, UBRK_WORD_NUMBER); - zend_string *const_WORD_NUMBER_name = zend_string_init_interned("WORD_NUMBER", sizeof("WORD_NUMBER") - 1, 1); + zend_string *const_WORD_NUMBER_name = zend_string_init_interned("WORD_NUMBER", sizeof("WORD_NUMBER") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_NUMBER_name, &const_WORD_NUMBER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_NUMBER_name); + zend_string_release_ex(const_WORD_NUMBER_name, true); zval const_WORD_NUMBER_LIMIT_value; ZVAL_LONG(&const_WORD_NUMBER_LIMIT_value, UBRK_WORD_NUMBER_LIMIT); - zend_string *const_WORD_NUMBER_LIMIT_name = zend_string_init_interned("WORD_NUMBER_LIMIT", sizeof("WORD_NUMBER_LIMIT") - 1, 1); + zend_string *const_WORD_NUMBER_LIMIT_name = zend_string_init_interned("WORD_NUMBER_LIMIT", sizeof("WORD_NUMBER_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_NUMBER_LIMIT_name, &const_WORD_NUMBER_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_NUMBER_LIMIT_name); + zend_string_release_ex(const_WORD_NUMBER_LIMIT_name, true); zval const_WORD_LETTER_value; ZVAL_LONG(&const_WORD_LETTER_value, UBRK_WORD_LETTER); - zend_string *const_WORD_LETTER_name = zend_string_init_interned("WORD_LETTER", sizeof("WORD_LETTER") - 1, 1); + zend_string *const_WORD_LETTER_name = zend_string_init_interned("WORD_LETTER", sizeof("WORD_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_LETTER_name, &const_WORD_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_LETTER_name); + zend_string_release_ex(const_WORD_LETTER_name, true); zval const_WORD_LETTER_LIMIT_value; ZVAL_LONG(&const_WORD_LETTER_LIMIT_value, UBRK_WORD_LETTER_LIMIT); - zend_string *const_WORD_LETTER_LIMIT_name = zend_string_init_interned("WORD_LETTER_LIMIT", sizeof("WORD_LETTER_LIMIT") - 1, 1); + zend_string *const_WORD_LETTER_LIMIT_name = zend_string_init_interned("WORD_LETTER_LIMIT", sizeof("WORD_LETTER_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_LETTER_LIMIT_name, &const_WORD_LETTER_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_LETTER_LIMIT_name); + zend_string_release_ex(const_WORD_LETTER_LIMIT_name, true); zval const_WORD_KANA_value; ZVAL_LONG(&const_WORD_KANA_value, UBRK_WORD_KANA); - zend_string *const_WORD_KANA_name = zend_string_init_interned("WORD_KANA", sizeof("WORD_KANA") - 1, 1); + zend_string *const_WORD_KANA_name = zend_string_init_interned("WORD_KANA", sizeof("WORD_KANA") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_KANA_name, &const_WORD_KANA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_KANA_name); + zend_string_release_ex(const_WORD_KANA_name, true); zval const_WORD_KANA_LIMIT_value; ZVAL_LONG(&const_WORD_KANA_LIMIT_value, UBRK_WORD_KANA_LIMIT); - zend_string *const_WORD_KANA_LIMIT_name = zend_string_init_interned("WORD_KANA_LIMIT", sizeof("WORD_KANA_LIMIT") - 1, 1); + zend_string *const_WORD_KANA_LIMIT_name = zend_string_init_interned("WORD_KANA_LIMIT", sizeof("WORD_KANA_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_KANA_LIMIT_name, &const_WORD_KANA_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_KANA_LIMIT_name); + zend_string_release_ex(const_WORD_KANA_LIMIT_name, true); zval const_WORD_IDEO_value; ZVAL_LONG(&const_WORD_IDEO_value, UBRK_WORD_IDEO); - zend_string *const_WORD_IDEO_name = zend_string_init_interned("WORD_IDEO", sizeof("WORD_IDEO") - 1, 1); + zend_string *const_WORD_IDEO_name = zend_string_init_interned("WORD_IDEO", sizeof("WORD_IDEO") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_IDEO_name, &const_WORD_IDEO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_IDEO_name); + zend_string_release_ex(const_WORD_IDEO_name, true); zval const_WORD_IDEO_LIMIT_value; ZVAL_LONG(&const_WORD_IDEO_LIMIT_value, UBRK_WORD_IDEO_LIMIT); - zend_string *const_WORD_IDEO_LIMIT_name = zend_string_init_interned("WORD_IDEO_LIMIT", sizeof("WORD_IDEO_LIMIT") - 1, 1); + zend_string *const_WORD_IDEO_LIMIT_name = zend_string_init_interned("WORD_IDEO_LIMIT", sizeof("WORD_IDEO_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WORD_IDEO_LIMIT_name, &const_WORD_IDEO_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WORD_IDEO_LIMIT_name); + zend_string_release_ex(const_WORD_IDEO_LIMIT_name, true); zval const_LINE_SOFT_value; ZVAL_LONG(&const_LINE_SOFT_value, UBRK_LINE_SOFT); - zend_string *const_LINE_SOFT_name = zend_string_init_interned("LINE_SOFT", sizeof("LINE_SOFT") - 1, 1); + zend_string *const_LINE_SOFT_name = zend_string_init_interned("LINE_SOFT", sizeof("LINE_SOFT") - 1, true); zend_declare_typed_class_constant(class_entry, const_LINE_SOFT_name, &const_LINE_SOFT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LINE_SOFT_name); + zend_string_release_ex(const_LINE_SOFT_name, true); zval const_LINE_SOFT_LIMIT_value; ZVAL_LONG(&const_LINE_SOFT_LIMIT_value, UBRK_LINE_SOFT_LIMIT); - zend_string *const_LINE_SOFT_LIMIT_name = zend_string_init_interned("LINE_SOFT_LIMIT", sizeof("LINE_SOFT_LIMIT") - 1, 1); + zend_string *const_LINE_SOFT_LIMIT_name = zend_string_init_interned("LINE_SOFT_LIMIT", sizeof("LINE_SOFT_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_LINE_SOFT_LIMIT_name, &const_LINE_SOFT_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LINE_SOFT_LIMIT_name); + zend_string_release_ex(const_LINE_SOFT_LIMIT_name, true); zval const_LINE_HARD_value; ZVAL_LONG(&const_LINE_HARD_value, UBRK_LINE_HARD); - zend_string *const_LINE_HARD_name = zend_string_init_interned("LINE_HARD", sizeof("LINE_HARD") - 1, 1); + zend_string *const_LINE_HARD_name = zend_string_init_interned("LINE_HARD", sizeof("LINE_HARD") - 1, true); zend_declare_typed_class_constant(class_entry, const_LINE_HARD_name, &const_LINE_HARD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LINE_HARD_name); + zend_string_release_ex(const_LINE_HARD_name, true); zval const_LINE_HARD_LIMIT_value; ZVAL_LONG(&const_LINE_HARD_LIMIT_value, UBRK_LINE_HARD_LIMIT); - zend_string *const_LINE_HARD_LIMIT_name = zend_string_init_interned("LINE_HARD_LIMIT", sizeof("LINE_HARD_LIMIT") - 1, 1); + zend_string *const_LINE_HARD_LIMIT_name = zend_string_init_interned("LINE_HARD_LIMIT", sizeof("LINE_HARD_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_LINE_HARD_LIMIT_name, &const_LINE_HARD_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LINE_HARD_LIMIT_name); + zend_string_release_ex(const_LINE_HARD_LIMIT_name, true); zval const_SENTENCE_TERM_value; ZVAL_LONG(&const_SENTENCE_TERM_value, UBRK_SENTENCE_TERM); - zend_string *const_SENTENCE_TERM_name = zend_string_init_interned("SENTENCE_TERM", sizeof("SENTENCE_TERM") - 1, 1); + zend_string *const_SENTENCE_TERM_name = zend_string_init_interned("SENTENCE_TERM", sizeof("SENTENCE_TERM") - 1, true); zend_declare_typed_class_constant(class_entry, const_SENTENCE_TERM_name, &const_SENTENCE_TERM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SENTENCE_TERM_name); + zend_string_release_ex(const_SENTENCE_TERM_name, true); zval const_SENTENCE_TERM_LIMIT_value; ZVAL_LONG(&const_SENTENCE_TERM_LIMIT_value, UBRK_SENTENCE_TERM_LIMIT); - zend_string *const_SENTENCE_TERM_LIMIT_name = zend_string_init_interned("SENTENCE_TERM_LIMIT", sizeof("SENTENCE_TERM_LIMIT") - 1, 1); + zend_string *const_SENTENCE_TERM_LIMIT_name = zend_string_init_interned("SENTENCE_TERM_LIMIT", sizeof("SENTENCE_TERM_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SENTENCE_TERM_LIMIT_name, &const_SENTENCE_TERM_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SENTENCE_TERM_LIMIT_name); + zend_string_release_ex(const_SENTENCE_TERM_LIMIT_name, true); zval const_SENTENCE_SEP_value; ZVAL_LONG(&const_SENTENCE_SEP_value, UBRK_SENTENCE_SEP); - zend_string *const_SENTENCE_SEP_name = zend_string_init_interned("SENTENCE_SEP", sizeof("SENTENCE_SEP") - 1, 1); + zend_string *const_SENTENCE_SEP_name = zend_string_init_interned("SENTENCE_SEP", sizeof("SENTENCE_SEP") - 1, true); zend_declare_typed_class_constant(class_entry, const_SENTENCE_SEP_name, &const_SENTENCE_SEP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SENTENCE_SEP_name); + zend_string_release_ex(const_SENTENCE_SEP_name, true); zval const_SENTENCE_SEP_LIMIT_value; ZVAL_LONG(&const_SENTENCE_SEP_LIMIT_value, UBRK_SENTENCE_SEP_LIMIT); - zend_string *const_SENTENCE_SEP_LIMIT_name = zend_string_init_interned("SENTENCE_SEP_LIMIT", sizeof("SENTENCE_SEP_LIMIT") - 1, 1); + zend_string *const_SENTENCE_SEP_LIMIT_name = zend_string_init_interned("SENTENCE_SEP_LIMIT", sizeof("SENTENCE_SEP_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SENTENCE_SEP_LIMIT_name, &const_SENTENCE_SEP_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SENTENCE_SEP_LIMIT_name); + zend_string_release_ex(const_SENTENCE_SEP_LIMIT_name, true); return class_entry; } diff --git a/ext/intl/breakiterator/breakiterator_iterators_arginfo.h b/ext/intl/breakiterator/breakiterator_iterators_arginfo.h index f83c0accf6bf4..f4d0975a897f8 100644 --- a/ext/intl/breakiterator/breakiterator_iterators_arginfo.h +++ b/ext/intl/breakiterator/breakiterator_iterators_arginfo.h @@ -25,21 +25,21 @@ static zend_class_entry *register_class_IntlPartsIterator(zend_class_entry *clas zval const_KEY_SEQUENTIAL_value; ZVAL_LONG(&const_KEY_SEQUENTIAL_value, PARTS_ITERATOR_KEY_SEQUENTIAL); - zend_string *const_KEY_SEQUENTIAL_name = zend_string_init_interned("KEY_SEQUENTIAL", sizeof("KEY_SEQUENTIAL") - 1, 1); + zend_string *const_KEY_SEQUENTIAL_name = zend_string_init_interned("KEY_SEQUENTIAL", sizeof("KEY_SEQUENTIAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_KEY_SEQUENTIAL_name, &const_KEY_SEQUENTIAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_KEY_SEQUENTIAL_name); + zend_string_release_ex(const_KEY_SEQUENTIAL_name, true); zval const_KEY_LEFT_value; ZVAL_LONG(&const_KEY_LEFT_value, PARTS_ITERATOR_KEY_LEFT); - zend_string *const_KEY_LEFT_name = zend_string_init_interned("KEY_LEFT", sizeof("KEY_LEFT") - 1, 1); + zend_string *const_KEY_LEFT_name = zend_string_init_interned("KEY_LEFT", sizeof("KEY_LEFT") - 1, true); zend_declare_typed_class_constant(class_entry, const_KEY_LEFT_name, &const_KEY_LEFT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_KEY_LEFT_name); + zend_string_release_ex(const_KEY_LEFT_name, true); zval const_KEY_RIGHT_value; ZVAL_LONG(&const_KEY_RIGHT_value, PARTS_ITERATOR_KEY_RIGHT); - zend_string *const_KEY_RIGHT_name = zend_string_init_interned("KEY_RIGHT", sizeof("KEY_RIGHT") - 1, 1); + zend_string *const_KEY_RIGHT_name = zend_string_init_interned("KEY_RIGHT", sizeof("KEY_RIGHT") - 1, true); zend_declare_typed_class_constant(class_entry, const_KEY_RIGHT_name, &const_KEY_RIGHT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_KEY_RIGHT_name); + zend_string_release_ex(const_KEY_RIGHT_name, true); return class_entry; } diff --git a/ext/intl/calendar/calendar_arginfo.h b/ext/intl/calendar/calendar_arginfo.h index 415113b613a2e..f9c5a018d9a8c 100644 --- a/ext/intl/calendar/calendar_arginfo.h +++ b/ext/intl/calendar/calendar_arginfo.h @@ -329,237 +329,237 @@ static zend_class_entry *register_class_IntlCalendar(void) zval const_FIELD_ERA_value; ZVAL_LONG(&const_FIELD_ERA_value, UCAL_ERA); - zend_string *const_FIELD_ERA_name = zend_string_init_interned("FIELD_ERA", sizeof("FIELD_ERA") - 1, 1); + zend_string *const_FIELD_ERA_name = zend_string_init_interned("FIELD_ERA", sizeof("FIELD_ERA") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_ERA_name, &const_FIELD_ERA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_ERA_name); + zend_string_release_ex(const_FIELD_ERA_name, true); zval const_FIELD_YEAR_value; ZVAL_LONG(&const_FIELD_YEAR_value, UCAL_YEAR); - zend_string *const_FIELD_YEAR_name = zend_string_init_interned("FIELD_YEAR", sizeof("FIELD_YEAR") - 1, 1); + zend_string *const_FIELD_YEAR_name = zend_string_init_interned("FIELD_YEAR", sizeof("FIELD_YEAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_YEAR_name, &const_FIELD_YEAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_YEAR_name); + zend_string_release_ex(const_FIELD_YEAR_name, true); zval const_FIELD_MONTH_value; ZVAL_LONG(&const_FIELD_MONTH_value, UCAL_MONTH); - zend_string *const_FIELD_MONTH_name = zend_string_init_interned("FIELD_MONTH", sizeof("FIELD_MONTH") - 1, 1); + zend_string *const_FIELD_MONTH_name = zend_string_init_interned("FIELD_MONTH", sizeof("FIELD_MONTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_MONTH_name, &const_FIELD_MONTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_MONTH_name); + zend_string_release_ex(const_FIELD_MONTH_name, true); zval const_FIELD_WEEK_OF_YEAR_value; ZVAL_LONG(&const_FIELD_WEEK_OF_YEAR_value, UCAL_WEEK_OF_YEAR); - zend_string *const_FIELD_WEEK_OF_YEAR_name = zend_string_init_interned("FIELD_WEEK_OF_YEAR", sizeof("FIELD_WEEK_OF_YEAR") - 1, 1); + zend_string *const_FIELD_WEEK_OF_YEAR_name = zend_string_init_interned("FIELD_WEEK_OF_YEAR", sizeof("FIELD_WEEK_OF_YEAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_WEEK_OF_YEAR_name, &const_FIELD_WEEK_OF_YEAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_WEEK_OF_YEAR_name); + zend_string_release_ex(const_FIELD_WEEK_OF_YEAR_name, true); zval const_FIELD_WEEK_OF_MONTH_value; ZVAL_LONG(&const_FIELD_WEEK_OF_MONTH_value, UCAL_WEEK_OF_MONTH); - zend_string *const_FIELD_WEEK_OF_MONTH_name = zend_string_init_interned("FIELD_WEEK_OF_MONTH", sizeof("FIELD_WEEK_OF_MONTH") - 1, 1); + zend_string *const_FIELD_WEEK_OF_MONTH_name = zend_string_init_interned("FIELD_WEEK_OF_MONTH", sizeof("FIELD_WEEK_OF_MONTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_WEEK_OF_MONTH_name, &const_FIELD_WEEK_OF_MONTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_WEEK_OF_MONTH_name); + zend_string_release_ex(const_FIELD_WEEK_OF_MONTH_name, true); zval const_FIELD_DATE_value; ZVAL_LONG(&const_FIELD_DATE_value, UCAL_DATE); - zend_string *const_FIELD_DATE_name = zend_string_init_interned("FIELD_DATE", sizeof("FIELD_DATE") - 1, 1); + zend_string *const_FIELD_DATE_name = zend_string_init_interned("FIELD_DATE", sizeof("FIELD_DATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_DATE_name, &const_FIELD_DATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_DATE_name); + zend_string_release_ex(const_FIELD_DATE_name, true); zval const_FIELD_DAY_OF_YEAR_value; ZVAL_LONG(&const_FIELD_DAY_OF_YEAR_value, UCAL_DAY_OF_YEAR); - zend_string *const_FIELD_DAY_OF_YEAR_name = zend_string_init_interned("FIELD_DAY_OF_YEAR", sizeof("FIELD_DAY_OF_YEAR") - 1, 1); + zend_string *const_FIELD_DAY_OF_YEAR_name = zend_string_init_interned("FIELD_DAY_OF_YEAR", sizeof("FIELD_DAY_OF_YEAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_DAY_OF_YEAR_name, &const_FIELD_DAY_OF_YEAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_DAY_OF_YEAR_name); + zend_string_release_ex(const_FIELD_DAY_OF_YEAR_name, true); zval const_FIELD_DAY_OF_WEEK_value; ZVAL_LONG(&const_FIELD_DAY_OF_WEEK_value, UCAL_DAY_OF_WEEK); - zend_string *const_FIELD_DAY_OF_WEEK_name = zend_string_init_interned("FIELD_DAY_OF_WEEK", sizeof("FIELD_DAY_OF_WEEK") - 1, 1); + zend_string *const_FIELD_DAY_OF_WEEK_name = zend_string_init_interned("FIELD_DAY_OF_WEEK", sizeof("FIELD_DAY_OF_WEEK") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_DAY_OF_WEEK_name, &const_FIELD_DAY_OF_WEEK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_DAY_OF_WEEK_name); + zend_string_release_ex(const_FIELD_DAY_OF_WEEK_name, true); zval const_FIELD_DAY_OF_WEEK_IN_MONTH_value; ZVAL_LONG(&const_FIELD_DAY_OF_WEEK_IN_MONTH_value, UCAL_DAY_OF_WEEK_IN_MONTH); - zend_string *const_FIELD_DAY_OF_WEEK_IN_MONTH_name = zend_string_init_interned("FIELD_DAY_OF_WEEK_IN_MONTH", sizeof("FIELD_DAY_OF_WEEK_IN_MONTH") - 1, 1); + zend_string *const_FIELD_DAY_OF_WEEK_IN_MONTH_name = zend_string_init_interned("FIELD_DAY_OF_WEEK_IN_MONTH", sizeof("FIELD_DAY_OF_WEEK_IN_MONTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_DAY_OF_WEEK_IN_MONTH_name, &const_FIELD_DAY_OF_WEEK_IN_MONTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_DAY_OF_WEEK_IN_MONTH_name); + zend_string_release_ex(const_FIELD_DAY_OF_WEEK_IN_MONTH_name, true); zval const_FIELD_AM_PM_value; ZVAL_LONG(&const_FIELD_AM_PM_value, UCAL_AM_PM); - zend_string *const_FIELD_AM_PM_name = zend_string_init_interned("FIELD_AM_PM", sizeof("FIELD_AM_PM") - 1, 1); + zend_string *const_FIELD_AM_PM_name = zend_string_init_interned("FIELD_AM_PM", sizeof("FIELD_AM_PM") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_AM_PM_name, &const_FIELD_AM_PM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_AM_PM_name); + zend_string_release_ex(const_FIELD_AM_PM_name, true); zval const_FIELD_HOUR_value; ZVAL_LONG(&const_FIELD_HOUR_value, UCAL_HOUR); - zend_string *const_FIELD_HOUR_name = zend_string_init_interned("FIELD_HOUR", sizeof("FIELD_HOUR") - 1, 1); + zend_string *const_FIELD_HOUR_name = zend_string_init_interned("FIELD_HOUR", sizeof("FIELD_HOUR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_HOUR_name, &const_FIELD_HOUR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_HOUR_name); + zend_string_release_ex(const_FIELD_HOUR_name, true); zval const_FIELD_HOUR_OF_DAY_value; ZVAL_LONG(&const_FIELD_HOUR_OF_DAY_value, UCAL_HOUR_OF_DAY); - zend_string *const_FIELD_HOUR_OF_DAY_name = zend_string_init_interned("FIELD_HOUR_OF_DAY", sizeof("FIELD_HOUR_OF_DAY") - 1, 1); + zend_string *const_FIELD_HOUR_OF_DAY_name = zend_string_init_interned("FIELD_HOUR_OF_DAY", sizeof("FIELD_HOUR_OF_DAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_HOUR_OF_DAY_name, &const_FIELD_HOUR_OF_DAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_HOUR_OF_DAY_name); + zend_string_release_ex(const_FIELD_HOUR_OF_DAY_name, true); zval const_FIELD_MINUTE_value; ZVAL_LONG(&const_FIELD_MINUTE_value, UCAL_MINUTE); - zend_string *const_FIELD_MINUTE_name = zend_string_init_interned("FIELD_MINUTE", sizeof("FIELD_MINUTE") - 1, 1); + zend_string *const_FIELD_MINUTE_name = zend_string_init_interned("FIELD_MINUTE", sizeof("FIELD_MINUTE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_MINUTE_name, &const_FIELD_MINUTE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_MINUTE_name); + zend_string_release_ex(const_FIELD_MINUTE_name, true); zval const_FIELD_SECOND_value; ZVAL_LONG(&const_FIELD_SECOND_value, UCAL_SECOND); - zend_string *const_FIELD_SECOND_name = zend_string_init_interned("FIELD_SECOND", sizeof("FIELD_SECOND") - 1, 1); + zend_string *const_FIELD_SECOND_name = zend_string_init_interned("FIELD_SECOND", sizeof("FIELD_SECOND") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_SECOND_name, &const_FIELD_SECOND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_SECOND_name); + zend_string_release_ex(const_FIELD_SECOND_name, true); zval const_FIELD_MILLISECOND_value; ZVAL_LONG(&const_FIELD_MILLISECOND_value, UCAL_MILLISECOND); - zend_string *const_FIELD_MILLISECOND_name = zend_string_init_interned("FIELD_MILLISECOND", sizeof("FIELD_MILLISECOND") - 1, 1); + zend_string *const_FIELD_MILLISECOND_name = zend_string_init_interned("FIELD_MILLISECOND", sizeof("FIELD_MILLISECOND") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_MILLISECOND_name, &const_FIELD_MILLISECOND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_MILLISECOND_name); + zend_string_release_ex(const_FIELD_MILLISECOND_name, true); zval const_FIELD_ZONE_OFFSET_value; ZVAL_LONG(&const_FIELD_ZONE_OFFSET_value, UCAL_ZONE_OFFSET); - zend_string *const_FIELD_ZONE_OFFSET_name = zend_string_init_interned("FIELD_ZONE_OFFSET", sizeof("FIELD_ZONE_OFFSET") - 1, 1); + zend_string *const_FIELD_ZONE_OFFSET_name = zend_string_init_interned("FIELD_ZONE_OFFSET", sizeof("FIELD_ZONE_OFFSET") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_ZONE_OFFSET_name, &const_FIELD_ZONE_OFFSET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_ZONE_OFFSET_name); + zend_string_release_ex(const_FIELD_ZONE_OFFSET_name, true); zval const_FIELD_DST_OFFSET_value; ZVAL_LONG(&const_FIELD_DST_OFFSET_value, UCAL_DST_OFFSET); - zend_string *const_FIELD_DST_OFFSET_name = zend_string_init_interned("FIELD_DST_OFFSET", sizeof("FIELD_DST_OFFSET") - 1, 1); + zend_string *const_FIELD_DST_OFFSET_name = zend_string_init_interned("FIELD_DST_OFFSET", sizeof("FIELD_DST_OFFSET") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_DST_OFFSET_name, &const_FIELD_DST_OFFSET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_DST_OFFSET_name); + zend_string_release_ex(const_FIELD_DST_OFFSET_name, true); zval const_FIELD_YEAR_WOY_value; ZVAL_LONG(&const_FIELD_YEAR_WOY_value, UCAL_YEAR_WOY); - zend_string *const_FIELD_YEAR_WOY_name = zend_string_init_interned("FIELD_YEAR_WOY", sizeof("FIELD_YEAR_WOY") - 1, 1); + zend_string *const_FIELD_YEAR_WOY_name = zend_string_init_interned("FIELD_YEAR_WOY", sizeof("FIELD_YEAR_WOY") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_YEAR_WOY_name, &const_FIELD_YEAR_WOY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_YEAR_WOY_name); + zend_string_release_ex(const_FIELD_YEAR_WOY_name, true); zval const_FIELD_DOW_LOCAL_value; ZVAL_LONG(&const_FIELD_DOW_LOCAL_value, UCAL_DOW_LOCAL); - zend_string *const_FIELD_DOW_LOCAL_name = zend_string_init_interned("FIELD_DOW_LOCAL", sizeof("FIELD_DOW_LOCAL") - 1, 1); + zend_string *const_FIELD_DOW_LOCAL_name = zend_string_init_interned("FIELD_DOW_LOCAL", sizeof("FIELD_DOW_LOCAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_DOW_LOCAL_name, &const_FIELD_DOW_LOCAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_DOW_LOCAL_name); + zend_string_release_ex(const_FIELD_DOW_LOCAL_name, true); zval const_FIELD_EXTENDED_YEAR_value; ZVAL_LONG(&const_FIELD_EXTENDED_YEAR_value, UCAL_EXTENDED_YEAR); - zend_string *const_FIELD_EXTENDED_YEAR_name = zend_string_init_interned("FIELD_EXTENDED_YEAR", sizeof("FIELD_EXTENDED_YEAR") - 1, 1); + zend_string *const_FIELD_EXTENDED_YEAR_name = zend_string_init_interned("FIELD_EXTENDED_YEAR", sizeof("FIELD_EXTENDED_YEAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_EXTENDED_YEAR_name, &const_FIELD_EXTENDED_YEAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_EXTENDED_YEAR_name); + zend_string_release_ex(const_FIELD_EXTENDED_YEAR_name, true); zval const_FIELD_JULIAN_DAY_value; ZVAL_LONG(&const_FIELD_JULIAN_DAY_value, UCAL_JULIAN_DAY); - zend_string *const_FIELD_JULIAN_DAY_name = zend_string_init_interned("FIELD_JULIAN_DAY", sizeof("FIELD_JULIAN_DAY") - 1, 1); + zend_string *const_FIELD_JULIAN_DAY_name = zend_string_init_interned("FIELD_JULIAN_DAY", sizeof("FIELD_JULIAN_DAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_JULIAN_DAY_name, &const_FIELD_JULIAN_DAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_JULIAN_DAY_name); + zend_string_release_ex(const_FIELD_JULIAN_DAY_name, true); zval const_FIELD_MILLISECONDS_IN_DAY_value; ZVAL_LONG(&const_FIELD_MILLISECONDS_IN_DAY_value, UCAL_MILLISECONDS_IN_DAY); - zend_string *const_FIELD_MILLISECONDS_IN_DAY_name = zend_string_init_interned("FIELD_MILLISECONDS_IN_DAY", sizeof("FIELD_MILLISECONDS_IN_DAY") - 1, 1); + zend_string *const_FIELD_MILLISECONDS_IN_DAY_name = zend_string_init_interned("FIELD_MILLISECONDS_IN_DAY", sizeof("FIELD_MILLISECONDS_IN_DAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_MILLISECONDS_IN_DAY_name, &const_FIELD_MILLISECONDS_IN_DAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_MILLISECONDS_IN_DAY_name); + zend_string_release_ex(const_FIELD_MILLISECONDS_IN_DAY_name, true); zval const_FIELD_IS_LEAP_MONTH_value; ZVAL_LONG(&const_FIELD_IS_LEAP_MONTH_value, UCAL_IS_LEAP_MONTH); - zend_string *const_FIELD_IS_LEAP_MONTH_name = zend_string_init_interned("FIELD_IS_LEAP_MONTH", sizeof("FIELD_IS_LEAP_MONTH") - 1, 1); + zend_string *const_FIELD_IS_LEAP_MONTH_name = zend_string_init_interned("FIELD_IS_LEAP_MONTH", sizeof("FIELD_IS_LEAP_MONTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_IS_LEAP_MONTH_name, &const_FIELD_IS_LEAP_MONTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_IS_LEAP_MONTH_name); + zend_string_release_ex(const_FIELD_IS_LEAP_MONTH_name, true); zval const_FIELD_FIELD_COUNT_value; ZVAL_LONG(&const_FIELD_FIELD_COUNT_value, UCAL_FIELD_COUNT); - zend_string *const_FIELD_FIELD_COUNT_name = zend_string_init_interned("FIELD_FIELD_COUNT", sizeof("FIELD_FIELD_COUNT") - 1, 1); + zend_string *const_FIELD_FIELD_COUNT_name = zend_string_init_interned("FIELD_FIELD_COUNT", sizeof("FIELD_FIELD_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_FIELD_COUNT_name, &const_FIELD_FIELD_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_FIELD_COUNT_name); + zend_string_release_ex(const_FIELD_FIELD_COUNT_name, true); zval const_FIELD_DAY_OF_MONTH_value; ZVAL_LONG(&const_FIELD_DAY_OF_MONTH_value, UCAL_DAY_OF_MONTH); - zend_string *const_FIELD_DAY_OF_MONTH_name = zend_string_init_interned("FIELD_DAY_OF_MONTH", sizeof("FIELD_DAY_OF_MONTH") - 1, 1); + zend_string *const_FIELD_DAY_OF_MONTH_name = zend_string_init_interned("FIELD_DAY_OF_MONTH", sizeof("FIELD_DAY_OF_MONTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_FIELD_DAY_OF_MONTH_name, &const_FIELD_DAY_OF_MONTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FIELD_DAY_OF_MONTH_name); + zend_string_release_ex(const_FIELD_DAY_OF_MONTH_name, true); zval const_DOW_SUNDAY_value; ZVAL_LONG(&const_DOW_SUNDAY_value, UCAL_SUNDAY); - zend_string *const_DOW_SUNDAY_name = zend_string_init_interned("DOW_SUNDAY", sizeof("DOW_SUNDAY") - 1, 1); + zend_string *const_DOW_SUNDAY_name = zend_string_init_interned("DOW_SUNDAY", sizeof("DOW_SUNDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_SUNDAY_name, &const_DOW_SUNDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_SUNDAY_name); + zend_string_release_ex(const_DOW_SUNDAY_name, true); zval const_DOW_MONDAY_value; ZVAL_LONG(&const_DOW_MONDAY_value, UCAL_MONDAY); - zend_string *const_DOW_MONDAY_name = zend_string_init_interned("DOW_MONDAY", sizeof("DOW_MONDAY") - 1, 1); + zend_string *const_DOW_MONDAY_name = zend_string_init_interned("DOW_MONDAY", sizeof("DOW_MONDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_MONDAY_name, &const_DOW_MONDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_MONDAY_name); + zend_string_release_ex(const_DOW_MONDAY_name, true); zval const_DOW_TUESDAY_value; ZVAL_LONG(&const_DOW_TUESDAY_value, UCAL_TUESDAY); - zend_string *const_DOW_TUESDAY_name = zend_string_init_interned("DOW_TUESDAY", sizeof("DOW_TUESDAY") - 1, 1); + zend_string *const_DOW_TUESDAY_name = zend_string_init_interned("DOW_TUESDAY", sizeof("DOW_TUESDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_TUESDAY_name, &const_DOW_TUESDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_TUESDAY_name); + zend_string_release_ex(const_DOW_TUESDAY_name, true); zval const_DOW_WEDNESDAY_value; ZVAL_LONG(&const_DOW_WEDNESDAY_value, UCAL_WEDNESDAY); - zend_string *const_DOW_WEDNESDAY_name = zend_string_init_interned("DOW_WEDNESDAY", sizeof("DOW_WEDNESDAY") - 1, 1); + zend_string *const_DOW_WEDNESDAY_name = zend_string_init_interned("DOW_WEDNESDAY", sizeof("DOW_WEDNESDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_WEDNESDAY_name, &const_DOW_WEDNESDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_WEDNESDAY_name); + zend_string_release_ex(const_DOW_WEDNESDAY_name, true); zval const_DOW_THURSDAY_value; ZVAL_LONG(&const_DOW_THURSDAY_value, UCAL_THURSDAY); - zend_string *const_DOW_THURSDAY_name = zend_string_init_interned("DOW_THURSDAY", sizeof("DOW_THURSDAY") - 1, 1); + zend_string *const_DOW_THURSDAY_name = zend_string_init_interned("DOW_THURSDAY", sizeof("DOW_THURSDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_THURSDAY_name, &const_DOW_THURSDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_THURSDAY_name); + zend_string_release_ex(const_DOW_THURSDAY_name, true); zval const_DOW_FRIDAY_value; ZVAL_LONG(&const_DOW_FRIDAY_value, UCAL_FRIDAY); - zend_string *const_DOW_FRIDAY_name = zend_string_init_interned("DOW_FRIDAY", sizeof("DOW_FRIDAY") - 1, 1); + zend_string *const_DOW_FRIDAY_name = zend_string_init_interned("DOW_FRIDAY", sizeof("DOW_FRIDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_FRIDAY_name, &const_DOW_FRIDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_FRIDAY_name); + zend_string_release_ex(const_DOW_FRIDAY_name, true); zval const_DOW_SATURDAY_value; ZVAL_LONG(&const_DOW_SATURDAY_value, UCAL_SATURDAY); - zend_string *const_DOW_SATURDAY_name = zend_string_init_interned("DOW_SATURDAY", sizeof("DOW_SATURDAY") - 1, 1); + zend_string *const_DOW_SATURDAY_name = zend_string_init_interned("DOW_SATURDAY", sizeof("DOW_SATURDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_SATURDAY_name, &const_DOW_SATURDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_SATURDAY_name); + zend_string_release_ex(const_DOW_SATURDAY_name, true); zval const_DOW_TYPE_WEEKDAY_value; ZVAL_LONG(&const_DOW_TYPE_WEEKDAY_value, UCAL_WEEKDAY); - zend_string *const_DOW_TYPE_WEEKDAY_name = zend_string_init_interned("DOW_TYPE_WEEKDAY", sizeof("DOW_TYPE_WEEKDAY") - 1, 1); + zend_string *const_DOW_TYPE_WEEKDAY_name = zend_string_init_interned("DOW_TYPE_WEEKDAY", sizeof("DOW_TYPE_WEEKDAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_TYPE_WEEKDAY_name, &const_DOW_TYPE_WEEKDAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_TYPE_WEEKDAY_name); + zend_string_release_ex(const_DOW_TYPE_WEEKDAY_name, true); zval const_DOW_TYPE_WEEKEND_value; ZVAL_LONG(&const_DOW_TYPE_WEEKEND_value, UCAL_WEEKEND); - zend_string *const_DOW_TYPE_WEEKEND_name = zend_string_init_interned("DOW_TYPE_WEEKEND", sizeof("DOW_TYPE_WEEKEND") - 1, 1); + zend_string *const_DOW_TYPE_WEEKEND_name = zend_string_init_interned("DOW_TYPE_WEEKEND", sizeof("DOW_TYPE_WEEKEND") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_TYPE_WEEKEND_name, &const_DOW_TYPE_WEEKEND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_TYPE_WEEKEND_name); + zend_string_release_ex(const_DOW_TYPE_WEEKEND_name, true); zval const_DOW_TYPE_WEEKEND_OFFSET_value; ZVAL_LONG(&const_DOW_TYPE_WEEKEND_OFFSET_value, UCAL_WEEKEND_ONSET); - zend_string *const_DOW_TYPE_WEEKEND_OFFSET_name = zend_string_init_interned("DOW_TYPE_WEEKEND_OFFSET", sizeof("DOW_TYPE_WEEKEND_OFFSET") - 1, 1); + zend_string *const_DOW_TYPE_WEEKEND_OFFSET_name = zend_string_init_interned("DOW_TYPE_WEEKEND_OFFSET", sizeof("DOW_TYPE_WEEKEND_OFFSET") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_TYPE_WEEKEND_OFFSET_name, &const_DOW_TYPE_WEEKEND_OFFSET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_TYPE_WEEKEND_OFFSET_name); + zend_string_release_ex(const_DOW_TYPE_WEEKEND_OFFSET_name, true); zval const_DOW_TYPE_WEEKEND_CEASE_value; ZVAL_LONG(&const_DOW_TYPE_WEEKEND_CEASE_value, UCAL_WEEKEND_CEASE); - zend_string *const_DOW_TYPE_WEEKEND_CEASE_name = zend_string_init_interned("DOW_TYPE_WEEKEND_CEASE", sizeof("DOW_TYPE_WEEKEND_CEASE") - 1, 1); + zend_string *const_DOW_TYPE_WEEKEND_CEASE_name = zend_string_init_interned("DOW_TYPE_WEEKEND_CEASE", sizeof("DOW_TYPE_WEEKEND_CEASE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOW_TYPE_WEEKEND_CEASE_name, &const_DOW_TYPE_WEEKEND_CEASE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOW_TYPE_WEEKEND_CEASE_name); + zend_string_release_ex(const_DOW_TYPE_WEEKEND_CEASE_name, true); zval const_WALLTIME_FIRST_value; ZVAL_LONG(&const_WALLTIME_FIRST_value, UCAL_WALLTIME_FIRST); - zend_string *const_WALLTIME_FIRST_name = zend_string_init_interned("WALLTIME_FIRST", sizeof("WALLTIME_FIRST") - 1, 1); + zend_string *const_WALLTIME_FIRST_name = zend_string_init_interned("WALLTIME_FIRST", sizeof("WALLTIME_FIRST") - 1, true); zend_declare_typed_class_constant(class_entry, const_WALLTIME_FIRST_name, &const_WALLTIME_FIRST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WALLTIME_FIRST_name); + zend_string_release_ex(const_WALLTIME_FIRST_name, true); zval const_WALLTIME_LAST_value; ZVAL_LONG(&const_WALLTIME_LAST_value, UCAL_WALLTIME_LAST); - zend_string *const_WALLTIME_LAST_name = zend_string_init_interned("WALLTIME_LAST", sizeof("WALLTIME_LAST") - 1, 1); + zend_string *const_WALLTIME_LAST_name = zend_string_init_interned("WALLTIME_LAST", sizeof("WALLTIME_LAST") - 1, true); zend_declare_typed_class_constant(class_entry, const_WALLTIME_LAST_name, &const_WALLTIME_LAST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WALLTIME_LAST_name); + zend_string_release_ex(const_WALLTIME_LAST_name, true); zval const_WALLTIME_NEXT_VALID_value; ZVAL_LONG(&const_WALLTIME_NEXT_VALID_value, UCAL_WALLTIME_NEXT_VALID); - zend_string *const_WALLTIME_NEXT_VALID_name = zend_string_init_interned("WALLTIME_NEXT_VALID", sizeof("WALLTIME_NEXT_VALID") - 1, 1); + zend_string *const_WALLTIME_NEXT_VALID_name = zend_string_init_interned("WALLTIME_NEXT_VALID", sizeof("WALLTIME_NEXT_VALID") - 1, true); zend_declare_typed_class_constant(class_entry, const_WALLTIME_NEXT_VALID_name, &const_WALLTIME_NEXT_VALID_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WALLTIME_NEXT_VALID_name); + zend_string_release_ex(const_WALLTIME_NEXT_VALID_name, true); return class_entry; } diff --git a/ext/intl/collator/collator_arginfo.h b/ext/intl/collator/collator_arginfo.h index 3f469b02facd4..a35adbd3d1e05 100644 --- a/ext/intl/collator/collator_arginfo.h +++ b/ext/intl/collator/collator_arginfo.h @@ -103,147 +103,147 @@ static zend_class_entry *register_class_Collator(void) zval const_DEFAULT_VALUE_value; ZVAL_LONG(&const_DEFAULT_VALUE_value, UCOL_DEFAULT); - zend_string *const_DEFAULT_VALUE_name = zend_string_init_interned("DEFAULT_VALUE", sizeof("DEFAULT_VALUE") - 1, 1); + zend_string *const_DEFAULT_VALUE_name = zend_string_init_interned("DEFAULT_VALUE", sizeof("DEFAULT_VALUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DEFAULT_VALUE_name, &const_DEFAULT_VALUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DEFAULT_VALUE_name); + zend_string_release_ex(const_DEFAULT_VALUE_name, true); zval const_PRIMARY_value; ZVAL_LONG(&const_PRIMARY_value, UCOL_PRIMARY); - zend_string *const_PRIMARY_name = zend_string_init_interned("PRIMARY", sizeof("PRIMARY") - 1, 1); + zend_string *const_PRIMARY_name = zend_string_init_interned("PRIMARY", sizeof("PRIMARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_PRIMARY_name, &const_PRIMARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PRIMARY_name); + zend_string_release_ex(const_PRIMARY_name, true); zval const_SECONDARY_value; ZVAL_LONG(&const_SECONDARY_value, UCOL_SECONDARY); - zend_string *const_SECONDARY_name = zend_string_init_interned("SECONDARY", sizeof("SECONDARY") - 1, 1); + zend_string *const_SECONDARY_name = zend_string_init_interned("SECONDARY", sizeof("SECONDARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_SECONDARY_name, &const_SECONDARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SECONDARY_name); + zend_string_release_ex(const_SECONDARY_name, true); zval const_TERTIARY_value; ZVAL_LONG(&const_TERTIARY_value, UCOL_TERTIARY); - zend_string *const_TERTIARY_name = zend_string_init_interned("TERTIARY", sizeof("TERTIARY") - 1, 1); + zend_string *const_TERTIARY_name = zend_string_init_interned("TERTIARY", sizeof("TERTIARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_TERTIARY_name, &const_TERTIARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TERTIARY_name); + zend_string_release_ex(const_TERTIARY_name, true); zval const_DEFAULT_STRENGTH_value; ZVAL_LONG(&const_DEFAULT_STRENGTH_value, UCOL_DEFAULT_STRENGTH); - zend_string *const_DEFAULT_STRENGTH_name = zend_string_init_interned("DEFAULT_STRENGTH", sizeof("DEFAULT_STRENGTH") - 1, 1); + zend_string *const_DEFAULT_STRENGTH_name = zend_string_init_interned("DEFAULT_STRENGTH", sizeof("DEFAULT_STRENGTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_DEFAULT_STRENGTH_name, &const_DEFAULT_STRENGTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DEFAULT_STRENGTH_name); + zend_string_release_ex(const_DEFAULT_STRENGTH_name, true); zval const_QUATERNARY_value; ZVAL_LONG(&const_QUATERNARY_value, UCOL_QUATERNARY); - zend_string *const_QUATERNARY_name = zend_string_init_interned("QUATERNARY", sizeof("QUATERNARY") - 1, 1); + zend_string *const_QUATERNARY_name = zend_string_init_interned("QUATERNARY", sizeof("QUATERNARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_QUATERNARY_name, &const_QUATERNARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_QUATERNARY_name); + zend_string_release_ex(const_QUATERNARY_name, true); zval const_IDENTICAL_value; ZVAL_LONG(&const_IDENTICAL_value, UCOL_IDENTICAL); - zend_string *const_IDENTICAL_name = zend_string_init_interned("IDENTICAL", sizeof("IDENTICAL") - 1, 1); + zend_string *const_IDENTICAL_name = zend_string_init_interned("IDENTICAL", sizeof("IDENTICAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_IDENTICAL_name, &const_IDENTICAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IDENTICAL_name); + zend_string_release_ex(const_IDENTICAL_name, true); zval const_OFF_value; ZVAL_LONG(&const_OFF_value, UCOL_OFF); - zend_string *const_OFF_name = zend_string_init_interned("OFF", sizeof("OFF") - 1, 1); + zend_string *const_OFF_name = zend_string_init_interned("OFF", sizeof("OFF") - 1, true); zend_declare_typed_class_constant(class_entry, const_OFF_name, &const_OFF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OFF_name); + zend_string_release_ex(const_OFF_name, true); zval const_ON_value; ZVAL_LONG(&const_ON_value, UCOL_ON); - zend_string *const_ON_name = zend_string_init_interned("ON", sizeof("ON") - 1, 1); + zend_string *const_ON_name = zend_string_init_interned("ON", sizeof("ON") - 1, true); zend_declare_typed_class_constant(class_entry, const_ON_name, &const_ON_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ON_name); + zend_string_release_ex(const_ON_name, true); zval const_SHIFTED_value; ZVAL_LONG(&const_SHIFTED_value, UCOL_SHIFTED); - zend_string *const_SHIFTED_name = zend_string_init_interned("SHIFTED", sizeof("SHIFTED") - 1, 1); + zend_string *const_SHIFTED_name = zend_string_init_interned("SHIFTED", sizeof("SHIFTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_SHIFTED_name, &const_SHIFTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SHIFTED_name); + zend_string_release_ex(const_SHIFTED_name, true); zval const_NON_IGNORABLE_value; ZVAL_LONG(&const_NON_IGNORABLE_value, UCOL_NON_IGNORABLE); - zend_string *const_NON_IGNORABLE_name = zend_string_init_interned("NON_IGNORABLE", sizeof("NON_IGNORABLE") - 1, 1); + zend_string *const_NON_IGNORABLE_name = zend_string_init_interned("NON_IGNORABLE", sizeof("NON_IGNORABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_NON_IGNORABLE_name, &const_NON_IGNORABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NON_IGNORABLE_name); + zend_string_release_ex(const_NON_IGNORABLE_name, true); zval const_LOWER_FIRST_value; ZVAL_LONG(&const_LOWER_FIRST_value, UCOL_LOWER_FIRST); - zend_string *const_LOWER_FIRST_name = zend_string_init_interned("LOWER_FIRST", sizeof("LOWER_FIRST") - 1, 1); + zend_string *const_LOWER_FIRST_name = zend_string_init_interned("LOWER_FIRST", sizeof("LOWER_FIRST") - 1, true); zend_declare_typed_class_constant(class_entry, const_LOWER_FIRST_name, &const_LOWER_FIRST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LOWER_FIRST_name); + zend_string_release_ex(const_LOWER_FIRST_name, true); zval const_UPPER_FIRST_value; ZVAL_LONG(&const_UPPER_FIRST_value, UCOL_UPPER_FIRST); - zend_string *const_UPPER_FIRST_name = zend_string_init_interned("UPPER_FIRST", sizeof("UPPER_FIRST") - 1, 1); + zend_string *const_UPPER_FIRST_name = zend_string_init_interned("UPPER_FIRST", sizeof("UPPER_FIRST") - 1, true); zend_declare_typed_class_constant(class_entry, const_UPPER_FIRST_name, &const_UPPER_FIRST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UPPER_FIRST_name); + zend_string_release_ex(const_UPPER_FIRST_name, true); zval const_FRENCH_COLLATION_value; ZVAL_LONG(&const_FRENCH_COLLATION_value, UCOL_FRENCH_COLLATION); - zend_string *const_FRENCH_COLLATION_name = zend_string_init_interned("FRENCH_COLLATION", sizeof("FRENCH_COLLATION") - 1, 1); + zend_string *const_FRENCH_COLLATION_name = zend_string_init_interned("FRENCH_COLLATION", sizeof("FRENCH_COLLATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_FRENCH_COLLATION_name, &const_FRENCH_COLLATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FRENCH_COLLATION_name); + zend_string_release_ex(const_FRENCH_COLLATION_name, true); zval const_ALTERNATE_HANDLING_value; ZVAL_LONG(&const_ALTERNATE_HANDLING_value, UCOL_ALTERNATE_HANDLING); - zend_string *const_ALTERNATE_HANDLING_name = zend_string_init_interned("ALTERNATE_HANDLING", sizeof("ALTERNATE_HANDLING") - 1, 1); + zend_string *const_ALTERNATE_HANDLING_name = zend_string_init_interned("ALTERNATE_HANDLING", sizeof("ALTERNATE_HANDLING") - 1, true); zend_declare_typed_class_constant(class_entry, const_ALTERNATE_HANDLING_name, &const_ALTERNATE_HANDLING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ALTERNATE_HANDLING_name); + zend_string_release_ex(const_ALTERNATE_HANDLING_name, true); zval const_CASE_FIRST_value; ZVAL_LONG(&const_CASE_FIRST_value, UCOL_CASE_FIRST); - zend_string *const_CASE_FIRST_name = zend_string_init_interned("CASE_FIRST", sizeof("CASE_FIRST") - 1, 1); + zend_string *const_CASE_FIRST_name = zend_string_init_interned("CASE_FIRST", sizeof("CASE_FIRST") - 1, true); zend_declare_typed_class_constant(class_entry, const_CASE_FIRST_name, &const_CASE_FIRST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CASE_FIRST_name); + zend_string_release_ex(const_CASE_FIRST_name, true); zval const_CASE_LEVEL_value; ZVAL_LONG(&const_CASE_LEVEL_value, UCOL_CASE_LEVEL); - zend_string *const_CASE_LEVEL_name = zend_string_init_interned("CASE_LEVEL", sizeof("CASE_LEVEL") - 1, 1); + zend_string *const_CASE_LEVEL_name = zend_string_init_interned("CASE_LEVEL", sizeof("CASE_LEVEL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CASE_LEVEL_name, &const_CASE_LEVEL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CASE_LEVEL_name); + zend_string_release_ex(const_CASE_LEVEL_name, true); zval const_NORMALIZATION_MODE_value; ZVAL_LONG(&const_NORMALIZATION_MODE_value, UCOL_NORMALIZATION_MODE); - zend_string *const_NORMALIZATION_MODE_name = zend_string_init_interned("NORMALIZATION_MODE", sizeof("NORMALIZATION_MODE") - 1, 1); + zend_string *const_NORMALIZATION_MODE_name = zend_string_init_interned("NORMALIZATION_MODE", sizeof("NORMALIZATION_MODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_NORMALIZATION_MODE_name, &const_NORMALIZATION_MODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NORMALIZATION_MODE_name); + zend_string_release_ex(const_NORMALIZATION_MODE_name, true); zval const_STRENGTH_value; ZVAL_LONG(&const_STRENGTH_value, UCOL_STRENGTH); - zend_string *const_STRENGTH_name = zend_string_init_interned("STRENGTH", sizeof("STRENGTH") - 1, 1); + zend_string *const_STRENGTH_name = zend_string_init_interned("STRENGTH", sizeof("STRENGTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_STRENGTH_name, &const_STRENGTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_STRENGTH_name); + zend_string_release_ex(const_STRENGTH_name, true); zval const_HIRAGANA_QUATERNARY_MODE_value; ZVAL_LONG(&const_HIRAGANA_QUATERNARY_MODE_value, UCOL_HIRAGANA_QUATERNARY_MODE); - zend_string *const_HIRAGANA_QUATERNARY_MODE_name = zend_string_init_interned("HIRAGANA_QUATERNARY_MODE", sizeof("HIRAGANA_QUATERNARY_MODE") - 1, 1); + zend_string *const_HIRAGANA_QUATERNARY_MODE_name = zend_string_init_interned("HIRAGANA_QUATERNARY_MODE", sizeof("HIRAGANA_QUATERNARY_MODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_HIRAGANA_QUATERNARY_MODE_name, &const_HIRAGANA_QUATERNARY_MODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HIRAGANA_QUATERNARY_MODE_name); + zend_string_release_ex(const_HIRAGANA_QUATERNARY_MODE_name, true); zval const_NUMERIC_COLLATION_value; ZVAL_LONG(&const_NUMERIC_COLLATION_value, UCOL_NUMERIC_COLLATION); - zend_string *const_NUMERIC_COLLATION_name = zend_string_init_interned("NUMERIC_COLLATION", sizeof("NUMERIC_COLLATION") - 1, 1); + zend_string *const_NUMERIC_COLLATION_name = zend_string_init_interned("NUMERIC_COLLATION", sizeof("NUMERIC_COLLATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_NUMERIC_COLLATION_name, &const_NUMERIC_COLLATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NUMERIC_COLLATION_name); + zend_string_release_ex(const_NUMERIC_COLLATION_name, true); zval const_SORT_REGULAR_value; ZVAL_LONG(&const_SORT_REGULAR_value, COLLATOR_SORT_REGULAR); - zend_string *const_SORT_REGULAR_name = zend_string_init_interned("SORT_REGULAR", sizeof("SORT_REGULAR") - 1, 1); + zend_string *const_SORT_REGULAR_name = zend_string_init_interned("SORT_REGULAR", sizeof("SORT_REGULAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_SORT_REGULAR_name, &const_SORT_REGULAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SORT_REGULAR_name); + zend_string_release_ex(const_SORT_REGULAR_name, true); zval const_SORT_STRING_value; ZVAL_LONG(&const_SORT_STRING_value, COLLATOR_SORT_STRING); - zend_string *const_SORT_STRING_name = zend_string_init_interned("SORT_STRING", sizeof("SORT_STRING") - 1, 1); + zend_string *const_SORT_STRING_name = zend_string_init_interned("SORT_STRING", sizeof("SORT_STRING") - 1, true); zend_declare_typed_class_constant(class_entry, const_SORT_STRING_name, &const_SORT_STRING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SORT_STRING_name); + zend_string_release_ex(const_SORT_STRING_name, true); zval const_SORT_NUMERIC_value; ZVAL_LONG(&const_SORT_NUMERIC_value, COLLATOR_SORT_NUMERIC); - zend_string *const_SORT_NUMERIC_name = zend_string_init_interned("SORT_NUMERIC", sizeof("SORT_NUMERIC") - 1, 1); + zend_string *const_SORT_NUMERIC_name = zend_string_init_interned("SORT_NUMERIC", sizeof("SORT_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_SORT_NUMERIC_name, &const_SORT_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SORT_NUMERIC_name); + zend_string_release_ex(const_SORT_NUMERIC_name, true); return class_entry; } diff --git a/ext/intl/collator/collator_attr.c b/ext/intl/collator/collator_attr.cpp similarity index 81% rename from ext/intl/collator/collator_attr.c rename to ext/intl/collator/collator_attr.cpp index f16ae0cc5285d..f56596deb6b0e 100644 --- a/ext/intl/collator/collator_attr.c +++ b/ext/intl/collator/collator_attr.cpp @@ -17,14 +17,21 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" +} #include "collator_class.h" #include "collator_convert.h" #include /* {{{ Get collation attribute value. */ -PHP_FUNCTION( collator_get_attribute ) +U_CFUNC PHP_FUNCTION( collator_get_attribute ) { zend_long attribute, value; @@ -40,7 +47,7 @@ PHP_FUNCTION( collator_get_attribute ) /* Fetch the object. */ COLLATOR_METHOD_FETCH_OBJECT; - value = ucol_getAttribute( co->ucoll, attribute, COLLATOR_ERROR_CODE_P( co ) ); + value = ucol_getAttribute( co->ucoll, static_cast(attribute), COLLATOR_ERROR_CODE_P( co ) ); COLLATOR_CHECK_STATUS( co, "Error getting attribute value" ); RETURN_LONG( value ); @@ -48,7 +55,7 @@ PHP_FUNCTION( collator_get_attribute ) /* }}} */ /* {{{ Set collation attribute. */ -PHP_FUNCTION( collator_set_attribute ) +U_CFUNC PHP_FUNCTION( collator_set_attribute ) { zend_long attribute, value; COLLATOR_METHOD_INIT_VARS @@ -65,7 +72,7 @@ PHP_FUNCTION( collator_set_attribute ) COLLATOR_METHOD_FETCH_OBJECT; /* Set new value for the given attribute. */ - ucol_setAttribute( co->ucoll, attribute, value, COLLATOR_ERROR_CODE_P( co ) ); + ucol_setAttribute( co->ucoll, static_cast(attribute), static_cast(value), COLLATOR_ERROR_CODE_P( co ) ); COLLATOR_CHECK_STATUS( co, "Error setting attribute value" ); RETURN_TRUE; @@ -73,7 +80,7 @@ PHP_FUNCTION( collator_set_attribute ) /* }}} */ /* {{{ Returns the current collation strength. */ -PHP_FUNCTION( collator_get_strength ) +U_CFUNC PHP_FUNCTION( collator_get_strength ) { COLLATOR_METHOD_INIT_VARS @@ -93,7 +100,7 @@ PHP_FUNCTION( collator_get_strength ) /* }}} */ /* {{{ Set the collation strength. */ -PHP_FUNCTION( collator_set_strength ) +U_CFUNC PHP_FUNCTION( collator_set_strength ) { zend_long strength; @@ -110,7 +117,7 @@ PHP_FUNCTION( collator_set_strength ) COLLATOR_METHOD_FETCH_OBJECT; /* Set given strength. */ - ucol_setStrength( co->ucoll, strength ); + ucol_setStrength( co->ucoll, static_cast(strength) ); RETURN_TRUE; } diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.cpp similarity index 85% rename from ext/intl/collator/collator_class.c rename to ext/intl/collator/collator_class.cpp index 3a883c9e2e645..293a089c26796 100644 --- a/ext/intl/collator/collator_class.c +++ b/ext/intl/collator/collator_class.cpp @@ -15,16 +15,18 @@ #include "collator.h" #include "collator_class.h" +extern "C" { #include "php_intl.h" +#include "intl_error.h" +#include "collator_arginfo.h" +} #include "collator_sort.h" #include "collator_convert.h" -#include "intl_error.h" #include -#include "collator_arginfo.h" -zend_class_entry *Collator_ce_ptr = NULL; +zend_class_entry *Collator_ce_ptr = nullptr; static zend_object_handlers Collator_handlers; /* @@ -43,9 +45,9 @@ void Collator_objects_free(zend_object *object ) /* }}} */ /* {{{ Collator_object_create */ -zend_object *Collator_object_create(zend_class_entry *ce ) +U_CFUNC zend_object *Collator_object_create(zend_class_entry *ce ) { - Collator_object *intern = zend_object_alloc(sizeof(Collator_object), ce); + Collator_object *intern = reinterpret_cast(zend_object_alloc(sizeof(Collator_object), ce)); intl_error_init(COLLATOR_ERROR_P(intern)); zend_object_std_init(&intern->zo, ce ); object_properties_init(&intern->zo, ce); @@ -61,7 +63,7 @@ zend_object *Collator_object_create(zend_class_entry *ce ) /* {{{ collator_register_Collator_symbols * Initialize 'Collator' class */ -void collator_register_Collator_symbols(int module_number) +U_CFUNC void collator_register_Collator_symbols(int module_number) { register_collator_symbols(module_number); @@ -75,7 +77,7 @@ void collator_register_Collator_symbols(int module_number) /* Collator has no usable clone semantics - ucol_cloneBinary/ucol_openBinary require binary buffer for which we don't have the place to keep */ Collator_handlers.offset = XtOffsetOf(Collator_object, zo); - Collator_handlers.clone_obj = NULL; + Collator_handlers.clone_obj = nullptr; Collator_handlers.free_obj = Collator_objects_free; } /* }}} */ @@ -84,7 +86,7 @@ void collator_register_Collator_symbols(int module_number) * Initialize internals of Collator_object. * Must be called before any other call to 'collator_object_...' functions. */ -void collator_object_init( Collator_object* co ) +U_CFUNC void collator_object_init( Collator_object* co ) { if( !co ) return; @@ -96,7 +98,7 @@ void collator_object_init( Collator_object* co ) /* {{{ void collator_object_destroy( Collator_object* co ) * Clean up mem allocted by internals of Collator_object */ -void collator_object_destroy( Collator_object* co ) +U_CFUNC void collator_object_destroy( Collator_object* co ) { if( !co ) return; @@ -104,7 +106,7 @@ void collator_object_destroy( Collator_object* co ) if( co->ucoll ) { ucol_close( co->ucoll ); - co->ucoll = NULL; + co->ucoll = nullptr; } intl_error_reset( COLLATOR_ERROR_P( co ) ); diff --git a/ext/intl/collator/collator_class.h b/ext/intl/collator/collator_class.h index 311ab5623db4e..a281b2bec8ada 100644 --- a/ext/intl/collator/collator_class.h +++ b/ext/intl/collator/collator_class.h @@ -18,9 +18,15 @@ #include +#ifdef __cplusplus +extern "C" { +#endif #include "../intl_common.h" #include "../intl_error.h" #include "../intl_data.h" +#ifdef __cplusplus +} +#endif #include @@ -46,9 +52,15 @@ static inline Collator_object *php_intl_collator_fetch_object(zend_object *obj) } #define Z_INTL_COLLATOR_P(zv) php_intl_collator_fetch_object(Z_OBJ_P(zv)) +#ifdef __cplusplus +extern "C" { +#endif void collator_register_Collator_symbols(int module_number); void collator_object_init( Collator_object* co ); void collator_object_destroy( Collator_object* co ); +#ifdef __cplusplus +} +#endif extern zend_class_entry *Collator_ce_ptr; diff --git a/ext/intl/collator/collator_compare.c b/ext/intl/collator/collator_compare.cpp similarity index 95% rename from ext/intl/collator/collator_compare.c rename to ext/intl/collator/collator_compare.cpp index bafaf166ac7a6..38e283a6d8530 100644 --- a/ext/intl/collator/collator_compare.c +++ b/ext/intl/collator/collator_compare.cpp @@ -17,12 +17,19 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" -#include "collator_class.h" #include "intl_convert.h" +} +#include "collator_class.h" /* {{{ Compare two strings. */ -PHP_FUNCTION( collator_compare ) +U_CFUNC PHP_FUNCTION( collator_compare ) { char* str1 = NULL; char* str2 = NULL; diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.cpp similarity index 90% rename from ext/intl/collator/collator_convert.c rename to ext/intl/collator/collator_convert.cpp index 68f177e36b0ff..d4de15aa0b822 100644 --- a/ext/intl/collator/collator_convert.c +++ b/ext/intl/collator/collator_convert.cpp @@ -17,11 +17,18 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" +#include "intl_convert.h" +} #include "collator_class.h" #include "collator_is_numeric.h" #include "collator_convert.h" -#include "intl_convert.h" #include #include @@ -106,7 +113,7 @@ static void collator_convert_hash_item_from_utf16_to_utf8( /* {{{ collator_convert_hash_from_utf8_to_utf16 * Convert values of the given hash from UTF-8 encoding to UTF-16LE. */ -void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* status ) +U_CFUNC void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* status ) { zend_ulong hashIndex; zval *hashData; @@ -125,7 +132,7 @@ void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* stat /* {{{ collator_convert_hash_from_utf16_to_utf8 * Convert values of the given hash from UTF-16LE encoding to UTF-8. */ -void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* status ) +U_CFUNC void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* status ) { zend_ulong hashIndex; zend_string *hashKey; @@ -150,7 +157,7 @@ void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* stat * * @return zval* Converted string. */ -zval* collator_convert_zstr_utf16_to_utf8( zval* utf16_zval, zval *rv ) +U_CFUNC zval* collator_convert_zstr_utf16_to_utf8( zval* utf16_zval, zval *rv ) { zend_string* u8str; UErrorCode status = U_ZERO_ERROR; @@ -168,7 +175,7 @@ zval* collator_convert_zstr_utf16_to_utf8( zval* utf16_zval, zval *rv ) } /* }}} */ -zend_string *collator_convert_zstr_utf8_to_utf16(zend_string *utf8_str) +U_CFUNC zend_string *collator_convert_zstr_utf8_to_utf16(zend_string *utf8_str) { UErrorCode status = U_ZERO_ERROR; @@ -189,9 +196,9 @@ zend_string *collator_convert_zstr_utf8_to_utf16(zend_string *utf8_str) /* {{{ collator_convert_object_to_string * Convert object to UTF16-encoded string. */ -zval* collator_convert_object_to_string( zval* obj, zval *rv ) +U_CFUNC zval* collator_convert_object_to_string( zval* obj, zval *rv ) { - zval* zstr = NULL; + zval* zstr = nullptr; UErrorCode status = U_ZERO_ERROR; /* Bail out if it's not an object. */ @@ -211,7 +218,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv ) } /* Object wasn't successfully converted => bail out. */ - if( zstr == NULL ) + if( zstr == nullptr ) { COLLATOR_CONVERT_RETURN_FAILED( obj ); } @@ -244,7 +251,7 @@ zval* collator_convert_object_to_string( zval* obj, zval *rv ) * * @return zval* Number. If str is not numeric string return number zero. */ -zval* collator_convert_string_to_number( zval* str, zval *rv ) +U_CFUNC zval* collator_convert_string_to_number( zval* str, zval *rv ) { zval* num = collator_convert_string_to_number_if_possible( str, rv ); if( num == str ) @@ -268,7 +275,7 @@ zval* collator_convert_string_to_number( zval* str, zval *rv ) * * @return zval* Number. If str is not numeric string return number zero. */ -zval* collator_convert_string_to_double( zval* str, zval *rv ) +U_CFUNC zval* collator_convert_string_to_double( zval* str, zval *rv ) { zval* num = collator_convert_string_to_number( str, rv ); if( Z_TYPE_P(num) == IS_LONG ) @@ -289,7 +296,7 @@ zval* collator_convert_string_to_double( zval* str, zval *rv ) * @return zval* Number if str is numeric string. Otherwise * original str param. */ -zval* collator_convert_string_to_number_if_possible( zval* str, zval *rv ) +U_CFUNC zval* collator_convert_string_to_number_if_possible( zval* str, zval *rv ) { uint8_t is_numeric = 0; zend_long lval = 0; @@ -323,7 +330,7 @@ zval* collator_convert_string_to_number_if_possible( zval* str, zval *rv ) * * @return zend_string* UTF16 string. */ -zend_string *collator_zval_to_string(zval *arg) +U_CFUNC zend_string *collator_zval_to_string(zval *arg) { // TODO: This is extremely weird in that it leaves pre-existing strings alone and does not // perform a UTF-8 to UTF-16 conversion for them. The assumption is that values that are @@ -347,9 +354,9 @@ zend_string *collator_zval_to_string(zval *arg) * @return zval* Normalized copy of arg or unmodified arg * if normalization is not needed. */ -zval* collator_normalize_sort_argument( zval* arg, zval *rv ) +U_CFUNC zval* collator_normalize_sort_argument( zval* arg, zval *rv ) { - zval* n_arg = NULL; + zval* n_arg = nullptr; if( Z_TYPE_P( arg ) != IS_STRING ) { diff --git a/ext/intl/collator/collator_convert.h b/ext/intl/collator/collator_convert.h index 1d58560964399..8c5356095b7a1 100644 --- a/ext/intl/collator/collator_convert.h +++ b/ext/intl/collator/collator_convert.h @@ -19,6 +19,9 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* status ); void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* status ); @@ -32,5 +35,8 @@ zval* collator_convert_string_to_number_if_possible( zval* str, zval *rv ); zval* collator_convert_string_to_double( zval* str, zval *rv ); zend_string *collator_zval_to_string(zval *arg); +#ifdef __cplusplus +} +#endif #endif // COLLATOR_CONVERT_H diff --git a/ext/intl/collator/collator_create.c b/ext/intl/collator/collator_create.cpp similarity index 91% rename from ext/intl/collator/collator_create.c rename to ext/intl/collator/collator_create.cpp index 5e6b0dee9ce6e..59280bcdbed5e 100644 --- a/ext/intl/collator/collator_create.c +++ b/ext/intl/collator/collator_create.cpp @@ -17,7 +17,14 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" +} #include "collator_class.h" #include "intl_data.h" @@ -29,7 +36,7 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS) zval* object; Collator_object* co; - intl_error_reset( NULL ); + intl_error_reset( nullptr ); object = return_value; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STRING(locale, locale_len) @@ -50,7 +57,7 @@ static int collator_ctor(INTERNAL_FUNCTION_PARAMETERS) /* }}} */ /* {{{ Create collator. */ -PHP_FUNCTION( collator_create ) +U_CFUNC PHP_FUNCTION( collator_create ) { object_init_ex( return_value, Collator_ce_ptr ); if (collator_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { @@ -61,7 +68,7 @@ PHP_FUNCTION( collator_create ) /* }}} */ /* {{{ Collator object constructor. */ -PHP_METHOD( Collator, __construct ) +U_CFUNC PHP_METHOD( Collator, __construct ) { const bool old_use_exception = INTL_G(use_exceptions); const zend_long old_error_level = INTL_G(error_level); diff --git a/ext/intl/collator/collator_error.c b/ext/intl/collator/collator_error.cpp similarity index 87% rename from ext/intl/collator/collator_error.c rename to ext/intl/collator/collator_error.cpp index 2189b312d7c29..aa333b5098a04 100644 --- a/ext/intl/collator/collator_error.c +++ b/ext/intl/collator/collator_error.cpp @@ -17,11 +17,18 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" +} #include "collator_class.h" /* {{{ Get collator's last error code. */ -PHP_FUNCTION( collator_get_error_code ) +U_CFUNC PHP_FUNCTION( collator_get_error_code ) { COLLATOR_METHOD_INIT_VARS @@ -34,7 +41,7 @@ PHP_FUNCTION( collator_get_error_code ) /* Fetch the object (without resetting its last error code). */ co = Z_INTL_COLLATOR_P(object); - if( co == NULL ) + if( co == nullptr ) RETURN_FALSE; /* Return collator's last error code. */ @@ -43,9 +50,9 @@ PHP_FUNCTION( collator_get_error_code ) /* }}} */ /* {{{ Get text description for collator's last error code. */ -PHP_FUNCTION( collator_get_error_message ) +U_CFUNC PHP_FUNCTION( collator_get_error_message ) { - zend_string* message = NULL; + zend_string* message = nullptr; COLLATOR_METHOD_INIT_VARS @@ -58,7 +65,7 @@ PHP_FUNCTION( collator_get_error_message ) /* Fetch the object (without resetting its last error code). */ co = Z_INTL_COLLATOR_P( object ); - if( co == NULL ) + if( co == nullptr ) RETURN_FALSE; /* Return last error message. */ diff --git a/ext/intl/collator/collator_is_numeric.c b/ext/intl/collator/collator_is_numeric.cpp similarity index 96% rename from ext/intl/collator/collator_is_numeric.c rename to ext/intl/collator/collator_is_numeric.cpp index 4c473d9477116..b3cc52085deaa 100644 --- a/ext/intl/collator/collator_is_numeric.c +++ b/ext/intl/collator/collator_is_numeric.cpp @@ -82,20 +82,20 @@ static double collator_u_strtod(const UChar *nptr, UChar **endptr) /* {{{ */ } *bufpos = '\0'; - value = zend_strtod(numbuf, NULL); + value = zend_strtod(numbuf, nullptr); if (numbuf != buf) { free_alloca(numbuf, use_heap); } - if (endptr != NULL) { + if (endptr != nullptr) { *endptr = (UChar *)u; } return value; } - if (endptr != NULL) { + if (endptr != nullptr) { *endptr = (UChar *)nptr; } @@ -118,10 +118,10 @@ static zend_long collator_u_strtol(const UChar *nptr, UChar **endptr, int base) zend_ulong cutoff; int neg = 0, any, cutlim; - if (s == NULL) { + if (s == nullptr) { errno = ERANGE; - if (endptr != NULL) { - *endptr = NULL; + if (endptr != nullptr) { + *endptr = nullptr; } return 0; } @@ -194,7 +194,7 @@ static zend_long collator_u_strtol(const UChar *nptr, UChar **endptr, int base) errno = ERANGE; } else if (neg) acc = -acc; - if (endptr != NULL) + if (endptr != nullptr) *endptr = (UChar *)(any ? s - 1 : nptr); return (acc); } @@ -235,12 +235,12 @@ uint8_t collator_is_numeric( UChar *str, int32_t length, zend_long *lval, double return 0; } } else { - end_ptr_long = NULL; + end_ptr_long = nullptr; } local_dval = collator_u_strtod(str, &end_ptr_double); if (local_dval == 0 && end_ptr_double == str) { - end_ptr_double = NULL; + end_ptr_double = nullptr; } else { end_ptr_double = collator_skip_ws(end_ptr_double); if (end_ptr_double == str+length) { /* floating point string */ diff --git a/ext/intl/collator/collator_locale.c b/ext/intl/collator/collator_locale.cpp similarity index 82% rename from ext/intl/collator/collator_locale.c rename to ext/intl/collator/collator_locale.cpp index a7aafa74c26bd..67b3d1342cc75 100644 --- a/ext/intl/collator/collator_locale.c +++ b/ext/intl/collator/collator_locale.cpp @@ -17,17 +17,24 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" +} #include "collator_class.h" #include "intl_convert.h" #include /* {{{ Gets the locale name of the collator. */ -PHP_FUNCTION( collator_get_locale ) +U_CFUNC PHP_FUNCTION( collator_get_locale ) { zend_long type = 0; - char* locale_name = NULL; + char* locale_name = nullptr; COLLATOR_METHOD_INIT_VARS @@ -42,16 +49,16 @@ PHP_FUNCTION( collator_get_locale ) COLLATOR_METHOD_FETCH_OBJECT; if (!co || !co->ucoll) { - intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); + intl_error_set_code( nullptr, COLLATOR_ERROR_CODE( co ) ); intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized"); - zend_throw_error(NULL, "Object not initialized"); + zend_throw_error(nullptr, "Object not initialized"); RETURN_THROWS(); } /* Get locale by specified type. */ locale_name = (char*) ucol_getLocaleByType( - co->ucoll, type, COLLATOR_ERROR_CODE_P( co ) ); + co->ucoll, static_cast(type), COLLATOR_ERROR_CODE_P( co ) ); COLLATOR_CHECK_STATUS( co, "Error getting locale by type" ); /* Return it. */ diff --git a/ext/intl/collator/collator_sort.c b/ext/intl/collator/collator_sort.cpp similarity index 88% rename from ext/intl/collator/collator_sort.c rename to ext/intl/collator/collator_sort.cpp index 99b75aa0ef2be..003d7f45a837f 100644 --- a/ext/intl/collator/collator_sort.c +++ b/ext/intl/collator/collator_sort.cpp @@ -17,12 +17,19 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" +#include "intl_convert.h" +} #include "collator.h" #include "collator_class.h" #include "collator_sort.h" #include "collator_convert.h" -#include "intl_convert.h" /** * Declare 'index' which will point to sort key in sort key @@ -50,8 +57,8 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2) zval str1, str2; zval num1, num2; zval norm1, norm2; - zval *num1_p = NULL, *num2_p = NULL; - zval *norm1_p = NULL, *norm2_p = NULL; + zval *num1_p = nullptr, *num2_p = nullptr; + zval *norm1_p = nullptr, *norm2_p = nullptr; zval *str1_p, *str2_p; ZVAL_NULL(&str1); @@ -66,7 +73,7 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2) str2_p == ( num2_p = collator_convert_string_to_number_if_possible( str2_p, &num2 ) ) ) ) { /* Compare the strings using ICU. */ - ZEND_ASSERT(INTL_G(current_collator) != NULL); + ZEND_ASSERT(INTL_G(current_collator) != nullptr); ZVAL_LONG(result, ucol_strcoll( INTL_G(current_collator), INTL_ZSTR_VAL(Z_STR_P(str1_p)), INTL_ZSTR_LEN(Z_STR_P(str1_p)), @@ -132,8 +139,8 @@ static int collator_regular_compare_function(zval *result, zval *op1, zval *op2) static int collator_numeric_compare_function(zval *result, zval *op1, zval *op2) { zval num1, num2; - zval *num1_p = NULL; - zval *num2_p = NULL; + zval *num1_p = nullptr; + zval *num2_p = nullptr; if( Z_TYPE_P(op1) == IS_STRING ) { @@ -168,7 +175,7 @@ static int collator_icu_compare_function(zval *result, zval *op1, zval *op2) zend_string *str2 = collator_zval_to_string(op2); /* Compare the strings using ICU. */ - ZEND_ASSERT(INTL_G(current_collator) != NULL); + ZEND_ASSERT(INTL_G(current_collator) != nullptr); ZVAL_LONG(result, ucol_strcoll( INTL_G(current_collator), INTL_ZSTR_VAL(str1), INTL_ZSTR_LEN(str1), @@ -253,8 +260,8 @@ static collator_compare_func_t collator_get_compare_function( const zend_long so static void collator_sort_internal( int renumber, INTERNAL_FUNCTION_PARAMETERS ) { UCollator* saved_collator; - zval* array = NULL; - HashTable* hash = NULL; + zval* array = nullptr; + HashTable* hash = nullptr; zend_long sort_flags = COLLATOR_SORT_REGULAR; COLLATOR_METHOD_INIT_VARS @@ -302,7 +309,7 @@ static void collator_sort_internal( int renumber, INTERNAL_FUNCTION_PARAMETERS ) /* }}} */ /* {{{ Sort array using specified collator. */ -PHP_FUNCTION( collator_sort ) +U_CFUNC PHP_FUNCTION( collator_sort ) { collator_sort_internal( true, INTERNAL_FUNCTION_PARAM_PASSTHRU ); } @@ -320,28 +327,28 @@ static void collator_sortkey_swap(collator_sort_key_index_t *p, collator_sort_ke /* {{{ Equivalent to standard PHP sort using Collator. * Uses ICU ucol_getSortKey for performance. */ -PHP_FUNCTION( collator_sort_with_sort_keys ) +U_CFUNC PHP_FUNCTION( collator_sort_with_sort_keys ) { - zval* array = NULL; + zval* array = nullptr; zval garbage; - HashTable* hash = NULL; - zval* hashData = NULL; /* currently processed item of input hash */ + HashTable* hash = nullptr; + zval* hashData = nullptr; /* currently processed item of input hash */ - char* sortKeyBuf = NULL; /* buffer to store sort keys */ + char* sortKeyBuf = nullptr; /* buffer to store sort keys */ uint32_t sortKeyBufSize = DEF_SORT_KEYS_BUF_SIZE; /* buffer size */ ptrdiff_t sortKeyBufOffset = 0; /* pos in buffer to store sort key */ uint32_t sortKeyLen = 0; /* the length of currently processing key */ uint32_t bufLeft = 0; uint32_t bufIncrement = 0; - collator_sort_key_index_t* sortKeyIndxBuf = NULL; /* buffer to store 'indexes' which will be passed to 'qsort' */ + collator_sort_key_index_t* sortKeyIndxBuf = nullptr; /* buffer to store 'indexes' which will be passed to 'qsort' */ uint32_t sortKeyIndxBufSize = DEF_SORT_KEYS_INDX_BUF_SIZE; uint32_t sortKeyIndxSize = sizeof( collator_sort_key_index_t ); uint32_t sortKeyCount = 0; uint32_t j = 0; - UChar* utf16_buf = NULL; /* tmp buffer to hold current processing string in utf-16 */ + UChar* utf16_buf = nullptr; /* tmp buffer to hold current processing string in utf-16 */ int utf16_buf_size = DEF_UTF16_BUF_SIZE; /* the length of utf16_buf */ int utf16_len = 0; /* length of converted string */ @@ -358,7 +365,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) COLLATOR_METHOD_FETCH_OBJECT; if (!co || !co->ucoll) { - intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); + intl_error_set_code( nullptr, COLLATOR_ERROR_CODE( co ) ); intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized"); zend_throw_error(NULL, "Object not initialized"); @@ -374,8 +381,8 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) RETURN_TRUE; /* Create bufers */ - sortKeyBuf = ecalloc( sortKeyBufSize, sizeof( char ) ); - sortKeyIndxBuf = ecalloc( sortKeyIndxBufSize, sizeof( uint8_t ) ); + sortKeyBuf = reinterpret_cast(ecalloc( sortKeyBufSize, sizeof( char ) )); + sortKeyIndxBuf = reinterpret_cast(ecalloc( sortKeyIndxBufSize, sizeof( uint8_t ) )); utf16_buf = eumalloc( utf16_buf_size ); /* Iterate through input hash and create a sort key for each value. */ @@ -391,7 +398,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) ) { - intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); + intl_error_set_code( nullptr, COLLATOR_ERROR_CODE( co ) ); intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Sort with sort keys failed"); if( utf16_buf ) @@ -430,7 +437,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) sortKeyBufSize += bufIncrement; bufLeft += bufIncrement; - sortKeyBuf = erealloc( sortKeyBuf, sortKeyBufSize ); + sortKeyBuf = reinterpret_cast(erealloc( sortKeyBuf, sortKeyBufSize )); sortKeyLen = ucol_getSortKey( co->ucoll, utf16_buf, utf16_len, (uint8_t*)sortKeyBuf + sortKeyBufOffset, bufLeft ); } @@ -442,7 +449,7 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) sortKeyIndxBufSize += bufIncrement; - sortKeyIndxBuf = erealloc( sortKeyIndxBuf, sortKeyIndxBufSize ); + sortKeyIndxBuf = reinterpret_cast(erealloc( sortKeyIndxBuf, sortKeyIndxBufSize )); } sortKeyIndxBuf[sortKeyCount].key = (char*)sortKeyBufOffset; /* remember just offset, cause address */ @@ -485,18 +492,18 @@ PHP_FUNCTION( collator_sort_with_sort_keys ) /* }}} */ /* {{{ Sort array using specified collator, maintaining index association. */ -PHP_FUNCTION( collator_asort ) +U_CFUNC PHP_FUNCTION( collator_asort ) { collator_sort_internal( false, INTERNAL_FUNCTION_PARAM_PASSTHRU ); } /* }}} */ /* {{{ Get a sort key for a string from a Collator. */ -PHP_FUNCTION( collator_get_sort_key ) +U_CFUNC PHP_FUNCTION( collator_get_sort_key ) { - char* str = NULL; + char* str = nullptr; size_t str_len = 0; - UChar* ustr = NULL; + UChar* ustr = nullptr; int32_t ustr_len = 0; int key_len = 0; zend_string* key_str; @@ -514,7 +521,7 @@ PHP_FUNCTION( collator_get_sort_key ) COLLATOR_METHOD_FETCH_OBJECT; if (!co || !co->ucoll) { - intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); + intl_error_set_code( nullptr, COLLATOR_ERROR_CODE( co ) ); intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Object not initialized"); zend_throw_error(NULL, "Object not initialized"); @@ -531,7 +538,7 @@ PHP_FUNCTION( collator_get_sort_key ) if( U_FAILURE( COLLATOR_ERROR_CODE( co ) ) ) { /* Set global error code. */ - intl_error_set_code( NULL, COLLATOR_ERROR_CODE( co ) ); + intl_error_set_code( nullptr, COLLATOR_ERROR_CODE( co ) ); /* Set error messages. */ intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ), "Error converting first argument to UTF-16"); @@ -541,7 +548,7 @@ PHP_FUNCTION( collator_get_sort_key ) /* ucol_getSortKey is exception in that the key length includes the * NUL terminator*/ - key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, NULL, 0); + key_len = ucol_getSortKey(co->ucoll, ustr, ustr_len, nullptr, 0); if(!key_len) { efree( ustr ); RETURN_FALSE; diff --git a/ext/intl/common/common_date.h b/ext/intl/common/common_date.h index ef007c8eee687..988f279294c3c 100644 --- a/ext/intl/common/common_date.h +++ b/ext/intl/common/common_date.h @@ -24,6 +24,9 @@ U_CDECL_END #ifdef __cplusplus +// TODO once C++ migration done we can drop this workaround +#undef U_SHOW_CPLUSPLUS_API +#define U_SHOW_CPLUSPLUS_API 1 #include using icu::TimeZone; diff --git a/ext/intl/common/common_error.c b/ext/intl/common/common_error.cpp similarity index 84% rename from ext/intl/common/common_error.c rename to ext/intl/common/common_error.cpp index 733a1913ad08f..cb12d8dff8f3d 100644 --- a/ext/intl/common/common_error.c +++ b/ext/intl/common/common_error.cpp @@ -17,11 +17,13 @@ #include #endif +extern "C" { #include "php_intl.h" #include "intl_error.h" +} /* {{{ Get code of the last occurred error. */ -PHP_FUNCTION( intl_get_error_code ) +U_CFUNC PHP_FUNCTION( intl_get_error_code ) { ZEND_PARSE_PARAMETERS_NONE(); @@ -30,7 +32,7 @@ PHP_FUNCTION( intl_get_error_code ) /* }}} */ /* {{{ Get text description of the last occurred error. */ -PHP_FUNCTION( intl_get_error_message ) +U_CFUNC PHP_FUNCTION( intl_get_error_message ) { ZEND_PARSE_PARAMETERS_NONE(); @@ -42,7 +44,7 @@ PHP_FUNCTION( intl_get_error_message ) * Returns true if it does, and false if the code * indicates success or a warning. */ -PHP_FUNCTION( intl_is_failure ) +U_CFUNC PHP_FUNCTION( intl_is_failure ) { zend_long err_code; @@ -50,14 +52,14 @@ PHP_FUNCTION( intl_is_failure ) Z_PARAM_LONG(err_code) ZEND_PARSE_PARAMETERS_END(); - RETURN_BOOL( U_FAILURE( err_code ) ); + RETURN_BOOL( U_FAILURE( static_cast(err_code) ) ); } /* }}} */ /* {{{ Return a string for a given error code. * The string will be the same as the name of the error code constant. */ -PHP_FUNCTION( intl_error_name ) +U_CFUNC PHP_FUNCTION( intl_error_name ) { zend_long err_code; @@ -65,6 +67,6 @@ PHP_FUNCTION( intl_error_name ) Z_PARAM_LONG(err_code) ZEND_PARSE_PARAMETERS_END(); - RETURN_STRING( (char*)u_errorName( err_code ) ); + RETURN_STRING( (char*)u_errorName( static_cast(err_code) ) ); } /* }}} */ diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 index c4c3c9b1d4cea..7251f22835349 100644 --- a/ext/intl/config.m4 +++ b/ext/intl/config.m4 @@ -8,63 +8,55 @@ if test "$PHP_INTL" != "no"; then PHP_SUBST([INTL_SHARED_LIBADD]) INTL_COMMON_FLAGS="$ICU_CFLAGS -Wno-write-strings -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" PHP_NEW_EXTENSION([intl], m4_normalize([ - collator/collator_attr.c - collator/collator_class.c - collator/collator_compare.c - collator/collator_convert.c - collator/collator_create.c - collator/collator_error.c - collator/collator_is_numeric.c - collator/collator_locale.c - collator/collator_sort.c - common/common_error.c - converter/converter.c - dateformat/dateformat_attr.c - dateformat/dateformat_class.c - dateformat/dateformat_data.c - dateformat/dateformat_format.c - dateformat/dateformat_parse.c - dateformat/dateformat.c - formatter/formatter_attr.c - formatter/formatter_class.c - formatter/formatter_data.c - formatter/formatter_format.c - formatter/formatter_main.c - formatter/formatter_parse.c - grapheme/grapheme_string.c - grapheme/grapheme_util.c intl_convert.c intl_error.c - listformatter/listformatter_class.c php_intl.c - resourcebundle/resourcebundle_class.c - resourcebundle/resourcebundle_iterator.c - resourcebundle/resourcebundle.c - spoofchecker/spoofchecker_class.c - spoofchecker/spoofchecker_create.c - spoofchecker/spoofchecker_main.c - transliterator/transliterator_class.c - transliterator/transliterator_methods.c ]), [$ext_shared],, [$INTL_COMMON_FLAGS], [cxx]) PHP_INTL_CXX_SOURCES="intl_convertcpp.cpp \ + collator/collator_attr.cpp \ + collator/collator_class.cpp \ + collator/collator_compare.cpp \ + collator/collator_convert.cpp \ + collator/collator_create.cpp \ + collator/collator_error.cpp \ + collator/collator_is_numeric.cpp \ + collator/collator_locale.cpp \ + collator/collator_sort.cpp \ common/common_enum.cpp \ common/common_date.cpp \ - dateformat/dateformat_format_object.cpp \ - dateformat/dateformat_create.cpp \ + common/common_error.cpp \ + dateformat/dateformat_class.cpp \ + converter/converter.cpp \ + dateformat/dateformat.cpp \ + dateformat/dateformat_attr.cpp \ dateformat/dateformat_attrcpp.cpp \ + dateformat/dateformat_create.cpp \ + dateformat/dateformat_data.cpp \ + dateformat/dateformat_format.cpp \ + dateformat/dateformat_format_object.cpp \ dateformat/dateformat_helpers.cpp \ + dateformat/dateformat_parse.cpp \ dateformat/datepatterngenerator_class.cpp \ dateformat/datepatterngenerator_methods.cpp \ + formatter/formatter_class.cpp \ + grapheme/grapheme_string.cpp \ + grapheme/grapheme_util.cpp \ msgformat/msgformat_helpers.cpp \ + rangeformatter/rangeformatter_class.cpp \ timezone/timezone_class.cpp \ timezone/timezone_methods.cpp \ calendar/calendar_class.cpp \ calendar/calendar_methods.cpp \ calendar/gregoriancalendar_methods.cpp \ + formatter/formatter_attr.cpp \ + formatter/formatter_data.cpp \ + formatter/formatter_format.cpp \ + formatter/formatter_main.cpp \ + formatter/formatter_parse.cpp \ msgformat/msgformat_attr.cpp \ msgformat/msgformat_class.cpp \ msgformat/msgformat_data.cpp \ @@ -79,10 +71,19 @@ if test "$PHP_INTL" != "no"; then breakiterator/rulebasedbreakiterator_methods.cpp \ breakiterator/codepointiterator_internal.cpp \ breakiterator/codepointiterator_methods.cpp \ + listformatter/listformatter_class.cpp \ + transliterator/transliterator_class.cpp \ + transliterator/transliterator_methods.cpp \ idn/idn.cpp \ locale/locale_class.cpp \ locale/locale_methods.cpp \ locale/locale.cpp \ + resourcebundle/resourcebundle_class.cpp \ + resourcebundle/resourcebundle_iterator.cpp \ + resourcebundle/resourcebundle.cpp \ + spoofchecker/spoofchecker_class.cpp \ + spoofchecker/spoofchecker_create.cpp \ + spoofchecker/spoofchecker_main.cpp \ uchar/uchar.cpp" PHP_REQUIRE_CXX() @@ -123,6 +124,7 @@ if test "$PHP_INTL" != "no"; then $ext_builddir/listformatter $ext_builddir/msgformat $ext_builddir/normalizer + $ext_builddir/rangeformatter $ext_builddir/resourcebundle $ext_builddir/spoofchecker $ext_builddir/timezone diff --git a/ext/intl/config.w32 b/ext/intl/config.w32 index fb3f0212729dd..d5c86d1236712 100644 --- a/ext/intl/config.w32 +++ b/ext/intl/config.w32 @@ -13,34 +13,34 @@ if (PHP_INTL != "no") { "/I \"" + configure_module_dirname + "\" /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_EXTENSION_DEP('intl', 'date'); ADD_SOURCES(configure_module_dirname + "/collator", "\ - collator_attr.c \ - collator_class.c \ - collator_compare.c \ - collator_convert.c \ - collator_create.c \ - collator_error.c \ - collator_is_numeric.c \ - collator_locale.c \ - collator_sort.c \ + collator_attr.cpp \ + collator_class.cpp \ + collator_compare.cpp \ + collator_convert.cpp \ + collator_create.cpp \ + collator_error.cpp \ + collator_is_numeric.cpp \ + collator_locale.cpp \ + collator_sort.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/common", "\ - common_error.c \ + common_error.cpp \ common_enum.cpp \ common_date.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/converter", "\ - converter.c \ + converter.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/formatter", "\ - formatter_attr.c \ - formatter_class.c \ - formatter_data.c \ - formatter_format.c \ - formatter_main.c \ - formatter_parse.c \ + formatter_attr.cpp \ + formatter_class.cpp \ + formatter_data.cpp \ + formatter_format.cpp \ + formatter_main.cpp \ + formatter_parse.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/listformatter", "\ - listformatter_class.c \ + listformatter_class.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/locale", "\ locale.cpp \ @@ -57,20 +57,23 @@ if (PHP_INTL != "no") { msgformat_parse.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/grapheme", "\ - grapheme_string.c grapheme_util.c \ + grapheme_string.cpp grapheme_util.cpp \ ", "intl"); ADD_SOURCES(configure_module_dirname + "/normalizer", "\ normalizer_class.cpp \ normalizer_normalize.cpp \ ", "intl"); + ADD_SOURCES(configure_module_dirname + "/rangeformatter", "\ + rangeformatter_class.cpp \ + ", "intl"); ADD_SOURCES(configure_module_dirname + "/dateformat", "\ - dateformat.c \ - dateformat_class.c \ - dateformat_attr.c \ - dateformat_format.c \ + dateformat.cpp \ + dateformat_class.cpp \ + dateformat_attr.cpp \ + dateformat_format.cpp \ dateformat_format_object.cpp \ - dateformat_parse.c \ - dateformat_data.c \ + dateformat_parse.cpp \ + dateformat_data.cpp \ dateformat_attrcpp.cpp \ dateformat_helpers.cpp \ dateformat_create.cpp \ @@ -84,22 +87,22 @@ if (PHP_INTL != "no") { idn.cpp", "intl"); ADD_SOURCES(configure_module_dirname + "/resourcebundle", "\ - resourcebundle.c \ - resourcebundle_class.c \ - resourcebundle_iterator.c", + resourcebundle.cpp \ + resourcebundle_class.cpp \ + resourcebundle_iterator.cpp", "intl"); if (CHECK_HEADER_ADD_INCLUDE("unicode/uspoof.h", "CFLAGS_INTL")) { ADD_SOURCES(configure_module_dirname + "/spoofchecker", "\ - spoofchecker_class.c \ - spoofchecker_create.c \ - spoofchecker_main.c", + spoofchecker_class.cpp \ + spoofchecker_create.cpp \ + spoofchecker_main.cpp", "intl"); } ADD_SOURCES(configure_module_dirname + "/transliterator", "\ - transliterator_class.c \ - transliterator_methods.c", + transliterator_class.cpp \ + transliterator_methods.cpp", "intl"); ADD_SOURCES(configure_module_dirname + "/timezone", "\ diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.cpp similarity index 95% rename from ext/intl/converter/converter.c rename to ext/intl/converter/converter.cpp index 759db5e18873a..ad68909b5ea3c 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.cpp @@ -12,7 +12,6 @@ +----------------------------------------------------------------------+ */ -#include "converter.h" #include "zend_exceptions.h" #include @@ -21,10 +20,13 @@ #include #include +extern "C" { +#include "converter.h" +#include "php_intl.h" #include "../intl_error.h" #include "../intl_common.h" +} #include "converter_arginfo.h" -#include "php_intl.h" typedef struct _php_converter_object { UConverter *src, *dest; @@ -141,9 +143,9 @@ PHP_METHOD(UConverter, fromUCallback) { static inline bool php_converter_check_limits(php_converter_object *objval, zend_long available, zend_long needed) { if (available < needed) { php_converter_throw_failure(objval, U_BUFFER_OVERFLOW_ERROR, "Buffer overrun " ZEND_LONG_FMT " bytes needed, " ZEND_LONG_FMT " available", needed, available); - return 0; + return false; } - return 1; + return true; } /* }}} */ @@ -238,9 +240,9 @@ static void php_converter_to_u_callback(const void *context, } if (Z_TYPE(zargs[3]) == IS_LONG) { - *pErrorCode = Z_LVAL(zargs[3]); + *pErrorCode = static_cast(Z_LVAL(zargs[3])); } else if (Z_ISREF(zargs[3]) && Z_TYPE_P(Z_REFVAL(zargs[3])) == IS_LONG) { - *pErrorCode = Z_LVAL_P(Z_REFVAL(zargs[3])); + *pErrorCode = static_cast(Z_LVAL_P(Z_REFVAL(zargs[3]))); } zval_ptr_dtor(&zargs[0]); @@ -265,7 +267,7 @@ static void php_converter_append_fromUnicode_target(zval *val, UConverterFromUni { size_t vallen = Z_STRLEN_P(val); if (TARGET_CHECK(args, vallen)) { - args->target = zend_mempcpy(args->target, Z_STRVAL_P(val), vallen); + args->target = reinterpret_cast(zend_mempcpy(args->target, Z_STRVAL_P(val), vallen)); } return; } @@ -315,9 +317,9 @@ static void php_converter_from_u_callback(const void *context, } if (Z_TYPE(zargs[3]) == IS_LONG) { - *pErrorCode = Z_LVAL(zargs[3]); + *pErrorCode = static_cast(Z_LVAL(zargs[3])); } else if (Z_ISREF(zargs[3]) && Z_TYPE_P(Z_REFVAL(zargs[3])) == IS_LONG) { - *pErrorCode = Z_LVAL_P(Z_REFVAL(zargs[3])); + *pErrorCode = static_cast(Z_LVAL_P(Z_REFVAL(zargs[3]))); } zval_ptr_dtor(&zargs[0]); @@ -336,22 +338,22 @@ static inline bool php_converter_set_callbacks(php_converter_object *objval, UCo /* Short-circuit having to go through method calls and data marshalling * when we're using default behavior */ - return 1; + return true; } ucnv_setToUCallBack(cnv, (UConverterToUCallback)php_converter_to_u_callback, (const void*)objval, - NULL, NULL, &error); + nullptr, nullptr, &error); if (U_FAILURE(error)) { THROW_UFAILURE(objval, error); - ret = 0; + ret = false; } error = U_ZERO_ERROR; ucnv_setFromUCallBack(cnv, (UConverterFromUCallback)php_converter_from_u_callback, (const void*)objval, - NULL, NULL, &error); + nullptr, nullptr, &error); if (U_FAILURE(error)) { THROW_UFAILURE(objval, error); - ret = 0; + ret = false; } return ret; } @@ -507,14 +509,14 @@ static void php_converter_resolve_callback( const char *callback_name, size_t callback_name_len ) { - zend_function *fn = zend_hash_str_find_ptr_lc(&obj->ce->function_table, callback_name, callback_name_len); - ZEND_ASSERT(fn != NULL); + zend_function *fn = reinterpret_cast(zend_hash_str_find_ptr_lc(&obj->ce->function_table, callback_name, callback_name_len)); + ZEND_ASSERT(fn != nullptr); fcc->function_handler = fn; fcc->object = obj; fcc->called_scope = obj->ce; - fcc->calling_scope = NULL; - fcc->closure = NULL; + fcc->calling_scope = nullptr; + fcc->closure = nullptr; } /* }}} */ @@ -635,16 +637,16 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, if (!src_cnv || !dest_cnv) { php_converter_throw_failure(objval, U_INVALID_STATE_ERROR, "Internal converters not initialized"); - return NULL; + return nullptr; } /* Get necessary buffer size first */ temp_len = 1 + ucnv_toUChars(src_cnv, NULL, 0, src, src_len, &error); if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) { THROW_UFAILURE(objval, error); - return NULL; + return nullptr; } - temp = safe_emalloc(sizeof(UChar), temp_len, sizeof(UChar)); + temp = reinterpret_cast(safe_emalloc(sizeof(UChar), temp_len, sizeof(UChar))); /* Convert to intermediate UChar* array */ error = U_ZERO_ERROR; @@ -652,7 +654,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, if (U_FAILURE(error)) { THROW_UFAILURE(objval, error); efree(temp); - return NULL; + return nullptr; } temp[temp_len] = 0; @@ -661,7 +663,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, if (U_FAILURE(error) && error != U_BUFFER_OVERFLOW_ERROR) { THROW_UFAILURE(objval, error); efree(temp); - return NULL; + return nullptr; } ret = zend_string_alloc(ret_len, 0); @@ -673,7 +675,7 @@ static zend_string* php_converter_do_convert(UConverter *dest_cnv, if (U_FAILURE(error)) { THROW_UFAILURE(objval, error); zend_string_efree(ret); - return NULL; + return nullptr; } return ret; @@ -735,8 +737,8 @@ PHP_METHOD(UConverter, convert) { PHP_METHOD(UConverter, transcode) { char *str, *src, *dest; size_t str_len, src_len, dest_len; - zval *options = NULL; - UConverter *src_cnv = NULL, *dest_cnv = NULL; + zval *options = nullptr; + UConverter *src_cnv = nullptr, *dest_cnv = nullptr; ZEND_PARSE_PARAMETERS_START(3, 4) Z_PARAM_STRING(str, str_len) @@ -911,7 +913,7 @@ static void php_converter_free_object(zend_object *obj) { static zend_object *php_converter_object_ctor(zend_class_entry *ce, php_converter_object **pobjval) { php_converter_object *objval; - objval = zend_object_alloc(sizeof(php_converter_object), ce); + objval = reinterpret_cast(zend_object_alloc(sizeof(php_converter_object), ce)); zend_object_std_init(&objval->obj, ce); object_properties_init(&objval->obj, ce); @@ -923,7 +925,7 @@ static zend_object *php_converter_object_ctor(zend_class_entry *ce, php_converte } static zend_object *php_converter_create_object(zend_class_entry *ce) { - php_converter_object *objval = NULL; + php_converter_object *objval = nullptr; zend_object *retval = php_converter_object_ctor(ce, &objval); object_properties_init(&(objval->obj), ce); @@ -968,7 +970,7 @@ static zend_object *php_converter_clone_object(zend_object *object) { /* }}} */ /* {{{ php_converter_minit */ -int php_converter_minit(INIT_FUNC_ARGS) { +U_CFUNC int php_converter_minit(INIT_FUNC_ARGS) { php_converter_ce = register_class_UConverter(); php_converter_ce->create_object = php_converter_create_object; php_converter_ce->default_object_handlers = &php_converter_object_handlers; diff --git a/ext/intl/converter/converter.h b/ext/intl/converter/converter.h index f9fb27b82a7d0..5d779560811d0 100644 --- a/ext/intl/converter/converter.h +++ b/ext/intl/converter/converter.h @@ -21,6 +21,12 @@ #include "php.h" +#ifdef __cplusplus +extern "C" { +#endif int php_converter_minit(INIT_FUNC_ARGS); +#ifdef __cplusplus +} +#endif #endif /* PHP_INTL_CONVERTER_H */ diff --git a/ext/intl/converter/converter_arginfo.h b/ext/intl/converter/converter_arginfo.h index 4e02daf9478ad..9808e50b39dc8 100644 --- a/ext/intl/converter/converter_arginfo.h +++ b/ext/intl/converter/converter_arginfo.h @@ -126,249 +126,249 @@ static zend_class_entry *register_class_UConverter(void) zval const_REASON_UNASSIGNED_value; ZVAL_LONG(&const_REASON_UNASSIGNED_value, UCNV_UNASSIGNED); - zend_string *const_REASON_UNASSIGNED_name = zend_string_init_interned("REASON_UNASSIGNED", sizeof("REASON_UNASSIGNED") - 1, 1); + zend_string *const_REASON_UNASSIGNED_name = zend_string_init_interned("REASON_UNASSIGNED", sizeof("REASON_UNASSIGNED") - 1, true); zend_declare_typed_class_constant(class_entry, const_REASON_UNASSIGNED_name, &const_REASON_UNASSIGNED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REASON_UNASSIGNED_name); + zend_string_release_ex(const_REASON_UNASSIGNED_name, true); zval const_REASON_ILLEGAL_value; ZVAL_LONG(&const_REASON_ILLEGAL_value, UCNV_ILLEGAL); - zend_string *const_REASON_ILLEGAL_name = zend_string_init_interned("REASON_ILLEGAL", sizeof("REASON_ILLEGAL") - 1, 1); + zend_string *const_REASON_ILLEGAL_name = zend_string_init_interned("REASON_ILLEGAL", sizeof("REASON_ILLEGAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_REASON_ILLEGAL_name, &const_REASON_ILLEGAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REASON_ILLEGAL_name); + zend_string_release_ex(const_REASON_ILLEGAL_name, true); zval const_REASON_IRREGULAR_value; ZVAL_LONG(&const_REASON_IRREGULAR_value, UCNV_IRREGULAR); - zend_string *const_REASON_IRREGULAR_name = zend_string_init_interned("REASON_IRREGULAR", sizeof("REASON_IRREGULAR") - 1, 1); + zend_string *const_REASON_IRREGULAR_name = zend_string_init_interned("REASON_IRREGULAR", sizeof("REASON_IRREGULAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_REASON_IRREGULAR_name, &const_REASON_IRREGULAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REASON_IRREGULAR_name); + zend_string_release_ex(const_REASON_IRREGULAR_name, true); zval const_REASON_RESET_value; ZVAL_LONG(&const_REASON_RESET_value, UCNV_RESET); - zend_string *const_REASON_RESET_name = zend_string_init_interned("REASON_RESET", sizeof("REASON_RESET") - 1, 1); + zend_string *const_REASON_RESET_name = zend_string_init_interned("REASON_RESET", sizeof("REASON_RESET") - 1, true); zend_declare_typed_class_constant(class_entry, const_REASON_RESET_name, &const_REASON_RESET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REASON_RESET_name); + zend_string_release_ex(const_REASON_RESET_name, true); zval const_REASON_CLOSE_value; ZVAL_LONG(&const_REASON_CLOSE_value, UCNV_CLOSE); - zend_string *const_REASON_CLOSE_name = zend_string_init_interned("REASON_CLOSE", sizeof("REASON_CLOSE") - 1, 1); + zend_string *const_REASON_CLOSE_name = zend_string_init_interned("REASON_CLOSE", sizeof("REASON_CLOSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_REASON_CLOSE_name, &const_REASON_CLOSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REASON_CLOSE_name); + zend_string_release_ex(const_REASON_CLOSE_name, true); zval const_REASON_CLONE_value; ZVAL_LONG(&const_REASON_CLONE_value, UCNV_CLONE); - zend_string *const_REASON_CLONE_name = zend_string_init_interned("REASON_CLONE", sizeof("REASON_CLONE") - 1, 1); + zend_string *const_REASON_CLONE_name = zend_string_init_interned("REASON_CLONE", sizeof("REASON_CLONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_REASON_CLONE_name, &const_REASON_CLONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REASON_CLONE_name); + zend_string_release_ex(const_REASON_CLONE_name, true); zval const_UNSUPPORTED_CONVERTER_value; ZVAL_LONG(&const_UNSUPPORTED_CONVERTER_value, UCNV_UNSUPPORTED_CONVERTER); - zend_string *const_UNSUPPORTED_CONVERTER_name = zend_string_init_interned("UNSUPPORTED_CONVERTER", sizeof("UNSUPPORTED_CONVERTER") - 1, 1); + zend_string *const_UNSUPPORTED_CONVERTER_name = zend_string_init_interned("UNSUPPORTED_CONVERTER", sizeof("UNSUPPORTED_CONVERTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_UNSUPPORTED_CONVERTER_name, &const_UNSUPPORTED_CONVERTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UNSUPPORTED_CONVERTER_name); + zend_string_release_ex(const_UNSUPPORTED_CONVERTER_name, true); zval const_SBCS_value; ZVAL_LONG(&const_SBCS_value, UCNV_SBCS); - zend_string *const_SBCS_name = zend_string_init_interned("SBCS", sizeof("SBCS") - 1, 1); + zend_string *const_SBCS_name = zend_string_init_interned("SBCS", sizeof("SBCS") - 1, true); zend_declare_typed_class_constant(class_entry, const_SBCS_name, &const_SBCS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SBCS_name); + zend_string_release_ex(const_SBCS_name, true); zval const_DBCS_value; ZVAL_LONG(&const_DBCS_value, UCNV_DBCS); - zend_string *const_DBCS_name = zend_string_init_interned("DBCS", sizeof("DBCS") - 1, 1); + zend_string *const_DBCS_name = zend_string_init_interned("DBCS", sizeof("DBCS") - 1, true); zend_declare_typed_class_constant(class_entry, const_DBCS_name, &const_DBCS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DBCS_name); + zend_string_release_ex(const_DBCS_name, true); zval const_MBCS_value; ZVAL_LONG(&const_MBCS_value, UCNV_MBCS); - zend_string *const_MBCS_name = zend_string_init_interned("MBCS", sizeof("MBCS") - 1, 1); + zend_string *const_MBCS_name = zend_string_init_interned("MBCS", sizeof("MBCS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MBCS_name, &const_MBCS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MBCS_name); + zend_string_release_ex(const_MBCS_name, true); zval const_LATIN_1_value; ZVAL_LONG(&const_LATIN_1_value, UCNV_LATIN_1); - zend_string *const_LATIN_1_name = zend_string_init_interned("LATIN_1", sizeof("LATIN_1") - 1, 1); + zend_string *const_LATIN_1_name = zend_string_init_interned("LATIN_1", sizeof("LATIN_1") - 1, true); zend_declare_typed_class_constant(class_entry, const_LATIN_1_name, &const_LATIN_1_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LATIN_1_name); + zend_string_release_ex(const_LATIN_1_name, true); zval const_UTF8_value; ZVAL_LONG(&const_UTF8_value, UCNV_UTF8); - zend_string *const_UTF8_name = zend_string_init_interned("UTF8", sizeof("UTF8") - 1, 1); + zend_string *const_UTF8_name = zend_string_init_interned("UTF8", sizeof("UTF8") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF8_name, &const_UTF8_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF8_name); + zend_string_release_ex(const_UTF8_name, true); zval const_UTF16_BigEndian_value; ZVAL_LONG(&const_UTF16_BigEndian_value, UCNV_UTF16_BigEndian); - zend_string *const_UTF16_BigEndian_name = zend_string_init_interned("UTF16_BigEndian", sizeof("UTF16_BigEndian") - 1, 1); + zend_string *const_UTF16_BigEndian_name = zend_string_init_interned("UTF16_BigEndian", sizeof("UTF16_BigEndian") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF16_BigEndian_name, &const_UTF16_BigEndian_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF16_BigEndian_name); + zend_string_release_ex(const_UTF16_BigEndian_name, true); zval const_UTF16_LittleEndian_value; ZVAL_LONG(&const_UTF16_LittleEndian_value, UCNV_UTF16_LittleEndian); - zend_string *const_UTF16_LittleEndian_name = zend_string_init_interned("UTF16_LittleEndian", sizeof("UTF16_LittleEndian") - 1, 1); + zend_string *const_UTF16_LittleEndian_name = zend_string_init_interned("UTF16_LittleEndian", sizeof("UTF16_LittleEndian") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF16_LittleEndian_name, &const_UTF16_LittleEndian_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF16_LittleEndian_name); + zend_string_release_ex(const_UTF16_LittleEndian_name, true); zval const_UTF32_BigEndian_value; ZVAL_LONG(&const_UTF32_BigEndian_value, UCNV_UTF32_BigEndian); - zend_string *const_UTF32_BigEndian_name = zend_string_init_interned("UTF32_BigEndian", sizeof("UTF32_BigEndian") - 1, 1); + zend_string *const_UTF32_BigEndian_name = zend_string_init_interned("UTF32_BigEndian", sizeof("UTF32_BigEndian") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF32_BigEndian_name, &const_UTF32_BigEndian_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF32_BigEndian_name); + zend_string_release_ex(const_UTF32_BigEndian_name, true); zval const_UTF32_LittleEndian_value; ZVAL_LONG(&const_UTF32_LittleEndian_value, UCNV_UTF32_LittleEndian); - zend_string *const_UTF32_LittleEndian_name = zend_string_init_interned("UTF32_LittleEndian", sizeof("UTF32_LittleEndian") - 1, 1); + zend_string *const_UTF32_LittleEndian_name = zend_string_init_interned("UTF32_LittleEndian", sizeof("UTF32_LittleEndian") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF32_LittleEndian_name, &const_UTF32_LittleEndian_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF32_LittleEndian_name); + zend_string_release_ex(const_UTF32_LittleEndian_name, true); zval const_EBCDIC_STATEFUL_value; ZVAL_LONG(&const_EBCDIC_STATEFUL_value, UCNV_EBCDIC_STATEFUL); - zend_string *const_EBCDIC_STATEFUL_name = zend_string_init_interned("EBCDIC_STATEFUL", sizeof("EBCDIC_STATEFUL") - 1, 1); + zend_string *const_EBCDIC_STATEFUL_name = zend_string_init_interned("EBCDIC_STATEFUL", sizeof("EBCDIC_STATEFUL") - 1, true); zend_declare_typed_class_constant(class_entry, const_EBCDIC_STATEFUL_name, &const_EBCDIC_STATEFUL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EBCDIC_STATEFUL_name); + zend_string_release_ex(const_EBCDIC_STATEFUL_name, true); zval const_ISO_2022_value; ZVAL_LONG(&const_ISO_2022_value, UCNV_ISO_2022); - zend_string *const_ISO_2022_name = zend_string_init_interned("ISO_2022", sizeof("ISO_2022") - 1, 1); + zend_string *const_ISO_2022_name = zend_string_init_interned("ISO_2022", sizeof("ISO_2022") - 1, true); zend_declare_typed_class_constant(class_entry, const_ISO_2022_name, &const_ISO_2022_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ISO_2022_name); + zend_string_release_ex(const_ISO_2022_name, true); zval const_LMBCS_1_value; ZVAL_LONG(&const_LMBCS_1_value, UCNV_LMBCS_1); - zend_string *const_LMBCS_1_name = zend_string_init_interned("LMBCS_1", sizeof("LMBCS_1") - 1, 1); + zend_string *const_LMBCS_1_name = zend_string_init_interned("LMBCS_1", sizeof("LMBCS_1") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_1_name, &const_LMBCS_1_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_1_name); + zend_string_release_ex(const_LMBCS_1_name, true); zval const_LMBCS_2_value; ZVAL_LONG(&const_LMBCS_2_value, UCNV_LMBCS_2); - zend_string *const_LMBCS_2_name = zend_string_init_interned("LMBCS_2", sizeof("LMBCS_2") - 1, 1); + zend_string *const_LMBCS_2_name = zend_string_init_interned("LMBCS_2", sizeof("LMBCS_2") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_2_name, &const_LMBCS_2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_2_name); + zend_string_release_ex(const_LMBCS_2_name, true); zval const_LMBCS_3_value; ZVAL_LONG(&const_LMBCS_3_value, UCNV_LMBCS_3); - zend_string *const_LMBCS_3_name = zend_string_init_interned("LMBCS_3", sizeof("LMBCS_3") - 1, 1); + zend_string *const_LMBCS_3_name = zend_string_init_interned("LMBCS_3", sizeof("LMBCS_3") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_3_name, &const_LMBCS_3_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_3_name); + zend_string_release_ex(const_LMBCS_3_name, true); zval const_LMBCS_4_value; ZVAL_LONG(&const_LMBCS_4_value, UCNV_LMBCS_4); - zend_string *const_LMBCS_4_name = zend_string_init_interned("LMBCS_4", sizeof("LMBCS_4") - 1, 1); + zend_string *const_LMBCS_4_name = zend_string_init_interned("LMBCS_4", sizeof("LMBCS_4") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_4_name, &const_LMBCS_4_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_4_name); + zend_string_release_ex(const_LMBCS_4_name, true); zval const_LMBCS_5_value; ZVAL_LONG(&const_LMBCS_5_value, UCNV_LMBCS_5); - zend_string *const_LMBCS_5_name = zend_string_init_interned("LMBCS_5", sizeof("LMBCS_5") - 1, 1); + zend_string *const_LMBCS_5_name = zend_string_init_interned("LMBCS_5", sizeof("LMBCS_5") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_5_name, &const_LMBCS_5_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_5_name); + zend_string_release_ex(const_LMBCS_5_name, true); zval const_LMBCS_6_value; ZVAL_LONG(&const_LMBCS_6_value, UCNV_LMBCS_6); - zend_string *const_LMBCS_6_name = zend_string_init_interned("LMBCS_6", sizeof("LMBCS_6") - 1, 1); + zend_string *const_LMBCS_6_name = zend_string_init_interned("LMBCS_6", sizeof("LMBCS_6") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_6_name, &const_LMBCS_6_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_6_name); + zend_string_release_ex(const_LMBCS_6_name, true); zval const_LMBCS_8_value; ZVAL_LONG(&const_LMBCS_8_value, UCNV_LMBCS_8); - zend_string *const_LMBCS_8_name = zend_string_init_interned("LMBCS_8", sizeof("LMBCS_8") - 1, 1); + zend_string *const_LMBCS_8_name = zend_string_init_interned("LMBCS_8", sizeof("LMBCS_8") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_8_name, &const_LMBCS_8_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_8_name); + zend_string_release_ex(const_LMBCS_8_name, true); zval const_LMBCS_11_value; ZVAL_LONG(&const_LMBCS_11_value, UCNV_LMBCS_11); - zend_string *const_LMBCS_11_name = zend_string_init_interned("LMBCS_11", sizeof("LMBCS_11") - 1, 1); + zend_string *const_LMBCS_11_name = zend_string_init_interned("LMBCS_11", sizeof("LMBCS_11") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_11_name, &const_LMBCS_11_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_11_name); + zend_string_release_ex(const_LMBCS_11_name, true); zval const_LMBCS_16_value; ZVAL_LONG(&const_LMBCS_16_value, UCNV_LMBCS_16); - zend_string *const_LMBCS_16_name = zend_string_init_interned("LMBCS_16", sizeof("LMBCS_16") - 1, 1); + zend_string *const_LMBCS_16_name = zend_string_init_interned("LMBCS_16", sizeof("LMBCS_16") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_16_name, &const_LMBCS_16_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_16_name); + zend_string_release_ex(const_LMBCS_16_name, true); zval const_LMBCS_17_value; ZVAL_LONG(&const_LMBCS_17_value, UCNV_LMBCS_17); - zend_string *const_LMBCS_17_name = zend_string_init_interned("LMBCS_17", sizeof("LMBCS_17") - 1, 1); + zend_string *const_LMBCS_17_name = zend_string_init_interned("LMBCS_17", sizeof("LMBCS_17") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_17_name, &const_LMBCS_17_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_17_name); + zend_string_release_ex(const_LMBCS_17_name, true); zval const_LMBCS_18_value; ZVAL_LONG(&const_LMBCS_18_value, UCNV_LMBCS_18); - zend_string *const_LMBCS_18_name = zend_string_init_interned("LMBCS_18", sizeof("LMBCS_18") - 1, 1); + zend_string *const_LMBCS_18_name = zend_string_init_interned("LMBCS_18", sizeof("LMBCS_18") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_18_name, &const_LMBCS_18_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_18_name); + zend_string_release_ex(const_LMBCS_18_name, true); zval const_LMBCS_19_value; ZVAL_LONG(&const_LMBCS_19_value, UCNV_LMBCS_19); - zend_string *const_LMBCS_19_name = zend_string_init_interned("LMBCS_19", sizeof("LMBCS_19") - 1, 1); + zend_string *const_LMBCS_19_name = zend_string_init_interned("LMBCS_19", sizeof("LMBCS_19") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_19_name, &const_LMBCS_19_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_19_name); + zend_string_release_ex(const_LMBCS_19_name, true); zval const_LMBCS_LAST_value; ZVAL_LONG(&const_LMBCS_LAST_value, UCNV_LMBCS_LAST); - zend_string *const_LMBCS_LAST_name = zend_string_init_interned("LMBCS_LAST", sizeof("LMBCS_LAST") - 1, 1); + zend_string *const_LMBCS_LAST_name = zend_string_init_interned("LMBCS_LAST", sizeof("LMBCS_LAST") - 1, true); zend_declare_typed_class_constant(class_entry, const_LMBCS_LAST_name, &const_LMBCS_LAST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LMBCS_LAST_name); + zend_string_release_ex(const_LMBCS_LAST_name, true); zval const_HZ_value; ZVAL_LONG(&const_HZ_value, UCNV_HZ); - zend_string *const_HZ_name = zend_string_init_interned("HZ", sizeof("HZ") - 1, 1); + zend_string *const_HZ_name = zend_string_init_interned("HZ", sizeof("HZ") - 1, true); zend_declare_typed_class_constant(class_entry, const_HZ_name, &const_HZ_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HZ_name); + zend_string_release_ex(const_HZ_name, true); zval const_SCSU_value; ZVAL_LONG(&const_SCSU_value, UCNV_SCSU); - zend_string *const_SCSU_name = zend_string_init_interned("SCSU", sizeof("SCSU") - 1, 1); + zend_string *const_SCSU_name = zend_string_init_interned("SCSU", sizeof("SCSU") - 1, true); zend_declare_typed_class_constant(class_entry, const_SCSU_name, &const_SCSU_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SCSU_name); + zend_string_release_ex(const_SCSU_name, true); zval const_ISCII_value; ZVAL_LONG(&const_ISCII_value, UCNV_ISCII); - zend_string *const_ISCII_name = zend_string_init_interned("ISCII", sizeof("ISCII") - 1, 1); + zend_string *const_ISCII_name = zend_string_init_interned("ISCII", sizeof("ISCII") - 1, true); zend_declare_typed_class_constant(class_entry, const_ISCII_name, &const_ISCII_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ISCII_name); + zend_string_release_ex(const_ISCII_name, true); zval const_US_ASCII_value; ZVAL_LONG(&const_US_ASCII_value, UCNV_US_ASCII); - zend_string *const_US_ASCII_name = zend_string_init_interned("US_ASCII", sizeof("US_ASCII") - 1, 1); + zend_string *const_US_ASCII_name = zend_string_init_interned("US_ASCII", sizeof("US_ASCII") - 1, true); zend_declare_typed_class_constant(class_entry, const_US_ASCII_name, &const_US_ASCII_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_US_ASCII_name); + zend_string_release_ex(const_US_ASCII_name, true); zval const_UTF7_value; ZVAL_LONG(&const_UTF7_value, UCNV_UTF7); - zend_string *const_UTF7_name = zend_string_init_interned("UTF7", sizeof("UTF7") - 1, 1); + zend_string *const_UTF7_name = zend_string_init_interned("UTF7", sizeof("UTF7") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF7_name, &const_UTF7_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF7_name); + zend_string_release_ex(const_UTF7_name, true); zval const_BOCU1_value; ZVAL_LONG(&const_BOCU1_value, UCNV_BOCU1); - zend_string *const_BOCU1_name = zend_string_init_interned("BOCU1", sizeof("BOCU1") - 1, 1); + zend_string *const_BOCU1_name = zend_string_init_interned("BOCU1", sizeof("BOCU1") - 1, true); zend_declare_typed_class_constant(class_entry, const_BOCU1_name, &const_BOCU1_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BOCU1_name); + zend_string_release_ex(const_BOCU1_name, true); zval const_UTF16_value; ZVAL_LONG(&const_UTF16_value, UCNV_UTF16); - zend_string *const_UTF16_name = zend_string_init_interned("UTF16", sizeof("UTF16") - 1, 1); + zend_string *const_UTF16_name = zend_string_init_interned("UTF16", sizeof("UTF16") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF16_name, &const_UTF16_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF16_name); + zend_string_release_ex(const_UTF16_name, true); zval const_UTF32_value; ZVAL_LONG(&const_UTF32_value, UCNV_UTF32); - zend_string *const_UTF32_name = zend_string_init_interned("UTF32", sizeof("UTF32") - 1, 1); + zend_string *const_UTF32_name = zend_string_init_interned("UTF32", sizeof("UTF32") - 1, true); zend_declare_typed_class_constant(class_entry, const_UTF32_name, &const_UTF32_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UTF32_name); + zend_string_release_ex(const_UTF32_name, true); zval const_CESU8_value; ZVAL_LONG(&const_CESU8_value, UCNV_CESU8); - zend_string *const_CESU8_name = zend_string_init_interned("CESU8", sizeof("CESU8") - 1, 1); + zend_string *const_CESU8_name = zend_string_init_interned("CESU8", sizeof("CESU8") - 1, true); zend_declare_typed_class_constant(class_entry, const_CESU8_name, &const_CESU8_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CESU8_name); + zend_string_release_ex(const_CESU8_name, true); zval const_IMAP_MAILBOX_value; ZVAL_LONG(&const_IMAP_MAILBOX_value, UCNV_IMAP_MAILBOX); - zend_string *const_IMAP_MAILBOX_name = zend_string_init_interned("IMAP_MAILBOX", sizeof("IMAP_MAILBOX") - 1, 1); + zend_string *const_IMAP_MAILBOX_name = zend_string_init_interned("IMAP_MAILBOX", sizeof("IMAP_MAILBOX") - 1, true); zend_declare_typed_class_constant(class_entry, const_IMAP_MAILBOX_name, &const_IMAP_MAILBOX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IMAP_MAILBOX_name); + zend_string_release_ex(const_IMAP_MAILBOX_name, true); return class_entry; } diff --git a/ext/intl/dateformat/dateformat.c b/ext/intl/dateformat/dateformat.cpp similarity index 94% rename from ext/intl/dateformat/dateformat.c rename to ext/intl/dateformat/dateformat.cpp index e6ebd5b789649..cf2b445590bb9 100644 --- a/ext/intl/dateformat/dateformat.c +++ b/ext/intl/dateformat/dateformat.cpp @@ -17,12 +17,14 @@ #include +extern "C" { #include "php_intl.h" +} #include "dateformat_class.h" #include "dateformat.h" /* {{{ Get formatter's last error code. */ -PHP_FUNCTION( datefmt_get_error_code ) +U_CFUNC PHP_FUNCTION( datefmt_get_error_code ) { DATE_FORMAT_METHOD_INIT_VARS; @@ -41,7 +43,7 @@ PHP_FUNCTION( datefmt_get_error_code ) /* }}} */ /* {{{ Get text description for formatter's last error code. */ -PHP_FUNCTION( datefmt_get_error_message ) +U_CFUNC PHP_FUNCTION( datefmt_get_error_message ) { zend_string *message = NULL; DATE_FORMAT_METHOD_INIT_VARS; diff --git a/ext/intl/dateformat/dateformat_arginfo.h b/ext/intl/dateformat/dateformat_arginfo.h index d6d0306506f81..5a5c6a9f34c29 100644 --- a/ext/intl/dateformat/dateformat_arginfo.h +++ b/ext/intl/dateformat/dateformat_arginfo.h @@ -149,75 +149,75 @@ static zend_class_entry *register_class_IntlDateFormatter(void) zval const_FULL_value; ZVAL_LONG(&const_FULL_value, UDAT_FULL); - zend_string *const_FULL_name = zend_string_init_interned("FULL", sizeof("FULL") - 1, 1); + zend_string *const_FULL_name = zend_string_init_interned("FULL", sizeof("FULL") - 1, true); zend_declare_typed_class_constant(class_entry, const_FULL_name, &const_FULL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FULL_name); + zend_string_release_ex(const_FULL_name, true); zval const_LONG_value; ZVAL_LONG(&const_LONG_value, UDAT_LONG); - zend_string *const_LONG_name = zend_string_init_interned("LONG", sizeof("LONG") - 1, 1); + zend_string *const_LONG_name = zend_string_init_interned("LONG", sizeof("LONG") - 1, true); zend_declare_typed_class_constant(class_entry, const_LONG_name, &const_LONG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LONG_name); + zend_string_release_ex(const_LONG_name, true); zval const_MEDIUM_value; ZVAL_LONG(&const_MEDIUM_value, UDAT_MEDIUM); - zend_string *const_MEDIUM_name = zend_string_init_interned("MEDIUM", sizeof("MEDIUM") - 1, 1); + zend_string *const_MEDIUM_name = zend_string_init_interned("MEDIUM", sizeof("MEDIUM") - 1, true); zend_declare_typed_class_constant(class_entry, const_MEDIUM_name, &const_MEDIUM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MEDIUM_name); + zend_string_release_ex(const_MEDIUM_name, true); zval const_SHORT_value; ZVAL_LONG(&const_SHORT_value, UDAT_SHORT); - zend_string *const_SHORT_name = zend_string_init_interned("SHORT", sizeof("SHORT") - 1, 1); + zend_string *const_SHORT_name = zend_string_init_interned("SHORT", sizeof("SHORT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SHORT_name, &const_SHORT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SHORT_name); + zend_string_release_ex(const_SHORT_name, true); zval const_NONE_value; ZVAL_LONG(&const_NONE_value, UDAT_NONE); - zend_string *const_NONE_name = zend_string_init_interned("NONE", sizeof("NONE") - 1, 1); + zend_string *const_NONE_name = zend_string_init_interned("NONE", sizeof("NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_NONE_name, &const_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NONE_name); + zend_string_release_ex(const_NONE_name, true); zval const_RELATIVE_FULL_value; ZVAL_LONG(&const_RELATIVE_FULL_value, UDAT_FULL_RELATIVE); - zend_string *const_RELATIVE_FULL_name = zend_string_init_interned("RELATIVE_FULL", sizeof("RELATIVE_FULL") - 1, 1); + zend_string *const_RELATIVE_FULL_name = zend_string_init_interned("RELATIVE_FULL", sizeof("RELATIVE_FULL") - 1, true); zend_declare_typed_class_constant(class_entry, const_RELATIVE_FULL_name, &const_RELATIVE_FULL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_RELATIVE_FULL_name); + zend_string_release_ex(const_RELATIVE_FULL_name, true); zval const_RELATIVE_LONG_value; ZVAL_LONG(&const_RELATIVE_LONG_value, UDAT_LONG_RELATIVE); - zend_string *const_RELATIVE_LONG_name = zend_string_init_interned("RELATIVE_LONG", sizeof("RELATIVE_LONG") - 1, 1); + zend_string *const_RELATIVE_LONG_name = zend_string_init_interned("RELATIVE_LONG", sizeof("RELATIVE_LONG") - 1, true); zend_declare_typed_class_constant(class_entry, const_RELATIVE_LONG_name, &const_RELATIVE_LONG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_RELATIVE_LONG_name); + zend_string_release_ex(const_RELATIVE_LONG_name, true); zval const_RELATIVE_MEDIUM_value; ZVAL_LONG(&const_RELATIVE_MEDIUM_value, UDAT_MEDIUM_RELATIVE); - zend_string *const_RELATIVE_MEDIUM_name = zend_string_init_interned("RELATIVE_MEDIUM", sizeof("RELATIVE_MEDIUM") - 1, 1); + zend_string *const_RELATIVE_MEDIUM_name = zend_string_init_interned("RELATIVE_MEDIUM", sizeof("RELATIVE_MEDIUM") - 1, true); zend_declare_typed_class_constant(class_entry, const_RELATIVE_MEDIUM_name, &const_RELATIVE_MEDIUM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_RELATIVE_MEDIUM_name); + zend_string_release_ex(const_RELATIVE_MEDIUM_name, true); zval const_RELATIVE_SHORT_value; ZVAL_LONG(&const_RELATIVE_SHORT_value, UDAT_SHORT_RELATIVE); - zend_string *const_RELATIVE_SHORT_name = zend_string_init_interned("RELATIVE_SHORT", sizeof("RELATIVE_SHORT") - 1, 1); + zend_string *const_RELATIVE_SHORT_name = zend_string_init_interned("RELATIVE_SHORT", sizeof("RELATIVE_SHORT") - 1, true); zend_declare_typed_class_constant(class_entry, const_RELATIVE_SHORT_name, &const_RELATIVE_SHORT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_RELATIVE_SHORT_name); + zend_string_release_ex(const_RELATIVE_SHORT_name, true); zval const_PATTERN_value; ZVAL_LONG(&const_PATTERN_value, UDAT_PATTERN); - zend_string *const_PATTERN_name = zend_string_init_interned("PATTERN", sizeof("PATTERN") - 1, 1); + zend_string *const_PATTERN_name = zend_string_init_interned("PATTERN", sizeof("PATTERN") - 1, true); zend_declare_typed_class_constant(class_entry, const_PATTERN_name, &const_PATTERN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PATTERN_name); + zend_string_release_ex(const_PATTERN_name, true); zval const_GREGORIAN_value; ZVAL_LONG(&const_GREGORIAN_value, UCAL_GREGORIAN); - zend_string *const_GREGORIAN_name = zend_string_init_interned("GREGORIAN", sizeof("GREGORIAN") - 1, 1); + zend_string *const_GREGORIAN_name = zend_string_init_interned("GREGORIAN", sizeof("GREGORIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_GREGORIAN_name, &const_GREGORIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GREGORIAN_name); + zend_string_release_ex(const_GREGORIAN_name, true); zval const_TRADITIONAL_value; ZVAL_LONG(&const_TRADITIONAL_value, UCAL_TRADITIONAL); - zend_string *const_TRADITIONAL_name = zend_string_init_interned("TRADITIONAL", sizeof("TRADITIONAL") - 1, 1); + zend_string *const_TRADITIONAL_name = zend_string_init_interned("TRADITIONAL", sizeof("TRADITIONAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_TRADITIONAL_name, &const_TRADITIONAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRADITIONAL_name); + zend_string_release_ex(const_TRADITIONAL_name, true); return class_entry; } diff --git a/ext/intl/dateformat/dateformat_attr.c b/ext/intl/dateformat/dateformat_attr.cpp similarity index 90% rename from ext/intl/dateformat/dateformat_attr.c rename to ext/intl/dateformat/dateformat_attr.cpp index 8032d758a939b..1ec55a806a7ca 100644 --- a/ext/intl/dateformat/dateformat_attr.c +++ b/ext/intl/dateformat/dateformat_attr.cpp @@ -15,16 +15,18 @@ #include #endif +extern "C" { #include "../php_intl.h" -#include "dateformat_class.h" #include "../intl_convert.h" +} +#include "dateformat_class.h" #include "dateformat_class.h" #include #include /* {{{ Get formatter datetype. */ -PHP_FUNCTION( datefmt_get_datetype ) +U_CFUNC PHP_FUNCTION( datefmt_get_datetype ) { DATE_FORMAT_METHOD_INIT_VARS; @@ -44,7 +46,7 @@ PHP_FUNCTION( datefmt_get_datetype ) /* }}} */ /* {{{ Get formatter timetype. */ -PHP_FUNCTION( datefmt_get_timetype ) +U_CFUNC PHP_FUNCTION( datefmt_get_timetype ) { DATE_FORMAT_METHOD_INIT_VARS; @@ -64,7 +66,7 @@ PHP_FUNCTION( datefmt_get_timetype ) /* }}} */ /* {{{ Get formatter pattern. */ -PHP_FUNCTION( datefmt_get_pattern ) +U_CFUNC PHP_FUNCTION( datefmt_get_pattern ) { UChar value_buf[64]; uint32_t length = USIZE( value_buf ); @@ -100,12 +102,12 @@ PHP_FUNCTION( datefmt_get_pattern ) /* }}} */ /* {{{ Set formatter pattern. */ -PHP_FUNCTION( datefmt_set_pattern ) +U_CFUNC PHP_FUNCTION( datefmt_set_pattern ) { - char* value = NULL; + char* value = nullptr; size_t value_len = 0; int32_t slength = 0; - UChar* svalue = NULL; + UChar* svalue = nullptr; bool is_pattern_localized = false; @@ -136,9 +138,9 @@ PHP_FUNCTION( datefmt_set_pattern ) /* }}} */ /* {{{ Get formatter locale. */ -PHP_FUNCTION( datefmt_get_locale ) +U_CFUNC PHP_FUNCTION( datefmt_get_locale ) { - char *loc; + const char *loc; zend_long loc_type =ULOC_ACTUAL_LOCALE; DATE_FORMAT_METHOD_INIT_VARS; @@ -154,14 +156,14 @@ PHP_FUNCTION( datefmt_get_locale ) /* Fetch the object. */ DATE_FORMAT_METHOD_FETCH_OBJECT; - loc = (char *)udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), loc_type,&INTL_DATA_ERROR_CODE(dfo)); + loc = udat_getLocaleByType(DATE_FORMAT_OBJECT(dfo), static_cast(loc_type),&INTL_DATA_ERROR_CODE(dfo)); INTL_METHOD_CHECK_STATUS(dfo, "Error getting locale"); RETURN_STRING(loc); } /* }}} */ /* {{{ Get formatter isLenient. */ -PHP_FUNCTION( datefmt_is_lenient ) +U_CFUNC PHP_FUNCTION( datefmt_is_lenient ) { DATE_FORMAT_METHOD_INIT_VARS; @@ -182,7 +184,7 @@ PHP_FUNCTION( datefmt_is_lenient ) /* }}} */ /* {{{ Set formatter lenient. */ -PHP_FUNCTION( datefmt_set_lenient ) +U_CFUNC PHP_FUNCTION( datefmt_set_lenient ) { bool isLenient = false; diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.cpp similarity index 95% rename from ext/intl/dateformat/dateformat_class.c rename to ext/intl/dateformat/dateformat_class.cpp index 15bf5bf23ce57..b6ccf97990073 100644 --- a/ext/intl/dateformat/dateformat_class.c +++ b/ext/intl/dateformat/dateformat_class.cpp @@ -11,13 +11,15 @@ | Authors: Kirti Velankar | +----------------------------------------------------------------------+ */ -#include +#include +extern "C" { #include "dateformat_class.h" #include "php_intl.h" #include "dateformat_data.h" #include "dateformat.h" #include "dateformat_arginfo.h" +} #include @@ -48,7 +50,7 @@ zend_object *IntlDateFormatter_object_create(zend_class_entry *ce) { IntlDateFormatter_object* intern; - intern = zend_object_alloc(sizeof(IntlDateFormatter_object), ce); + intern = reinterpret_cast(zend_object_alloc(sizeof(IntlDateFormatter_object), ce)); dateformat_data_init( &intern->datef_data ); zend_object_std_init( &intern->zo, ce ); object_properties_init(&intern->zo, ce); diff --git a/ext/intl/dateformat/dateformat_class.h b/ext/intl/dateformat/dateformat_class.h index 18afb55023b42..e722c40b4bd9f 100644 --- a/ext/intl/dateformat/dateformat_class.h +++ b/ext/intl/dateformat/dateformat_class.h @@ -16,9 +16,15 @@ #include +#ifdef __cplusplus +extern "C" { +#endif #include "intl_common.h" #include "intl_error.h" #include "intl_data.h" +#ifdef __cplusplus +} +#endif #include "dateformat_data.h" typedef struct { @@ -35,8 +41,14 @@ static inline IntlDateFormatter_object *php_intl_dateformatter_fetch_object(zend } #define Z_INTL_DATEFORMATTER_P(zv) php_intl_dateformatter_fetch_object(Z_OBJ_P(zv)) +#ifdef __cplusplus +extern "C" { +#endif void dateformat_register_IntlDateFormatter_class( void ); extern zend_class_entry *IntlDateFormatter_ce_ptr; +#ifdef __cplusplus +} +#endif /* Auxiliary macros */ diff --git a/ext/intl/dateformat/dateformat_data.c b/ext/intl/dateformat/dateformat_data.cpp similarity index 91% rename from ext/intl/dateformat/dateformat_data.c rename to ext/intl/dateformat/dateformat_data.cpp index 9c12af6fb6059..42e7c9522055f 100644 --- a/ext/intl/dateformat/dateformat_data.c +++ b/ext/intl/dateformat/dateformat_data.cpp @@ -25,7 +25,7 @@ void dateformat_data_init( dateformat_data* datef_data ) if( !datef_data ) return; - datef_data->udatf = NULL; + datef_data->udatf = nullptr; intl_error_reset( &datef_data->error ); } /* }}} */ @@ -41,7 +41,7 @@ void dateformat_data_free( dateformat_data* datef_data ) if( datef_data->udatf ) udat_close( datef_data->udatf ); - datef_data->udatf = NULL; + datef_data->udatf = nullptr; intl_error_reset( &datef_data->error ); } /* }}} */ @@ -51,7 +51,7 @@ void dateformat_data_free( dateformat_data* datef_data ) */ dateformat_data* dateformat_data_create( void ) { - dateformat_data* datef_data = ecalloc( 1, sizeof(dateformat_data) ); + dateformat_data* datef_data = reinterpret_cast(ecalloc( 1, sizeof(dateformat_data) )); dateformat_data_init( datef_data ); diff --git a/ext/intl/dateformat/dateformat_data.h b/ext/intl/dateformat/dateformat_data.h index 4007d1344fbb6..962ffbade31d8 100644 --- a/ext/intl/dateformat/dateformat_data.h +++ b/ext/intl/dateformat/dateformat_data.h @@ -18,7 +18,13 @@ #include +#ifdef __cplusplus +extern "C" { +#endif #include "intl_error.h" +#ifdef __cplusplus +} +#endif typedef struct { // error handling @@ -28,8 +34,14 @@ typedef struct { UDateFormat * udatf; } dateformat_data; +#ifdef __cplusplus +extern "C" { +#endif dateformat_data* dateformat_data_create( void ); void dateformat_data_init( dateformat_data* datef_data ); void dateformat_data_free( dateformat_data* datef_data ); +#ifdef __cplusplus +} +#endif #endif // DATE_FORMAT_DATA_H diff --git a/ext/intl/dateformat/dateformat_format.c b/ext/intl/dateformat/dateformat_format.cpp similarity index 98% rename from ext/intl/dateformat/dateformat_format.c rename to ext/intl/dateformat/dateformat_format.cpp index ee3abd052d669..30570a5887c17 100644 --- a/ext/intl/dateformat/dateformat_format.c +++ b/ext/intl/dateformat/dateformat_format.cpp @@ -16,12 +16,14 @@ #include #endif -#include "../php_intl.h" - #include -#include +#include +extern "C" { +#include "../php_intl.h" #include "../intl_convert.h" +} + #include "../common/common_date.h" #include "dateformat.h" #include "dateformat_class.h" @@ -137,7 +139,7 @@ static UDate internal_get_timestamp(IntlDateFormatter_object *dfo, /* {{{ Format the time value as a string. */ -PHP_FUNCTION(datefmt_format) +U_CFUNC PHP_FUNCTION(datefmt_format) { UDate timestamp = 0; HashTable *hash_arr = NULL; diff --git a/ext/intl/dateformat/dateformat_parse.c b/ext/intl/dateformat/dateformat_parse.cpp similarity index 96% rename from ext/intl/dateformat/dateformat_parse.c rename to ext/intl/dateformat/dateformat_parse.cpp index b6e9f7c92eb6f..a82a20a42f969 100644 --- a/ext/intl/dateformat/dateformat_parse.c +++ b/ext/intl/dateformat/dateformat_parse.cpp @@ -19,8 +19,10 @@ #include #include +extern "C" { #include "php_intl.h" #include "intl_convert.h" +} #include "dateformat.h" #include "dateformat_class.h" #include "dateformat_data.h" @@ -70,7 +72,7 @@ static void internal_parse_to_timestamp(IntlDateFormatter_object *dfo, char* tex static void add_to_localtime_arr( IntlDateFormatter_object *dfo, zval* return_value, const UCalendar *parsed_calendar, zend_long calendar_field, char* key_name) { - zend_long calendar_field_val = ucal_get( parsed_calendar, calendar_field, &INTL_DATA_ERROR_CODE(dfo)); + zend_long calendar_field_val = ucal_get( parsed_calendar, static_cast(calendar_field), &INTL_DATA_ERROR_CODE(dfo)); INTL_METHOD_CHECK_STATUS( dfo, "Date parsing - localtime failed : could not get a field from calendar" ); if( strcmp(key_name, CALENDAR_YEAR )==0 ){ @@ -126,7 +128,7 @@ static void internal_parse_to_localtime(IntlDateFormatter_object *dfo, char* tex /* {{{ Parse the string $value starting at parse_pos to a Unix timestamp -int */ -PHP_FUNCTION(datefmt_parse) +U_CFUNC PHP_FUNCTION(datefmt_parse) { char* text_to_parse = NULL; size_t text_len =0; @@ -165,7 +167,7 @@ PHP_FUNCTION(datefmt_parse) } /* }}} */ -PHP_METHOD(IntlDateFormatter, parseToCalendar) +U_CFUNC PHP_METHOD(IntlDateFormatter, parseToCalendar) { zend_string *text_to_parse = NULL; zval* z_parse_pos = NULL; @@ -208,7 +210,7 @@ PHP_METHOD(IntlDateFormatter, parseToCalendar) } /* {{{ Parse the string $value to a localtime array */ -PHP_FUNCTION(datefmt_localtime) +U_CFUNC PHP_FUNCTION(datefmt_localtime) { char* text_to_parse = NULL; size_t text_len =0; diff --git a/ext/intl/formatter/formatter_arginfo.h b/ext/intl/formatter/formatter_arginfo.h index ce9de964e77b1..df111763f8b96 100644 --- a/ext/intl/formatter/formatter_arginfo.h +++ b/ext/intl/formatter/formatter_arginfo.h @@ -127,503 +127,503 @@ static zend_class_entry *register_class_NumberFormatter(void) zval const_PATTERN_DECIMAL_value; ZVAL_LONG(&const_PATTERN_DECIMAL_value, UNUM_PATTERN_DECIMAL); - zend_string *const_PATTERN_DECIMAL_name = zend_string_init_interned("PATTERN_DECIMAL", sizeof("PATTERN_DECIMAL") - 1, 1); + zend_string *const_PATTERN_DECIMAL_name = zend_string_init_interned("PATTERN_DECIMAL", sizeof("PATTERN_DECIMAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PATTERN_DECIMAL_name, &const_PATTERN_DECIMAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PATTERN_DECIMAL_name); + zend_string_release_ex(const_PATTERN_DECIMAL_name, true); zval const_DECIMAL_value; ZVAL_LONG(&const_DECIMAL_value, UNUM_DECIMAL); - zend_string *const_DECIMAL_name = zend_string_init_interned("DECIMAL", sizeof("DECIMAL") - 1, 1); + zend_string *const_DECIMAL_name = zend_string_init_interned("DECIMAL", sizeof("DECIMAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DECIMAL_name, &const_DECIMAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DECIMAL_name); + zend_string_release_ex(const_DECIMAL_name, true); zval const_DECIMAL_COMPACT_SHORT_value; ZVAL_LONG(&const_DECIMAL_COMPACT_SHORT_value, UNUM_DECIMAL_COMPACT_SHORT); - zend_string *const_DECIMAL_COMPACT_SHORT_name = zend_string_init_interned("DECIMAL_COMPACT_SHORT", sizeof("DECIMAL_COMPACT_SHORT") - 1, 1); + zend_string *const_DECIMAL_COMPACT_SHORT_name = zend_string_init_interned("DECIMAL_COMPACT_SHORT", sizeof("DECIMAL_COMPACT_SHORT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DECIMAL_COMPACT_SHORT_name, &const_DECIMAL_COMPACT_SHORT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DECIMAL_COMPACT_SHORT_name); + zend_string_release_ex(const_DECIMAL_COMPACT_SHORT_name, true); zval const_DECIMAL_COMPACT_LONG_value; ZVAL_LONG(&const_DECIMAL_COMPACT_LONG_value, UNUM_DECIMAL_COMPACT_LONG); - zend_string *const_DECIMAL_COMPACT_LONG_name = zend_string_init_interned("DECIMAL_COMPACT_LONG", sizeof("DECIMAL_COMPACT_LONG") - 1, 1); + zend_string *const_DECIMAL_COMPACT_LONG_name = zend_string_init_interned("DECIMAL_COMPACT_LONG", sizeof("DECIMAL_COMPACT_LONG") - 1, true); zend_declare_typed_class_constant(class_entry, const_DECIMAL_COMPACT_LONG_name, &const_DECIMAL_COMPACT_LONG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DECIMAL_COMPACT_LONG_name); + zend_string_release_ex(const_DECIMAL_COMPACT_LONG_name, true); zval const_CURRENCY_value; ZVAL_LONG(&const_CURRENCY_value, UNUM_CURRENCY); - zend_string *const_CURRENCY_name = zend_string_init_interned("CURRENCY", sizeof("CURRENCY") - 1, 1); + zend_string *const_CURRENCY_name = zend_string_init_interned("CURRENCY", sizeof("CURRENCY") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENCY_name, &const_CURRENCY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENCY_name); + zend_string_release_ex(const_CURRENCY_name, true); zval const_PERCENT_value; ZVAL_LONG(&const_PERCENT_value, UNUM_PERCENT); - zend_string *const_PERCENT_name = zend_string_init_interned("PERCENT", sizeof("PERCENT") - 1, 1); + zend_string *const_PERCENT_name = zend_string_init_interned("PERCENT", sizeof("PERCENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PERCENT_name, &const_PERCENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PERCENT_name); + zend_string_release_ex(const_PERCENT_name, true); zval const_SCIENTIFIC_value; ZVAL_LONG(&const_SCIENTIFIC_value, UNUM_SCIENTIFIC); - zend_string *const_SCIENTIFIC_name = zend_string_init_interned("SCIENTIFIC", sizeof("SCIENTIFIC") - 1, 1); + zend_string *const_SCIENTIFIC_name = zend_string_init_interned("SCIENTIFIC", sizeof("SCIENTIFIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_SCIENTIFIC_name, &const_SCIENTIFIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SCIENTIFIC_name); + zend_string_release_ex(const_SCIENTIFIC_name, true); zval const_SPELLOUT_value; ZVAL_LONG(&const_SPELLOUT_value, UNUM_SPELLOUT); - zend_string *const_SPELLOUT_name = zend_string_init_interned("SPELLOUT", sizeof("SPELLOUT") - 1, 1); + zend_string *const_SPELLOUT_name = zend_string_init_interned("SPELLOUT", sizeof("SPELLOUT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SPELLOUT_name, &const_SPELLOUT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SPELLOUT_name); + zend_string_release_ex(const_SPELLOUT_name, true); zval const_ORDINAL_value; ZVAL_LONG(&const_ORDINAL_value, UNUM_ORDINAL); - zend_string *const_ORDINAL_name = zend_string_init_interned("ORDINAL", sizeof("ORDINAL") - 1, 1); + zend_string *const_ORDINAL_name = zend_string_init_interned("ORDINAL", sizeof("ORDINAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ORDINAL_name, &const_ORDINAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ORDINAL_name); + zend_string_release_ex(const_ORDINAL_name, true); zval const_DURATION_value; ZVAL_LONG(&const_DURATION_value, UNUM_DURATION); - zend_string *const_DURATION_name = zend_string_init_interned("DURATION", sizeof("DURATION") - 1, 1); + zend_string *const_DURATION_name = zend_string_init_interned("DURATION", sizeof("DURATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_DURATION_name, &const_DURATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DURATION_name); + zend_string_release_ex(const_DURATION_name, true); zval const_PATTERN_RULEBASED_value; ZVAL_LONG(&const_PATTERN_RULEBASED_value, UNUM_PATTERN_RULEBASED); - zend_string *const_PATTERN_RULEBASED_name = zend_string_init_interned("PATTERN_RULEBASED", sizeof("PATTERN_RULEBASED") - 1, 1); + zend_string *const_PATTERN_RULEBASED_name = zend_string_init_interned("PATTERN_RULEBASED", sizeof("PATTERN_RULEBASED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PATTERN_RULEBASED_name, &const_PATTERN_RULEBASED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PATTERN_RULEBASED_name); + zend_string_release_ex(const_PATTERN_RULEBASED_name, true); zval const_IGNORE_value; ZVAL_LONG(&const_IGNORE_value, UNUM_IGNORE); - zend_string *const_IGNORE_name = zend_string_init_interned("IGNORE", sizeof("IGNORE") - 1, 1); + zend_string *const_IGNORE_name = zend_string_init_interned("IGNORE", sizeof("IGNORE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IGNORE_name, &const_IGNORE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IGNORE_name); + zend_string_release_ex(const_IGNORE_name, true); zval const_CURRENCY_ISO_value; ZVAL_LONG(&const_CURRENCY_ISO_value, UNUM_CURRENCY_ISO); - zend_string *const_CURRENCY_ISO_name = zend_string_init_interned("CURRENCY_ISO", sizeof("CURRENCY_ISO") - 1, 1); + zend_string *const_CURRENCY_ISO_name = zend_string_init_interned("CURRENCY_ISO", sizeof("CURRENCY_ISO") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENCY_ISO_name, &const_CURRENCY_ISO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENCY_ISO_name); + zend_string_release_ex(const_CURRENCY_ISO_name, true); zval const_CURRENCY_PLURAL_value; ZVAL_LONG(&const_CURRENCY_PLURAL_value, UNUM_CURRENCY_PLURAL); - zend_string *const_CURRENCY_PLURAL_name = zend_string_init_interned("CURRENCY_PLURAL", sizeof("CURRENCY_PLURAL") - 1, 1); + zend_string *const_CURRENCY_PLURAL_name = zend_string_init_interned("CURRENCY_PLURAL", sizeof("CURRENCY_PLURAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENCY_PLURAL_name, &const_CURRENCY_PLURAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENCY_PLURAL_name); + zend_string_release_ex(const_CURRENCY_PLURAL_name, true); zval const_CURRENCY_ACCOUNTING_value; ZVAL_LONG(&const_CURRENCY_ACCOUNTING_value, UNUM_CURRENCY_ACCOUNTING); - zend_string *const_CURRENCY_ACCOUNTING_name = zend_string_init_interned("CURRENCY_ACCOUNTING", sizeof("CURRENCY_ACCOUNTING") - 1, 1); + zend_string *const_CURRENCY_ACCOUNTING_name = zend_string_init_interned("CURRENCY_ACCOUNTING", sizeof("CURRENCY_ACCOUNTING") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENCY_ACCOUNTING_name, &const_CURRENCY_ACCOUNTING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENCY_ACCOUNTING_name); + zend_string_release_ex(const_CURRENCY_ACCOUNTING_name, true); zval const_CASH_CURRENCY_value; ZVAL_LONG(&const_CASH_CURRENCY_value, UNUM_CASH_CURRENCY); - zend_string *const_CASH_CURRENCY_name = zend_string_init_interned("CASH_CURRENCY", sizeof("CASH_CURRENCY") - 1, 1); + zend_string *const_CASH_CURRENCY_name = zend_string_init_interned("CASH_CURRENCY", sizeof("CASH_CURRENCY") - 1, true); zend_declare_typed_class_constant(class_entry, const_CASH_CURRENCY_name, &const_CASH_CURRENCY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CASH_CURRENCY_name); + zend_string_release_ex(const_CASH_CURRENCY_name, true); zval const_CURRENCY_STANDARD_value; ZVAL_LONG(&const_CURRENCY_STANDARD_value, UNUM_CURRENCY_STANDARD); - zend_string *const_CURRENCY_STANDARD_name = zend_string_init_interned("CURRENCY_STANDARD", sizeof("CURRENCY_STANDARD") - 1, 1); + zend_string *const_CURRENCY_STANDARD_name = zend_string_init_interned("CURRENCY_STANDARD", sizeof("CURRENCY_STANDARD") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENCY_STANDARD_name, &const_CURRENCY_STANDARD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENCY_STANDARD_name); + zend_string_release_ex(const_CURRENCY_STANDARD_name, true); zval const_DEFAULT_STYLE_value; ZVAL_LONG(&const_DEFAULT_STYLE_value, UNUM_DEFAULT); - zend_string *const_DEFAULT_STYLE_name = zend_string_init_interned("DEFAULT_STYLE", sizeof("DEFAULT_STYLE") - 1, 1); + zend_string *const_DEFAULT_STYLE_name = zend_string_init_interned("DEFAULT_STYLE", sizeof("DEFAULT_STYLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DEFAULT_STYLE_name, &const_DEFAULT_STYLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DEFAULT_STYLE_name); + zend_string_release_ex(const_DEFAULT_STYLE_name, true); zval const_ROUND_CEILING_value; ZVAL_LONG(&const_ROUND_CEILING_value, UNUM_ROUND_CEILING); - zend_string *const_ROUND_CEILING_name = zend_string_init_interned("ROUND_CEILING", sizeof("ROUND_CEILING") - 1, 1); + zend_string *const_ROUND_CEILING_name = zend_string_init_interned("ROUND_CEILING", sizeof("ROUND_CEILING") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_CEILING_name, &const_ROUND_CEILING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_CEILING_name); + zend_string_release_ex(const_ROUND_CEILING_name, true); zval const_ROUND_FLOOR_value; ZVAL_LONG(&const_ROUND_FLOOR_value, UNUM_ROUND_FLOOR); - zend_string *const_ROUND_FLOOR_name = zend_string_init_interned("ROUND_FLOOR", sizeof("ROUND_FLOOR") - 1, 1); + zend_string *const_ROUND_FLOOR_name = zend_string_init_interned("ROUND_FLOOR", sizeof("ROUND_FLOOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_FLOOR_name, &const_ROUND_FLOOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_FLOOR_name); + zend_string_release_ex(const_ROUND_FLOOR_name, true); zval const_ROUND_DOWN_value; ZVAL_LONG(&const_ROUND_DOWN_value, UNUM_ROUND_DOWN); - zend_string *const_ROUND_DOWN_name = zend_string_init_interned("ROUND_DOWN", sizeof("ROUND_DOWN") - 1, 1); + zend_string *const_ROUND_DOWN_name = zend_string_init_interned("ROUND_DOWN", sizeof("ROUND_DOWN") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_DOWN_name, &const_ROUND_DOWN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_DOWN_name); + zend_string_release_ex(const_ROUND_DOWN_name, true); zval const_ROUND_UP_value; ZVAL_LONG(&const_ROUND_UP_value, UNUM_ROUND_UP); - zend_string *const_ROUND_UP_name = zend_string_init_interned("ROUND_UP", sizeof("ROUND_UP") - 1, 1); + zend_string *const_ROUND_UP_name = zend_string_init_interned("ROUND_UP", sizeof("ROUND_UP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_UP_name, &const_ROUND_UP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_UP_name); + zend_string_release_ex(const_ROUND_UP_name, true); zval const_ROUND_TOWARD_ZERO_value; ZVAL_LONG(&const_ROUND_TOWARD_ZERO_value, UNUM_ROUND_DOWN); - zend_string *const_ROUND_TOWARD_ZERO_name = zend_string_init_interned("ROUND_TOWARD_ZERO", sizeof("ROUND_TOWARD_ZERO") - 1, 1); + zend_string *const_ROUND_TOWARD_ZERO_name = zend_string_init_interned("ROUND_TOWARD_ZERO", sizeof("ROUND_TOWARD_ZERO") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_TOWARD_ZERO_name, &const_ROUND_TOWARD_ZERO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_TOWARD_ZERO_name); + zend_string_release_ex(const_ROUND_TOWARD_ZERO_name, true); zval const_ROUND_AWAY_FROM_ZERO_value; ZVAL_LONG(&const_ROUND_AWAY_FROM_ZERO_value, UNUM_ROUND_UP); - zend_string *const_ROUND_AWAY_FROM_ZERO_name = zend_string_init_interned("ROUND_AWAY_FROM_ZERO", sizeof("ROUND_AWAY_FROM_ZERO") - 1, 1); + zend_string *const_ROUND_AWAY_FROM_ZERO_name = zend_string_init_interned("ROUND_AWAY_FROM_ZERO", sizeof("ROUND_AWAY_FROM_ZERO") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_AWAY_FROM_ZERO_name, &const_ROUND_AWAY_FROM_ZERO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_AWAY_FROM_ZERO_name); + zend_string_release_ex(const_ROUND_AWAY_FROM_ZERO_name, true); zval const_ROUND_HALFEVEN_value; ZVAL_LONG(&const_ROUND_HALFEVEN_value, UNUM_ROUND_HALFEVEN); - zend_string *const_ROUND_HALFEVEN_name = zend_string_init_interned("ROUND_HALFEVEN", sizeof("ROUND_HALFEVEN") - 1, 1); + zend_string *const_ROUND_HALFEVEN_name = zend_string_init_interned("ROUND_HALFEVEN", sizeof("ROUND_HALFEVEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_HALFEVEN_name, &const_ROUND_HALFEVEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_HALFEVEN_name); + zend_string_release_ex(const_ROUND_HALFEVEN_name, true); #if U_ICU_VERSION_MAJOR_NUM >= 69 zval const_ROUND_HALFODD_value; ZVAL_LONG(&const_ROUND_HALFODD_value, UNUM_ROUND_HALF_ODD); - zend_string *const_ROUND_HALFODD_name = zend_string_init_interned("ROUND_HALFODD", sizeof("ROUND_HALFODD") - 1, 1); + zend_string *const_ROUND_HALFODD_name = zend_string_init_interned("ROUND_HALFODD", sizeof("ROUND_HALFODD") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_HALFODD_name, &const_ROUND_HALFODD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_HALFODD_name); + zend_string_release_ex(const_ROUND_HALFODD_name, true); #endif zval const_ROUND_HALFDOWN_value; ZVAL_LONG(&const_ROUND_HALFDOWN_value, UNUM_ROUND_HALFDOWN); - zend_string *const_ROUND_HALFDOWN_name = zend_string_init_interned("ROUND_HALFDOWN", sizeof("ROUND_HALFDOWN") - 1, 1); + zend_string *const_ROUND_HALFDOWN_name = zend_string_init_interned("ROUND_HALFDOWN", sizeof("ROUND_HALFDOWN") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_HALFDOWN_name, &const_ROUND_HALFDOWN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_HALFDOWN_name); + zend_string_release_ex(const_ROUND_HALFDOWN_name, true); zval const_ROUND_HALFUP_value; ZVAL_LONG(&const_ROUND_HALFUP_value, UNUM_ROUND_HALFUP); - zend_string *const_ROUND_HALFUP_name = zend_string_init_interned("ROUND_HALFUP", sizeof("ROUND_HALFUP") - 1, 1); + zend_string *const_ROUND_HALFUP_name = zend_string_init_interned("ROUND_HALFUP", sizeof("ROUND_HALFUP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUND_HALFUP_name, &const_ROUND_HALFUP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUND_HALFUP_name); + zend_string_release_ex(const_ROUND_HALFUP_name, true); zval const_PAD_BEFORE_PREFIX_value; ZVAL_LONG(&const_PAD_BEFORE_PREFIX_value, UNUM_PAD_BEFORE_PREFIX); - zend_string *const_PAD_BEFORE_PREFIX_name = zend_string_init_interned("PAD_BEFORE_PREFIX", sizeof("PAD_BEFORE_PREFIX") - 1, 1); + zend_string *const_PAD_BEFORE_PREFIX_name = zend_string_init_interned("PAD_BEFORE_PREFIX", sizeof("PAD_BEFORE_PREFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_PAD_BEFORE_PREFIX_name, &const_PAD_BEFORE_PREFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PAD_BEFORE_PREFIX_name); + zend_string_release_ex(const_PAD_BEFORE_PREFIX_name, true); zval const_PAD_AFTER_PREFIX_value; ZVAL_LONG(&const_PAD_AFTER_PREFIX_value, UNUM_PAD_AFTER_PREFIX); - zend_string *const_PAD_AFTER_PREFIX_name = zend_string_init_interned("PAD_AFTER_PREFIX", sizeof("PAD_AFTER_PREFIX") - 1, 1); + zend_string *const_PAD_AFTER_PREFIX_name = zend_string_init_interned("PAD_AFTER_PREFIX", sizeof("PAD_AFTER_PREFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_PAD_AFTER_PREFIX_name, &const_PAD_AFTER_PREFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PAD_AFTER_PREFIX_name); + zend_string_release_ex(const_PAD_AFTER_PREFIX_name, true); zval const_PAD_BEFORE_SUFFIX_value; ZVAL_LONG(&const_PAD_BEFORE_SUFFIX_value, UNUM_PAD_BEFORE_SUFFIX); - zend_string *const_PAD_BEFORE_SUFFIX_name = zend_string_init_interned("PAD_BEFORE_SUFFIX", sizeof("PAD_BEFORE_SUFFIX") - 1, 1); + zend_string *const_PAD_BEFORE_SUFFIX_name = zend_string_init_interned("PAD_BEFORE_SUFFIX", sizeof("PAD_BEFORE_SUFFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_PAD_BEFORE_SUFFIX_name, &const_PAD_BEFORE_SUFFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PAD_BEFORE_SUFFIX_name); + zend_string_release_ex(const_PAD_BEFORE_SUFFIX_name, true); zval const_PAD_AFTER_SUFFIX_value; ZVAL_LONG(&const_PAD_AFTER_SUFFIX_value, UNUM_PAD_AFTER_SUFFIX); - zend_string *const_PAD_AFTER_SUFFIX_name = zend_string_init_interned("PAD_AFTER_SUFFIX", sizeof("PAD_AFTER_SUFFIX") - 1, 1); + zend_string *const_PAD_AFTER_SUFFIX_name = zend_string_init_interned("PAD_AFTER_SUFFIX", sizeof("PAD_AFTER_SUFFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_PAD_AFTER_SUFFIX_name, &const_PAD_AFTER_SUFFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PAD_AFTER_SUFFIX_name); + zend_string_release_ex(const_PAD_AFTER_SUFFIX_name, true); zval const_PARSE_INT_ONLY_value; ZVAL_LONG(&const_PARSE_INT_ONLY_value, UNUM_PARSE_INT_ONLY); - zend_string *const_PARSE_INT_ONLY_name = zend_string_init_interned("PARSE_INT_ONLY", sizeof("PARSE_INT_ONLY") - 1, 1); + zend_string *const_PARSE_INT_ONLY_name = zend_string_init_interned("PARSE_INT_ONLY", sizeof("PARSE_INT_ONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARSE_INT_ONLY_name, &const_PARSE_INT_ONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARSE_INT_ONLY_name); + zend_string_release_ex(const_PARSE_INT_ONLY_name, true); zval const_GROUPING_USED_value; ZVAL_LONG(&const_GROUPING_USED_value, UNUM_GROUPING_USED); - zend_string *const_GROUPING_USED_name = zend_string_init_interned("GROUPING_USED", sizeof("GROUPING_USED") - 1, 1); + zend_string *const_GROUPING_USED_name = zend_string_init_interned("GROUPING_USED", sizeof("GROUPING_USED") - 1, true); zend_declare_typed_class_constant(class_entry, const_GROUPING_USED_name, &const_GROUPING_USED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GROUPING_USED_name); + zend_string_release_ex(const_GROUPING_USED_name, true); zval const_DECIMAL_ALWAYS_SHOWN_value; ZVAL_LONG(&const_DECIMAL_ALWAYS_SHOWN_value, UNUM_DECIMAL_ALWAYS_SHOWN); - zend_string *const_DECIMAL_ALWAYS_SHOWN_name = zend_string_init_interned("DECIMAL_ALWAYS_SHOWN", sizeof("DECIMAL_ALWAYS_SHOWN") - 1, 1); + zend_string *const_DECIMAL_ALWAYS_SHOWN_name = zend_string_init_interned("DECIMAL_ALWAYS_SHOWN", sizeof("DECIMAL_ALWAYS_SHOWN") - 1, true); zend_declare_typed_class_constant(class_entry, const_DECIMAL_ALWAYS_SHOWN_name, &const_DECIMAL_ALWAYS_SHOWN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DECIMAL_ALWAYS_SHOWN_name); + zend_string_release_ex(const_DECIMAL_ALWAYS_SHOWN_name, true); zval const_MAX_INTEGER_DIGITS_value; ZVAL_LONG(&const_MAX_INTEGER_DIGITS_value, UNUM_MAX_INTEGER_DIGITS); - zend_string *const_MAX_INTEGER_DIGITS_name = zend_string_init_interned("MAX_INTEGER_DIGITS", sizeof("MAX_INTEGER_DIGITS") - 1, 1); + zend_string *const_MAX_INTEGER_DIGITS_name = zend_string_init_interned("MAX_INTEGER_DIGITS", sizeof("MAX_INTEGER_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MAX_INTEGER_DIGITS_name, &const_MAX_INTEGER_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MAX_INTEGER_DIGITS_name); + zend_string_release_ex(const_MAX_INTEGER_DIGITS_name, true); zval const_MIN_INTEGER_DIGITS_value; ZVAL_LONG(&const_MIN_INTEGER_DIGITS_value, UNUM_MIN_INTEGER_DIGITS); - zend_string *const_MIN_INTEGER_DIGITS_name = zend_string_init_interned("MIN_INTEGER_DIGITS", sizeof("MIN_INTEGER_DIGITS") - 1, 1); + zend_string *const_MIN_INTEGER_DIGITS_name = zend_string_init_interned("MIN_INTEGER_DIGITS", sizeof("MIN_INTEGER_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIN_INTEGER_DIGITS_name, &const_MIN_INTEGER_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIN_INTEGER_DIGITS_name); + zend_string_release_ex(const_MIN_INTEGER_DIGITS_name, true); zval const_INTEGER_DIGITS_value; ZVAL_LONG(&const_INTEGER_DIGITS_value, UNUM_INTEGER_DIGITS); - zend_string *const_INTEGER_DIGITS_name = zend_string_init_interned("INTEGER_DIGITS", sizeof("INTEGER_DIGITS") - 1, 1); + zend_string *const_INTEGER_DIGITS_name = zend_string_init_interned("INTEGER_DIGITS", sizeof("INTEGER_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_INTEGER_DIGITS_name, &const_INTEGER_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INTEGER_DIGITS_name); + zend_string_release_ex(const_INTEGER_DIGITS_name, true); zval const_MAX_FRACTION_DIGITS_value; ZVAL_LONG(&const_MAX_FRACTION_DIGITS_value, UNUM_MAX_FRACTION_DIGITS); - zend_string *const_MAX_FRACTION_DIGITS_name = zend_string_init_interned("MAX_FRACTION_DIGITS", sizeof("MAX_FRACTION_DIGITS") - 1, 1); + zend_string *const_MAX_FRACTION_DIGITS_name = zend_string_init_interned("MAX_FRACTION_DIGITS", sizeof("MAX_FRACTION_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MAX_FRACTION_DIGITS_name, &const_MAX_FRACTION_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MAX_FRACTION_DIGITS_name); + zend_string_release_ex(const_MAX_FRACTION_DIGITS_name, true); zval const_MIN_FRACTION_DIGITS_value; ZVAL_LONG(&const_MIN_FRACTION_DIGITS_value, UNUM_MIN_FRACTION_DIGITS); - zend_string *const_MIN_FRACTION_DIGITS_name = zend_string_init_interned("MIN_FRACTION_DIGITS", sizeof("MIN_FRACTION_DIGITS") - 1, 1); + zend_string *const_MIN_FRACTION_DIGITS_name = zend_string_init_interned("MIN_FRACTION_DIGITS", sizeof("MIN_FRACTION_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIN_FRACTION_DIGITS_name, &const_MIN_FRACTION_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIN_FRACTION_DIGITS_name); + zend_string_release_ex(const_MIN_FRACTION_DIGITS_name, true); zval const_FRACTION_DIGITS_value; ZVAL_LONG(&const_FRACTION_DIGITS_value, UNUM_FRACTION_DIGITS); - zend_string *const_FRACTION_DIGITS_name = zend_string_init_interned("FRACTION_DIGITS", sizeof("FRACTION_DIGITS") - 1, 1); + zend_string *const_FRACTION_DIGITS_name = zend_string_init_interned("FRACTION_DIGITS", sizeof("FRACTION_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_FRACTION_DIGITS_name, &const_FRACTION_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FRACTION_DIGITS_name); + zend_string_release_ex(const_FRACTION_DIGITS_name, true); zval const_MULTIPLIER_value; ZVAL_LONG(&const_MULTIPLIER_value, UNUM_MULTIPLIER); - zend_string *const_MULTIPLIER_name = zend_string_init_interned("MULTIPLIER", sizeof("MULTIPLIER") - 1, 1); + zend_string *const_MULTIPLIER_name = zend_string_init_interned("MULTIPLIER", sizeof("MULTIPLIER") - 1, true); zend_declare_typed_class_constant(class_entry, const_MULTIPLIER_name, &const_MULTIPLIER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MULTIPLIER_name); + zend_string_release_ex(const_MULTIPLIER_name, true); zval const_GROUPING_SIZE_value; ZVAL_LONG(&const_GROUPING_SIZE_value, UNUM_GROUPING_SIZE); - zend_string *const_GROUPING_SIZE_name = zend_string_init_interned("GROUPING_SIZE", sizeof("GROUPING_SIZE") - 1, 1); + zend_string *const_GROUPING_SIZE_name = zend_string_init_interned("GROUPING_SIZE", sizeof("GROUPING_SIZE") - 1, true); zend_declare_typed_class_constant(class_entry, const_GROUPING_SIZE_name, &const_GROUPING_SIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GROUPING_SIZE_name); + zend_string_release_ex(const_GROUPING_SIZE_name, true); zval const_ROUNDING_MODE_value; ZVAL_LONG(&const_ROUNDING_MODE_value, UNUM_ROUNDING_MODE); - zend_string *const_ROUNDING_MODE_name = zend_string_init_interned("ROUNDING_MODE", sizeof("ROUNDING_MODE") - 1, 1); + zend_string *const_ROUNDING_MODE_name = zend_string_init_interned("ROUNDING_MODE", sizeof("ROUNDING_MODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUNDING_MODE_name, &const_ROUNDING_MODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUNDING_MODE_name); + zend_string_release_ex(const_ROUNDING_MODE_name, true); zval const_ROUNDING_INCREMENT_value; ZVAL_LONG(&const_ROUNDING_INCREMENT_value, UNUM_ROUNDING_INCREMENT); - zend_string *const_ROUNDING_INCREMENT_name = zend_string_init_interned("ROUNDING_INCREMENT", sizeof("ROUNDING_INCREMENT") - 1, 1); + zend_string *const_ROUNDING_INCREMENT_name = zend_string_init_interned("ROUNDING_INCREMENT", sizeof("ROUNDING_INCREMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ROUNDING_INCREMENT_name, &const_ROUNDING_INCREMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ROUNDING_INCREMENT_name); + zend_string_release_ex(const_ROUNDING_INCREMENT_name, true); zval const_FORMAT_WIDTH_value; ZVAL_LONG(&const_FORMAT_WIDTH_value, UNUM_FORMAT_WIDTH); - zend_string *const_FORMAT_WIDTH_name = zend_string_init_interned("FORMAT_WIDTH", sizeof("FORMAT_WIDTH") - 1, 1); + zend_string *const_FORMAT_WIDTH_name = zend_string_init_interned("FORMAT_WIDTH", sizeof("FORMAT_WIDTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_FORMAT_WIDTH_name, &const_FORMAT_WIDTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FORMAT_WIDTH_name); + zend_string_release_ex(const_FORMAT_WIDTH_name, true); zval const_PADDING_POSITION_value; ZVAL_LONG(&const_PADDING_POSITION_value, UNUM_PADDING_POSITION); - zend_string *const_PADDING_POSITION_name = zend_string_init_interned("PADDING_POSITION", sizeof("PADDING_POSITION") - 1, 1); + zend_string *const_PADDING_POSITION_name = zend_string_init_interned("PADDING_POSITION", sizeof("PADDING_POSITION") - 1, true); zend_declare_typed_class_constant(class_entry, const_PADDING_POSITION_name, &const_PADDING_POSITION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PADDING_POSITION_name); + zend_string_release_ex(const_PADDING_POSITION_name, true); zval const_SECONDARY_GROUPING_SIZE_value; ZVAL_LONG(&const_SECONDARY_GROUPING_SIZE_value, UNUM_SECONDARY_GROUPING_SIZE); - zend_string *const_SECONDARY_GROUPING_SIZE_name = zend_string_init_interned("SECONDARY_GROUPING_SIZE", sizeof("SECONDARY_GROUPING_SIZE") - 1, 1); + zend_string *const_SECONDARY_GROUPING_SIZE_name = zend_string_init_interned("SECONDARY_GROUPING_SIZE", sizeof("SECONDARY_GROUPING_SIZE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SECONDARY_GROUPING_SIZE_name, &const_SECONDARY_GROUPING_SIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SECONDARY_GROUPING_SIZE_name); + zend_string_release_ex(const_SECONDARY_GROUPING_SIZE_name, true); zval const_SIGNIFICANT_DIGITS_USED_value; ZVAL_LONG(&const_SIGNIFICANT_DIGITS_USED_value, UNUM_SIGNIFICANT_DIGITS_USED); - zend_string *const_SIGNIFICANT_DIGITS_USED_name = zend_string_init_interned("SIGNIFICANT_DIGITS_USED", sizeof("SIGNIFICANT_DIGITS_USED") - 1, 1); + zend_string *const_SIGNIFICANT_DIGITS_USED_name = zend_string_init_interned("SIGNIFICANT_DIGITS_USED", sizeof("SIGNIFICANT_DIGITS_USED") - 1, true); zend_declare_typed_class_constant(class_entry, const_SIGNIFICANT_DIGITS_USED_name, &const_SIGNIFICANT_DIGITS_USED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SIGNIFICANT_DIGITS_USED_name); + zend_string_release_ex(const_SIGNIFICANT_DIGITS_USED_name, true); zval const_MIN_SIGNIFICANT_DIGITS_value; ZVAL_LONG(&const_MIN_SIGNIFICANT_DIGITS_value, UNUM_MIN_SIGNIFICANT_DIGITS); - zend_string *const_MIN_SIGNIFICANT_DIGITS_name = zend_string_init_interned("MIN_SIGNIFICANT_DIGITS", sizeof("MIN_SIGNIFICANT_DIGITS") - 1, 1); + zend_string *const_MIN_SIGNIFICANT_DIGITS_name = zend_string_init_interned("MIN_SIGNIFICANT_DIGITS", sizeof("MIN_SIGNIFICANT_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIN_SIGNIFICANT_DIGITS_name, &const_MIN_SIGNIFICANT_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIN_SIGNIFICANT_DIGITS_name); + zend_string_release_ex(const_MIN_SIGNIFICANT_DIGITS_name, true); zval const_MAX_SIGNIFICANT_DIGITS_value; ZVAL_LONG(&const_MAX_SIGNIFICANT_DIGITS_value, UNUM_MAX_SIGNIFICANT_DIGITS); - zend_string *const_MAX_SIGNIFICANT_DIGITS_name = zend_string_init_interned("MAX_SIGNIFICANT_DIGITS", sizeof("MAX_SIGNIFICANT_DIGITS") - 1, 1); + zend_string *const_MAX_SIGNIFICANT_DIGITS_name = zend_string_init_interned("MAX_SIGNIFICANT_DIGITS", sizeof("MAX_SIGNIFICANT_DIGITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MAX_SIGNIFICANT_DIGITS_name, &const_MAX_SIGNIFICANT_DIGITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MAX_SIGNIFICANT_DIGITS_name); + zend_string_release_ex(const_MAX_SIGNIFICANT_DIGITS_name, true); zval const_LENIENT_PARSE_value; ZVAL_LONG(&const_LENIENT_PARSE_value, UNUM_LENIENT_PARSE); - zend_string *const_LENIENT_PARSE_name = zend_string_init_interned("LENIENT_PARSE", sizeof("LENIENT_PARSE") - 1, 1); + zend_string *const_LENIENT_PARSE_name = zend_string_init_interned("LENIENT_PARSE", sizeof("LENIENT_PARSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LENIENT_PARSE_name, &const_LENIENT_PARSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LENIENT_PARSE_name); + zend_string_release_ex(const_LENIENT_PARSE_name, true); zval const_POSITIVE_PREFIX_value; ZVAL_LONG(&const_POSITIVE_PREFIX_value, UNUM_POSITIVE_PREFIX); - zend_string *const_POSITIVE_PREFIX_name = zend_string_init_interned("POSITIVE_PREFIX", sizeof("POSITIVE_PREFIX") - 1, 1); + zend_string *const_POSITIVE_PREFIX_name = zend_string_init_interned("POSITIVE_PREFIX", sizeof("POSITIVE_PREFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_POSITIVE_PREFIX_name, &const_POSITIVE_PREFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_POSITIVE_PREFIX_name); + zend_string_release_ex(const_POSITIVE_PREFIX_name, true); zval const_POSITIVE_SUFFIX_value; ZVAL_LONG(&const_POSITIVE_SUFFIX_value, UNUM_POSITIVE_SUFFIX); - zend_string *const_POSITIVE_SUFFIX_name = zend_string_init_interned("POSITIVE_SUFFIX", sizeof("POSITIVE_SUFFIX") - 1, 1); + zend_string *const_POSITIVE_SUFFIX_name = zend_string_init_interned("POSITIVE_SUFFIX", sizeof("POSITIVE_SUFFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_POSITIVE_SUFFIX_name, &const_POSITIVE_SUFFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_POSITIVE_SUFFIX_name); + zend_string_release_ex(const_POSITIVE_SUFFIX_name, true); zval const_NEGATIVE_PREFIX_value; ZVAL_LONG(&const_NEGATIVE_PREFIX_value, UNUM_NEGATIVE_PREFIX); - zend_string *const_NEGATIVE_PREFIX_name = zend_string_init_interned("NEGATIVE_PREFIX", sizeof("NEGATIVE_PREFIX") - 1, 1); + zend_string *const_NEGATIVE_PREFIX_name = zend_string_init_interned("NEGATIVE_PREFIX", sizeof("NEGATIVE_PREFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_NEGATIVE_PREFIX_name, &const_NEGATIVE_PREFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NEGATIVE_PREFIX_name); + zend_string_release_ex(const_NEGATIVE_PREFIX_name, true); zval const_NEGATIVE_SUFFIX_value; ZVAL_LONG(&const_NEGATIVE_SUFFIX_value, UNUM_NEGATIVE_SUFFIX); - zend_string *const_NEGATIVE_SUFFIX_name = zend_string_init_interned("NEGATIVE_SUFFIX", sizeof("NEGATIVE_SUFFIX") - 1, 1); + zend_string *const_NEGATIVE_SUFFIX_name = zend_string_init_interned("NEGATIVE_SUFFIX", sizeof("NEGATIVE_SUFFIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_NEGATIVE_SUFFIX_name, &const_NEGATIVE_SUFFIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NEGATIVE_SUFFIX_name); + zend_string_release_ex(const_NEGATIVE_SUFFIX_name, true); zval const_PADDING_CHARACTER_value; ZVAL_LONG(&const_PADDING_CHARACTER_value, UNUM_PADDING_CHARACTER); - zend_string *const_PADDING_CHARACTER_name = zend_string_init_interned("PADDING_CHARACTER", sizeof("PADDING_CHARACTER") - 1, 1); + zend_string *const_PADDING_CHARACTER_name = zend_string_init_interned("PADDING_CHARACTER", sizeof("PADDING_CHARACTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_PADDING_CHARACTER_name, &const_PADDING_CHARACTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PADDING_CHARACTER_name); + zend_string_release_ex(const_PADDING_CHARACTER_name, true); zval const_CURRENCY_CODE_value; ZVAL_LONG(&const_CURRENCY_CODE_value, UNUM_CURRENCY_CODE); - zend_string *const_CURRENCY_CODE_name = zend_string_init_interned("CURRENCY_CODE", sizeof("CURRENCY_CODE") - 1, 1); + zend_string *const_CURRENCY_CODE_name = zend_string_init_interned("CURRENCY_CODE", sizeof("CURRENCY_CODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENCY_CODE_name, &const_CURRENCY_CODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENCY_CODE_name); + zend_string_release_ex(const_CURRENCY_CODE_name, true); zval const_DEFAULT_RULESET_value; ZVAL_LONG(&const_DEFAULT_RULESET_value, UNUM_DEFAULT_RULESET); - zend_string *const_DEFAULT_RULESET_name = zend_string_init_interned("DEFAULT_RULESET", sizeof("DEFAULT_RULESET") - 1, 1); + zend_string *const_DEFAULT_RULESET_name = zend_string_init_interned("DEFAULT_RULESET", sizeof("DEFAULT_RULESET") - 1, true); zend_declare_typed_class_constant(class_entry, const_DEFAULT_RULESET_name, &const_DEFAULT_RULESET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DEFAULT_RULESET_name); + zend_string_release_ex(const_DEFAULT_RULESET_name, true); zval const_PUBLIC_RULESETS_value; ZVAL_LONG(&const_PUBLIC_RULESETS_value, UNUM_PUBLIC_RULESETS); - zend_string *const_PUBLIC_RULESETS_name = zend_string_init_interned("PUBLIC_RULESETS", sizeof("PUBLIC_RULESETS") - 1, 1); + zend_string *const_PUBLIC_RULESETS_name = zend_string_init_interned("PUBLIC_RULESETS", sizeof("PUBLIC_RULESETS") - 1, true); zend_declare_typed_class_constant(class_entry, const_PUBLIC_RULESETS_name, &const_PUBLIC_RULESETS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PUBLIC_RULESETS_name); + zend_string_release_ex(const_PUBLIC_RULESETS_name, true); zval const_DECIMAL_SEPARATOR_SYMBOL_value; ZVAL_LONG(&const_DECIMAL_SEPARATOR_SYMBOL_value, UNUM_DECIMAL_SEPARATOR_SYMBOL); - zend_string *const_DECIMAL_SEPARATOR_SYMBOL_name = zend_string_init_interned("DECIMAL_SEPARATOR_SYMBOL", sizeof("DECIMAL_SEPARATOR_SYMBOL") - 1, 1); + zend_string *const_DECIMAL_SEPARATOR_SYMBOL_name = zend_string_init_interned("DECIMAL_SEPARATOR_SYMBOL", sizeof("DECIMAL_SEPARATOR_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DECIMAL_SEPARATOR_SYMBOL_name, &const_DECIMAL_SEPARATOR_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DECIMAL_SEPARATOR_SYMBOL_name); + zend_string_release_ex(const_DECIMAL_SEPARATOR_SYMBOL_name, true); zval const_GROUPING_SEPARATOR_SYMBOL_value; ZVAL_LONG(&const_GROUPING_SEPARATOR_SYMBOL_value, UNUM_GROUPING_SEPARATOR_SYMBOL); - zend_string *const_GROUPING_SEPARATOR_SYMBOL_name = zend_string_init_interned("GROUPING_SEPARATOR_SYMBOL", sizeof("GROUPING_SEPARATOR_SYMBOL") - 1, 1); + zend_string *const_GROUPING_SEPARATOR_SYMBOL_name = zend_string_init_interned("GROUPING_SEPARATOR_SYMBOL", sizeof("GROUPING_SEPARATOR_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_GROUPING_SEPARATOR_SYMBOL_name, &const_GROUPING_SEPARATOR_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GROUPING_SEPARATOR_SYMBOL_name); + zend_string_release_ex(const_GROUPING_SEPARATOR_SYMBOL_name, true); zval const_PATTERN_SEPARATOR_SYMBOL_value; ZVAL_LONG(&const_PATTERN_SEPARATOR_SYMBOL_value, UNUM_PATTERN_SEPARATOR_SYMBOL); - zend_string *const_PATTERN_SEPARATOR_SYMBOL_name = zend_string_init_interned("PATTERN_SEPARATOR_SYMBOL", sizeof("PATTERN_SEPARATOR_SYMBOL") - 1, 1); + zend_string *const_PATTERN_SEPARATOR_SYMBOL_name = zend_string_init_interned("PATTERN_SEPARATOR_SYMBOL", sizeof("PATTERN_SEPARATOR_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PATTERN_SEPARATOR_SYMBOL_name, &const_PATTERN_SEPARATOR_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PATTERN_SEPARATOR_SYMBOL_name); + zend_string_release_ex(const_PATTERN_SEPARATOR_SYMBOL_name, true); zval const_PERCENT_SYMBOL_value; ZVAL_LONG(&const_PERCENT_SYMBOL_value, UNUM_PERCENT_SYMBOL); - zend_string *const_PERCENT_SYMBOL_name = zend_string_init_interned("PERCENT_SYMBOL", sizeof("PERCENT_SYMBOL") - 1, 1); + zend_string *const_PERCENT_SYMBOL_name = zend_string_init_interned("PERCENT_SYMBOL", sizeof("PERCENT_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PERCENT_SYMBOL_name, &const_PERCENT_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PERCENT_SYMBOL_name); + zend_string_release_ex(const_PERCENT_SYMBOL_name, true); zval const_ZERO_DIGIT_SYMBOL_value; ZVAL_LONG(&const_ZERO_DIGIT_SYMBOL_value, UNUM_ZERO_DIGIT_SYMBOL); - zend_string *const_ZERO_DIGIT_SYMBOL_name = zend_string_init_interned("ZERO_DIGIT_SYMBOL", sizeof("ZERO_DIGIT_SYMBOL") - 1, 1); + zend_string *const_ZERO_DIGIT_SYMBOL_name = zend_string_init_interned("ZERO_DIGIT_SYMBOL", sizeof("ZERO_DIGIT_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ZERO_DIGIT_SYMBOL_name, &const_ZERO_DIGIT_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ZERO_DIGIT_SYMBOL_name); + zend_string_release_ex(const_ZERO_DIGIT_SYMBOL_name, true); zval const_DIGIT_SYMBOL_value; ZVAL_LONG(&const_DIGIT_SYMBOL_value, UNUM_DIGIT_SYMBOL); - zend_string *const_DIGIT_SYMBOL_name = zend_string_init_interned("DIGIT_SYMBOL", sizeof("DIGIT_SYMBOL") - 1, 1); + zend_string *const_DIGIT_SYMBOL_name = zend_string_init_interned("DIGIT_SYMBOL", sizeof("DIGIT_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DIGIT_SYMBOL_name, &const_DIGIT_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DIGIT_SYMBOL_name); + zend_string_release_ex(const_DIGIT_SYMBOL_name, true); zval const_MINUS_SIGN_SYMBOL_value; ZVAL_LONG(&const_MINUS_SIGN_SYMBOL_value, UNUM_MINUS_SIGN_SYMBOL); - zend_string *const_MINUS_SIGN_SYMBOL_name = zend_string_init_interned("MINUS_SIGN_SYMBOL", sizeof("MINUS_SIGN_SYMBOL") - 1, 1); + zend_string *const_MINUS_SIGN_SYMBOL_name = zend_string_init_interned("MINUS_SIGN_SYMBOL", sizeof("MINUS_SIGN_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_MINUS_SIGN_SYMBOL_name, &const_MINUS_SIGN_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MINUS_SIGN_SYMBOL_name); + zend_string_release_ex(const_MINUS_SIGN_SYMBOL_name, true); zval const_PLUS_SIGN_SYMBOL_value; ZVAL_LONG(&const_PLUS_SIGN_SYMBOL_value, UNUM_PLUS_SIGN_SYMBOL); - zend_string *const_PLUS_SIGN_SYMBOL_name = zend_string_init_interned("PLUS_SIGN_SYMBOL", sizeof("PLUS_SIGN_SYMBOL") - 1, 1); + zend_string *const_PLUS_SIGN_SYMBOL_name = zend_string_init_interned("PLUS_SIGN_SYMBOL", sizeof("PLUS_SIGN_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PLUS_SIGN_SYMBOL_name, &const_PLUS_SIGN_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PLUS_SIGN_SYMBOL_name); + zend_string_release_ex(const_PLUS_SIGN_SYMBOL_name, true); zval const_CURRENCY_SYMBOL_value; ZVAL_LONG(&const_CURRENCY_SYMBOL_value, UNUM_CURRENCY_SYMBOL); - zend_string *const_CURRENCY_SYMBOL_name = zend_string_init_interned("CURRENCY_SYMBOL", sizeof("CURRENCY_SYMBOL") - 1, 1); + zend_string *const_CURRENCY_SYMBOL_name = zend_string_init_interned("CURRENCY_SYMBOL", sizeof("CURRENCY_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENCY_SYMBOL_name, &const_CURRENCY_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENCY_SYMBOL_name); + zend_string_release_ex(const_CURRENCY_SYMBOL_name, true); zval const_INTL_CURRENCY_SYMBOL_value; ZVAL_LONG(&const_INTL_CURRENCY_SYMBOL_value, UNUM_INTL_CURRENCY_SYMBOL); - zend_string *const_INTL_CURRENCY_SYMBOL_name = zend_string_init_interned("INTL_CURRENCY_SYMBOL", sizeof("INTL_CURRENCY_SYMBOL") - 1, 1); + zend_string *const_INTL_CURRENCY_SYMBOL_name = zend_string_init_interned("INTL_CURRENCY_SYMBOL", sizeof("INTL_CURRENCY_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_INTL_CURRENCY_SYMBOL_name, &const_INTL_CURRENCY_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INTL_CURRENCY_SYMBOL_name); + zend_string_release_ex(const_INTL_CURRENCY_SYMBOL_name, true); zval const_MONETARY_SEPARATOR_SYMBOL_value; ZVAL_LONG(&const_MONETARY_SEPARATOR_SYMBOL_value, UNUM_MONETARY_SEPARATOR_SYMBOL); - zend_string *const_MONETARY_SEPARATOR_SYMBOL_name = zend_string_init_interned("MONETARY_SEPARATOR_SYMBOL", sizeof("MONETARY_SEPARATOR_SYMBOL") - 1, 1); + zend_string *const_MONETARY_SEPARATOR_SYMBOL_name = zend_string_init_interned("MONETARY_SEPARATOR_SYMBOL", sizeof("MONETARY_SEPARATOR_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_MONETARY_SEPARATOR_SYMBOL_name, &const_MONETARY_SEPARATOR_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MONETARY_SEPARATOR_SYMBOL_name); + zend_string_release_ex(const_MONETARY_SEPARATOR_SYMBOL_name, true); zval const_EXPONENTIAL_SYMBOL_value; ZVAL_LONG(&const_EXPONENTIAL_SYMBOL_value, UNUM_EXPONENTIAL_SYMBOL); - zend_string *const_EXPONENTIAL_SYMBOL_name = zend_string_init_interned("EXPONENTIAL_SYMBOL", sizeof("EXPONENTIAL_SYMBOL") - 1, 1); + zend_string *const_EXPONENTIAL_SYMBOL_name = zend_string_init_interned("EXPONENTIAL_SYMBOL", sizeof("EXPONENTIAL_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXPONENTIAL_SYMBOL_name, &const_EXPONENTIAL_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXPONENTIAL_SYMBOL_name); + zend_string_release_ex(const_EXPONENTIAL_SYMBOL_name, true); zval const_PERMILL_SYMBOL_value; ZVAL_LONG(&const_PERMILL_SYMBOL_value, UNUM_PERMILL_SYMBOL); - zend_string *const_PERMILL_SYMBOL_name = zend_string_init_interned("PERMILL_SYMBOL", sizeof("PERMILL_SYMBOL") - 1, 1); + zend_string *const_PERMILL_SYMBOL_name = zend_string_init_interned("PERMILL_SYMBOL", sizeof("PERMILL_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PERMILL_SYMBOL_name, &const_PERMILL_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PERMILL_SYMBOL_name); + zend_string_release_ex(const_PERMILL_SYMBOL_name, true); zval const_PAD_ESCAPE_SYMBOL_value; ZVAL_LONG(&const_PAD_ESCAPE_SYMBOL_value, UNUM_PAD_ESCAPE_SYMBOL); - zend_string *const_PAD_ESCAPE_SYMBOL_name = zend_string_init_interned("PAD_ESCAPE_SYMBOL", sizeof("PAD_ESCAPE_SYMBOL") - 1, 1); + zend_string *const_PAD_ESCAPE_SYMBOL_name = zend_string_init_interned("PAD_ESCAPE_SYMBOL", sizeof("PAD_ESCAPE_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PAD_ESCAPE_SYMBOL_name, &const_PAD_ESCAPE_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PAD_ESCAPE_SYMBOL_name); + zend_string_release_ex(const_PAD_ESCAPE_SYMBOL_name, true); zval const_INFINITY_SYMBOL_value; ZVAL_LONG(&const_INFINITY_SYMBOL_value, UNUM_INFINITY_SYMBOL); - zend_string *const_INFINITY_SYMBOL_name = zend_string_init_interned("INFINITY_SYMBOL", sizeof("INFINITY_SYMBOL") - 1, 1); + zend_string *const_INFINITY_SYMBOL_name = zend_string_init_interned("INFINITY_SYMBOL", sizeof("INFINITY_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_INFINITY_SYMBOL_name, &const_INFINITY_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INFINITY_SYMBOL_name); + zend_string_release_ex(const_INFINITY_SYMBOL_name, true); zval const_NAN_SYMBOL_value; ZVAL_LONG(&const_NAN_SYMBOL_value, UNUM_NAN_SYMBOL); - zend_string *const_NAN_SYMBOL_name = zend_string_init_interned("NAN_SYMBOL", sizeof("NAN_SYMBOL") - 1, 1); + zend_string *const_NAN_SYMBOL_name = zend_string_init_interned("NAN_SYMBOL", sizeof("NAN_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_NAN_SYMBOL_name, &const_NAN_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NAN_SYMBOL_name); + zend_string_release_ex(const_NAN_SYMBOL_name, true); zval const_SIGNIFICANT_DIGIT_SYMBOL_value; ZVAL_LONG(&const_SIGNIFICANT_DIGIT_SYMBOL_value, UNUM_SIGNIFICANT_DIGIT_SYMBOL); - zend_string *const_SIGNIFICANT_DIGIT_SYMBOL_name = zend_string_init_interned("SIGNIFICANT_DIGIT_SYMBOL", sizeof("SIGNIFICANT_DIGIT_SYMBOL") - 1, 1); + zend_string *const_SIGNIFICANT_DIGIT_SYMBOL_name = zend_string_init_interned("SIGNIFICANT_DIGIT_SYMBOL", sizeof("SIGNIFICANT_DIGIT_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_SIGNIFICANT_DIGIT_SYMBOL_name, &const_SIGNIFICANT_DIGIT_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SIGNIFICANT_DIGIT_SYMBOL_name); + zend_string_release_ex(const_SIGNIFICANT_DIGIT_SYMBOL_name, true); zval const_MONETARY_GROUPING_SEPARATOR_SYMBOL_value; ZVAL_LONG(&const_MONETARY_GROUPING_SEPARATOR_SYMBOL_value, UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL); - zend_string *const_MONETARY_GROUPING_SEPARATOR_SYMBOL_name = zend_string_init_interned("MONETARY_GROUPING_SEPARATOR_SYMBOL", sizeof("MONETARY_GROUPING_SEPARATOR_SYMBOL") - 1, 1); + zend_string *const_MONETARY_GROUPING_SEPARATOR_SYMBOL_name = zend_string_init_interned("MONETARY_GROUPING_SEPARATOR_SYMBOL", sizeof("MONETARY_GROUPING_SEPARATOR_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_MONETARY_GROUPING_SEPARATOR_SYMBOL_name, &const_MONETARY_GROUPING_SEPARATOR_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MONETARY_GROUPING_SEPARATOR_SYMBOL_name); + zend_string_release_ex(const_MONETARY_GROUPING_SEPARATOR_SYMBOL_name, true); zval const_TYPE_DEFAULT_value; ZVAL_LONG(&const_TYPE_DEFAULT_value, FORMAT_TYPE_DEFAULT); - zend_string *const_TYPE_DEFAULT_name = zend_string_init_interned("TYPE_DEFAULT", sizeof("TYPE_DEFAULT") - 1, 1); + zend_string *const_TYPE_DEFAULT_name = zend_string_init_interned("TYPE_DEFAULT", sizeof("TYPE_DEFAULT") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_DEFAULT_name, &const_TYPE_DEFAULT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_DEFAULT_name); + zend_string_release_ex(const_TYPE_DEFAULT_name, true); zval const_TYPE_INT32_value; ZVAL_LONG(&const_TYPE_INT32_value, FORMAT_TYPE_INT32); - zend_string *const_TYPE_INT32_name = zend_string_init_interned("TYPE_INT32", sizeof("TYPE_INT32") - 1, 1); + zend_string *const_TYPE_INT32_name = zend_string_init_interned("TYPE_INT32", sizeof("TYPE_INT32") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_INT32_name, &const_TYPE_INT32_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_INT32_name); + zend_string_release_ex(const_TYPE_INT32_name, true); zval const_TYPE_INT64_value; ZVAL_LONG(&const_TYPE_INT64_value, FORMAT_TYPE_INT64); - zend_string *const_TYPE_INT64_name = zend_string_init_interned("TYPE_INT64", sizeof("TYPE_INT64") - 1, 1); + zend_string *const_TYPE_INT64_name = zend_string_init_interned("TYPE_INT64", sizeof("TYPE_INT64") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_INT64_name, &const_TYPE_INT64_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_INT64_name); + zend_string_release_ex(const_TYPE_INT64_name, true); zval const_TYPE_DOUBLE_value; ZVAL_LONG(&const_TYPE_DOUBLE_value, FORMAT_TYPE_DOUBLE); - zend_string *const_TYPE_DOUBLE_name = zend_string_init_interned("TYPE_DOUBLE", sizeof("TYPE_DOUBLE") - 1, 1); + zend_string *const_TYPE_DOUBLE_name = zend_string_init_interned("TYPE_DOUBLE", sizeof("TYPE_DOUBLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_DOUBLE_name, &const_TYPE_DOUBLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_DOUBLE_name); + zend_string_release_ex(const_TYPE_DOUBLE_name, true); zval const_TYPE_CURRENCY_value; ZVAL_LONG(&const_TYPE_CURRENCY_value, FORMAT_TYPE_CURRENCY); - zend_string *const_TYPE_CURRENCY_name = zend_string_init_interned("TYPE_CURRENCY", sizeof("TYPE_CURRENCY") - 1, 1); + zend_string *const_TYPE_CURRENCY_name = zend_string_init_interned("TYPE_CURRENCY", sizeof("TYPE_CURRENCY") - 1, true); zend_class_constant *const_TYPE_CURRENCY = zend_declare_typed_class_constant(class_entry, const_TYPE_CURRENCY_name, &const_TYPE_CURRENCY_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_CURRENCY_name); + zend_string_release_ex(const_TYPE_CURRENCY_name, true); zend_attribute *attribute_Deprecated_const_TYPE_CURRENCY_0 = zend_add_class_constant_attribute(class_entry, const_TYPE_CURRENCY, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 1); diff --git a/ext/intl/formatter/formatter_attr.c b/ext/intl/formatter/formatter_attr.cpp similarity index 86% rename from ext/intl/formatter/formatter_attr.c rename to ext/intl/formatter/formatter_attr.cpp index a7cafcf5f9733..905a4415ef59b 100644 --- a/ext/intl/formatter/formatter_attr.c +++ b/ext/intl/formatter/formatter_attr.cpp @@ -16,25 +16,29 @@ #include #endif +extern "C" { #include "php_intl.h" -#include "formatter_class.h" #include "intl_convert.h" +} +#include "formatter_class.h" #include /* {{{ Get formatter attribute value. */ -PHP_FUNCTION( numfmt_get_attribute ) +U_CFUNC PHP_FUNCTION( numfmt_get_attribute ) { - zend_long attribute, value; + zend_long lattribute, value; FORMATTER_METHOD_INIT_VARS; /* Parse parameters. */ if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Ol", - &object, NumberFormatter_ce_ptr, &attribute ) == FAILURE ) + &object, NumberFormatter_ce_ptr, &lattribute ) == FAILURE ) { RETURN_THROWS(); } + UNumberFormatAttribute attribute = static_cast(lattribute); + /* Fetch the object. */ FORMATTER_METHOD_FETCH_OBJECT; @@ -85,9 +89,9 @@ PHP_FUNCTION( numfmt_get_attribute ) /* }}} */ /* {{{ Get formatter attribute value. */ -PHP_FUNCTION( numfmt_get_text_attribute ) +U_CFUNC PHP_FUNCTION( numfmt_get_text_attribute ) { - zend_long attribute; + zend_long lattribute; UChar value_buf[64]; int32_t value_buf_size = USIZE( value_buf ); UChar* value = value_buf; @@ -96,7 +100,7 @@ PHP_FUNCTION( numfmt_get_text_attribute ) /* Parse parameters. */ if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Ol", - &object, NumberFormatter_ce_ptr, &attribute ) == FAILURE ) + &object, NumberFormatter_ce_ptr, &lattribute ) == FAILURE ) { RETURN_THROWS(); } @@ -104,6 +108,8 @@ PHP_FUNCTION( numfmt_get_text_attribute ) /* Fetch the object. */ FORMATTER_METHOD_FETCH_OBJECT; + UNumberFormatTextAttribute attribute = static_cast(lattribute); + length = unum_getTextAttribute( FORMATTER_OBJECT(nfo), attribute, value, value_buf_size, &INTL_DATA_ERROR_CODE(nfo) ); if(INTL_DATA_ERROR_CODE(nfo) == U_BUFFER_OVERFLOW_ERROR && length >= value_buf_size) { ++length; /* to avoid U_STRING_NOT_TERMINATED_WARNING */ @@ -122,15 +128,15 @@ PHP_FUNCTION( numfmt_get_text_attribute ) /* }}} */ /* {{{ Get formatter attribute value. */ -PHP_FUNCTION( numfmt_set_attribute ) +U_CFUNC PHP_FUNCTION( numfmt_set_attribute ) { - zend_long attribute; + zend_long lattribute; zval *value; FORMATTER_METHOD_INIT_VARS; /* Parse parameters. */ if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Oln", - &object, NumberFormatter_ce_ptr, &attribute, &value ) == FAILURE) + &object, NumberFormatter_ce_ptr, &lattribute, &value ) == FAILURE) { RETURN_THROWS(); } @@ -138,6 +144,8 @@ PHP_FUNCTION( numfmt_set_attribute ) /* Fetch the object. */ FORMATTER_METHOD_FETCH_OBJECT; + UNumberFormatAttribute attribute = static_cast(lattribute); + switch(attribute) { case UNUM_PARSE_INT_ONLY: case UNUM_GROUPING_USED: @@ -175,7 +183,7 @@ PHP_FUNCTION( numfmt_set_attribute ) /* }}} */ /* {{{ Get formatter attribute value. */ -PHP_FUNCTION( numfmt_set_text_attribute ) +U_CFUNC PHP_FUNCTION( numfmt_set_text_attribute ) { int32_t slength = 0; UChar *svalue = NULL; @@ -199,7 +207,7 @@ PHP_FUNCTION( numfmt_set_text_attribute ) INTL_METHOD_CHECK_STATUS( nfo, "Error converting attribute value to UTF-16" ); /* Actually set new attribute value. */ - unum_setTextAttribute(FORMATTER_OBJECT(nfo), attribute, svalue, slength, &INTL_DATA_ERROR_CODE(nfo)); + unum_setTextAttribute(FORMATTER_OBJECT(nfo), static_cast(attribute), svalue, slength, &INTL_DATA_ERROR_CODE(nfo)); if (svalue) { efree(svalue); } @@ -210,9 +218,9 @@ PHP_FUNCTION( numfmt_set_text_attribute ) /* }}} */ /* {{{ Get formatter symbol value. */ -PHP_FUNCTION( numfmt_get_symbol ) +U_CFUNC PHP_FUNCTION( numfmt_get_symbol ) { - zend_long symbol; + zend_long lsymbol; UChar value_buf[4]; UChar *value = value_buf; uint32_t length = USIZE(value_buf); @@ -220,11 +228,13 @@ PHP_FUNCTION( numfmt_get_symbol ) /* Parse parameters. */ if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Ol", - &object, NumberFormatter_ce_ptr, &symbol ) == FAILURE ) + &object, NumberFormatter_ce_ptr, &lsymbol ) == FAILURE ) { RETURN_THROWS(); } + UNumberFormatSymbol symbol = static_cast(lsymbol); + if(symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid symbol value"); RETURN_FALSE; @@ -251,9 +261,9 @@ PHP_FUNCTION( numfmt_get_symbol ) /* }}} */ /* {{{ Set formatter symbol value. */ -PHP_FUNCTION( numfmt_set_symbol ) +U_CFUNC PHP_FUNCTION( numfmt_set_symbol ) { - zend_long symbol; + zend_long lsymbol; char* value = NULL; size_t value_len = 0; UChar* svalue = 0; @@ -262,11 +272,13 @@ PHP_FUNCTION( numfmt_set_symbol ) /* Parse parameters. */ if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Ols", - &object, NumberFormatter_ce_ptr, &symbol, &value, &value_len ) == FAILURE ) + &object, NumberFormatter_ce_ptr, &lsymbol, &value, &value_len ) == FAILURE ) { RETURN_THROWS(); } + UNumberFormatSymbol symbol = static_cast(lsymbol); + if (symbol >= UNUM_FORMAT_SYMBOL_COUNT || symbol < 0) { intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid symbol value"); RETURN_FALSE; @@ -291,7 +303,7 @@ PHP_FUNCTION( numfmt_set_symbol ) /* }}} */ /* {{{ Get formatter pattern. */ -PHP_FUNCTION( numfmt_get_pattern ) +U_CFUNC PHP_FUNCTION( numfmt_get_pattern ) { UChar value_buf[64]; uint32_t length = USIZE( value_buf ); @@ -326,7 +338,7 @@ PHP_FUNCTION( numfmt_get_pattern ) /* }}} */ /* {{{ Set formatter pattern. */ -PHP_FUNCTION( numfmt_set_pattern ) +U_CFUNC PHP_FUNCTION( numfmt_set_pattern ) { char* value = NULL; size_t value_len = 0; @@ -365,10 +377,10 @@ PHP_FUNCTION( numfmt_set_pattern ) /* }}} */ /* {{{ Get formatter locale. */ -PHP_FUNCTION( numfmt_get_locale ) +U_CFUNC PHP_FUNCTION( numfmt_get_locale ) { zend_long type = ULOC_ACTUAL_LOCALE; - char* loc; + const char* loc; FORMATTER_METHOD_INIT_VARS; /* Parse parameters. */ @@ -381,7 +393,7 @@ PHP_FUNCTION( numfmt_get_locale ) /* Fetch the object. */ FORMATTER_METHOD_FETCH_OBJECT; - loc = (char *)unum_getLocaleByType(FORMATTER_OBJECT(nfo), type, &INTL_DATA_ERROR_CODE(nfo)); + loc = unum_getLocaleByType(FORMATTER_OBJECT(nfo), static_cast(type), &INTL_DATA_ERROR_CODE(nfo)); INTL_METHOD_CHECK_STATUS( nfo, "Error getting locale" ); RETURN_STRING(loc); } diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.cpp similarity index 89% rename from ext/intl/formatter/formatter_class.c rename to ext/intl/formatter/formatter_class.cpp index 7832824c94e1c..214e1e57dae8a 100644 --- a/ext/intl/formatter/formatter_class.c +++ b/ext/intl/formatter/formatter_class.cpp @@ -15,15 +15,19 @@ #include #include "formatter_class.h" +extern "C" { #include "php_intl.h" #include "formatter_data.h" #include "formatter_format.h" +} #include #include "Zend/zend_attributes.h" #include "Zend/zend_interfaces.h" +extern "C" { #include "formatter_arginfo.h" +} zend_class_entry *NumberFormatter_ce_ptr = NULL; static zend_object_handlers NumberFormatter_handlers; @@ -33,7 +37,7 @@ static zend_object_handlers NumberFormatter_handlers; */ /* {{{ NumberFormatter_objects_free */ -void NumberFormatter_object_free( zend_object *object ) +U_CFUNC void NumberFormatter_object_free( zend_object *object ) { NumberFormatter_object* nfo = php_intl_number_format_fetch_object(object); @@ -44,11 +48,11 @@ void NumberFormatter_object_free( zend_object *object ) /* }}} */ /* {{{ NumberFormatter_object_create */ -zend_object *NumberFormatter_object_create(zend_class_entry *ce) +U_CFUNC zend_object *NumberFormatter_object_create(zend_class_entry *ce) { NumberFormatter_object* intern; - intern = zend_object_alloc(sizeof(NumberFormatter_object), ce); + intern = reinterpret_cast(zend_object_alloc(sizeof(NumberFormatter_object), ce)); formatter_data_init( &intern->nf_data ); zend_object_std_init( &intern->zo, ce ); object_properties_init(&intern->zo, ce); @@ -58,7 +62,7 @@ zend_object *NumberFormatter_object_create(zend_class_entry *ce) /* }}} */ /* {{{ NumberFormatter_object_clone */ -zend_object *NumberFormatter_object_clone(zend_object *object) +U_CFUNC zend_object *NumberFormatter_object_clone(zend_object *object) { NumberFormatter_object *nfo = php_intl_number_format_fetch_object(object); zend_object *new_obj = NumberFormatter_ce_ptr->create_object(object->ce); @@ -88,7 +92,7 @@ zend_object *NumberFormatter_object_clone(zend_object *object) /* {{{ formatter_register_class * Initialize 'NumberFormatter' class */ -void formatter_register_class( void ) +U_CFUNC void formatter_register_class( void ) { /* Create and register 'NumberFormatter' class. */ NumberFormatter_ce_ptr = register_class_NumberFormatter(); diff --git a/ext/intl/formatter/formatter_class.h b/ext/intl/formatter/formatter_class.h index f7da2b2201917..bf21825b5f5f4 100644 --- a/ext/intl/formatter/formatter_class.h +++ b/ext/intl/formatter/formatter_class.h @@ -17,10 +17,16 @@ #include +#ifdef __cplusplus +extern "C" { +#endif #include "intl_common.h" #include "intl_error.h" #include "intl_data.h" #include "formatter_data.h" +#ifdef __cplusplus +} +#endif typedef struct { formatter_data nf_data; @@ -32,8 +38,14 @@ static inline NumberFormatter_object *php_intl_number_format_fetch_object(zend_o } #define Z_INTL_NUMBERFORMATTER_P(zv) php_intl_number_format_fetch_object(Z_OBJ_P(zv)) +#ifdef __cplusplus +extern "C" { +#endif void formatter_register_class( void ); extern zend_class_entry *NumberFormatter_ce_ptr; +#ifdef __cplusplus +} +#endif /* Auxiliary macros */ diff --git a/ext/intl/formatter/formatter_data.c b/ext/intl/formatter/formatter_data.cpp similarity index 94% rename from ext/intl/formatter/formatter_data.c rename to ext/intl/formatter/formatter_data.cpp index 57dbc8bde6b5e..095be92ed29e1 100644 --- a/ext/intl/formatter/formatter_data.c +++ b/ext/intl/formatter/formatter_data.cpp @@ -52,7 +52,7 @@ void formatter_data_free( formatter_data* nf_data ) */ formatter_data* formatter_data_create( void ) { - formatter_data* nf_data = ecalloc( 1, sizeof(formatter_data) ); + formatter_data* nf_data = reinterpret_cast(ecalloc( 1, sizeof(formatter_data) )); formatter_data_init( nf_data ); diff --git a/ext/intl/formatter/formatter_data.h b/ext/intl/formatter/formatter_data.h index 817ad0d6055f3..35acc242a8db9 100644 --- a/ext/intl/formatter/formatter_data.h +++ b/ext/intl/formatter/formatter_data.h @@ -19,7 +19,13 @@ #include +#ifdef __cplusplus +extern "C" { +#endif #include "intl_error.h" +#ifdef __cplusplus +} +#endif typedef struct { // error hangling @@ -29,8 +35,14 @@ typedef struct { UNumberFormat* unum; } formatter_data; +#ifdef __cplusplus +extern "C" { +#endif formatter_data* formatter_data_create( void ); void formatter_data_init( formatter_data* nf_data ); void formatter_data_free( formatter_data* nf_data ); +#ifdef __cplusplus +} +#endif #endif // FORMATTER_DATA_H diff --git a/ext/intl/formatter/formatter_format.c b/ext/intl/formatter/formatter_format.cpp similarity index 98% rename from ext/intl/formatter/formatter_format.c rename to ext/intl/formatter/formatter_format.cpp index 5be732dde77e8..f28ea30b9ff8f 100644 --- a/ext/intl/formatter/formatter_format.c +++ b/ext/intl/formatter/formatter_format.cpp @@ -16,16 +16,18 @@ #include #endif +extern "C" { #include "php_intl.h" +#include "intl_convert.h" +} #include #include "formatter_class.h" #include "formatter_format.h" -#include "intl_convert.h" /* {{{ Format a number. */ -PHP_FUNCTION( numfmt_format ) +U_CFUNC PHP_FUNCTION( numfmt_format ) { zval *number; zend_long type = FORMAT_TYPE_DEFAULT; @@ -123,7 +125,7 @@ PHP_FUNCTION( numfmt_format ) /* }}} */ /* {{{ Format a number as currency. */ -PHP_FUNCTION( numfmt_format_currency ) +U_CFUNC PHP_FUNCTION( numfmt_format_currency ) { double number; UChar format_buf[32]; diff --git a/ext/intl/formatter/formatter_main.c b/ext/intl/formatter/formatter_main.cpp similarity index 91% rename from ext/intl/formatter/formatter_main.c rename to ext/intl/formatter/formatter_main.cpp index d6d69f57277f9..a014323089a7e 100644 --- a/ext/intl/formatter/formatter_main.c +++ b/ext/intl/formatter/formatter_main.cpp @@ -19,9 +19,11 @@ #include #include +extern "C" { #include "php_intl.h" -#include "formatter_class.h" #include "intl_convert.h" +} +#include "formatter_class.h" /* {{{ */ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) @@ -67,7 +69,8 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) char* canonicalized_locale = canonicalize_locale_string(locale); const char* final_locale = canonicalized_locale ? canonicalized_locale : locale; - FORMATTER_OBJECT(nfo) = unum_open(style, spattern, spattern_len, final_locale, NULL, &INTL_DATA_ERROR_CODE(nfo)); + /* Create an ICU number formatter. */ + FORMATTER_OBJECT(nfo) = unum_open(static_cast(style), spattern, spattern_len, final_locale, nullptr, &INTL_DATA_ERROR_CODE(nfo)); if (spattern) { efree(spattern); @@ -83,7 +86,7 @@ static int numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS) /* }}} */ /* {{{ Create number formatter. */ -PHP_FUNCTION( numfmt_create ) +U_CFUNC PHP_FUNCTION( numfmt_create ) { object_init_ex( return_value, NumberFormatter_ce_ptr ); if (numfmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { @@ -94,7 +97,7 @@ PHP_FUNCTION( numfmt_create ) /* }}} */ /* {{{ NumberFormatter object constructor. */ -PHP_METHOD( NumberFormatter, __construct ) +U_CFUNC PHP_METHOD( NumberFormatter, __construct ) { const bool old_use_exception = INTL_G(use_exceptions); const zend_long old_error_level = INTL_G(error_level); @@ -111,7 +114,7 @@ PHP_METHOD( NumberFormatter, __construct ) /* }}} */ /* {{{ Get formatter's last error code. */ -PHP_FUNCTION( numfmt_get_error_code ) +U_CFUNC PHP_FUNCTION( numfmt_get_error_code ) { FORMATTER_METHOD_INIT_VARS @@ -130,7 +133,7 @@ PHP_FUNCTION( numfmt_get_error_code ) /* }}} */ /* {{{ Get text description for formatter's last error code. */ -PHP_FUNCTION( numfmt_get_error_message ) +U_CFUNC PHP_FUNCTION( numfmt_get_error_message ) { zend_string *message = NULL; FORMATTER_METHOD_INIT_VARS diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.cpp similarity index 98% rename from ext/intl/formatter/formatter_parse.c rename to ext/intl/formatter/formatter_parse.cpp index ba8307419b4cf..c7d0df8cbda02 100644 --- a/ext/intl/formatter/formatter_parse.c +++ b/ext/intl/formatter/formatter_parse.cpp @@ -16,19 +16,21 @@ #include #endif +extern "C" { #include "php_intl.h" +#include "intl_convert.h" +} #include #include #include "formatter_class.h" #include "formatter_format.h" -#include "intl_convert.h" #define ICU_LOCALE_BUG 1 /* {{{ Parse a number. */ -PHP_FUNCTION( numfmt_parse ) +U_CFUNC PHP_FUNCTION( numfmt_parse ) { zend_long type = FORMAT_TYPE_DOUBLE; UChar* sstr = NULL; @@ -120,7 +122,7 @@ PHP_FUNCTION( numfmt_parse ) /* }}} */ /* {{{ Parse a number as currency. */ -PHP_FUNCTION( numfmt_parse_currency ) +U_CFUNC PHP_FUNCTION( numfmt_parse_currency ) { double number; UChar currency[5] = {0}; diff --git a/ext/intl/grapheme/grapheme.h b/ext/intl/grapheme/grapheme.h index 003e0d49317a9..8ec470d479272 100644 --- a/ext/intl/grapheme/grapheme.h +++ b/ext/intl/grapheme/grapheme.h @@ -18,7 +18,13 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif void grapheme_close_global_iterator( void ); +#ifdef __cplusplus +} +#endif #define GRAPHEME_EXTRACT_TYPE_COUNT 0 #define GRAPHEME_EXTRACT_TYPE_MAXBYTES 1 diff --git a/ext/intl/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.cpp similarity index 90% rename from ext/intl/grapheme/grapheme_string.c rename to ext/intl/grapheme/grapheme_string.cpp index 28d3130c3959d..6dd5a002a65b8 100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.cpp @@ -17,9 +17,16 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include #include "grapheme.h" #include "grapheme_util.h" +} #include #include @@ -30,11 +37,11 @@ /* }}} */ /* {{{ Get number of graphemes in a string */ -PHP_FUNCTION(grapheme_strlen) +U_CFUNC PHP_FUNCTION(grapheme_strlen) { char* string; size_t string_len; - UChar* ustring = NULL; + UChar* ustring = nullptr; int ustring_len = 0; zend_long ret_len; UErrorCode status; @@ -54,17 +61,17 @@ PHP_FUNCTION(grapheme_strlen) if ( U_FAILURE( status ) ) { /* Set global error code. */ - intl_error_set_code( NULL, status ); + intl_error_set_code( nullptr, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16"); + intl_error_set_custom_msg( nullptr, "Error converting input string to UTF-16"); if (ustring) { efree( ustring ); } RETURN_NULL(); } - ret_len = grapheme_split_string(ustring, ustring_len, NULL, 0 ); + ret_len = grapheme_split_string(ustring, ustring_len, nullptr, 0 ); if (ustring) { efree( ustring ); @@ -79,7 +86,7 @@ PHP_FUNCTION(grapheme_strlen) /* }}} */ /* {{{ Find position of first occurrence of a string within another */ -PHP_FUNCTION(grapheme_strpos) +U_CFUNC PHP_FUNCTION(grapheme_strpos) { char *haystack, *needle, *locale = ""; size_t haystack_len, needle_len, locale_len = 0; @@ -122,7 +129,7 @@ PHP_FUNCTION(grapheme_strpos) } /* do utf16 part of the strpos */ - ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, /* fIgnoreCase */ 0, /* last */ 0, locale); + ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, nullptr, /* fIgnoreCase */ 0, /* last */ 0, locale); if ( ret_pos >= 0 ) { RETURN_LONG(ret_pos); @@ -133,7 +140,7 @@ PHP_FUNCTION(grapheme_strpos) /* }}} */ /* {{{ Find position of first occurrence of a string within another, ignoring case differences */ -PHP_FUNCTION(grapheme_stripos) +U_CFUNC PHP_FUNCTION(grapheme_stripos) { char *haystack, *needle, *locale = ""; size_t haystack_len, needle_len, locale_len = 0; @@ -187,7 +194,7 @@ PHP_FUNCTION(grapheme_stripos) } /* do utf16 part of the strpos */ - ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, /* fIgnoreCase */ 1, /*last */ 0, locale); + ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, nullptr, /* fIgnoreCase */ 1, /*last */ 0, locale); if ( ret_pos >= 0 ) { RETURN_LONG(ret_pos); @@ -199,7 +206,7 @@ PHP_FUNCTION(grapheme_stripos) /* }}} */ /* {{{ Find position of last occurrence of a string within another */ -PHP_FUNCTION(grapheme_strrpos) +U_CFUNC PHP_FUNCTION(grapheme_strrpos) { char *haystack, *needle; char *locale = ""; @@ -246,7 +253,7 @@ PHP_FUNCTION(grapheme_strrpos) /* else we need to continue via utf16 */ } - ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, /* f_ignore_case */ 0, /* last */ 1, locale); + ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, nullptr, /* f_ignore_case */ 0, /* last */ 1, locale); if ( ret_pos >= 0 ) { RETURN_LONG(ret_pos); @@ -259,7 +266,7 @@ PHP_FUNCTION(grapheme_strrpos) /* }}} */ /* {{{ Find position of last occurrence of a string within another, ignoring case */ -PHP_FUNCTION(grapheme_strripos) +U_CFUNC PHP_FUNCTION(grapheme_strripos) { char *haystack, *needle, *locale = ""; size_t haystack_len, needle_len, locale_len = 0; @@ -314,7 +321,7 @@ PHP_FUNCTION(grapheme_strripos) /* else we need to continue via utf16 */ } - ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, NULL, /* f_ignore_case */ 1, /*last */ 1, locale); + ret_pos = grapheme_strpos_utf16(haystack, haystack_len, needle, needle_len, offset, nullptr, /* f_ignore_case */ 1, /*last */ 1, locale); if ( ret_pos >= 0 ) { RETURN_LONG(ret_pos); @@ -327,7 +334,7 @@ PHP_FUNCTION(grapheme_strripos) /* }}} */ /* {{{ Returns part of a string */ -PHP_FUNCTION(grapheme_substr) +U_CFUNC PHP_FUNCTION(grapheme_substr) { char *str, *locale = ""; zend_string *u8_sub_str; @@ -339,7 +346,7 @@ PHP_FUNCTION(grapheme_substr) int iter_val; UErrorCode status; unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE]; - UBreakIterator* bi = NULL; + UBreakIterator* bi = nullptr; int sub_str_start_pos, sub_str_end_pos; int32_t (*iter_func)(UBreakIterator *); bool no_length = true; @@ -375,25 +382,25 @@ PHP_FUNCTION(grapheme_substr) char *sub_str; grapheme_substr_ascii(str, str_len, start, (int32_t)length, &sub_str, &asub_str_len); - if ( NULL == sub_str ) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "invalid parameters"); + if ( nullptr == sub_str ) { + intl_error_set( nullptr, U_ILLEGAL_ARGUMENT_ERROR, "invalid parameters"); RETURN_FALSE; } RETURN_STRINGL(sub_str, asub_str_len); } - ustr = NULL; + ustr = nullptr; ustr_len = 0; status = U_ZERO_ERROR; intl_convert_utf8_to_utf16(&ustr, &ustr_len, str, str_len, &status); if ( U_FAILURE( status ) ) { /* Set global error code. */ - intl_error_set_code( NULL, status ); + intl_error_set_code( nullptr, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16"); + intl_error_set_custom_msg( nullptr, "Error converting input string to UTF-16"); if (ustr) { efree( ustr ); } @@ -458,10 +465,10 @@ PHP_FUNCTION(grapheme_substr) if ( !u8_sub_str ) { /* Set global error code. */ - intl_error_set_code( NULL, status ); + intl_error_set_code( nullptr, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8"); + intl_error_set_custom_msg( nullptr, "Error converting output string to UTF-8"); RETURN_FALSE; } @@ -527,10 +534,10 @@ PHP_FUNCTION(grapheme_substr) if ( !u8_sub_str ) { /* Set global error code. */ - intl_error_set_code( NULL, status ); + intl_error_set_code( nullptr, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8"); + intl_error_set_custom_msg( nullptr, "Error converting output string to UTF-8"); RETURN_FALSE; } @@ -602,14 +609,14 @@ static void strstr_common_handler(INTERNAL_FUNCTION_PARAMETERS, int f_ignore_cas /* }}} */ /* {{{ Finds first occurrence of a string within another */ -PHP_FUNCTION(grapheme_strstr) +U_CFUNC PHP_FUNCTION(grapheme_strstr) { strstr_common_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0 /* f_ignore_case */); } /* }}} */ /* {{{ Finds first occurrence of a string within another */ -PHP_FUNCTION(grapheme_stristr) +U_CFUNC PHP_FUNCTION(grapheme_stristr) { strstr_common_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1 /* f_ignore_case */); } @@ -712,7 +719,7 @@ static const grapheme_extract_iter grapheme_extract_iters[] = { /* }}} */ /* {{{ Function to extract a sequence of default grapheme clusters */ -PHP_FUNCTION(grapheme_extract) +U_CFUNC PHP_FUNCTION(grapheme_extract) { char *str, *pstr; UText ut = UTEXT_INITIALIZER; @@ -723,9 +730,9 @@ PHP_FUNCTION(grapheme_extract) zend_long extract_type = GRAPHEME_EXTRACT_TYPE_COUNT; UErrorCode status; unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE]; - UBreakIterator* bi = NULL; + UBreakIterator* bi = nullptr; int ret_pos; - zval *next = NULL; /* return offset of next part of the string */ + zval *next = nullptr; /* return offset of next part of the string */ ZEND_PARSE_PARAMETERS_START(2, 5) Z_PARAM_STRING(str, str_len) @@ -740,7 +747,7 @@ PHP_FUNCTION(grapheme_extract) lstart += str_len; } - if ( NULL != next ) { + if ( nullptr != next ) { ZEND_ASSERT(Z_ISREF_P(next)); ZEND_TRY_ASSIGN_REF_LONG(next, lstart); if (UNEXPECTED(EG(exception))) { @@ -754,7 +761,7 @@ PHP_FUNCTION(grapheme_extract) } if ( lstart > INT32_MAX || lstart < 0 || (size_t)lstart >= str_len ) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "start not contained in string"); + intl_error_set( nullptr, U_ILLEGAL_ARGUMENT_ERROR, "start not contained in string"); RETURN_FALSE; } @@ -785,7 +792,7 @@ PHP_FUNCTION(grapheme_extract) pstr++; start++; if ( pstr >= str_end ) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, + intl_error_set( nullptr, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_extract: invalid input string"); RETURN_FALSE; @@ -801,7 +808,7 @@ PHP_FUNCTION(grapheme_extract) if ( -1 != grapheme_ascii_check((unsigned char *)pstr, MIN(size + 1, str_len)) ) { size_t nsize = MIN(size, str_len); - if ( NULL != next ) { + if ( nullptr != next ) { ZEND_TRY_ASSIGN_REF_LONG(next, start + nsize); } RETURN_STRINGL(pstr, nsize); @@ -812,15 +819,15 @@ PHP_FUNCTION(grapheme_extract) if ( U_FAILURE( status ) ) { /* Set global error code. */ - intl_error_set_code( NULL, status ); + intl_error_set_code( nullptr, status ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error opening UTF-8 text"); + intl_error_set_custom_msg( nullptr, "Error opening UTF-8 text"); RETURN_FALSE; } - bi = NULL; + bi = nullptr; status = U_ZERO_ERROR; bi = grapheme_get_break_iterator(u_break_iterator_buffer, &status ); @@ -835,14 +842,14 @@ PHP_FUNCTION(grapheme_extract) utext_close(&ut); ubrk_close(bi); - if ( NULL != next ) { + if ( nullptr != next ) { ZEND_TRY_ASSIGN_REF_LONG(next, start + ret_pos); } RETURN_STRINGL(((char *)pstr), ret_pos); } -PHP_FUNCTION(grapheme_str_split) +U_CFUNC PHP_FUNCTION(grapheme_str_split) { char *pstr, *end; zend_string *str; @@ -852,7 +859,7 @@ PHP_FUNCTION(grapheme_str_split) UErrorCode ustatus = U_ZERO_ERROR; int32_t pos, current, i, end_len = 0; UBreakIterator* bi; - UText *ut = NULL; + UText *ut = nullptr; ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STR(str) @@ -874,15 +881,15 @@ PHP_FUNCTION(grapheme_str_split) if ( U_FAILURE( ustatus ) ) { /* Set global error code. */ - intl_error_set_code( NULL, ustatus ); + intl_error_set_code( nullptr, ustatus ); /* Set error messages. */ - intl_error_set_custom_msg( NULL, "Error opening UTF-8 text"); + intl_error_set_custom_msg( nullptr, "Error opening UTF-8 text"); RETURN_FALSE; } - bi = NULL; + bi = nullptr; ustatus = U_ZERO_ERROR; bi = grapheme_get_break_iterator((void*)u_break_iterator_buffer, &ustatus ); @@ -920,7 +927,7 @@ PHP_FUNCTION(grapheme_str_split) ubrk_close(bi); } -PHP_FUNCTION(grapheme_levenshtein) +U_CFUNC PHP_FUNCTION(grapheme_levenshtein) { zend_string *string1, *string2; zend_long cost_ins = 1; @@ -959,11 +966,17 @@ PHP_FUNCTION(grapheme_levenshtein) size_t i2; char *pstr1, *pstr2; - UChar *ustring1 = NULL; - UChar *ustring2 = NULL; + UChar *ustring1 = nullptr; + UChar *ustring2 = nullptr; int32_t ustring1_len = 0; int32_t ustring2_len = 0; + int32_t current1 = 0; + int32_t current2 = 0; + int32_t pos1 = 0; + int32_t pos2 = 0; + + UCollator *collator = nullptr; UErrorCode ustatus = U_ZERO_ERROR; @@ -1002,8 +1015,8 @@ PHP_FUNCTION(grapheme_levenshtein) UBreakIterator *bi1, *bi2; int32_t strlen_1, strlen_2; - strlen_1 = grapheme_split_string(ustring1, ustring1_len, NULL, 0); - strlen_2 = grapheme_split_string(ustring2, ustring2_len, NULL, 0); + strlen_1 = grapheme_split_string(ustring1, ustring1_len, nullptr, 0); + strlen_2 = grapheme_split_string(ustring2, ustring2_len, nullptr, 0); if (UNEXPECTED(strlen_1 < 0 || strlen_2 < 0)) { RETVAL_FALSE; goto out_ustring2; @@ -1053,7 +1066,7 @@ PHP_FUNCTION(grapheme_levenshtein) RETVAL_FALSE; goto out_bi2; } - UCollator *collator = ucol_open(locale, &ustatus); + collator = ucol_open(locale, &ustatus); if (U_FAILURE(ustatus)) { intl_error_set_code(NULL, ustatus); @@ -1063,18 +1076,13 @@ PHP_FUNCTION(grapheme_levenshtein) } zend_long *p1, *p2, *tmp; - p1 = safe_emalloc((size_t) strlen_2 + 1, sizeof(zend_long), 0); - p2 = safe_emalloc((size_t) strlen_2 + 1, sizeof(zend_long), 0); + p1 = reinterpret_cast(safe_emalloc((size_t) strlen_2 + 1, sizeof(zend_long), 0)); + p2 = reinterpret_cast(safe_emalloc((size_t) strlen_2 + 1, sizeof(zend_long), 0)); for (i2 = 0; i2 <= strlen_2; i2++) { p1[i2] = i2 * cost_ins; } - int32_t current1 = 0; - int32_t current2 = 0; - int32_t pos1 = 0; - int32_t pos2 = 0; - while (true) { current1 = ubrk_current(bi1); pos1 = ubrk_next(bi1); diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.cpp similarity index 89% rename from ext/intl/grapheme/grapheme_util.c rename to ext/intl/grapheme/grapheme_util.cpp index 825eea9468cb3..a04f3db0b8a6d 100644 --- a/ext/intl/grapheme/grapheme_util.c +++ b/ext/intl/grapheme/grapheme_util.cpp @@ -17,10 +17,17 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include #include "grapheme.h" #include "grapheme_util.h" #include "intl_common.h" +} #include #include @@ -33,7 +40,7 @@ ZEND_EXTERN_MODULE_GLOBALS( intl ) /* }}} */ /* {{{ grapheme_close_global_iterator - clean up */ -void +U_CFUNC void grapheme_close_global_iterator( void ) { UBreakIterator *global_break_iterator = INTL_G( grapheme_iterator ); @@ -45,7 +52,7 @@ grapheme_close_global_iterator( void ) /* }}} */ /* {{{ grapheme_substr_ascii f='from' - starting point, l='length' */ -void grapheme_substr_ascii(char *str, size_t str_len, int32_t f, int32_t l, char **sub_str, int32_t *sub_str_len) +U_CFUNC void grapheme_substr_ascii(char *str, size_t str_len, int32_t f, int32_t l, char **sub_str, int32_t *sub_str_len) { int32_t str_len2 = (int32_t)str_len; /* in order to avoid signed/unsigned problems */ *sub_str = NULL; @@ -94,7 +101,7 @@ void grapheme_substr_ascii(char *str, size_t str_len, int32_t f, int32_t l, char /* {{{ grapheme_strpos_utf16 - strrpos using utf16*/ -int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char *needle, size_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case, int last, const char* locale) +U_CFUNC int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char *needle, size_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case, int last, const char* locale) { UChar *uhaystack = NULL, *uneedle = NULL; int32_t uhaystack_len = 0, uneedle_len = 0, char_pos, ret_pos, offset_pos = 0; @@ -212,7 +219,7 @@ int32_t grapheme_strpos_utf16(char *haystack, size_t haystack_len, char *needle, /* }}} */ /* {{{ grapheme_ascii_check: ASCII check */ -zend_long grapheme_ascii_check(const unsigned char *day, size_t len) +U_CFUNC zend_long grapheme_ascii_check(const unsigned char *day, size_t len) { int ret_len = len; while ( len-- ) { @@ -226,7 +233,7 @@ zend_long grapheme_ascii_check(const unsigned char *day, size_t len) /* }}} */ /* {{{ grapheme_split_string: find and optionally return grapheme boundaries */ -int32_t grapheme_split_string(const UChar *text, int32_t text_length, int boundary_array[], int boundary_array_len ) +U_CFUNC int32_t grapheme_split_string(const UChar *text, int32_t text_length, int boundary_array[], int boundary_array_len ) { unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE]; UErrorCode status = U_ZERO_ERROR; @@ -264,7 +271,7 @@ int32_t grapheme_split_string(const UChar *text, int32_t text_length, int bounda /* }}} */ /* {{{ grapheme_count_graphemes */ -int32_t grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t string_len) +U_CFUNC int32_t grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t string_len) { int ret_len = 0; int pos = 0; @@ -288,7 +295,7 @@ int32_t grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t stri /* {{{ grapheme_get_haystack_offset - bump the haystack pointer based on the grapheme count offset */ -int32_t grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset) +U_CFUNC int32_t grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset) { int32_t pos; int32_t (*iter_op)(UBreakIterator* bi); @@ -328,7 +335,7 @@ int32_t grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset) /* }}} */ /* {{{ grapheme_strrpos_ascii: borrowed from the php ext/standard/string.c */ -zend_long grapheme_strrpos_ascii(char *haystack, size_t haystack_len, char *needle, size_t needle_len, int32_t offset) +U_CFUNC zend_long grapheme_strrpos_ascii(char *haystack, size_t haystack_len, char *needle, size_t needle_len, int32_t offset) { char *p, *e; @@ -368,7 +375,7 @@ zend_long grapheme_strrpos_ascii(char *haystack, size_t haystack_len, char *need /* }}} */ /* {{{ grapheme_get_break_iterator: get a clone of the global character break iterator */ -UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status ) +U_CFUNC UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status ) { UBreakIterator *global_break_iterator = INTL_G( grapheme_iterator ); diff --git a/ext/intl/grapheme/grapheme_util.h b/ext/intl/grapheme/grapheme_util.h index 9d276a9dcfe26..57d2ace384f89 100644 --- a/ext/intl/grapheme/grapheme_util.h +++ b/ext/intl/grapheme/grapheme_util.h @@ -15,6 +15,9 @@ #ifndef GRAPHEME_GRAPHEME_UTIL_H #define GRAPHEME_GRAPHEME_UTIL_H +#ifdef __cplusplus +extern "C" { +#endif #include "php_intl.h" #include "intl_convert.h" @@ -35,6 +38,9 @@ int32_t grapheme_count_graphemes(UBreakIterator *bi, UChar *string, int32_t stri int32_t grapheme_get_haystack_offset(UBreakIterator* bi, int32_t offset); UBreakIterator* grapheme_get_break_iterator(void *stack_buffer, UErrorCode *status ); +#ifdef __cplusplus +} +#endif /* OUTSIDE_STRING: check if (possibly negative) long offset is outside the string with int32_t length */ #define OUTSIDE_STRING(offset, max_len) ( offset <= INT32_MIN || offset > INT32_MAX || (offset < 0 ? -offset > (zend_long) max_len : offset > (zend_long) max_len) ) diff --git a/ext/intl/listformatter/listformatter_arginfo.h b/ext/intl/listformatter/listformatter_arginfo.h index 3a2afa2d1c2d9..fda62aac9691d 100644 --- a/ext/intl/listformatter/listformatter_arginfo.h +++ b/ext/intl/listformatter/listformatter_arginfo.h @@ -40,59 +40,59 @@ static zend_class_entry *register_class_IntlListFormatter(void) zval const_TYPE_AND_value; ZVAL_LONG(&const_TYPE_AND_value, ULISTFMT_TYPE_AND); - zend_string *const_TYPE_AND_name = zend_string_init_interned("TYPE_AND", sizeof("TYPE_AND") - 1, 1); + zend_string *const_TYPE_AND_name = zend_string_init_interned("TYPE_AND", sizeof("TYPE_AND") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_AND_name, &const_TYPE_AND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_AND_name); + zend_string_release_ex(const_TYPE_AND_name, true); #endif #if !(U_ICU_VERSION_MAJOR_NUM >= 67) zval const_TYPE_AND_value; ZVAL_LONG(&const_TYPE_AND_value, INTL_LISTFORMATTER_FALLBACK_TYPE_AND); - zend_string *const_TYPE_AND_name = zend_string_init_interned("TYPE_AND", sizeof("TYPE_AND") - 1, 1); + zend_string *const_TYPE_AND_name = zend_string_init_interned("TYPE_AND", sizeof("TYPE_AND") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_AND_name, &const_TYPE_AND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_AND_name); + zend_string_release_ex(const_TYPE_AND_name, true); #endif #if U_ICU_VERSION_MAJOR_NUM >= 67 zval const_TYPE_OR_value; ZVAL_LONG(&const_TYPE_OR_value, ULISTFMT_TYPE_OR); - zend_string *const_TYPE_OR_name = zend_string_init_interned("TYPE_OR", sizeof("TYPE_OR") - 1, 1); + zend_string *const_TYPE_OR_name = zend_string_init_interned("TYPE_OR", sizeof("TYPE_OR") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_OR_name, &const_TYPE_OR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_OR_name); + zend_string_release_ex(const_TYPE_OR_name, true); zval const_TYPE_UNITS_value; ZVAL_LONG(&const_TYPE_UNITS_value, ULISTFMT_TYPE_UNITS); - zend_string *const_TYPE_UNITS_name = zend_string_init_interned("TYPE_UNITS", sizeof("TYPE_UNITS") - 1, 1); + zend_string *const_TYPE_UNITS_name = zend_string_init_interned("TYPE_UNITS", sizeof("TYPE_UNITS") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_UNITS_name, &const_TYPE_UNITS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_UNITS_name); + zend_string_release_ex(const_TYPE_UNITS_name, true); zval const_WIDTH_WIDE_value; ZVAL_LONG(&const_WIDTH_WIDE_value, ULISTFMT_WIDTH_WIDE); - zend_string *const_WIDTH_WIDE_name = zend_string_init_interned("WIDTH_WIDE", sizeof("WIDTH_WIDE") - 1, 1); + zend_string *const_WIDTH_WIDE_name = zend_string_init_interned("WIDTH_WIDE", sizeof("WIDTH_WIDE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WIDTH_WIDE_name, &const_WIDTH_WIDE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WIDTH_WIDE_name); + zend_string_release_ex(const_WIDTH_WIDE_name, true); #endif #if !(U_ICU_VERSION_MAJOR_NUM >= 67) zval const_WIDTH_WIDE_value; ZVAL_LONG(&const_WIDTH_WIDE_value, INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE); - zend_string *const_WIDTH_WIDE_name = zend_string_init_interned("WIDTH_WIDE", sizeof("WIDTH_WIDE") - 1, 1); + zend_string *const_WIDTH_WIDE_name = zend_string_init_interned("WIDTH_WIDE", sizeof("WIDTH_WIDE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WIDTH_WIDE_name, &const_WIDTH_WIDE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WIDTH_WIDE_name); + zend_string_release_ex(const_WIDTH_WIDE_name, true); #endif #if U_ICU_VERSION_MAJOR_NUM >= 67 zval const_WIDTH_SHORT_value; ZVAL_LONG(&const_WIDTH_SHORT_value, ULISTFMT_WIDTH_SHORT); - zend_string *const_WIDTH_SHORT_name = zend_string_init_interned("WIDTH_SHORT", sizeof("WIDTH_SHORT") - 1, 1); + zend_string *const_WIDTH_SHORT_name = zend_string_init_interned("WIDTH_SHORT", sizeof("WIDTH_SHORT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WIDTH_SHORT_name, &const_WIDTH_SHORT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WIDTH_SHORT_name); + zend_string_release_ex(const_WIDTH_SHORT_name, true); zval const_WIDTH_NARROW_value; ZVAL_LONG(&const_WIDTH_NARROW_value, ULISTFMT_WIDTH_NARROW); - zend_string *const_WIDTH_NARROW_name = zend_string_init_interned("WIDTH_NARROW", sizeof("WIDTH_NARROW") - 1, 1); + zend_string *const_WIDTH_NARROW_name = zend_string_init_interned("WIDTH_NARROW", sizeof("WIDTH_NARROW") - 1, true); zend_declare_typed_class_constant(class_entry, const_WIDTH_NARROW_name, &const_WIDTH_NARROW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WIDTH_NARROW_name); + zend_string_release_ex(const_WIDTH_NARROW_name, true); #endif return class_entry; diff --git a/ext/intl/listformatter/listformatter_class.c b/ext/intl/listformatter/listformatter_class.cpp similarity index 89% rename from ext/intl/listformatter/listformatter_class.c rename to ext/intl/listformatter/listformatter_class.cpp index 1aa849370ab8f..8a7f9ffef9c2b 100644 --- a/ext/intl/listformatter/listformatter_class.c +++ b/ext/intl/listformatter/listformatter_class.cpp @@ -12,12 +12,14 @@ +----------------------------------------------------------------------+ */ +extern "C" { #include "php.h" #include "php_intl.h" +#include "intl_convert.h" +} #include #include "listformatter_class.h" #include "listformatter_arginfo.h" -#include "intl_convert.h" static zend_object_handlers listformatter_handlers; @@ -28,7 +30,7 @@ static void listformatter_free_obj(zend_object *object) if( obj->lf_data.ulistfmt ) ulistfmt_close( obj->lf_data.ulistfmt ); - obj->lf_data.ulistfmt = NULL; + obj->lf_data.ulistfmt = nullptr; intl_error_reset( &obj->lf_data.error ); zend_object_std_dtor(&obj->zo); @@ -37,9 +39,9 @@ static void listformatter_free_obj(zend_object *object) static zend_object *listformatter_create_object(zend_class_entry *class_type) { ListFormatter_object *obj; - obj = zend_object_alloc(sizeof(ListFormatter_object), class_type); + obj = reinterpret_cast(zend_object_alloc(sizeof(ListFormatter_object), class_type)); - obj->lf_data.ulistfmt = NULL; + obj->lf_data.ulistfmt = nullptr; intl_error_reset( &obj->lf_data.error ); zend_object_std_init(&obj->zo, class_type); @@ -93,7 +95,7 @@ PHP_METHOD(IntlListFormatter, __construct) RETURN_THROWS(); } - LISTFORMATTER_OBJECT(obj) = ulistfmt_openForType(locale, type, width, &status); + LISTFORMATTER_OBJECT(obj) = ulistfmt_openForType(locale, static_cast(type), static_cast(width), &status); #else if (type != INTL_LISTFORMATTER_FALLBACK_TYPE_AND) { zend_argument_value_error(2, "contains an unsupported type. ICU 66 and below only support IntlListFormatter::TYPE_AND"); @@ -109,7 +111,7 @@ PHP_METHOD(IntlListFormatter, __construct) #endif if (U_FAILURE(status)) { - intl_error_set(NULL, status, "Constructor failed"); + intl_error_set(nullptr, status, "Constructor failed"); zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); RETURN_THROWS(); } @@ -140,7 +142,7 @@ PHP_METHOD(IntlListFormatter, format) str_val = zval_get_tmp_string(val, &tmp_str); // Convert PHP string to UTF-16 - UChar *ustr = NULL; + UChar *ustr = nullptr; int32_t ustr_len = 0; UErrorCode status = U_ZERO_ERROR; @@ -154,7 +156,7 @@ PHP_METHOD(IntlListFormatter, format) } efree(items); efree(itemLengths); - intl_error_set(NULL, status, "Failed to convert string to UTF-16"); + intl_error_set(nullptr, status, "Failed to convert string to UTF-16"); RETURN_FALSE; } @@ -165,12 +167,13 @@ PHP_METHOD(IntlListFormatter, format) UErrorCode status = U_ZERO_ERROR; int32_t resultLength; - UChar *result = NULL; + UChar *result = nullptr; + zend_string *ret = nullptr; - resultLength = ulistfmt_format(LISTFORMATTER_OBJECT(obj), items, itemLengths, count, NULL, 0, &status); + resultLength = ulistfmt_format(LISTFORMATTER_OBJECT(obj), items, itemLengths, count, nullptr, 0, &status); if (U_FAILURE(status) && status != U_BUFFER_OVERFLOW_ERROR) { - intl_error_set(NULL, status, "Failed to format list"); + intl_error_set(nullptr, status, "Failed to format list"); RETVAL_FALSE; goto cleanup; } @@ -184,17 +187,17 @@ PHP_METHOD(IntlListFormatter, format) if (result) { efree(result); } - intl_error_set(NULL, status, "Failed to format list"); + intl_error_set(nullptr, status, "Failed to format list"); RETVAL_FALSE; goto cleanup; } // Convert result back to UTF-8 - zend_string *ret = intl_convert_utf16_to_utf8(result, resultLength, &status); + ret = intl_convert_utf16_to_utf8(result, resultLength, &status); efree(result); if (!ret) { - intl_error_set(NULL, status, "Failed to convert result to UTF-8"); + intl_error_set(nullptr, status, "Failed to convert result to UTF-8"); RETVAL_FALSE; } else { RETVAL_NEW_STR(ret); @@ -237,5 +240,5 @@ void listformatter_register_class(void) memcpy(&listformatter_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); listformatter_handlers.offset = XtOffsetOf(ListFormatter_object, zo); listformatter_handlers.free_obj = listformatter_free_obj; - listformatter_handlers.clone_obj = NULL; + listformatter_handlers.clone_obj = nullptr; } diff --git a/ext/intl/listformatter/listformatter_class.h b/ext/intl/listformatter/listformatter_class.h index 8fe8137796bfb..8edbf8d63e2d0 100644 --- a/ext/intl/listformatter/listformatter_class.h +++ b/ext/intl/listformatter/listformatter_class.h @@ -46,8 +46,14 @@ static inline ListFormatter_object *php_intl_listformatter_fetch_object(zend_obj #define LISTFORMATTER_OBJECT(lfo) (lfo)->lf_data.ulistfmt +#ifdef __cplusplus +extern "C" { +#endif void listformatter_register_class( void ); extern zend_class_entry *ListFormatter_ce_ptr; +#ifdef __cplusplus +} +#endif #define INTL_LISTFORMATTER_FALLBACK_TYPE_AND 0 #define INTL_LISTFORMATTER_FALLBACK_WIDTH_WIDE 0 diff --git a/ext/intl/locale/locale_arginfo.h b/ext/intl/locale/locale_arginfo.h index 79a16452e2975..e6fde7981a98c 100644 --- a/ext/intl/locale/locale_arginfo.h +++ b/ext/intl/locale/locale_arginfo.h @@ -128,70 +128,70 @@ static zend_class_entry *register_class_Locale(void) zval const_ACTUAL_LOCALE_value; ZVAL_LONG(&const_ACTUAL_LOCALE_value, ULOC_ACTUAL_LOCALE); - zend_string *const_ACTUAL_LOCALE_name = zend_string_init_interned("ACTUAL_LOCALE", sizeof("ACTUAL_LOCALE") - 1, 1); + zend_string *const_ACTUAL_LOCALE_name = zend_string_init_interned("ACTUAL_LOCALE", sizeof("ACTUAL_LOCALE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ACTUAL_LOCALE_name, &const_ACTUAL_LOCALE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ACTUAL_LOCALE_name); + zend_string_release_ex(const_ACTUAL_LOCALE_name, true); zval const_VALID_LOCALE_value; ZVAL_LONG(&const_VALID_LOCALE_value, ULOC_VALID_LOCALE); - zend_string *const_VALID_LOCALE_name = zend_string_init_interned("VALID_LOCALE", sizeof("VALID_LOCALE") - 1, 1); + zend_string *const_VALID_LOCALE_name = zend_string_init_interned("VALID_LOCALE", sizeof("VALID_LOCALE") - 1, true); zend_declare_typed_class_constant(class_entry, const_VALID_LOCALE_name, &const_VALID_LOCALE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_VALID_LOCALE_name); + zend_string_release_ex(const_VALID_LOCALE_name, true); zval const_DEFAULT_LOCALE_value; ZVAL_NULL(&const_DEFAULT_LOCALE_value); - zend_string *const_DEFAULT_LOCALE_name = zend_string_init_interned("DEFAULT_LOCALE", sizeof("DEFAULT_LOCALE") - 1, 1); + zend_string *const_DEFAULT_LOCALE_name = zend_string_init_interned("DEFAULT_LOCALE", sizeof("DEFAULT_LOCALE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DEFAULT_LOCALE_name, &const_DEFAULT_LOCALE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_NULL)); - zend_string_release(const_DEFAULT_LOCALE_name); + zend_string_release_ex(const_DEFAULT_LOCALE_name, true); zval const_LANG_TAG_value; zend_string *const_LANG_TAG_value_str = zend_string_init(LOC_LANG_TAG, strlen(LOC_LANG_TAG), 1); ZVAL_STR(&const_LANG_TAG_value, const_LANG_TAG_value_str); - zend_string *const_LANG_TAG_name = zend_string_init_interned("LANG_TAG", sizeof("LANG_TAG") - 1, 1); + zend_string *const_LANG_TAG_name = zend_string_init_interned("LANG_TAG", sizeof("LANG_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_LANG_TAG_name, &const_LANG_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_LANG_TAG_name); + zend_string_release_ex(const_LANG_TAG_name, true); zval const_EXTLANG_TAG_value; zend_string *const_EXTLANG_TAG_value_str = zend_string_init(LOC_EXTLANG_TAG, strlen(LOC_EXTLANG_TAG), 1); ZVAL_STR(&const_EXTLANG_TAG_value, const_EXTLANG_TAG_value_str); - zend_string *const_EXTLANG_TAG_name = zend_string_init_interned("EXTLANG_TAG", sizeof("EXTLANG_TAG") - 1, 1); + zend_string *const_EXTLANG_TAG_name = zend_string_init_interned("EXTLANG_TAG", sizeof("EXTLANG_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXTLANG_TAG_name, &const_EXTLANG_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_EXTLANG_TAG_name); + zend_string_release_ex(const_EXTLANG_TAG_name, true); zval const_SCRIPT_TAG_value; zend_string *const_SCRIPT_TAG_value_str = zend_string_init(LOC_SCRIPT_TAG, strlen(LOC_SCRIPT_TAG), 1); ZVAL_STR(&const_SCRIPT_TAG_value, const_SCRIPT_TAG_value_str); - zend_string *const_SCRIPT_TAG_name = zend_string_init_interned("SCRIPT_TAG", sizeof("SCRIPT_TAG") - 1, 1); + zend_string *const_SCRIPT_TAG_name = zend_string_init_interned("SCRIPT_TAG", sizeof("SCRIPT_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_SCRIPT_TAG_name, &const_SCRIPT_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_SCRIPT_TAG_name); + zend_string_release_ex(const_SCRIPT_TAG_name, true); zval const_REGION_TAG_value; zend_string *const_REGION_TAG_value_str = zend_string_init(LOC_REGION_TAG, strlen(LOC_REGION_TAG), 1); ZVAL_STR(&const_REGION_TAG_value, const_REGION_TAG_value_str); - zend_string *const_REGION_TAG_name = zend_string_init_interned("REGION_TAG", sizeof("REGION_TAG") - 1, 1); + zend_string *const_REGION_TAG_name = zend_string_init_interned("REGION_TAG", sizeof("REGION_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_REGION_TAG_name, &const_REGION_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_REGION_TAG_name); + zend_string_release_ex(const_REGION_TAG_name, true); zval const_VARIANT_TAG_value; zend_string *const_VARIANT_TAG_value_str = zend_string_init(LOC_VARIANT_TAG, strlen(LOC_VARIANT_TAG), 1); ZVAL_STR(&const_VARIANT_TAG_value, const_VARIANT_TAG_value_str); - zend_string *const_VARIANT_TAG_name = zend_string_init_interned("VARIANT_TAG", sizeof("VARIANT_TAG") - 1, 1); + zend_string *const_VARIANT_TAG_name = zend_string_init_interned("VARIANT_TAG", sizeof("VARIANT_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_VARIANT_TAG_name, &const_VARIANT_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_VARIANT_TAG_name); + zend_string_release_ex(const_VARIANT_TAG_name, true); zval const_GRANDFATHERED_LANG_TAG_value; zend_string *const_GRANDFATHERED_LANG_TAG_value_str = zend_string_init(LOC_GRANDFATHERED_LANG_TAG, strlen(LOC_GRANDFATHERED_LANG_TAG), 1); ZVAL_STR(&const_GRANDFATHERED_LANG_TAG_value, const_GRANDFATHERED_LANG_TAG_value_str); - zend_string *const_GRANDFATHERED_LANG_TAG_name = zend_string_init_interned("GRANDFATHERED_LANG_TAG", sizeof("GRANDFATHERED_LANG_TAG") - 1, 1); + zend_string *const_GRANDFATHERED_LANG_TAG_name = zend_string_init_interned("GRANDFATHERED_LANG_TAG", sizeof("GRANDFATHERED_LANG_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_GRANDFATHERED_LANG_TAG_name, &const_GRANDFATHERED_LANG_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_GRANDFATHERED_LANG_TAG_name); + zend_string_release_ex(const_GRANDFATHERED_LANG_TAG_name, true); zval const_PRIVATE_TAG_value; zend_string *const_PRIVATE_TAG_value_str = zend_string_init(LOC_PRIVATE_TAG, strlen(LOC_PRIVATE_TAG), 1); ZVAL_STR(&const_PRIVATE_TAG_value, const_PRIVATE_TAG_value_str); - zend_string *const_PRIVATE_TAG_name = zend_string_init_interned("PRIVATE_TAG", sizeof("PRIVATE_TAG") - 1, 1); + zend_string *const_PRIVATE_TAG_name = zend_string_init_interned("PRIVATE_TAG", sizeof("PRIVATE_TAG") - 1, true); zend_declare_typed_class_constant(class_entry, const_PRIVATE_TAG_name, &const_PRIVATE_TAG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_PRIVATE_TAG_name); + zend_string_release_ex(const_PRIVATE_TAG_name, true); return class_entry; } diff --git a/ext/intl/locale/locale_methods.cpp b/ext/intl/locale/locale_methods.cpp index f7699ab335979..5cf6928a8cd3c 100644 --- a/ext/intl/locale/locale_methods.cpp +++ b/ext/intl/locale/locale_methods.cpp @@ -1574,8 +1574,6 @@ U_CFUNC PHP_FUNCTION(locale_lookup) } /* }}} */ -/* {{{ Tries to find out best available locale based on HTTP "Accept-Language" header */ -/* }}} */ /* {{{ Tries to find out best available locale based on HTTP "Accept-Language" header */ U_CFUNC PHP_FUNCTION(locale_accept_from_http) { diff --git a/ext/intl/msgformat/msgformat_helpers.cpp b/ext/intl/msgformat/msgformat_helpers.cpp index e734b2df27b84..25e8dbf869685 100644 --- a/ext/intl/msgformat/msgformat_helpers.cpp +++ b/ext/intl/msgformat/msgformat_helpers.cpp @@ -455,6 +455,7 @@ U_CFUNC void umsg_format_helper(MessageFormatter_object *mfo, char *message; spprintf(&message, 0, "Invalid UTF-8 data in string argument: " "'%s'", ZSTR_VAL(str)); + zend_tmp_string_release(tmp_str); intl_errors_set(&err, err.code, message); efree(message); delete text; diff --git a/ext/intl/normalizer/normalizer_arginfo.h b/ext/intl/normalizer/normalizer_arginfo.h index e5ef152c0423a..23ce84b1c76e1 100644 --- a/ext/intl/normalizer/normalizer_arginfo.h +++ b/ext/intl/normalizer/normalizer_arginfo.h @@ -36,63 +36,63 @@ static zend_class_entry *register_class_Normalizer(void) zval const_FORM_D_value; ZVAL_LONG(&const_FORM_D_value, NORMALIZER_FORM_D); - zend_string *const_FORM_D_name = zend_string_init_interned("FORM_D", sizeof("FORM_D") - 1, 1); + zend_string *const_FORM_D_name = zend_string_init_interned("FORM_D", sizeof("FORM_D") - 1, true); zend_declare_typed_class_constant(class_entry, const_FORM_D_name, &const_FORM_D_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FORM_D_name); + zend_string_release_ex(const_FORM_D_name, true); zval const_NFD_value; ZVAL_LONG(&const_NFD_value, NORMALIZER_NFD); - zend_string *const_NFD_name = zend_string_init_interned("NFD", sizeof("NFD") - 1, 1); + zend_string *const_NFD_name = zend_string_init_interned("NFD", sizeof("NFD") - 1, true); zend_declare_typed_class_constant(class_entry, const_NFD_name, &const_NFD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NFD_name); + zend_string_release_ex(const_NFD_name, true); zval const_FORM_KD_value; ZVAL_LONG(&const_FORM_KD_value, NORMALIZER_FORM_KD); - zend_string *const_FORM_KD_name = zend_string_init_interned("FORM_KD", sizeof("FORM_KD") - 1, 1); + zend_string *const_FORM_KD_name = zend_string_init_interned("FORM_KD", sizeof("FORM_KD") - 1, true); zend_declare_typed_class_constant(class_entry, const_FORM_KD_name, &const_FORM_KD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FORM_KD_name); + zend_string_release_ex(const_FORM_KD_name, true); zval const_NFKD_value; ZVAL_LONG(&const_NFKD_value, NORMALIZER_NFKD); - zend_string *const_NFKD_name = zend_string_init_interned("NFKD", sizeof("NFKD") - 1, 1); + zend_string *const_NFKD_name = zend_string_init_interned("NFKD", sizeof("NFKD") - 1, true); zend_declare_typed_class_constant(class_entry, const_NFKD_name, &const_NFKD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NFKD_name); + zend_string_release_ex(const_NFKD_name, true); zval const_FORM_C_value; ZVAL_LONG(&const_FORM_C_value, NORMALIZER_FORM_C); - zend_string *const_FORM_C_name = zend_string_init_interned("FORM_C", sizeof("FORM_C") - 1, 1); + zend_string *const_FORM_C_name = zend_string_init_interned("FORM_C", sizeof("FORM_C") - 1, true); zend_declare_typed_class_constant(class_entry, const_FORM_C_name, &const_FORM_C_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FORM_C_name); + zend_string_release_ex(const_FORM_C_name, true); zval const_NFC_value; ZVAL_LONG(&const_NFC_value, NORMALIZER_NFC); - zend_string *const_NFC_name = zend_string_init_interned("NFC", sizeof("NFC") - 1, 1); + zend_string *const_NFC_name = zend_string_init_interned("NFC", sizeof("NFC") - 1, true); zend_declare_typed_class_constant(class_entry, const_NFC_name, &const_NFC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NFC_name); + zend_string_release_ex(const_NFC_name, true); zval const_FORM_KC_value; ZVAL_LONG(&const_FORM_KC_value, NORMALIZER_FORM_KC); - zend_string *const_FORM_KC_name = zend_string_init_interned("FORM_KC", sizeof("FORM_KC") - 1, 1); + zend_string *const_FORM_KC_name = zend_string_init_interned("FORM_KC", sizeof("FORM_KC") - 1, true); zend_declare_typed_class_constant(class_entry, const_FORM_KC_name, &const_FORM_KC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FORM_KC_name); + zend_string_release_ex(const_FORM_KC_name, true); zval const_NFKC_value; ZVAL_LONG(&const_NFKC_value, NORMALIZER_NFKC); - zend_string *const_NFKC_name = zend_string_init_interned("NFKC", sizeof("NFKC") - 1, 1); + zend_string *const_NFKC_name = zend_string_init_interned("NFKC", sizeof("NFKC") - 1, true); zend_declare_typed_class_constant(class_entry, const_NFKC_name, &const_NFKC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NFKC_name); + zend_string_release_ex(const_NFKC_name, true); zval const_FORM_KC_CF_value; ZVAL_LONG(&const_FORM_KC_CF_value, NORMALIZER_FORM_KC_CF); - zend_string *const_FORM_KC_CF_name = zend_string_init_interned("FORM_KC_CF", sizeof("FORM_KC_CF") - 1, 1); + zend_string *const_FORM_KC_CF_name = zend_string_init_interned("FORM_KC_CF", sizeof("FORM_KC_CF") - 1, true); zend_declare_typed_class_constant(class_entry, const_FORM_KC_CF_name, &const_FORM_KC_CF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FORM_KC_CF_name); + zend_string_release_ex(const_FORM_KC_CF_name, true); zval const_NFKC_CF_value; ZVAL_LONG(&const_NFKC_CF_value, NORMALIZER_NFKC_CF); - zend_string *const_NFKC_CF_name = zend_string_init_interned("NFKC_CF", sizeof("NFKC_CF") - 1, 1); + zend_string *const_NFKC_CF_name = zend_string_init_interned("NFKC_CF", sizeof("NFKC_CF") - 1, true); zend_declare_typed_class_constant(class_entry, const_NFKC_CF_name, &const_NFKC_CF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NFKC_CF_name); + zend_string_release_ex(const_NFKC_CF_name, true); return class_entry; } diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 9ede8a92e97a8..00001e9985b7f 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -42,6 +42,7 @@ #include "locale/locale_class.h" #include "listformatter/listformatter_class.h" +#include "rangeformatter/rangeformatter_class.h" #include "dateformat/dateformat.h" #include "dateformat/dateformat_class.h" @@ -189,6 +190,10 @@ PHP_MINIT_FUNCTION( intl ) /* Register 'ListFormatter' PHP class */ listformatter_register_class( ); +#if U_ICU_VERSION_MAJOR_NUM >= 63 + /* Register 'NumberRangeFormatter' PHP class */ + rangeformatter_register_class( ); +#endif /* Register 'Normalizer' PHP class */ normalizer_register_Normalizer_class( ); diff --git a/ext/intl/rangeformatter/rangeformatter.stub.php b/ext/intl/rangeformatter/rangeformatter.stub.php new file mode 100644 index 0000000000000..eae40b5a56c23 --- /dev/null +++ b/ext/intl/rangeformatter/rangeformatter.stub.php @@ -0,0 +1,61 @@ += 63 + /** @cvalue UNUM_RANGE_COLLAPSE_AUTO */ + public const int COLLAPSE_AUTO = UNKNOWN; + + /** @cvalue UNUM_RANGE_COLLAPSE_NONE */ + public const int COLLAPSE_NONE = UNKNOWN; + + /** @cvalue UNUM_RANGE_COLLAPSE_UNIT */ + public const int COLLAPSE_UNIT = UNKNOWN; + + /** @cvalue UNUM_RANGE_COLLAPSE_ALL */ + public const int COLLAPSE_ALL = UNKNOWN; + + /** @cvalue UNUM_IDENTITY_FALLBACK_SINGLE_VALUE */ + public const int IDENTITY_FALLBACK_SINGLE_VALUE = UNKNOWN; + + /** @cvalue UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE */ + public const int IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE = UNKNOWN; + + /** @cvalue UNUM_IDENTITY_FALLBACK_APPROXIMATELY */ + public const int IDENTITY_FALLBACK_APPROXIMATELY = UNKNOWN; + + /** @cvalue UNUM_IDENTITY_FALLBACK_RANGE */ + public const int IDENTITY_FALLBACK_RANGE = UNKNOWN; +#else + public const int COLLAPSE_AUTO = 0; + + public const int COLLAPSE_NONE = 1; + + public const int COLLAPSE_UNIT = 2; + + public const int COLLAPSE_ALL = 3; + + public const int IDENTITY_FALLBACK_SINGLE_VALUE = 0; + + public const int IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE = 1; + + public const int IDENTITY_FALLBACK_APPROXIMATELY = 2; + + public const int IDENTITY_FALLBACK_RANGE = 3; +#endif + + private function __construct() {} + + public static function createFromSkeleton(string $skeleton, string $locale, int $collapse, int $identityFallback): IntlNumberRangeFormatter {} + + public function format(float|int $start, float|int $end): string {} + + public function getErrorCode(): int {} + + public function getErrorMessage(): string {} +} diff --git a/ext/intl/rangeformatter/rangeformatter_arginfo.h b/ext/intl/rangeformatter/rangeformatter_arginfo.h new file mode 100644 index 0000000000000..ef3255415d16a --- /dev/null +++ b/ext/intl/rangeformatter/rangeformatter_arginfo.h @@ -0,0 +1,148 @@ +/* This is a generated file, edit the .stub.php file instead. + * Stub hash: 7029642524e32984e893e1e050a5e0bbf275c416 */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlNumberRangeFormatter___construct, 0, 0, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_IntlNumberRangeFormatter_createFromSkeleton, 0, 4, IntlNumberRangeFormatter, 0) + ZEND_ARG_TYPE_INFO(0, skeleton, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, collapse, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, identityFallback, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_IntlNumberRangeFormatter_format, 0, 2, IS_STRING, 0) + ZEND_ARG_TYPE_MASK(0, start, MAY_BE_DOUBLE|MAY_BE_LONG, NULL) + ZEND_ARG_TYPE_MASK(0, end, MAY_BE_DOUBLE|MAY_BE_LONG, NULL) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_IntlNumberRangeFormatter_getErrorCode, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_IntlNumberRangeFormatter_getErrorMessage, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_METHOD(IntlNumberRangeFormatter, __construct); +ZEND_METHOD(IntlNumberRangeFormatter, createFromSkeleton); +ZEND_METHOD(IntlNumberRangeFormatter, format); +ZEND_METHOD(IntlNumberRangeFormatter, getErrorCode); +ZEND_METHOD(IntlNumberRangeFormatter, getErrorMessage); + +static const zend_function_entry class_IntlNumberRangeFormatter_methods[] = { + ZEND_ME(IntlNumberRangeFormatter, __construct, arginfo_class_IntlNumberRangeFormatter___construct, ZEND_ACC_PRIVATE) + ZEND_ME(IntlNumberRangeFormatter, createFromSkeleton, arginfo_class_IntlNumberRangeFormatter_createFromSkeleton, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_ME(IntlNumberRangeFormatter, format, arginfo_class_IntlNumberRangeFormatter_format, ZEND_ACC_PUBLIC) + ZEND_ME(IntlNumberRangeFormatter, getErrorCode, arginfo_class_IntlNumberRangeFormatter_getErrorCode, ZEND_ACC_PUBLIC) + ZEND_ME(IntlNumberRangeFormatter, getErrorMessage, arginfo_class_IntlNumberRangeFormatter_getErrorMessage, ZEND_ACC_PUBLIC) + ZEND_FE_END +}; + +static zend_class_entry *register_class_IntlNumberRangeFormatter(void) +{ + zend_class_entry ce, *class_entry; + + INIT_CLASS_ENTRY(ce, "IntlNumberRangeFormatter", class_IntlNumberRangeFormatter_methods); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE); +#if U_ICU_VERSION_MAJOR_NUM >= 63 + + zval const_COLLAPSE_AUTO_value; + ZVAL_LONG(&const_COLLAPSE_AUTO_value, UNUM_RANGE_COLLAPSE_AUTO); + zend_string *const_COLLAPSE_AUTO_name = zend_string_init_interned("COLLAPSE_AUTO", sizeof("COLLAPSE_AUTO") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_AUTO_name, &const_COLLAPSE_AUTO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_AUTO_name, true); + + zval const_COLLAPSE_NONE_value; + ZVAL_LONG(&const_COLLAPSE_NONE_value, UNUM_RANGE_COLLAPSE_NONE); + zend_string *const_COLLAPSE_NONE_name = zend_string_init_interned("COLLAPSE_NONE", sizeof("COLLAPSE_NONE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_NONE_name, &const_COLLAPSE_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_NONE_name, true); + + zval const_COLLAPSE_UNIT_value; + ZVAL_LONG(&const_COLLAPSE_UNIT_value, UNUM_RANGE_COLLAPSE_UNIT); + zend_string *const_COLLAPSE_UNIT_name = zend_string_init_interned("COLLAPSE_UNIT", sizeof("COLLAPSE_UNIT") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_UNIT_name, &const_COLLAPSE_UNIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_UNIT_name, true); + + zval const_COLLAPSE_ALL_value; + ZVAL_LONG(&const_COLLAPSE_ALL_value, UNUM_RANGE_COLLAPSE_ALL); + zend_string *const_COLLAPSE_ALL_name = zend_string_init_interned("COLLAPSE_ALL", sizeof("COLLAPSE_ALL") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_ALL_name, &const_COLLAPSE_ALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_ALL_name, true); + + zval const_IDENTITY_FALLBACK_SINGLE_VALUE_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_SINGLE_VALUE_value, UNUM_IDENTITY_FALLBACK_SINGLE_VALUE); + zend_string *const_IDENTITY_FALLBACK_SINGLE_VALUE_name = zend_string_init_interned("IDENTITY_FALLBACK_SINGLE_VALUE", sizeof("IDENTITY_FALLBACK_SINGLE_VALUE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_SINGLE_VALUE_name, &const_IDENTITY_FALLBACK_SINGLE_VALUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_SINGLE_VALUE_name, true); + + zval const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_value, UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE); + zend_string *const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_name = zend_string_init_interned("IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE", sizeof("IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_name, &const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_name, true); + + zval const_IDENTITY_FALLBACK_APPROXIMATELY_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_APPROXIMATELY_value, UNUM_IDENTITY_FALLBACK_APPROXIMATELY); + zend_string *const_IDENTITY_FALLBACK_APPROXIMATELY_name = zend_string_init_interned("IDENTITY_FALLBACK_APPROXIMATELY", sizeof("IDENTITY_FALLBACK_APPROXIMATELY") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_APPROXIMATELY_name, &const_IDENTITY_FALLBACK_APPROXIMATELY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_APPROXIMATELY_name, true); + + zval const_IDENTITY_FALLBACK_RANGE_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_RANGE_value, UNUM_IDENTITY_FALLBACK_RANGE); + zend_string *const_IDENTITY_FALLBACK_RANGE_name = zend_string_init_interned("IDENTITY_FALLBACK_RANGE", sizeof("IDENTITY_FALLBACK_RANGE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_RANGE_name, &const_IDENTITY_FALLBACK_RANGE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_RANGE_name, true); +#endif +#if !(U_ICU_VERSION_MAJOR_NUM >= 63) + + zval const_COLLAPSE_AUTO_value; + ZVAL_LONG(&const_COLLAPSE_AUTO_value, 0); + zend_string *const_COLLAPSE_AUTO_name = zend_string_init_interned("COLLAPSE_AUTO", sizeof("COLLAPSE_AUTO") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_AUTO_name, &const_COLLAPSE_AUTO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_AUTO_name, true); + + zval const_COLLAPSE_NONE_value; + ZVAL_LONG(&const_COLLAPSE_NONE_value, 1); + zend_string *const_COLLAPSE_NONE_name = zend_string_init_interned("COLLAPSE_NONE", sizeof("COLLAPSE_NONE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_NONE_name, &const_COLLAPSE_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_NONE_name, true); + + zval const_COLLAPSE_UNIT_value; + ZVAL_LONG(&const_COLLAPSE_UNIT_value, 2); + zend_string *const_COLLAPSE_UNIT_name = zend_string_init_interned("COLLAPSE_UNIT", sizeof("COLLAPSE_UNIT") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_UNIT_name, &const_COLLAPSE_UNIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_UNIT_name, true); + + zval const_COLLAPSE_ALL_value; + ZVAL_LONG(&const_COLLAPSE_ALL_value, 3); + zend_string *const_COLLAPSE_ALL_name = zend_string_init_interned("COLLAPSE_ALL", sizeof("COLLAPSE_ALL") - 1, true); + zend_declare_typed_class_constant(class_entry, const_COLLAPSE_ALL_name, &const_COLLAPSE_ALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_COLLAPSE_ALL_name, true); + + zval const_IDENTITY_FALLBACK_SINGLE_VALUE_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_SINGLE_VALUE_value, 0); + zend_string *const_IDENTITY_FALLBACK_SINGLE_VALUE_name = zend_string_init_interned("IDENTITY_FALLBACK_SINGLE_VALUE", sizeof("IDENTITY_FALLBACK_SINGLE_VALUE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_SINGLE_VALUE_name, &const_IDENTITY_FALLBACK_SINGLE_VALUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_SINGLE_VALUE_name, true); + + zval const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_value, 1); + zend_string *const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_name = zend_string_init_interned("IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE", sizeof("IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_name, &const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE_name, true); + + zval const_IDENTITY_FALLBACK_APPROXIMATELY_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_APPROXIMATELY_value, 2); + zend_string *const_IDENTITY_FALLBACK_APPROXIMATELY_name = zend_string_init_interned("IDENTITY_FALLBACK_APPROXIMATELY", sizeof("IDENTITY_FALLBACK_APPROXIMATELY") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_APPROXIMATELY_name, &const_IDENTITY_FALLBACK_APPROXIMATELY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_APPROXIMATELY_name, true); + + zval const_IDENTITY_FALLBACK_RANGE_value; + ZVAL_LONG(&const_IDENTITY_FALLBACK_RANGE_value, 3); + zend_string *const_IDENTITY_FALLBACK_RANGE_name = zend_string_init_interned("IDENTITY_FALLBACK_RANGE", sizeof("IDENTITY_FALLBACK_RANGE") - 1, true); + zend_declare_typed_class_constant(class_entry, const_IDENTITY_FALLBACK_RANGE_name, &const_IDENTITY_FALLBACK_RANGE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release_ex(const_IDENTITY_FALLBACK_RANGE_name, true); +#endif + + return class_entry; +} diff --git a/ext/intl/rangeformatter/rangeformatter_class.cpp b/ext/intl/rangeformatter/rangeformatter_class.cpp new file mode 100644 index 0000000000000..2042966177cb2 --- /dev/null +++ b/ext/intl/rangeformatter/rangeformatter_class.cpp @@ -0,0 +1,226 @@ +/* + +----------------------------------------------------------------------+ + | 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: Bogdan Ungureanu | + +----------------------------------------------------------------------+ +*/ + +extern "C" { + #include "php.h" + #include "zend_API.h" + #include "../intl_common.h" +} + +#if U_ICU_VERSION_MAJOR_NUM >= 63 +#include +#include +#include +#include "../intl_convertcpp.h" + +extern "C" { + #include "../intl_error.h" + #include "../php_intl.h" + #include "../intl_data.h" + #include "rangeformatter_arginfo.h" + #include "rangeformatter_class.h" + #include "intl_convert.h" +} + +using icu::number::NumberRangeFormatter; +using icu::number::NumberFormatter; +using icu::number::UnlocalizedNumberFormatter; +using icu::number::LocalizedNumberRangeFormatter; +using icu::UnicodeString; +using icu::MeasureUnit; + +static zend_object_handlers rangeformatter_handlers; +zend_class_entry *class_entry_IntlNumberRangeFormatter; + +zend_object *IntlNumberRangeFormatter_object_create(zend_class_entry *ce) +{ + IntlNumberRangeFormatter_object* intern; + + intern = reinterpret_cast(zend_object_alloc(sizeof(IntlNumberRangeFormatter_object), ce)); + zend_object_std_init(&intern->zo, ce); + object_properties_init(&intern->zo, ce); + + // Initialize rangeformatter_data structure + intl_error_init(&intern->nrf_data.error); + intern->nrf_data.unumrf = nullptr; + + intern->zo.handlers = &rangeformatter_handlers; + + return &intern->zo; +} + +U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, __construct) +{ + ZEND_PARSE_PARAMETERS_NONE(); + zend_throw_error(NULL, "Cannot directly construct %s, use createFromSkeleton method instead", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name)); +} + +U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, createFromSkeleton) +{ + char* skeleton; + char* locale; + size_t locale_len; + size_t skeleton_len; + zend_long collapse; + zend_long identityFallback; + + ZEND_PARSE_PARAMETERS_START(4,4) + Z_PARAM_STRING(skeleton, skeleton_len) + Z_PARAM_STRING(locale, locale_len) + Z_PARAM_LONG(collapse) + Z_PARAM_LONG(identityFallback) + ZEND_PARSE_PARAMETERS_END(); + + if (locale_len == 0) { + locale = (char *)intl_locale_get_default(); + } + + if (locale_len > INTL_MAX_LOCALE_LEN) { + zend_argument_value_error(2, "must be no longer than %d characters", INTL_MAX_LOCALE_LEN); + RETURN_THROWS(); + } + + if (strlen(uloc_getISO3Language(locale)) == 0) { + zend_argument_value_error(2, "\"%s\" is invalid", locale); + RETURN_THROWS(); + } + + if (collapse != UNUM_RANGE_COLLAPSE_AUTO && collapse != UNUM_RANGE_COLLAPSE_NONE && collapse != UNUM_RANGE_COLLAPSE_UNIT && collapse != UNUM_RANGE_COLLAPSE_ALL) { + zend_argument_value_error(3, "must be one of IntlNumberRangeFormatter::COLLAPSE_AUTO, IntlNumberRangeFormatter::COLLAPSE_NONE, IntlNumberRangeFormatter::COLLAPSE_UNIT, or IntlNumberRangeFormatter::COLLAPSE_ALL"); + RETURN_THROWS(); + } + + if (identityFallback != UNUM_IDENTITY_FALLBACK_SINGLE_VALUE && identityFallback != UNUM_IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE && identityFallback != UNUM_IDENTITY_FALLBACK_APPROXIMATELY && identityFallback != UNUM_IDENTITY_FALLBACK_RANGE) { + zend_argument_value_error(4, "must be one of IntlNumberRangeFormatter::IDENTITY_FALLBACK_SINGLE_VALUE, IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE, IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY, or IntlNumberRangeFormatter::IDENTITY_FALLBACK_RANGE"); + RETURN_THROWS(); + } + + UErrorCode status = U_ZERO_ERROR; + + UnicodeString skeleton_ustr(skeleton, skeleton_len); + + UnlocalizedNumberFormatter nf = NumberFormatter::forSkeleton(skeleton_ustr, status); + + if (U_FAILURE(status)) { + // override error level and use exceptions + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; + + intl_error_set(NULL, status, "Failed to create the number skeleton"); + + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; + } + + LocalizedNumberRangeFormatter* nrf = new LocalizedNumberRangeFormatter( + NumberRangeFormatter::with() + .locale(locale) + .numberFormatterBoth(nf) + .collapse(static_cast(collapse)) + .identityFallback(static_cast(identityFallback)) + ); + + zend_object* obj = IntlNumberRangeFormatter_object_create(class_entry_IntlNumberRangeFormatter); + + RANGEFORMATTER_OBJECT(php_intl_numberrangeformatter_fetch_object(obj)) = nrf; + + RETURN_OBJ(obj); +} + +U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, format) +{ + zval *start; + zval *end; + + IntlNumberRangeFormatter_object* obj = Z_INTL_RANGEFORMATTER_P(ZEND_THIS); + + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_NUMBER(start) + Z_PARAM_NUMBER(end) + ZEND_PARSE_PARAMETERS_END(); + + UErrorCode error = U_ZERO_ERROR; + + icu::Formattable start_formattable(Z_TYPE_P(start) == IS_DOUBLE ? Z_DVAL_P(start) : Z_LVAL_P(start)); + icu::Formattable end_formattable(Z_TYPE_P(end) == IS_DOUBLE ? Z_DVAL_P(end) : Z_LVAL_P(end)); + + UnicodeString result = RANGEFORMATTER_OBJECT(obj)->formatFormattableRange(start_formattable, end_formattable, error).toString(error); + + // override error level and use exceptions + const bool old_use_exception = INTL_G(use_exceptions); + const zend_long old_error_level = INTL_G(error_level); + INTL_G(use_exceptions) = true; + INTL_G(error_level) = 0; + + if (U_FAILURE(error)) { + intl_error_set(NULL, error, "Failed to format number range"); + } + + zend_string *ret = intl_charFromString(result, &error); + + if (U_FAILURE(error)) { + intl_error_set(NULL, error, "Failed to convert result to UTF-8"); + } + + INTL_G(use_exceptions) = old_use_exception; + INTL_G(error_level) = old_error_level; + + RETVAL_NEW_STR(ret); +} + +U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, getErrorCode) +{ + ZEND_PARSE_PARAMETERS_NONE(); + + IntlNumberRangeFormatter_object* obj = Z_INTL_RANGEFORMATTER_P(ZEND_THIS); + + RETURN_LONG(intl_error_get_code(&obj->nrf_data.error)); +} + +U_CFUNC PHP_METHOD(IntlNumberRangeFormatter, getErrorMessage) +{ + ZEND_PARSE_PARAMETERS_NONE(); + + IntlNumberRangeFormatter_object* obj = Z_INTL_RANGEFORMATTER_P(ZEND_THIS); + + RETURN_STR(intl_error_get_message(&obj->nrf_data.error)); +} + +void IntlNumberRangeFormatter_object_free(zend_object *object) +{ + IntlNumberRangeFormatter_object* nfo = php_intl_numberrangeformatter_fetch_object(object); + + if (nfo->nrf_data.unumrf) { + delete nfo->nrf_data.unumrf; + nfo->nrf_data.unumrf = nullptr; + } + + intl_error_reset(&nfo->nrf_data.error); + + zend_object_std_dtor(&nfo->zo); +} + +void rangeformatter_register_class(void) +{ + class_entry_IntlNumberRangeFormatter = register_class_IntlNumberRangeFormatter(); + class_entry_IntlNumberRangeFormatter->create_object = IntlNumberRangeFormatter_object_create; + + memcpy(&rangeformatter_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + rangeformatter_handlers.offset = XtOffsetOf(IntlNumberRangeFormatter_object, zo); + rangeformatter_handlers.free_obj = IntlNumberRangeFormatter_object_free; + rangeformatter_handlers.clone_obj = NULL; +} +#endif diff --git a/ext/intl/rangeformatter/rangeformatter_class.h b/ext/intl/rangeformatter/rangeformatter_class.h new file mode 100644 index 0000000000000..661641c2ce0f0 --- /dev/null +++ b/ext/intl/rangeformatter/rangeformatter_class.h @@ -0,0 +1,53 @@ +/* + +----------------------------------------------------------------------+ + | 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: Bogdan Ungureanu | + +----------------------------------------------------------------------+ +*/ + +#ifndef RANGEFORMATTER_CLASS_H +#define RANGEFORMATTER_CLASS_H + +#include + +#ifdef __cplusplus +using icu::number::LocalizedNumberRangeFormatter; +#else +typedef void LocalizedNumberRangeFormatter; +#endif + +typedef struct { + // error handling + intl_error error; + + // formatter handling + LocalizedNumberRangeFormatter* unumrf; +} rangeformatter_data; + +typedef struct { + rangeformatter_data nrf_data; + zend_object zo; +} IntlNumberRangeFormatter_object; + +static inline IntlNumberRangeFormatter_object *php_intl_numberrangeformatter_fetch_object(zend_object *obj) { + return (IntlNumberRangeFormatter_object *)((char*)(obj) - XtOffsetOf(IntlNumberRangeFormatter_object, zo)); +} + +#define Z_INTL_RANGEFORMATTER_P(zv) php_intl_numberrangeformatter_fetch_object(Z_OBJ_P(zv)) + +#define RANGEFORMATTER_ERROR(nfo) (nfo)->nrf_data.error +#define RANGEFORMATTER_ERROR_P(nfo) &(RANGEFORMATTER_ERROR(nfo)) + +#define RANGEFORMATTER_OBJECT(nfo) (nfo)->nrf_data.unumrf + + +void rangeformatter_register_class(void); + +#endif diff --git a/ext/intl/resourcebundle/resourcebundle.c b/ext/intl/resourcebundle/resourcebundle.cpp similarity index 96% rename from ext/intl/resourcebundle/resourcebundle.c rename to ext/intl/resourcebundle/resourcebundle.cpp index e29596f01872e..b8c5c00efaba6 100644 --- a/ext/intl/resourcebundle/resourcebundle.c +++ b/ext/intl/resourcebundle/resourcebundle.cpp @@ -17,12 +17,14 @@ #include #include +extern "C" { #include "intl_convert.h" #include "intl_data.h" #include "resourcebundle/resourcebundle_class.h" +} /* {{{ ResourceBundle_extract_value */ -void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *source ) +U_CFUNC void resourcebundle_extract_value( zval *return_value, ResourceBundle_object *source ) { UResType restype; const UChar* ufield; diff --git a/ext/intl/resourcebundle/resourcebundle.h b/ext/intl/resourcebundle/resourcebundle.h index ddcf75b8c50ac..c46908a8edff2 100644 --- a/ext/intl/resourcebundle/resourcebundle.h +++ b/ext/intl/resourcebundle/resourcebundle.h @@ -21,6 +21,12 @@ #include "resourcebundle/resourcebundle_class.h" +#ifdef __cplusplus +extern "C" { +#endif void resourcebundle_extract_value( zval *target, ResourceBundle_object *source); +#ifdef __cplusplus +} +#endif #endif // #ifndef RESOURCEBUNDLE_CLASS_H diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.cpp similarity index 95% rename from ext/intl/resourcebundle/resourcebundle_class.c rename to ext/intl/resourcebundle/resourcebundle_class.cpp index 165e60cc1d3a1..d88ba2ad13170 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.cpp @@ -16,19 +16,24 @@ #include #include + +extern "C" { #include +#include +} + #include #include -#include +extern "C" { #include "php_intl.h" #include "intl_data.h" #include "intl_common.h" - #include "resourcebundle/resourcebundle.h" #include "resourcebundle/resourcebundle_iterator.h" #include "resourcebundle/resourcebundle_class.h" #include "resourcebundle/resourcebundle_arginfo.h" +} zend_class_entry *ResourceBundle_ce_ptr = NULL; @@ -58,7 +63,7 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce ) { ResourceBundle_object *rb; - rb = zend_object_alloc(sizeof(ResourceBundle_object), ce); + rb = reinterpret_cast(zend_object_alloc(sizeof(ResourceBundle_object), ce)); zend_object_std_init( &rb->zend, ce ); object_properties_init( &rb->zend, ce); @@ -152,7 +157,7 @@ PHP_METHOD( ResourceBundle, __construct ) /* }}} */ /* {{{ */ -PHP_FUNCTION( resourcebundle_create ) +U_CFUNC PHP_FUNCTION( resourcebundle_create ) { object_init_ex( return_value, ResourceBundle_ce_ptr ); if (resourcebundle_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) { @@ -234,7 +239,7 @@ static zval *resource_bundle_array_fetch( /* }}} */ /* {{{ resourcebundle_array_get */ -zval *resourcebundle_array_get(zend_object *object, zval *offset, int type, zval *rv) +U_CFUNC zval *resourcebundle_array_get(zend_object *object, zval *offset, int type, zval *rv) { if (offset == NULL) { zend_throw_error(NULL, "Cannot apply [] to ResourceBundle object"); @@ -254,7 +259,7 @@ zval *resourcebundle_array_get(zend_object *object, zval *offset, int type, zval /* }}} */ /* {{{ Get resource identified by numerical index or key name. */ -PHP_FUNCTION( resourcebundle_get ) +U_CFUNC PHP_FUNCTION( resourcebundle_get ) { bool fallback = true; zend_object *resource_bundle = NULL; @@ -312,7 +317,7 @@ static zend_result resourcebundle_array_count(zend_object *object, zend_long *co /* }}} */ /* {{{ Get resources count */ -PHP_FUNCTION( resourcebundle_count ) +U_CFUNC PHP_FUNCTION( resourcebundle_count ) { int32_t len; RESOURCEBUNDLE_METHOD_INIT_VARS; @@ -328,7 +333,7 @@ PHP_FUNCTION( resourcebundle_count ) } /* {{{ Get available locales from ResourceBundle name */ -PHP_FUNCTION( resourcebundle_locales ) +U_CFUNC PHP_FUNCTION( resourcebundle_locales ) { char * bundlename; size_t bundlename_len = 0; @@ -368,7 +373,7 @@ PHP_FUNCTION( resourcebundle_locales ) /* }}} */ /* {{{ Get text description for ResourceBundle's last error code. */ -PHP_FUNCTION( resourcebundle_get_error_code ) +U_CFUNC PHP_FUNCTION( resourcebundle_get_error_code ) { RESOURCEBUNDLE_METHOD_INIT_VARS; @@ -385,7 +390,7 @@ PHP_FUNCTION( resourcebundle_get_error_code ) /* }}} */ /* {{{ Get text description for ResourceBundle's last error. */ -PHP_FUNCTION( resourcebundle_get_error_message ) +U_CFUNC PHP_FUNCTION( resourcebundle_get_error_message ) { zend_string* message = NULL; RESOURCEBUNDLE_METHOD_INIT_VARS; @@ -411,7 +416,7 @@ PHP_METHOD(ResourceBundle, getIterator) { /* {{{ resourcebundle_register_class * Initialize 'ResourceBundle' class */ -void resourcebundle_register_class( void ) +U_CFUNC void resourcebundle_register_class( void ) { ResourceBundle_ce_ptr = register_class_ResourceBundle(zend_ce_aggregate, zend_ce_countable); ResourceBundle_ce_ptr->create_object = ResourceBundle_object_create; diff --git a/ext/intl/resourcebundle/resourcebundle_class.h b/ext/intl/resourcebundle/resourcebundle_class.h index be397c8d47601..334532bde99b7 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.h +++ b/ext/intl/resourcebundle/resourcebundle_class.h @@ -18,9 +18,14 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif #include "php.h" - #include "intl_error.h" +#ifdef __cplusplus +} +#endif typedef struct { intl_error error; @@ -46,7 +51,13 @@ static inline ResourceBundle_object *php_intl_resourcebundle_fetch_object(zend_o #define RESOURCEBUNDLE_OBJECT(rb) (rb)->me +#ifdef __cplusplus +extern "C" { +#endif void resourcebundle_register_class( void ); extern zend_class_entry *ResourceBundle_ce_ptr; +#ifdef __cplusplus +} +#endif #endif // #ifndef RESOURCEBUNDLE_CLASS_H diff --git a/ext/intl/resourcebundle/resourcebundle_iterator.c b/ext/intl/resourcebundle/resourcebundle_iterator.cpp similarity index 95% rename from ext/intl/resourcebundle/resourcebundle_iterator.c rename to ext/intl/resourcebundle/resourcebundle_iterator.cpp index c79269e475070..7747b34adbd4c 100644 --- a/ext/intl/resourcebundle/resourcebundle_iterator.c +++ b/ext/intl/resourcebundle/resourcebundle_iterator.cpp @@ -12,9 +12,11 @@ +----------------------------------------------------------------------+ */ +extern "C" { #include #include #include +} #include "resourcebundle/resourcebundle.h" #include "resourcebundle/resourcebundle_class.h" @@ -145,7 +147,7 @@ static const zend_object_iterator_funcs resourcebundle_iterator_funcs = { /* }}} */ /* {{{ resourcebundle_get_iterator */ -zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref ) +U_CFUNC zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref ) { if (byref) { zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); @@ -153,7 +155,7 @@ zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *o } ResourceBundle_object *rb = Z_INTL_RESOURCEBUNDLE_P(object ); - ResourceBundle_iterator *iterator = emalloc( sizeof( ResourceBundle_iterator ) ); + ResourceBundle_iterator *iterator = reinterpret_cast(emalloc( sizeof( ResourceBundle_iterator )) ); zend_iterator_init(&iterator->intern); Z_ADDREF_P(object); diff --git a/ext/intl/resourcebundle/resourcebundle_iterator.h b/ext/intl/resourcebundle/resourcebundle_iterator.h index 1ad948723160f..c323d4e17b4c9 100644 --- a/ext/intl/resourcebundle/resourcebundle_iterator.h +++ b/ext/intl/resourcebundle/resourcebundle_iterator.h @@ -29,6 +29,12 @@ typedef struct { zend_long i; } ResourceBundle_iterator; +#ifdef __cplusplus +extern "C" { +#endif zend_object_iterator *resourcebundle_get_iterator( zend_class_entry *ce, zval *object, int byref ); +#ifdef __cplusplus +} +#endif #endif // #ifndef RESOURCEBUNDLE_ITERATOR_H diff --git a/ext/intl/spoofchecker/spoofchecker_arginfo.h b/ext/intl/spoofchecker/spoofchecker_arginfo.h index 6a3c0e55aa27d..fa8996b8f24eb 100644 --- a/ext/intl/spoofchecker/spoofchecker_arginfo.h +++ b/ext/intl/spoofchecker/spoofchecker_arginfo.h @@ -66,122 +66,122 @@ static zend_class_entry *register_class_Spoofchecker(void) zval const_SINGLE_SCRIPT_CONFUSABLE_value; ZVAL_LONG(&const_SINGLE_SCRIPT_CONFUSABLE_value, USPOOF_SINGLE_SCRIPT_CONFUSABLE); - zend_string *const_SINGLE_SCRIPT_CONFUSABLE_name = zend_string_init_interned("SINGLE_SCRIPT_CONFUSABLE", sizeof("SINGLE_SCRIPT_CONFUSABLE") - 1, 1); + zend_string *const_SINGLE_SCRIPT_CONFUSABLE_name = zend_string_init_interned("SINGLE_SCRIPT_CONFUSABLE", sizeof("SINGLE_SCRIPT_CONFUSABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SINGLE_SCRIPT_CONFUSABLE_name, &const_SINGLE_SCRIPT_CONFUSABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SINGLE_SCRIPT_CONFUSABLE_name); + zend_string_release_ex(const_SINGLE_SCRIPT_CONFUSABLE_name, true); zval const_MIXED_SCRIPT_CONFUSABLE_value; ZVAL_LONG(&const_MIXED_SCRIPT_CONFUSABLE_value, USPOOF_MIXED_SCRIPT_CONFUSABLE); - zend_string *const_MIXED_SCRIPT_CONFUSABLE_name = zend_string_init_interned("MIXED_SCRIPT_CONFUSABLE", sizeof("MIXED_SCRIPT_CONFUSABLE") - 1, 1); + zend_string *const_MIXED_SCRIPT_CONFUSABLE_name = zend_string_init_interned("MIXED_SCRIPT_CONFUSABLE", sizeof("MIXED_SCRIPT_CONFUSABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIXED_SCRIPT_CONFUSABLE_name, &const_MIXED_SCRIPT_CONFUSABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIXED_SCRIPT_CONFUSABLE_name); + zend_string_release_ex(const_MIXED_SCRIPT_CONFUSABLE_name, true); zval const_WHOLE_SCRIPT_CONFUSABLE_value; ZVAL_LONG(&const_WHOLE_SCRIPT_CONFUSABLE_value, USPOOF_WHOLE_SCRIPT_CONFUSABLE); - zend_string *const_WHOLE_SCRIPT_CONFUSABLE_name = zend_string_init_interned("WHOLE_SCRIPT_CONFUSABLE", sizeof("WHOLE_SCRIPT_CONFUSABLE") - 1, 1); + zend_string *const_WHOLE_SCRIPT_CONFUSABLE_name = zend_string_init_interned("WHOLE_SCRIPT_CONFUSABLE", sizeof("WHOLE_SCRIPT_CONFUSABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WHOLE_SCRIPT_CONFUSABLE_name, &const_WHOLE_SCRIPT_CONFUSABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WHOLE_SCRIPT_CONFUSABLE_name); + zend_string_release_ex(const_WHOLE_SCRIPT_CONFUSABLE_name, true); zval const_ANY_CASE_value; ZVAL_LONG(&const_ANY_CASE_value, USPOOF_ANY_CASE); - zend_string *const_ANY_CASE_name = zend_string_init_interned("ANY_CASE", sizeof("ANY_CASE") - 1, 1); + zend_string *const_ANY_CASE_name = zend_string_init_interned("ANY_CASE", sizeof("ANY_CASE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ANY_CASE_name, &const_ANY_CASE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ANY_CASE_name); + zend_string_release_ex(const_ANY_CASE_name, true); zval const_SINGLE_SCRIPT_value; ZVAL_LONG(&const_SINGLE_SCRIPT_value, USPOOF_SINGLE_SCRIPT); - zend_string *const_SINGLE_SCRIPT_name = zend_string_init_interned("SINGLE_SCRIPT", sizeof("SINGLE_SCRIPT") - 1, 1); + zend_string *const_SINGLE_SCRIPT_name = zend_string_init_interned("SINGLE_SCRIPT", sizeof("SINGLE_SCRIPT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SINGLE_SCRIPT_name, &const_SINGLE_SCRIPT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SINGLE_SCRIPT_name); + zend_string_release_ex(const_SINGLE_SCRIPT_name, true); zval const_INVISIBLE_value; ZVAL_LONG(&const_INVISIBLE_value, USPOOF_INVISIBLE); - zend_string *const_INVISIBLE_name = zend_string_init_interned("INVISIBLE", sizeof("INVISIBLE") - 1, 1); + zend_string *const_INVISIBLE_name = zend_string_init_interned("INVISIBLE", sizeof("INVISIBLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_INVISIBLE_name, &const_INVISIBLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INVISIBLE_name); + zend_string_release_ex(const_INVISIBLE_name, true); zval const_CHAR_LIMIT_value; ZVAL_LONG(&const_CHAR_LIMIT_value, USPOOF_CHAR_LIMIT); - zend_string *const_CHAR_LIMIT_name = zend_string_init_interned("CHAR_LIMIT", sizeof("CHAR_LIMIT") - 1, 1); + zend_string *const_CHAR_LIMIT_name = zend_string_init_interned("CHAR_LIMIT", sizeof("CHAR_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_LIMIT_name, &const_CHAR_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_LIMIT_name); + zend_string_release_ex(const_CHAR_LIMIT_name, true); #if U_ICU_VERSION_MAJOR_NUM >= 58 zval const_ASCII_value; ZVAL_LONG(&const_ASCII_value, USPOOF_ASCII); - zend_string *const_ASCII_name = zend_string_init_interned("ASCII", sizeof("ASCII") - 1, 1); + zend_string *const_ASCII_name = zend_string_init_interned("ASCII", sizeof("ASCII") - 1, true); zend_declare_typed_class_constant(class_entry, const_ASCII_name, &const_ASCII_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ASCII_name); + zend_string_release_ex(const_ASCII_name, true); zval const_HIGHLY_RESTRICTIVE_value; ZVAL_LONG(&const_HIGHLY_RESTRICTIVE_value, USPOOF_HIGHLY_RESTRICTIVE); - zend_string *const_HIGHLY_RESTRICTIVE_name = zend_string_init_interned("HIGHLY_RESTRICTIVE", sizeof("HIGHLY_RESTRICTIVE") - 1, 1); + zend_string *const_HIGHLY_RESTRICTIVE_name = zend_string_init_interned("HIGHLY_RESTRICTIVE", sizeof("HIGHLY_RESTRICTIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_HIGHLY_RESTRICTIVE_name, &const_HIGHLY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HIGHLY_RESTRICTIVE_name); + zend_string_release_ex(const_HIGHLY_RESTRICTIVE_name, true); zval const_MODERATELY_RESTRICTIVE_value; ZVAL_LONG(&const_MODERATELY_RESTRICTIVE_value, USPOOF_MODERATELY_RESTRICTIVE); - zend_string *const_MODERATELY_RESTRICTIVE_name = zend_string_init_interned("MODERATELY_RESTRICTIVE", sizeof("MODERATELY_RESTRICTIVE") - 1, 1); + zend_string *const_MODERATELY_RESTRICTIVE_name = zend_string_init_interned("MODERATELY_RESTRICTIVE", sizeof("MODERATELY_RESTRICTIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_MODERATELY_RESTRICTIVE_name, &const_MODERATELY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MODERATELY_RESTRICTIVE_name); + zend_string_release_ex(const_MODERATELY_RESTRICTIVE_name, true); zval const_MINIMALLY_RESTRICTIVE_value; ZVAL_LONG(&const_MINIMALLY_RESTRICTIVE_value, USPOOF_MINIMALLY_RESTRICTIVE); - zend_string *const_MINIMALLY_RESTRICTIVE_name = zend_string_init_interned("MINIMALLY_RESTRICTIVE", sizeof("MINIMALLY_RESTRICTIVE") - 1, 1); + zend_string *const_MINIMALLY_RESTRICTIVE_name = zend_string_init_interned("MINIMALLY_RESTRICTIVE", sizeof("MINIMALLY_RESTRICTIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_MINIMALLY_RESTRICTIVE_name, &const_MINIMALLY_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MINIMALLY_RESTRICTIVE_name); + zend_string_release_ex(const_MINIMALLY_RESTRICTIVE_name, true); zval const_UNRESTRICTIVE_value; ZVAL_LONG(&const_UNRESTRICTIVE_value, USPOOF_UNRESTRICTIVE); - zend_string *const_UNRESTRICTIVE_name = zend_string_init_interned("UNRESTRICTIVE", sizeof("UNRESTRICTIVE") - 1, 1); + zend_string *const_UNRESTRICTIVE_name = zend_string_init_interned("UNRESTRICTIVE", sizeof("UNRESTRICTIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_UNRESTRICTIVE_name, &const_UNRESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UNRESTRICTIVE_name); + zend_string_release_ex(const_UNRESTRICTIVE_name, true); zval const_SINGLE_SCRIPT_RESTRICTIVE_value; ZVAL_LONG(&const_SINGLE_SCRIPT_RESTRICTIVE_value, USPOOF_SINGLE_SCRIPT_RESTRICTIVE); - zend_string *const_SINGLE_SCRIPT_RESTRICTIVE_name = zend_string_init_interned("SINGLE_SCRIPT_RESTRICTIVE", sizeof("SINGLE_SCRIPT_RESTRICTIVE") - 1, 1); + zend_string *const_SINGLE_SCRIPT_RESTRICTIVE_name = zend_string_init_interned("SINGLE_SCRIPT_RESTRICTIVE", sizeof("SINGLE_SCRIPT_RESTRICTIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SINGLE_SCRIPT_RESTRICTIVE_name, &const_SINGLE_SCRIPT_RESTRICTIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SINGLE_SCRIPT_RESTRICTIVE_name); + zend_string_release_ex(const_SINGLE_SCRIPT_RESTRICTIVE_name, true); zval const_MIXED_NUMBERS_value; ZVAL_LONG(&const_MIXED_NUMBERS_value, USPOOF_MIXED_NUMBERS); - zend_string *const_MIXED_NUMBERS_name = zend_string_init_interned("MIXED_NUMBERS", sizeof("MIXED_NUMBERS") - 1, 1); + zend_string *const_MIXED_NUMBERS_name = zend_string_init_interned("MIXED_NUMBERS", sizeof("MIXED_NUMBERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIXED_NUMBERS_name, &const_MIXED_NUMBERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIXED_NUMBERS_name); + zend_string_release_ex(const_MIXED_NUMBERS_name, true); #endif #if U_ICU_VERSION_MAJOR_NUM >= 62 zval const_HIDDEN_OVERLAY_value; ZVAL_LONG(&const_HIDDEN_OVERLAY_value, USPOOF_HIDDEN_OVERLAY); - zend_string *const_HIDDEN_OVERLAY_name = zend_string_init_interned("HIDDEN_OVERLAY", sizeof("HIDDEN_OVERLAY") - 1, 1); + zend_string *const_HIDDEN_OVERLAY_name = zend_string_init_interned("HIDDEN_OVERLAY", sizeof("HIDDEN_OVERLAY") - 1, true); zend_declare_typed_class_constant(class_entry, const_HIDDEN_OVERLAY_name, &const_HIDDEN_OVERLAY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HIDDEN_OVERLAY_name); + zend_string_release_ex(const_HIDDEN_OVERLAY_name, true); #endif zval const_IGNORE_SPACE_value; ZVAL_LONG(&const_IGNORE_SPACE_value, USET_IGNORE_SPACE); - zend_string *const_IGNORE_SPACE_name = zend_string_init_interned("IGNORE_SPACE", sizeof("IGNORE_SPACE") - 1, 1); + zend_string *const_IGNORE_SPACE_name = zend_string_init_interned("IGNORE_SPACE", sizeof("IGNORE_SPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IGNORE_SPACE_name, &const_IGNORE_SPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IGNORE_SPACE_name); + zend_string_release_ex(const_IGNORE_SPACE_name, true); zval const_CASE_INSENSITIVE_value; ZVAL_LONG(&const_CASE_INSENSITIVE_value, USET_CASE_INSENSITIVE); - zend_string *const_CASE_INSENSITIVE_name = zend_string_init_interned("CASE_INSENSITIVE", sizeof("CASE_INSENSITIVE") - 1, 1); + zend_string *const_CASE_INSENSITIVE_name = zend_string_init_interned("CASE_INSENSITIVE", sizeof("CASE_INSENSITIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CASE_INSENSITIVE_name, &const_CASE_INSENSITIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CASE_INSENSITIVE_name); + zend_string_release_ex(const_CASE_INSENSITIVE_name, true); zval const_ADD_CASE_MAPPINGS_value; ZVAL_LONG(&const_ADD_CASE_MAPPINGS_value, USET_ADD_CASE_MAPPINGS); - zend_string *const_ADD_CASE_MAPPINGS_name = zend_string_init_interned("ADD_CASE_MAPPINGS", sizeof("ADD_CASE_MAPPINGS") - 1, 1); + zend_string *const_ADD_CASE_MAPPINGS_name = zend_string_init_interned("ADD_CASE_MAPPINGS", sizeof("ADD_CASE_MAPPINGS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ADD_CASE_MAPPINGS_name, &const_ADD_CASE_MAPPINGS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ADD_CASE_MAPPINGS_name); + zend_string_release_ex(const_ADD_CASE_MAPPINGS_name, true); #if U_ICU_VERSION_MAJOR_NUM >= 73 zval const_SIMPLE_CASE_INSENSITIVE_value; ZVAL_LONG(&const_SIMPLE_CASE_INSENSITIVE_value, USET_SIMPLE_CASE_INSENSITIVE); - zend_string *const_SIMPLE_CASE_INSENSITIVE_name = zend_string_init_interned("SIMPLE_CASE_INSENSITIVE", sizeof("SIMPLE_CASE_INSENSITIVE") - 1, 1); + zend_string *const_SIMPLE_CASE_INSENSITIVE_name = zend_string_init_interned("SIMPLE_CASE_INSENSITIVE", sizeof("SIMPLE_CASE_INSENSITIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SIMPLE_CASE_INSENSITIVE_name, &const_SIMPLE_CASE_INSENSITIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SIMPLE_CASE_INSENSITIVE_name); + zend_string_release_ex(const_SIMPLE_CASE_INSENSITIVE_name, true); #endif return class_entry; diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.cpp similarity index 90% rename from ext/intl/spoofchecker/spoofchecker_class.c rename to ext/intl/spoofchecker/spoofchecker_class.cpp index 6fa59edd47b00..ba4c64321f14e 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.c +++ b/ext/intl/spoofchecker/spoofchecker_class.cpp @@ -13,9 +13,11 @@ */ #include "spoofchecker_class.h" +extern "C" { #include "spoofchecker_arginfo.h" #include "php_intl.h" #include "intl_error.h" +} #include @@ -27,7 +29,7 @@ static zend_object_handlers Spoofchecker_handlers; */ /* {{{ Spoofchecker_objects_free */ -void Spoofchecker_objects_free(zend_object *object) +U_CFUNC void Spoofchecker_objects_free(zend_object *object) { Spoofchecker_object* co = php_intl_spoofchecker_fetch_object(object); @@ -38,11 +40,11 @@ void Spoofchecker_objects_free(zend_object *object) /* }}} */ /* {{{ Spoofchecker_object_create */ -zend_object *Spoofchecker_object_create(zend_class_entry *ce) +U_CFUNC zend_object *Spoofchecker_object_create(zend_class_entry *ce) { Spoofchecker_object* intern; - intern = zend_object_alloc(sizeof(Spoofchecker_object), ce); + intern = reinterpret_cast(zend_object_alloc(sizeof(Spoofchecker_object), ce)); intl_error_init(SPOOFCHECKER_ERROR_P(intern)); zend_object_std_init(&intern->zo, ce); object_properties_init(&intern->zo, ce); @@ -87,7 +89,7 @@ static zend_object *spoofchecker_clone_obj(zend_object *object) /* {{{ */ /* {{{ spoofchecker_register_Spoofchecker_class * Initialize 'Spoofchecker' class */ -void spoofchecker_register_Spoofchecker_class(void) +U_CFUNC void spoofchecker_register_Spoofchecker_class(void) { /* Create and register 'Spoofchecker' class. */ Spoofchecker_ce_ptr = register_class_Spoofchecker(); @@ -106,7 +108,7 @@ void spoofchecker_register_Spoofchecker_class(void) * Initialize internals of Spoofchecker_object. * Must be called before any other call to 'spoofchecker_object_...' functions. */ -void spoofchecker_object_init(Spoofchecker_object* co) +U_CFUNC void spoofchecker_object_init(Spoofchecker_object* co) { if (!co) { return; @@ -119,7 +121,7 @@ void spoofchecker_object_init(Spoofchecker_object* co) /* {{{ void spoofchecker_object_destroy( Spoofchecker_object* co ) * Clean up mem allocted by internals of Spoofchecker_object */ -void spoofchecker_object_destroy(Spoofchecker_object* co) +U_CFUNC void spoofchecker_object_destroy(Spoofchecker_object* co) { if (!co) { return; diff --git a/ext/intl/spoofchecker/spoofchecker_class.h b/ext/intl/spoofchecker/spoofchecker_class.h index a471c055c2ce6..06701eb60e36e 100644 --- a/ext/intl/spoofchecker/spoofchecker_class.h +++ b/ext/intl/spoofchecker/spoofchecker_class.h @@ -17,9 +17,15 @@ #include +#ifdef __cplusplus +extern "C" { +#endif #include "intl_common.h" #include "intl_error.h" #include "intl_data.h" +#ifdef __cplusplus +} +#endif #include @@ -47,10 +53,16 @@ static inline Spoofchecker_object *php_intl_spoofchecker_fetch_object(zend_objec #define SPOOFCHECKER_ERROR_CODE(co) INTL_ERROR_CODE(SPOOFCHECKER_ERROR(co)) #define SPOOFCHECKER_ERROR_CODE_P(co) &(INTL_ERROR_CODE(SPOOFCHECKER_ERROR(co))) +#ifdef __cplusplus +extern "C" { +#endif void spoofchecker_register_Spoofchecker_class(void); void spoofchecker_object_init(Spoofchecker_object* co); void spoofchecker_object_destroy(Spoofchecker_object* co); +#ifdef __cplusplus +} +#endif extern zend_class_entry *Spoofchecker_ce_ptr; diff --git a/ext/intl/spoofchecker/spoofchecker_create.c b/ext/intl/spoofchecker/spoofchecker_create.cpp similarity index 94% rename from ext/intl/spoofchecker/spoofchecker_create.c rename to ext/intl/spoofchecker/spoofchecker_create.cpp index 7cb51adef4e24..1ed4055cccd10 100644 --- a/ext/intl/spoofchecker/spoofchecker_create.c +++ b/ext/intl/spoofchecker/spoofchecker_create.cpp @@ -16,12 +16,19 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" -#include "spoofchecker_class.h" #include "intl_data.h" +} +#include "spoofchecker_class.h" /* {{{ Spoofchecker object constructor. */ -PHP_METHOD(Spoofchecker, __construct) +U_CFUNC PHP_METHOD(Spoofchecker, __construct) { #if U_ICU_VERSION_MAJOR_NUM < 58 int checks; diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.cpp similarity index 95% rename from ext/intl/spoofchecker/spoofchecker_main.c rename to ext/intl/spoofchecker/spoofchecker_main.cpp index 0ead525aed6f2..e49ddec87a3cb 100644 --- a/ext/intl/spoofchecker/spoofchecker_main.c +++ b/ext/intl/spoofchecker/spoofchecker_main.cpp @@ -16,12 +16,19 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" #include "intl_convert.h" +} #include "spoofchecker_class.h" /* {{{ Checks if a given text contains any suspicious characters */ -PHP_METHOD(Spoofchecker, isSuspicious) +U_CFUNC PHP_METHOD(Spoofchecker, isSuspicious) { int32_t ret, errmask; zend_string *text; @@ -62,7 +69,7 @@ PHP_METHOD(Spoofchecker, isSuspicious) /* }}} */ /* {{{ Checks if a given text contains any confusable characters */ -PHP_METHOD(Spoofchecker, areConfusable) +U_CFUNC PHP_METHOD(Spoofchecker, areConfusable) { int ret; zend_string *s1, *s2; @@ -95,7 +102,7 @@ PHP_METHOD(Spoofchecker, areConfusable) /* }}} */ /* {{{ Locales to use when running checks */ -PHP_METHOD(Spoofchecker, setAllowedLocales) +U_CFUNC PHP_METHOD(Spoofchecker, setAllowedLocales) { zend_string *locales; SPOOFCHECKER_METHOD_INIT_VARS; @@ -116,7 +123,7 @@ PHP_METHOD(Spoofchecker, setAllowedLocales) /* }}} */ /* {{{ Set the checks to run */ -PHP_METHOD(Spoofchecker, setChecks) +U_CFUNC PHP_METHOD(Spoofchecker, setChecks) { zend_long checks; SPOOFCHECKER_METHOD_INIT_VARS; @@ -136,9 +143,8 @@ PHP_METHOD(Spoofchecker, setChecks) /* }}} */ #if U_ICU_VERSION_MAJOR_NUM >= 58 -/* TODO Document this method on PHP.net */ /* {{{ Set the loosest restriction level allowed for strings. */ -PHP_METHOD(Spoofchecker, setRestrictionLevel) +U_CFUNC PHP_METHOD(Spoofchecker, setRestrictionLevel) { zend_long level; SPOOFCHECKER_METHOD_INIT_VARS; @@ -166,7 +172,7 @@ PHP_METHOD(Spoofchecker, setRestrictionLevel) /* }}} */ #endif -PHP_METHOD(Spoofchecker, setAllowedChars) +U_CFUNC PHP_METHOD(Spoofchecker, setAllowedChars) { zend_string *pattern; UChar *upattern = NULL; diff --git a/ext/intl/tests/formatter/currencies.phpt b/ext/intl/tests/formatter/currencies.phpt index 01c64a0480d37..1293283e7fc2b 100644 --- a/ext/intl/tests/formatter/currencies.phpt +++ b/ext/intl/tests/formatter/currencies.phpt @@ -1,6 +1,6 @@ --TEST-- NumberFormatter: currency formatting -----DESCRIPTION-- +--DESCRIPTION-- Tests NumberFormatter with various currenct-related formatters. --EXTENSIONS-- intl diff --git a/ext/intl/tests/msgfmt_format_error4.phpt b/ext/intl/tests/msgfmt_format_error4.phpt index 451a55ad9da94..78dc27b4092e4 100644 --- a/ext/intl/tests/msgfmt_format_error4.phpt +++ b/ext/intl/tests/msgfmt_format_error4.phpt @@ -25,9 +25,22 @@ try { var_dump($e::class === 'IntlException'); var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage()); } + +try { + var_dump($mf->format(array("foo" => new class { + function __toString(): string { + return str_repeat("\x80", random_int(1, 1)); + } + }))); +} catch (Throwable $e) { + var_dump($e::class === 'IntlException'); + var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage()); +} ?> --EXPECT-- bool(true) bool(true) bool(true) bool(true) +bool(true) +bool(true) diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt index 014bdd4749bca..9436a9e954386 100644 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt +++ b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt @@ -29,4 +29,4 @@ echo "msgf2: ", $msgf->format(array($time, 'date')), " ", ?> --EXPECTF-- Deprecated: Calling IntlGregorianCalendar::__construct() with more than 2 arguments is deprecated, use either IntlGregorianCalendar::createFromDate() or IntlGregorianCalendar::createFromDateTime() instead in %s on line %d -quinta-feira, 17 de maio de 2012 5:35:36 da tarde ptlis +quinta-feira, 17 de maio de 2012 5:35:36 %r(da tarde|p.m.)%r ptlis diff --git a/ext/intl/tests/rangeformatter/basic.phpt b/ext/intl/tests/rangeformatter/basic.phpt new file mode 100644 index 0000000000000..0e76466bc09b7 --- /dev/null +++ b/ext/intl/tests/rangeformatter/basic.phpt @@ -0,0 +1,484 @@ +--TEST-- +Basic test for IntlNumberRangeFormatter +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- + IntlNumberRangeFormatter::IDENTITY_FALLBACK_SINGLE_VALUE, + 'IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE' => IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE, + 'IDENTITY_FALLBACK_APPROXIMATELY' => IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY, + 'IDENTITY_FALLBACK_RANGE' => IntlNumberRangeFormatter::IDENTITY_FALLBACK_RANGE +]; + +$collapses = [ + 'COLLAPSE_AUTO' => IntlNumberRangeFormatter::COLLAPSE_AUTO, + 'COLLAPSE_NONE' => IntlNumberRangeFormatter::COLLAPSE_NONE, + 'COLLAPSE_UNIT' => IntlNumberRangeFormatter::COLLAPSE_UNIT, + 'COLLAPSE_ALL' => IntlNumberRangeFormatter::COLLAPSE_ALL +]; + +foreach ($languages as $language) { + foreach ($identityFallbacks as $iName => $identityFallback) { + foreach ($collapses as $cName => $collapse) { + echo PHP_EOL . $language . ' - ' . $cName . ' - ' . $iName . PHP_EOL; + $nrf = IntlNumberRangeFormatter::createFromSkeleton( + 'measure-unit/length-meter', + $language, + $collapse, + $identityFallback + ); + + var_dump($nrf->format(1.1, 2.2)); + var_dump($nrf->format(100, 200)); + var_dump($nrf->format(-5, 5)); + var_dump($nrf->format(5, 5)); + var_dump($nrf->format(5.0001, 5.0001)); + var_dump($nrf->format(5, 5.1)); + var_dump($nrf->format(5.1, 6)); + } + } +} + +?> +--EXPECT-- +en_US - COLLAPSE_AUTO - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_NONE - IDENTITY_FALLBACK_SINGLE_VALUE +string(15) "1.1 m – 2.2 m" +string(15) "100 m – 200 m" +string(12) "-5 m – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(13) "5 m – 5.1 m" +string(13) "5.1 m – 6 m" + +en_US - COLLAPSE_UNIT - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_ALL - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_AUTO - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_NONE - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(15) "1.1 m – 2.2 m" +string(15) "100 m – 200 m" +string(12) "-5 m – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(13) "5 m – 5.1 m" +string(13) "5.1 m – 6 m" + +en_US - COLLAPSE_UNIT - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_ALL - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_AUTO - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(4) "~5 m" +string(9) "~5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_NONE - IDENTITY_FALLBACK_APPROXIMATELY +string(15) "1.1 m – 2.2 m" +string(15) "100 m – 200 m" +string(12) "-5 m – 5 m" +string(4) "~5 m" +string(9) "~5.0001 m" +string(13) "5 m – 5.1 m" +string(13) "5.1 m – 6 m" + +en_US - COLLAPSE_UNIT - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(4) "~5 m" +string(9) "~5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_ALL - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(4) "~5 m" +string(9) "~5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_AUTO - IDENTITY_FALLBACK_RANGE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(7) "5–5 m" +string(17) "5.0001–5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_NONE - IDENTITY_FALLBACK_RANGE +string(15) "1.1 m – 2.2 m" +string(15) "100 m – 200 m" +string(12) "-5 m – 5 m" +string(11) "5 m – 5 m" +string(21) "5.0001 m – 5.0001 m" +string(13) "5 m – 5.1 m" +string(13) "5.1 m – 6 m" + +en_US - COLLAPSE_UNIT - IDENTITY_FALLBACK_RANGE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(7) "5–5 m" +string(17) "5.0001–5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +en_US - COLLAPSE_ALL - IDENTITY_FALLBACK_RANGE +string(11) "1.1–2.2 m" +string(11) "100–200 m" +string(10) "-5 – 5 m" +string(7) "5–5 m" +string(17) "5.0001–5.0001 m" +string(9) "5–5.1 m" +string(9) "5.1–6 m" + +RO - COLLAPSE_AUTO - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_NONE - IDENTITY_FALLBACK_SINGLE_VALUE +string(13) "1,1 m - 2,2 m" +string(13) "100 m - 200 m" +string(10) "-5 m - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(11) "5 m - 5,1 m" +string(11) "5,1 m - 6 m" + +RO - COLLAPSE_UNIT - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_ALL - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_AUTO - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_NONE - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(13) "1,1 m - 2,2 m" +string(13) "100 m - 200 m" +string(10) "-5 m - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(11) "5 m - 5,1 m" +string(11) "5,1 m - 6 m" + +RO - COLLAPSE_UNIT - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_ALL - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(3) "5 m" +string(8) "5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_AUTO - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(4) "~5 m" +string(9) "~5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_NONE - IDENTITY_FALLBACK_APPROXIMATELY +string(13) "1,1 m - 2,2 m" +string(13) "100 m - 200 m" +string(10) "-5 m - 5 m" +string(4) "~5 m" +string(9) "~5,0001 m" +string(11) "5 m - 5,1 m" +string(11) "5,1 m - 6 m" + +RO - COLLAPSE_UNIT - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(4) "~5 m" +string(9) "~5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_ALL - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(4) "~5 m" +string(9) "~5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_AUTO - IDENTITY_FALLBACK_RANGE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(7) "5 - 5 m" +string(17) "5,0001 - 5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_NONE - IDENTITY_FALLBACK_RANGE +string(13) "1,1 m - 2,2 m" +string(13) "100 m - 200 m" +string(10) "-5 m - 5 m" +string(9) "5 m - 5 m" +string(19) "5,0001 m - 5,0001 m" +string(11) "5 m - 5,1 m" +string(11) "5,1 m - 6 m" + +RO - COLLAPSE_UNIT - IDENTITY_FALLBACK_RANGE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(7) "5 - 5 m" +string(17) "5,0001 - 5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +RO - COLLAPSE_ALL - IDENTITY_FALLBACK_RANGE +string(11) "1,1 - 2,2 m" +string(11) "100 - 200 m" +string(8) "-5 - 5 m" +string(7) "5 - 5 m" +string(17) "5,0001 - 5,0001 m" +string(9) "5 - 5,1 m" +string(9) "5,1 - 6 m" + +JA - COLLAPSE_AUTO - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_NONE - IDENTITY_FALLBACK_SINGLE_VALUE +string(15) "1.1 m ~ 2.2 m" +string(15) "100 m ~ 200 m" +string(12) "-5 m ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(13) "5 m ~ 5.1 m" +string(13) "5.1 m ~ 6 m" + +JA - COLLAPSE_UNIT - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_ALL - IDENTITY_FALLBACK_SINGLE_VALUE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_AUTO - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_NONE - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(15) "1.1 m ~ 2.2 m" +string(15) "100 m ~ 200 m" +string(12) "-5 m ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(13) "5 m ~ 5.1 m" +string(13) "5.1 m ~ 6 m" + +JA - COLLAPSE_UNIT - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_ALL - IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(3) "5 m" +string(8) "5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_AUTO - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(6) "約5 m" +string(11) "約5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_NONE - IDENTITY_FALLBACK_APPROXIMATELY +string(15) "1.1 m ~ 2.2 m" +string(15) "100 m ~ 200 m" +string(12) "-5 m ~ 5 m" +string(6) "約5 m" +string(11) "約5.0001 m" +string(13) "5 m ~ 5.1 m" +string(13) "5.1 m ~ 6 m" + +JA - COLLAPSE_UNIT - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(6) "約5 m" +string(11) "約5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_ALL - IDENTITY_FALLBACK_APPROXIMATELY +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(6) "約5 m" +string(11) "約5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_AUTO - IDENTITY_FALLBACK_RANGE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(7) "5~5 m" +string(17) "5.0001~5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_NONE - IDENTITY_FALLBACK_RANGE +string(15) "1.1 m ~ 2.2 m" +string(15) "100 m ~ 200 m" +string(12) "-5 m ~ 5 m" +string(11) "5 m ~ 5 m" +string(21) "5.0001 m ~ 5.0001 m" +string(13) "5 m ~ 5.1 m" +string(13) "5.1 m ~ 6 m" + +JA - COLLAPSE_UNIT - IDENTITY_FALLBACK_RANGE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(7) "5~5 m" +string(17) "5.0001~5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" + +JA - COLLAPSE_ALL - IDENTITY_FALLBACK_RANGE +string(11) "1.1~2.2 m" +string(11) "100~200 m" +string(10) "-5 ~ 5 m" +string(7) "5~5 m" +string(17) "5.0001~5.0001 m" +string(9) "5~5.1 m" +string(9) "5.1~6 m" diff --git a/ext/intl/tests/rangeformatter/rangeformatter_clone.phpt b/ext/intl/tests/rangeformatter/rangeformatter_clone.phpt new file mode 100644 index 0000000000000..31674ba6eea25 --- /dev/null +++ b/ext/intl/tests/rangeformatter/rangeformatter_clone.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test IntlNumberRangeFormatter cannot be cloned +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- +getMessage(); +} +?> +--EXPECT-- +Trying to clone an uncloneable object of class IntlNumberRangeFormatter diff --git a/ext/intl/tests/rangeformatter/rangeformatter_errors.phpt b/ext/intl/tests/rangeformatter/rangeformatter_errors.phpt new file mode 100644 index 0000000000000..83c993d7fc98b --- /dev/null +++ b/ext/intl/tests/rangeformatter/rangeformatter_errors.phpt @@ -0,0 +1,87 @@ +--TEST-- +errors for IntlNumberRangeFormatter +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- +getMessage() . PHP_EOL; +} + +echo intl_get_error_code() . PHP_EOL; +echo intl_get_error_message() . PHP_EOL; + +try { + new IntlNumberRangeFormatter(); +} catch(Error $error) { + echo $error->getMessage() . PHP_EOL; +} + +try { + $nrf = IntlNumberRangeFormatter::createFromSkeleton( + 'invalid skeleton here', + 'ro', + 34, + IntlNumberRangeFormatter::IDENTITY_FALLBACK_SINGLE_VALUE + ); +} catch (ValueError $exception) { + echo $exception->getMessage() . PHP_EOL; +} + +try { + $nrf = IntlNumberRangeFormatter::createFromSkeleton( + 'invalid skeleton here', + 'ro', + IntlNumberRangeFormatter::COLLAPSE_AUTO, + 343 + ); +} catch (ValueError $exception) { + echo $exception->getMessage() . PHP_EOL; +} + +try { + $nrf = IntlNumberRangeFormatter::createFromSkeleton( + 'invalid skeleton here', + 'invalid-language', + IntlNumberRangeFormatter::COLLAPSE_AUTO, + IntlNumberRangeFormatter::IDENTITY_FALLBACK_SINGLE_VALUE + ); +} catch (ValueError $exception) { + echo $exception->getMessage() . PHP_EOL; +} + +try { + $nrf = IntlNumberRangeFormatter::createFromSkeleton( + 'invalid skeleton here', + 'ro_thisiswaytooooooooooooooooooooooooooooooooooooooooooooolongtobevaliditneedstobeatleast157characterstofailthevalidationinthelistformattercodeimplementation', + IntlNumberRangeFormatter::COLLAPSE_AUTO, + IntlNumberRangeFormatter::IDENTITY_FALLBACK_SINGLE_VALUE + ); +} catch (ValueError $exception) { + echo $exception->getMessage() . PHP_EOL; +} + +?> +--EXPECT-- +IntlNumberRangeFormatter::createFromSkeleton(): Failed to create the number skeleton +65811 +IntlNumberRangeFormatter::createFromSkeleton(): Failed to create the number skeleton: U_NUMBER_SKELETON_SYNTAX_ERROR +Call to private IntlNumberRangeFormatter::__construct() from global scope +IntlNumberRangeFormatter::createFromSkeleton(): Argument #3 ($collapse) must be one of IntlNumberRangeFormatter::COLLAPSE_AUTO, IntlNumberRangeFormatter::COLLAPSE_NONE, IntlNumberRangeFormatter::COLLAPSE_UNIT, or IntlNumberRangeFormatter::COLLAPSE_ALL +IntlNumberRangeFormatter::createFromSkeleton(): Argument #4 ($identityFallback) must be one of IntlNumberRangeFormatter::IDENTITY_FALLBACK_SINGLE_VALUE, IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY_OR_SINGLE_VALUE, IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY, or IntlNumberRangeFormatter::IDENTITY_FALLBACK_RANGE +IntlNumberRangeFormatter::createFromSkeleton(): Argument #2 ($locale) "invalid-language" is invalid +IntlNumberRangeFormatter::createFromSkeleton(): Argument #2 ($locale) must be no longer than 156 characters diff --git a/ext/intl/tests/rangeformatter/rangeformatter_fraction_skeleton.phpt b/ext/intl/tests/rangeformatter/rangeformatter_fraction_skeleton.phpt new file mode 100644 index 0000000000000..f054aea94b5fa --- /dev/null +++ b/ext/intl/tests/rangeformatter/rangeformatter_fraction_skeleton.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test precision skeleton with IntlNumberRangeFormatter::IDENTITY_FALLBACK_APPROXIMATELY +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- +format(5.1, 5.2)); + var_dump($nrf->format(5.01, 5.02)); + var_dump($nrf->format(5.001, 5.002)); +} + +?> +--EXPECT-- +Approximate with .## +string(9) "5.1–5.2" +string(11) "5.01–5.02" +string(2) "~5" +Approximate with .# +string(9) "5.1–5.2" +string(2) "~5" +string(2) "~5" diff --git a/ext/intl/tests/rangeformatter/rangeformatter_icu63_compatibility.phpt b/ext/intl/tests/rangeformatter/rangeformatter_icu63_compatibility.phpt new file mode 100644 index 0000000000000..9b3867161d60b --- /dev/null +++ b/ext/intl/tests/rangeformatter/rangeformatter_icu63_compatibility.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test IntlNumberRangeFormatter::createFromSkeleton throws error for ICU < 63 +--EXTENSIONS-- +intl +--SKIPIF-- += 0) { + die('skip for ICU > 63.0'); +} +?> +--FILE-- +getMessage(); +} +?> +--EXPECT-- +Class "IntlNumberRangeFormatter" not found \ No newline at end of file diff --git a/ext/intl/tests/rangeformatter/rangeformatter_with_empty_skeleton.phpt b/ext/intl/tests/rangeformatter/rangeformatter_with_empty_skeleton.phpt new file mode 100644 index 0000000000000..43afc85f2b5fa --- /dev/null +++ b/ext/intl/tests/rangeformatter/rangeformatter_with_empty_skeleton.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test an empty skeleton with IntlNumberRangeFormatter +--EXTENSIONS-- +intl +--SKIPIF-- + +--FILE-- +format(5.1, 5.2)); + +?> +--EXPECT-- +string(9) "5.1–5.2" diff --git a/ext/intl/tests/timezone_getDisplayName_variant4.phpt b/ext/intl/tests/timezone_getDisplayName_variant4.phpt index 39d71f5aa2011..ccde7f8e0ea79 100644 --- a/ext/intl/tests/timezone_getDisplayName_variant4.phpt +++ b/ext/intl/tests/timezone_getDisplayName_variant4.phpt @@ -19,12 +19,12 @@ var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_COMMONLY_USED)) var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_GENERIC_LOCATION)); ?> ---EXPECT-- -string(3) "GMT" +--EXPECTF-- +string(%d) "%r(GMT|GMT\+0)%r" string(30) "Western European Standard Time" string(13) "Portugal Time" string(21) "Western European Time" string(5) "+0000" -string(3) "GMT" -string(3) "GMT" +string(%d) "%r(GMT|GMT\+00:00)%r" +string(%d) "%r(GMT|GMT\+0)%r" string(13) "Portugal Time" diff --git a/ext/intl/timezone/timezone_arginfo.h b/ext/intl/timezone/timezone_arginfo.h index e30e9806d9d53..418d2901fe935 100644 --- a/ext/intl/timezone/timezone_arginfo.h +++ b/ext/intl/timezone/timezone_arginfo.h @@ -168,69 +168,69 @@ static zend_class_entry *register_class_IntlTimeZone(void) zval const_DISPLAY_SHORT_value; ZVAL_LONG(&const_DISPLAY_SHORT_value, TimeZone::SHORT); - zend_string *const_DISPLAY_SHORT_name = zend_string_init_interned("DISPLAY_SHORT", sizeof("DISPLAY_SHORT") - 1, 1); + zend_string *const_DISPLAY_SHORT_name = zend_string_init_interned("DISPLAY_SHORT", sizeof("DISPLAY_SHORT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_SHORT_name, &const_DISPLAY_SHORT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_SHORT_name); + zend_string_release_ex(const_DISPLAY_SHORT_name, true); zval const_DISPLAY_LONG_value; ZVAL_LONG(&const_DISPLAY_LONG_value, TimeZone::LONG); - zend_string *const_DISPLAY_LONG_name = zend_string_init_interned("DISPLAY_LONG", sizeof("DISPLAY_LONG") - 1, 1); + zend_string *const_DISPLAY_LONG_name = zend_string_init_interned("DISPLAY_LONG", sizeof("DISPLAY_LONG") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_LONG_name, &const_DISPLAY_LONG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_LONG_name); + zend_string_release_ex(const_DISPLAY_LONG_name, true); zval const_DISPLAY_SHORT_GENERIC_value; ZVAL_LONG(&const_DISPLAY_SHORT_GENERIC_value, TimeZone::SHORT_GENERIC); - zend_string *const_DISPLAY_SHORT_GENERIC_name = zend_string_init_interned("DISPLAY_SHORT_GENERIC", sizeof("DISPLAY_SHORT_GENERIC") - 1, 1); + zend_string *const_DISPLAY_SHORT_GENERIC_name = zend_string_init_interned("DISPLAY_SHORT_GENERIC", sizeof("DISPLAY_SHORT_GENERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_SHORT_GENERIC_name, &const_DISPLAY_SHORT_GENERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_SHORT_GENERIC_name); + zend_string_release_ex(const_DISPLAY_SHORT_GENERIC_name, true); zval const_DISPLAY_LONG_GENERIC_value; ZVAL_LONG(&const_DISPLAY_LONG_GENERIC_value, TimeZone::LONG_GENERIC); - zend_string *const_DISPLAY_LONG_GENERIC_name = zend_string_init_interned("DISPLAY_LONG_GENERIC", sizeof("DISPLAY_LONG_GENERIC") - 1, 1); + zend_string *const_DISPLAY_LONG_GENERIC_name = zend_string_init_interned("DISPLAY_LONG_GENERIC", sizeof("DISPLAY_LONG_GENERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_LONG_GENERIC_name, &const_DISPLAY_LONG_GENERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_LONG_GENERIC_name); + zend_string_release_ex(const_DISPLAY_LONG_GENERIC_name, true); zval const_DISPLAY_SHORT_GMT_value; ZVAL_LONG(&const_DISPLAY_SHORT_GMT_value, TimeZone::SHORT_GMT); - zend_string *const_DISPLAY_SHORT_GMT_name = zend_string_init_interned("DISPLAY_SHORT_GMT", sizeof("DISPLAY_SHORT_GMT") - 1, 1); + zend_string *const_DISPLAY_SHORT_GMT_name = zend_string_init_interned("DISPLAY_SHORT_GMT", sizeof("DISPLAY_SHORT_GMT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_SHORT_GMT_name, &const_DISPLAY_SHORT_GMT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_SHORT_GMT_name); + zend_string_release_ex(const_DISPLAY_SHORT_GMT_name, true); zval const_DISPLAY_LONG_GMT_value; ZVAL_LONG(&const_DISPLAY_LONG_GMT_value, TimeZone::LONG_GMT); - zend_string *const_DISPLAY_LONG_GMT_name = zend_string_init_interned("DISPLAY_LONG_GMT", sizeof("DISPLAY_LONG_GMT") - 1, 1); + zend_string *const_DISPLAY_LONG_GMT_name = zend_string_init_interned("DISPLAY_LONG_GMT", sizeof("DISPLAY_LONG_GMT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_LONG_GMT_name, &const_DISPLAY_LONG_GMT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_LONG_GMT_name); + zend_string_release_ex(const_DISPLAY_LONG_GMT_name, true); zval const_DISPLAY_SHORT_COMMONLY_USED_value; ZVAL_LONG(&const_DISPLAY_SHORT_COMMONLY_USED_value, TimeZone::SHORT_COMMONLY_USED); - zend_string *const_DISPLAY_SHORT_COMMONLY_USED_name = zend_string_init_interned("DISPLAY_SHORT_COMMONLY_USED", sizeof("DISPLAY_SHORT_COMMONLY_USED") - 1, 1); + zend_string *const_DISPLAY_SHORT_COMMONLY_USED_name = zend_string_init_interned("DISPLAY_SHORT_COMMONLY_USED", sizeof("DISPLAY_SHORT_COMMONLY_USED") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_SHORT_COMMONLY_USED_name, &const_DISPLAY_SHORT_COMMONLY_USED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_SHORT_COMMONLY_USED_name); + zend_string_release_ex(const_DISPLAY_SHORT_COMMONLY_USED_name, true); zval const_DISPLAY_GENERIC_LOCATION_value; ZVAL_LONG(&const_DISPLAY_GENERIC_LOCATION_value, TimeZone::GENERIC_LOCATION); - zend_string *const_DISPLAY_GENERIC_LOCATION_name = zend_string_init_interned("DISPLAY_GENERIC_LOCATION", sizeof("DISPLAY_GENERIC_LOCATION") - 1, 1); + zend_string *const_DISPLAY_GENERIC_LOCATION_name = zend_string_init_interned("DISPLAY_GENERIC_LOCATION", sizeof("DISPLAY_GENERIC_LOCATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_DISPLAY_GENERIC_LOCATION_name, &const_DISPLAY_GENERIC_LOCATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DISPLAY_GENERIC_LOCATION_name); + zend_string_release_ex(const_DISPLAY_GENERIC_LOCATION_name, true); zval const_TYPE_ANY_value; ZVAL_LONG(&const_TYPE_ANY_value, UCAL_ZONE_TYPE_ANY); - zend_string *const_TYPE_ANY_name = zend_string_init_interned("TYPE_ANY", sizeof("TYPE_ANY") - 1, 1); + zend_string *const_TYPE_ANY_name = zend_string_init_interned("TYPE_ANY", sizeof("TYPE_ANY") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_ANY_name, &const_TYPE_ANY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_ANY_name); + zend_string_release_ex(const_TYPE_ANY_name, true); zval const_TYPE_CANONICAL_value; ZVAL_LONG(&const_TYPE_CANONICAL_value, UCAL_ZONE_TYPE_CANONICAL); - zend_string *const_TYPE_CANONICAL_name = zend_string_init_interned("TYPE_CANONICAL", sizeof("TYPE_CANONICAL") - 1, 1); + zend_string *const_TYPE_CANONICAL_name = zend_string_init_interned("TYPE_CANONICAL", sizeof("TYPE_CANONICAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_CANONICAL_name, &const_TYPE_CANONICAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_CANONICAL_name); + zend_string_release_ex(const_TYPE_CANONICAL_name, true); zval const_TYPE_CANONICAL_LOCATION_value; ZVAL_LONG(&const_TYPE_CANONICAL_LOCATION_value, UCAL_ZONE_TYPE_CANONICAL_LOCATION); - zend_string *const_TYPE_CANONICAL_LOCATION_name = zend_string_init_interned("TYPE_CANONICAL_LOCATION", sizeof("TYPE_CANONICAL_LOCATION") - 1, 1); + zend_string *const_TYPE_CANONICAL_LOCATION_name = zend_string_init_interned("TYPE_CANONICAL_LOCATION", sizeof("TYPE_CANONICAL_LOCATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_TYPE_CANONICAL_LOCATION_name, &const_TYPE_CANONICAL_LOCATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TYPE_CANONICAL_LOCATION_name); + zend_string_release_ex(const_TYPE_CANONICAL_LOCATION_name, true); return class_entry; } diff --git a/ext/intl/transliterator/transliterator_arginfo.h b/ext/intl/transliterator/transliterator_arginfo.h index 6f74b55521df3..c5a5bcc6090dd 100644 --- a/ext/intl/transliterator/transliterator_arginfo.h +++ b/ext/intl/transliterator/transliterator_arginfo.h @@ -62,21 +62,21 @@ static zend_class_entry *register_class_Transliterator(void) zval const_FORWARD_value; ZVAL_LONG(&const_FORWARD_value, TRANSLITERATOR_FORWARD); - zend_string *const_FORWARD_name = zend_string_init_interned("FORWARD", sizeof("FORWARD") - 1, 1); + zend_string *const_FORWARD_name = zend_string_init_interned("FORWARD", sizeof("FORWARD") - 1, true); zend_declare_typed_class_constant(class_entry, const_FORWARD_name, &const_FORWARD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FORWARD_name); + zend_string_release_ex(const_FORWARD_name, true); zval const_REVERSE_value; ZVAL_LONG(&const_REVERSE_value, TRANSLITERATOR_REVERSE); - zend_string *const_REVERSE_name = zend_string_init_interned("REVERSE", sizeof("REVERSE") - 1, 1); + zend_string *const_REVERSE_name = zend_string_init_interned("REVERSE", sizeof("REVERSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_REVERSE_name, &const_REVERSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REVERSE_name); + zend_string_release_ex(const_REVERSE_name, true); zval property_id_default_value; ZVAL_UNDEF(&property_id_default_value); - zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, 1); + zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, true); zend_declare_typed_property(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_id_name); + zend_string_release_ex(property_id_name, true); return class_entry; } diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.cpp similarity index 88% rename from ext/intl/transliterator/transliterator_class.c rename to ext/intl/transliterator/transliterator_class.cpp index 438b71c2c417a..fd0cd4f3c3e64 100644 --- a/ext/intl/transliterator/transliterator_class.c +++ b/ext/intl/transliterator/transliterator_class.cpp @@ -13,22 +13,24 @@ */ #include "transliterator_class.h" +extern "C" { #include "php_intl.h" -#include "transliterator_arginfo.h" #include "intl_error.h" #include "intl_convert.h" #include "intl_data.h" +#include "transliterator_arginfo.h" +} #include -zend_class_entry *Transliterator_ce_ptr = NULL; +zend_class_entry *Transliterator_ce_ptr = nullptr; zend_object_handlers Transliterator_handlers; /* {{{ int transliterator_object_construct( zval *object, UTransliterator *utrans, UErrorCode *status ) * Initialize internals of Transliterator_object. */ -int transliterator_object_construct( zval *object, +U_CFUNC int transliterator_object_construct( zval *object, UTransliterator *utrans, UErrorCode *status ) { @@ -40,7 +42,7 @@ int transliterator_object_construct( zval *object, TRANSLITERATOR_METHOD_FETCH_OBJECT_NO_CHECK; - assert( to->utrans == NULL ); + assert( to->utrans == nullptr ); /* this assignment must happen before any return with failure because the * caller relies on it always being made (so it can just destroy the object * to close the transliterator) */ @@ -88,7 +90,7 @@ static void transliterator_object_destroy( Transliterator_object* to ) if( to->utrans ) { utrans_close( to->utrans ); - to->utrans = NULL; + to->utrans = nullptr; } intl_error_reset( TRANSLITERATOR_ERROR_P( to ) ); @@ -111,7 +113,7 @@ static zend_object *Transliterator_object_create( zend_class_entry *ce ) { Transliterator_object* intern; - intern = zend_object_alloc(sizeof(Transliterator_object), ce); + intern = reinterpret_cast(zend_object_alloc(sizeof(Transliterator_object), ce)); zend_object_std_init( &intern->zo, ce ); object_properties_init( &intern->zo, ce ); @@ -133,22 +135,22 @@ static zend_object *Transliterator_clone_obj( zend_object *object ) Transliterator_object *to_new = php_intl_transliterator_fetch_object(ret_val); zend_objects_clone_members( &to_new->zo, &to_orig->zo ); - if (to_orig->utrans != NULL) { - /* guaranteed to return NULL if it fails */ + if (to_orig->utrans != nullptr) { + /* guaranteed to return nullptr if it fails */ UErrorCode error = U_ZERO_ERROR; UTransliterator *utrans = utrans_clone( to_orig->utrans, &error); if (U_FAILURE(error)) { - if (utrans != NULL) { + if (utrans != nullptr) { transliterator_object_destroy(to_new); } - zend_throw_error(NULL, "Failed to clone Transliterator"); + zend_throw_error(nullptr, "Failed to clone Transliterator"); } else { to_new->utrans = utrans; } } else { /* We shouldn't have unconstructed objects in the first place */ - zend_throw_error(NULL, "Cannot clone uninitialized Transliterator"); + zend_throw_error(nullptr, "Cannot clone uninitialized Transliterator"); } return ret_val; @@ -158,7 +160,7 @@ static zend_object *Transliterator_clone_obj( zend_object *object ) /* {{{ transliterator_register_Transliterator_class * Initialize 'Transliterator' class */ -void transliterator_register_Transliterator_class( void ) +U_CFUNC void transliterator_register_Transliterator_class( void ) { /* Create and register 'Transliterator' class. */ Transliterator_ce_ptr = register_class_Transliterator(); diff --git a/ext/intl/transliterator/transliterator_class.h b/ext/intl/transliterator/transliterator_class.h index 2ce85d6cfdb74..7e02d6fa5e287 100644 --- a/ext/intl/transliterator/transliterator_class.h +++ b/ext/intl/transliterator/transliterator_class.h @@ -17,8 +17,14 @@ #include +#ifdef __cplusplus +extern "C" { +#endif #include "intl_common.h" #include "intl_error.h" +#ifdef __cplusplus +} +#endif #include @@ -56,6 +62,9 @@ static inline Transliterator_object *php_intl_transliterator_fetch_object(zend_o RETURN_THROWS(); \ } +#ifdef __cplusplus +extern "C" { +#endif int transliterator_object_construct( zval *object, UTransliterator *utrans, UErrorCode *status ); @@ -64,5 +73,8 @@ void transliterator_register_Transliterator_class( void ); extern zend_class_entry *Transliterator_ce_ptr; extern zend_object_handlers Transliterator_handlers; +#ifdef __cplusplus +} +#endif #endif /* #ifndef TRANSLITERATOR_CLASS_H */ diff --git a/ext/intl/transliterator/transliterator_methods.c b/ext/intl/transliterator/transliterator_methods.cpp similarity index 84% rename from ext/intl/transliterator/transliterator_methods.c rename to ext/intl/transliterator/transliterator_methods.cpp index 9c1f48608cf21..d8a8cbb7a49ec 100644 --- a/ext/intl/transliterator/transliterator_methods.c +++ b/ext/intl/transliterator/transliterator_methods.cpp @@ -16,23 +16,30 @@ #include #endif +#if __cplusplus >= 201703L +#include +#include +#endif + +extern "C" { #include "php_intl.h" -#include "transliterator.h" -#include "transliterator_class.h" #include "intl_data.h" #include "intl_convert.h" +} +#include "transliterator.h" +#include "transliterator_class.h" #include static int create_transliterator( char *str_id, size_t str_id_len, zend_long direction, zval *object ) { Transliterator_object *to; - UChar *ustr_id = NULL; + UChar *ustr_id = nullptr; int32_t ustr_id_len = 0; UTransliterator *utrans; UParseError parse_error; - intl_error_reset( NULL ); + intl_error_reset( nullptr ); if( ( direction != TRANSLITERATOR_FORWARD ) && (direction != TRANSLITERATOR_REVERSE ) ) { @@ -47,31 +54,31 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir intl_convert_utf8_to_utf16( &ustr_id, &ustr_id_len, str_id, str_id_len, TRANSLITERATOR_ERROR_CODE_P( to ) ); if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to ) ) ) { - intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); - intl_error_set_custom_msg( NULL, "String conversion of id to UTF-16 failed"); + intl_error_set_code( nullptr, TRANSLITERATOR_ERROR_CODE( to ) ); + intl_error_set_custom_msg( nullptr, "String conversion of id to UTF-16 failed"); zval_ptr_dtor( object ); return FAILURE; } /* Open ICU Transliterator. */ utrans = utrans_openU( ustr_id, ustr_id_len, (UTransDirection ) direction, - NULL, -1, &parse_error, TRANSLITERATOR_ERROR_CODE_P( to ) ); + nullptr, -1, &parse_error, TRANSLITERATOR_ERROR_CODE_P( to ) ); if (ustr_id) { efree( ustr_id ); } if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to ) ) ) { - char *buf = NULL; - intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); + char *buf = nullptr; + intl_error_set_code( nullptr, TRANSLITERATOR_ERROR_CODE( to ) ); spprintf( &buf, 0, "unable to open ICU transliterator" " with id \"%s\"", str_id ); - if( buf == NULL ) { - intl_error_set_custom_msg(NULL, "unable to open ICU transliterator"); + if( buf == nullptr ) { + intl_error_set_custom_msg(nullptr, "unable to open ICU transliterator"); } else { - intl_error_set_custom_msg(NULL, buf); + intl_error_set_custom_msg(nullptr, buf); efree( buf ); } zval_ptr_dtor( object ); @@ -82,8 +89,8 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir /* no need to close the transliterator manually on construction error */ if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to ) ) ) { - intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); - intl_error_set_custom_msg(NULL, "internal constructor call failed"); + intl_error_set_code( nullptr, TRANSLITERATOR_ERROR_CODE( to ) ); + intl_error_set_custom_msg(nullptr, "internal constructor call failed"); zval_ptr_dtor( object ); return FAILURE; } @@ -92,7 +99,7 @@ static int create_transliterator( char *str_id, size_t str_id_len, zend_long dir } /* {{{ Opens a transliterator by id. */ -PHP_FUNCTION( transliterator_create ) +U_CFUNC PHP_FUNCTION( transliterator_create ) { char *str_id; size_t str_id_len; @@ -119,11 +126,11 @@ PHP_FUNCTION( transliterator_create ) /* }}} */ /* {{{ Opens a transliterator by id. */ -PHP_FUNCTION( transliterator_create_from_rules ) +U_CFUNC PHP_FUNCTION( transliterator_create_from_rules ) { char *str_rules; size_t str_rules_len; - UChar *ustr_rules = NULL; + UChar *ustr_rules = nullptr; int32_t ustr_rules_len = 0; zend_long direction = TRANSLITERATOR_FORWARD; UParseError parse_error; @@ -161,16 +168,16 @@ PHP_FUNCTION( transliterator_create_from_rules ) efree( ustr_rules ); } - intl_error_set_code( NULL, INTL_DATA_ERROR_CODE( to ) ); + intl_error_set_code( nullptr, INTL_DATA_ERROR_CODE( to ) ); if( U_FAILURE( INTL_DATA_ERROR_CODE( to ) ) ) { - char *msg = NULL; + char *msg = nullptr; smart_str parse_error_str; parse_error_str = intl_parse_error_to_string( &parse_error ); spprintf( &msg, 0, "unable to " "create ICU transliterator from rules (%s)", parse_error_str.s? ZSTR_VAL(parse_error_str.s) : "" ); smart_str_free( &parse_error_str ); - if( msg != NULL ) + if( msg != nullptr ) { intl_errors_set_custom_msg( INTL_DATA_ERROR_P( to ), msg); efree( msg ); @@ -185,7 +192,7 @@ PHP_FUNCTION( transliterator_create_from_rules ) /* }}} */ /* {{{ Opens the inverse transliterator transliterator. */ -PHP_FUNCTION( transliterator_create_inverse ) +U_CFUNC PHP_FUNCTION( transliterator_create_inverse ) { Transliterator_object *to_orig; UTransliterator *utrans; @@ -214,14 +221,14 @@ PHP_FUNCTION( transliterator_create_inverse ) /* }}} */ /* {{{ Return an array with the registered transliterator IDs. */ -PHP_FUNCTION( transliterator_list_ids ) +U_CFUNC PHP_FUNCTION( transliterator_list_ids ) { UEnumeration *en; const UChar *elem; int32_t elem_len; UErrorCode status = U_ZERO_ERROR; - intl_error_reset( NULL ); + intl_error_reset( nullptr ); ZEND_PARSE_PARAMETERS_NONE(); @@ -245,23 +252,23 @@ PHP_FUNCTION( transliterator_list_ids ) } uenum_close( en ); - intl_error_set_code( NULL, status ); + intl_error_set_code( nullptr, status ); if( U_FAILURE( status ) ) { zend_array_destroy( Z_ARR_P(return_value) ); RETVAL_FALSE; - intl_error_set_custom_msg( NULL, + intl_error_set_custom_msg( nullptr, "Failed to build array of registered transliterators"); } } /* }}} */ /* {{{ Transliterate a string. */ -PHP_FUNCTION( transliterator_transliterate ) +U_CFUNC PHP_FUNCTION( transliterator_transliterate ) { char *str; - UChar *ustr = NULL, - *uresult = NULL; + UChar *ustr = nullptr, + *uresult = nullptr; size_t str_len; int32_t ustr_len = 0, capacity, @@ -276,7 +283,7 @@ PHP_FUNCTION( transliterator_transliterate ) ZVAL_UNDEF(&tmp_object); - if (object == NULL) { + if (object == nullptr) { /* in non-OOP version, accept both a transliterator and a string */ zend_string *arg1_str; zend_object *arg1_obj; @@ -296,8 +303,8 @@ PHP_FUNCTION( transliterator_transliterate ) if( res == FAILURE ) { if (!EG(exception)) { - zend_string *message = intl_error_get_message( NULL ); - php_error_docref(NULL, E_WARNING, "Could not create transliterator with ID \"%s\" (%s)", ZSTR_VAL(arg1_str), ZSTR_VAL(message) ); + zend_string *message = intl_error_get_message( nullptr ); + php_error_docref(nullptr, E_WARNING, "Could not create transliterator with ID \"%s\" (%s)", ZSTR_VAL(arg1_str), ZSTR_VAL(message) ); zend_string_free( message ); } ZVAL_UNDEF(&tmp_object); @@ -343,7 +350,7 @@ PHP_FUNCTION( transliterator_transliterate ) "Neither \"start\" nor the \"end\" " "arguments can exceed the number of UTF-16 code units " "(in this case, %d)", (int) ustr_len ); - if(msg != NULL ) + if(msg != nullptr ) { intl_errors_set(TRANSLITERATOR_ERROR_P(to), U_ILLEGAL_ARGUMENT_ERROR, msg); efree( msg ); @@ -351,7 +358,7 @@ PHP_FUNCTION( transliterator_transliterate ) goto cleanup; } - uresult = safe_emalloc( ustr_len, sizeof( UChar ), 1 * sizeof( UChar ) ); + uresult = reinterpret_cast(safe_emalloc( ustr_len, sizeof( UChar ), 1 * sizeof( UChar ) )); capacity = ustr_len + 1; while( 1 ) @@ -366,21 +373,21 @@ PHP_FUNCTION( transliterator_transliterate ) { efree( uresult ); - uresult = safe_emalloc( uresult_len, sizeof( UChar ), 1 * sizeof( UChar ) ); + uresult = reinterpret_cast(safe_emalloc( uresult_len, sizeof( UChar ), 1 * sizeof( UChar ) )); capacity = uresult_len + 1; intl_error_reset( TRANSLITERATOR_ERROR_P( to ) ); } else if(TRANSLITERATOR_ERROR_CODE( to ) == U_STRING_NOT_TERMINATED_WARNING ) { - uresult = safe_erealloc( uresult, uresult_len, sizeof( UChar ), 1 * sizeof( UChar ) ); + uresult = reinterpret_cast(safe_erealloc( uresult, uresult_len, sizeof( UChar ), 1 * sizeof( UChar ) )); intl_error_reset( TRANSLITERATOR_ERROR_P( to ) ); break; } else if( U_FAILURE( TRANSLITERATOR_ERROR_CODE( to ) ) ) { - intl_error_set_code( NULL, TRANSLITERATOR_ERROR_CODE( to ) ); + intl_error_set_code( nullptr, TRANSLITERATOR_ERROR_CODE( to ) ); intl_errors_set_custom_msg( TRANSLITERATOR_ERROR_P( to ), "transliteration failed"); goto cleanup; } @@ -412,16 +419,16 @@ PHP_FUNCTION( transliterator_transliterate ) } /* }}} */ -PHP_METHOD( Transliterator, __construct ) +U_CFUNC PHP_METHOD( Transliterator, __construct ) { /* this constructor shouldn't be called as it's private */ - zend_throw_exception( NULL, + zend_throw_exception( nullptr, "An object of this type cannot be created with the new operator.", 0 ); } /* {{{ Get the last error code for this transliterator. */ -PHP_FUNCTION( transliterator_get_error_code ) +U_CFUNC PHP_FUNCTION( transliterator_get_error_code ) { TRANSLITERATOR_METHOD_INIT_VARS @@ -440,9 +447,9 @@ PHP_FUNCTION( transliterator_get_error_code ) /* {{{ Get the last error message for this transliterator. */ -PHP_FUNCTION( transliterator_get_error_message ) +U_CFUNC PHP_FUNCTION( transliterator_get_error_message ) { - zend_string* message = NULL; + zend_string* message = nullptr; TRANSLITERATOR_METHOD_INIT_VARS if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "O", diff --git a/ext/intl/uchar/uchar_arginfo.h b/ext/intl/uchar/uchar_arginfo.h index f290fb2b958ec..9f69dc597c219 100644 --- a/ext/intl/uchar/uchar_arginfo.h +++ b/ext/intl/uchar/uchar_arginfo.h @@ -311,4001 +311,4001 @@ static zend_class_entry *register_class_IntlChar(void) zval const_UNICODE_VERSION_value; zend_string *const_UNICODE_VERSION_value_str = zend_string_init(U_UNICODE_VERSION, strlen(U_UNICODE_VERSION), 1); ZVAL_STR(&const_UNICODE_VERSION_value, const_UNICODE_VERSION_value_str); - zend_string *const_UNICODE_VERSION_name = zend_string_init_interned("UNICODE_VERSION", sizeof("UNICODE_VERSION") - 1, 1); + zend_string *const_UNICODE_VERSION_name = zend_string_init_interned("UNICODE_VERSION", sizeof("UNICODE_VERSION") - 1, true); zend_declare_typed_class_constant(class_entry, const_UNICODE_VERSION_name, &const_UNICODE_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_UNICODE_VERSION_name); + zend_string_release_ex(const_UNICODE_VERSION_name, true); zval const_CODEPOINT_MIN_value; ZVAL_LONG(&const_CODEPOINT_MIN_value, UCHAR_MIN_VALUE); - zend_string *const_CODEPOINT_MIN_name = zend_string_init_interned("CODEPOINT_MIN", sizeof("CODEPOINT_MIN") - 1, 1); + zend_string *const_CODEPOINT_MIN_name = zend_string_init_interned("CODEPOINT_MIN", sizeof("CODEPOINT_MIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_CODEPOINT_MIN_name, &const_CODEPOINT_MIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CODEPOINT_MIN_name); + zend_string_release_ex(const_CODEPOINT_MIN_name, true); zval const_CODEPOINT_MAX_value; ZVAL_LONG(&const_CODEPOINT_MAX_value, UCHAR_MAX_VALUE); - zend_string *const_CODEPOINT_MAX_name = zend_string_init_interned("CODEPOINT_MAX", sizeof("CODEPOINT_MAX") - 1, 1); + zend_string *const_CODEPOINT_MAX_name = zend_string_init_interned("CODEPOINT_MAX", sizeof("CODEPOINT_MAX") - 1, true); zend_declare_typed_class_constant(class_entry, const_CODEPOINT_MAX_name, &const_CODEPOINT_MAX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CODEPOINT_MAX_name); + zend_string_release_ex(const_CODEPOINT_MAX_name, true); zval const_NO_NUMERIC_VALUE_value; ZVAL_DOUBLE(&const_NO_NUMERIC_VALUE_value, U_NO_NUMERIC_VALUE); - zend_string *const_NO_NUMERIC_VALUE_name = zend_string_init_interned("NO_NUMERIC_VALUE", sizeof("NO_NUMERIC_VALUE") - 1, 1); + zend_string *const_NO_NUMERIC_VALUE_name = zend_string_init_interned("NO_NUMERIC_VALUE", sizeof("NO_NUMERIC_VALUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_NO_NUMERIC_VALUE_name, &const_NO_NUMERIC_VALUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE)); - zend_string_release(const_NO_NUMERIC_VALUE_name); + zend_string_release_ex(const_NO_NUMERIC_VALUE_name, true); zval const_PROPERTY_ALPHABETIC_value; ZVAL_LONG(&const_PROPERTY_ALPHABETIC_value, UCHAR_ALPHABETIC); - zend_string *const_PROPERTY_ALPHABETIC_name = zend_string_init_interned("PROPERTY_ALPHABETIC", sizeof("PROPERTY_ALPHABETIC") - 1, 1); + zend_string *const_PROPERTY_ALPHABETIC_name = zend_string_init_interned("PROPERTY_ALPHABETIC", sizeof("PROPERTY_ALPHABETIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ALPHABETIC_name, &const_PROPERTY_ALPHABETIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_ALPHABETIC_name); + zend_string_release_ex(const_PROPERTY_ALPHABETIC_name, true); zval const_PROPERTY_BINARY_START_value; ZVAL_LONG(&const_PROPERTY_BINARY_START_value, UCHAR_BINARY_START); - zend_string *const_PROPERTY_BINARY_START_name = zend_string_init_interned("PROPERTY_BINARY_START", sizeof("PROPERTY_BINARY_START") - 1, 1); + zend_string *const_PROPERTY_BINARY_START_name = zend_string_init_interned("PROPERTY_BINARY_START", sizeof("PROPERTY_BINARY_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BINARY_START_name, &const_PROPERTY_BINARY_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BINARY_START_name); + zend_string_release_ex(const_PROPERTY_BINARY_START_name, true); zval const_PROPERTY_ASCII_HEX_DIGIT_value; ZVAL_LONG(&const_PROPERTY_ASCII_HEX_DIGIT_value, UCHAR_ASCII_HEX_DIGIT); - zend_string *const_PROPERTY_ASCII_HEX_DIGIT_name = zend_string_init_interned("PROPERTY_ASCII_HEX_DIGIT", sizeof("PROPERTY_ASCII_HEX_DIGIT") - 1, 1); + zend_string *const_PROPERTY_ASCII_HEX_DIGIT_name = zend_string_init_interned("PROPERTY_ASCII_HEX_DIGIT", sizeof("PROPERTY_ASCII_HEX_DIGIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ASCII_HEX_DIGIT_name, &const_PROPERTY_ASCII_HEX_DIGIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_ASCII_HEX_DIGIT_name); + zend_string_release_ex(const_PROPERTY_ASCII_HEX_DIGIT_name, true); zval const_PROPERTY_BIDI_CONTROL_value; ZVAL_LONG(&const_PROPERTY_BIDI_CONTROL_value, UCHAR_BIDI_CONTROL); - zend_string *const_PROPERTY_BIDI_CONTROL_name = zend_string_init_interned("PROPERTY_BIDI_CONTROL", sizeof("PROPERTY_BIDI_CONTROL") - 1, 1); + zend_string *const_PROPERTY_BIDI_CONTROL_name = zend_string_init_interned("PROPERTY_BIDI_CONTROL", sizeof("PROPERTY_BIDI_CONTROL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BIDI_CONTROL_name, &const_PROPERTY_BIDI_CONTROL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BIDI_CONTROL_name); + zend_string_release_ex(const_PROPERTY_BIDI_CONTROL_name, true); zval const_PROPERTY_BIDI_MIRRORED_value; ZVAL_LONG(&const_PROPERTY_BIDI_MIRRORED_value, UCHAR_BIDI_MIRRORED); - zend_string *const_PROPERTY_BIDI_MIRRORED_name = zend_string_init_interned("PROPERTY_BIDI_MIRRORED", sizeof("PROPERTY_BIDI_MIRRORED") - 1, 1); + zend_string *const_PROPERTY_BIDI_MIRRORED_name = zend_string_init_interned("PROPERTY_BIDI_MIRRORED", sizeof("PROPERTY_BIDI_MIRRORED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BIDI_MIRRORED_name, &const_PROPERTY_BIDI_MIRRORED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BIDI_MIRRORED_name); + zend_string_release_ex(const_PROPERTY_BIDI_MIRRORED_name, true); zval const_PROPERTY_DASH_value; ZVAL_LONG(&const_PROPERTY_DASH_value, UCHAR_DASH); - zend_string *const_PROPERTY_DASH_name = zend_string_init_interned("PROPERTY_DASH", sizeof("PROPERTY_DASH") - 1, 1); + zend_string *const_PROPERTY_DASH_name = zend_string_init_interned("PROPERTY_DASH", sizeof("PROPERTY_DASH") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_DASH_name, &const_PROPERTY_DASH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_DASH_name); + zend_string_release_ex(const_PROPERTY_DASH_name, true); zval const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_value; ZVAL_LONG(&const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_value, UCHAR_DEFAULT_IGNORABLE_CODE_POINT); - zend_string *const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_name = zend_string_init_interned("PROPERTY_DEFAULT_IGNORABLE_CODE_POINT", sizeof("PROPERTY_DEFAULT_IGNORABLE_CODE_POINT") - 1, 1); + zend_string *const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_name = zend_string_init_interned("PROPERTY_DEFAULT_IGNORABLE_CODE_POINT", sizeof("PROPERTY_DEFAULT_IGNORABLE_CODE_POINT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_name, &const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_name); + zend_string_release_ex(const_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT_name, true); zval const_PROPERTY_DEPRECATED_value; ZVAL_LONG(&const_PROPERTY_DEPRECATED_value, UCHAR_DEPRECATED); - zend_string *const_PROPERTY_DEPRECATED_name = zend_string_init_interned("PROPERTY_DEPRECATED", sizeof("PROPERTY_DEPRECATED") - 1, 1); + zend_string *const_PROPERTY_DEPRECATED_name = zend_string_init_interned("PROPERTY_DEPRECATED", sizeof("PROPERTY_DEPRECATED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_DEPRECATED_name, &const_PROPERTY_DEPRECATED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_DEPRECATED_name); + zend_string_release_ex(const_PROPERTY_DEPRECATED_name, true); zval const_PROPERTY_DIACRITIC_value; ZVAL_LONG(&const_PROPERTY_DIACRITIC_value, UCHAR_DIACRITIC); - zend_string *const_PROPERTY_DIACRITIC_name = zend_string_init_interned("PROPERTY_DIACRITIC", sizeof("PROPERTY_DIACRITIC") - 1, 1); + zend_string *const_PROPERTY_DIACRITIC_name = zend_string_init_interned("PROPERTY_DIACRITIC", sizeof("PROPERTY_DIACRITIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_DIACRITIC_name, &const_PROPERTY_DIACRITIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_DIACRITIC_name); + zend_string_release_ex(const_PROPERTY_DIACRITIC_name, true); zval const_PROPERTY_EXTENDER_value; ZVAL_LONG(&const_PROPERTY_EXTENDER_value, UCHAR_EXTENDER); - zend_string *const_PROPERTY_EXTENDER_name = zend_string_init_interned("PROPERTY_EXTENDER", sizeof("PROPERTY_EXTENDER") - 1, 1); + zend_string *const_PROPERTY_EXTENDER_name = zend_string_init_interned("PROPERTY_EXTENDER", sizeof("PROPERTY_EXTENDER") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_EXTENDER_name, &const_PROPERTY_EXTENDER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_EXTENDER_name); + zend_string_release_ex(const_PROPERTY_EXTENDER_name, true); zval const_PROPERTY_FULL_COMPOSITION_EXCLUSION_value; ZVAL_LONG(&const_PROPERTY_FULL_COMPOSITION_EXCLUSION_value, UCHAR_FULL_COMPOSITION_EXCLUSION); - zend_string *const_PROPERTY_FULL_COMPOSITION_EXCLUSION_name = zend_string_init_interned("PROPERTY_FULL_COMPOSITION_EXCLUSION", sizeof("PROPERTY_FULL_COMPOSITION_EXCLUSION") - 1, 1); + zend_string *const_PROPERTY_FULL_COMPOSITION_EXCLUSION_name = zend_string_init_interned("PROPERTY_FULL_COMPOSITION_EXCLUSION", sizeof("PROPERTY_FULL_COMPOSITION_EXCLUSION") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_FULL_COMPOSITION_EXCLUSION_name, &const_PROPERTY_FULL_COMPOSITION_EXCLUSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_FULL_COMPOSITION_EXCLUSION_name); + zend_string_release_ex(const_PROPERTY_FULL_COMPOSITION_EXCLUSION_name, true); zval const_PROPERTY_GRAPHEME_BASE_value; ZVAL_LONG(&const_PROPERTY_GRAPHEME_BASE_value, UCHAR_GRAPHEME_BASE); - zend_string *const_PROPERTY_GRAPHEME_BASE_name = zend_string_init_interned("PROPERTY_GRAPHEME_BASE", sizeof("PROPERTY_GRAPHEME_BASE") - 1, 1); + zend_string *const_PROPERTY_GRAPHEME_BASE_name = zend_string_init_interned("PROPERTY_GRAPHEME_BASE", sizeof("PROPERTY_GRAPHEME_BASE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_GRAPHEME_BASE_name, &const_PROPERTY_GRAPHEME_BASE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_GRAPHEME_BASE_name); + zend_string_release_ex(const_PROPERTY_GRAPHEME_BASE_name, true); zval const_PROPERTY_GRAPHEME_EXTEND_value; ZVAL_LONG(&const_PROPERTY_GRAPHEME_EXTEND_value, UCHAR_GRAPHEME_EXTEND); - zend_string *const_PROPERTY_GRAPHEME_EXTEND_name = zend_string_init_interned("PROPERTY_GRAPHEME_EXTEND", sizeof("PROPERTY_GRAPHEME_EXTEND") - 1, 1); + zend_string *const_PROPERTY_GRAPHEME_EXTEND_name = zend_string_init_interned("PROPERTY_GRAPHEME_EXTEND", sizeof("PROPERTY_GRAPHEME_EXTEND") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_GRAPHEME_EXTEND_name, &const_PROPERTY_GRAPHEME_EXTEND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_GRAPHEME_EXTEND_name); + zend_string_release_ex(const_PROPERTY_GRAPHEME_EXTEND_name, true); zval const_PROPERTY_GRAPHEME_LINK_value; ZVAL_LONG(&const_PROPERTY_GRAPHEME_LINK_value, UCHAR_GRAPHEME_LINK); - zend_string *const_PROPERTY_GRAPHEME_LINK_name = zend_string_init_interned("PROPERTY_GRAPHEME_LINK", sizeof("PROPERTY_GRAPHEME_LINK") - 1, 1); + zend_string *const_PROPERTY_GRAPHEME_LINK_name = zend_string_init_interned("PROPERTY_GRAPHEME_LINK", sizeof("PROPERTY_GRAPHEME_LINK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_GRAPHEME_LINK_name, &const_PROPERTY_GRAPHEME_LINK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_GRAPHEME_LINK_name); + zend_string_release_ex(const_PROPERTY_GRAPHEME_LINK_name, true); zval const_PROPERTY_HEX_DIGIT_value; ZVAL_LONG(&const_PROPERTY_HEX_DIGIT_value, UCHAR_HEX_DIGIT); - zend_string *const_PROPERTY_HEX_DIGIT_name = zend_string_init_interned("PROPERTY_HEX_DIGIT", sizeof("PROPERTY_HEX_DIGIT") - 1, 1); + zend_string *const_PROPERTY_HEX_DIGIT_name = zend_string_init_interned("PROPERTY_HEX_DIGIT", sizeof("PROPERTY_HEX_DIGIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_HEX_DIGIT_name, &const_PROPERTY_HEX_DIGIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_HEX_DIGIT_name); + zend_string_release_ex(const_PROPERTY_HEX_DIGIT_name, true); zval const_PROPERTY_HYPHEN_value; ZVAL_LONG(&const_PROPERTY_HYPHEN_value, UCHAR_HYPHEN); - zend_string *const_PROPERTY_HYPHEN_name = zend_string_init_interned("PROPERTY_HYPHEN", sizeof("PROPERTY_HYPHEN") - 1, 1); + zend_string *const_PROPERTY_HYPHEN_name = zend_string_init_interned("PROPERTY_HYPHEN", sizeof("PROPERTY_HYPHEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_HYPHEN_name, &const_PROPERTY_HYPHEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_HYPHEN_name); + zend_string_release_ex(const_PROPERTY_HYPHEN_name, true); zval const_PROPERTY_ID_CONTINUE_value; ZVAL_LONG(&const_PROPERTY_ID_CONTINUE_value, UCHAR_ID_CONTINUE); - zend_string *const_PROPERTY_ID_CONTINUE_name = zend_string_init_interned("PROPERTY_ID_CONTINUE", sizeof("PROPERTY_ID_CONTINUE") - 1, 1); + zend_string *const_PROPERTY_ID_CONTINUE_name = zend_string_init_interned("PROPERTY_ID_CONTINUE", sizeof("PROPERTY_ID_CONTINUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ID_CONTINUE_name, &const_PROPERTY_ID_CONTINUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_ID_CONTINUE_name); + zend_string_release_ex(const_PROPERTY_ID_CONTINUE_name, true); zval const_PROPERTY_ID_START_value; ZVAL_LONG(&const_PROPERTY_ID_START_value, UCHAR_ID_START); - zend_string *const_PROPERTY_ID_START_name = zend_string_init_interned("PROPERTY_ID_START", sizeof("PROPERTY_ID_START") - 1, 1); + zend_string *const_PROPERTY_ID_START_name = zend_string_init_interned("PROPERTY_ID_START", sizeof("PROPERTY_ID_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ID_START_name, &const_PROPERTY_ID_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_ID_START_name); + zend_string_release_ex(const_PROPERTY_ID_START_name, true); zval const_PROPERTY_IDEOGRAPHIC_value; ZVAL_LONG(&const_PROPERTY_IDEOGRAPHIC_value, UCHAR_IDEOGRAPHIC); - zend_string *const_PROPERTY_IDEOGRAPHIC_name = zend_string_init_interned("PROPERTY_IDEOGRAPHIC", sizeof("PROPERTY_IDEOGRAPHIC") - 1, 1); + zend_string *const_PROPERTY_IDEOGRAPHIC_name = zend_string_init_interned("PROPERTY_IDEOGRAPHIC", sizeof("PROPERTY_IDEOGRAPHIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_IDEOGRAPHIC_name, &const_PROPERTY_IDEOGRAPHIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_IDEOGRAPHIC_name); + zend_string_release_ex(const_PROPERTY_IDEOGRAPHIC_name, true); zval const_PROPERTY_IDS_BINARY_OPERATOR_value; ZVAL_LONG(&const_PROPERTY_IDS_BINARY_OPERATOR_value, UCHAR_IDS_BINARY_OPERATOR); - zend_string *const_PROPERTY_IDS_BINARY_OPERATOR_name = zend_string_init_interned("PROPERTY_IDS_BINARY_OPERATOR", sizeof("PROPERTY_IDS_BINARY_OPERATOR") - 1, 1); + zend_string *const_PROPERTY_IDS_BINARY_OPERATOR_name = zend_string_init_interned("PROPERTY_IDS_BINARY_OPERATOR", sizeof("PROPERTY_IDS_BINARY_OPERATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_IDS_BINARY_OPERATOR_name, &const_PROPERTY_IDS_BINARY_OPERATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_IDS_BINARY_OPERATOR_name); + zend_string_release_ex(const_PROPERTY_IDS_BINARY_OPERATOR_name, true); zval const_PROPERTY_IDS_TRINARY_OPERATOR_value; ZVAL_LONG(&const_PROPERTY_IDS_TRINARY_OPERATOR_value, UCHAR_IDS_TRINARY_OPERATOR); - zend_string *const_PROPERTY_IDS_TRINARY_OPERATOR_name = zend_string_init_interned("PROPERTY_IDS_TRINARY_OPERATOR", sizeof("PROPERTY_IDS_TRINARY_OPERATOR") - 1, 1); + zend_string *const_PROPERTY_IDS_TRINARY_OPERATOR_name = zend_string_init_interned("PROPERTY_IDS_TRINARY_OPERATOR", sizeof("PROPERTY_IDS_TRINARY_OPERATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_IDS_TRINARY_OPERATOR_name, &const_PROPERTY_IDS_TRINARY_OPERATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_IDS_TRINARY_OPERATOR_name); + zend_string_release_ex(const_PROPERTY_IDS_TRINARY_OPERATOR_name, true); #if U_ICU_VERSION_MAJOR_NUM >= 74 zval const_PROPERTY_IDS_UNARY_OPERATOR_value; ZVAL_LONG(&const_PROPERTY_IDS_UNARY_OPERATOR_value, UCHAR_IDS_UNARY_OPERATOR); - zend_string *const_PROPERTY_IDS_UNARY_OPERATOR_name = zend_string_init_interned("PROPERTY_IDS_UNARY_OPERATOR", sizeof("PROPERTY_IDS_UNARY_OPERATOR") - 1, 1); + zend_string *const_PROPERTY_IDS_UNARY_OPERATOR_name = zend_string_init_interned("PROPERTY_IDS_UNARY_OPERATOR", sizeof("PROPERTY_IDS_UNARY_OPERATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_IDS_UNARY_OPERATOR_name, &const_PROPERTY_IDS_UNARY_OPERATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_IDS_UNARY_OPERATOR_name); + zend_string_release_ex(const_PROPERTY_IDS_UNARY_OPERATOR_name, true); zval const_PROPERTY_ID_COMPAT_MATH_START_value; ZVAL_LONG(&const_PROPERTY_ID_COMPAT_MATH_START_value, UCHAR_ID_COMPAT_MATH_START); - zend_string *const_PROPERTY_ID_COMPAT_MATH_START_name = zend_string_init_interned("PROPERTY_ID_COMPAT_MATH_START", sizeof("PROPERTY_ID_COMPAT_MATH_START") - 1, 1); + zend_string *const_PROPERTY_ID_COMPAT_MATH_START_name = zend_string_init_interned("PROPERTY_ID_COMPAT_MATH_START", sizeof("PROPERTY_ID_COMPAT_MATH_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ID_COMPAT_MATH_START_name, &const_PROPERTY_ID_COMPAT_MATH_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_ID_COMPAT_MATH_START_name); + zend_string_release_ex(const_PROPERTY_ID_COMPAT_MATH_START_name, true); zval const_PROPERTY_ID_COMPAT_MATH_CONTINUE_value; ZVAL_LONG(&const_PROPERTY_ID_COMPAT_MATH_CONTINUE_value, UCHAR_ID_COMPAT_MATH_CONTINUE); - zend_string *const_PROPERTY_ID_COMPAT_MATH_CONTINUE_name = zend_string_init_interned("PROPERTY_ID_COMPAT_MATH_CONTINUE", sizeof("PROPERTY_ID_COMPAT_MATH_CONTINUE") - 1, 1); + zend_string *const_PROPERTY_ID_COMPAT_MATH_CONTINUE_name = zend_string_init_interned("PROPERTY_ID_COMPAT_MATH_CONTINUE", sizeof("PROPERTY_ID_COMPAT_MATH_CONTINUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ID_COMPAT_MATH_CONTINUE_name, &const_PROPERTY_ID_COMPAT_MATH_CONTINUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_ID_COMPAT_MATH_CONTINUE_name); + zend_string_release_ex(const_PROPERTY_ID_COMPAT_MATH_CONTINUE_name, true); #endif zval const_PROPERTY_JOIN_CONTROL_value; ZVAL_LONG(&const_PROPERTY_JOIN_CONTROL_value, UCHAR_JOIN_CONTROL); - zend_string *const_PROPERTY_JOIN_CONTROL_name = zend_string_init_interned("PROPERTY_JOIN_CONTROL", sizeof("PROPERTY_JOIN_CONTROL") - 1, 1); + zend_string *const_PROPERTY_JOIN_CONTROL_name = zend_string_init_interned("PROPERTY_JOIN_CONTROL", sizeof("PROPERTY_JOIN_CONTROL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_JOIN_CONTROL_name, &const_PROPERTY_JOIN_CONTROL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_JOIN_CONTROL_name); + zend_string_release_ex(const_PROPERTY_JOIN_CONTROL_name, true); zval const_PROPERTY_LOGICAL_ORDER_EXCEPTION_value; ZVAL_LONG(&const_PROPERTY_LOGICAL_ORDER_EXCEPTION_value, UCHAR_LOGICAL_ORDER_EXCEPTION); - zend_string *const_PROPERTY_LOGICAL_ORDER_EXCEPTION_name = zend_string_init_interned("PROPERTY_LOGICAL_ORDER_EXCEPTION", sizeof("PROPERTY_LOGICAL_ORDER_EXCEPTION") - 1, 1); + zend_string *const_PROPERTY_LOGICAL_ORDER_EXCEPTION_name = zend_string_init_interned("PROPERTY_LOGICAL_ORDER_EXCEPTION", sizeof("PROPERTY_LOGICAL_ORDER_EXCEPTION") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_LOGICAL_ORDER_EXCEPTION_name, &const_PROPERTY_LOGICAL_ORDER_EXCEPTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_LOGICAL_ORDER_EXCEPTION_name); + zend_string_release_ex(const_PROPERTY_LOGICAL_ORDER_EXCEPTION_name, true); zval const_PROPERTY_LOWERCASE_value; ZVAL_LONG(&const_PROPERTY_LOWERCASE_value, UCHAR_LOWERCASE); - zend_string *const_PROPERTY_LOWERCASE_name = zend_string_init_interned("PROPERTY_LOWERCASE", sizeof("PROPERTY_LOWERCASE") - 1, 1); + zend_string *const_PROPERTY_LOWERCASE_name = zend_string_init_interned("PROPERTY_LOWERCASE", sizeof("PROPERTY_LOWERCASE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_LOWERCASE_name, &const_PROPERTY_LOWERCASE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_LOWERCASE_name); + zend_string_release_ex(const_PROPERTY_LOWERCASE_name, true); zval const_PROPERTY_MATH_value; ZVAL_LONG(&const_PROPERTY_MATH_value, UCHAR_MATH); - zend_string *const_PROPERTY_MATH_name = zend_string_init_interned("PROPERTY_MATH", sizeof("PROPERTY_MATH") - 1, 1); + zend_string *const_PROPERTY_MATH_name = zend_string_init_interned("PROPERTY_MATH", sizeof("PROPERTY_MATH") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_MATH_name, &const_PROPERTY_MATH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_MATH_name); + zend_string_release_ex(const_PROPERTY_MATH_name, true); zval const_PROPERTY_NONCHARACTER_CODE_POINT_value; ZVAL_LONG(&const_PROPERTY_NONCHARACTER_CODE_POINT_value, UCHAR_NONCHARACTER_CODE_POINT); - zend_string *const_PROPERTY_NONCHARACTER_CODE_POINT_name = zend_string_init_interned("PROPERTY_NONCHARACTER_CODE_POINT", sizeof("PROPERTY_NONCHARACTER_CODE_POINT") - 1, 1); + zend_string *const_PROPERTY_NONCHARACTER_CODE_POINT_name = zend_string_init_interned("PROPERTY_NONCHARACTER_CODE_POINT", sizeof("PROPERTY_NONCHARACTER_CODE_POINT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NONCHARACTER_CODE_POINT_name, &const_PROPERTY_NONCHARACTER_CODE_POINT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NONCHARACTER_CODE_POINT_name); + zend_string_release_ex(const_PROPERTY_NONCHARACTER_CODE_POINT_name, true); zval const_PROPERTY_QUOTATION_MARK_value; ZVAL_LONG(&const_PROPERTY_QUOTATION_MARK_value, UCHAR_QUOTATION_MARK); - zend_string *const_PROPERTY_QUOTATION_MARK_name = zend_string_init_interned("PROPERTY_QUOTATION_MARK", sizeof("PROPERTY_QUOTATION_MARK") - 1, 1); + zend_string *const_PROPERTY_QUOTATION_MARK_name = zend_string_init_interned("PROPERTY_QUOTATION_MARK", sizeof("PROPERTY_QUOTATION_MARK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_QUOTATION_MARK_name, &const_PROPERTY_QUOTATION_MARK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_QUOTATION_MARK_name); + zend_string_release_ex(const_PROPERTY_QUOTATION_MARK_name, true); zval const_PROPERTY_RADICAL_value; ZVAL_LONG(&const_PROPERTY_RADICAL_value, UCHAR_RADICAL); - zend_string *const_PROPERTY_RADICAL_name = zend_string_init_interned("PROPERTY_RADICAL", sizeof("PROPERTY_RADICAL") - 1, 1); + zend_string *const_PROPERTY_RADICAL_name = zend_string_init_interned("PROPERTY_RADICAL", sizeof("PROPERTY_RADICAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_RADICAL_name, &const_PROPERTY_RADICAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_RADICAL_name); + zend_string_release_ex(const_PROPERTY_RADICAL_name, true); zval const_PROPERTY_SOFT_DOTTED_value; ZVAL_LONG(&const_PROPERTY_SOFT_DOTTED_value, UCHAR_SOFT_DOTTED); - zend_string *const_PROPERTY_SOFT_DOTTED_name = zend_string_init_interned("PROPERTY_SOFT_DOTTED", sizeof("PROPERTY_SOFT_DOTTED") - 1, 1); + zend_string *const_PROPERTY_SOFT_DOTTED_name = zend_string_init_interned("PROPERTY_SOFT_DOTTED", sizeof("PROPERTY_SOFT_DOTTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SOFT_DOTTED_name, &const_PROPERTY_SOFT_DOTTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SOFT_DOTTED_name); + zend_string_release_ex(const_PROPERTY_SOFT_DOTTED_name, true); zval const_PROPERTY_TERMINAL_PUNCTUATION_value; ZVAL_LONG(&const_PROPERTY_TERMINAL_PUNCTUATION_value, UCHAR_TERMINAL_PUNCTUATION); - zend_string *const_PROPERTY_TERMINAL_PUNCTUATION_name = zend_string_init_interned("PROPERTY_TERMINAL_PUNCTUATION", sizeof("PROPERTY_TERMINAL_PUNCTUATION") - 1, 1); + zend_string *const_PROPERTY_TERMINAL_PUNCTUATION_name = zend_string_init_interned("PROPERTY_TERMINAL_PUNCTUATION", sizeof("PROPERTY_TERMINAL_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_TERMINAL_PUNCTUATION_name, &const_PROPERTY_TERMINAL_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_TERMINAL_PUNCTUATION_name); + zend_string_release_ex(const_PROPERTY_TERMINAL_PUNCTUATION_name, true); zval const_PROPERTY_UNIFIED_IDEOGRAPH_value; ZVAL_LONG(&const_PROPERTY_UNIFIED_IDEOGRAPH_value, UCHAR_UNIFIED_IDEOGRAPH); - zend_string *const_PROPERTY_UNIFIED_IDEOGRAPH_name = zend_string_init_interned("PROPERTY_UNIFIED_IDEOGRAPH", sizeof("PROPERTY_UNIFIED_IDEOGRAPH") - 1, 1); + zend_string *const_PROPERTY_UNIFIED_IDEOGRAPH_name = zend_string_init_interned("PROPERTY_UNIFIED_IDEOGRAPH", sizeof("PROPERTY_UNIFIED_IDEOGRAPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_UNIFIED_IDEOGRAPH_name, &const_PROPERTY_UNIFIED_IDEOGRAPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_UNIFIED_IDEOGRAPH_name); + zend_string_release_ex(const_PROPERTY_UNIFIED_IDEOGRAPH_name, true); zval const_PROPERTY_UPPERCASE_value; ZVAL_LONG(&const_PROPERTY_UPPERCASE_value, UCHAR_UPPERCASE); - zend_string *const_PROPERTY_UPPERCASE_name = zend_string_init_interned("PROPERTY_UPPERCASE", sizeof("PROPERTY_UPPERCASE") - 1, 1); + zend_string *const_PROPERTY_UPPERCASE_name = zend_string_init_interned("PROPERTY_UPPERCASE", sizeof("PROPERTY_UPPERCASE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_UPPERCASE_name, &const_PROPERTY_UPPERCASE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_UPPERCASE_name); + zend_string_release_ex(const_PROPERTY_UPPERCASE_name, true); zval const_PROPERTY_WHITE_SPACE_value; ZVAL_LONG(&const_PROPERTY_WHITE_SPACE_value, UCHAR_WHITE_SPACE); - zend_string *const_PROPERTY_WHITE_SPACE_name = zend_string_init_interned("PROPERTY_WHITE_SPACE", sizeof("PROPERTY_WHITE_SPACE") - 1, 1); + zend_string *const_PROPERTY_WHITE_SPACE_name = zend_string_init_interned("PROPERTY_WHITE_SPACE", sizeof("PROPERTY_WHITE_SPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_WHITE_SPACE_name, &const_PROPERTY_WHITE_SPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_WHITE_SPACE_name); + zend_string_release_ex(const_PROPERTY_WHITE_SPACE_name, true); zval const_PROPERTY_XID_CONTINUE_value; ZVAL_LONG(&const_PROPERTY_XID_CONTINUE_value, UCHAR_XID_CONTINUE); - zend_string *const_PROPERTY_XID_CONTINUE_name = zend_string_init_interned("PROPERTY_XID_CONTINUE", sizeof("PROPERTY_XID_CONTINUE") - 1, 1); + zend_string *const_PROPERTY_XID_CONTINUE_name = zend_string_init_interned("PROPERTY_XID_CONTINUE", sizeof("PROPERTY_XID_CONTINUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_XID_CONTINUE_name, &const_PROPERTY_XID_CONTINUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_XID_CONTINUE_name); + zend_string_release_ex(const_PROPERTY_XID_CONTINUE_name, true); zval const_PROPERTY_XID_START_value; ZVAL_LONG(&const_PROPERTY_XID_START_value, UCHAR_XID_START); - zend_string *const_PROPERTY_XID_START_name = zend_string_init_interned("PROPERTY_XID_START", sizeof("PROPERTY_XID_START") - 1, 1); + zend_string *const_PROPERTY_XID_START_name = zend_string_init_interned("PROPERTY_XID_START", sizeof("PROPERTY_XID_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_XID_START_name, &const_PROPERTY_XID_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_XID_START_name); + zend_string_release_ex(const_PROPERTY_XID_START_name, true); zval const_PROPERTY_CASE_SENSITIVE_value; ZVAL_LONG(&const_PROPERTY_CASE_SENSITIVE_value, UCHAR_CASE_SENSITIVE); - zend_string *const_PROPERTY_CASE_SENSITIVE_name = zend_string_init_interned("PROPERTY_CASE_SENSITIVE", sizeof("PROPERTY_CASE_SENSITIVE") - 1, 1); + zend_string *const_PROPERTY_CASE_SENSITIVE_name = zend_string_init_interned("PROPERTY_CASE_SENSITIVE", sizeof("PROPERTY_CASE_SENSITIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CASE_SENSITIVE_name, &const_PROPERTY_CASE_SENSITIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CASE_SENSITIVE_name); + zend_string_release_ex(const_PROPERTY_CASE_SENSITIVE_name, true); zval const_PROPERTY_S_TERM_value; ZVAL_LONG(&const_PROPERTY_S_TERM_value, UCHAR_S_TERM); - zend_string *const_PROPERTY_S_TERM_name = zend_string_init_interned("PROPERTY_S_TERM", sizeof("PROPERTY_S_TERM") - 1, 1); + zend_string *const_PROPERTY_S_TERM_name = zend_string_init_interned("PROPERTY_S_TERM", sizeof("PROPERTY_S_TERM") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_S_TERM_name, &const_PROPERTY_S_TERM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_S_TERM_name); + zend_string_release_ex(const_PROPERTY_S_TERM_name, true); zval const_PROPERTY_VARIATION_SELECTOR_value; ZVAL_LONG(&const_PROPERTY_VARIATION_SELECTOR_value, UCHAR_VARIATION_SELECTOR); - zend_string *const_PROPERTY_VARIATION_SELECTOR_name = zend_string_init_interned("PROPERTY_VARIATION_SELECTOR", sizeof("PROPERTY_VARIATION_SELECTOR") - 1, 1); + zend_string *const_PROPERTY_VARIATION_SELECTOR_name = zend_string_init_interned("PROPERTY_VARIATION_SELECTOR", sizeof("PROPERTY_VARIATION_SELECTOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_VARIATION_SELECTOR_name, &const_PROPERTY_VARIATION_SELECTOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_VARIATION_SELECTOR_name); + zend_string_release_ex(const_PROPERTY_VARIATION_SELECTOR_name, true); zval const_PROPERTY_NFD_INERT_value; ZVAL_LONG(&const_PROPERTY_NFD_INERT_value, UCHAR_NFD_INERT); - zend_string *const_PROPERTY_NFD_INERT_name = zend_string_init_interned("PROPERTY_NFD_INERT", sizeof("PROPERTY_NFD_INERT") - 1, 1); + zend_string *const_PROPERTY_NFD_INERT_name = zend_string_init_interned("PROPERTY_NFD_INERT", sizeof("PROPERTY_NFD_INERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFD_INERT_name, &const_PROPERTY_NFD_INERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFD_INERT_name); + zend_string_release_ex(const_PROPERTY_NFD_INERT_name, true); zval const_PROPERTY_NFKD_INERT_value; ZVAL_LONG(&const_PROPERTY_NFKD_INERT_value, UCHAR_NFKD_INERT); - zend_string *const_PROPERTY_NFKD_INERT_name = zend_string_init_interned("PROPERTY_NFKD_INERT", sizeof("PROPERTY_NFKD_INERT") - 1, 1); + zend_string *const_PROPERTY_NFKD_INERT_name = zend_string_init_interned("PROPERTY_NFKD_INERT", sizeof("PROPERTY_NFKD_INERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFKD_INERT_name, &const_PROPERTY_NFKD_INERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFKD_INERT_name); + zend_string_release_ex(const_PROPERTY_NFKD_INERT_name, true); zval const_PROPERTY_NFC_INERT_value; ZVAL_LONG(&const_PROPERTY_NFC_INERT_value, UCHAR_NFC_INERT); - zend_string *const_PROPERTY_NFC_INERT_name = zend_string_init_interned("PROPERTY_NFC_INERT", sizeof("PROPERTY_NFC_INERT") - 1, 1); + zend_string *const_PROPERTY_NFC_INERT_name = zend_string_init_interned("PROPERTY_NFC_INERT", sizeof("PROPERTY_NFC_INERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFC_INERT_name, &const_PROPERTY_NFC_INERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFC_INERT_name); + zend_string_release_ex(const_PROPERTY_NFC_INERT_name, true); zval const_PROPERTY_NFKC_INERT_value; ZVAL_LONG(&const_PROPERTY_NFKC_INERT_value, UCHAR_NFKC_INERT); - zend_string *const_PROPERTY_NFKC_INERT_name = zend_string_init_interned("PROPERTY_NFKC_INERT", sizeof("PROPERTY_NFKC_INERT") - 1, 1); + zend_string *const_PROPERTY_NFKC_INERT_name = zend_string_init_interned("PROPERTY_NFKC_INERT", sizeof("PROPERTY_NFKC_INERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFKC_INERT_name, &const_PROPERTY_NFKC_INERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFKC_INERT_name); + zend_string_release_ex(const_PROPERTY_NFKC_INERT_name, true); zval const_PROPERTY_SEGMENT_STARTER_value; ZVAL_LONG(&const_PROPERTY_SEGMENT_STARTER_value, UCHAR_SEGMENT_STARTER); - zend_string *const_PROPERTY_SEGMENT_STARTER_name = zend_string_init_interned("PROPERTY_SEGMENT_STARTER", sizeof("PROPERTY_SEGMENT_STARTER") - 1, 1); + zend_string *const_PROPERTY_SEGMENT_STARTER_name = zend_string_init_interned("PROPERTY_SEGMENT_STARTER", sizeof("PROPERTY_SEGMENT_STARTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SEGMENT_STARTER_name, &const_PROPERTY_SEGMENT_STARTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SEGMENT_STARTER_name); + zend_string_release_ex(const_PROPERTY_SEGMENT_STARTER_name, true); zval const_PROPERTY_PATTERN_SYNTAX_value; ZVAL_LONG(&const_PROPERTY_PATTERN_SYNTAX_value, UCHAR_PATTERN_SYNTAX); - zend_string *const_PROPERTY_PATTERN_SYNTAX_name = zend_string_init_interned("PROPERTY_PATTERN_SYNTAX", sizeof("PROPERTY_PATTERN_SYNTAX") - 1, 1); + zend_string *const_PROPERTY_PATTERN_SYNTAX_name = zend_string_init_interned("PROPERTY_PATTERN_SYNTAX", sizeof("PROPERTY_PATTERN_SYNTAX") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_PATTERN_SYNTAX_name, &const_PROPERTY_PATTERN_SYNTAX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_PATTERN_SYNTAX_name); + zend_string_release_ex(const_PROPERTY_PATTERN_SYNTAX_name, true); zval const_PROPERTY_PATTERN_WHITE_SPACE_value; ZVAL_LONG(&const_PROPERTY_PATTERN_WHITE_SPACE_value, UCHAR_PATTERN_WHITE_SPACE); - zend_string *const_PROPERTY_PATTERN_WHITE_SPACE_name = zend_string_init_interned("PROPERTY_PATTERN_WHITE_SPACE", sizeof("PROPERTY_PATTERN_WHITE_SPACE") - 1, 1); + zend_string *const_PROPERTY_PATTERN_WHITE_SPACE_name = zend_string_init_interned("PROPERTY_PATTERN_WHITE_SPACE", sizeof("PROPERTY_PATTERN_WHITE_SPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_PATTERN_WHITE_SPACE_name, &const_PROPERTY_PATTERN_WHITE_SPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_PATTERN_WHITE_SPACE_name); + zend_string_release_ex(const_PROPERTY_PATTERN_WHITE_SPACE_name, true); zval const_PROPERTY_POSIX_ALNUM_value; ZVAL_LONG(&const_PROPERTY_POSIX_ALNUM_value, UCHAR_POSIX_ALNUM); - zend_string *const_PROPERTY_POSIX_ALNUM_name = zend_string_init_interned("PROPERTY_POSIX_ALNUM", sizeof("PROPERTY_POSIX_ALNUM") - 1, 1); + zend_string *const_PROPERTY_POSIX_ALNUM_name = zend_string_init_interned("PROPERTY_POSIX_ALNUM", sizeof("PROPERTY_POSIX_ALNUM") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_POSIX_ALNUM_name, &const_PROPERTY_POSIX_ALNUM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_POSIX_ALNUM_name); + zend_string_release_ex(const_PROPERTY_POSIX_ALNUM_name, true); zval const_PROPERTY_POSIX_BLANK_value; ZVAL_LONG(&const_PROPERTY_POSIX_BLANK_value, UCHAR_POSIX_BLANK); - zend_string *const_PROPERTY_POSIX_BLANK_name = zend_string_init_interned("PROPERTY_POSIX_BLANK", sizeof("PROPERTY_POSIX_BLANK") - 1, 1); + zend_string *const_PROPERTY_POSIX_BLANK_name = zend_string_init_interned("PROPERTY_POSIX_BLANK", sizeof("PROPERTY_POSIX_BLANK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_POSIX_BLANK_name, &const_PROPERTY_POSIX_BLANK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_POSIX_BLANK_name); + zend_string_release_ex(const_PROPERTY_POSIX_BLANK_name, true); zval const_PROPERTY_POSIX_GRAPH_value; ZVAL_LONG(&const_PROPERTY_POSIX_GRAPH_value, UCHAR_POSIX_GRAPH); - zend_string *const_PROPERTY_POSIX_GRAPH_name = zend_string_init_interned("PROPERTY_POSIX_GRAPH", sizeof("PROPERTY_POSIX_GRAPH") - 1, 1); + zend_string *const_PROPERTY_POSIX_GRAPH_name = zend_string_init_interned("PROPERTY_POSIX_GRAPH", sizeof("PROPERTY_POSIX_GRAPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_POSIX_GRAPH_name, &const_PROPERTY_POSIX_GRAPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_POSIX_GRAPH_name); + zend_string_release_ex(const_PROPERTY_POSIX_GRAPH_name, true); zval const_PROPERTY_POSIX_PRINT_value; ZVAL_LONG(&const_PROPERTY_POSIX_PRINT_value, UCHAR_POSIX_PRINT); - zend_string *const_PROPERTY_POSIX_PRINT_name = zend_string_init_interned("PROPERTY_POSIX_PRINT", sizeof("PROPERTY_POSIX_PRINT") - 1, 1); + zend_string *const_PROPERTY_POSIX_PRINT_name = zend_string_init_interned("PROPERTY_POSIX_PRINT", sizeof("PROPERTY_POSIX_PRINT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_POSIX_PRINT_name, &const_PROPERTY_POSIX_PRINT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_POSIX_PRINT_name); + zend_string_release_ex(const_PROPERTY_POSIX_PRINT_name, true); zval const_PROPERTY_POSIX_XDIGIT_value; ZVAL_LONG(&const_PROPERTY_POSIX_XDIGIT_value, UCHAR_POSIX_XDIGIT); - zend_string *const_PROPERTY_POSIX_XDIGIT_name = zend_string_init_interned("PROPERTY_POSIX_XDIGIT", sizeof("PROPERTY_POSIX_XDIGIT") - 1, 1); + zend_string *const_PROPERTY_POSIX_XDIGIT_name = zend_string_init_interned("PROPERTY_POSIX_XDIGIT", sizeof("PROPERTY_POSIX_XDIGIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_POSIX_XDIGIT_name, &const_PROPERTY_POSIX_XDIGIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_POSIX_XDIGIT_name); + zend_string_release_ex(const_PROPERTY_POSIX_XDIGIT_name, true); zval const_PROPERTY_CASED_value; ZVAL_LONG(&const_PROPERTY_CASED_value, UCHAR_CASED); - zend_string *const_PROPERTY_CASED_name = zend_string_init_interned("PROPERTY_CASED", sizeof("PROPERTY_CASED") - 1, 1); + zend_string *const_PROPERTY_CASED_name = zend_string_init_interned("PROPERTY_CASED", sizeof("PROPERTY_CASED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CASED_name, &const_PROPERTY_CASED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CASED_name); + zend_string_release_ex(const_PROPERTY_CASED_name, true); zval const_PROPERTY_CASE_IGNORABLE_value; ZVAL_LONG(&const_PROPERTY_CASE_IGNORABLE_value, UCHAR_CASE_IGNORABLE); - zend_string *const_PROPERTY_CASE_IGNORABLE_name = zend_string_init_interned("PROPERTY_CASE_IGNORABLE", sizeof("PROPERTY_CASE_IGNORABLE") - 1, 1); + zend_string *const_PROPERTY_CASE_IGNORABLE_name = zend_string_init_interned("PROPERTY_CASE_IGNORABLE", sizeof("PROPERTY_CASE_IGNORABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CASE_IGNORABLE_name, &const_PROPERTY_CASE_IGNORABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CASE_IGNORABLE_name); + zend_string_release_ex(const_PROPERTY_CASE_IGNORABLE_name, true); zval const_PROPERTY_CHANGES_WHEN_LOWERCASED_value; ZVAL_LONG(&const_PROPERTY_CHANGES_WHEN_LOWERCASED_value, UCHAR_CHANGES_WHEN_LOWERCASED); - zend_string *const_PROPERTY_CHANGES_WHEN_LOWERCASED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_LOWERCASED", sizeof("PROPERTY_CHANGES_WHEN_LOWERCASED") - 1, 1); + zend_string *const_PROPERTY_CHANGES_WHEN_LOWERCASED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_LOWERCASED", sizeof("PROPERTY_CHANGES_WHEN_LOWERCASED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CHANGES_WHEN_LOWERCASED_name, &const_PROPERTY_CHANGES_WHEN_LOWERCASED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CHANGES_WHEN_LOWERCASED_name); + zend_string_release_ex(const_PROPERTY_CHANGES_WHEN_LOWERCASED_name, true); zval const_PROPERTY_CHANGES_WHEN_UPPERCASED_value; ZVAL_LONG(&const_PROPERTY_CHANGES_WHEN_UPPERCASED_value, UCHAR_CHANGES_WHEN_UPPERCASED); - zend_string *const_PROPERTY_CHANGES_WHEN_UPPERCASED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_UPPERCASED", sizeof("PROPERTY_CHANGES_WHEN_UPPERCASED") - 1, 1); + zend_string *const_PROPERTY_CHANGES_WHEN_UPPERCASED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_UPPERCASED", sizeof("PROPERTY_CHANGES_WHEN_UPPERCASED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CHANGES_WHEN_UPPERCASED_name, &const_PROPERTY_CHANGES_WHEN_UPPERCASED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CHANGES_WHEN_UPPERCASED_name); + zend_string_release_ex(const_PROPERTY_CHANGES_WHEN_UPPERCASED_name, true); zval const_PROPERTY_CHANGES_WHEN_TITLECASED_value; ZVAL_LONG(&const_PROPERTY_CHANGES_WHEN_TITLECASED_value, UCHAR_CHANGES_WHEN_TITLECASED); - zend_string *const_PROPERTY_CHANGES_WHEN_TITLECASED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_TITLECASED", sizeof("PROPERTY_CHANGES_WHEN_TITLECASED") - 1, 1); + zend_string *const_PROPERTY_CHANGES_WHEN_TITLECASED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_TITLECASED", sizeof("PROPERTY_CHANGES_WHEN_TITLECASED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CHANGES_WHEN_TITLECASED_name, &const_PROPERTY_CHANGES_WHEN_TITLECASED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CHANGES_WHEN_TITLECASED_name); + zend_string_release_ex(const_PROPERTY_CHANGES_WHEN_TITLECASED_name, true); zval const_PROPERTY_CHANGES_WHEN_CASEFOLDED_value; ZVAL_LONG(&const_PROPERTY_CHANGES_WHEN_CASEFOLDED_value, UCHAR_CHANGES_WHEN_CASEFOLDED); - zend_string *const_PROPERTY_CHANGES_WHEN_CASEFOLDED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_CASEFOLDED", sizeof("PROPERTY_CHANGES_WHEN_CASEFOLDED") - 1, 1); + zend_string *const_PROPERTY_CHANGES_WHEN_CASEFOLDED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_CASEFOLDED", sizeof("PROPERTY_CHANGES_WHEN_CASEFOLDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CHANGES_WHEN_CASEFOLDED_name, &const_PROPERTY_CHANGES_WHEN_CASEFOLDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CHANGES_WHEN_CASEFOLDED_name); + zend_string_release_ex(const_PROPERTY_CHANGES_WHEN_CASEFOLDED_name, true); zval const_PROPERTY_CHANGES_WHEN_CASEMAPPED_value; ZVAL_LONG(&const_PROPERTY_CHANGES_WHEN_CASEMAPPED_value, UCHAR_CHANGES_WHEN_CASEMAPPED); - zend_string *const_PROPERTY_CHANGES_WHEN_CASEMAPPED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_CASEMAPPED", sizeof("PROPERTY_CHANGES_WHEN_CASEMAPPED") - 1, 1); + zend_string *const_PROPERTY_CHANGES_WHEN_CASEMAPPED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_CASEMAPPED", sizeof("PROPERTY_CHANGES_WHEN_CASEMAPPED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CHANGES_WHEN_CASEMAPPED_name, &const_PROPERTY_CHANGES_WHEN_CASEMAPPED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CHANGES_WHEN_CASEMAPPED_name); + zend_string_release_ex(const_PROPERTY_CHANGES_WHEN_CASEMAPPED_name, true); zval const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_value; ZVAL_LONG(&const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_value, UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED); - zend_string *const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED", sizeof("PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED") - 1, 1); + zend_string *const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_name = zend_string_init_interned("PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED", sizeof("PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_name, &const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_name); + zend_string_release_ex(const_PROPERTY_CHANGES_WHEN_NFKC_CASEFOLDED_name, true); zval const_PROPERTY_BINARY_LIMIT_value; ZVAL_LONG(&const_PROPERTY_BINARY_LIMIT_value, UCHAR_BINARY_LIMIT); - zend_string *const_PROPERTY_BINARY_LIMIT_name = zend_string_init_interned("PROPERTY_BINARY_LIMIT", sizeof("PROPERTY_BINARY_LIMIT") - 1, 1); + zend_string *const_PROPERTY_BINARY_LIMIT_name = zend_string_init_interned("PROPERTY_BINARY_LIMIT", sizeof("PROPERTY_BINARY_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BINARY_LIMIT_name, &const_PROPERTY_BINARY_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BINARY_LIMIT_name); + zend_string_release_ex(const_PROPERTY_BINARY_LIMIT_name, true); zval const_PROPERTY_BIDI_CLASS_value; ZVAL_LONG(&const_PROPERTY_BIDI_CLASS_value, UCHAR_BIDI_CLASS); - zend_string *const_PROPERTY_BIDI_CLASS_name = zend_string_init_interned("PROPERTY_BIDI_CLASS", sizeof("PROPERTY_BIDI_CLASS") - 1, 1); + zend_string *const_PROPERTY_BIDI_CLASS_name = zend_string_init_interned("PROPERTY_BIDI_CLASS", sizeof("PROPERTY_BIDI_CLASS") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BIDI_CLASS_name, &const_PROPERTY_BIDI_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BIDI_CLASS_name); + zend_string_release_ex(const_PROPERTY_BIDI_CLASS_name, true); zval const_PROPERTY_INT_START_value; ZVAL_LONG(&const_PROPERTY_INT_START_value, UCHAR_INT_START); - zend_string *const_PROPERTY_INT_START_name = zend_string_init_interned("PROPERTY_INT_START", sizeof("PROPERTY_INT_START") - 1, 1); + zend_string *const_PROPERTY_INT_START_name = zend_string_init_interned("PROPERTY_INT_START", sizeof("PROPERTY_INT_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_INT_START_name, &const_PROPERTY_INT_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_INT_START_name); + zend_string_release_ex(const_PROPERTY_INT_START_name, true); zval const_PROPERTY_BLOCK_value; ZVAL_LONG(&const_PROPERTY_BLOCK_value, UCHAR_BLOCK); - zend_string *const_PROPERTY_BLOCK_name = zend_string_init_interned("PROPERTY_BLOCK", sizeof("PROPERTY_BLOCK") - 1, 1); + zend_string *const_PROPERTY_BLOCK_name = zend_string_init_interned("PROPERTY_BLOCK", sizeof("PROPERTY_BLOCK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BLOCK_name, &const_PROPERTY_BLOCK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BLOCK_name); + zend_string_release_ex(const_PROPERTY_BLOCK_name, true); zval const_PROPERTY_CANONICAL_COMBINING_CLASS_value; ZVAL_LONG(&const_PROPERTY_CANONICAL_COMBINING_CLASS_value, UCHAR_CANONICAL_COMBINING_CLASS); - zend_string *const_PROPERTY_CANONICAL_COMBINING_CLASS_name = zend_string_init_interned("PROPERTY_CANONICAL_COMBINING_CLASS", sizeof("PROPERTY_CANONICAL_COMBINING_CLASS") - 1, 1); + zend_string *const_PROPERTY_CANONICAL_COMBINING_CLASS_name = zend_string_init_interned("PROPERTY_CANONICAL_COMBINING_CLASS", sizeof("PROPERTY_CANONICAL_COMBINING_CLASS") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CANONICAL_COMBINING_CLASS_name, &const_PROPERTY_CANONICAL_COMBINING_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CANONICAL_COMBINING_CLASS_name); + zend_string_release_ex(const_PROPERTY_CANONICAL_COMBINING_CLASS_name, true); zval const_PROPERTY_DECOMPOSITION_TYPE_value; ZVAL_LONG(&const_PROPERTY_DECOMPOSITION_TYPE_value, UCHAR_DECOMPOSITION_TYPE); - zend_string *const_PROPERTY_DECOMPOSITION_TYPE_name = zend_string_init_interned("PROPERTY_DECOMPOSITION_TYPE", sizeof("PROPERTY_DECOMPOSITION_TYPE") - 1, 1); + zend_string *const_PROPERTY_DECOMPOSITION_TYPE_name = zend_string_init_interned("PROPERTY_DECOMPOSITION_TYPE", sizeof("PROPERTY_DECOMPOSITION_TYPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_DECOMPOSITION_TYPE_name, &const_PROPERTY_DECOMPOSITION_TYPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_DECOMPOSITION_TYPE_name); + zend_string_release_ex(const_PROPERTY_DECOMPOSITION_TYPE_name, true); zval const_PROPERTY_EAST_ASIAN_WIDTH_value; ZVAL_LONG(&const_PROPERTY_EAST_ASIAN_WIDTH_value, UCHAR_EAST_ASIAN_WIDTH); - zend_string *const_PROPERTY_EAST_ASIAN_WIDTH_name = zend_string_init_interned("PROPERTY_EAST_ASIAN_WIDTH", sizeof("PROPERTY_EAST_ASIAN_WIDTH") - 1, 1); + zend_string *const_PROPERTY_EAST_ASIAN_WIDTH_name = zend_string_init_interned("PROPERTY_EAST_ASIAN_WIDTH", sizeof("PROPERTY_EAST_ASIAN_WIDTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_EAST_ASIAN_WIDTH_name, &const_PROPERTY_EAST_ASIAN_WIDTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_EAST_ASIAN_WIDTH_name); + zend_string_release_ex(const_PROPERTY_EAST_ASIAN_WIDTH_name, true); zval const_PROPERTY_GENERAL_CATEGORY_value; ZVAL_LONG(&const_PROPERTY_GENERAL_CATEGORY_value, UCHAR_GENERAL_CATEGORY); - zend_string *const_PROPERTY_GENERAL_CATEGORY_name = zend_string_init_interned("PROPERTY_GENERAL_CATEGORY", sizeof("PROPERTY_GENERAL_CATEGORY") - 1, 1); + zend_string *const_PROPERTY_GENERAL_CATEGORY_name = zend_string_init_interned("PROPERTY_GENERAL_CATEGORY", sizeof("PROPERTY_GENERAL_CATEGORY") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_GENERAL_CATEGORY_name, &const_PROPERTY_GENERAL_CATEGORY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_GENERAL_CATEGORY_name); + zend_string_release_ex(const_PROPERTY_GENERAL_CATEGORY_name, true); zval const_PROPERTY_JOINING_GROUP_value; ZVAL_LONG(&const_PROPERTY_JOINING_GROUP_value, UCHAR_JOINING_GROUP); - zend_string *const_PROPERTY_JOINING_GROUP_name = zend_string_init_interned("PROPERTY_JOINING_GROUP", sizeof("PROPERTY_JOINING_GROUP") - 1, 1); + zend_string *const_PROPERTY_JOINING_GROUP_name = zend_string_init_interned("PROPERTY_JOINING_GROUP", sizeof("PROPERTY_JOINING_GROUP") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_JOINING_GROUP_name, &const_PROPERTY_JOINING_GROUP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_JOINING_GROUP_name); + zend_string_release_ex(const_PROPERTY_JOINING_GROUP_name, true); zval const_PROPERTY_JOINING_TYPE_value; ZVAL_LONG(&const_PROPERTY_JOINING_TYPE_value, UCHAR_JOINING_TYPE); - zend_string *const_PROPERTY_JOINING_TYPE_name = zend_string_init_interned("PROPERTY_JOINING_TYPE", sizeof("PROPERTY_JOINING_TYPE") - 1, 1); + zend_string *const_PROPERTY_JOINING_TYPE_name = zend_string_init_interned("PROPERTY_JOINING_TYPE", sizeof("PROPERTY_JOINING_TYPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_JOINING_TYPE_name, &const_PROPERTY_JOINING_TYPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_JOINING_TYPE_name); + zend_string_release_ex(const_PROPERTY_JOINING_TYPE_name, true); zval const_PROPERTY_LINE_BREAK_value; ZVAL_LONG(&const_PROPERTY_LINE_BREAK_value, UCHAR_LINE_BREAK); - zend_string *const_PROPERTY_LINE_BREAK_name = zend_string_init_interned("PROPERTY_LINE_BREAK", sizeof("PROPERTY_LINE_BREAK") - 1, 1); + zend_string *const_PROPERTY_LINE_BREAK_name = zend_string_init_interned("PROPERTY_LINE_BREAK", sizeof("PROPERTY_LINE_BREAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_LINE_BREAK_name, &const_PROPERTY_LINE_BREAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_LINE_BREAK_name); + zend_string_release_ex(const_PROPERTY_LINE_BREAK_name, true); zval const_PROPERTY_NUMERIC_TYPE_value; ZVAL_LONG(&const_PROPERTY_NUMERIC_TYPE_value, UCHAR_NUMERIC_TYPE); - zend_string *const_PROPERTY_NUMERIC_TYPE_name = zend_string_init_interned("PROPERTY_NUMERIC_TYPE", sizeof("PROPERTY_NUMERIC_TYPE") - 1, 1); + zend_string *const_PROPERTY_NUMERIC_TYPE_name = zend_string_init_interned("PROPERTY_NUMERIC_TYPE", sizeof("PROPERTY_NUMERIC_TYPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NUMERIC_TYPE_name, &const_PROPERTY_NUMERIC_TYPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NUMERIC_TYPE_name); + zend_string_release_ex(const_PROPERTY_NUMERIC_TYPE_name, true); zval const_PROPERTY_SCRIPT_value; ZVAL_LONG(&const_PROPERTY_SCRIPT_value, UCHAR_SCRIPT); - zend_string *const_PROPERTY_SCRIPT_name = zend_string_init_interned("PROPERTY_SCRIPT", sizeof("PROPERTY_SCRIPT") - 1, 1); + zend_string *const_PROPERTY_SCRIPT_name = zend_string_init_interned("PROPERTY_SCRIPT", sizeof("PROPERTY_SCRIPT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SCRIPT_name, &const_PROPERTY_SCRIPT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SCRIPT_name); + zend_string_release_ex(const_PROPERTY_SCRIPT_name, true); zval const_PROPERTY_HANGUL_SYLLABLE_TYPE_value; ZVAL_LONG(&const_PROPERTY_HANGUL_SYLLABLE_TYPE_value, UCHAR_HANGUL_SYLLABLE_TYPE); - zend_string *const_PROPERTY_HANGUL_SYLLABLE_TYPE_name = zend_string_init_interned("PROPERTY_HANGUL_SYLLABLE_TYPE", sizeof("PROPERTY_HANGUL_SYLLABLE_TYPE") - 1, 1); + zend_string *const_PROPERTY_HANGUL_SYLLABLE_TYPE_name = zend_string_init_interned("PROPERTY_HANGUL_SYLLABLE_TYPE", sizeof("PROPERTY_HANGUL_SYLLABLE_TYPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_HANGUL_SYLLABLE_TYPE_name, &const_PROPERTY_HANGUL_SYLLABLE_TYPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_HANGUL_SYLLABLE_TYPE_name); + zend_string_release_ex(const_PROPERTY_HANGUL_SYLLABLE_TYPE_name, true); zval const_PROPERTY_NFD_QUICK_CHECK_value; ZVAL_LONG(&const_PROPERTY_NFD_QUICK_CHECK_value, UCHAR_NFD_QUICK_CHECK); - zend_string *const_PROPERTY_NFD_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFD_QUICK_CHECK", sizeof("PROPERTY_NFD_QUICK_CHECK") - 1, 1); + zend_string *const_PROPERTY_NFD_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFD_QUICK_CHECK", sizeof("PROPERTY_NFD_QUICK_CHECK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFD_QUICK_CHECK_name, &const_PROPERTY_NFD_QUICK_CHECK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFD_QUICK_CHECK_name); + zend_string_release_ex(const_PROPERTY_NFD_QUICK_CHECK_name, true); zval const_PROPERTY_NFKD_QUICK_CHECK_value; ZVAL_LONG(&const_PROPERTY_NFKD_QUICK_CHECK_value, UCHAR_NFKD_QUICK_CHECK); - zend_string *const_PROPERTY_NFKD_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFKD_QUICK_CHECK", sizeof("PROPERTY_NFKD_QUICK_CHECK") - 1, 1); + zend_string *const_PROPERTY_NFKD_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFKD_QUICK_CHECK", sizeof("PROPERTY_NFKD_QUICK_CHECK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFKD_QUICK_CHECK_name, &const_PROPERTY_NFKD_QUICK_CHECK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFKD_QUICK_CHECK_name); + zend_string_release_ex(const_PROPERTY_NFKD_QUICK_CHECK_name, true); zval const_PROPERTY_NFC_QUICK_CHECK_value; ZVAL_LONG(&const_PROPERTY_NFC_QUICK_CHECK_value, UCHAR_NFC_QUICK_CHECK); - zend_string *const_PROPERTY_NFC_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFC_QUICK_CHECK", sizeof("PROPERTY_NFC_QUICK_CHECK") - 1, 1); + zend_string *const_PROPERTY_NFC_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFC_QUICK_CHECK", sizeof("PROPERTY_NFC_QUICK_CHECK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFC_QUICK_CHECK_name, &const_PROPERTY_NFC_QUICK_CHECK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFC_QUICK_CHECK_name); + zend_string_release_ex(const_PROPERTY_NFC_QUICK_CHECK_name, true); zval const_PROPERTY_NFKC_QUICK_CHECK_value; ZVAL_LONG(&const_PROPERTY_NFKC_QUICK_CHECK_value, UCHAR_NFKC_QUICK_CHECK); - zend_string *const_PROPERTY_NFKC_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFKC_QUICK_CHECK", sizeof("PROPERTY_NFKC_QUICK_CHECK") - 1, 1); + zend_string *const_PROPERTY_NFKC_QUICK_CHECK_name = zend_string_init_interned("PROPERTY_NFKC_QUICK_CHECK", sizeof("PROPERTY_NFKC_QUICK_CHECK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NFKC_QUICK_CHECK_name, &const_PROPERTY_NFKC_QUICK_CHECK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NFKC_QUICK_CHECK_name); + zend_string_release_ex(const_PROPERTY_NFKC_QUICK_CHECK_name, true); zval const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_value; ZVAL_LONG(&const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_value, UCHAR_LEAD_CANONICAL_COMBINING_CLASS); - zend_string *const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_name = zend_string_init_interned("PROPERTY_LEAD_CANONICAL_COMBINING_CLASS", sizeof("PROPERTY_LEAD_CANONICAL_COMBINING_CLASS") - 1, 1); + zend_string *const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_name = zend_string_init_interned("PROPERTY_LEAD_CANONICAL_COMBINING_CLASS", sizeof("PROPERTY_LEAD_CANONICAL_COMBINING_CLASS") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_name, &const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_name); + zend_string_release_ex(const_PROPERTY_LEAD_CANONICAL_COMBINING_CLASS_name, true); zval const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_value; ZVAL_LONG(&const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_value, UCHAR_TRAIL_CANONICAL_COMBINING_CLASS); - zend_string *const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_name = zend_string_init_interned("PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS", sizeof("PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS") - 1, 1); + zend_string *const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_name = zend_string_init_interned("PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS", sizeof("PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_name, &const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_name); + zend_string_release_ex(const_PROPERTY_TRAIL_CANONICAL_COMBINING_CLASS_name, true); zval const_PROPERTY_GRAPHEME_CLUSTER_BREAK_value; ZVAL_LONG(&const_PROPERTY_GRAPHEME_CLUSTER_BREAK_value, UCHAR_GRAPHEME_CLUSTER_BREAK); - zend_string *const_PROPERTY_GRAPHEME_CLUSTER_BREAK_name = zend_string_init_interned("PROPERTY_GRAPHEME_CLUSTER_BREAK", sizeof("PROPERTY_GRAPHEME_CLUSTER_BREAK") - 1, 1); + zend_string *const_PROPERTY_GRAPHEME_CLUSTER_BREAK_name = zend_string_init_interned("PROPERTY_GRAPHEME_CLUSTER_BREAK", sizeof("PROPERTY_GRAPHEME_CLUSTER_BREAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_GRAPHEME_CLUSTER_BREAK_name, &const_PROPERTY_GRAPHEME_CLUSTER_BREAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_GRAPHEME_CLUSTER_BREAK_name); + zend_string_release_ex(const_PROPERTY_GRAPHEME_CLUSTER_BREAK_name, true); zval const_PROPERTY_SENTENCE_BREAK_value; ZVAL_LONG(&const_PROPERTY_SENTENCE_BREAK_value, UCHAR_SENTENCE_BREAK); - zend_string *const_PROPERTY_SENTENCE_BREAK_name = zend_string_init_interned("PROPERTY_SENTENCE_BREAK", sizeof("PROPERTY_SENTENCE_BREAK") - 1, 1); + zend_string *const_PROPERTY_SENTENCE_BREAK_name = zend_string_init_interned("PROPERTY_SENTENCE_BREAK", sizeof("PROPERTY_SENTENCE_BREAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SENTENCE_BREAK_name, &const_PROPERTY_SENTENCE_BREAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SENTENCE_BREAK_name); + zend_string_release_ex(const_PROPERTY_SENTENCE_BREAK_name, true); zval const_PROPERTY_WORD_BREAK_value; ZVAL_LONG(&const_PROPERTY_WORD_BREAK_value, UCHAR_WORD_BREAK); - zend_string *const_PROPERTY_WORD_BREAK_name = zend_string_init_interned("PROPERTY_WORD_BREAK", sizeof("PROPERTY_WORD_BREAK") - 1, 1); + zend_string *const_PROPERTY_WORD_BREAK_name = zend_string_init_interned("PROPERTY_WORD_BREAK", sizeof("PROPERTY_WORD_BREAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_WORD_BREAK_name, &const_PROPERTY_WORD_BREAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_WORD_BREAK_name); + zend_string_release_ex(const_PROPERTY_WORD_BREAK_name, true); zval const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_value; ZVAL_LONG(&const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_value, UCHAR_BIDI_PAIRED_BRACKET_TYPE); - zend_string *const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_name = zend_string_init_interned("PROPERTY_BIDI_PAIRED_BRACKET_TYPE", sizeof("PROPERTY_BIDI_PAIRED_BRACKET_TYPE") - 1, 1); + zend_string *const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_name = zend_string_init_interned("PROPERTY_BIDI_PAIRED_BRACKET_TYPE", sizeof("PROPERTY_BIDI_PAIRED_BRACKET_TYPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_name, &const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_name); + zend_string_release_ex(const_PROPERTY_BIDI_PAIRED_BRACKET_TYPE_name, true); zval const_PROPERTY_INT_LIMIT_value; ZVAL_LONG(&const_PROPERTY_INT_LIMIT_value, UCHAR_INT_LIMIT); - zend_string *const_PROPERTY_INT_LIMIT_name = zend_string_init_interned("PROPERTY_INT_LIMIT", sizeof("PROPERTY_INT_LIMIT") - 1, 1); + zend_string *const_PROPERTY_INT_LIMIT_name = zend_string_init_interned("PROPERTY_INT_LIMIT", sizeof("PROPERTY_INT_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_INT_LIMIT_name, &const_PROPERTY_INT_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_INT_LIMIT_name); + zend_string_release_ex(const_PROPERTY_INT_LIMIT_name, true); zval const_PROPERTY_GENERAL_CATEGORY_MASK_value; ZVAL_LONG(&const_PROPERTY_GENERAL_CATEGORY_MASK_value, UCHAR_GENERAL_CATEGORY_MASK); - zend_string *const_PROPERTY_GENERAL_CATEGORY_MASK_name = zend_string_init_interned("PROPERTY_GENERAL_CATEGORY_MASK", sizeof("PROPERTY_GENERAL_CATEGORY_MASK") - 1, 1); + zend_string *const_PROPERTY_GENERAL_CATEGORY_MASK_name = zend_string_init_interned("PROPERTY_GENERAL_CATEGORY_MASK", sizeof("PROPERTY_GENERAL_CATEGORY_MASK") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_GENERAL_CATEGORY_MASK_name, &const_PROPERTY_GENERAL_CATEGORY_MASK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_GENERAL_CATEGORY_MASK_name); + zend_string_release_ex(const_PROPERTY_GENERAL_CATEGORY_MASK_name, true); zval const_PROPERTY_MASK_START_value; ZVAL_LONG(&const_PROPERTY_MASK_START_value, UCHAR_MASK_START); - zend_string *const_PROPERTY_MASK_START_name = zend_string_init_interned("PROPERTY_MASK_START", sizeof("PROPERTY_MASK_START") - 1, 1); + zend_string *const_PROPERTY_MASK_START_name = zend_string_init_interned("PROPERTY_MASK_START", sizeof("PROPERTY_MASK_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_MASK_START_name, &const_PROPERTY_MASK_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_MASK_START_name); + zend_string_release_ex(const_PROPERTY_MASK_START_name, true); zval const_PROPERTY_MASK_LIMIT_value; ZVAL_LONG(&const_PROPERTY_MASK_LIMIT_value, UCHAR_MASK_LIMIT); - zend_string *const_PROPERTY_MASK_LIMIT_name = zend_string_init_interned("PROPERTY_MASK_LIMIT", sizeof("PROPERTY_MASK_LIMIT") - 1, 1); + zend_string *const_PROPERTY_MASK_LIMIT_name = zend_string_init_interned("PROPERTY_MASK_LIMIT", sizeof("PROPERTY_MASK_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_MASK_LIMIT_name, &const_PROPERTY_MASK_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_MASK_LIMIT_name); + zend_string_release_ex(const_PROPERTY_MASK_LIMIT_name, true); zval const_PROPERTY_NUMERIC_VALUE_value; ZVAL_LONG(&const_PROPERTY_NUMERIC_VALUE_value, UCHAR_NUMERIC_VALUE); - zend_string *const_PROPERTY_NUMERIC_VALUE_name = zend_string_init_interned("PROPERTY_NUMERIC_VALUE", sizeof("PROPERTY_NUMERIC_VALUE") - 1, 1); + zend_string *const_PROPERTY_NUMERIC_VALUE_name = zend_string_init_interned("PROPERTY_NUMERIC_VALUE", sizeof("PROPERTY_NUMERIC_VALUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NUMERIC_VALUE_name, &const_PROPERTY_NUMERIC_VALUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NUMERIC_VALUE_name); + zend_string_release_ex(const_PROPERTY_NUMERIC_VALUE_name, true); zval const_PROPERTY_DOUBLE_START_value; ZVAL_LONG(&const_PROPERTY_DOUBLE_START_value, UCHAR_DOUBLE_START); - zend_string *const_PROPERTY_DOUBLE_START_name = zend_string_init_interned("PROPERTY_DOUBLE_START", sizeof("PROPERTY_DOUBLE_START") - 1, 1); + zend_string *const_PROPERTY_DOUBLE_START_name = zend_string_init_interned("PROPERTY_DOUBLE_START", sizeof("PROPERTY_DOUBLE_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_DOUBLE_START_name, &const_PROPERTY_DOUBLE_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_DOUBLE_START_name); + zend_string_release_ex(const_PROPERTY_DOUBLE_START_name, true); zval const_PROPERTY_DOUBLE_LIMIT_value; ZVAL_LONG(&const_PROPERTY_DOUBLE_LIMIT_value, UCHAR_DOUBLE_LIMIT); - zend_string *const_PROPERTY_DOUBLE_LIMIT_name = zend_string_init_interned("PROPERTY_DOUBLE_LIMIT", sizeof("PROPERTY_DOUBLE_LIMIT") - 1, 1); + zend_string *const_PROPERTY_DOUBLE_LIMIT_name = zend_string_init_interned("PROPERTY_DOUBLE_LIMIT", sizeof("PROPERTY_DOUBLE_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_DOUBLE_LIMIT_name, &const_PROPERTY_DOUBLE_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_DOUBLE_LIMIT_name); + zend_string_release_ex(const_PROPERTY_DOUBLE_LIMIT_name, true); zval const_PROPERTY_AGE_value; ZVAL_LONG(&const_PROPERTY_AGE_value, UCHAR_AGE); - zend_string *const_PROPERTY_AGE_name = zend_string_init_interned("PROPERTY_AGE", sizeof("PROPERTY_AGE") - 1, 1); + zend_string *const_PROPERTY_AGE_name = zend_string_init_interned("PROPERTY_AGE", sizeof("PROPERTY_AGE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_AGE_name, &const_PROPERTY_AGE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_AGE_name); + zend_string_release_ex(const_PROPERTY_AGE_name, true); zval const_PROPERTY_STRING_START_value; ZVAL_LONG(&const_PROPERTY_STRING_START_value, UCHAR_STRING_START); - zend_string *const_PROPERTY_STRING_START_name = zend_string_init_interned("PROPERTY_STRING_START", sizeof("PROPERTY_STRING_START") - 1, 1); + zend_string *const_PROPERTY_STRING_START_name = zend_string_init_interned("PROPERTY_STRING_START", sizeof("PROPERTY_STRING_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_STRING_START_name, &const_PROPERTY_STRING_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_STRING_START_name); + zend_string_release_ex(const_PROPERTY_STRING_START_name, true); zval const_PROPERTY_BIDI_MIRRORING_GLYPH_value; ZVAL_LONG(&const_PROPERTY_BIDI_MIRRORING_GLYPH_value, UCHAR_BIDI_MIRRORING_GLYPH); - zend_string *const_PROPERTY_BIDI_MIRRORING_GLYPH_name = zend_string_init_interned("PROPERTY_BIDI_MIRRORING_GLYPH", sizeof("PROPERTY_BIDI_MIRRORING_GLYPH") - 1, 1); + zend_string *const_PROPERTY_BIDI_MIRRORING_GLYPH_name = zend_string_init_interned("PROPERTY_BIDI_MIRRORING_GLYPH", sizeof("PROPERTY_BIDI_MIRRORING_GLYPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BIDI_MIRRORING_GLYPH_name, &const_PROPERTY_BIDI_MIRRORING_GLYPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BIDI_MIRRORING_GLYPH_name); + zend_string_release_ex(const_PROPERTY_BIDI_MIRRORING_GLYPH_name, true); zval const_PROPERTY_CASE_FOLDING_value; ZVAL_LONG(&const_PROPERTY_CASE_FOLDING_value, UCHAR_CASE_FOLDING); - zend_string *const_PROPERTY_CASE_FOLDING_name = zend_string_init_interned("PROPERTY_CASE_FOLDING", sizeof("PROPERTY_CASE_FOLDING") - 1, 1); + zend_string *const_PROPERTY_CASE_FOLDING_name = zend_string_init_interned("PROPERTY_CASE_FOLDING", sizeof("PROPERTY_CASE_FOLDING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_CASE_FOLDING_name, &const_PROPERTY_CASE_FOLDING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_CASE_FOLDING_name); + zend_string_release_ex(const_PROPERTY_CASE_FOLDING_name, true); zval const_PROPERTY_ISO_COMMENT_value; ZVAL_LONG(&const_PROPERTY_ISO_COMMENT_value, UCHAR_ISO_COMMENT); - zend_string *const_PROPERTY_ISO_COMMENT_name = zend_string_init_interned("PROPERTY_ISO_COMMENT", sizeof("PROPERTY_ISO_COMMENT") - 1, 1); + zend_string *const_PROPERTY_ISO_COMMENT_name = zend_string_init_interned("PROPERTY_ISO_COMMENT", sizeof("PROPERTY_ISO_COMMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_ISO_COMMENT_name, &const_PROPERTY_ISO_COMMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_ISO_COMMENT_name); + zend_string_release_ex(const_PROPERTY_ISO_COMMENT_name, true); zval const_PROPERTY_LOWERCASE_MAPPING_value; ZVAL_LONG(&const_PROPERTY_LOWERCASE_MAPPING_value, UCHAR_LOWERCASE_MAPPING); - zend_string *const_PROPERTY_LOWERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_LOWERCASE_MAPPING", sizeof("PROPERTY_LOWERCASE_MAPPING") - 1, 1); + zend_string *const_PROPERTY_LOWERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_LOWERCASE_MAPPING", sizeof("PROPERTY_LOWERCASE_MAPPING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_LOWERCASE_MAPPING_name, &const_PROPERTY_LOWERCASE_MAPPING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_LOWERCASE_MAPPING_name); + zend_string_release_ex(const_PROPERTY_LOWERCASE_MAPPING_name, true); zval const_PROPERTY_NAME_value; ZVAL_LONG(&const_PROPERTY_NAME_value, UCHAR_NAME); - zend_string *const_PROPERTY_NAME_name = zend_string_init_interned("PROPERTY_NAME", sizeof("PROPERTY_NAME") - 1, 1); + zend_string *const_PROPERTY_NAME_name = zend_string_init_interned("PROPERTY_NAME", sizeof("PROPERTY_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NAME_name, &const_PROPERTY_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NAME_name); + zend_string_release_ex(const_PROPERTY_NAME_name, true); zval const_PROPERTY_SIMPLE_CASE_FOLDING_value; ZVAL_LONG(&const_PROPERTY_SIMPLE_CASE_FOLDING_value, UCHAR_SIMPLE_CASE_FOLDING); - zend_string *const_PROPERTY_SIMPLE_CASE_FOLDING_name = zend_string_init_interned("PROPERTY_SIMPLE_CASE_FOLDING", sizeof("PROPERTY_SIMPLE_CASE_FOLDING") - 1, 1); + zend_string *const_PROPERTY_SIMPLE_CASE_FOLDING_name = zend_string_init_interned("PROPERTY_SIMPLE_CASE_FOLDING", sizeof("PROPERTY_SIMPLE_CASE_FOLDING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SIMPLE_CASE_FOLDING_name, &const_PROPERTY_SIMPLE_CASE_FOLDING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SIMPLE_CASE_FOLDING_name); + zend_string_release_ex(const_PROPERTY_SIMPLE_CASE_FOLDING_name, true); zval const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_value; ZVAL_LONG(&const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_value, UCHAR_SIMPLE_LOWERCASE_MAPPING); - zend_string *const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_SIMPLE_LOWERCASE_MAPPING", sizeof("PROPERTY_SIMPLE_LOWERCASE_MAPPING") - 1, 1); + zend_string *const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_SIMPLE_LOWERCASE_MAPPING", sizeof("PROPERTY_SIMPLE_LOWERCASE_MAPPING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_name, &const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_name); + zend_string_release_ex(const_PROPERTY_SIMPLE_LOWERCASE_MAPPING_name, true); zval const_PROPERTY_SIMPLE_TITLECASE_MAPPING_value; ZVAL_LONG(&const_PROPERTY_SIMPLE_TITLECASE_MAPPING_value, UCHAR_SIMPLE_TITLECASE_MAPPING); - zend_string *const_PROPERTY_SIMPLE_TITLECASE_MAPPING_name = zend_string_init_interned("PROPERTY_SIMPLE_TITLECASE_MAPPING", sizeof("PROPERTY_SIMPLE_TITLECASE_MAPPING") - 1, 1); + zend_string *const_PROPERTY_SIMPLE_TITLECASE_MAPPING_name = zend_string_init_interned("PROPERTY_SIMPLE_TITLECASE_MAPPING", sizeof("PROPERTY_SIMPLE_TITLECASE_MAPPING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SIMPLE_TITLECASE_MAPPING_name, &const_PROPERTY_SIMPLE_TITLECASE_MAPPING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SIMPLE_TITLECASE_MAPPING_name); + zend_string_release_ex(const_PROPERTY_SIMPLE_TITLECASE_MAPPING_name, true); zval const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_value; ZVAL_LONG(&const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_value, UCHAR_SIMPLE_UPPERCASE_MAPPING); - zend_string *const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_SIMPLE_UPPERCASE_MAPPING", sizeof("PROPERTY_SIMPLE_UPPERCASE_MAPPING") - 1, 1); + zend_string *const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_SIMPLE_UPPERCASE_MAPPING", sizeof("PROPERTY_SIMPLE_UPPERCASE_MAPPING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_name, &const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_name); + zend_string_release_ex(const_PROPERTY_SIMPLE_UPPERCASE_MAPPING_name, true); zval const_PROPERTY_TITLECASE_MAPPING_value; ZVAL_LONG(&const_PROPERTY_TITLECASE_MAPPING_value, UCHAR_TITLECASE_MAPPING); - zend_string *const_PROPERTY_TITLECASE_MAPPING_name = zend_string_init_interned("PROPERTY_TITLECASE_MAPPING", sizeof("PROPERTY_TITLECASE_MAPPING") - 1, 1); + zend_string *const_PROPERTY_TITLECASE_MAPPING_name = zend_string_init_interned("PROPERTY_TITLECASE_MAPPING", sizeof("PROPERTY_TITLECASE_MAPPING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_TITLECASE_MAPPING_name, &const_PROPERTY_TITLECASE_MAPPING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_TITLECASE_MAPPING_name); + zend_string_release_ex(const_PROPERTY_TITLECASE_MAPPING_name, true); zval const_PROPERTY_UNICODE_1_NAME_value; ZVAL_LONG(&const_PROPERTY_UNICODE_1_NAME_value, UCHAR_UNICODE_1_NAME); - zend_string *const_PROPERTY_UNICODE_1_NAME_name = zend_string_init_interned("PROPERTY_UNICODE_1_NAME", sizeof("PROPERTY_UNICODE_1_NAME") - 1, 1); + zend_string *const_PROPERTY_UNICODE_1_NAME_name = zend_string_init_interned("PROPERTY_UNICODE_1_NAME", sizeof("PROPERTY_UNICODE_1_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_UNICODE_1_NAME_name, &const_PROPERTY_UNICODE_1_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_UNICODE_1_NAME_name); + zend_string_release_ex(const_PROPERTY_UNICODE_1_NAME_name, true); zval const_PROPERTY_UPPERCASE_MAPPING_value; ZVAL_LONG(&const_PROPERTY_UPPERCASE_MAPPING_value, UCHAR_UPPERCASE_MAPPING); - zend_string *const_PROPERTY_UPPERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_UPPERCASE_MAPPING", sizeof("PROPERTY_UPPERCASE_MAPPING") - 1, 1); + zend_string *const_PROPERTY_UPPERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_UPPERCASE_MAPPING", sizeof("PROPERTY_UPPERCASE_MAPPING") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_UPPERCASE_MAPPING_name, &const_PROPERTY_UPPERCASE_MAPPING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_UPPERCASE_MAPPING_name); + zend_string_release_ex(const_PROPERTY_UPPERCASE_MAPPING_name, true); zval const_PROPERTY_BIDI_PAIRED_BRACKET_value; ZVAL_LONG(&const_PROPERTY_BIDI_PAIRED_BRACKET_value, UCHAR_BIDI_PAIRED_BRACKET); - zend_string *const_PROPERTY_BIDI_PAIRED_BRACKET_name = zend_string_init_interned("PROPERTY_BIDI_PAIRED_BRACKET", sizeof("PROPERTY_BIDI_PAIRED_BRACKET") - 1, 1); + zend_string *const_PROPERTY_BIDI_PAIRED_BRACKET_name = zend_string_init_interned("PROPERTY_BIDI_PAIRED_BRACKET", sizeof("PROPERTY_BIDI_PAIRED_BRACKET") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_BIDI_PAIRED_BRACKET_name, &const_PROPERTY_BIDI_PAIRED_BRACKET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_BIDI_PAIRED_BRACKET_name); + zend_string_release_ex(const_PROPERTY_BIDI_PAIRED_BRACKET_name, true); zval const_PROPERTY_STRING_LIMIT_value; ZVAL_LONG(&const_PROPERTY_STRING_LIMIT_value, UCHAR_STRING_LIMIT); - zend_string *const_PROPERTY_STRING_LIMIT_name = zend_string_init_interned("PROPERTY_STRING_LIMIT", sizeof("PROPERTY_STRING_LIMIT") - 1, 1); + zend_string *const_PROPERTY_STRING_LIMIT_name = zend_string_init_interned("PROPERTY_STRING_LIMIT", sizeof("PROPERTY_STRING_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_STRING_LIMIT_name, &const_PROPERTY_STRING_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_STRING_LIMIT_name); + zend_string_release_ex(const_PROPERTY_STRING_LIMIT_name, true); zval const_PROPERTY_SCRIPT_EXTENSIONS_value; ZVAL_LONG(&const_PROPERTY_SCRIPT_EXTENSIONS_value, UCHAR_SCRIPT_EXTENSIONS); - zend_string *const_PROPERTY_SCRIPT_EXTENSIONS_name = zend_string_init_interned("PROPERTY_SCRIPT_EXTENSIONS", sizeof("PROPERTY_SCRIPT_EXTENSIONS") - 1, 1); + zend_string *const_PROPERTY_SCRIPT_EXTENSIONS_name = zend_string_init_interned("PROPERTY_SCRIPT_EXTENSIONS", sizeof("PROPERTY_SCRIPT_EXTENSIONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_SCRIPT_EXTENSIONS_name, &const_PROPERTY_SCRIPT_EXTENSIONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_SCRIPT_EXTENSIONS_name); + zend_string_release_ex(const_PROPERTY_SCRIPT_EXTENSIONS_name, true); zval const_PROPERTY_OTHER_PROPERTY_START_value; ZVAL_LONG(&const_PROPERTY_OTHER_PROPERTY_START_value, UCHAR_OTHER_PROPERTY_START); - zend_string *const_PROPERTY_OTHER_PROPERTY_START_name = zend_string_init_interned("PROPERTY_OTHER_PROPERTY_START", sizeof("PROPERTY_OTHER_PROPERTY_START") - 1, 1); + zend_string *const_PROPERTY_OTHER_PROPERTY_START_name = zend_string_init_interned("PROPERTY_OTHER_PROPERTY_START", sizeof("PROPERTY_OTHER_PROPERTY_START") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_OTHER_PROPERTY_START_name, &const_PROPERTY_OTHER_PROPERTY_START_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_OTHER_PROPERTY_START_name); + zend_string_release_ex(const_PROPERTY_OTHER_PROPERTY_START_name, true); zval const_PROPERTY_OTHER_PROPERTY_LIMIT_value; ZVAL_LONG(&const_PROPERTY_OTHER_PROPERTY_LIMIT_value, UCHAR_OTHER_PROPERTY_LIMIT); - zend_string *const_PROPERTY_OTHER_PROPERTY_LIMIT_name = zend_string_init_interned("PROPERTY_OTHER_PROPERTY_LIMIT", sizeof("PROPERTY_OTHER_PROPERTY_LIMIT") - 1, 1); + zend_string *const_PROPERTY_OTHER_PROPERTY_LIMIT_name = zend_string_init_interned("PROPERTY_OTHER_PROPERTY_LIMIT", sizeof("PROPERTY_OTHER_PROPERTY_LIMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_OTHER_PROPERTY_LIMIT_name, &const_PROPERTY_OTHER_PROPERTY_LIMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_OTHER_PROPERTY_LIMIT_name); + zend_string_release_ex(const_PROPERTY_OTHER_PROPERTY_LIMIT_name, true); zval const_PROPERTY_INVALID_CODE_value; ZVAL_LONG(&const_PROPERTY_INVALID_CODE_value, UCHAR_INVALID_CODE); - zend_string *const_PROPERTY_INVALID_CODE_name = zend_string_init_interned("PROPERTY_INVALID_CODE", sizeof("PROPERTY_INVALID_CODE") - 1, 1); + zend_string *const_PROPERTY_INVALID_CODE_name = zend_string_init_interned("PROPERTY_INVALID_CODE", sizeof("PROPERTY_INVALID_CODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_INVALID_CODE_name, &const_PROPERTY_INVALID_CODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_INVALID_CODE_name); + zend_string_release_ex(const_PROPERTY_INVALID_CODE_name, true); zval const_CHAR_CATEGORY_UNASSIGNED_value; ZVAL_LONG(&const_CHAR_CATEGORY_UNASSIGNED_value, U_UNASSIGNED); - zend_string *const_CHAR_CATEGORY_UNASSIGNED_name = zend_string_init_interned("CHAR_CATEGORY_UNASSIGNED", sizeof("CHAR_CATEGORY_UNASSIGNED") - 1, 1); + zend_string *const_CHAR_CATEGORY_UNASSIGNED_name = zend_string_init_interned("CHAR_CATEGORY_UNASSIGNED", sizeof("CHAR_CATEGORY_UNASSIGNED") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_UNASSIGNED_name, &const_CHAR_CATEGORY_UNASSIGNED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_UNASSIGNED_name); + zend_string_release_ex(const_CHAR_CATEGORY_UNASSIGNED_name, true); zval const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_value; ZVAL_LONG(&const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_value, U_GENERAL_OTHER_TYPES); - zend_string *const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_name = zend_string_init_interned("CHAR_CATEGORY_GENERAL_OTHER_TYPES", sizeof("CHAR_CATEGORY_GENERAL_OTHER_TYPES") - 1, 1); + zend_string *const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_name = zend_string_init_interned("CHAR_CATEGORY_GENERAL_OTHER_TYPES", sizeof("CHAR_CATEGORY_GENERAL_OTHER_TYPES") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_name, &const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_name); + zend_string_release_ex(const_CHAR_CATEGORY_GENERAL_OTHER_TYPES_name, true); zval const_CHAR_CATEGORY_UPPERCASE_LETTER_value; ZVAL_LONG(&const_CHAR_CATEGORY_UPPERCASE_LETTER_value, U_UPPERCASE_LETTER); - zend_string *const_CHAR_CATEGORY_UPPERCASE_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_UPPERCASE_LETTER", sizeof("CHAR_CATEGORY_UPPERCASE_LETTER") - 1, 1); + zend_string *const_CHAR_CATEGORY_UPPERCASE_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_UPPERCASE_LETTER", sizeof("CHAR_CATEGORY_UPPERCASE_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_UPPERCASE_LETTER_name, &const_CHAR_CATEGORY_UPPERCASE_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_UPPERCASE_LETTER_name); + zend_string_release_ex(const_CHAR_CATEGORY_UPPERCASE_LETTER_name, true); zval const_CHAR_CATEGORY_LOWERCASE_LETTER_value; ZVAL_LONG(&const_CHAR_CATEGORY_LOWERCASE_LETTER_value, U_LOWERCASE_LETTER); - zend_string *const_CHAR_CATEGORY_LOWERCASE_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_LOWERCASE_LETTER", sizeof("CHAR_CATEGORY_LOWERCASE_LETTER") - 1, 1); + zend_string *const_CHAR_CATEGORY_LOWERCASE_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_LOWERCASE_LETTER", sizeof("CHAR_CATEGORY_LOWERCASE_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_LOWERCASE_LETTER_name, &const_CHAR_CATEGORY_LOWERCASE_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_LOWERCASE_LETTER_name); + zend_string_release_ex(const_CHAR_CATEGORY_LOWERCASE_LETTER_name, true); zval const_CHAR_CATEGORY_TITLECASE_LETTER_value; ZVAL_LONG(&const_CHAR_CATEGORY_TITLECASE_LETTER_value, U_TITLECASE_LETTER); - zend_string *const_CHAR_CATEGORY_TITLECASE_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_TITLECASE_LETTER", sizeof("CHAR_CATEGORY_TITLECASE_LETTER") - 1, 1); + zend_string *const_CHAR_CATEGORY_TITLECASE_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_TITLECASE_LETTER", sizeof("CHAR_CATEGORY_TITLECASE_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_TITLECASE_LETTER_name, &const_CHAR_CATEGORY_TITLECASE_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_TITLECASE_LETTER_name); + zend_string_release_ex(const_CHAR_CATEGORY_TITLECASE_LETTER_name, true); zval const_CHAR_CATEGORY_MODIFIER_LETTER_value; ZVAL_LONG(&const_CHAR_CATEGORY_MODIFIER_LETTER_value, U_MODIFIER_LETTER); - zend_string *const_CHAR_CATEGORY_MODIFIER_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_MODIFIER_LETTER", sizeof("CHAR_CATEGORY_MODIFIER_LETTER") - 1, 1); + zend_string *const_CHAR_CATEGORY_MODIFIER_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_MODIFIER_LETTER", sizeof("CHAR_CATEGORY_MODIFIER_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_MODIFIER_LETTER_name, &const_CHAR_CATEGORY_MODIFIER_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_MODIFIER_LETTER_name); + zend_string_release_ex(const_CHAR_CATEGORY_MODIFIER_LETTER_name, true); zval const_CHAR_CATEGORY_OTHER_LETTER_value; ZVAL_LONG(&const_CHAR_CATEGORY_OTHER_LETTER_value, U_OTHER_LETTER); - zend_string *const_CHAR_CATEGORY_OTHER_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_LETTER", sizeof("CHAR_CATEGORY_OTHER_LETTER") - 1, 1); + zend_string *const_CHAR_CATEGORY_OTHER_LETTER_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_LETTER", sizeof("CHAR_CATEGORY_OTHER_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_OTHER_LETTER_name, &const_CHAR_CATEGORY_OTHER_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_OTHER_LETTER_name); + zend_string_release_ex(const_CHAR_CATEGORY_OTHER_LETTER_name, true); zval const_CHAR_CATEGORY_NON_SPACING_MARK_value; ZVAL_LONG(&const_CHAR_CATEGORY_NON_SPACING_MARK_value, U_NON_SPACING_MARK); - zend_string *const_CHAR_CATEGORY_NON_SPACING_MARK_name = zend_string_init_interned("CHAR_CATEGORY_NON_SPACING_MARK", sizeof("CHAR_CATEGORY_NON_SPACING_MARK") - 1, 1); + zend_string *const_CHAR_CATEGORY_NON_SPACING_MARK_name = zend_string_init_interned("CHAR_CATEGORY_NON_SPACING_MARK", sizeof("CHAR_CATEGORY_NON_SPACING_MARK") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_NON_SPACING_MARK_name, &const_CHAR_CATEGORY_NON_SPACING_MARK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_NON_SPACING_MARK_name); + zend_string_release_ex(const_CHAR_CATEGORY_NON_SPACING_MARK_name, true); zval const_CHAR_CATEGORY_ENCLOSING_MARK_value; ZVAL_LONG(&const_CHAR_CATEGORY_ENCLOSING_MARK_value, U_ENCLOSING_MARK); - zend_string *const_CHAR_CATEGORY_ENCLOSING_MARK_name = zend_string_init_interned("CHAR_CATEGORY_ENCLOSING_MARK", sizeof("CHAR_CATEGORY_ENCLOSING_MARK") - 1, 1); + zend_string *const_CHAR_CATEGORY_ENCLOSING_MARK_name = zend_string_init_interned("CHAR_CATEGORY_ENCLOSING_MARK", sizeof("CHAR_CATEGORY_ENCLOSING_MARK") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_ENCLOSING_MARK_name, &const_CHAR_CATEGORY_ENCLOSING_MARK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_ENCLOSING_MARK_name); + zend_string_release_ex(const_CHAR_CATEGORY_ENCLOSING_MARK_name, true); zval const_CHAR_CATEGORY_COMBINING_SPACING_MARK_value; ZVAL_LONG(&const_CHAR_CATEGORY_COMBINING_SPACING_MARK_value, U_COMBINING_SPACING_MARK); - zend_string *const_CHAR_CATEGORY_COMBINING_SPACING_MARK_name = zend_string_init_interned("CHAR_CATEGORY_COMBINING_SPACING_MARK", sizeof("CHAR_CATEGORY_COMBINING_SPACING_MARK") - 1, 1); + zend_string *const_CHAR_CATEGORY_COMBINING_SPACING_MARK_name = zend_string_init_interned("CHAR_CATEGORY_COMBINING_SPACING_MARK", sizeof("CHAR_CATEGORY_COMBINING_SPACING_MARK") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_COMBINING_SPACING_MARK_name, &const_CHAR_CATEGORY_COMBINING_SPACING_MARK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_COMBINING_SPACING_MARK_name); + zend_string_release_ex(const_CHAR_CATEGORY_COMBINING_SPACING_MARK_name, true); zval const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_value; ZVAL_LONG(&const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_value, U_DECIMAL_DIGIT_NUMBER); - zend_string *const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_name = zend_string_init_interned("CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER", sizeof("CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER") - 1, 1); + zend_string *const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_name = zend_string_init_interned("CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER", sizeof("CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_name, &const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_name); + zend_string_release_ex(const_CHAR_CATEGORY_DECIMAL_DIGIT_NUMBER_name, true); zval const_CHAR_CATEGORY_LETTER_NUMBER_value; ZVAL_LONG(&const_CHAR_CATEGORY_LETTER_NUMBER_value, U_LETTER_NUMBER); - zend_string *const_CHAR_CATEGORY_LETTER_NUMBER_name = zend_string_init_interned("CHAR_CATEGORY_LETTER_NUMBER", sizeof("CHAR_CATEGORY_LETTER_NUMBER") - 1, 1); + zend_string *const_CHAR_CATEGORY_LETTER_NUMBER_name = zend_string_init_interned("CHAR_CATEGORY_LETTER_NUMBER", sizeof("CHAR_CATEGORY_LETTER_NUMBER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_LETTER_NUMBER_name, &const_CHAR_CATEGORY_LETTER_NUMBER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_LETTER_NUMBER_name); + zend_string_release_ex(const_CHAR_CATEGORY_LETTER_NUMBER_name, true); zval const_CHAR_CATEGORY_OTHER_NUMBER_value; ZVAL_LONG(&const_CHAR_CATEGORY_OTHER_NUMBER_value, U_OTHER_NUMBER); - zend_string *const_CHAR_CATEGORY_OTHER_NUMBER_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_NUMBER", sizeof("CHAR_CATEGORY_OTHER_NUMBER") - 1, 1); + zend_string *const_CHAR_CATEGORY_OTHER_NUMBER_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_NUMBER", sizeof("CHAR_CATEGORY_OTHER_NUMBER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_OTHER_NUMBER_name, &const_CHAR_CATEGORY_OTHER_NUMBER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_OTHER_NUMBER_name); + zend_string_release_ex(const_CHAR_CATEGORY_OTHER_NUMBER_name, true); zval const_CHAR_CATEGORY_SPACE_SEPARATOR_value; ZVAL_LONG(&const_CHAR_CATEGORY_SPACE_SEPARATOR_value, U_SPACE_SEPARATOR); - zend_string *const_CHAR_CATEGORY_SPACE_SEPARATOR_name = zend_string_init_interned("CHAR_CATEGORY_SPACE_SEPARATOR", sizeof("CHAR_CATEGORY_SPACE_SEPARATOR") - 1, 1); + zend_string *const_CHAR_CATEGORY_SPACE_SEPARATOR_name = zend_string_init_interned("CHAR_CATEGORY_SPACE_SEPARATOR", sizeof("CHAR_CATEGORY_SPACE_SEPARATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_SPACE_SEPARATOR_name, &const_CHAR_CATEGORY_SPACE_SEPARATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_SPACE_SEPARATOR_name); + zend_string_release_ex(const_CHAR_CATEGORY_SPACE_SEPARATOR_name, true); zval const_CHAR_CATEGORY_LINE_SEPARATOR_value; ZVAL_LONG(&const_CHAR_CATEGORY_LINE_SEPARATOR_value, U_LINE_SEPARATOR); - zend_string *const_CHAR_CATEGORY_LINE_SEPARATOR_name = zend_string_init_interned("CHAR_CATEGORY_LINE_SEPARATOR", sizeof("CHAR_CATEGORY_LINE_SEPARATOR") - 1, 1); + zend_string *const_CHAR_CATEGORY_LINE_SEPARATOR_name = zend_string_init_interned("CHAR_CATEGORY_LINE_SEPARATOR", sizeof("CHAR_CATEGORY_LINE_SEPARATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_LINE_SEPARATOR_name, &const_CHAR_CATEGORY_LINE_SEPARATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_LINE_SEPARATOR_name); + zend_string_release_ex(const_CHAR_CATEGORY_LINE_SEPARATOR_name, true); zval const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_value; ZVAL_LONG(&const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_value, U_PARAGRAPH_SEPARATOR); - zend_string *const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_name = zend_string_init_interned("CHAR_CATEGORY_PARAGRAPH_SEPARATOR", sizeof("CHAR_CATEGORY_PARAGRAPH_SEPARATOR") - 1, 1); + zend_string *const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_name = zend_string_init_interned("CHAR_CATEGORY_PARAGRAPH_SEPARATOR", sizeof("CHAR_CATEGORY_PARAGRAPH_SEPARATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_name, &const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_name); + zend_string_release_ex(const_CHAR_CATEGORY_PARAGRAPH_SEPARATOR_name, true); zval const_CHAR_CATEGORY_CONTROL_CHAR_value; ZVAL_LONG(&const_CHAR_CATEGORY_CONTROL_CHAR_value, U_CONTROL_CHAR); - zend_string *const_CHAR_CATEGORY_CONTROL_CHAR_name = zend_string_init_interned("CHAR_CATEGORY_CONTROL_CHAR", sizeof("CHAR_CATEGORY_CONTROL_CHAR") - 1, 1); + zend_string *const_CHAR_CATEGORY_CONTROL_CHAR_name = zend_string_init_interned("CHAR_CATEGORY_CONTROL_CHAR", sizeof("CHAR_CATEGORY_CONTROL_CHAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_CONTROL_CHAR_name, &const_CHAR_CATEGORY_CONTROL_CHAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_CONTROL_CHAR_name); + zend_string_release_ex(const_CHAR_CATEGORY_CONTROL_CHAR_name, true); zval const_CHAR_CATEGORY_FORMAT_CHAR_value; ZVAL_LONG(&const_CHAR_CATEGORY_FORMAT_CHAR_value, U_FORMAT_CHAR); - zend_string *const_CHAR_CATEGORY_FORMAT_CHAR_name = zend_string_init_interned("CHAR_CATEGORY_FORMAT_CHAR", sizeof("CHAR_CATEGORY_FORMAT_CHAR") - 1, 1); + zend_string *const_CHAR_CATEGORY_FORMAT_CHAR_name = zend_string_init_interned("CHAR_CATEGORY_FORMAT_CHAR", sizeof("CHAR_CATEGORY_FORMAT_CHAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_FORMAT_CHAR_name, &const_CHAR_CATEGORY_FORMAT_CHAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_FORMAT_CHAR_name); + zend_string_release_ex(const_CHAR_CATEGORY_FORMAT_CHAR_name, true); zval const_CHAR_CATEGORY_PRIVATE_USE_CHAR_value; ZVAL_LONG(&const_CHAR_CATEGORY_PRIVATE_USE_CHAR_value, U_PRIVATE_USE_CHAR); - zend_string *const_CHAR_CATEGORY_PRIVATE_USE_CHAR_name = zend_string_init_interned("CHAR_CATEGORY_PRIVATE_USE_CHAR", sizeof("CHAR_CATEGORY_PRIVATE_USE_CHAR") - 1, 1); + zend_string *const_CHAR_CATEGORY_PRIVATE_USE_CHAR_name = zend_string_init_interned("CHAR_CATEGORY_PRIVATE_USE_CHAR", sizeof("CHAR_CATEGORY_PRIVATE_USE_CHAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_PRIVATE_USE_CHAR_name, &const_CHAR_CATEGORY_PRIVATE_USE_CHAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_PRIVATE_USE_CHAR_name); + zend_string_release_ex(const_CHAR_CATEGORY_PRIVATE_USE_CHAR_name, true); zval const_CHAR_CATEGORY_SURROGATE_value; ZVAL_LONG(&const_CHAR_CATEGORY_SURROGATE_value, U_SURROGATE); - zend_string *const_CHAR_CATEGORY_SURROGATE_name = zend_string_init_interned("CHAR_CATEGORY_SURROGATE", sizeof("CHAR_CATEGORY_SURROGATE") - 1, 1); + zend_string *const_CHAR_CATEGORY_SURROGATE_name = zend_string_init_interned("CHAR_CATEGORY_SURROGATE", sizeof("CHAR_CATEGORY_SURROGATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_SURROGATE_name, &const_CHAR_CATEGORY_SURROGATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_SURROGATE_name); + zend_string_release_ex(const_CHAR_CATEGORY_SURROGATE_name, true); zval const_CHAR_CATEGORY_DASH_PUNCTUATION_value; ZVAL_LONG(&const_CHAR_CATEGORY_DASH_PUNCTUATION_value, U_DASH_PUNCTUATION); - zend_string *const_CHAR_CATEGORY_DASH_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_DASH_PUNCTUATION", sizeof("CHAR_CATEGORY_DASH_PUNCTUATION") - 1, 1); + zend_string *const_CHAR_CATEGORY_DASH_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_DASH_PUNCTUATION", sizeof("CHAR_CATEGORY_DASH_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_DASH_PUNCTUATION_name, &const_CHAR_CATEGORY_DASH_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_DASH_PUNCTUATION_name); + zend_string_release_ex(const_CHAR_CATEGORY_DASH_PUNCTUATION_name, true); zval const_CHAR_CATEGORY_START_PUNCTUATION_value; ZVAL_LONG(&const_CHAR_CATEGORY_START_PUNCTUATION_value, U_START_PUNCTUATION); - zend_string *const_CHAR_CATEGORY_START_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_START_PUNCTUATION", sizeof("CHAR_CATEGORY_START_PUNCTUATION") - 1, 1); + zend_string *const_CHAR_CATEGORY_START_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_START_PUNCTUATION", sizeof("CHAR_CATEGORY_START_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_START_PUNCTUATION_name, &const_CHAR_CATEGORY_START_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_START_PUNCTUATION_name); + zend_string_release_ex(const_CHAR_CATEGORY_START_PUNCTUATION_name, true); zval const_CHAR_CATEGORY_END_PUNCTUATION_value; ZVAL_LONG(&const_CHAR_CATEGORY_END_PUNCTUATION_value, U_END_PUNCTUATION); - zend_string *const_CHAR_CATEGORY_END_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_END_PUNCTUATION", sizeof("CHAR_CATEGORY_END_PUNCTUATION") - 1, 1); + zend_string *const_CHAR_CATEGORY_END_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_END_PUNCTUATION", sizeof("CHAR_CATEGORY_END_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_END_PUNCTUATION_name, &const_CHAR_CATEGORY_END_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_END_PUNCTUATION_name); + zend_string_release_ex(const_CHAR_CATEGORY_END_PUNCTUATION_name, true); zval const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_value; ZVAL_LONG(&const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_value, U_CONNECTOR_PUNCTUATION); - zend_string *const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_CONNECTOR_PUNCTUATION", sizeof("CHAR_CATEGORY_CONNECTOR_PUNCTUATION") - 1, 1); + zend_string *const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_CONNECTOR_PUNCTUATION", sizeof("CHAR_CATEGORY_CONNECTOR_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_name, &const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_name); + zend_string_release_ex(const_CHAR_CATEGORY_CONNECTOR_PUNCTUATION_name, true); zval const_CHAR_CATEGORY_OTHER_PUNCTUATION_value; ZVAL_LONG(&const_CHAR_CATEGORY_OTHER_PUNCTUATION_value, U_OTHER_PUNCTUATION); - zend_string *const_CHAR_CATEGORY_OTHER_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_PUNCTUATION", sizeof("CHAR_CATEGORY_OTHER_PUNCTUATION") - 1, 1); + zend_string *const_CHAR_CATEGORY_OTHER_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_PUNCTUATION", sizeof("CHAR_CATEGORY_OTHER_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_OTHER_PUNCTUATION_name, &const_CHAR_CATEGORY_OTHER_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_OTHER_PUNCTUATION_name); + zend_string_release_ex(const_CHAR_CATEGORY_OTHER_PUNCTUATION_name, true); zval const_CHAR_CATEGORY_MATH_SYMBOL_value; ZVAL_LONG(&const_CHAR_CATEGORY_MATH_SYMBOL_value, U_MATH_SYMBOL); - zend_string *const_CHAR_CATEGORY_MATH_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_MATH_SYMBOL", sizeof("CHAR_CATEGORY_MATH_SYMBOL") - 1, 1); + zend_string *const_CHAR_CATEGORY_MATH_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_MATH_SYMBOL", sizeof("CHAR_CATEGORY_MATH_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_MATH_SYMBOL_name, &const_CHAR_CATEGORY_MATH_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_MATH_SYMBOL_name); + zend_string_release_ex(const_CHAR_CATEGORY_MATH_SYMBOL_name, true); zval const_CHAR_CATEGORY_CURRENCY_SYMBOL_value; ZVAL_LONG(&const_CHAR_CATEGORY_CURRENCY_SYMBOL_value, U_CURRENCY_SYMBOL); - zend_string *const_CHAR_CATEGORY_CURRENCY_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_CURRENCY_SYMBOL", sizeof("CHAR_CATEGORY_CURRENCY_SYMBOL") - 1, 1); + zend_string *const_CHAR_CATEGORY_CURRENCY_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_CURRENCY_SYMBOL", sizeof("CHAR_CATEGORY_CURRENCY_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_CURRENCY_SYMBOL_name, &const_CHAR_CATEGORY_CURRENCY_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_CURRENCY_SYMBOL_name); + zend_string_release_ex(const_CHAR_CATEGORY_CURRENCY_SYMBOL_name, true); zval const_CHAR_CATEGORY_MODIFIER_SYMBOL_value; ZVAL_LONG(&const_CHAR_CATEGORY_MODIFIER_SYMBOL_value, U_MODIFIER_SYMBOL); - zend_string *const_CHAR_CATEGORY_MODIFIER_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_MODIFIER_SYMBOL", sizeof("CHAR_CATEGORY_MODIFIER_SYMBOL") - 1, 1); + zend_string *const_CHAR_CATEGORY_MODIFIER_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_MODIFIER_SYMBOL", sizeof("CHAR_CATEGORY_MODIFIER_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_MODIFIER_SYMBOL_name, &const_CHAR_CATEGORY_MODIFIER_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_MODIFIER_SYMBOL_name); + zend_string_release_ex(const_CHAR_CATEGORY_MODIFIER_SYMBOL_name, true); zval const_CHAR_CATEGORY_OTHER_SYMBOL_value; ZVAL_LONG(&const_CHAR_CATEGORY_OTHER_SYMBOL_value, U_OTHER_SYMBOL); - zend_string *const_CHAR_CATEGORY_OTHER_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_SYMBOL", sizeof("CHAR_CATEGORY_OTHER_SYMBOL") - 1, 1); + zend_string *const_CHAR_CATEGORY_OTHER_SYMBOL_name = zend_string_init_interned("CHAR_CATEGORY_OTHER_SYMBOL", sizeof("CHAR_CATEGORY_OTHER_SYMBOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_OTHER_SYMBOL_name, &const_CHAR_CATEGORY_OTHER_SYMBOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_OTHER_SYMBOL_name); + zend_string_release_ex(const_CHAR_CATEGORY_OTHER_SYMBOL_name, true); zval const_CHAR_CATEGORY_INITIAL_PUNCTUATION_value; ZVAL_LONG(&const_CHAR_CATEGORY_INITIAL_PUNCTUATION_value, U_INITIAL_PUNCTUATION); - zend_string *const_CHAR_CATEGORY_INITIAL_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_INITIAL_PUNCTUATION", sizeof("CHAR_CATEGORY_INITIAL_PUNCTUATION") - 1, 1); + zend_string *const_CHAR_CATEGORY_INITIAL_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_INITIAL_PUNCTUATION", sizeof("CHAR_CATEGORY_INITIAL_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_INITIAL_PUNCTUATION_name, &const_CHAR_CATEGORY_INITIAL_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_INITIAL_PUNCTUATION_name); + zend_string_release_ex(const_CHAR_CATEGORY_INITIAL_PUNCTUATION_name, true); zval const_CHAR_CATEGORY_FINAL_PUNCTUATION_value; ZVAL_LONG(&const_CHAR_CATEGORY_FINAL_PUNCTUATION_value, U_FINAL_PUNCTUATION); - zend_string *const_CHAR_CATEGORY_FINAL_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_FINAL_PUNCTUATION", sizeof("CHAR_CATEGORY_FINAL_PUNCTUATION") - 1, 1); + zend_string *const_CHAR_CATEGORY_FINAL_PUNCTUATION_name = zend_string_init_interned("CHAR_CATEGORY_FINAL_PUNCTUATION", sizeof("CHAR_CATEGORY_FINAL_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_FINAL_PUNCTUATION_name, &const_CHAR_CATEGORY_FINAL_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_FINAL_PUNCTUATION_name); + zend_string_release_ex(const_CHAR_CATEGORY_FINAL_PUNCTUATION_name, true); zval const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_value; ZVAL_LONG(&const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_value, U_CHAR_CATEGORY_COUNT); - zend_string *const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_name = zend_string_init_interned("CHAR_CATEGORY_CHAR_CATEGORY_COUNT", sizeof("CHAR_CATEGORY_CHAR_CATEGORY_COUNT") - 1, 1); + zend_string *const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_name = zend_string_init_interned("CHAR_CATEGORY_CHAR_CATEGORY_COUNT", sizeof("CHAR_CATEGORY_CHAR_CATEGORY_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_name, &const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_name); + zend_string_release_ex(const_CHAR_CATEGORY_CHAR_CATEGORY_COUNT_name, true); zval const_CHAR_DIRECTION_LEFT_TO_RIGHT_value; ZVAL_LONG(&const_CHAR_DIRECTION_LEFT_TO_RIGHT_value, U_LEFT_TO_RIGHT); - zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT") - 1, 1); + zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_LEFT_TO_RIGHT_name, &const_CHAR_DIRECTION_LEFT_TO_RIGHT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_LEFT_TO_RIGHT_name); + zend_string_release_ex(const_CHAR_DIRECTION_LEFT_TO_RIGHT_name, true); zval const_CHAR_DIRECTION_RIGHT_TO_LEFT_value; ZVAL_LONG(&const_CHAR_DIRECTION_RIGHT_TO_LEFT_value, U_RIGHT_TO_LEFT); - zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT") - 1, 1); + zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_RIGHT_TO_LEFT_name, &const_CHAR_DIRECTION_RIGHT_TO_LEFT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_RIGHT_TO_LEFT_name); + zend_string_release_ex(const_CHAR_DIRECTION_RIGHT_TO_LEFT_name, true); zval const_CHAR_DIRECTION_EUROPEAN_NUMBER_value; ZVAL_LONG(&const_CHAR_DIRECTION_EUROPEAN_NUMBER_value, U_EUROPEAN_NUMBER); - zend_string *const_CHAR_DIRECTION_EUROPEAN_NUMBER_name = zend_string_init_interned("CHAR_DIRECTION_EUROPEAN_NUMBER", sizeof("CHAR_DIRECTION_EUROPEAN_NUMBER") - 1, 1); + zend_string *const_CHAR_DIRECTION_EUROPEAN_NUMBER_name = zend_string_init_interned("CHAR_DIRECTION_EUROPEAN_NUMBER", sizeof("CHAR_DIRECTION_EUROPEAN_NUMBER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_EUROPEAN_NUMBER_name, &const_CHAR_DIRECTION_EUROPEAN_NUMBER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_EUROPEAN_NUMBER_name); + zend_string_release_ex(const_CHAR_DIRECTION_EUROPEAN_NUMBER_name, true); zval const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_value; ZVAL_LONG(&const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_value, U_EUROPEAN_NUMBER_SEPARATOR); - zend_string *const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR", sizeof("CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR") - 1, 1); + zend_string *const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR", sizeof("CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_name, &const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_name); + zend_string_release_ex(const_CHAR_DIRECTION_EUROPEAN_NUMBER_SEPARATOR_name, true); zval const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_value; ZVAL_LONG(&const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_value, U_EUROPEAN_NUMBER_TERMINATOR); - zend_string *const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_name = zend_string_init_interned("CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR", sizeof("CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR") - 1, 1); + zend_string *const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_name = zend_string_init_interned("CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR", sizeof("CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_name, &const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_name); + zend_string_release_ex(const_CHAR_DIRECTION_EUROPEAN_NUMBER_TERMINATOR_name, true); zval const_CHAR_DIRECTION_ARABIC_NUMBER_value; ZVAL_LONG(&const_CHAR_DIRECTION_ARABIC_NUMBER_value, U_ARABIC_NUMBER); - zend_string *const_CHAR_DIRECTION_ARABIC_NUMBER_name = zend_string_init_interned("CHAR_DIRECTION_ARABIC_NUMBER", sizeof("CHAR_DIRECTION_ARABIC_NUMBER") - 1, 1); + zend_string *const_CHAR_DIRECTION_ARABIC_NUMBER_name = zend_string_init_interned("CHAR_DIRECTION_ARABIC_NUMBER", sizeof("CHAR_DIRECTION_ARABIC_NUMBER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_ARABIC_NUMBER_name, &const_CHAR_DIRECTION_ARABIC_NUMBER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_ARABIC_NUMBER_name); + zend_string_release_ex(const_CHAR_DIRECTION_ARABIC_NUMBER_name, true); zval const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_value; ZVAL_LONG(&const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_value, U_COMMON_NUMBER_SEPARATOR); - zend_string *const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR", sizeof("CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR") - 1, 1); + zend_string *const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR", sizeof("CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_name, &const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_name); + zend_string_release_ex(const_CHAR_DIRECTION_COMMON_NUMBER_SEPARATOR_name, true); zval const_CHAR_DIRECTION_BLOCK_SEPARATOR_value; ZVAL_LONG(&const_CHAR_DIRECTION_BLOCK_SEPARATOR_value, U_BLOCK_SEPARATOR); - zend_string *const_CHAR_DIRECTION_BLOCK_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_BLOCK_SEPARATOR", sizeof("CHAR_DIRECTION_BLOCK_SEPARATOR") - 1, 1); + zend_string *const_CHAR_DIRECTION_BLOCK_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_BLOCK_SEPARATOR", sizeof("CHAR_DIRECTION_BLOCK_SEPARATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_BLOCK_SEPARATOR_name, &const_CHAR_DIRECTION_BLOCK_SEPARATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_BLOCK_SEPARATOR_name); + zend_string_release_ex(const_CHAR_DIRECTION_BLOCK_SEPARATOR_name, true); zval const_CHAR_DIRECTION_SEGMENT_SEPARATOR_value; ZVAL_LONG(&const_CHAR_DIRECTION_SEGMENT_SEPARATOR_value, U_SEGMENT_SEPARATOR); - zend_string *const_CHAR_DIRECTION_SEGMENT_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_SEGMENT_SEPARATOR", sizeof("CHAR_DIRECTION_SEGMENT_SEPARATOR") - 1, 1); + zend_string *const_CHAR_DIRECTION_SEGMENT_SEPARATOR_name = zend_string_init_interned("CHAR_DIRECTION_SEGMENT_SEPARATOR", sizeof("CHAR_DIRECTION_SEGMENT_SEPARATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_SEGMENT_SEPARATOR_name, &const_CHAR_DIRECTION_SEGMENT_SEPARATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_SEGMENT_SEPARATOR_name); + zend_string_release_ex(const_CHAR_DIRECTION_SEGMENT_SEPARATOR_name, true); zval const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_value; ZVAL_LONG(&const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_value, U_WHITE_SPACE_NEUTRAL); - zend_string *const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_name = zend_string_init_interned("CHAR_DIRECTION_WHITE_SPACE_NEUTRAL", sizeof("CHAR_DIRECTION_WHITE_SPACE_NEUTRAL") - 1, 1); + zend_string *const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_name = zend_string_init_interned("CHAR_DIRECTION_WHITE_SPACE_NEUTRAL", sizeof("CHAR_DIRECTION_WHITE_SPACE_NEUTRAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_name, &const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_name); + zend_string_release_ex(const_CHAR_DIRECTION_WHITE_SPACE_NEUTRAL_name, true); zval const_CHAR_DIRECTION_OTHER_NEUTRAL_value; ZVAL_LONG(&const_CHAR_DIRECTION_OTHER_NEUTRAL_value, U_OTHER_NEUTRAL); - zend_string *const_CHAR_DIRECTION_OTHER_NEUTRAL_name = zend_string_init_interned("CHAR_DIRECTION_OTHER_NEUTRAL", sizeof("CHAR_DIRECTION_OTHER_NEUTRAL") - 1, 1); + zend_string *const_CHAR_DIRECTION_OTHER_NEUTRAL_name = zend_string_init_interned("CHAR_DIRECTION_OTHER_NEUTRAL", sizeof("CHAR_DIRECTION_OTHER_NEUTRAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_OTHER_NEUTRAL_name, &const_CHAR_DIRECTION_OTHER_NEUTRAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_OTHER_NEUTRAL_name); + zend_string_release_ex(const_CHAR_DIRECTION_OTHER_NEUTRAL_name, true); zval const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_value; ZVAL_LONG(&const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_value, U_LEFT_TO_RIGHT_EMBEDDING); - zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING") - 1, 1); + zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_name, &const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_name); + zend_string_release_ex(const_CHAR_DIRECTION_LEFT_TO_RIGHT_EMBEDDING_name, true); zval const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_value; ZVAL_LONG(&const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_value, U_LEFT_TO_RIGHT_OVERRIDE); - zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE") - 1, 1); + zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_name, &const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_name); + zend_string_release_ex(const_CHAR_DIRECTION_LEFT_TO_RIGHT_OVERRIDE_name, true); zval const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_value; ZVAL_LONG(&const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_value, U_RIGHT_TO_LEFT_ARABIC); - zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC") - 1, 1); + zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_name, &const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_name); + zend_string_release_ex(const_CHAR_DIRECTION_RIGHT_TO_LEFT_ARABIC_name, true); zval const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_value; ZVAL_LONG(&const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_value, U_RIGHT_TO_LEFT_EMBEDDING); - zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING") - 1, 1); + zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_name, &const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_name); + zend_string_release_ex(const_CHAR_DIRECTION_RIGHT_TO_LEFT_EMBEDDING_name, true); zval const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_value; ZVAL_LONG(&const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_value, U_RIGHT_TO_LEFT_OVERRIDE); - zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE") - 1, 1); + zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_name, &const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_name); + zend_string_release_ex(const_CHAR_DIRECTION_RIGHT_TO_LEFT_OVERRIDE_name, true); zval const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_value; ZVAL_LONG(&const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_value, U_POP_DIRECTIONAL_FORMAT); - zend_string *const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_name = zend_string_init_interned("CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT", sizeof("CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT") - 1, 1); + zend_string *const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_name = zend_string_init_interned("CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT", sizeof("CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_name, &const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_name); + zend_string_release_ex(const_CHAR_DIRECTION_POP_DIRECTIONAL_FORMAT_name, true); zval const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_value; ZVAL_LONG(&const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_value, U_DIR_NON_SPACING_MARK); - zend_string *const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_name = zend_string_init_interned("CHAR_DIRECTION_DIR_NON_SPACING_MARK", sizeof("CHAR_DIRECTION_DIR_NON_SPACING_MARK") - 1, 1); + zend_string *const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_name = zend_string_init_interned("CHAR_DIRECTION_DIR_NON_SPACING_MARK", sizeof("CHAR_DIRECTION_DIR_NON_SPACING_MARK") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_name, &const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_name); + zend_string_release_ex(const_CHAR_DIRECTION_DIR_NON_SPACING_MARK_name, true); zval const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_value; ZVAL_LONG(&const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_value, U_BOUNDARY_NEUTRAL); - zend_string *const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_name = zend_string_init_interned("CHAR_DIRECTION_BOUNDARY_NEUTRAL", sizeof("CHAR_DIRECTION_BOUNDARY_NEUTRAL") - 1, 1); + zend_string *const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_name = zend_string_init_interned("CHAR_DIRECTION_BOUNDARY_NEUTRAL", sizeof("CHAR_DIRECTION_BOUNDARY_NEUTRAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_name, &const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_name); + zend_string_release_ex(const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_name, true); zval const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_value; ZVAL_LONG(&const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_value, U_FIRST_STRONG_ISOLATE); - zend_string *const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_FIRST_STRONG_ISOLATE", sizeof("CHAR_DIRECTION_FIRST_STRONG_ISOLATE") - 1, 1); + zend_string *const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_FIRST_STRONG_ISOLATE", sizeof("CHAR_DIRECTION_FIRST_STRONG_ISOLATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_name, &const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_name); + zend_string_release_ex(const_CHAR_DIRECTION_FIRST_STRONG_ISOLATE_name, true); zval const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_value; ZVAL_LONG(&const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_value, U_LEFT_TO_RIGHT_ISOLATE); - zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE") - 1, 1); + zend_string *const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE", sizeof("CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_name, &const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_name); + zend_string_release_ex(const_CHAR_DIRECTION_LEFT_TO_RIGHT_ISOLATE_name, true); zval const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_value; ZVAL_LONG(&const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_value, U_RIGHT_TO_LEFT_ISOLATE); - zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE") - 1, 1); + zend_string *const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE", sizeof("CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_name, &const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_name); + zend_string_release_ex(const_CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE_name, true); zval const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_value; ZVAL_LONG(&const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_value, U_POP_DIRECTIONAL_ISOLATE); - zend_string *const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE", sizeof("CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE") - 1, 1); + zend_string *const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_name = zend_string_init_interned("CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE", sizeof("CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_name, &const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_name); + zend_string_release_ex(const_CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE_name, true); zval const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_value; ZVAL_LONG(&const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_value, U_CHAR_DIRECTION_COUNT); - zend_string *const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_name = zend_string_init_interned("CHAR_DIRECTION_CHAR_DIRECTION_COUNT", sizeof("CHAR_DIRECTION_CHAR_DIRECTION_COUNT") - 1, 1); + zend_string *const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_name = zend_string_init_interned("CHAR_DIRECTION_CHAR_DIRECTION_COUNT", sizeof("CHAR_DIRECTION_CHAR_DIRECTION_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_name, &const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_name); + zend_string_release_ex(const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_name, true); zval const_BLOCK_CODE_NO_BLOCK_value; ZVAL_LONG(&const_BLOCK_CODE_NO_BLOCK_value, UBLOCK_NO_BLOCK); - zend_string *const_BLOCK_CODE_NO_BLOCK_name = zend_string_init_interned("BLOCK_CODE_NO_BLOCK", sizeof("BLOCK_CODE_NO_BLOCK") - 1, 1); + zend_string *const_BLOCK_CODE_NO_BLOCK_name = zend_string_init_interned("BLOCK_CODE_NO_BLOCK", sizeof("BLOCK_CODE_NO_BLOCK") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_NO_BLOCK_name, &const_BLOCK_CODE_NO_BLOCK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_NO_BLOCK_name); + zend_string_release_ex(const_BLOCK_CODE_NO_BLOCK_name, true); zval const_BLOCK_CODE_BASIC_LATIN_value; ZVAL_LONG(&const_BLOCK_CODE_BASIC_LATIN_value, UBLOCK_BASIC_LATIN); - zend_string *const_BLOCK_CODE_BASIC_LATIN_name = zend_string_init_interned("BLOCK_CODE_BASIC_LATIN", sizeof("BLOCK_CODE_BASIC_LATIN") - 1, 1); + zend_string *const_BLOCK_CODE_BASIC_LATIN_name = zend_string_init_interned("BLOCK_CODE_BASIC_LATIN", sizeof("BLOCK_CODE_BASIC_LATIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BASIC_LATIN_name, &const_BLOCK_CODE_BASIC_LATIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BASIC_LATIN_name); + zend_string_release_ex(const_BLOCK_CODE_BASIC_LATIN_name, true); zval const_BLOCK_CODE_LATIN_1_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_LATIN_1_SUPPLEMENT_value, UBLOCK_LATIN_1_SUPPLEMENT); - zend_string *const_BLOCK_CODE_LATIN_1_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_LATIN_1_SUPPLEMENT", sizeof("BLOCK_CODE_LATIN_1_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_LATIN_1_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_LATIN_1_SUPPLEMENT", sizeof("BLOCK_CODE_LATIN_1_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LATIN_1_SUPPLEMENT_name, &const_BLOCK_CODE_LATIN_1_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LATIN_1_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_LATIN_1_SUPPLEMENT_name, true); zval const_BLOCK_CODE_LATIN_EXTENDED_A_value; ZVAL_LONG(&const_BLOCK_CODE_LATIN_EXTENDED_A_value, UBLOCK_LATIN_EXTENDED_A); - zend_string *const_BLOCK_CODE_LATIN_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_A", sizeof("BLOCK_CODE_LATIN_EXTENDED_A") - 1, 1); + zend_string *const_BLOCK_CODE_LATIN_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_A", sizeof("BLOCK_CODE_LATIN_EXTENDED_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LATIN_EXTENDED_A_name, &const_BLOCK_CODE_LATIN_EXTENDED_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LATIN_EXTENDED_A_name); + zend_string_release_ex(const_BLOCK_CODE_LATIN_EXTENDED_A_name, true); zval const_BLOCK_CODE_LATIN_EXTENDED_B_value; ZVAL_LONG(&const_BLOCK_CODE_LATIN_EXTENDED_B_value, UBLOCK_LATIN_EXTENDED_B); - zend_string *const_BLOCK_CODE_LATIN_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_B", sizeof("BLOCK_CODE_LATIN_EXTENDED_B") - 1, 1); + zend_string *const_BLOCK_CODE_LATIN_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_B", sizeof("BLOCK_CODE_LATIN_EXTENDED_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LATIN_EXTENDED_B_name, &const_BLOCK_CODE_LATIN_EXTENDED_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LATIN_EXTENDED_B_name); + zend_string_release_ex(const_BLOCK_CODE_LATIN_EXTENDED_B_name, true); zval const_BLOCK_CODE_IPA_EXTENSIONS_value; ZVAL_LONG(&const_BLOCK_CODE_IPA_EXTENSIONS_value, UBLOCK_IPA_EXTENSIONS); - zend_string *const_BLOCK_CODE_IPA_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_IPA_EXTENSIONS", sizeof("BLOCK_CODE_IPA_EXTENSIONS") - 1, 1); + zend_string *const_BLOCK_CODE_IPA_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_IPA_EXTENSIONS", sizeof("BLOCK_CODE_IPA_EXTENSIONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_IPA_EXTENSIONS_name, &const_BLOCK_CODE_IPA_EXTENSIONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_IPA_EXTENSIONS_name); + zend_string_release_ex(const_BLOCK_CODE_IPA_EXTENSIONS_name, true); zval const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_value; ZVAL_LONG(&const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_value, UBLOCK_SPACING_MODIFIER_LETTERS); - zend_string *const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_name = zend_string_init_interned("BLOCK_CODE_SPACING_MODIFIER_LETTERS", sizeof("BLOCK_CODE_SPACING_MODIFIER_LETTERS") - 1, 1); + zend_string *const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_name = zend_string_init_interned("BLOCK_CODE_SPACING_MODIFIER_LETTERS", sizeof("BLOCK_CODE_SPACING_MODIFIER_LETTERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_name, &const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_name); + zend_string_release_ex(const_BLOCK_CODE_SPACING_MODIFIER_LETTERS_name, true); zval const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_value; ZVAL_LONG(&const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_value, UBLOCK_COMBINING_DIACRITICAL_MARKS); - zend_string *const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_name = zend_string_init_interned("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS", sizeof("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS") - 1, 1); + zend_string *const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_name = zend_string_init_interned("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS", sizeof("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_name, &const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_name); + zend_string_release_ex(const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_name, true); zval const_BLOCK_CODE_GREEK_value; ZVAL_LONG(&const_BLOCK_CODE_GREEK_value, UBLOCK_GREEK); - zend_string *const_BLOCK_CODE_GREEK_name = zend_string_init_interned("BLOCK_CODE_GREEK", sizeof("BLOCK_CODE_GREEK") - 1, 1); + zend_string *const_BLOCK_CODE_GREEK_name = zend_string_init_interned("BLOCK_CODE_GREEK", sizeof("BLOCK_CODE_GREEK") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GREEK_name, &const_BLOCK_CODE_GREEK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GREEK_name); + zend_string_release_ex(const_BLOCK_CODE_GREEK_name, true); zval const_BLOCK_CODE_CYRILLIC_value; ZVAL_LONG(&const_BLOCK_CODE_CYRILLIC_value, UBLOCK_CYRILLIC); - zend_string *const_BLOCK_CODE_CYRILLIC_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC", sizeof("BLOCK_CODE_CYRILLIC") - 1, 1); + zend_string *const_BLOCK_CODE_CYRILLIC_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC", sizeof("BLOCK_CODE_CYRILLIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CYRILLIC_name, &const_BLOCK_CODE_CYRILLIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CYRILLIC_name); + zend_string_release_ex(const_BLOCK_CODE_CYRILLIC_name, true); zval const_BLOCK_CODE_ARMENIAN_value; ZVAL_LONG(&const_BLOCK_CODE_ARMENIAN_value, UBLOCK_ARMENIAN); - zend_string *const_BLOCK_CODE_ARMENIAN_name = zend_string_init_interned("BLOCK_CODE_ARMENIAN", sizeof("BLOCK_CODE_ARMENIAN") - 1, 1); + zend_string *const_BLOCK_CODE_ARMENIAN_name = zend_string_init_interned("BLOCK_CODE_ARMENIAN", sizeof("BLOCK_CODE_ARMENIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARMENIAN_name, &const_BLOCK_CODE_ARMENIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARMENIAN_name); + zend_string_release_ex(const_BLOCK_CODE_ARMENIAN_name, true); zval const_BLOCK_CODE_HEBREW_value; ZVAL_LONG(&const_BLOCK_CODE_HEBREW_value, UBLOCK_HEBREW); - zend_string *const_BLOCK_CODE_HEBREW_name = zend_string_init_interned("BLOCK_CODE_HEBREW", sizeof("BLOCK_CODE_HEBREW") - 1, 1); + zend_string *const_BLOCK_CODE_HEBREW_name = zend_string_init_interned("BLOCK_CODE_HEBREW", sizeof("BLOCK_CODE_HEBREW") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HEBREW_name, &const_BLOCK_CODE_HEBREW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HEBREW_name); + zend_string_release_ex(const_BLOCK_CODE_HEBREW_name, true); zval const_BLOCK_CODE_ARABIC_value; ZVAL_LONG(&const_BLOCK_CODE_ARABIC_value, UBLOCK_ARABIC); - zend_string *const_BLOCK_CODE_ARABIC_name = zend_string_init_interned("BLOCK_CODE_ARABIC", sizeof("BLOCK_CODE_ARABIC") - 1, 1); + zend_string *const_BLOCK_CODE_ARABIC_name = zend_string_init_interned("BLOCK_CODE_ARABIC", sizeof("BLOCK_CODE_ARABIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARABIC_name, &const_BLOCK_CODE_ARABIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARABIC_name); + zend_string_release_ex(const_BLOCK_CODE_ARABIC_name, true); zval const_BLOCK_CODE_SYRIAC_value; ZVAL_LONG(&const_BLOCK_CODE_SYRIAC_value, UBLOCK_SYRIAC); - zend_string *const_BLOCK_CODE_SYRIAC_name = zend_string_init_interned("BLOCK_CODE_SYRIAC", sizeof("BLOCK_CODE_SYRIAC") - 1, 1); + zend_string *const_BLOCK_CODE_SYRIAC_name = zend_string_init_interned("BLOCK_CODE_SYRIAC", sizeof("BLOCK_CODE_SYRIAC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SYRIAC_name, &const_BLOCK_CODE_SYRIAC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SYRIAC_name); + zend_string_release_ex(const_BLOCK_CODE_SYRIAC_name, true); zval const_BLOCK_CODE_THAANA_value; ZVAL_LONG(&const_BLOCK_CODE_THAANA_value, UBLOCK_THAANA); - zend_string *const_BLOCK_CODE_THAANA_name = zend_string_init_interned("BLOCK_CODE_THAANA", sizeof("BLOCK_CODE_THAANA") - 1, 1); + zend_string *const_BLOCK_CODE_THAANA_name = zend_string_init_interned("BLOCK_CODE_THAANA", sizeof("BLOCK_CODE_THAANA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_THAANA_name, &const_BLOCK_CODE_THAANA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_THAANA_name); + zend_string_release_ex(const_BLOCK_CODE_THAANA_name, true); zval const_BLOCK_CODE_DEVANAGARI_value; ZVAL_LONG(&const_BLOCK_CODE_DEVANAGARI_value, UBLOCK_DEVANAGARI); - zend_string *const_BLOCK_CODE_DEVANAGARI_name = zend_string_init_interned("BLOCK_CODE_DEVANAGARI", sizeof("BLOCK_CODE_DEVANAGARI") - 1, 1); + zend_string *const_BLOCK_CODE_DEVANAGARI_name = zend_string_init_interned("BLOCK_CODE_DEVANAGARI", sizeof("BLOCK_CODE_DEVANAGARI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_DEVANAGARI_name, &const_BLOCK_CODE_DEVANAGARI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_DEVANAGARI_name); + zend_string_release_ex(const_BLOCK_CODE_DEVANAGARI_name, true); zval const_BLOCK_CODE_BENGALI_value; ZVAL_LONG(&const_BLOCK_CODE_BENGALI_value, UBLOCK_BENGALI); - zend_string *const_BLOCK_CODE_BENGALI_name = zend_string_init_interned("BLOCK_CODE_BENGALI", sizeof("BLOCK_CODE_BENGALI") - 1, 1); + zend_string *const_BLOCK_CODE_BENGALI_name = zend_string_init_interned("BLOCK_CODE_BENGALI", sizeof("BLOCK_CODE_BENGALI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BENGALI_name, &const_BLOCK_CODE_BENGALI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BENGALI_name); + zend_string_release_ex(const_BLOCK_CODE_BENGALI_name, true); zval const_BLOCK_CODE_GURMUKHI_value; ZVAL_LONG(&const_BLOCK_CODE_GURMUKHI_value, UBLOCK_GURMUKHI); - zend_string *const_BLOCK_CODE_GURMUKHI_name = zend_string_init_interned("BLOCK_CODE_GURMUKHI", sizeof("BLOCK_CODE_GURMUKHI") - 1, 1); + zend_string *const_BLOCK_CODE_GURMUKHI_name = zend_string_init_interned("BLOCK_CODE_GURMUKHI", sizeof("BLOCK_CODE_GURMUKHI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GURMUKHI_name, &const_BLOCK_CODE_GURMUKHI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GURMUKHI_name); + zend_string_release_ex(const_BLOCK_CODE_GURMUKHI_name, true); zval const_BLOCK_CODE_GUJARATI_value; ZVAL_LONG(&const_BLOCK_CODE_GUJARATI_value, UBLOCK_GUJARATI); - zend_string *const_BLOCK_CODE_GUJARATI_name = zend_string_init_interned("BLOCK_CODE_GUJARATI", sizeof("BLOCK_CODE_GUJARATI") - 1, 1); + zend_string *const_BLOCK_CODE_GUJARATI_name = zend_string_init_interned("BLOCK_CODE_GUJARATI", sizeof("BLOCK_CODE_GUJARATI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GUJARATI_name, &const_BLOCK_CODE_GUJARATI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GUJARATI_name); + zend_string_release_ex(const_BLOCK_CODE_GUJARATI_name, true); zval const_BLOCK_CODE_ORIYA_value; ZVAL_LONG(&const_BLOCK_CODE_ORIYA_value, UBLOCK_ORIYA); - zend_string *const_BLOCK_CODE_ORIYA_name = zend_string_init_interned("BLOCK_CODE_ORIYA", sizeof("BLOCK_CODE_ORIYA") - 1, 1); + zend_string *const_BLOCK_CODE_ORIYA_name = zend_string_init_interned("BLOCK_CODE_ORIYA", sizeof("BLOCK_CODE_ORIYA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ORIYA_name, &const_BLOCK_CODE_ORIYA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ORIYA_name); + zend_string_release_ex(const_BLOCK_CODE_ORIYA_name, true); zval const_BLOCK_CODE_TAMIL_value; ZVAL_LONG(&const_BLOCK_CODE_TAMIL_value, UBLOCK_TAMIL); - zend_string *const_BLOCK_CODE_TAMIL_name = zend_string_init_interned("BLOCK_CODE_TAMIL", sizeof("BLOCK_CODE_TAMIL") - 1, 1); + zend_string *const_BLOCK_CODE_TAMIL_name = zend_string_init_interned("BLOCK_CODE_TAMIL", sizeof("BLOCK_CODE_TAMIL") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAMIL_name, &const_BLOCK_CODE_TAMIL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAMIL_name); + zend_string_release_ex(const_BLOCK_CODE_TAMIL_name, true); zval const_BLOCK_CODE_TELUGU_value; ZVAL_LONG(&const_BLOCK_CODE_TELUGU_value, UBLOCK_TELUGU); - zend_string *const_BLOCK_CODE_TELUGU_name = zend_string_init_interned("BLOCK_CODE_TELUGU", sizeof("BLOCK_CODE_TELUGU") - 1, 1); + zend_string *const_BLOCK_CODE_TELUGU_name = zend_string_init_interned("BLOCK_CODE_TELUGU", sizeof("BLOCK_CODE_TELUGU") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TELUGU_name, &const_BLOCK_CODE_TELUGU_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TELUGU_name); + zend_string_release_ex(const_BLOCK_CODE_TELUGU_name, true); zval const_BLOCK_CODE_KANNADA_value; ZVAL_LONG(&const_BLOCK_CODE_KANNADA_value, UBLOCK_KANNADA); - zend_string *const_BLOCK_CODE_KANNADA_name = zend_string_init_interned("BLOCK_CODE_KANNADA", sizeof("BLOCK_CODE_KANNADA") - 1, 1); + zend_string *const_BLOCK_CODE_KANNADA_name = zend_string_init_interned("BLOCK_CODE_KANNADA", sizeof("BLOCK_CODE_KANNADA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KANNADA_name, &const_BLOCK_CODE_KANNADA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KANNADA_name); + zend_string_release_ex(const_BLOCK_CODE_KANNADA_name, true); zval const_BLOCK_CODE_MALAYALAM_value; ZVAL_LONG(&const_BLOCK_CODE_MALAYALAM_value, UBLOCK_MALAYALAM); - zend_string *const_BLOCK_CODE_MALAYALAM_name = zend_string_init_interned("BLOCK_CODE_MALAYALAM", sizeof("BLOCK_CODE_MALAYALAM") - 1, 1); + zend_string *const_BLOCK_CODE_MALAYALAM_name = zend_string_init_interned("BLOCK_CODE_MALAYALAM", sizeof("BLOCK_CODE_MALAYALAM") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MALAYALAM_name, &const_BLOCK_CODE_MALAYALAM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MALAYALAM_name); + zend_string_release_ex(const_BLOCK_CODE_MALAYALAM_name, true); zval const_BLOCK_CODE_SINHALA_value; ZVAL_LONG(&const_BLOCK_CODE_SINHALA_value, UBLOCK_SINHALA); - zend_string *const_BLOCK_CODE_SINHALA_name = zend_string_init_interned("BLOCK_CODE_SINHALA", sizeof("BLOCK_CODE_SINHALA") - 1, 1); + zend_string *const_BLOCK_CODE_SINHALA_name = zend_string_init_interned("BLOCK_CODE_SINHALA", sizeof("BLOCK_CODE_SINHALA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SINHALA_name, &const_BLOCK_CODE_SINHALA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SINHALA_name); + zend_string_release_ex(const_BLOCK_CODE_SINHALA_name, true); zval const_BLOCK_CODE_THAI_value; ZVAL_LONG(&const_BLOCK_CODE_THAI_value, UBLOCK_THAI); - zend_string *const_BLOCK_CODE_THAI_name = zend_string_init_interned("BLOCK_CODE_THAI", sizeof("BLOCK_CODE_THAI") - 1, 1); + zend_string *const_BLOCK_CODE_THAI_name = zend_string_init_interned("BLOCK_CODE_THAI", sizeof("BLOCK_CODE_THAI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_THAI_name, &const_BLOCK_CODE_THAI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_THAI_name); + zend_string_release_ex(const_BLOCK_CODE_THAI_name, true); zval const_BLOCK_CODE_LAO_value; ZVAL_LONG(&const_BLOCK_CODE_LAO_value, UBLOCK_LAO); - zend_string *const_BLOCK_CODE_LAO_name = zend_string_init_interned("BLOCK_CODE_LAO", sizeof("BLOCK_CODE_LAO") - 1, 1); + zend_string *const_BLOCK_CODE_LAO_name = zend_string_init_interned("BLOCK_CODE_LAO", sizeof("BLOCK_CODE_LAO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LAO_name, &const_BLOCK_CODE_LAO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LAO_name); + zend_string_release_ex(const_BLOCK_CODE_LAO_name, true); zval const_BLOCK_CODE_TIBETAN_value; ZVAL_LONG(&const_BLOCK_CODE_TIBETAN_value, UBLOCK_TIBETAN); - zend_string *const_BLOCK_CODE_TIBETAN_name = zend_string_init_interned("BLOCK_CODE_TIBETAN", sizeof("BLOCK_CODE_TIBETAN") - 1, 1); + zend_string *const_BLOCK_CODE_TIBETAN_name = zend_string_init_interned("BLOCK_CODE_TIBETAN", sizeof("BLOCK_CODE_TIBETAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TIBETAN_name, &const_BLOCK_CODE_TIBETAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TIBETAN_name); + zend_string_release_ex(const_BLOCK_CODE_TIBETAN_name, true); zval const_BLOCK_CODE_MYANMAR_value; ZVAL_LONG(&const_BLOCK_CODE_MYANMAR_value, UBLOCK_MYANMAR); - zend_string *const_BLOCK_CODE_MYANMAR_name = zend_string_init_interned("BLOCK_CODE_MYANMAR", sizeof("BLOCK_CODE_MYANMAR") - 1, 1); + zend_string *const_BLOCK_CODE_MYANMAR_name = zend_string_init_interned("BLOCK_CODE_MYANMAR", sizeof("BLOCK_CODE_MYANMAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MYANMAR_name, &const_BLOCK_CODE_MYANMAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MYANMAR_name); + zend_string_release_ex(const_BLOCK_CODE_MYANMAR_name, true); zval const_BLOCK_CODE_GEORGIAN_value; ZVAL_LONG(&const_BLOCK_CODE_GEORGIAN_value, UBLOCK_GEORGIAN); - zend_string *const_BLOCK_CODE_GEORGIAN_name = zend_string_init_interned("BLOCK_CODE_GEORGIAN", sizeof("BLOCK_CODE_GEORGIAN") - 1, 1); + zend_string *const_BLOCK_CODE_GEORGIAN_name = zend_string_init_interned("BLOCK_CODE_GEORGIAN", sizeof("BLOCK_CODE_GEORGIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GEORGIAN_name, &const_BLOCK_CODE_GEORGIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GEORGIAN_name); + zend_string_release_ex(const_BLOCK_CODE_GEORGIAN_name, true); zval const_BLOCK_CODE_HANGUL_JAMO_value; ZVAL_LONG(&const_BLOCK_CODE_HANGUL_JAMO_value, UBLOCK_HANGUL_JAMO); - zend_string *const_BLOCK_CODE_HANGUL_JAMO_name = zend_string_init_interned("BLOCK_CODE_HANGUL_JAMO", sizeof("BLOCK_CODE_HANGUL_JAMO") - 1, 1); + zend_string *const_BLOCK_CODE_HANGUL_JAMO_name = zend_string_init_interned("BLOCK_CODE_HANGUL_JAMO", sizeof("BLOCK_CODE_HANGUL_JAMO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HANGUL_JAMO_name, &const_BLOCK_CODE_HANGUL_JAMO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HANGUL_JAMO_name); + zend_string_release_ex(const_BLOCK_CODE_HANGUL_JAMO_name, true); zval const_BLOCK_CODE_ETHIOPIC_value; ZVAL_LONG(&const_BLOCK_CODE_ETHIOPIC_value, UBLOCK_ETHIOPIC); - zend_string *const_BLOCK_CODE_ETHIOPIC_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC", sizeof("BLOCK_CODE_ETHIOPIC") - 1, 1); + zend_string *const_BLOCK_CODE_ETHIOPIC_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC", sizeof("BLOCK_CODE_ETHIOPIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ETHIOPIC_name, &const_BLOCK_CODE_ETHIOPIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ETHIOPIC_name); + zend_string_release_ex(const_BLOCK_CODE_ETHIOPIC_name, true); zval const_BLOCK_CODE_CHEROKEE_value; ZVAL_LONG(&const_BLOCK_CODE_CHEROKEE_value, UBLOCK_CHEROKEE); - zend_string *const_BLOCK_CODE_CHEROKEE_name = zend_string_init_interned("BLOCK_CODE_CHEROKEE", sizeof("BLOCK_CODE_CHEROKEE") - 1, 1); + zend_string *const_BLOCK_CODE_CHEROKEE_name = zend_string_init_interned("BLOCK_CODE_CHEROKEE", sizeof("BLOCK_CODE_CHEROKEE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CHEROKEE_name, &const_BLOCK_CODE_CHEROKEE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CHEROKEE_name); + zend_string_release_ex(const_BLOCK_CODE_CHEROKEE_name, true); zval const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_value; ZVAL_LONG(&const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_value, UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS); - zend_string *const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_name = zend_string_init_interned("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS", sizeof("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS") - 1, 1); + zend_string *const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_name = zend_string_init_interned("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS", sizeof("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_name, &const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_name); + zend_string_release_ex(const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_name, true); zval const_BLOCK_CODE_OGHAM_value; ZVAL_LONG(&const_BLOCK_CODE_OGHAM_value, UBLOCK_OGHAM); - zend_string *const_BLOCK_CODE_OGHAM_name = zend_string_init_interned("BLOCK_CODE_OGHAM", sizeof("BLOCK_CODE_OGHAM") - 1, 1); + zend_string *const_BLOCK_CODE_OGHAM_name = zend_string_init_interned("BLOCK_CODE_OGHAM", sizeof("BLOCK_CODE_OGHAM") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OGHAM_name, &const_BLOCK_CODE_OGHAM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OGHAM_name); + zend_string_release_ex(const_BLOCK_CODE_OGHAM_name, true); zval const_BLOCK_CODE_RUNIC_value; ZVAL_LONG(&const_BLOCK_CODE_RUNIC_value, UBLOCK_RUNIC); - zend_string *const_BLOCK_CODE_RUNIC_name = zend_string_init_interned("BLOCK_CODE_RUNIC", sizeof("BLOCK_CODE_RUNIC") - 1, 1); + zend_string *const_BLOCK_CODE_RUNIC_name = zend_string_init_interned("BLOCK_CODE_RUNIC", sizeof("BLOCK_CODE_RUNIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_RUNIC_name, &const_BLOCK_CODE_RUNIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_RUNIC_name); + zend_string_release_ex(const_BLOCK_CODE_RUNIC_name, true); zval const_BLOCK_CODE_KHMER_value; ZVAL_LONG(&const_BLOCK_CODE_KHMER_value, UBLOCK_KHMER); - zend_string *const_BLOCK_CODE_KHMER_name = zend_string_init_interned("BLOCK_CODE_KHMER", sizeof("BLOCK_CODE_KHMER") - 1, 1); + zend_string *const_BLOCK_CODE_KHMER_name = zend_string_init_interned("BLOCK_CODE_KHMER", sizeof("BLOCK_CODE_KHMER") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KHMER_name, &const_BLOCK_CODE_KHMER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KHMER_name); + zend_string_release_ex(const_BLOCK_CODE_KHMER_name, true); zval const_BLOCK_CODE_MONGOLIAN_value; ZVAL_LONG(&const_BLOCK_CODE_MONGOLIAN_value, UBLOCK_MONGOLIAN); - zend_string *const_BLOCK_CODE_MONGOLIAN_name = zend_string_init_interned("BLOCK_CODE_MONGOLIAN", sizeof("BLOCK_CODE_MONGOLIAN") - 1, 1); + zend_string *const_BLOCK_CODE_MONGOLIAN_name = zend_string_init_interned("BLOCK_CODE_MONGOLIAN", sizeof("BLOCK_CODE_MONGOLIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MONGOLIAN_name, &const_BLOCK_CODE_MONGOLIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MONGOLIAN_name); + zend_string_release_ex(const_BLOCK_CODE_MONGOLIAN_name, true); zval const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_value; ZVAL_LONG(&const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_value, UBLOCK_LATIN_EXTENDED_ADDITIONAL); - zend_string *const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL", sizeof("BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL") - 1, 1); + zend_string *const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL", sizeof("BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_name, &const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_name); + zend_string_release_ex(const_BLOCK_CODE_LATIN_EXTENDED_ADDITIONAL_name, true); zval const_BLOCK_CODE_GREEK_EXTENDED_value; ZVAL_LONG(&const_BLOCK_CODE_GREEK_EXTENDED_value, UBLOCK_GREEK_EXTENDED); - zend_string *const_BLOCK_CODE_GREEK_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_GREEK_EXTENDED", sizeof("BLOCK_CODE_GREEK_EXTENDED") - 1, 1); + zend_string *const_BLOCK_CODE_GREEK_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_GREEK_EXTENDED", sizeof("BLOCK_CODE_GREEK_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GREEK_EXTENDED_name, &const_BLOCK_CODE_GREEK_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GREEK_EXTENDED_name); + zend_string_release_ex(const_BLOCK_CODE_GREEK_EXTENDED_name, true); zval const_BLOCK_CODE_GENERAL_PUNCTUATION_value; ZVAL_LONG(&const_BLOCK_CODE_GENERAL_PUNCTUATION_value, UBLOCK_GENERAL_PUNCTUATION); - zend_string *const_BLOCK_CODE_GENERAL_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_GENERAL_PUNCTUATION", sizeof("BLOCK_CODE_GENERAL_PUNCTUATION") - 1, 1); + zend_string *const_BLOCK_CODE_GENERAL_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_GENERAL_PUNCTUATION", sizeof("BLOCK_CODE_GENERAL_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GENERAL_PUNCTUATION_name, &const_BLOCK_CODE_GENERAL_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GENERAL_PUNCTUATION_name); + zend_string_release_ex(const_BLOCK_CODE_GENERAL_PUNCTUATION_name, true); zval const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_value; ZVAL_LONG(&const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_value, UBLOCK_SUPERSCRIPTS_AND_SUBSCRIPTS); - zend_string *const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_name = zend_string_init_interned("BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS", sizeof("BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS") - 1, 1); + zend_string *const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_name = zend_string_init_interned("BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS", sizeof("BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_name, &const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_name); + zend_string_release_ex(const_BLOCK_CODE_SUPERSCRIPTS_AND_SUBSCRIPTS_name, true); zval const_BLOCK_CODE_CURRENCY_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_CURRENCY_SYMBOLS_value, UBLOCK_CURRENCY_SYMBOLS); - zend_string *const_BLOCK_CODE_CURRENCY_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_CURRENCY_SYMBOLS", sizeof("BLOCK_CODE_CURRENCY_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_CURRENCY_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_CURRENCY_SYMBOLS", sizeof("BLOCK_CODE_CURRENCY_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CURRENCY_SYMBOLS_name, &const_BLOCK_CODE_CURRENCY_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CURRENCY_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_CURRENCY_SYMBOLS_name, true); zval const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_value, UBLOCK_COMBINING_MARKS_FOR_SYMBOLS); - zend_string *const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS", sizeof("BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS", sizeof("BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_name, &const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_COMBINING_MARKS_FOR_SYMBOLS_name, true); zval const_BLOCK_CODE_LETTERLIKE_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_LETTERLIKE_SYMBOLS_value, UBLOCK_LETTERLIKE_SYMBOLS); - zend_string *const_BLOCK_CODE_LETTERLIKE_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_LETTERLIKE_SYMBOLS", sizeof("BLOCK_CODE_LETTERLIKE_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_LETTERLIKE_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_LETTERLIKE_SYMBOLS", sizeof("BLOCK_CODE_LETTERLIKE_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LETTERLIKE_SYMBOLS_name, &const_BLOCK_CODE_LETTERLIKE_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LETTERLIKE_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_LETTERLIKE_SYMBOLS_name, true); zval const_BLOCK_CODE_NUMBER_FORMS_value; ZVAL_LONG(&const_BLOCK_CODE_NUMBER_FORMS_value, UBLOCK_NUMBER_FORMS); - zend_string *const_BLOCK_CODE_NUMBER_FORMS_name = zend_string_init_interned("BLOCK_CODE_NUMBER_FORMS", sizeof("BLOCK_CODE_NUMBER_FORMS") - 1, 1); + zend_string *const_BLOCK_CODE_NUMBER_FORMS_name = zend_string_init_interned("BLOCK_CODE_NUMBER_FORMS", sizeof("BLOCK_CODE_NUMBER_FORMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_NUMBER_FORMS_name, &const_BLOCK_CODE_NUMBER_FORMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_NUMBER_FORMS_name); + zend_string_release_ex(const_BLOCK_CODE_NUMBER_FORMS_name, true); zval const_BLOCK_CODE_ARROWS_value; ZVAL_LONG(&const_BLOCK_CODE_ARROWS_value, UBLOCK_ARROWS); - zend_string *const_BLOCK_CODE_ARROWS_name = zend_string_init_interned("BLOCK_CODE_ARROWS", sizeof("BLOCK_CODE_ARROWS") - 1, 1); + zend_string *const_BLOCK_CODE_ARROWS_name = zend_string_init_interned("BLOCK_CODE_ARROWS", sizeof("BLOCK_CODE_ARROWS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARROWS_name, &const_BLOCK_CODE_ARROWS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARROWS_name); + zend_string_release_ex(const_BLOCK_CODE_ARROWS_name, true); zval const_BLOCK_CODE_MATHEMATICAL_OPERATORS_value; ZVAL_LONG(&const_BLOCK_CODE_MATHEMATICAL_OPERATORS_value, UBLOCK_MATHEMATICAL_OPERATORS); - zend_string *const_BLOCK_CODE_MATHEMATICAL_OPERATORS_name = zend_string_init_interned("BLOCK_CODE_MATHEMATICAL_OPERATORS", sizeof("BLOCK_CODE_MATHEMATICAL_OPERATORS") - 1, 1); + zend_string *const_BLOCK_CODE_MATHEMATICAL_OPERATORS_name = zend_string_init_interned("BLOCK_CODE_MATHEMATICAL_OPERATORS", sizeof("BLOCK_CODE_MATHEMATICAL_OPERATORS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MATHEMATICAL_OPERATORS_name, &const_BLOCK_CODE_MATHEMATICAL_OPERATORS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MATHEMATICAL_OPERATORS_name); + zend_string_release_ex(const_BLOCK_CODE_MATHEMATICAL_OPERATORS_name, true); zval const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_value; ZVAL_LONG(&const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_value, UBLOCK_MISCELLANEOUS_TECHNICAL); - zend_string *const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_TECHNICAL", sizeof("BLOCK_CODE_MISCELLANEOUS_TECHNICAL") - 1, 1); + zend_string *const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_TECHNICAL", sizeof("BLOCK_CODE_MISCELLANEOUS_TECHNICAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_name, &const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_name); + zend_string_release_ex(const_BLOCK_CODE_MISCELLANEOUS_TECHNICAL_name, true); zval const_BLOCK_CODE_CONTROL_PICTURES_value; ZVAL_LONG(&const_BLOCK_CODE_CONTROL_PICTURES_value, UBLOCK_CONTROL_PICTURES); - zend_string *const_BLOCK_CODE_CONTROL_PICTURES_name = zend_string_init_interned("BLOCK_CODE_CONTROL_PICTURES", sizeof("BLOCK_CODE_CONTROL_PICTURES") - 1, 1); + zend_string *const_BLOCK_CODE_CONTROL_PICTURES_name = zend_string_init_interned("BLOCK_CODE_CONTROL_PICTURES", sizeof("BLOCK_CODE_CONTROL_PICTURES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CONTROL_PICTURES_name, &const_BLOCK_CODE_CONTROL_PICTURES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CONTROL_PICTURES_name); + zend_string_release_ex(const_BLOCK_CODE_CONTROL_PICTURES_name, true); zval const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_value; ZVAL_LONG(&const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_value, UBLOCK_OPTICAL_CHARACTER_RECOGNITION); - zend_string *const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_name = zend_string_init_interned("BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION", sizeof("BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION") - 1, 1); + zend_string *const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_name = zend_string_init_interned("BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION", sizeof("BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_name, &const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_name); + zend_string_release_ex(const_BLOCK_CODE_OPTICAL_CHARACTER_RECOGNITION_name, true); zval const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_value; ZVAL_LONG(&const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_value, UBLOCK_ENCLOSED_ALPHANUMERICS); - zend_string *const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_ALPHANUMERICS", sizeof("BLOCK_CODE_ENCLOSED_ALPHANUMERICS") - 1, 1); + zend_string *const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_ALPHANUMERICS", sizeof("BLOCK_CODE_ENCLOSED_ALPHANUMERICS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_name, &const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_name); + zend_string_release_ex(const_BLOCK_CODE_ENCLOSED_ALPHANUMERICS_name, true); zval const_BLOCK_CODE_BOX_DRAWING_value; ZVAL_LONG(&const_BLOCK_CODE_BOX_DRAWING_value, UBLOCK_BOX_DRAWING); - zend_string *const_BLOCK_CODE_BOX_DRAWING_name = zend_string_init_interned("BLOCK_CODE_BOX_DRAWING", sizeof("BLOCK_CODE_BOX_DRAWING") - 1, 1); + zend_string *const_BLOCK_CODE_BOX_DRAWING_name = zend_string_init_interned("BLOCK_CODE_BOX_DRAWING", sizeof("BLOCK_CODE_BOX_DRAWING") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BOX_DRAWING_name, &const_BLOCK_CODE_BOX_DRAWING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BOX_DRAWING_name); + zend_string_release_ex(const_BLOCK_CODE_BOX_DRAWING_name, true); zval const_BLOCK_CODE_BLOCK_ELEMENTS_value; ZVAL_LONG(&const_BLOCK_CODE_BLOCK_ELEMENTS_value, UBLOCK_BLOCK_ELEMENTS); - zend_string *const_BLOCK_CODE_BLOCK_ELEMENTS_name = zend_string_init_interned("BLOCK_CODE_BLOCK_ELEMENTS", sizeof("BLOCK_CODE_BLOCK_ELEMENTS") - 1, 1); + zend_string *const_BLOCK_CODE_BLOCK_ELEMENTS_name = zend_string_init_interned("BLOCK_CODE_BLOCK_ELEMENTS", sizeof("BLOCK_CODE_BLOCK_ELEMENTS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BLOCK_ELEMENTS_name, &const_BLOCK_CODE_BLOCK_ELEMENTS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BLOCK_ELEMENTS_name); + zend_string_release_ex(const_BLOCK_CODE_BLOCK_ELEMENTS_name, true); zval const_BLOCK_CODE_GEOMETRIC_SHAPES_value; ZVAL_LONG(&const_BLOCK_CODE_GEOMETRIC_SHAPES_value, UBLOCK_GEOMETRIC_SHAPES); - zend_string *const_BLOCK_CODE_GEOMETRIC_SHAPES_name = zend_string_init_interned("BLOCK_CODE_GEOMETRIC_SHAPES", sizeof("BLOCK_CODE_GEOMETRIC_SHAPES") - 1, 1); + zend_string *const_BLOCK_CODE_GEOMETRIC_SHAPES_name = zend_string_init_interned("BLOCK_CODE_GEOMETRIC_SHAPES", sizeof("BLOCK_CODE_GEOMETRIC_SHAPES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GEOMETRIC_SHAPES_name, &const_BLOCK_CODE_GEOMETRIC_SHAPES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GEOMETRIC_SHAPES_name); + zend_string_release_ex(const_BLOCK_CODE_GEOMETRIC_SHAPES_name, true); zval const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_value, UBLOCK_MISCELLANEOUS_SYMBOLS); - zend_string *const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_SYMBOLS", sizeof("BLOCK_CODE_MISCELLANEOUS_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_SYMBOLS", sizeof("BLOCK_CODE_MISCELLANEOUS_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_name, &const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_name, true); zval const_BLOCK_CODE_DINGBATS_value; ZVAL_LONG(&const_BLOCK_CODE_DINGBATS_value, UBLOCK_DINGBATS); - zend_string *const_BLOCK_CODE_DINGBATS_name = zend_string_init_interned("BLOCK_CODE_DINGBATS", sizeof("BLOCK_CODE_DINGBATS") - 1, 1); + zend_string *const_BLOCK_CODE_DINGBATS_name = zend_string_init_interned("BLOCK_CODE_DINGBATS", sizeof("BLOCK_CODE_DINGBATS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_DINGBATS_name, &const_BLOCK_CODE_DINGBATS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_DINGBATS_name); + zend_string_release_ex(const_BLOCK_CODE_DINGBATS_name, true); zval const_BLOCK_CODE_BRAILLE_PATTERNS_value; ZVAL_LONG(&const_BLOCK_CODE_BRAILLE_PATTERNS_value, UBLOCK_BRAILLE_PATTERNS); - zend_string *const_BLOCK_CODE_BRAILLE_PATTERNS_name = zend_string_init_interned("BLOCK_CODE_BRAILLE_PATTERNS", sizeof("BLOCK_CODE_BRAILLE_PATTERNS") - 1, 1); + zend_string *const_BLOCK_CODE_BRAILLE_PATTERNS_name = zend_string_init_interned("BLOCK_CODE_BRAILLE_PATTERNS", sizeof("BLOCK_CODE_BRAILLE_PATTERNS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BRAILLE_PATTERNS_name, &const_BLOCK_CODE_BRAILLE_PATTERNS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BRAILLE_PATTERNS_name); + zend_string_release_ex(const_BLOCK_CODE_BRAILLE_PATTERNS_name, true); zval const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_value, UBLOCK_CJK_RADICALS_SUPPLEMENT); - zend_string *const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_CJK_RADICALS_SUPPLEMENT", sizeof("BLOCK_CODE_CJK_RADICALS_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_CJK_RADICALS_SUPPLEMENT", sizeof("BLOCK_CODE_CJK_RADICALS_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_name, &const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_RADICALS_SUPPLEMENT_name, true); zval const_BLOCK_CODE_KANGXI_RADICALS_value; ZVAL_LONG(&const_BLOCK_CODE_KANGXI_RADICALS_value, UBLOCK_KANGXI_RADICALS); - zend_string *const_BLOCK_CODE_KANGXI_RADICALS_name = zend_string_init_interned("BLOCK_CODE_KANGXI_RADICALS", sizeof("BLOCK_CODE_KANGXI_RADICALS") - 1, 1); + zend_string *const_BLOCK_CODE_KANGXI_RADICALS_name = zend_string_init_interned("BLOCK_CODE_KANGXI_RADICALS", sizeof("BLOCK_CODE_KANGXI_RADICALS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KANGXI_RADICALS_name, &const_BLOCK_CODE_KANGXI_RADICALS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KANGXI_RADICALS_name); + zend_string_release_ex(const_BLOCK_CODE_KANGXI_RADICALS_name, true); zval const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_value; ZVAL_LONG(&const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_value, UBLOCK_IDEOGRAPHIC_DESCRIPTION_CHARACTERS); - zend_string *const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_name = zend_string_init_interned("BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS", sizeof("BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS") - 1, 1); + zend_string *const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_name = zend_string_init_interned("BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS", sizeof("BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_name, &const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_name); + zend_string_release_ex(const_BLOCK_CODE_IDEOGRAPHIC_DESCRIPTION_CHARACTERS_name, true); zval const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_value, UBLOCK_CJK_SYMBOLS_AND_PUNCTUATION); - zend_string *const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION", sizeof("BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION", sizeof("BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_name, &const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_SYMBOLS_AND_PUNCTUATION_name, true); zval const_BLOCK_CODE_HIRAGANA_value; ZVAL_LONG(&const_BLOCK_CODE_HIRAGANA_value, UBLOCK_HIRAGANA); - zend_string *const_BLOCK_CODE_HIRAGANA_name = zend_string_init_interned("BLOCK_CODE_HIRAGANA", sizeof("BLOCK_CODE_HIRAGANA") - 1, 1); + zend_string *const_BLOCK_CODE_HIRAGANA_name = zend_string_init_interned("BLOCK_CODE_HIRAGANA", sizeof("BLOCK_CODE_HIRAGANA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HIRAGANA_name, &const_BLOCK_CODE_HIRAGANA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HIRAGANA_name); + zend_string_release_ex(const_BLOCK_CODE_HIRAGANA_name, true); zval const_BLOCK_CODE_KATAKANA_value; ZVAL_LONG(&const_BLOCK_CODE_KATAKANA_value, UBLOCK_KATAKANA); - zend_string *const_BLOCK_CODE_KATAKANA_name = zend_string_init_interned("BLOCK_CODE_KATAKANA", sizeof("BLOCK_CODE_KATAKANA") - 1, 1); + zend_string *const_BLOCK_CODE_KATAKANA_name = zend_string_init_interned("BLOCK_CODE_KATAKANA", sizeof("BLOCK_CODE_KATAKANA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KATAKANA_name, &const_BLOCK_CODE_KATAKANA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KATAKANA_name); + zend_string_release_ex(const_BLOCK_CODE_KATAKANA_name, true); zval const_BLOCK_CODE_BOPOMOFO_value; ZVAL_LONG(&const_BLOCK_CODE_BOPOMOFO_value, UBLOCK_BOPOMOFO); - zend_string *const_BLOCK_CODE_BOPOMOFO_name = zend_string_init_interned("BLOCK_CODE_BOPOMOFO", sizeof("BLOCK_CODE_BOPOMOFO") - 1, 1); + zend_string *const_BLOCK_CODE_BOPOMOFO_name = zend_string_init_interned("BLOCK_CODE_BOPOMOFO", sizeof("BLOCK_CODE_BOPOMOFO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BOPOMOFO_name, &const_BLOCK_CODE_BOPOMOFO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BOPOMOFO_name); + zend_string_release_ex(const_BLOCK_CODE_BOPOMOFO_name, true); zval const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_value; ZVAL_LONG(&const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_value, UBLOCK_HANGUL_COMPATIBILITY_JAMO); - zend_string *const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_name = zend_string_init_interned("BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO", sizeof("BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO") - 1, 1); + zend_string *const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_name = zend_string_init_interned("BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO", sizeof("BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_name, &const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_name); + zend_string_release_ex(const_BLOCK_CODE_HANGUL_COMPATIBILITY_JAMO_name, true); zval const_BLOCK_CODE_KANBUN_value; ZVAL_LONG(&const_BLOCK_CODE_KANBUN_value, UBLOCK_KANBUN); - zend_string *const_BLOCK_CODE_KANBUN_name = zend_string_init_interned("BLOCK_CODE_KANBUN", sizeof("BLOCK_CODE_KANBUN") - 1, 1); + zend_string *const_BLOCK_CODE_KANBUN_name = zend_string_init_interned("BLOCK_CODE_KANBUN", sizeof("BLOCK_CODE_KANBUN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KANBUN_name, &const_BLOCK_CODE_KANBUN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KANBUN_name); + zend_string_release_ex(const_BLOCK_CODE_KANBUN_name, true); zval const_BLOCK_CODE_BOPOMOFO_EXTENDED_value; ZVAL_LONG(&const_BLOCK_CODE_BOPOMOFO_EXTENDED_value, UBLOCK_BOPOMOFO_EXTENDED); - zend_string *const_BLOCK_CODE_BOPOMOFO_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_BOPOMOFO_EXTENDED", sizeof("BLOCK_CODE_BOPOMOFO_EXTENDED") - 1, 1); + zend_string *const_BLOCK_CODE_BOPOMOFO_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_BOPOMOFO_EXTENDED", sizeof("BLOCK_CODE_BOPOMOFO_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BOPOMOFO_EXTENDED_name, &const_BLOCK_CODE_BOPOMOFO_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BOPOMOFO_EXTENDED_name); + zend_string_release_ex(const_BLOCK_CODE_BOPOMOFO_EXTENDED_name, true); zval const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_value; ZVAL_LONG(&const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_value, UBLOCK_ENCLOSED_CJK_LETTERS_AND_MONTHS); - zend_string *const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS", sizeof("BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS") - 1, 1); + zend_string *const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS", sizeof("BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_name, &const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_name); + zend_string_release_ex(const_BLOCK_CODE_ENCLOSED_CJK_LETTERS_AND_MONTHS_name, true); zval const_BLOCK_CODE_CJK_COMPATIBILITY_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_COMPATIBILITY_value, UBLOCK_CJK_COMPATIBILITY); - zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY", sizeof("BLOCK_CODE_CJK_COMPATIBILITY") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY", sizeof("BLOCK_CODE_CJK_COMPATIBILITY") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_COMPATIBILITY_name, &const_BLOCK_CODE_CJK_COMPATIBILITY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_COMPATIBILITY_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_COMPATIBILITY_name, true); zval const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_value, UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A); - zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_name, &const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A_name, true); zval const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_value, UBLOCK_CJK_UNIFIED_IDEOGRAPHS); - zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_name, &const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_name, true); zval const_BLOCK_CODE_YI_SYLLABLES_value; ZVAL_LONG(&const_BLOCK_CODE_YI_SYLLABLES_value, UBLOCK_YI_SYLLABLES); - zend_string *const_BLOCK_CODE_YI_SYLLABLES_name = zend_string_init_interned("BLOCK_CODE_YI_SYLLABLES", sizeof("BLOCK_CODE_YI_SYLLABLES") - 1, 1); + zend_string *const_BLOCK_CODE_YI_SYLLABLES_name = zend_string_init_interned("BLOCK_CODE_YI_SYLLABLES", sizeof("BLOCK_CODE_YI_SYLLABLES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_YI_SYLLABLES_name, &const_BLOCK_CODE_YI_SYLLABLES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_YI_SYLLABLES_name); + zend_string_release_ex(const_BLOCK_CODE_YI_SYLLABLES_name, true); zval const_BLOCK_CODE_YI_RADICALS_value; ZVAL_LONG(&const_BLOCK_CODE_YI_RADICALS_value, UBLOCK_YI_RADICALS); - zend_string *const_BLOCK_CODE_YI_RADICALS_name = zend_string_init_interned("BLOCK_CODE_YI_RADICALS", sizeof("BLOCK_CODE_YI_RADICALS") - 1, 1); + zend_string *const_BLOCK_CODE_YI_RADICALS_name = zend_string_init_interned("BLOCK_CODE_YI_RADICALS", sizeof("BLOCK_CODE_YI_RADICALS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_YI_RADICALS_name, &const_BLOCK_CODE_YI_RADICALS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_YI_RADICALS_name); + zend_string_release_ex(const_BLOCK_CODE_YI_RADICALS_name, true); zval const_BLOCK_CODE_HANGUL_SYLLABLES_value; ZVAL_LONG(&const_BLOCK_CODE_HANGUL_SYLLABLES_value, UBLOCK_HANGUL_SYLLABLES); - zend_string *const_BLOCK_CODE_HANGUL_SYLLABLES_name = zend_string_init_interned("BLOCK_CODE_HANGUL_SYLLABLES", sizeof("BLOCK_CODE_HANGUL_SYLLABLES") - 1, 1); + zend_string *const_BLOCK_CODE_HANGUL_SYLLABLES_name = zend_string_init_interned("BLOCK_CODE_HANGUL_SYLLABLES", sizeof("BLOCK_CODE_HANGUL_SYLLABLES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HANGUL_SYLLABLES_name, &const_BLOCK_CODE_HANGUL_SYLLABLES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HANGUL_SYLLABLES_name); + zend_string_release_ex(const_BLOCK_CODE_HANGUL_SYLLABLES_name, true); zval const_BLOCK_CODE_HIGH_SURROGATES_value; ZVAL_LONG(&const_BLOCK_CODE_HIGH_SURROGATES_value, UBLOCK_HIGH_SURROGATES); - zend_string *const_BLOCK_CODE_HIGH_SURROGATES_name = zend_string_init_interned("BLOCK_CODE_HIGH_SURROGATES", sizeof("BLOCK_CODE_HIGH_SURROGATES") - 1, 1); + zend_string *const_BLOCK_CODE_HIGH_SURROGATES_name = zend_string_init_interned("BLOCK_CODE_HIGH_SURROGATES", sizeof("BLOCK_CODE_HIGH_SURROGATES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HIGH_SURROGATES_name, &const_BLOCK_CODE_HIGH_SURROGATES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HIGH_SURROGATES_name); + zend_string_release_ex(const_BLOCK_CODE_HIGH_SURROGATES_name, true); zval const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_value; ZVAL_LONG(&const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_value, UBLOCK_HIGH_PRIVATE_USE_SURROGATES); - zend_string *const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_name = zend_string_init_interned("BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES", sizeof("BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES") - 1, 1); + zend_string *const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_name = zend_string_init_interned("BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES", sizeof("BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_name, &const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_name); + zend_string_release_ex(const_BLOCK_CODE_HIGH_PRIVATE_USE_SURROGATES_name, true); zval const_BLOCK_CODE_LOW_SURROGATES_value; ZVAL_LONG(&const_BLOCK_CODE_LOW_SURROGATES_value, UBLOCK_LOW_SURROGATES); - zend_string *const_BLOCK_CODE_LOW_SURROGATES_name = zend_string_init_interned("BLOCK_CODE_LOW_SURROGATES", sizeof("BLOCK_CODE_LOW_SURROGATES") - 1, 1); + zend_string *const_BLOCK_CODE_LOW_SURROGATES_name = zend_string_init_interned("BLOCK_CODE_LOW_SURROGATES", sizeof("BLOCK_CODE_LOW_SURROGATES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LOW_SURROGATES_name, &const_BLOCK_CODE_LOW_SURROGATES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LOW_SURROGATES_name); + zend_string_release_ex(const_BLOCK_CODE_LOW_SURROGATES_name, true); zval const_BLOCK_CODE_PRIVATE_USE_AREA_value; ZVAL_LONG(&const_BLOCK_CODE_PRIVATE_USE_AREA_value, UBLOCK_PRIVATE_USE_AREA); - zend_string *const_BLOCK_CODE_PRIVATE_USE_AREA_name = zend_string_init_interned("BLOCK_CODE_PRIVATE_USE_AREA", sizeof("BLOCK_CODE_PRIVATE_USE_AREA") - 1, 1); + zend_string *const_BLOCK_CODE_PRIVATE_USE_AREA_name = zend_string_init_interned("BLOCK_CODE_PRIVATE_USE_AREA", sizeof("BLOCK_CODE_PRIVATE_USE_AREA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PRIVATE_USE_AREA_name, &const_BLOCK_CODE_PRIVATE_USE_AREA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PRIVATE_USE_AREA_name); + zend_string_release_ex(const_BLOCK_CODE_PRIVATE_USE_AREA_name, true); zval const_BLOCK_CODE_PRIVATE_USE_value; ZVAL_LONG(&const_BLOCK_CODE_PRIVATE_USE_value, UBLOCK_PRIVATE_USE); - zend_string *const_BLOCK_CODE_PRIVATE_USE_name = zend_string_init_interned("BLOCK_CODE_PRIVATE_USE", sizeof("BLOCK_CODE_PRIVATE_USE") - 1, 1); + zend_string *const_BLOCK_CODE_PRIVATE_USE_name = zend_string_init_interned("BLOCK_CODE_PRIVATE_USE", sizeof("BLOCK_CODE_PRIVATE_USE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PRIVATE_USE_name, &const_BLOCK_CODE_PRIVATE_USE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PRIVATE_USE_name); + zend_string_release_ex(const_BLOCK_CODE_PRIVATE_USE_name, true); zval const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_value, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS); - zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS", sizeof("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS", sizeof("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_name, &const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_name, true); zval const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_value; ZVAL_LONG(&const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_value, UBLOCK_ALPHABETIC_PRESENTATION_FORMS); - zend_string *const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_name = zend_string_init_interned("BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS", sizeof("BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS") - 1, 1); + zend_string *const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_name = zend_string_init_interned("BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS", sizeof("BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_name, &const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_name); + zend_string_release_ex(const_BLOCK_CODE_ALPHABETIC_PRESENTATION_FORMS_name, true); zval const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_value; ZVAL_LONG(&const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_value, UBLOCK_ARABIC_PRESENTATION_FORMS_A); - zend_string *const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_name = zend_string_init_interned("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A", sizeof("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A") - 1, 1); + zend_string *const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_name = zend_string_init_interned("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A", sizeof("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_name, &const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_name); + zend_string_release_ex(const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_A_name, true); zval const_BLOCK_CODE_COMBINING_HALF_MARKS_value; ZVAL_LONG(&const_BLOCK_CODE_COMBINING_HALF_MARKS_value, UBLOCK_COMBINING_HALF_MARKS); - zend_string *const_BLOCK_CODE_COMBINING_HALF_MARKS_name = zend_string_init_interned("BLOCK_CODE_COMBINING_HALF_MARKS", sizeof("BLOCK_CODE_COMBINING_HALF_MARKS") - 1, 1); + zend_string *const_BLOCK_CODE_COMBINING_HALF_MARKS_name = zend_string_init_interned("BLOCK_CODE_COMBINING_HALF_MARKS", sizeof("BLOCK_CODE_COMBINING_HALF_MARKS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COMBINING_HALF_MARKS_name, &const_BLOCK_CODE_COMBINING_HALF_MARKS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COMBINING_HALF_MARKS_name); + zend_string_release_ex(const_BLOCK_CODE_COMBINING_HALF_MARKS_name, true); zval const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_value, UBLOCK_CJK_COMPATIBILITY_FORMS); - zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY_FORMS", sizeof("BLOCK_CODE_CJK_COMPATIBILITY_FORMS") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY_FORMS", sizeof("BLOCK_CODE_CJK_COMPATIBILITY_FORMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_name, &const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_COMPATIBILITY_FORMS_name, true); zval const_BLOCK_CODE_SMALL_FORM_VARIANTS_value; ZVAL_LONG(&const_BLOCK_CODE_SMALL_FORM_VARIANTS_value, UBLOCK_SMALL_FORM_VARIANTS); - zend_string *const_BLOCK_CODE_SMALL_FORM_VARIANTS_name = zend_string_init_interned("BLOCK_CODE_SMALL_FORM_VARIANTS", sizeof("BLOCK_CODE_SMALL_FORM_VARIANTS") - 1, 1); + zend_string *const_BLOCK_CODE_SMALL_FORM_VARIANTS_name = zend_string_init_interned("BLOCK_CODE_SMALL_FORM_VARIANTS", sizeof("BLOCK_CODE_SMALL_FORM_VARIANTS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SMALL_FORM_VARIANTS_name, &const_BLOCK_CODE_SMALL_FORM_VARIANTS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SMALL_FORM_VARIANTS_name); + zend_string_release_ex(const_BLOCK_CODE_SMALL_FORM_VARIANTS_name, true); zval const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_value; ZVAL_LONG(&const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_value, UBLOCK_ARABIC_PRESENTATION_FORMS_B); - zend_string *const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_name = zend_string_init_interned("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B", sizeof("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B") - 1, 1); + zend_string *const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_name = zend_string_init_interned("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B", sizeof("BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_name, &const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_name); + zend_string_release_ex(const_BLOCK_CODE_ARABIC_PRESENTATION_FORMS_B_name, true); zval const_BLOCK_CODE_SPECIALS_value; ZVAL_LONG(&const_BLOCK_CODE_SPECIALS_value, UBLOCK_SPECIALS); - zend_string *const_BLOCK_CODE_SPECIALS_name = zend_string_init_interned("BLOCK_CODE_SPECIALS", sizeof("BLOCK_CODE_SPECIALS") - 1, 1); + zend_string *const_BLOCK_CODE_SPECIALS_name = zend_string_init_interned("BLOCK_CODE_SPECIALS", sizeof("BLOCK_CODE_SPECIALS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SPECIALS_name, &const_BLOCK_CODE_SPECIALS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SPECIALS_name); + zend_string_release_ex(const_BLOCK_CODE_SPECIALS_name, true); zval const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_value; ZVAL_LONG(&const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_value, UBLOCK_HALFWIDTH_AND_FULLWIDTH_FORMS); - zend_string *const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_name = zend_string_init_interned("BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS", sizeof("BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS") - 1, 1); + zend_string *const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_name = zend_string_init_interned("BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS", sizeof("BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_name, &const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_name); + zend_string_release_ex(const_BLOCK_CODE_HALFWIDTH_AND_FULLWIDTH_FORMS_name, true); zval const_BLOCK_CODE_OLD_ITALIC_value; ZVAL_LONG(&const_BLOCK_CODE_OLD_ITALIC_value, UBLOCK_OLD_ITALIC); - zend_string *const_BLOCK_CODE_OLD_ITALIC_name = zend_string_init_interned("BLOCK_CODE_OLD_ITALIC", sizeof("BLOCK_CODE_OLD_ITALIC") - 1, 1); + zend_string *const_BLOCK_CODE_OLD_ITALIC_name = zend_string_init_interned("BLOCK_CODE_OLD_ITALIC", sizeof("BLOCK_CODE_OLD_ITALIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OLD_ITALIC_name, &const_BLOCK_CODE_OLD_ITALIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OLD_ITALIC_name); + zend_string_release_ex(const_BLOCK_CODE_OLD_ITALIC_name, true); zval const_BLOCK_CODE_GOTHIC_value; ZVAL_LONG(&const_BLOCK_CODE_GOTHIC_value, UBLOCK_GOTHIC); - zend_string *const_BLOCK_CODE_GOTHIC_name = zend_string_init_interned("BLOCK_CODE_GOTHIC", sizeof("BLOCK_CODE_GOTHIC") - 1, 1); + zend_string *const_BLOCK_CODE_GOTHIC_name = zend_string_init_interned("BLOCK_CODE_GOTHIC", sizeof("BLOCK_CODE_GOTHIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GOTHIC_name, &const_BLOCK_CODE_GOTHIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GOTHIC_name); + zend_string_release_ex(const_BLOCK_CODE_GOTHIC_name, true); zval const_BLOCK_CODE_DESERET_value; ZVAL_LONG(&const_BLOCK_CODE_DESERET_value, UBLOCK_DESERET); - zend_string *const_BLOCK_CODE_DESERET_name = zend_string_init_interned("BLOCK_CODE_DESERET", sizeof("BLOCK_CODE_DESERET") - 1, 1); + zend_string *const_BLOCK_CODE_DESERET_name = zend_string_init_interned("BLOCK_CODE_DESERET", sizeof("BLOCK_CODE_DESERET") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_DESERET_name, &const_BLOCK_CODE_DESERET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_DESERET_name); + zend_string_release_ex(const_BLOCK_CODE_DESERET_name, true); zval const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_value, UBLOCK_BYZANTINE_MUSICAL_SYMBOLS); - zend_string *const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS", sizeof("BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS", sizeof("BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_name, &const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_BYZANTINE_MUSICAL_SYMBOLS_name, true); zval const_BLOCK_CODE_MUSICAL_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_MUSICAL_SYMBOLS_value, UBLOCK_MUSICAL_SYMBOLS); - zend_string *const_BLOCK_CODE_MUSICAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_MUSICAL_SYMBOLS", sizeof("BLOCK_CODE_MUSICAL_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_MUSICAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_MUSICAL_SYMBOLS", sizeof("BLOCK_CODE_MUSICAL_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MUSICAL_SYMBOLS_name, &const_BLOCK_CODE_MUSICAL_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MUSICAL_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_MUSICAL_SYMBOLS_name, true); zval const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_value, UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS); - zend_string *const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS", sizeof("BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS", sizeof("BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_name, &const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_MATHEMATICAL_ALPHANUMERIC_SYMBOLS_name, true); zval const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_value, UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B); - zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_name, &const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B_name, true); zval const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_value, UBLOCK_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT); - zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT", sizeof("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT", sizeof("BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_name, &const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT_name, true); zval const_BLOCK_CODE_TAGS_value; ZVAL_LONG(&const_BLOCK_CODE_TAGS_value, UBLOCK_TAGS); - zend_string *const_BLOCK_CODE_TAGS_name = zend_string_init_interned("BLOCK_CODE_TAGS", sizeof("BLOCK_CODE_TAGS") - 1, 1); + zend_string *const_BLOCK_CODE_TAGS_name = zend_string_init_interned("BLOCK_CODE_TAGS", sizeof("BLOCK_CODE_TAGS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAGS_name, &const_BLOCK_CODE_TAGS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAGS_name); + zend_string_release_ex(const_BLOCK_CODE_TAGS_name, true); zval const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_value, UBLOCK_CYRILLIC_SUPPLEMENT); - zend_string *const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_SUPPLEMENT", sizeof("BLOCK_CODE_CYRILLIC_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_SUPPLEMENT", sizeof("BLOCK_CODE_CYRILLIC_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_name, &const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_CYRILLIC_SUPPLEMENT_name, true); zval const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_value; ZVAL_LONG(&const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_value, UBLOCK_CYRILLIC_SUPPLEMENTARY); - zend_string *const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_SUPPLEMENTARY", sizeof("BLOCK_CODE_CYRILLIC_SUPPLEMENTARY") - 1, 1); + zend_string *const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_SUPPLEMENTARY", sizeof("BLOCK_CODE_CYRILLIC_SUPPLEMENTARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_name, &const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_name); + zend_string_release_ex(const_BLOCK_CODE_CYRILLIC_SUPPLEMENTARY_name, true); zval const_BLOCK_CODE_TAGALOG_value; ZVAL_LONG(&const_BLOCK_CODE_TAGALOG_value, UBLOCK_TAGALOG); - zend_string *const_BLOCK_CODE_TAGALOG_name = zend_string_init_interned("BLOCK_CODE_TAGALOG", sizeof("BLOCK_CODE_TAGALOG") - 1, 1); + zend_string *const_BLOCK_CODE_TAGALOG_name = zend_string_init_interned("BLOCK_CODE_TAGALOG", sizeof("BLOCK_CODE_TAGALOG") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAGALOG_name, &const_BLOCK_CODE_TAGALOG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAGALOG_name); + zend_string_release_ex(const_BLOCK_CODE_TAGALOG_name, true); zval const_BLOCK_CODE_HANUNOO_value; ZVAL_LONG(&const_BLOCK_CODE_HANUNOO_value, UBLOCK_HANUNOO); - zend_string *const_BLOCK_CODE_HANUNOO_name = zend_string_init_interned("BLOCK_CODE_HANUNOO", sizeof("BLOCK_CODE_HANUNOO") - 1, 1); + zend_string *const_BLOCK_CODE_HANUNOO_name = zend_string_init_interned("BLOCK_CODE_HANUNOO", sizeof("BLOCK_CODE_HANUNOO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HANUNOO_name, &const_BLOCK_CODE_HANUNOO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HANUNOO_name); + zend_string_release_ex(const_BLOCK_CODE_HANUNOO_name, true); zval const_BLOCK_CODE_BUHID_value; ZVAL_LONG(&const_BLOCK_CODE_BUHID_value, UBLOCK_BUHID); - zend_string *const_BLOCK_CODE_BUHID_name = zend_string_init_interned("BLOCK_CODE_BUHID", sizeof("BLOCK_CODE_BUHID") - 1, 1); + zend_string *const_BLOCK_CODE_BUHID_name = zend_string_init_interned("BLOCK_CODE_BUHID", sizeof("BLOCK_CODE_BUHID") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BUHID_name, &const_BLOCK_CODE_BUHID_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BUHID_name); + zend_string_release_ex(const_BLOCK_CODE_BUHID_name, true); zval const_BLOCK_CODE_TAGBANWA_value; ZVAL_LONG(&const_BLOCK_CODE_TAGBANWA_value, UBLOCK_TAGBANWA); - zend_string *const_BLOCK_CODE_TAGBANWA_name = zend_string_init_interned("BLOCK_CODE_TAGBANWA", sizeof("BLOCK_CODE_TAGBANWA") - 1, 1); + zend_string *const_BLOCK_CODE_TAGBANWA_name = zend_string_init_interned("BLOCK_CODE_TAGBANWA", sizeof("BLOCK_CODE_TAGBANWA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAGBANWA_name, &const_BLOCK_CODE_TAGBANWA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAGBANWA_name); + zend_string_release_ex(const_BLOCK_CODE_TAGBANWA_name, true); zval const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_value; ZVAL_LONG(&const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_value, UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A); - zend_string *const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A", sizeof("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A") - 1, 1); + zend_string *const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A", sizeof("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_name, &const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_name); + zend_string_release_ex(const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A_name, true); zval const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_value; ZVAL_LONG(&const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_value, UBLOCK_SUPPLEMENTAL_ARROWS_A); - zend_string *const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_ARROWS_A", sizeof("BLOCK_CODE_SUPPLEMENTAL_ARROWS_A") - 1, 1); + zend_string *const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_ARROWS_A", sizeof("BLOCK_CODE_SUPPLEMENTAL_ARROWS_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_name, &const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_name); + zend_string_release_ex(const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_A_name, true); zval const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_value; ZVAL_LONG(&const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_value, UBLOCK_SUPPLEMENTAL_ARROWS_B); - zend_string *const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_ARROWS_B", sizeof("BLOCK_CODE_SUPPLEMENTAL_ARROWS_B") - 1, 1); + zend_string *const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_ARROWS_B", sizeof("BLOCK_CODE_SUPPLEMENTAL_ARROWS_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_name, &const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_name); + zend_string_release_ex(const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_B_name, true); zval const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_value; ZVAL_LONG(&const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_value, UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B); - zend_string *const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B", sizeof("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B") - 1, 1); + zend_string *const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B", sizeof("BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_name, &const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_name); + zend_string_release_ex(const_BLOCK_CODE_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B_name, true); zval const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_value; ZVAL_LONG(&const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_value, UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS); - zend_string *const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS", sizeof("BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS") - 1, 1); + zend_string *const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS", sizeof("BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_name, &const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_name); + zend_string_release_ex(const_BLOCK_CODE_SUPPLEMENTAL_MATHEMATICAL_OPERATORS_name, true); zval const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_value; ZVAL_LONG(&const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_value, UBLOCK_KATAKANA_PHONETIC_EXTENSIONS); - zend_string *const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS", sizeof("BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS") - 1, 1); + zend_string *const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS", sizeof("BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_name, &const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_name); + zend_string_release_ex(const_BLOCK_CODE_KATAKANA_PHONETIC_EXTENSIONS_name, true); zval const_BLOCK_CODE_VARIATION_SELECTORS_value; ZVAL_LONG(&const_BLOCK_CODE_VARIATION_SELECTORS_value, UBLOCK_VARIATION_SELECTORS); - zend_string *const_BLOCK_CODE_VARIATION_SELECTORS_name = zend_string_init_interned("BLOCK_CODE_VARIATION_SELECTORS", sizeof("BLOCK_CODE_VARIATION_SELECTORS") - 1, 1); + zend_string *const_BLOCK_CODE_VARIATION_SELECTORS_name = zend_string_init_interned("BLOCK_CODE_VARIATION_SELECTORS", sizeof("BLOCK_CODE_VARIATION_SELECTORS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_VARIATION_SELECTORS_name, &const_BLOCK_CODE_VARIATION_SELECTORS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_VARIATION_SELECTORS_name); + zend_string_release_ex(const_BLOCK_CODE_VARIATION_SELECTORS_name, true); zval const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_value; ZVAL_LONG(&const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_value, UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_A); - zend_string *const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A", sizeof("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A") - 1, 1); + zend_string *const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A", sizeof("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_name, &const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_name); + zend_string_release_ex(const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_A_name, true); zval const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_value; ZVAL_LONG(&const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_value, UBLOCK_SUPPLEMENTARY_PRIVATE_USE_AREA_B); - zend_string *const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B", sizeof("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B") - 1, 1); + zend_string *const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B", sizeof("BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_name, &const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_name); + zend_string_release_ex(const_BLOCK_CODE_SUPPLEMENTARY_PRIVATE_USE_AREA_B_name, true); zval const_BLOCK_CODE_LIMBU_value; ZVAL_LONG(&const_BLOCK_CODE_LIMBU_value, UBLOCK_LIMBU); - zend_string *const_BLOCK_CODE_LIMBU_name = zend_string_init_interned("BLOCK_CODE_LIMBU", sizeof("BLOCK_CODE_LIMBU") - 1, 1); + zend_string *const_BLOCK_CODE_LIMBU_name = zend_string_init_interned("BLOCK_CODE_LIMBU", sizeof("BLOCK_CODE_LIMBU") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LIMBU_name, &const_BLOCK_CODE_LIMBU_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LIMBU_name); + zend_string_release_ex(const_BLOCK_CODE_LIMBU_name, true); zval const_BLOCK_CODE_TAI_LE_value; ZVAL_LONG(&const_BLOCK_CODE_TAI_LE_value, UBLOCK_TAI_LE); - zend_string *const_BLOCK_CODE_TAI_LE_name = zend_string_init_interned("BLOCK_CODE_TAI_LE", sizeof("BLOCK_CODE_TAI_LE") - 1, 1); + zend_string *const_BLOCK_CODE_TAI_LE_name = zend_string_init_interned("BLOCK_CODE_TAI_LE", sizeof("BLOCK_CODE_TAI_LE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAI_LE_name, &const_BLOCK_CODE_TAI_LE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAI_LE_name); + zend_string_release_ex(const_BLOCK_CODE_TAI_LE_name, true); zval const_BLOCK_CODE_KHMER_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_KHMER_SYMBOLS_value, UBLOCK_KHMER_SYMBOLS); - zend_string *const_BLOCK_CODE_KHMER_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_KHMER_SYMBOLS", sizeof("BLOCK_CODE_KHMER_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_KHMER_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_KHMER_SYMBOLS", sizeof("BLOCK_CODE_KHMER_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KHMER_SYMBOLS_name, &const_BLOCK_CODE_KHMER_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KHMER_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_KHMER_SYMBOLS_name, true); zval const_BLOCK_CODE_PHONETIC_EXTENSIONS_value; ZVAL_LONG(&const_BLOCK_CODE_PHONETIC_EXTENSIONS_value, UBLOCK_PHONETIC_EXTENSIONS); - zend_string *const_BLOCK_CODE_PHONETIC_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_PHONETIC_EXTENSIONS", sizeof("BLOCK_CODE_PHONETIC_EXTENSIONS") - 1, 1); + zend_string *const_BLOCK_CODE_PHONETIC_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_PHONETIC_EXTENSIONS", sizeof("BLOCK_CODE_PHONETIC_EXTENSIONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PHONETIC_EXTENSIONS_name, &const_BLOCK_CODE_PHONETIC_EXTENSIONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PHONETIC_EXTENSIONS_name); + zend_string_release_ex(const_BLOCK_CODE_PHONETIC_EXTENSIONS_name, true); zval const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_value; ZVAL_LONG(&const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_value, UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS); - zend_string *const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS", sizeof("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS") - 1, 1); + zend_string *const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS", sizeof("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_name, &const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_name); + zend_string_release_ex(const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_ARROWS_name, true); zval const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_value, UBLOCK_YIJING_HEXAGRAM_SYMBOLS); - zend_string *const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS", sizeof("BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS", sizeof("BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_name, &const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_YIJING_HEXAGRAM_SYMBOLS_name, true); zval const_BLOCK_CODE_LINEAR_B_SYLLABARY_value; ZVAL_LONG(&const_BLOCK_CODE_LINEAR_B_SYLLABARY_value, UBLOCK_LINEAR_B_SYLLABARY); - zend_string *const_BLOCK_CODE_LINEAR_B_SYLLABARY_name = zend_string_init_interned("BLOCK_CODE_LINEAR_B_SYLLABARY", sizeof("BLOCK_CODE_LINEAR_B_SYLLABARY") - 1, 1); + zend_string *const_BLOCK_CODE_LINEAR_B_SYLLABARY_name = zend_string_init_interned("BLOCK_CODE_LINEAR_B_SYLLABARY", sizeof("BLOCK_CODE_LINEAR_B_SYLLABARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LINEAR_B_SYLLABARY_name, &const_BLOCK_CODE_LINEAR_B_SYLLABARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LINEAR_B_SYLLABARY_name); + zend_string_release_ex(const_BLOCK_CODE_LINEAR_B_SYLLABARY_name, true); zval const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_value; ZVAL_LONG(&const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_value, UBLOCK_LINEAR_B_IDEOGRAMS); - zend_string *const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_name = zend_string_init_interned("BLOCK_CODE_LINEAR_B_IDEOGRAMS", sizeof("BLOCK_CODE_LINEAR_B_IDEOGRAMS") - 1, 1); + zend_string *const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_name = zend_string_init_interned("BLOCK_CODE_LINEAR_B_IDEOGRAMS", sizeof("BLOCK_CODE_LINEAR_B_IDEOGRAMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_name, &const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_name); + zend_string_release_ex(const_BLOCK_CODE_LINEAR_B_IDEOGRAMS_name, true); zval const_BLOCK_CODE_AEGEAN_NUMBERS_value; ZVAL_LONG(&const_BLOCK_CODE_AEGEAN_NUMBERS_value, UBLOCK_AEGEAN_NUMBERS); - zend_string *const_BLOCK_CODE_AEGEAN_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_AEGEAN_NUMBERS", sizeof("BLOCK_CODE_AEGEAN_NUMBERS") - 1, 1); + zend_string *const_BLOCK_CODE_AEGEAN_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_AEGEAN_NUMBERS", sizeof("BLOCK_CODE_AEGEAN_NUMBERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_AEGEAN_NUMBERS_name, &const_BLOCK_CODE_AEGEAN_NUMBERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_AEGEAN_NUMBERS_name); + zend_string_release_ex(const_BLOCK_CODE_AEGEAN_NUMBERS_name, true); zval const_BLOCK_CODE_UGARITIC_value; ZVAL_LONG(&const_BLOCK_CODE_UGARITIC_value, UBLOCK_UGARITIC); - zend_string *const_BLOCK_CODE_UGARITIC_name = zend_string_init_interned("BLOCK_CODE_UGARITIC", sizeof("BLOCK_CODE_UGARITIC") - 1, 1); + zend_string *const_BLOCK_CODE_UGARITIC_name = zend_string_init_interned("BLOCK_CODE_UGARITIC", sizeof("BLOCK_CODE_UGARITIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_UGARITIC_name, &const_BLOCK_CODE_UGARITIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_UGARITIC_name); + zend_string_release_ex(const_BLOCK_CODE_UGARITIC_name, true); zval const_BLOCK_CODE_SHAVIAN_value; ZVAL_LONG(&const_BLOCK_CODE_SHAVIAN_value, UBLOCK_SHAVIAN); - zend_string *const_BLOCK_CODE_SHAVIAN_name = zend_string_init_interned("BLOCK_CODE_SHAVIAN", sizeof("BLOCK_CODE_SHAVIAN") - 1, 1); + zend_string *const_BLOCK_CODE_SHAVIAN_name = zend_string_init_interned("BLOCK_CODE_SHAVIAN", sizeof("BLOCK_CODE_SHAVIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SHAVIAN_name, &const_BLOCK_CODE_SHAVIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SHAVIAN_name); + zend_string_release_ex(const_BLOCK_CODE_SHAVIAN_name, true); zval const_BLOCK_CODE_OSMANYA_value; ZVAL_LONG(&const_BLOCK_CODE_OSMANYA_value, UBLOCK_OSMANYA); - zend_string *const_BLOCK_CODE_OSMANYA_name = zend_string_init_interned("BLOCK_CODE_OSMANYA", sizeof("BLOCK_CODE_OSMANYA") - 1, 1); + zend_string *const_BLOCK_CODE_OSMANYA_name = zend_string_init_interned("BLOCK_CODE_OSMANYA", sizeof("BLOCK_CODE_OSMANYA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OSMANYA_name, &const_BLOCK_CODE_OSMANYA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OSMANYA_name); + zend_string_release_ex(const_BLOCK_CODE_OSMANYA_name, true); zval const_BLOCK_CODE_CYPRIOT_SYLLABARY_value; ZVAL_LONG(&const_BLOCK_CODE_CYPRIOT_SYLLABARY_value, UBLOCK_CYPRIOT_SYLLABARY); - zend_string *const_BLOCK_CODE_CYPRIOT_SYLLABARY_name = zend_string_init_interned("BLOCK_CODE_CYPRIOT_SYLLABARY", sizeof("BLOCK_CODE_CYPRIOT_SYLLABARY") - 1, 1); + zend_string *const_BLOCK_CODE_CYPRIOT_SYLLABARY_name = zend_string_init_interned("BLOCK_CODE_CYPRIOT_SYLLABARY", sizeof("BLOCK_CODE_CYPRIOT_SYLLABARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CYPRIOT_SYLLABARY_name, &const_BLOCK_CODE_CYPRIOT_SYLLABARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CYPRIOT_SYLLABARY_name); + zend_string_release_ex(const_BLOCK_CODE_CYPRIOT_SYLLABARY_name, true); zval const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_value, UBLOCK_TAI_XUAN_JING_SYMBOLS); - zend_string *const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_TAI_XUAN_JING_SYMBOLS", sizeof("BLOCK_CODE_TAI_XUAN_JING_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_TAI_XUAN_JING_SYMBOLS", sizeof("BLOCK_CODE_TAI_XUAN_JING_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_name, &const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_TAI_XUAN_JING_SYMBOLS_name, true); zval const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_value, UBLOCK_VARIATION_SELECTORS_SUPPLEMENT); - zend_string *const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT", sizeof("BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT", sizeof("BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_name, &const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_VARIATION_SELECTORS_SUPPLEMENT_name, true); zval const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_value; ZVAL_LONG(&const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_value, UBLOCK_ANCIENT_GREEK_MUSICAL_NOTATION); - zend_string *const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_name = zend_string_init_interned("BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION", sizeof("BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION") - 1, 1); + zend_string *const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_name = zend_string_init_interned("BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION", sizeof("BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_name, &const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_name); + zend_string_release_ex(const_BLOCK_CODE_ANCIENT_GREEK_MUSICAL_NOTATION_name, true); zval const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_value; ZVAL_LONG(&const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_value, UBLOCK_ANCIENT_GREEK_NUMBERS); - zend_string *const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_ANCIENT_GREEK_NUMBERS", sizeof("BLOCK_CODE_ANCIENT_GREEK_NUMBERS") - 1, 1); + zend_string *const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_ANCIENT_GREEK_NUMBERS", sizeof("BLOCK_CODE_ANCIENT_GREEK_NUMBERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_name, &const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_name); + zend_string_release_ex(const_BLOCK_CODE_ANCIENT_GREEK_NUMBERS_name, true); zval const_BLOCK_CODE_ARABIC_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_ARABIC_SUPPLEMENT_value, UBLOCK_ARABIC_SUPPLEMENT); - zend_string *const_BLOCK_CODE_ARABIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ARABIC_SUPPLEMENT", sizeof("BLOCK_CODE_ARABIC_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_ARABIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ARABIC_SUPPLEMENT", sizeof("BLOCK_CODE_ARABIC_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARABIC_SUPPLEMENT_name, &const_BLOCK_CODE_ARABIC_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARABIC_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_ARABIC_SUPPLEMENT_name, true); zval const_BLOCK_CODE_BUGINESE_value; ZVAL_LONG(&const_BLOCK_CODE_BUGINESE_value, UBLOCK_BUGINESE); - zend_string *const_BLOCK_CODE_BUGINESE_name = zend_string_init_interned("BLOCK_CODE_BUGINESE", sizeof("BLOCK_CODE_BUGINESE") - 1, 1); + zend_string *const_BLOCK_CODE_BUGINESE_name = zend_string_init_interned("BLOCK_CODE_BUGINESE", sizeof("BLOCK_CODE_BUGINESE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BUGINESE_name, &const_BLOCK_CODE_BUGINESE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BUGINESE_name); + zend_string_release_ex(const_BLOCK_CODE_BUGINESE_name, true); zval const_BLOCK_CODE_CJK_STROKES_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_STROKES_value, UBLOCK_CJK_STROKES); - zend_string *const_BLOCK_CODE_CJK_STROKES_name = zend_string_init_interned("BLOCK_CODE_CJK_STROKES", sizeof("BLOCK_CODE_CJK_STROKES") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_STROKES_name = zend_string_init_interned("BLOCK_CODE_CJK_STROKES", sizeof("BLOCK_CODE_CJK_STROKES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_STROKES_name, &const_BLOCK_CODE_CJK_STROKES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_STROKES_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_STROKES_name, true); zval const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_value, UBLOCK_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT); - zend_string *const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT", sizeof("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT", sizeof("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_name, &const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_SUPPLEMENT_name, true); zval const_BLOCK_CODE_COPTIC_value; ZVAL_LONG(&const_BLOCK_CODE_COPTIC_value, UBLOCK_COPTIC); - zend_string *const_BLOCK_CODE_COPTIC_name = zend_string_init_interned("BLOCK_CODE_COPTIC", sizeof("BLOCK_CODE_COPTIC") - 1, 1); + zend_string *const_BLOCK_CODE_COPTIC_name = zend_string_init_interned("BLOCK_CODE_COPTIC", sizeof("BLOCK_CODE_COPTIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COPTIC_name, &const_BLOCK_CODE_COPTIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COPTIC_name); + zend_string_release_ex(const_BLOCK_CODE_COPTIC_name, true); zval const_BLOCK_CODE_ETHIOPIC_EXTENDED_value; ZVAL_LONG(&const_BLOCK_CODE_ETHIOPIC_EXTENDED_value, UBLOCK_ETHIOPIC_EXTENDED); - zend_string *const_BLOCK_CODE_ETHIOPIC_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC_EXTENDED", sizeof("BLOCK_CODE_ETHIOPIC_EXTENDED") - 1, 1); + zend_string *const_BLOCK_CODE_ETHIOPIC_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC_EXTENDED", sizeof("BLOCK_CODE_ETHIOPIC_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ETHIOPIC_EXTENDED_name, &const_BLOCK_CODE_ETHIOPIC_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ETHIOPIC_EXTENDED_name); + zend_string_release_ex(const_BLOCK_CODE_ETHIOPIC_EXTENDED_name, true); zval const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_value, UBLOCK_ETHIOPIC_SUPPLEMENT); - zend_string *const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC_SUPPLEMENT", sizeof("BLOCK_CODE_ETHIOPIC_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC_SUPPLEMENT", sizeof("BLOCK_CODE_ETHIOPIC_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_name, &const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_ETHIOPIC_SUPPLEMENT_name, true); zval const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_value, UBLOCK_GEORGIAN_SUPPLEMENT); - zend_string *const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_GEORGIAN_SUPPLEMENT", sizeof("BLOCK_CODE_GEORGIAN_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_GEORGIAN_SUPPLEMENT", sizeof("BLOCK_CODE_GEORGIAN_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_name, &const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_GEORGIAN_SUPPLEMENT_name, true); zval const_BLOCK_CODE_GLAGOLITIC_value; ZVAL_LONG(&const_BLOCK_CODE_GLAGOLITIC_value, UBLOCK_GLAGOLITIC); - zend_string *const_BLOCK_CODE_GLAGOLITIC_name = zend_string_init_interned("BLOCK_CODE_GLAGOLITIC", sizeof("BLOCK_CODE_GLAGOLITIC") - 1, 1); + zend_string *const_BLOCK_CODE_GLAGOLITIC_name = zend_string_init_interned("BLOCK_CODE_GLAGOLITIC", sizeof("BLOCK_CODE_GLAGOLITIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GLAGOLITIC_name, &const_BLOCK_CODE_GLAGOLITIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GLAGOLITIC_name); + zend_string_release_ex(const_BLOCK_CODE_GLAGOLITIC_name, true); zval const_BLOCK_CODE_KHAROSHTHI_value; ZVAL_LONG(&const_BLOCK_CODE_KHAROSHTHI_value, UBLOCK_KHAROSHTHI); - zend_string *const_BLOCK_CODE_KHAROSHTHI_name = zend_string_init_interned("BLOCK_CODE_KHAROSHTHI", sizeof("BLOCK_CODE_KHAROSHTHI") - 1, 1); + zend_string *const_BLOCK_CODE_KHAROSHTHI_name = zend_string_init_interned("BLOCK_CODE_KHAROSHTHI", sizeof("BLOCK_CODE_KHAROSHTHI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KHAROSHTHI_name, &const_BLOCK_CODE_KHAROSHTHI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KHAROSHTHI_name); + zend_string_release_ex(const_BLOCK_CODE_KHAROSHTHI_name, true); zval const_BLOCK_CODE_MODIFIER_TONE_LETTERS_value; ZVAL_LONG(&const_BLOCK_CODE_MODIFIER_TONE_LETTERS_value, UBLOCK_MODIFIER_TONE_LETTERS); - zend_string *const_BLOCK_CODE_MODIFIER_TONE_LETTERS_name = zend_string_init_interned("BLOCK_CODE_MODIFIER_TONE_LETTERS", sizeof("BLOCK_CODE_MODIFIER_TONE_LETTERS") - 1, 1); + zend_string *const_BLOCK_CODE_MODIFIER_TONE_LETTERS_name = zend_string_init_interned("BLOCK_CODE_MODIFIER_TONE_LETTERS", sizeof("BLOCK_CODE_MODIFIER_TONE_LETTERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MODIFIER_TONE_LETTERS_name, &const_BLOCK_CODE_MODIFIER_TONE_LETTERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MODIFIER_TONE_LETTERS_name); + zend_string_release_ex(const_BLOCK_CODE_MODIFIER_TONE_LETTERS_name, true); zval const_BLOCK_CODE_NEW_TAI_LUE_value; ZVAL_LONG(&const_BLOCK_CODE_NEW_TAI_LUE_value, UBLOCK_NEW_TAI_LUE); - zend_string *const_BLOCK_CODE_NEW_TAI_LUE_name = zend_string_init_interned("BLOCK_CODE_NEW_TAI_LUE", sizeof("BLOCK_CODE_NEW_TAI_LUE") - 1, 1); + zend_string *const_BLOCK_CODE_NEW_TAI_LUE_name = zend_string_init_interned("BLOCK_CODE_NEW_TAI_LUE", sizeof("BLOCK_CODE_NEW_TAI_LUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_NEW_TAI_LUE_name, &const_BLOCK_CODE_NEW_TAI_LUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_NEW_TAI_LUE_name); + zend_string_release_ex(const_BLOCK_CODE_NEW_TAI_LUE_name, true); zval const_BLOCK_CODE_OLD_PERSIAN_value; ZVAL_LONG(&const_BLOCK_CODE_OLD_PERSIAN_value, UBLOCK_OLD_PERSIAN); - zend_string *const_BLOCK_CODE_OLD_PERSIAN_name = zend_string_init_interned("BLOCK_CODE_OLD_PERSIAN", sizeof("BLOCK_CODE_OLD_PERSIAN") - 1, 1); + zend_string *const_BLOCK_CODE_OLD_PERSIAN_name = zend_string_init_interned("BLOCK_CODE_OLD_PERSIAN", sizeof("BLOCK_CODE_OLD_PERSIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OLD_PERSIAN_name, &const_BLOCK_CODE_OLD_PERSIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OLD_PERSIAN_name); + zend_string_release_ex(const_BLOCK_CODE_OLD_PERSIAN_name, true); zval const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_value, UBLOCK_PHONETIC_EXTENSIONS_SUPPLEMENT); - zend_string *const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT", sizeof("BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT", sizeof("BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_name, &const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_PHONETIC_EXTENSIONS_SUPPLEMENT_name, true); zval const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_value; ZVAL_LONG(&const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_value, UBLOCK_SUPPLEMENTAL_PUNCTUATION); - zend_string *const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION", sizeof("BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION") - 1, 1); + zend_string *const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION", sizeof("BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_name, &const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_name); + zend_string_release_ex(const_BLOCK_CODE_SUPPLEMENTAL_PUNCTUATION_name, true); zval const_BLOCK_CODE_SYLOTI_NAGRI_value; ZVAL_LONG(&const_BLOCK_CODE_SYLOTI_NAGRI_value, UBLOCK_SYLOTI_NAGRI); - zend_string *const_BLOCK_CODE_SYLOTI_NAGRI_name = zend_string_init_interned("BLOCK_CODE_SYLOTI_NAGRI", sizeof("BLOCK_CODE_SYLOTI_NAGRI") - 1, 1); + zend_string *const_BLOCK_CODE_SYLOTI_NAGRI_name = zend_string_init_interned("BLOCK_CODE_SYLOTI_NAGRI", sizeof("BLOCK_CODE_SYLOTI_NAGRI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SYLOTI_NAGRI_name, &const_BLOCK_CODE_SYLOTI_NAGRI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SYLOTI_NAGRI_name); + zend_string_release_ex(const_BLOCK_CODE_SYLOTI_NAGRI_name, true); zval const_BLOCK_CODE_TIFINAGH_value; ZVAL_LONG(&const_BLOCK_CODE_TIFINAGH_value, UBLOCK_TIFINAGH); - zend_string *const_BLOCK_CODE_TIFINAGH_name = zend_string_init_interned("BLOCK_CODE_TIFINAGH", sizeof("BLOCK_CODE_TIFINAGH") - 1, 1); + zend_string *const_BLOCK_CODE_TIFINAGH_name = zend_string_init_interned("BLOCK_CODE_TIFINAGH", sizeof("BLOCK_CODE_TIFINAGH") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TIFINAGH_name, &const_BLOCK_CODE_TIFINAGH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TIFINAGH_name); + zend_string_release_ex(const_BLOCK_CODE_TIFINAGH_name, true); zval const_BLOCK_CODE_VERTICAL_FORMS_value; ZVAL_LONG(&const_BLOCK_CODE_VERTICAL_FORMS_value, UBLOCK_VERTICAL_FORMS); - zend_string *const_BLOCK_CODE_VERTICAL_FORMS_name = zend_string_init_interned("BLOCK_CODE_VERTICAL_FORMS", sizeof("BLOCK_CODE_VERTICAL_FORMS") - 1, 1); + zend_string *const_BLOCK_CODE_VERTICAL_FORMS_name = zend_string_init_interned("BLOCK_CODE_VERTICAL_FORMS", sizeof("BLOCK_CODE_VERTICAL_FORMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_VERTICAL_FORMS_name, &const_BLOCK_CODE_VERTICAL_FORMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_VERTICAL_FORMS_name); + zend_string_release_ex(const_BLOCK_CODE_VERTICAL_FORMS_name, true); zval const_BLOCK_CODE_NKO_value; ZVAL_LONG(&const_BLOCK_CODE_NKO_value, UBLOCK_NKO); - zend_string *const_BLOCK_CODE_NKO_name = zend_string_init_interned("BLOCK_CODE_NKO", sizeof("BLOCK_CODE_NKO") - 1, 1); + zend_string *const_BLOCK_CODE_NKO_name = zend_string_init_interned("BLOCK_CODE_NKO", sizeof("BLOCK_CODE_NKO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_NKO_name, &const_BLOCK_CODE_NKO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_NKO_name); + zend_string_release_ex(const_BLOCK_CODE_NKO_name, true); zval const_BLOCK_CODE_BALINESE_value; ZVAL_LONG(&const_BLOCK_CODE_BALINESE_value, UBLOCK_BALINESE); - zend_string *const_BLOCK_CODE_BALINESE_name = zend_string_init_interned("BLOCK_CODE_BALINESE", sizeof("BLOCK_CODE_BALINESE") - 1, 1); + zend_string *const_BLOCK_CODE_BALINESE_name = zend_string_init_interned("BLOCK_CODE_BALINESE", sizeof("BLOCK_CODE_BALINESE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BALINESE_name, &const_BLOCK_CODE_BALINESE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BALINESE_name); + zend_string_release_ex(const_BLOCK_CODE_BALINESE_name, true); zval const_BLOCK_CODE_LATIN_EXTENDED_C_value; ZVAL_LONG(&const_BLOCK_CODE_LATIN_EXTENDED_C_value, UBLOCK_LATIN_EXTENDED_C); - zend_string *const_BLOCK_CODE_LATIN_EXTENDED_C_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_C", sizeof("BLOCK_CODE_LATIN_EXTENDED_C") - 1, 1); + zend_string *const_BLOCK_CODE_LATIN_EXTENDED_C_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_C", sizeof("BLOCK_CODE_LATIN_EXTENDED_C") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LATIN_EXTENDED_C_name, &const_BLOCK_CODE_LATIN_EXTENDED_C_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LATIN_EXTENDED_C_name); + zend_string_release_ex(const_BLOCK_CODE_LATIN_EXTENDED_C_name, true); zval const_BLOCK_CODE_LATIN_EXTENDED_D_value; ZVAL_LONG(&const_BLOCK_CODE_LATIN_EXTENDED_D_value, UBLOCK_LATIN_EXTENDED_D); - zend_string *const_BLOCK_CODE_LATIN_EXTENDED_D_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_D", sizeof("BLOCK_CODE_LATIN_EXTENDED_D") - 1, 1); + zend_string *const_BLOCK_CODE_LATIN_EXTENDED_D_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_D", sizeof("BLOCK_CODE_LATIN_EXTENDED_D") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LATIN_EXTENDED_D_name, &const_BLOCK_CODE_LATIN_EXTENDED_D_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LATIN_EXTENDED_D_name); + zend_string_release_ex(const_BLOCK_CODE_LATIN_EXTENDED_D_name, true); zval const_BLOCK_CODE_PHAGS_PA_value; ZVAL_LONG(&const_BLOCK_CODE_PHAGS_PA_value, UBLOCK_PHAGS_PA); - zend_string *const_BLOCK_CODE_PHAGS_PA_name = zend_string_init_interned("BLOCK_CODE_PHAGS_PA", sizeof("BLOCK_CODE_PHAGS_PA") - 1, 1); + zend_string *const_BLOCK_CODE_PHAGS_PA_name = zend_string_init_interned("BLOCK_CODE_PHAGS_PA", sizeof("BLOCK_CODE_PHAGS_PA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PHAGS_PA_name, &const_BLOCK_CODE_PHAGS_PA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PHAGS_PA_name); + zend_string_release_ex(const_BLOCK_CODE_PHAGS_PA_name, true); zval const_BLOCK_CODE_PHOENICIAN_value; ZVAL_LONG(&const_BLOCK_CODE_PHOENICIAN_value, UBLOCK_PHOENICIAN); - zend_string *const_BLOCK_CODE_PHOENICIAN_name = zend_string_init_interned("BLOCK_CODE_PHOENICIAN", sizeof("BLOCK_CODE_PHOENICIAN") - 1, 1); + zend_string *const_BLOCK_CODE_PHOENICIAN_name = zend_string_init_interned("BLOCK_CODE_PHOENICIAN", sizeof("BLOCK_CODE_PHOENICIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PHOENICIAN_name, &const_BLOCK_CODE_PHOENICIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PHOENICIAN_name); + zend_string_release_ex(const_BLOCK_CODE_PHOENICIAN_name, true); zval const_BLOCK_CODE_CUNEIFORM_value; ZVAL_LONG(&const_BLOCK_CODE_CUNEIFORM_value, UBLOCK_CUNEIFORM); - zend_string *const_BLOCK_CODE_CUNEIFORM_name = zend_string_init_interned("BLOCK_CODE_CUNEIFORM", sizeof("BLOCK_CODE_CUNEIFORM") - 1, 1); + zend_string *const_BLOCK_CODE_CUNEIFORM_name = zend_string_init_interned("BLOCK_CODE_CUNEIFORM", sizeof("BLOCK_CODE_CUNEIFORM") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CUNEIFORM_name, &const_BLOCK_CODE_CUNEIFORM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CUNEIFORM_name); + zend_string_release_ex(const_BLOCK_CODE_CUNEIFORM_name, true); zval const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_value; ZVAL_LONG(&const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_value, UBLOCK_CUNEIFORM_NUMBERS_AND_PUNCTUATION); - zend_string *const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION", sizeof("BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION") - 1, 1); + zend_string *const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_name = zend_string_init_interned("BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION", sizeof("BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_name, &const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_name); + zend_string_release_ex(const_BLOCK_CODE_CUNEIFORM_NUMBERS_AND_PUNCTUATION_name, true); zval const_BLOCK_CODE_COUNTING_ROD_NUMERALS_value; ZVAL_LONG(&const_BLOCK_CODE_COUNTING_ROD_NUMERALS_value, UBLOCK_COUNTING_ROD_NUMERALS); - zend_string *const_BLOCK_CODE_COUNTING_ROD_NUMERALS_name = zend_string_init_interned("BLOCK_CODE_COUNTING_ROD_NUMERALS", sizeof("BLOCK_CODE_COUNTING_ROD_NUMERALS") - 1, 1); + zend_string *const_BLOCK_CODE_COUNTING_ROD_NUMERALS_name = zend_string_init_interned("BLOCK_CODE_COUNTING_ROD_NUMERALS", sizeof("BLOCK_CODE_COUNTING_ROD_NUMERALS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COUNTING_ROD_NUMERALS_name, &const_BLOCK_CODE_COUNTING_ROD_NUMERALS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COUNTING_ROD_NUMERALS_name); + zend_string_release_ex(const_BLOCK_CODE_COUNTING_ROD_NUMERALS_name, true); zval const_BLOCK_CODE_SUNDANESE_value; ZVAL_LONG(&const_BLOCK_CODE_SUNDANESE_value, UBLOCK_SUNDANESE); - zend_string *const_BLOCK_CODE_SUNDANESE_name = zend_string_init_interned("BLOCK_CODE_SUNDANESE", sizeof("BLOCK_CODE_SUNDANESE") - 1, 1); + zend_string *const_BLOCK_CODE_SUNDANESE_name = zend_string_init_interned("BLOCK_CODE_SUNDANESE", sizeof("BLOCK_CODE_SUNDANESE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUNDANESE_name, &const_BLOCK_CODE_SUNDANESE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUNDANESE_name); + zend_string_release_ex(const_BLOCK_CODE_SUNDANESE_name, true); zval const_BLOCK_CODE_LEPCHA_value; ZVAL_LONG(&const_BLOCK_CODE_LEPCHA_value, UBLOCK_LEPCHA); - zend_string *const_BLOCK_CODE_LEPCHA_name = zend_string_init_interned("BLOCK_CODE_LEPCHA", sizeof("BLOCK_CODE_LEPCHA") - 1, 1); + zend_string *const_BLOCK_CODE_LEPCHA_name = zend_string_init_interned("BLOCK_CODE_LEPCHA", sizeof("BLOCK_CODE_LEPCHA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LEPCHA_name, &const_BLOCK_CODE_LEPCHA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LEPCHA_name); + zend_string_release_ex(const_BLOCK_CODE_LEPCHA_name, true); zval const_BLOCK_CODE_OL_CHIKI_value; ZVAL_LONG(&const_BLOCK_CODE_OL_CHIKI_value, UBLOCK_OL_CHIKI); - zend_string *const_BLOCK_CODE_OL_CHIKI_name = zend_string_init_interned("BLOCK_CODE_OL_CHIKI", sizeof("BLOCK_CODE_OL_CHIKI") - 1, 1); + zend_string *const_BLOCK_CODE_OL_CHIKI_name = zend_string_init_interned("BLOCK_CODE_OL_CHIKI", sizeof("BLOCK_CODE_OL_CHIKI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OL_CHIKI_name, &const_BLOCK_CODE_OL_CHIKI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OL_CHIKI_name); + zend_string_release_ex(const_BLOCK_CODE_OL_CHIKI_name, true); zval const_BLOCK_CODE_CYRILLIC_EXTENDED_A_value; ZVAL_LONG(&const_BLOCK_CODE_CYRILLIC_EXTENDED_A_value, UBLOCK_CYRILLIC_EXTENDED_A); - zend_string *const_BLOCK_CODE_CYRILLIC_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_EXTENDED_A", sizeof("BLOCK_CODE_CYRILLIC_EXTENDED_A") - 1, 1); + zend_string *const_BLOCK_CODE_CYRILLIC_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_EXTENDED_A", sizeof("BLOCK_CODE_CYRILLIC_EXTENDED_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CYRILLIC_EXTENDED_A_name, &const_BLOCK_CODE_CYRILLIC_EXTENDED_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CYRILLIC_EXTENDED_A_name); + zend_string_release_ex(const_BLOCK_CODE_CYRILLIC_EXTENDED_A_name, true); zval const_BLOCK_CODE_VAI_value; ZVAL_LONG(&const_BLOCK_CODE_VAI_value, UBLOCK_VAI); - zend_string *const_BLOCK_CODE_VAI_name = zend_string_init_interned("BLOCK_CODE_VAI", sizeof("BLOCK_CODE_VAI") - 1, 1); + zend_string *const_BLOCK_CODE_VAI_name = zend_string_init_interned("BLOCK_CODE_VAI", sizeof("BLOCK_CODE_VAI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_VAI_name, &const_BLOCK_CODE_VAI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_VAI_name); + zend_string_release_ex(const_BLOCK_CODE_VAI_name, true); zval const_BLOCK_CODE_CYRILLIC_EXTENDED_B_value; ZVAL_LONG(&const_BLOCK_CODE_CYRILLIC_EXTENDED_B_value, UBLOCK_CYRILLIC_EXTENDED_B); - zend_string *const_BLOCK_CODE_CYRILLIC_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_EXTENDED_B", sizeof("BLOCK_CODE_CYRILLIC_EXTENDED_B") - 1, 1); + zend_string *const_BLOCK_CODE_CYRILLIC_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_CYRILLIC_EXTENDED_B", sizeof("BLOCK_CODE_CYRILLIC_EXTENDED_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CYRILLIC_EXTENDED_B_name, &const_BLOCK_CODE_CYRILLIC_EXTENDED_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CYRILLIC_EXTENDED_B_name); + zend_string_release_ex(const_BLOCK_CODE_CYRILLIC_EXTENDED_B_name, true); zval const_BLOCK_CODE_SAURASHTRA_value; ZVAL_LONG(&const_BLOCK_CODE_SAURASHTRA_value, UBLOCK_SAURASHTRA); - zend_string *const_BLOCK_CODE_SAURASHTRA_name = zend_string_init_interned("BLOCK_CODE_SAURASHTRA", sizeof("BLOCK_CODE_SAURASHTRA") - 1, 1); + zend_string *const_BLOCK_CODE_SAURASHTRA_name = zend_string_init_interned("BLOCK_CODE_SAURASHTRA", sizeof("BLOCK_CODE_SAURASHTRA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SAURASHTRA_name, &const_BLOCK_CODE_SAURASHTRA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SAURASHTRA_name); + zend_string_release_ex(const_BLOCK_CODE_SAURASHTRA_name, true); zval const_BLOCK_CODE_KAYAH_LI_value; ZVAL_LONG(&const_BLOCK_CODE_KAYAH_LI_value, UBLOCK_KAYAH_LI); - zend_string *const_BLOCK_CODE_KAYAH_LI_name = zend_string_init_interned("BLOCK_CODE_KAYAH_LI", sizeof("BLOCK_CODE_KAYAH_LI") - 1, 1); + zend_string *const_BLOCK_CODE_KAYAH_LI_name = zend_string_init_interned("BLOCK_CODE_KAYAH_LI", sizeof("BLOCK_CODE_KAYAH_LI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KAYAH_LI_name, &const_BLOCK_CODE_KAYAH_LI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KAYAH_LI_name); + zend_string_release_ex(const_BLOCK_CODE_KAYAH_LI_name, true); zval const_BLOCK_CODE_REJANG_value; ZVAL_LONG(&const_BLOCK_CODE_REJANG_value, UBLOCK_REJANG); - zend_string *const_BLOCK_CODE_REJANG_name = zend_string_init_interned("BLOCK_CODE_REJANG", sizeof("BLOCK_CODE_REJANG") - 1, 1); + zend_string *const_BLOCK_CODE_REJANG_name = zend_string_init_interned("BLOCK_CODE_REJANG", sizeof("BLOCK_CODE_REJANG") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_REJANG_name, &const_BLOCK_CODE_REJANG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_REJANG_name); + zend_string_release_ex(const_BLOCK_CODE_REJANG_name, true); zval const_BLOCK_CODE_CHAM_value; ZVAL_LONG(&const_BLOCK_CODE_CHAM_value, UBLOCK_CHAM); - zend_string *const_BLOCK_CODE_CHAM_name = zend_string_init_interned("BLOCK_CODE_CHAM", sizeof("BLOCK_CODE_CHAM") - 1, 1); + zend_string *const_BLOCK_CODE_CHAM_name = zend_string_init_interned("BLOCK_CODE_CHAM", sizeof("BLOCK_CODE_CHAM") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CHAM_name, &const_BLOCK_CODE_CHAM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CHAM_name); + zend_string_release_ex(const_BLOCK_CODE_CHAM_name, true); zval const_BLOCK_CODE_ANCIENT_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_ANCIENT_SYMBOLS_value, UBLOCK_ANCIENT_SYMBOLS); - zend_string *const_BLOCK_CODE_ANCIENT_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_ANCIENT_SYMBOLS", sizeof("BLOCK_CODE_ANCIENT_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_ANCIENT_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_ANCIENT_SYMBOLS", sizeof("BLOCK_CODE_ANCIENT_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ANCIENT_SYMBOLS_name, &const_BLOCK_CODE_ANCIENT_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ANCIENT_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_ANCIENT_SYMBOLS_name, true); zval const_BLOCK_CODE_PHAISTOS_DISC_value; ZVAL_LONG(&const_BLOCK_CODE_PHAISTOS_DISC_value, UBLOCK_PHAISTOS_DISC); - zend_string *const_BLOCK_CODE_PHAISTOS_DISC_name = zend_string_init_interned("BLOCK_CODE_PHAISTOS_DISC", sizeof("BLOCK_CODE_PHAISTOS_DISC") - 1, 1); + zend_string *const_BLOCK_CODE_PHAISTOS_DISC_name = zend_string_init_interned("BLOCK_CODE_PHAISTOS_DISC", sizeof("BLOCK_CODE_PHAISTOS_DISC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PHAISTOS_DISC_name, &const_BLOCK_CODE_PHAISTOS_DISC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PHAISTOS_DISC_name); + zend_string_release_ex(const_BLOCK_CODE_PHAISTOS_DISC_name, true); zval const_BLOCK_CODE_LYCIAN_value; ZVAL_LONG(&const_BLOCK_CODE_LYCIAN_value, UBLOCK_LYCIAN); - zend_string *const_BLOCK_CODE_LYCIAN_name = zend_string_init_interned("BLOCK_CODE_LYCIAN", sizeof("BLOCK_CODE_LYCIAN") - 1, 1); + zend_string *const_BLOCK_CODE_LYCIAN_name = zend_string_init_interned("BLOCK_CODE_LYCIAN", sizeof("BLOCK_CODE_LYCIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LYCIAN_name, &const_BLOCK_CODE_LYCIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LYCIAN_name); + zend_string_release_ex(const_BLOCK_CODE_LYCIAN_name, true); zval const_BLOCK_CODE_CARIAN_value; ZVAL_LONG(&const_BLOCK_CODE_CARIAN_value, UBLOCK_CARIAN); - zend_string *const_BLOCK_CODE_CARIAN_name = zend_string_init_interned("BLOCK_CODE_CARIAN", sizeof("BLOCK_CODE_CARIAN") - 1, 1); + zend_string *const_BLOCK_CODE_CARIAN_name = zend_string_init_interned("BLOCK_CODE_CARIAN", sizeof("BLOCK_CODE_CARIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CARIAN_name, &const_BLOCK_CODE_CARIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CARIAN_name); + zend_string_release_ex(const_BLOCK_CODE_CARIAN_name, true); zval const_BLOCK_CODE_LYDIAN_value; ZVAL_LONG(&const_BLOCK_CODE_LYDIAN_value, UBLOCK_LYDIAN); - zend_string *const_BLOCK_CODE_LYDIAN_name = zend_string_init_interned("BLOCK_CODE_LYDIAN", sizeof("BLOCK_CODE_LYDIAN") - 1, 1); + zend_string *const_BLOCK_CODE_LYDIAN_name = zend_string_init_interned("BLOCK_CODE_LYDIAN", sizeof("BLOCK_CODE_LYDIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LYDIAN_name, &const_BLOCK_CODE_LYDIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LYDIAN_name); + zend_string_release_ex(const_BLOCK_CODE_LYDIAN_name, true); zval const_BLOCK_CODE_MAHJONG_TILES_value; ZVAL_LONG(&const_BLOCK_CODE_MAHJONG_TILES_value, UBLOCK_MAHJONG_TILES); - zend_string *const_BLOCK_CODE_MAHJONG_TILES_name = zend_string_init_interned("BLOCK_CODE_MAHJONG_TILES", sizeof("BLOCK_CODE_MAHJONG_TILES") - 1, 1); + zend_string *const_BLOCK_CODE_MAHJONG_TILES_name = zend_string_init_interned("BLOCK_CODE_MAHJONG_TILES", sizeof("BLOCK_CODE_MAHJONG_TILES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MAHJONG_TILES_name, &const_BLOCK_CODE_MAHJONG_TILES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MAHJONG_TILES_name); + zend_string_release_ex(const_BLOCK_CODE_MAHJONG_TILES_name, true); zval const_BLOCK_CODE_DOMINO_TILES_value; ZVAL_LONG(&const_BLOCK_CODE_DOMINO_TILES_value, UBLOCK_DOMINO_TILES); - zend_string *const_BLOCK_CODE_DOMINO_TILES_name = zend_string_init_interned("BLOCK_CODE_DOMINO_TILES", sizeof("BLOCK_CODE_DOMINO_TILES") - 1, 1); + zend_string *const_BLOCK_CODE_DOMINO_TILES_name = zend_string_init_interned("BLOCK_CODE_DOMINO_TILES", sizeof("BLOCK_CODE_DOMINO_TILES") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_DOMINO_TILES_name, &const_BLOCK_CODE_DOMINO_TILES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_DOMINO_TILES_name); + zend_string_release_ex(const_BLOCK_CODE_DOMINO_TILES_name, true); zval const_BLOCK_CODE_SAMARITAN_value; ZVAL_LONG(&const_BLOCK_CODE_SAMARITAN_value, UBLOCK_SAMARITAN); - zend_string *const_BLOCK_CODE_SAMARITAN_name = zend_string_init_interned("BLOCK_CODE_SAMARITAN", sizeof("BLOCK_CODE_SAMARITAN") - 1, 1); + zend_string *const_BLOCK_CODE_SAMARITAN_name = zend_string_init_interned("BLOCK_CODE_SAMARITAN", sizeof("BLOCK_CODE_SAMARITAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SAMARITAN_name, &const_BLOCK_CODE_SAMARITAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SAMARITAN_name); + zend_string_release_ex(const_BLOCK_CODE_SAMARITAN_name, true); zval const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_value; ZVAL_LONG(&const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_value, UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED); - zend_string *const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED", sizeof("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED") - 1, 1); + zend_string *const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED", sizeof("BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_name, &const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_name); + zend_string_release_ex(const_BLOCK_CODE_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS_EXTENDED_name, true); zval const_BLOCK_CODE_TAI_THAM_value; ZVAL_LONG(&const_BLOCK_CODE_TAI_THAM_value, UBLOCK_TAI_THAM); - zend_string *const_BLOCK_CODE_TAI_THAM_name = zend_string_init_interned("BLOCK_CODE_TAI_THAM", sizeof("BLOCK_CODE_TAI_THAM") - 1, 1); + zend_string *const_BLOCK_CODE_TAI_THAM_name = zend_string_init_interned("BLOCK_CODE_TAI_THAM", sizeof("BLOCK_CODE_TAI_THAM") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAI_THAM_name, &const_BLOCK_CODE_TAI_THAM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAI_THAM_name); + zend_string_release_ex(const_BLOCK_CODE_TAI_THAM_name, true); zval const_BLOCK_CODE_VEDIC_EXTENSIONS_value; ZVAL_LONG(&const_BLOCK_CODE_VEDIC_EXTENSIONS_value, UBLOCK_VEDIC_EXTENSIONS); - zend_string *const_BLOCK_CODE_VEDIC_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_VEDIC_EXTENSIONS", sizeof("BLOCK_CODE_VEDIC_EXTENSIONS") - 1, 1); + zend_string *const_BLOCK_CODE_VEDIC_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_VEDIC_EXTENSIONS", sizeof("BLOCK_CODE_VEDIC_EXTENSIONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_VEDIC_EXTENSIONS_name, &const_BLOCK_CODE_VEDIC_EXTENSIONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_VEDIC_EXTENSIONS_name); + zend_string_release_ex(const_BLOCK_CODE_VEDIC_EXTENSIONS_name, true); zval const_BLOCK_CODE_LISU_value; ZVAL_LONG(&const_BLOCK_CODE_LISU_value, UBLOCK_LISU); - zend_string *const_BLOCK_CODE_LISU_name = zend_string_init_interned("BLOCK_CODE_LISU", sizeof("BLOCK_CODE_LISU") - 1, 1); + zend_string *const_BLOCK_CODE_LISU_name = zend_string_init_interned("BLOCK_CODE_LISU", sizeof("BLOCK_CODE_LISU") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LISU_name, &const_BLOCK_CODE_LISU_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LISU_name); + zend_string_release_ex(const_BLOCK_CODE_LISU_name, true); zval const_BLOCK_CODE_BAMUM_value; ZVAL_LONG(&const_BLOCK_CODE_BAMUM_value, UBLOCK_BAMUM); - zend_string *const_BLOCK_CODE_BAMUM_name = zend_string_init_interned("BLOCK_CODE_BAMUM", sizeof("BLOCK_CODE_BAMUM") - 1, 1); + zend_string *const_BLOCK_CODE_BAMUM_name = zend_string_init_interned("BLOCK_CODE_BAMUM", sizeof("BLOCK_CODE_BAMUM") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BAMUM_name, &const_BLOCK_CODE_BAMUM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BAMUM_name); + zend_string_release_ex(const_BLOCK_CODE_BAMUM_name, true); zval const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_value; ZVAL_LONG(&const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_value, UBLOCK_COMMON_INDIC_NUMBER_FORMS); - zend_string *const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_name = zend_string_init_interned("BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS", sizeof("BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS") - 1, 1); + zend_string *const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_name = zend_string_init_interned("BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS", sizeof("BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_name, &const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_name); + zend_string_release_ex(const_BLOCK_CODE_COMMON_INDIC_NUMBER_FORMS_name, true); zval const_BLOCK_CODE_DEVANAGARI_EXTENDED_value; ZVAL_LONG(&const_BLOCK_CODE_DEVANAGARI_EXTENDED_value, UBLOCK_DEVANAGARI_EXTENDED); - zend_string *const_BLOCK_CODE_DEVANAGARI_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_DEVANAGARI_EXTENDED", sizeof("BLOCK_CODE_DEVANAGARI_EXTENDED") - 1, 1); + zend_string *const_BLOCK_CODE_DEVANAGARI_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_DEVANAGARI_EXTENDED", sizeof("BLOCK_CODE_DEVANAGARI_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_DEVANAGARI_EXTENDED_name, &const_BLOCK_CODE_DEVANAGARI_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_DEVANAGARI_EXTENDED_name); + zend_string_release_ex(const_BLOCK_CODE_DEVANAGARI_EXTENDED_name, true); zval const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_value; ZVAL_LONG(&const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_value, UBLOCK_HANGUL_JAMO_EXTENDED_A); - zend_string *const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_HANGUL_JAMO_EXTENDED_A", sizeof("BLOCK_CODE_HANGUL_JAMO_EXTENDED_A") - 1, 1); + zend_string *const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_HANGUL_JAMO_EXTENDED_A", sizeof("BLOCK_CODE_HANGUL_JAMO_EXTENDED_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_name, &const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_name); + zend_string_release_ex(const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_A_name, true); zval const_BLOCK_CODE_JAVANESE_value; ZVAL_LONG(&const_BLOCK_CODE_JAVANESE_value, UBLOCK_JAVANESE); - zend_string *const_BLOCK_CODE_JAVANESE_name = zend_string_init_interned("BLOCK_CODE_JAVANESE", sizeof("BLOCK_CODE_JAVANESE") - 1, 1); + zend_string *const_BLOCK_CODE_JAVANESE_name = zend_string_init_interned("BLOCK_CODE_JAVANESE", sizeof("BLOCK_CODE_JAVANESE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_JAVANESE_name, &const_BLOCK_CODE_JAVANESE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_JAVANESE_name); + zend_string_release_ex(const_BLOCK_CODE_JAVANESE_name, true); zval const_BLOCK_CODE_MYANMAR_EXTENDED_A_value; ZVAL_LONG(&const_BLOCK_CODE_MYANMAR_EXTENDED_A_value, UBLOCK_MYANMAR_EXTENDED_A); - zend_string *const_BLOCK_CODE_MYANMAR_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_MYANMAR_EXTENDED_A", sizeof("BLOCK_CODE_MYANMAR_EXTENDED_A") - 1, 1); + zend_string *const_BLOCK_CODE_MYANMAR_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_MYANMAR_EXTENDED_A", sizeof("BLOCK_CODE_MYANMAR_EXTENDED_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MYANMAR_EXTENDED_A_name, &const_BLOCK_CODE_MYANMAR_EXTENDED_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MYANMAR_EXTENDED_A_name); + zend_string_release_ex(const_BLOCK_CODE_MYANMAR_EXTENDED_A_name, true); zval const_BLOCK_CODE_TAI_VIET_value; ZVAL_LONG(&const_BLOCK_CODE_TAI_VIET_value, UBLOCK_TAI_VIET); - zend_string *const_BLOCK_CODE_TAI_VIET_name = zend_string_init_interned("BLOCK_CODE_TAI_VIET", sizeof("BLOCK_CODE_TAI_VIET") - 1, 1); + zend_string *const_BLOCK_CODE_TAI_VIET_name = zend_string_init_interned("BLOCK_CODE_TAI_VIET", sizeof("BLOCK_CODE_TAI_VIET") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAI_VIET_name, &const_BLOCK_CODE_TAI_VIET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAI_VIET_name); + zend_string_release_ex(const_BLOCK_CODE_TAI_VIET_name, true); zval const_BLOCK_CODE_MEETEI_MAYEK_value; ZVAL_LONG(&const_BLOCK_CODE_MEETEI_MAYEK_value, UBLOCK_MEETEI_MAYEK); - zend_string *const_BLOCK_CODE_MEETEI_MAYEK_name = zend_string_init_interned("BLOCK_CODE_MEETEI_MAYEK", sizeof("BLOCK_CODE_MEETEI_MAYEK") - 1, 1); + zend_string *const_BLOCK_CODE_MEETEI_MAYEK_name = zend_string_init_interned("BLOCK_CODE_MEETEI_MAYEK", sizeof("BLOCK_CODE_MEETEI_MAYEK") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MEETEI_MAYEK_name, &const_BLOCK_CODE_MEETEI_MAYEK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MEETEI_MAYEK_name); + zend_string_release_ex(const_BLOCK_CODE_MEETEI_MAYEK_name, true); zval const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_value; ZVAL_LONG(&const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_value, UBLOCK_HANGUL_JAMO_EXTENDED_B); - zend_string *const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_HANGUL_JAMO_EXTENDED_B", sizeof("BLOCK_CODE_HANGUL_JAMO_EXTENDED_B") - 1, 1); + zend_string *const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_HANGUL_JAMO_EXTENDED_B", sizeof("BLOCK_CODE_HANGUL_JAMO_EXTENDED_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_name, &const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_name); + zend_string_release_ex(const_BLOCK_CODE_HANGUL_JAMO_EXTENDED_B_name, true); zval const_BLOCK_CODE_IMPERIAL_ARAMAIC_value; ZVAL_LONG(&const_BLOCK_CODE_IMPERIAL_ARAMAIC_value, UBLOCK_IMPERIAL_ARAMAIC); - zend_string *const_BLOCK_CODE_IMPERIAL_ARAMAIC_name = zend_string_init_interned("BLOCK_CODE_IMPERIAL_ARAMAIC", sizeof("BLOCK_CODE_IMPERIAL_ARAMAIC") - 1, 1); + zend_string *const_BLOCK_CODE_IMPERIAL_ARAMAIC_name = zend_string_init_interned("BLOCK_CODE_IMPERIAL_ARAMAIC", sizeof("BLOCK_CODE_IMPERIAL_ARAMAIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_IMPERIAL_ARAMAIC_name, &const_BLOCK_CODE_IMPERIAL_ARAMAIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_IMPERIAL_ARAMAIC_name); + zend_string_release_ex(const_BLOCK_CODE_IMPERIAL_ARAMAIC_name, true); zval const_BLOCK_CODE_OLD_SOUTH_ARABIAN_value; ZVAL_LONG(&const_BLOCK_CODE_OLD_SOUTH_ARABIAN_value, UBLOCK_OLD_SOUTH_ARABIAN); - zend_string *const_BLOCK_CODE_OLD_SOUTH_ARABIAN_name = zend_string_init_interned("BLOCK_CODE_OLD_SOUTH_ARABIAN", sizeof("BLOCK_CODE_OLD_SOUTH_ARABIAN") - 1, 1); + zend_string *const_BLOCK_CODE_OLD_SOUTH_ARABIAN_name = zend_string_init_interned("BLOCK_CODE_OLD_SOUTH_ARABIAN", sizeof("BLOCK_CODE_OLD_SOUTH_ARABIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OLD_SOUTH_ARABIAN_name, &const_BLOCK_CODE_OLD_SOUTH_ARABIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OLD_SOUTH_ARABIAN_name); + zend_string_release_ex(const_BLOCK_CODE_OLD_SOUTH_ARABIAN_name, true); zval const_BLOCK_CODE_AVESTAN_value; ZVAL_LONG(&const_BLOCK_CODE_AVESTAN_value, UBLOCK_AVESTAN); - zend_string *const_BLOCK_CODE_AVESTAN_name = zend_string_init_interned("BLOCK_CODE_AVESTAN", sizeof("BLOCK_CODE_AVESTAN") - 1, 1); + zend_string *const_BLOCK_CODE_AVESTAN_name = zend_string_init_interned("BLOCK_CODE_AVESTAN", sizeof("BLOCK_CODE_AVESTAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_AVESTAN_name, &const_BLOCK_CODE_AVESTAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_AVESTAN_name); + zend_string_release_ex(const_BLOCK_CODE_AVESTAN_name, true); zval const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_value; ZVAL_LONG(&const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_value, UBLOCK_INSCRIPTIONAL_PARTHIAN); - zend_string *const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_name = zend_string_init_interned("BLOCK_CODE_INSCRIPTIONAL_PARTHIAN", sizeof("BLOCK_CODE_INSCRIPTIONAL_PARTHIAN") - 1, 1); + zend_string *const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_name = zend_string_init_interned("BLOCK_CODE_INSCRIPTIONAL_PARTHIAN", sizeof("BLOCK_CODE_INSCRIPTIONAL_PARTHIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_name, &const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_name); + zend_string_release_ex(const_BLOCK_CODE_INSCRIPTIONAL_PARTHIAN_name, true); zval const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_value; ZVAL_LONG(&const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_value, UBLOCK_INSCRIPTIONAL_PAHLAVI); - zend_string *const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_name = zend_string_init_interned("BLOCK_CODE_INSCRIPTIONAL_PAHLAVI", sizeof("BLOCK_CODE_INSCRIPTIONAL_PAHLAVI") - 1, 1); + zend_string *const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_name = zend_string_init_interned("BLOCK_CODE_INSCRIPTIONAL_PAHLAVI", sizeof("BLOCK_CODE_INSCRIPTIONAL_PAHLAVI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_name, &const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_name); + zend_string_release_ex(const_BLOCK_CODE_INSCRIPTIONAL_PAHLAVI_name, true); zval const_BLOCK_CODE_OLD_TURKIC_value; ZVAL_LONG(&const_BLOCK_CODE_OLD_TURKIC_value, UBLOCK_OLD_TURKIC); - zend_string *const_BLOCK_CODE_OLD_TURKIC_name = zend_string_init_interned("BLOCK_CODE_OLD_TURKIC", sizeof("BLOCK_CODE_OLD_TURKIC") - 1, 1); + zend_string *const_BLOCK_CODE_OLD_TURKIC_name = zend_string_init_interned("BLOCK_CODE_OLD_TURKIC", sizeof("BLOCK_CODE_OLD_TURKIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OLD_TURKIC_name, &const_BLOCK_CODE_OLD_TURKIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OLD_TURKIC_name); + zend_string_release_ex(const_BLOCK_CODE_OLD_TURKIC_name, true); zval const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_value, UBLOCK_RUMI_NUMERAL_SYMBOLS); - zend_string *const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_RUMI_NUMERAL_SYMBOLS", sizeof("BLOCK_CODE_RUMI_NUMERAL_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_RUMI_NUMERAL_SYMBOLS", sizeof("BLOCK_CODE_RUMI_NUMERAL_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_name, &const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_RUMI_NUMERAL_SYMBOLS_name, true); zval const_BLOCK_CODE_KAITHI_value; ZVAL_LONG(&const_BLOCK_CODE_KAITHI_value, UBLOCK_KAITHI); - zend_string *const_BLOCK_CODE_KAITHI_name = zend_string_init_interned("BLOCK_CODE_KAITHI", sizeof("BLOCK_CODE_KAITHI") - 1, 1); + zend_string *const_BLOCK_CODE_KAITHI_name = zend_string_init_interned("BLOCK_CODE_KAITHI", sizeof("BLOCK_CODE_KAITHI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KAITHI_name, &const_BLOCK_CODE_KAITHI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KAITHI_name); + zend_string_release_ex(const_BLOCK_CODE_KAITHI_name, true); zval const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_value; ZVAL_LONG(&const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_value, UBLOCK_EGYPTIAN_HIEROGLYPHS); - zend_string *const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_name = zend_string_init_interned("BLOCK_CODE_EGYPTIAN_HIEROGLYPHS", sizeof("BLOCK_CODE_EGYPTIAN_HIEROGLYPHS") - 1, 1); + zend_string *const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_name = zend_string_init_interned("BLOCK_CODE_EGYPTIAN_HIEROGLYPHS", sizeof("BLOCK_CODE_EGYPTIAN_HIEROGLYPHS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_name, &const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_name); + zend_string_release_ex(const_BLOCK_CODE_EGYPTIAN_HIEROGLYPHS_name, true); zval const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_value, UBLOCK_ENCLOSED_ALPHANUMERIC_SUPPLEMENT); - zend_string *const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT", sizeof("BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT", sizeof("BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_name, &const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_ENCLOSED_ALPHANUMERIC_SUPPLEMENT_name, true); zval const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_value, UBLOCK_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT); - zend_string *const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT", sizeof("BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT", sizeof("BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_name, &const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_ENCLOSED_IDEOGRAPHIC_SUPPLEMENT_name, true); zval const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_value, UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C); - zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_name, &const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_C_name, true); zval const_BLOCK_CODE_MANDAIC_value; ZVAL_LONG(&const_BLOCK_CODE_MANDAIC_value, UBLOCK_MANDAIC); - zend_string *const_BLOCK_CODE_MANDAIC_name = zend_string_init_interned("BLOCK_CODE_MANDAIC", sizeof("BLOCK_CODE_MANDAIC") - 1, 1); + zend_string *const_BLOCK_CODE_MANDAIC_name = zend_string_init_interned("BLOCK_CODE_MANDAIC", sizeof("BLOCK_CODE_MANDAIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MANDAIC_name, &const_BLOCK_CODE_MANDAIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MANDAIC_name); + zend_string_release_ex(const_BLOCK_CODE_MANDAIC_name, true); zval const_BLOCK_CODE_BATAK_value; ZVAL_LONG(&const_BLOCK_CODE_BATAK_value, UBLOCK_BATAK); - zend_string *const_BLOCK_CODE_BATAK_name = zend_string_init_interned("BLOCK_CODE_BATAK", sizeof("BLOCK_CODE_BATAK") - 1, 1); + zend_string *const_BLOCK_CODE_BATAK_name = zend_string_init_interned("BLOCK_CODE_BATAK", sizeof("BLOCK_CODE_BATAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BATAK_name, &const_BLOCK_CODE_BATAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BATAK_name); + zend_string_release_ex(const_BLOCK_CODE_BATAK_name, true); zval const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_value; ZVAL_LONG(&const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_value, UBLOCK_ETHIOPIC_EXTENDED_A); - zend_string *const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC_EXTENDED_A", sizeof("BLOCK_CODE_ETHIOPIC_EXTENDED_A") - 1, 1); + zend_string *const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_ETHIOPIC_EXTENDED_A", sizeof("BLOCK_CODE_ETHIOPIC_EXTENDED_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_name, &const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_name); + zend_string_release_ex(const_BLOCK_CODE_ETHIOPIC_EXTENDED_A_name, true); zval const_BLOCK_CODE_BRAHMI_value; ZVAL_LONG(&const_BLOCK_CODE_BRAHMI_value, UBLOCK_BRAHMI); - zend_string *const_BLOCK_CODE_BRAHMI_name = zend_string_init_interned("BLOCK_CODE_BRAHMI", sizeof("BLOCK_CODE_BRAHMI") - 1, 1); + zend_string *const_BLOCK_CODE_BRAHMI_name = zend_string_init_interned("BLOCK_CODE_BRAHMI", sizeof("BLOCK_CODE_BRAHMI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BRAHMI_name, &const_BLOCK_CODE_BRAHMI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BRAHMI_name); + zend_string_release_ex(const_BLOCK_CODE_BRAHMI_name, true); zval const_BLOCK_CODE_BAMUM_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_BAMUM_SUPPLEMENT_value, UBLOCK_BAMUM_SUPPLEMENT); - zend_string *const_BLOCK_CODE_BAMUM_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_BAMUM_SUPPLEMENT", sizeof("BLOCK_CODE_BAMUM_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_BAMUM_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_BAMUM_SUPPLEMENT", sizeof("BLOCK_CODE_BAMUM_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BAMUM_SUPPLEMENT_name, &const_BLOCK_CODE_BAMUM_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BAMUM_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_BAMUM_SUPPLEMENT_name, true); zval const_BLOCK_CODE_KANA_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_KANA_SUPPLEMENT_value, UBLOCK_KANA_SUPPLEMENT); - zend_string *const_BLOCK_CODE_KANA_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_KANA_SUPPLEMENT", sizeof("BLOCK_CODE_KANA_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_KANA_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_KANA_SUPPLEMENT", sizeof("BLOCK_CODE_KANA_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KANA_SUPPLEMENT_name, &const_BLOCK_CODE_KANA_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KANA_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_KANA_SUPPLEMENT_name, true); zval const_BLOCK_CODE_PLAYING_CARDS_value; ZVAL_LONG(&const_BLOCK_CODE_PLAYING_CARDS_value, UBLOCK_PLAYING_CARDS); - zend_string *const_BLOCK_CODE_PLAYING_CARDS_name = zend_string_init_interned("BLOCK_CODE_PLAYING_CARDS", sizeof("BLOCK_CODE_PLAYING_CARDS") - 1, 1); + zend_string *const_BLOCK_CODE_PLAYING_CARDS_name = zend_string_init_interned("BLOCK_CODE_PLAYING_CARDS", sizeof("BLOCK_CODE_PLAYING_CARDS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PLAYING_CARDS_name, &const_BLOCK_CODE_PLAYING_CARDS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PLAYING_CARDS_name); + zend_string_release_ex(const_BLOCK_CODE_PLAYING_CARDS_name, true); zval const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_value; ZVAL_LONG(&const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_value, UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS); - zend_string *const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS", sizeof("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS") - 1, 1); + zend_string *const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_name = zend_string_init_interned("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS", sizeof("BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_name, &const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_name); + zend_string_release_ex(const_BLOCK_CODE_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS_name, true); zval const_BLOCK_CODE_EMOTICONS_value; ZVAL_LONG(&const_BLOCK_CODE_EMOTICONS_value, UBLOCK_EMOTICONS); - zend_string *const_BLOCK_CODE_EMOTICONS_name = zend_string_init_interned("BLOCK_CODE_EMOTICONS", sizeof("BLOCK_CODE_EMOTICONS") - 1, 1); + zend_string *const_BLOCK_CODE_EMOTICONS_name = zend_string_init_interned("BLOCK_CODE_EMOTICONS", sizeof("BLOCK_CODE_EMOTICONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_EMOTICONS_name, &const_BLOCK_CODE_EMOTICONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_EMOTICONS_name); + zend_string_release_ex(const_BLOCK_CODE_EMOTICONS_name, true); zval const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_value, UBLOCK_TRANSPORT_AND_MAP_SYMBOLS); - zend_string *const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS", sizeof("BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS", sizeof("BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_name, &const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_TRANSPORT_AND_MAP_SYMBOLS_name, true); zval const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_value, UBLOCK_ALCHEMICAL_SYMBOLS); - zend_string *const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_ALCHEMICAL_SYMBOLS", sizeof("BLOCK_CODE_ALCHEMICAL_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_ALCHEMICAL_SYMBOLS", sizeof("BLOCK_CODE_ALCHEMICAL_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_name, &const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_ALCHEMICAL_SYMBOLS_name, true); zval const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_value; ZVAL_LONG(&const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_value, UBLOCK_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D); - zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D") - 1, 1); + zend_string *const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_name = zend_string_init_interned("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D", sizeof("BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_name, &const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_name); + zend_string_release_ex(const_BLOCK_CODE_CJK_UNIFIED_IDEOGRAPHS_EXTENSION_D_name, true); zval const_BLOCK_CODE_ARABIC_EXTENDED_A_value; ZVAL_LONG(&const_BLOCK_CODE_ARABIC_EXTENDED_A_value, UBLOCK_ARABIC_EXTENDED_A); - zend_string *const_BLOCK_CODE_ARABIC_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_ARABIC_EXTENDED_A", sizeof("BLOCK_CODE_ARABIC_EXTENDED_A") - 1, 1); + zend_string *const_BLOCK_CODE_ARABIC_EXTENDED_A_name = zend_string_init_interned("BLOCK_CODE_ARABIC_EXTENDED_A", sizeof("BLOCK_CODE_ARABIC_EXTENDED_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARABIC_EXTENDED_A_name, &const_BLOCK_CODE_ARABIC_EXTENDED_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARABIC_EXTENDED_A_name); + zend_string_release_ex(const_BLOCK_CODE_ARABIC_EXTENDED_A_name, true); zval const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_value; ZVAL_LONG(&const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_value, UBLOCK_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS); - zend_string *const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS", sizeof("BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS") - 1, 1); + zend_string *const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_name = zend_string_init_interned("BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS", sizeof("BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_name, &const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_name); + zend_string_release_ex(const_BLOCK_CODE_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS_name, true); zval const_BLOCK_CODE_CHAKMA_value; ZVAL_LONG(&const_BLOCK_CODE_CHAKMA_value, UBLOCK_CHAKMA); - zend_string *const_BLOCK_CODE_CHAKMA_name = zend_string_init_interned("BLOCK_CODE_CHAKMA", sizeof("BLOCK_CODE_CHAKMA") - 1, 1); + zend_string *const_BLOCK_CODE_CHAKMA_name = zend_string_init_interned("BLOCK_CODE_CHAKMA", sizeof("BLOCK_CODE_CHAKMA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CHAKMA_name, &const_BLOCK_CODE_CHAKMA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CHAKMA_name); + zend_string_release_ex(const_BLOCK_CODE_CHAKMA_name, true); zval const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_value; ZVAL_LONG(&const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_value, UBLOCK_MEETEI_MAYEK_EXTENSIONS); - zend_string *const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS", sizeof("BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS") - 1, 1); + zend_string *const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_name = zend_string_init_interned("BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS", sizeof("BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_name, &const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_name); + zend_string_release_ex(const_BLOCK_CODE_MEETEI_MAYEK_EXTENSIONS_name, true); zval const_BLOCK_CODE_MEROITIC_CURSIVE_value; ZVAL_LONG(&const_BLOCK_CODE_MEROITIC_CURSIVE_value, UBLOCK_MEROITIC_CURSIVE); - zend_string *const_BLOCK_CODE_MEROITIC_CURSIVE_name = zend_string_init_interned("BLOCK_CODE_MEROITIC_CURSIVE", sizeof("BLOCK_CODE_MEROITIC_CURSIVE") - 1, 1); + zend_string *const_BLOCK_CODE_MEROITIC_CURSIVE_name = zend_string_init_interned("BLOCK_CODE_MEROITIC_CURSIVE", sizeof("BLOCK_CODE_MEROITIC_CURSIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MEROITIC_CURSIVE_name, &const_BLOCK_CODE_MEROITIC_CURSIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MEROITIC_CURSIVE_name); + zend_string_release_ex(const_BLOCK_CODE_MEROITIC_CURSIVE_name, true); zval const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_value; ZVAL_LONG(&const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_value, UBLOCK_MEROITIC_HIEROGLYPHS); - zend_string *const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_name = zend_string_init_interned("BLOCK_CODE_MEROITIC_HIEROGLYPHS", sizeof("BLOCK_CODE_MEROITIC_HIEROGLYPHS") - 1, 1); + zend_string *const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_name = zend_string_init_interned("BLOCK_CODE_MEROITIC_HIEROGLYPHS", sizeof("BLOCK_CODE_MEROITIC_HIEROGLYPHS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_name, &const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_name); + zend_string_release_ex(const_BLOCK_CODE_MEROITIC_HIEROGLYPHS_name, true); zval const_BLOCK_CODE_MIAO_value; ZVAL_LONG(&const_BLOCK_CODE_MIAO_value, UBLOCK_MIAO); - zend_string *const_BLOCK_CODE_MIAO_name = zend_string_init_interned("BLOCK_CODE_MIAO", sizeof("BLOCK_CODE_MIAO") - 1, 1); + zend_string *const_BLOCK_CODE_MIAO_name = zend_string_init_interned("BLOCK_CODE_MIAO", sizeof("BLOCK_CODE_MIAO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MIAO_name, &const_BLOCK_CODE_MIAO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MIAO_name); + zend_string_release_ex(const_BLOCK_CODE_MIAO_name, true); zval const_BLOCK_CODE_SHARADA_value; ZVAL_LONG(&const_BLOCK_CODE_SHARADA_value, UBLOCK_SHARADA); - zend_string *const_BLOCK_CODE_SHARADA_name = zend_string_init_interned("BLOCK_CODE_SHARADA", sizeof("BLOCK_CODE_SHARADA") - 1, 1); + zend_string *const_BLOCK_CODE_SHARADA_name = zend_string_init_interned("BLOCK_CODE_SHARADA", sizeof("BLOCK_CODE_SHARADA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SHARADA_name, &const_BLOCK_CODE_SHARADA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SHARADA_name); + zend_string_release_ex(const_BLOCK_CODE_SHARADA_name, true); zval const_BLOCK_CODE_SORA_SOMPENG_value; ZVAL_LONG(&const_BLOCK_CODE_SORA_SOMPENG_value, UBLOCK_SORA_SOMPENG); - zend_string *const_BLOCK_CODE_SORA_SOMPENG_name = zend_string_init_interned("BLOCK_CODE_SORA_SOMPENG", sizeof("BLOCK_CODE_SORA_SOMPENG") - 1, 1); + zend_string *const_BLOCK_CODE_SORA_SOMPENG_name = zend_string_init_interned("BLOCK_CODE_SORA_SOMPENG", sizeof("BLOCK_CODE_SORA_SOMPENG") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SORA_SOMPENG_name, &const_BLOCK_CODE_SORA_SOMPENG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SORA_SOMPENG_name); + zend_string_release_ex(const_BLOCK_CODE_SORA_SOMPENG_name, true); zval const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_value; ZVAL_LONG(&const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_value, UBLOCK_SUNDANESE_SUPPLEMENT); - zend_string *const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_SUNDANESE_SUPPLEMENT", sizeof("BLOCK_CODE_SUNDANESE_SUPPLEMENT") - 1, 1); + zend_string *const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_name = zend_string_init_interned("BLOCK_CODE_SUNDANESE_SUPPLEMENT", sizeof("BLOCK_CODE_SUNDANESE_SUPPLEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_name, &const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_name); + zend_string_release_ex(const_BLOCK_CODE_SUNDANESE_SUPPLEMENT_name, true); zval const_BLOCK_CODE_TAKRI_value; ZVAL_LONG(&const_BLOCK_CODE_TAKRI_value, UBLOCK_TAKRI); - zend_string *const_BLOCK_CODE_TAKRI_name = zend_string_init_interned("BLOCK_CODE_TAKRI", sizeof("BLOCK_CODE_TAKRI") - 1, 1); + zend_string *const_BLOCK_CODE_TAKRI_name = zend_string_init_interned("BLOCK_CODE_TAKRI", sizeof("BLOCK_CODE_TAKRI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TAKRI_name, &const_BLOCK_CODE_TAKRI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TAKRI_name); + zend_string_release_ex(const_BLOCK_CODE_TAKRI_name, true); zval const_BLOCK_CODE_BASSA_VAH_value; ZVAL_LONG(&const_BLOCK_CODE_BASSA_VAH_value, UBLOCK_BASSA_VAH); - zend_string *const_BLOCK_CODE_BASSA_VAH_name = zend_string_init_interned("BLOCK_CODE_BASSA_VAH", sizeof("BLOCK_CODE_BASSA_VAH") - 1, 1); + zend_string *const_BLOCK_CODE_BASSA_VAH_name = zend_string_init_interned("BLOCK_CODE_BASSA_VAH", sizeof("BLOCK_CODE_BASSA_VAH") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_BASSA_VAH_name, &const_BLOCK_CODE_BASSA_VAH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_BASSA_VAH_name); + zend_string_release_ex(const_BLOCK_CODE_BASSA_VAH_name, true); zval const_BLOCK_CODE_CAUCASIAN_ALBANIAN_value; ZVAL_LONG(&const_BLOCK_CODE_CAUCASIAN_ALBANIAN_value, UBLOCK_CAUCASIAN_ALBANIAN); - zend_string *const_BLOCK_CODE_CAUCASIAN_ALBANIAN_name = zend_string_init_interned("BLOCK_CODE_CAUCASIAN_ALBANIAN", sizeof("BLOCK_CODE_CAUCASIAN_ALBANIAN") - 1, 1); + zend_string *const_BLOCK_CODE_CAUCASIAN_ALBANIAN_name = zend_string_init_interned("BLOCK_CODE_CAUCASIAN_ALBANIAN", sizeof("BLOCK_CODE_CAUCASIAN_ALBANIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_CAUCASIAN_ALBANIAN_name, &const_BLOCK_CODE_CAUCASIAN_ALBANIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_CAUCASIAN_ALBANIAN_name); + zend_string_release_ex(const_BLOCK_CODE_CAUCASIAN_ALBANIAN_name, true); zval const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_value; ZVAL_LONG(&const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_value, UBLOCK_COPTIC_EPACT_NUMBERS); - zend_string *const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_COPTIC_EPACT_NUMBERS", sizeof("BLOCK_CODE_COPTIC_EPACT_NUMBERS") - 1, 1); + zend_string *const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_COPTIC_EPACT_NUMBERS", sizeof("BLOCK_CODE_COPTIC_EPACT_NUMBERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_name, &const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_name); + zend_string_release_ex(const_BLOCK_CODE_COPTIC_EPACT_NUMBERS_name, true); zval const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_value; ZVAL_LONG(&const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_value, UBLOCK_COMBINING_DIACRITICAL_MARKS_EXTENDED); - zend_string *const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED", sizeof("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED") - 1, 1); + zend_string *const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED", sizeof("BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_name, &const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_name); + zend_string_release_ex(const_BLOCK_CODE_COMBINING_DIACRITICAL_MARKS_EXTENDED_name, true); zval const_BLOCK_CODE_DUPLOYAN_value; ZVAL_LONG(&const_BLOCK_CODE_DUPLOYAN_value, UBLOCK_DUPLOYAN); - zend_string *const_BLOCK_CODE_DUPLOYAN_name = zend_string_init_interned("BLOCK_CODE_DUPLOYAN", sizeof("BLOCK_CODE_DUPLOYAN") - 1, 1); + zend_string *const_BLOCK_CODE_DUPLOYAN_name = zend_string_init_interned("BLOCK_CODE_DUPLOYAN", sizeof("BLOCK_CODE_DUPLOYAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_DUPLOYAN_name, &const_BLOCK_CODE_DUPLOYAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_DUPLOYAN_name); + zend_string_release_ex(const_BLOCK_CODE_DUPLOYAN_name, true); zval const_BLOCK_CODE_ELBASAN_value; ZVAL_LONG(&const_BLOCK_CODE_ELBASAN_value, UBLOCK_ELBASAN); - zend_string *const_BLOCK_CODE_ELBASAN_name = zend_string_init_interned("BLOCK_CODE_ELBASAN", sizeof("BLOCK_CODE_ELBASAN") - 1, 1); + zend_string *const_BLOCK_CODE_ELBASAN_name = zend_string_init_interned("BLOCK_CODE_ELBASAN", sizeof("BLOCK_CODE_ELBASAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ELBASAN_name, &const_BLOCK_CODE_ELBASAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ELBASAN_name); + zend_string_release_ex(const_BLOCK_CODE_ELBASAN_name, true); zval const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_value; ZVAL_LONG(&const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_value, UBLOCK_GEOMETRIC_SHAPES_EXTENDED); - zend_string *const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED", sizeof("BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED") - 1, 1); + zend_string *const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_name = zend_string_init_interned("BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED", sizeof("BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_name, &const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_name); + zend_string_release_ex(const_BLOCK_CODE_GEOMETRIC_SHAPES_EXTENDED_name, true); zval const_BLOCK_CODE_GRANTHA_value; ZVAL_LONG(&const_BLOCK_CODE_GRANTHA_value, UBLOCK_GRANTHA); - zend_string *const_BLOCK_CODE_GRANTHA_name = zend_string_init_interned("BLOCK_CODE_GRANTHA", sizeof("BLOCK_CODE_GRANTHA") - 1, 1); + zend_string *const_BLOCK_CODE_GRANTHA_name = zend_string_init_interned("BLOCK_CODE_GRANTHA", sizeof("BLOCK_CODE_GRANTHA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_GRANTHA_name, &const_BLOCK_CODE_GRANTHA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_GRANTHA_name); + zend_string_release_ex(const_BLOCK_CODE_GRANTHA_name, true); zval const_BLOCK_CODE_KHOJKI_value; ZVAL_LONG(&const_BLOCK_CODE_KHOJKI_value, UBLOCK_KHOJKI); - zend_string *const_BLOCK_CODE_KHOJKI_name = zend_string_init_interned("BLOCK_CODE_KHOJKI", sizeof("BLOCK_CODE_KHOJKI") - 1, 1); + zend_string *const_BLOCK_CODE_KHOJKI_name = zend_string_init_interned("BLOCK_CODE_KHOJKI", sizeof("BLOCK_CODE_KHOJKI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KHOJKI_name, &const_BLOCK_CODE_KHOJKI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KHOJKI_name); + zend_string_release_ex(const_BLOCK_CODE_KHOJKI_name, true); zval const_BLOCK_CODE_KHUDAWADI_value; ZVAL_LONG(&const_BLOCK_CODE_KHUDAWADI_value, UBLOCK_KHUDAWADI); - zend_string *const_BLOCK_CODE_KHUDAWADI_name = zend_string_init_interned("BLOCK_CODE_KHUDAWADI", sizeof("BLOCK_CODE_KHUDAWADI") - 1, 1); + zend_string *const_BLOCK_CODE_KHUDAWADI_name = zend_string_init_interned("BLOCK_CODE_KHUDAWADI", sizeof("BLOCK_CODE_KHUDAWADI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_KHUDAWADI_name, &const_BLOCK_CODE_KHUDAWADI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_KHUDAWADI_name); + zend_string_release_ex(const_BLOCK_CODE_KHUDAWADI_name, true); zval const_BLOCK_CODE_LATIN_EXTENDED_E_value; ZVAL_LONG(&const_BLOCK_CODE_LATIN_EXTENDED_E_value, UBLOCK_LATIN_EXTENDED_E); - zend_string *const_BLOCK_CODE_LATIN_EXTENDED_E_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_E", sizeof("BLOCK_CODE_LATIN_EXTENDED_E") - 1, 1); + zend_string *const_BLOCK_CODE_LATIN_EXTENDED_E_name = zend_string_init_interned("BLOCK_CODE_LATIN_EXTENDED_E", sizeof("BLOCK_CODE_LATIN_EXTENDED_E") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LATIN_EXTENDED_E_name, &const_BLOCK_CODE_LATIN_EXTENDED_E_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LATIN_EXTENDED_E_name); + zend_string_release_ex(const_BLOCK_CODE_LATIN_EXTENDED_E_name, true); zval const_BLOCK_CODE_LINEAR_A_value; ZVAL_LONG(&const_BLOCK_CODE_LINEAR_A_value, UBLOCK_LINEAR_A); - zend_string *const_BLOCK_CODE_LINEAR_A_name = zend_string_init_interned("BLOCK_CODE_LINEAR_A", sizeof("BLOCK_CODE_LINEAR_A") - 1, 1); + zend_string *const_BLOCK_CODE_LINEAR_A_name = zend_string_init_interned("BLOCK_CODE_LINEAR_A", sizeof("BLOCK_CODE_LINEAR_A") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_LINEAR_A_name, &const_BLOCK_CODE_LINEAR_A_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_LINEAR_A_name); + zend_string_release_ex(const_BLOCK_CODE_LINEAR_A_name, true); zval const_BLOCK_CODE_MAHAJANI_value; ZVAL_LONG(&const_BLOCK_CODE_MAHAJANI_value, UBLOCK_MAHAJANI); - zend_string *const_BLOCK_CODE_MAHAJANI_name = zend_string_init_interned("BLOCK_CODE_MAHAJANI", sizeof("BLOCK_CODE_MAHAJANI") - 1, 1); + zend_string *const_BLOCK_CODE_MAHAJANI_name = zend_string_init_interned("BLOCK_CODE_MAHAJANI", sizeof("BLOCK_CODE_MAHAJANI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MAHAJANI_name, &const_BLOCK_CODE_MAHAJANI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MAHAJANI_name); + zend_string_release_ex(const_BLOCK_CODE_MAHAJANI_name, true); zval const_BLOCK_CODE_MANICHAEAN_value; ZVAL_LONG(&const_BLOCK_CODE_MANICHAEAN_value, UBLOCK_MANICHAEAN); - zend_string *const_BLOCK_CODE_MANICHAEAN_name = zend_string_init_interned("BLOCK_CODE_MANICHAEAN", sizeof("BLOCK_CODE_MANICHAEAN") - 1, 1); + zend_string *const_BLOCK_CODE_MANICHAEAN_name = zend_string_init_interned("BLOCK_CODE_MANICHAEAN", sizeof("BLOCK_CODE_MANICHAEAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MANICHAEAN_name, &const_BLOCK_CODE_MANICHAEAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MANICHAEAN_name); + zend_string_release_ex(const_BLOCK_CODE_MANICHAEAN_name, true); zval const_BLOCK_CODE_MENDE_KIKAKUI_value; ZVAL_LONG(&const_BLOCK_CODE_MENDE_KIKAKUI_value, UBLOCK_MENDE_KIKAKUI); - zend_string *const_BLOCK_CODE_MENDE_KIKAKUI_name = zend_string_init_interned("BLOCK_CODE_MENDE_KIKAKUI", sizeof("BLOCK_CODE_MENDE_KIKAKUI") - 1, 1); + zend_string *const_BLOCK_CODE_MENDE_KIKAKUI_name = zend_string_init_interned("BLOCK_CODE_MENDE_KIKAKUI", sizeof("BLOCK_CODE_MENDE_KIKAKUI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MENDE_KIKAKUI_name, &const_BLOCK_CODE_MENDE_KIKAKUI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MENDE_KIKAKUI_name); + zend_string_release_ex(const_BLOCK_CODE_MENDE_KIKAKUI_name, true); zval const_BLOCK_CODE_MODI_value; ZVAL_LONG(&const_BLOCK_CODE_MODI_value, UBLOCK_MODI); - zend_string *const_BLOCK_CODE_MODI_name = zend_string_init_interned("BLOCK_CODE_MODI", sizeof("BLOCK_CODE_MODI") - 1, 1); + zend_string *const_BLOCK_CODE_MODI_name = zend_string_init_interned("BLOCK_CODE_MODI", sizeof("BLOCK_CODE_MODI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MODI_name, &const_BLOCK_CODE_MODI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MODI_name); + zend_string_release_ex(const_BLOCK_CODE_MODI_name, true); zval const_BLOCK_CODE_MRO_value; ZVAL_LONG(&const_BLOCK_CODE_MRO_value, UBLOCK_MRO); - zend_string *const_BLOCK_CODE_MRO_name = zend_string_init_interned("BLOCK_CODE_MRO", sizeof("BLOCK_CODE_MRO") - 1, 1); + zend_string *const_BLOCK_CODE_MRO_name = zend_string_init_interned("BLOCK_CODE_MRO", sizeof("BLOCK_CODE_MRO") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MRO_name, &const_BLOCK_CODE_MRO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MRO_name); + zend_string_release_ex(const_BLOCK_CODE_MRO_name, true); zval const_BLOCK_CODE_MYANMAR_EXTENDED_B_value; ZVAL_LONG(&const_BLOCK_CODE_MYANMAR_EXTENDED_B_value, UBLOCK_MYANMAR_EXTENDED_B); - zend_string *const_BLOCK_CODE_MYANMAR_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_MYANMAR_EXTENDED_B", sizeof("BLOCK_CODE_MYANMAR_EXTENDED_B") - 1, 1); + zend_string *const_BLOCK_CODE_MYANMAR_EXTENDED_B_name = zend_string_init_interned("BLOCK_CODE_MYANMAR_EXTENDED_B", sizeof("BLOCK_CODE_MYANMAR_EXTENDED_B") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_MYANMAR_EXTENDED_B_name, &const_BLOCK_CODE_MYANMAR_EXTENDED_B_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_MYANMAR_EXTENDED_B_name); + zend_string_release_ex(const_BLOCK_CODE_MYANMAR_EXTENDED_B_name, true); zval const_BLOCK_CODE_NABATAEAN_value; ZVAL_LONG(&const_BLOCK_CODE_NABATAEAN_value, UBLOCK_NABATAEAN); - zend_string *const_BLOCK_CODE_NABATAEAN_name = zend_string_init_interned("BLOCK_CODE_NABATAEAN", sizeof("BLOCK_CODE_NABATAEAN") - 1, 1); + zend_string *const_BLOCK_CODE_NABATAEAN_name = zend_string_init_interned("BLOCK_CODE_NABATAEAN", sizeof("BLOCK_CODE_NABATAEAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_NABATAEAN_name, &const_BLOCK_CODE_NABATAEAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_NABATAEAN_name); + zend_string_release_ex(const_BLOCK_CODE_NABATAEAN_name, true); zval const_BLOCK_CODE_OLD_NORTH_ARABIAN_value; ZVAL_LONG(&const_BLOCK_CODE_OLD_NORTH_ARABIAN_value, UBLOCK_OLD_NORTH_ARABIAN); - zend_string *const_BLOCK_CODE_OLD_NORTH_ARABIAN_name = zend_string_init_interned("BLOCK_CODE_OLD_NORTH_ARABIAN", sizeof("BLOCK_CODE_OLD_NORTH_ARABIAN") - 1, 1); + zend_string *const_BLOCK_CODE_OLD_NORTH_ARABIAN_name = zend_string_init_interned("BLOCK_CODE_OLD_NORTH_ARABIAN", sizeof("BLOCK_CODE_OLD_NORTH_ARABIAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OLD_NORTH_ARABIAN_name, &const_BLOCK_CODE_OLD_NORTH_ARABIAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OLD_NORTH_ARABIAN_name); + zend_string_release_ex(const_BLOCK_CODE_OLD_NORTH_ARABIAN_name, true); zval const_BLOCK_CODE_OLD_PERMIC_value; ZVAL_LONG(&const_BLOCK_CODE_OLD_PERMIC_value, UBLOCK_OLD_PERMIC); - zend_string *const_BLOCK_CODE_OLD_PERMIC_name = zend_string_init_interned("BLOCK_CODE_OLD_PERMIC", sizeof("BLOCK_CODE_OLD_PERMIC") - 1, 1); + zend_string *const_BLOCK_CODE_OLD_PERMIC_name = zend_string_init_interned("BLOCK_CODE_OLD_PERMIC", sizeof("BLOCK_CODE_OLD_PERMIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_OLD_PERMIC_name, &const_BLOCK_CODE_OLD_PERMIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_OLD_PERMIC_name); + zend_string_release_ex(const_BLOCK_CODE_OLD_PERMIC_name, true); zval const_BLOCK_CODE_ORNAMENTAL_DINGBATS_value; ZVAL_LONG(&const_BLOCK_CODE_ORNAMENTAL_DINGBATS_value, UBLOCK_ORNAMENTAL_DINGBATS); - zend_string *const_BLOCK_CODE_ORNAMENTAL_DINGBATS_name = zend_string_init_interned("BLOCK_CODE_ORNAMENTAL_DINGBATS", sizeof("BLOCK_CODE_ORNAMENTAL_DINGBATS") - 1, 1); + zend_string *const_BLOCK_CODE_ORNAMENTAL_DINGBATS_name = zend_string_init_interned("BLOCK_CODE_ORNAMENTAL_DINGBATS", sizeof("BLOCK_CODE_ORNAMENTAL_DINGBATS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_ORNAMENTAL_DINGBATS_name, &const_BLOCK_CODE_ORNAMENTAL_DINGBATS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_ORNAMENTAL_DINGBATS_name); + zend_string_release_ex(const_BLOCK_CODE_ORNAMENTAL_DINGBATS_name, true); zval const_BLOCK_CODE_PAHAWH_HMONG_value; ZVAL_LONG(&const_BLOCK_CODE_PAHAWH_HMONG_value, UBLOCK_PAHAWH_HMONG); - zend_string *const_BLOCK_CODE_PAHAWH_HMONG_name = zend_string_init_interned("BLOCK_CODE_PAHAWH_HMONG", sizeof("BLOCK_CODE_PAHAWH_HMONG") - 1, 1); + zend_string *const_BLOCK_CODE_PAHAWH_HMONG_name = zend_string_init_interned("BLOCK_CODE_PAHAWH_HMONG", sizeof("BLOCK_CODE_PAHAWH_HMONG") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PAHAWH_HMONG_name, &const_BLOCK_CODE_PAHAWH_HMONG_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PAHAWH_HMONG_name); + zend_string_release_ex(const_BLOCK_CODE_PAHAWH_HMONG_name, true); zval const_BLOCK_CODE_PALMYRENE_value; ZVAL_LONG(&const_BLOCK_CODE_PALMYRENE_value, UBLOCK_PALMYRENE); - zend_string *const_BLOCK_CODE_PALMYRENE_name = zend_string_init_interned("BLOCK_CODE_PALMYRENE", sizeof("BLOCK_CODE_PALMYRENE") - 1, 1); + zend_string *const_BLOCK_CODE_PALMYRENE_name = zend_string_init_interned("BLOCK_CODE_PALMYRENE", sizeof("BLOCK_CODE_PALMYRENE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PALMYRENE_name, &const_BLOCK_CODE_PALMYRENE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PALMYRENE_name); + zend_string_release_ex(const_BLOCK_CODE_PALMYRENE_name, true); zval const_BLOCK_CODE_PAU_CIN_HAU_value; ZVAL_LONG(&const_BLOCK_CODE_PAU_CIN_HAU_value, UBLOCK_PAU_CIN_HAU); - zend_string *const_BLOCK_CODE_PAU_CIN_HAU_name = zend_string_init_interned("BLOCK_CODE_PAU_CIN_HAU", sizeof("BLOCK_CODE_PAU_CIN_HAU") - 1, 1); + zend_string *const_BLOCK_CODE_PAU_CIN_HAU_name = zend_string_init_interned("BLOCK_CODE_PAU_CIN_HAU", sizeof("BLOCK_CODE_PAU_CIN_HAU") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PAU_CIN_HAU_name, &const_BLOCK_CODE_PAU_CIN_HAU_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PAU_CIN_HAU_name); + zend_string_release_ex(const_BLOCK_CODE_PAU_CIN_HAU_name, true); zval const_BLOCK_CODE_PSALTER_PAHLAVI_value; ZVAL_LONG(&const_BLOCK_CODE_PSALTER_PAHLAVI_value, UBLOCK_PSALTER_PAHLAVI); - zend_string *const_BLOCK_CODE_PSALTER_PAHLAVI_name = zend_string_init_interned("BLOCK_CODE_PSALTER_PAHLAVI", sizeof("BLOCK_CODE_PSALTER_PAHLAVI") - 1, 1); + zend_string *const_BLOCK_CODE_PSALTER_PAHLAVI_name = zend_string_init_interned("BLOCK_CODE_PSALTER_PAHLAVI", sizeof("BLOCK_CODE_PSALTER_PAHLAVI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_PSALTER_PAHLAVI_name, &const_BLOCK_CODE_PSALTER_PAHLAVI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_PSALTER_PAHLAVI_name); + zend_string_release_ex(const_BLOCK_CODE_PSALTER_PAHLAVI_name, true); zval const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_value; ZVAL_LONG(&const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_value, UBLOCK_SHORTHAND_FORMAT_CONTROLS); - zend_string *const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_name = zend_string_init_interned("BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS", sizeof("BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS") - 1, 1); + zend_string *const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_name = zend_string_init_interned("BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS", sizeof("BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_name, &const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_name); + zend_string_release_ex(const_BLOCK_CODE_SHORTHAND_FORMAT_CONTROLS_name, true); zval const_BLOCK_CODE_SIDDHAM_value; ZVAL_LONG(&const_BLOCK_CODE_SIDDHAM_value, UBLOCK_SIDDHAM); - zend_string *const_BLOCK_CODE_SIDDHAM_name = zend_string_init_interned("BLOCK_CODE_SIDDHAM", sizeof("BLOCK_CODE_SIDDHAM") - 1, 1); + zend_string *const_BLOCK_CODE_SIDDHAM_name = zend_string_init_interned("BLOCK_CODE_SIDDHAM", sizeof("BLOCK_CODE_SIDDHAM") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SIDDHAM_name, &const_BLOCK_CODE_SIDDHAM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SIDDHAM_name); + zend_string_release_ex(const_BLOCK_CODE_SIDDHAM_name, true); zval const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_value; ZVAL_LONG(&const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_value, UBLOCK_SINHALA_ARCHAIC_NUMBERS); - zend_string *const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS", sizeof("BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS") - 1, 1); + zend_string *const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_name = zend_string_init_interned("BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS", sizeof("BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_name, &const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_name); + zend_string_release_ex(const_BLOCK_CODE_SINHALA_ARCHAIC_NUMBERS_name, true); zval const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_value; ZVAL_LONG(&const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_value, UBLOCK_SUPPLEMENTAL_ARROWS_C); - zend_string *const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_ARROWS_C", sizeof("BLOCK_CODE_SUPPLEMENTAL_ARROWS_C") - 1, 1); + zend_string *const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_name = zend_string_init_interned("BLOCK_CODE_SUPPLEMENTAL_ARROWS_C", sizeof("BLOCK_CODE_SUPPLEMENTAL_ARROWS_C") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_name, &const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_name); + zend_string_release_ex(const_BLOCK_CODE_SUPPLEMENTAL_ARROWS_C_name, true); zval const_BLOCK_CODE_TIRHUTA_value; ZVAL_LONG(&const_BLOCK_CODE_TIRHUTA_value, UBLOCK_TIRHUTA); - zend_string *const_BLOCK_CODE_TIRHUTA_name = zend_string_init_interned("BLOCK_CODE_TIRHUTA", sizeof("BLOCK_CODE_TIRHUTA") - 1, 1); + zend_string *const_BLOCK_CODE_TIRHUTA_name = zend_string_init_interned("BLOCK_CODE_TIRHUTA", sizeof("BLOCK_CODE_TIRHUTA") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_TIRHUTA_name, &const_BLOCK_CODE_TIRHUTA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_TIRHUTA_name); + zend_string_release_ex(const_BLOCK_CODE_TIRHUTA_name, true); zval const_BLOCK_CODE_WARANG_CITI_value; ZVAL_LONG(&const_BLOCK_CODE_WARANG_CITI_value, UBLOCK_WARANG_CITI); - zend_string *const_BLOCK_CODE_WARANG_CITI_name = zend_string_init_interned("BLOCK_CODE_WARANG_CITI", sizeof("BLOCK_CODE_WARANG_CITI") - 1, 1); + zend_string *const_BLOCK_CODE_WARANG_CITI_name = zend_string_init_interned("BLOCK_CODE_WARANG_CITI", sizeof("BLOCK_CODE_WARANG_CITI") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_WARANG_CITI_name, &const_BLOCK_CODE_WARANG_CITI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_WARANG_CITI_name); + zend_string_release_ex(const_BLOCK_CODE_WARANG_CITI_name, true); zval const_BLOCK_CODE_COUNT_value; ZVAL_LONG(&const_BLOCK_CODE_COUNT_value, UBLOCK_COUNT); - zend_string *const_BLOCK_CODE_COUNT_name = zend_string_init_interned("BLOCK_CODE_COUNT", sizeof("BLOCK_CODE_COUNT") - 1, 1); + zend_string *const_BLOCK_CODE_COUNT_name = zend_string_init_interned("BLOCK_CODE_COUNT", sizeof("BLOCK_CODE_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_COUNT_name, &const_BLOCK_CODE_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_COUNT_name); + zend_string_release_ex(const_BLOCK_CODE_COUNT_name, true); zval const_BLOCK_CODE_INVALID_CODE_value; ZVAL_LONG(&const_BLOCK_CODE_INVALID_CODE_value, UBLOCK_INVALID_CODE); - zend_string *const_BLOCK_CODE_INVALID_CODE_name = zend_string_init_interned("BLOCK_CODE_INVALID_CODE", sizeof("BLOCK_CODE_INVALID_CODE") - 1, 1); + zend_string *const_BLOCK_CODE_INVALID_CODE_name = zend_string_init_interned("BLOCK_CODE_INVALID_CODE", sizeof("BLOCK_CODE_INVALID_CODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BLOCK_CODE_INVALID_CODE_name, &const_BLOCK_CODE_INVALID_CODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BLOCK_CODE_INVALID_CODE_name); + zend_string_release_ex(const_BLOCK_CODE_INVALID_CODE_name, true); zval const_BPT_NONE_value; ZVAL_LONG(&const_BPT_NONE_value, U_BPT_NONE); - zend_string *const_BPT_NONE_name = zend_string_init_interned("BPT_NONE", sizeof("BPT_NONE") - 1, 1); + zend_string *const_BPT_NONE_name = zend_string_init_interned("BPT_NONE", sizeof("BPT_NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BPT_NONE_name, &const_BPT_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BPT_NONE_name); + zend_string_release_ex(const_BPT_NONE_name, true); zval const_BPT_OPEN_value; ZVAL_LONG(&const_BPT_OPEN_value, U_BPT_OPEN); - zend_string *const_BPT_OPEN_name = zend_string_init_interned("BPT_OPEN", sizeof("BPT_OPEN") - 1, 1); + zend_string *const_BPT_OPEN_name = zend_string_init_interned("BPT_OPEN", sizeof("BPT_OPEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_BPT_OPEN_name, &const_BPT_OPEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BPT_OPEN_name); + zend_string_release_ex(const_BPT_OPEN_name, true); zval const_BPT_CLOSE_value; ZVAL_LONG(&const_BPT_CLOSE_value, U_BPT_CLOSE); - zend_string *const_BPT_CLOSE_name = zend_string_init_interned("BPT_CLOSE", sizeof("BPT_CLOSE") - 1, 1); + zend_string *const_BPT_CLOSE_name = zend_string_init_interned("BPT_CLOSE", sizeof("BPT_CLOSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_BPT_CLOSE_name, &const_BPT_CLOSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BPT_CLOSE_name); + zend_string_release_ex(const_BPT_CLOSE_name, true); zval const_BPT_COUNT_value; ZVAL_LONG(&const_BPT_COUNT_value, U_BPT_COUNT); - zend_string *const_BPT_COUNT_name = zend_string_init_interned("BPT_COUNT", sizeof("BPT_COUNT") - 1, 1); + zend_string *const_BPT_COUNT_name = zend_string_init_interned("BPT_COUNT", sizeof("BPT_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BPT_COUNT_name, &const_BPT_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BPT_COUNT_name); + zend_string_release_ex(const_BPT_COUNT_name, true); zval const_EA_NEUTRAL_value; ZVAL_LONG(&const_EA_NEUTRAL_value, U_EA_NEUTRAL); - zend_string *const_EA_NEUTRAL_name = zend_string_init_interned("EA_NEUTRAL", sizeof("EA_NEUTRAL") - 1, 1); + zend_string *const_EA_NEUTRAL_name = zend_string_init_interned("EA_NEUTRAL", sizeof("EA_NEUTRAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_EA_NEUTRAL_name, &const_EA_NEUTRAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EA_NEUTRAL_name); + zend_string_release_ex(const_EA_NEUTRAL_name, true); zval const_EA_AMBIGUOUS_value; ZVAL_LONG(&const_EA_AMBIGUOUS_value, U_EA_AMBIGUOUS); - zend_string *const_EA_AMBIGUOUS_name = zend_string_init_interned("EA_AMBIGUOUS", sizeof("EA_AMBIGUOUS") - 1, 1); + zend_string *const_EA_AMBIGUOUS_name = zend_string_init_interned("EA_AMBIGUOUS", sizeof("EA_AMBIGUOUS") - 1, true); zend_declare_typed_class_constant(class_entry, const_EA_AMBIGUOUS_name, &const_EA_AMBIGUOUS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EA_AMBIGUOUS_name); + zend_string_release_ex(const_EA_AMBIGUOUS_name, true); zval const_EA_HALFWIDTH_value; ZVAL_LONG(&const_EA_HALFWIDTH_value, U_EA_HALFWIDTH); - zend_string *const_EA_HALFWIDTH_name = zend_string_init_interned("EA_HALFWIDTH", sizeof("EA_HALFWIDTH") - 1, 1); + zend_string *const_EA_HALFWIDTH_name = zend_string_init_interned("EA_HALFWIDTH", sizeof("EA_HALFWIDTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_EA_HALFWIDTH_name, &const_EA_HALFWIDTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EA_HALFWIDTH_name); + zend_string_release_ex(const_EA_HALFWIDTH_name, true); zval const_EA_FULLWIDTH_value; ZVAL_LONG(&const_EA_FULLWIDTH_value, U_EA_FULLWIDTH); - zend_string *const_EA_FULLWIDTH_name = zend_string_init_interned("EA_FULLWIDTH", sizeof("EA_FULLWIDTH") - 1, 1); + zend_string *const_EA_FULLWIDTH_name = zend_string_init_interned("EA_FULLWIDTH", sizeof("EA_FULLWIDTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_EA_FULLWIDTH_name, &const_EA_FULLWIDTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EA_FULLWIDTH_name); + zend_string_release_ex(const_EA_FULLWIDTH_name, true); zval const_EA_NARROW_value; ZVAL_LONG(&const_EA_NARROW_value, U_EA_NARROW); - zend_string *const_EA_NARROW_name = zend_string_init_interned("EA_NARROW", sizeof("EA_NARROW") - 1, 1); + zend_string *const_EA_NARROW_name = zend_string_init_interned("EA_NARROW", sizeof("EA_NARROW") - 1, true); zend_declare_typed_class_constant(class_entry, const_EA_NARROW_name, &const_EA_NARROW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EA_NARROW_name); + zend_string_release_ex(const_EA_NARROW_name, true); zval const_EA_WIDE_value; ZVAL_LONG(&const_EA_WIDE_value, U_EA_WIDE); - zend_string *const_EA_WIDE_name = zend_string_init_interned("EA_WIDE", sizeof("EA_WIDE") - 1, 1); + zend_string *const_EA_WIDE_name = zend_string_init_interned("EA_WIDE", sizeof("EA_WIDE") - 1, true); zend_declare_typed_class_constant(class_entry, const_EA_WIDE_name, &const_EA_WIDE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EA_WIDE_name); + zend_string_release_ex(const_EA_WIDE_name, true); zval const_EA_COUNT_value; ZVAL_LONG(&const_EA_COUNT_value, U_EA_COUNT); - zend_string *const_EA_COUNT_name = zend_string_init_interned("EA_COUNT", sizeof("EA_COUNT") - 1, 1); + zend_string *const_EA_COUNT_name = zend_string_init_interned("EA_COUNT", sizeof("EA_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_EA_COUNT_name, &const_EA_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EA_COUNT_name); + zend_string_release_ex(const_EA_COUNT_name, true); zval const_UNICODE_CHAR_NAME_value; ZVAL_LONG(&const_UNICODE_CHAR_NAME_value, U_UNICODE_CHAR_NAME); - zend_string *const_UNICODE_CHAR_NAME_name = zend_string_init_interned("UNICODE_CHAR_NAME", sizeof("UNICODE_CHAR_NAME") - 1, 1); + zend_string *const_UNICODE_CHAR_NAME_name = zend_string_init_interned("UNICODE_CHAR_NAME", sizeof("UNICODE_CHAR_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_UNICODE_CHAR_NAME_name, &const_UNICODE_CHAR_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UNICODE_CHAR_NAME_name); + zend_string_release_ex(const_UNICODE_CHAR_NAME_name, true); zval const_UNICODE_10_CHAR_NAME_value; ZVAL_LONG(&const_UNICODE_10_CHAR_NAME_value, U_UNICODE_10_CHAR_NAME); - zend_string *const_UNICODE_10_CHAR_NAME_name = zend_string_init_interned("UNICODE_10_CHAR_NAME", sizeof("UNICODE_10_CHAR_NAME") - 1, 1); + zend_string *const_UNICODE_10_CHAR_NAME_name = zend_string_init_interned("UNICODE_10_CHAR_NAME", sizeof("UNICODE_10_CHAR_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_UNICODE_10_CHAR_NAME_name, &const_UNICODE_10_CHAR_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UNICODE_10_CHAR_NAME_name); + zend_string_release_ex(const_UNICODE_10_CHAR_NAME_name, true); zval const_EXTENDED_CHAR_NAME_value; ZVAL_LONG(&const_EXTENDED_CHAR_NAME_value, U_EXTENDED_CHAR_NAME); - zend_string *const_EXTENDED_CHAR_NAME_name = zend_string_init_interned("EXTENDED_CHAR_NAME", sizeof("EXTENDED_CHAR_NAME") - 1, 1); + zend_string *const_EXTENDED_CHAR_NAME_name = zend_string_init_interned("EXTENDED_CHAR_NAME", sizeof("EXTENDED_CHAR_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXTENDED_CHAR_NAME_name, &const_EXTENDED_CHAR_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXTENDED_CHAR_NAME_name); + zend_string_release_ex(const_EXTENDED_CHAR_NAME_name, true); zval const_CHAR_NAME_ALIAS_value; ZVAL_LONG(&const_CHAR_NAME_ALIAS_value, U_CHAR_NAME_ALIAS); - zend_string *const_CHAR_NAME_ALIAS_name = zend_string_init_interned("CHAR_NAME_ALIAS", sizeof("CHAR_NAME_ALIAS") - 1, 1); + zend_string *const_CHAR_NAME_ALIAS_name = zend_string_init_interned("CHAR_NAME_ALIAS", sizeof("CHAR_NAME_ALIAS") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_NAME_ALIAS_name, &const_CHAR_NAME_ALIAS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_NAME_ALIAS_name); + zend_string_release_ex(const_CHAR_NAME_ALIAS_name, true); zval const_CHAR_NAME_CHOICE_COUNT_value; ZVAL_LONG(&const_CHAR_NAME_CHOICE_COUNT_value, U_CHAR_NAME_CHOICE_COUNT); - zend_string *const_CHAR_NAME_CHOICE_COUNT_name = zend_string_init_interned("CHAR_NAME_CHOICE_COUNT", sizeof("CHAR_NAME_CHOICE_COUNT") - 1, 1); + zend_string *const_CHAR_NAME_CHOICE_COUNT_name = zend_string_init_interned("CHAR_NAME_CHOICE_COUNT", sizeof("CHAR_NAME_CHOICE_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHAR_NAME_CHOICE_COUNT_name, &const_CHAR_NAME_CHOICE_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHAR_NAME_CHOICE_COUNT_name); + zend_string_release_ex(const_CHAR_NAME_CHOICE_COUNT_name, true); zval const_SHORT_PROPERTY_NAME_value; ZVAL_LONG(&const_SHORT_PROPERTY_NAME_value, U_SHORT_PROPERTY_NAME); - zend_string *const_SHORT_PROPERTY_NAME_name = zend_string_init_interned("SHORT_PROPERTY_NAME", sizeof("SHORT_PROPERTY_NAME") - 1, 1); + zend_string *const_SHORT_PROPERTY_NAME_name = zend_string_init_interned("SHORT_PROPERTY_NAME", sizeof("SHORT_PROPERTY_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_SHORT_PROPERTY_NAME_name, &const_SHORT_PROPERTY_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SHORT_PROPERTY_NAME_name); + zend_string_release_ex(const_SHORT_PROPERTY_NAME_name, true); zval const_LONG_PROPERTY_NAME_value; ZVAL_LONG(&const_LONG_PROPERTY_NAME_value, U_LONG_PROPERTY_NAME); - zend_string *const_LONG_PROPERTY_NAME_name = zend_string_init_interned("LONG_PROPERTY_NAME", sizeof("LONG_PROPERTY_NAME") - 1, 1); + zend_string *const_LONG_PROPERTY_NAME_name = zend_string_init_interned("LONG_PROPERTY_NAME", sizeof("LONG_PROPERTY_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_LONG_PROPERTY_NAME_name, &const_LONG_PROPERTY_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LONG_PROPERTY_NAME_name); + zend_string_release_ex(const_LONG_PROPERTY_NAME_name, true); zval const_PROPERTY_NAME_CHOICE_COUNT_value; ZVAL_LONG(&const_PROPERTY_NAME_CHOICE_COUNT_value, U_PROPERTY_NAME_CHOICE_COUNT); - zend_string *const_PROPERTY_NAME_CHOICE_COUNT_name = zend_string_init_interned("PROPERTY_NAME_CHOICE_COUNT", sizeof("PROPERTY_NAME_CHOICE_COUNT") - 1, 1); + zend_string *const_PROPERTY_NAME_CHOICE_COUNT_name = zend_string_init_interned("PROPERTY_NAME_CHOICE_COUNT", sizeof("PROPERTY_NAME_CHOICE_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PROPERTY_NAME_CHOICE_COUNT_name, &const_PROPERTY_NAME_CHOICE_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PROPERTY_NAME_CHOICE_COUNT_name); + zend_string_release_ex(const_PROPERTY_NAME_CHOICE_COUNT_name, true); zval const_DT_NONE_value; ZVAL_LONG(&const_DT_NONE_value, U_DT_NONE); - zend_string *const_DT_NONE_name = zend_string_init_interned("DT_NONE", sizeof("DT_NONE") - 1, 1); + zend_string *const_DT_NONE_name = zend_string_init_interned("DT_NONE", sizeof("DT_NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_NONE_name, &const_DT_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_NONE_name); + zend_string_release_ex(const_DT_NONE_name, true); zval const_DT_CANONICAL_value; ZVAL_LONG(&const_DT_CANONICAL_value, U_DT_CANONICAL); - zend_string *const_DT_CANONICAL_name = zend_string_init_interned("DT_CANONICAL", sizeof("DT_CANONICAL") - 1, 1); + zend_string *const_DT_CANONICAL_name = zend_string_init_interned("DT_CANONICAL", sizeof("DT_CANONICAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_CANONICAL_name, &const_DT_CANONICAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_CANONICAL_name); + zend_string_release_ex(const_DT_CANONICAL_name, true); zval const_DT_COMPAT_value; ZVAL_LONG(&const_DT_COMPAT_value, U_DT_COMPAT); - zend_string *const_DT_COMPAT_name = zend_string_init_interned("DT_COMPAT", sizeof("DT_COMPAT") - 1, 1); + zend_string *const_DT_COMPAT_name = zend_string_init_interned("DT_COMPAT", sizeof("DT_COMPAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_COMPAT_name, &const_DT_COMPAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_COMPAT_name); + zend_string_release_ex(const_DT_COMPAT_name, true); zval const_DT_CIRCLE_value; ZVAL_LONG(&const_DT_CIRCLE_value, U_DT_CIRCLE); - zend_string *const_DT_CIRCLE_name = zend_string_init_interned("DT_CIRCLE", sizeof("DT_CIRCLE") - 1, 1); + zend_string *const_DT_CIRCLE_name = zend_string_init_interned("DT_CIRCLE", sizeof("DT_CIRCLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_CIRCLE_name, &const_DT_CIRCLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_CIRCLE_name); + zend_string_release_ex(const_DT_CIRCLE_name, true); zval const_DT_FINAL_value; ZVAL_LONG(&const_DT_FINAL_value, U_DT_FINAL); - zend_string *const_DT_FINAL_name = zend_string_init_interned("DT_FINAL", sizeof("DT_FINAL") - 1, 1); + zend_string *const_DT_FINAL_name = zend_string_init_interned("DT_FINAL", sizeof("DT_FINAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_FINAL_name, &const_DT_FINAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_FINAL_name); + zend_string_release_ex(const_DT_FINAL_name, true); zval const_DT_FONT_value; ZVAL_LONG(&const_DT_FONT_value, U_DT_FONT); - zend_string *const_DT_FONT_name = zend_string_init_interned("DT_FONT", sizeof("DT_FONT") - 1, 1); + zend_string *const_DT_FONT_name = zend_string_init_interned("DT_FONT", sizeof("DT_FONT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_FONT_name, &const_DT_FONT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_FONT_name); + zend_string_release_ex(const_DT_FONT_name, true); zval const_DT_FRACTION_value; ZVAL_LONG(&const_DT_FRACTION_value, U_DT_FRACTION); - zend_string *const_DT_FRACTION_name = zend_string_init_interned("DT_FRACTION", sizeof("DT_FRACTION") - 1, 1); + zend_string *const_DT_FRACTION_name = zend_string_init_interned("DT_FRACTION", sizeof("DT_FRACTION") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_FRACTION_name, &const_DT_FRACTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_FRACTION_name); + zend_string_release_ex(const_DT_FRACTION_name, true); zval const_DT_INITIAL_value; ZVAL_LONG(&const_DT_INITIAL_value, U_DT_INITIAL); - zend_string *const_DT_INITIAL_name = zend_string_init_interned("DT_INITIAL", sizeof("DT_INITIAL") - 1, 1); + zend_string *const_DT_INITIAL_name = zend_string_init_interned("DT_INITIAL", sizeof("DT_INITIAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_INITIAL_name, &const_DT_INITIAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_INITIAL_name); + zend_string_release_ex(const_DT_INITIAL_name, true); zval const_DT_ISOLATED_value; ZVAL_LONG(&const_DT_ISOLATED_value, U_DT_ISOLATED); - zend_string *const_DT_ISOLATED_name = zend_string_init_interned("DT_ISOLATED", sizeof("DT_ISOLATED") - 1, 1); + zend_string *const_DT_ISOLATED_name = zend_string_init_interned("DT_ISOLATED", sizeof("DT_ISOLATED") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_ISOLATED_name, &const_DT_ISOLATED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_ISOLATED_name); + zend_string_release_ex(const_DT_ISOLATED_name, true); zval const_DT_MEDIAL_value; ZVAL_LONG(&const_DT_MEDIAL_value, U_DT_MEDIAL); - zend_string *const_DT_MEDIAL_name = zend_string_init_interned("DT_MEDIAL", sizeof("DT_MEDIAL") - 1, 1); + zend_string *const_DT_MEDIAL_name = zend_string_init_interned("DT_MEDIAL", sizeof("DT_MEDIAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_MEDIAL_name, &const_DT_MEDIAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_MEDIAL_name); + zend_string_release_ex(const_DT_MEDIAL_name, true); zval const_DT_NARROW_value; ZVAL_LONG(&const_DT_NARROW_value, U_DT_NARROW); - zend_string *const_DT_NARROW_name = zend_string_init_interned("DT_NARROW", sizeof("DT_NARROW") - 1, 1); + zend_string *const_DT_NARROW_name = zend_string_init_interned("DT_NARROW", sizeof("DT_NARROW") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_NARROW_name, &const_DT_NARROW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_NARROW_name); + zend_string_release_ex(const_DT_NARROW_name, true); zval const_DT_NOBREAK_value; ZVAL_LONG(&const_DT_NOBREAK_value, U_DT_NOBREAK); - zend_string *const_DT_NOBREAK_name = zend_string_init_interned("DT_NOBREAK", sizeof("DT_NOBREAK") - 1, 1); + zend_string *const_DT_NOBREAK_name = zend_string_init_interned("DT_NOBREAK", sizeof("DT_NOBREAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_NOBREAK_name, &const_DT_NOBREAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_NOBREAK_name); + zend_string_release_ex(const_DT_NOBREAK_name, true); zval const_DT_SMALL_value; ZVAL_LONG(&const_DT_SMALL_value, U_DT_SMALL); - zend_string *const_DT_SMALL_name = zend_string_init_interned("DT_SMALL", sizeof("DT_SMALL") - 1, 1); + zend_string *const_DT_SMALL_name = zend_string_init_interned("DT_SMALL", sizeof("DT_SMALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_SMALL_name, &const_DT_SMALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_SMALL_name); + zend_string_release_ex(const_DT_SMALL_name, true); zval const_DT_SQUARE_value; ZVAL_LONG(&const_DT_SQUARE_value, U_DT_SQUARE); - zend_string *const_DT_SQUARE_name = zend_string_init_interned("DT_SQUARE", sizeof("DT_SQUARE") - 1, 1); + zend_string *const_DT_SQUARE_name = zend_string_init_interned("DT_SQUARE", sizeof("DT_SQUARE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_SQUARE_name, &const_DT_SQUARE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_SQUARE_name); + zend_string_release_ex(const_DT_SQUARE_name, true); zval const_DT_SUB_value; ZVAL_LONG(&const_DT_SUB_value, U_DT_SUB); - zend_string *const_DT_SUB_name = zend_string_init_interned("DT_SUB", sizeof("DT_SUB") - 1, 1); + zend_string *const_DT_SUB_name = zend_string_init_interned("DT_SUB", sizeof("DT_SUB") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_SUB_name, &const_DT_SUB_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_SUB_name); + zend_string_release_ex(const_DT_SUB_name, true); zval const_DT_SUPER_value; ZVAL_LONG(&const_DT_SUPER_value, U_DT_SUPER); - zend_string *const_DT_SUPER_name = zend_string_init_interned("DT_SUPER", sizeof("DT_SUPER") - 1, 1); + zend_string *const_DT_SUPER_name = zend_string_init_interned("DT_SUPER", sizeof("DT_SUPER") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_SUPER_name, &const_DT_SUPER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_SUPER_name); + zend_string_release_ex(const_DT_SUPER_name, true); zval const_DT_VERTICAL_value; ZVAL_LONG(&const_DT_VERTICAL_value, U_DT_VERTICAL); - zend_string *const_DT_VERTICAL_name = zend_string_init_interned("DT_VERTICAL", sizeof("DT_VERTICAL") - 1, 1); + zend_string *const_DT_VERTICAL_name = zend_string_init_interned("DT_VERTICAL", sizeof("DT_VERTICAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_VERTICAL_name, &const_DT_VERTICAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_VERTICAL_name); + zend_string_release_ex(const_DT_VERTICAL_name, true); zval const_DT_WIDE_value; ZVAL_LONG(&const_DT_WIDE_value, U_DT_WIDE); - zend_string *const_DT_WIDE_name = zend_string_init_interned("DT_WIDE", sizeof("DT_WIDE") - 1, 1); + zend_string *const_DT_WIDE_name = zend_string_init_interned("DT_WIDE", sizeof("DT_WIDE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_WIDE_name, &const_DT_WIDE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_WIDE_name); + zend_string_release_ex(const_DT_WIDE_name, true); zval const_DT_COUNT_value; ZVAL_LONG(&const_DT_COUNT_value, U_DT_COUNT); - zend_string *const_DT_COUNT_name = zend_string_init_interned("DT_COUNT", sizeof("DT_COUNT") - 1, 1); + zend_string *const_DT_COUNT_name = zend_string_init_interned("DT_COUNT", sizeof("DT_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DT_COUNT_name, &const_DT_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DT_COUNT_name); + zend_string_release_ex(const_DT_COUNT_name, true); zval const_JT_NON_JOINING_value; ZVAL_LONG(&const_JT_NON_JOINING_value, U_JT_NON_JOINING); - zend_string *const_JT_NON_JOINING_name = zend_string_init_interned("JT_NON_JOINING", sizeof("JT_NON_JOINING") - 1, 1); + zend_string *const_JT_NON_JOINING_name = zend_string_init_interned("JT_NON_JOINING", sizeof("JT_NON_JOINING") - 1, true); zend_declare_typed_class_constant(class_entry, const_JT_NON_JOINING_name, &const_JT_NON_JOINING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JT_NON_JOINING_name); + zend_string_release_ex(const_JT_NON_JOINING_name, true); zval const_JT_JOIN_CAUSING_value; ZVAL_LONG(&const_JT_JOIN_CAUSING_value, U_JT_JOIN_CAUSING); - zend_string *const_JT_JOIN_CAUSING_name = zend_string_init_interned("JT_JOIN_CAUSING", sizeof("JT_JOIN_CAUSING") - 1, 1); + zend_string *const_JT_JOIN_CAUSING_name = zend_string_init_interned("JT_JOIN_CAUSING", sizeof("JT_JOIN_CAUSING") - 1, true); zend_declare_typed_class_constant(class_entry, const_JT_JOIN_CAUSING_name, &const_JT_JOIN_CAUSING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JT_JOIN_CAUSING_name); + zend_string_release_ex(const_JT_JOIN_CAUSING_name, true); zval const_JT_DUAL_JOINING_value; ZVAL_LONG(&const_JT_DUAL_JOINING_value, U_JT_DUAL_JOINING); - zend_string *const_JT_DUAL_JOINING_name = zend_string_init_interned("JT_DUAL_JOINING", sizeof("JT_DUAL_JOINING") - 1, 1); + zend_string *const_JT_DUAL_JOINING_name = zend_string_init_interned("JT_DUAL_JOINING", sizeof("JT_DUAL_JOINING") - 1, true); zend_declare_typed_class_constant(class_entry, const_JT_DUAL_JOINING_name, &const_JT_DUAL_JOINING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JT_DUAL_JOINING_name); + zend_string_release_ex(const_JT_DUAL_JOINING_name, true); zval const_JT_LEFT_JOINING_value; ZVAL_LONG(&const_JT_LEFT_JOINING_value, U_JT_LEFT_JOINING); - zend_string *const_JT_LEFT_JOINING_name = zend_string_init_interned("JT_LEFT_JOINING", sizeof("JT_LEFT_JOINING") - 1, 1); + zend_string *const_JT_LEFT_JOINING_name = zend_string_init_interned("JT_LEFT_JOINING", sizeof("JT_LEFT_JOINING") - 1, true); zend_declare_typed_class_constant(class_entry, const_JT_LEFT_JOINING_name, &const_JT_LEFT_JOINING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JT_LEFT_JOINING_name); + zend_string_release_ex(const_JT_LEFT_JOINING_name, true); zval const_JT_RIGHT_JOINING_value; ZVAL_LONG(&const_JT_RIGHT_JOINING_value, U_JT_RIGHT_JOINING); - zend_string *const_JT_RIGHT_JOINING_name = zend_string_init_interned("JT_RIGHT_JOINING", sizeof("JT_RIGHT_JOINING") - 1, 1); + zend_string *const_JT_RIGHT_JOINING_name = zend_string_init_interned("JT_RIGHT_JOINING", sizeof("JT_RIGHT_JOINING") - 1, true); zend_declare_typed_class_constant(class_entry, const_JT_RIGHT_JOINING_name, &const_JT_RIGHT_JOINING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JT_RIGHT_JOINING_name); + zend_string_release_ex(const_JT_RIGHT_JOINING_name, true); zval const_JT_TRANSPARENT_value; ZVAL_LONG(&const_JT_TRANSPARENT_value, U_JT_TRANSPARENT); - zend_string *const_JT_TRANSPARENT_name = zend_string_init_interned("JT_TRANSPARENT", sizeof("JT_TRANSPARENT") - 1, 1); + zend_string *const_JT_TRANSPARENT_name = zend_string_init_interned("JT_TRANSPARENT", sizeof("JT_TRANSPARENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_JT_TRANSPARENT_name, &const_JT_TRANSPARENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JT_TRANSPARENT_name); + zend_string_release_ex(const_JT_TRANSPARENT_name, true); zval const_JT_COUNT_value; ZVAL_LONG(&const_JT_COUNT_value, U_JT_COUNT); - zend_string *const_JT_COUNT_name = zend_string_init_interned("JT_COUNT", sizeof("JT_COUNT") - 1, 1); + zend_string *const_JT_COUNT_name = zend_string_init_interned("JT_COUNT", sizeof("JT_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_JT_COUNT_name, &const_JT_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JT_COUNT_name); + zend_string_release_ex(const_JT_COUNT_name, true); zval const_JG_NO_JOINING_GROUP_value; ZVAL_LONG(&const_JG_NO_JOINING_GROUP_value, U_JG_NO_JOINING_GROUP); - zend_string *const_JG_NO_JOINING_GROUP_name = zend_string_init_interned("JG_NO_JOINING_GROUP", sizeof("JG_NO_JOINING_GROUP") - 1, 1); + zend_string *const_JG_NO_JOINING_GROUP_name = zend_string_init_interned("JG_NO_JOINING_GROUP", sizeof("JG_NO_JOINING_GROUP") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_NO_JOINING_GROUP_name, &const_JG_NO_JOINING_GROUP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_NO_JOINING_GROUP_name); + zend_string_release_ex(const_JG_NO_JOINING_GROUP_name, true); zval const_JG_AIN_value; ZVAL_LONG(&const_JG_AIN_value, U_JG_AIN); - zend_string *const_JG_AIN_name = zend_string_init_interned("JG_AIN", sizeof("JG_AIN") - 1, 1); + zend_string *const_JG_AIN_name = zend_string_init_interned("JG_AIN", sizeof("JG_AIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_AIN_name, &const_JG_AIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_AIN_name); + zend_string_release_ex(const_JG_AIN_name, true); zval const_JG_ALAPH_value; ZVAL_LONG(&const_JG_ALAPH_value, U_JG_ALAPH); - zend_string *const_JG_ALAPH_name = zend_string_init_interned("JG_ALAPH", sizeof("JG_ALAPH") - 1, 1); + zend_string *const_JG_ALAPH_name = zend_string_init_interned("JG_ALAPH", sizeof("JG_ALAPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_ALAPH_name, &const_JG_ALAPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_ALAPH_name); + zend_string_release_ex(const_JG_ALAPH_name, true); zval const_JG_ALEF_value; ZVAL_LONG(&const_JG_ALEF_value, U_JG_ALEF); - zend_string *const_JG_ALEF_name = zend_string_init_interned("JG_ALEF", sizeof("JG_ALEF") - 1, 1); + zend_string *const_JG_ALEF_name = zend_string_init_interned("JG_ALEF", sizeof("JG_ALEF") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_ALEF_name, &const_JG_ALEF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_ALEF_name); + zend_string_release_ex(const_JG_ALEF_name, true); zval const_JG_BEH_value; ZVAL_LONG(&const_JG_BEH_value, U_JG_BEH); - zend_string *const_JG_BEH_name = zend_string_init_interned("JG_BEH", sizeof("JG_BEH") - 1, 1); + zend_string *const_JG_BEH_name = zend_string_init_interned("JG_BEH", sizeof("JG_BEH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_BEH_name, &const_JG_BEH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_BEH_name); + zend_string_release_ex(const_JG_BEH_name, true); zval const_JG_BETH_value; ZVAL_LONG(&const_JG_BETH_value, U_JG_BETH); - zend_string *const_JG_BETH_name = zend_string_init_interned("JG_BETH", sizeof("JG_BETH") - 1, 1); + zend_string *const_JG_BETH_name = zend_string_init_interned("JG_BETH", sizeof("JG_BETH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_BETH_name, &const_JG_BETH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_BETH_name); + zend_string_release_ex(const_JG_BETH_name, true); zval const_JG_DAL_value; ZVAL_LONG(&const_JG_DAL_value, U_JG_DAL); - zend_string *const_JG_DAL_name = zend_string_init_interned("JG_DAL", sizeof("JG_DAL") - 1, 1); + zend_string *const_JG_DAL_name = zend_string_init_interned("JG_DAL", sizeof("JG_DAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_DAL_name, &const_JG_DAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_DAL_name); + zend_string_release_ex(const_JG_DAL_name, true); zval const_JG_DALATH_RISH_value; ZVAL_LONG(&const_JG_DALATH_RISH_value, U_JG_DALATH_RISH); - zend_string *const_JG_DALATH_RISH_name = zend_string_init_interned("JG_DALATH_RISH", sizeof("JG_DALATH_RISH") - 1, 1); + zend_string *const_JG_DALATH_RISH_name = zend_string_init_interned("JG_DALATH_RISH", sizeof("JG_DALATH_RISH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_DALATH_RISH_name, &const_JG_DALATH_RISH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_DALATH_RISH_name); + zend_string_release_ex(const_JG_DALATH_RISH_name, true); zval const_JG_E_value; ZVAL_LONG(&const_JG_E_value, U_JG_E); - zend_string *const_JG_E_name = zend_string_init_interned("JG_E", sizeof("JG_E") - 1, 1); + zend_string *const_JG_E_name = zend_string_init_interned("JG_E", sizeof("JG_E") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_E_name, &const_JG_E_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_E_name); + zend_string_release_ex(const_JG_E_name, true); zval const_JG_FEH_value; ZVAL_LONG(&const_JG_FEH_value, U_JG_FEH); - zend_string *const_JG_FEH_name = zend_string_init_interned("JG_FEH", sizeof("JG_FEH") - 1, 1); + zend_string *const_JG_FEH_name = zend_string_init_interned("JG_FEH", sizeof("JG_FEH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_FEH_name, &const_JG_FEH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_FEH_name); + zend_string_release_ex(const_JG_FEH_name, true); zval const_JG_FINAL_SEMKATH_value; ZVAL_LONG(&const_JG_FINAL_SEMKATH_value, U_JG_FINAL_SEMKATH); - zend_string *const_JG_FINAL_SEMKATH_name = zend_string_init_interned("JG_FINAL_SEMKATH", sizeof("JG_FINAL_SEMKATH") - 1, 1); + zend_string *const_JG_FINAL_SEMKATH_name = zend_string_init_interned("JG_FINAL_SEMKATH", sizeof("JG_FINAL_SEMKATH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_FINAL_SEMKATH_name, &const_JG_FINAL_SEMKATH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_FINAL_SEMKATH_name); + zend_string_release_ex(const_JG_FINAL_SEMKATH_name, true); zval const_JG_GAF_value; ZVAL_LONG(&const_JG_GAF_value, U_JG_GAF); - zend_string *const_JG_GAF_name = zend_string_init_interned("JG_GAF", sizeof("JG_GAF") - 1, 1); + zend_string *const_JG_GAF_name = zend_string_init_interned("JG_GAF", sizeof("JG_GAF") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_GAF_name, &const_JG_GAF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_GAF_name); + zend_string_release_ex(const_JG_GAF_name, true); zval const_JG_GAMAL_value; ZVAL_LONG(&const_JG_GAMAL_value, U_JG_GAMAL); - zend_string *const_JG_GAMAL_name = zend_string_init_interned("JG_GAMAL", sizeof("JG_GAMAL") - 1, 1); + zend_string *const_JG_GAMAL_name = zend_string_init_interned("JG_GAMAL", sizeof("JG_GAMAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_GAMAL_name, &const_JG_GAMAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_GAMAL_name); + zend_string_release_ex(const_JG_GAMAL_name, true); zval const_JG_HAH_value; ZVAL_LONG(&const_JG_HAH_value, U_JG_HAH); - zend_string *const_JG_HAH_name = zend_string_init_interned("JG_HAH", sizeof("JG_HAH") - 1, 1); + zend_string *const_JG_HAH_name = zend_string_init_interned("JG_HAH", sizeof("JG_HAH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_HAH_name, &const_JG_HAH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_HAH_name); + zend_string_release_ex(const_JG_HAH_name, true); zval const_JG_TEH_MARBUTA_GOAL_value; ZVAL_LONG(&const_JG_TEH_MARBUTA_GOAL_value, U_JG_TEH_MARBUTA_GOAL); - zend_string *const_JG_TEH_MARBUTA_GOAL_name = zend_string_init_interned("JG_TEH_MARBUTA_GOAL", sizeof("JG_TEH_MARBUTA_GOAL") - 1, 1); + zend_string *const_JG_TEH_MARBUTA_GOAL_name = zend_string_init_interned("JG_TEH_MARBUTA_GOAL", sizeof("JG_TEH_MARBUTA_GOAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_TEH_MARBUTA_GOAL_name, &const_JG_TEH_MARBUTA_GOAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_TEH_MARBUTA_GOAL_name); + zend_string_release_ex(const_JG_TEH_MARBUTA_GOAL_name, true); zval const_JG_HAMZA_ON_HEH_GOAL_value; ZVAL_LONG(&const_JG_HAMZA_ON_HEH_GOAL_value, U_JG_HAMZA_ON_HEH_GOAL); - zend_string *const_JG_HAMZA_ON_HEH_GOAL_name = zend_string_init_interned("JG_HAMZA_ON_HEH_GOAL", sizeof("JG_HAMZA_ON_HEH_GOAL") - 1, 1); + zend_string *const_JG_HAMZA_ON_HEH_GOAL_name = zend_string_init_interned("JG_HAMZA_ON_HEH_GOAL", sizeof("JG_HAMZA_ON_HEH_GOAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_HAMZA_ON_HEH_GOAL_name, &const_JG_HAMZA_ON_HEH_GOAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_HAMZA_ON_HEH_GOAL_name); + zend_string_release_ex(const_JG_HAMZA_ON_HEH_GOAL_name, true); zval const_JG_HE_value; ZVAL_LONG(&const_JG_HE_value, U_JG_HE); - zend_string *const_JG_HE_name = zend_string_init_interned("JG_HE", sizeof("JG_HE") - 1, 1); + zend_string *const_JG_HE_name = zend_string_init_interned("JG_HE", sizeof("JG_HE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_HE_name, &const_JG_HE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_HE_name); + zend_string_release_ex(const_JG_HE_name, true); zval const_JG_HEH_value; ZVAL_LONG(&const_JG_HEH_value, U_JG_HEH); - zend_string *const_JG_HEH_name = zend_string_init_interned("JG_HEH", sizeof("JG_HEH") - 1, 1); + zend_string *const_JG_HEH_name = zend_string_init_interned("JG_HEH", sizeof("JG_HEH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_HEH_name, &const_JG_HEH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_HEH_name); + zend_string_release_ex(const_JG_HEH_name, true); zval const_JG_HEH_GOAL_value; ZVAL_LONG(&const_JG_HEH_GOAL_value, U_JG_HEH_GOAL); - zend_string *const_JG_HEH_GOAL_name = zend_string_init_interned("JG_HEH_GOAL", sizeof("JG_HEH_GOAL") - 1, 1); + zend_string *const_JG_HEH_GOAL_name = zend_string_init_interned("JG_HEH_GOAL", sizeof("JG_HEH_GOAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_HEH_GOAL_name, &const_JG_HEH_GOAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_HEH_GOAL_name); + zend_string_release_ex(const_JG_HEH_GOAL_name, true); zval const_JG_HETH_value; ZVAL_LONG(&const_JG_HETH_value, U_JG_HETH); - zend_string *const_JG_HETH_name = zend_string_init_interned("JG_HETH", sizeof("JG_HETH") - 1, 1); + zend_string *const_JG_HETH_name = zend_string_init_interned("JG_HETH", sizeof("JG_HETH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_HETH_name, &const_JG_HETH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_HETH_name); + zend_string_release_ex(const_JG_HETH_name, true); zval const_JG_KAF_value; ZVAL_LONG(&const_JG_KAF_value, U_JG_KAF); - zend_string *const_JG_KAF_name = zend_string_init_interned("JG_KAF", sizeof("JG_KAF") - 1, 1); + zend_string *const_JG_KAF_name = zend_string_init_interned("JG_KAF", sizeof("JG_KAF") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_KAF_name, &const_JG_KAF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_KAF_name); + zend_string_release_ex(const_JG_KAF_name, true); zval const_JG_KAPH_value; ZVAL_LONG(&const_JG_KAPH_value, U_JG_KAPH); - zend_string *const_JG_KAPH_name = zend_string_init_interned("JG_KAPH", sizeof("JG_KAPH") - 1, 1); + zend_string *const_JG_KAPH_name = zend_string_init_interned("JG_KAPH", sizeof("JG_KAPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_KAPH_name, &const_JG_KAPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_KAPH_name); + zend_string_release_ex(const_JG_KAPH_name, true); zval const_JG_KNOTTED_HEH_value; ZVAL_LONG(&const_JG_KNOTTED_HEH_value, U_JG_KNOTTED_HEH); - zend_string *const_JG_KNOTTED_HEH_name = zend_string_init_interned("JG_KNOTTED_HEH", sizeof("JG_KNOTTED_HEH") - 1, 1); + zend_string *const_JG_KNOTTED_HEH_name = zend_string_init_interned("JG_KNOTTED_HEH", sizeof("JG_KNOTTED_HEH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_KNOTTED_HEH_name, &const_JG_KNOTTED_HEH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_KNOTTED_HEH_name); + zend_string_release_ex(const_JG_KNOTTED_HEH_name, true); zval const_JG_LAM_value; ZVAL_LONG(&const_JG_LAM_value, U_JG_LAM); - zend_string *const_JG_LAM_name = zend_string_init_interned("JG_LAM", sizeof("JG_LAM") - 1, 1); + zend_string *const_JG_LAM_name = zend_string_init_interned("JG_LAM", sizeof("JG_LAM") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_LAM_name, &const_JG_LAM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_LAM_name); + zend_string_release_ex(const_JG_LAM_name, true); zval const_JG_LAMADH_value; ZVAL_LONG(&const_JG_LAMADH_value, U_JG_LAMADH); - zend_string *const_JG_LAMADH_name = zend_string_init_interned("JG_LAMADH", sizeof("JG_LAMADH") - 1, 1); + zend_string *const_JG_LAMADH_name = zend_string_init_interned("JG_LAMADH", sizeof("JG_LAMADH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_LAMADH_name, &const_JG_LAMADH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_LAMADH_name); + zend_string_release_ex(const_JG_LAMADH_name, true); zval const_JG_MEEM_value; ZVAL_LONG(&const_JG_MEEM_value, U_JG_MEEM); - zend_string *const_JG_MEEM_name = zend_string_init_interned("JG_MEEM", sizeof("JG_MEEM") - 1, 1); + zend_string *const_JG_MEEM_name = zend_string_init_interned("JG_MEEM", sizeof("JG_MEEM") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MEEM_name, &const_JG_MEEM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MEEM_name); + zend_string_release_ex(const_JG_MEEM_name, true); zval const_JG_MIM_value; ZVAL_LONG(&const_JG_MIM_value, U_JG_MIM); - zend_string *const_JG_MIM_name = zend_string_init_interned("JG_MIM", sizeof("JG_MIM") - 1, 1); + zend_string *const_JG_MIM_name = zend_string_init_interned("JG_MIM", sizeof("JG_MIM") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MIM_name, &const_JG_MIM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MIM_name); + zend_string_release_ex(const_JG_MIM_name, true); zval const_JG_NOON_value; ZVAL_LONG(&const_JG_NOON_value, U_JG_NOON); - zend_string *const_JG_NOON_name = zend_string_init_interned("JG_NOON", sizeof("JG_NOON") - 1, 1); + zend_string *const_JG_NOON_name = zend_string_init_interned("JG_NOON", sizeof("JG_NOON") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_NOON_name, &const_JG_NOON_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_NOON_name); + zend_string_release_ex(const_JG_NOON_name, true); zval const_JG_NUN_value; ZVAL_LONG(&const_JG_NUN_value, U_JG_NUN); - zend_string *const_JG_NUN_name = zend_string_init_interned("JG_NUN", sizeof("JG_NUN") - 1, 1); + zend_string *const_JG_NUN_name = zend_string_init_interned("JG_NUN", sizeof("JG_NUN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_NUN_name, &const_JG_NUN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_NUN_name); + zend_string_release_ex(const_JG_NUN_name, true); zval const_JG_PE_value; ZVAL_LONG(&const_JG_PE_value, U_JG_PE); - zend_string *const_JG_PE_name = zend_string_init_interned("JG_PE", sizeof("JG_PE") - 1, 1); + zend_string *const_JG_PE_name = zend_string_init_interned("JG_PE", sizeof("JG_PE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_PE_name, &const_JG_PE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_PE_name); + zend_string_release_ex(const_JG_PE_name, true); zval const_JG_QAF_value; ZVAL_LONG(&const_JG_QAF_value, U_JG_QAF); - zend_string *const_JG_QAF_name = zend_string_init_interned("JG_QAF", sizeof("JG_QAF") - 1, 1); + zend_string *const_JG_QAF_name = zend_string_init_interned("JG_QAF", sizeof("JG_QAF") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_QAF_name, &const_JG_QAF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_QAF_name); + zend_string_release_ex(const_JG_QAF_name, true); zval const_JG_QAPH_value; ZVAL_LONG(&const_JG_QAPH_value, U_JG_QAPH); - zend_string *const_JG_QAPH_name = zend_string_init_interned("JG_QAPH", sizeof("JG_QAPH") - 1, 1); + zend_string *const_JG_QAPH_name = zend_string_init_interned("JG_QAPH", sizeof("JG_QAPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_QAPH_name, &const_JG_QAPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_QAPH_name); + zend_string_release_ex(const_JG_QAPH_name, true); zval const_JG_REH_value; ZVAL_LONG(&const_JG_REH_value, U_JG_REH); - zend_string *const_JG_REH_name = zend_string_init_interned("JG_REH", sizeof("JG_REH") - 1, 1); + zend_string *const_JG_REH_name = zend_string_init_interned("JG_REH", sizeof("JG_REH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_REH_name, &const_JG_REH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_REH_name); + zend_string_release_ex(const_JG_REH_name, true); zval const_JG_REVERSED_PE_value; ZVAL_LONG(&const_JG_REVERSED_PE_value, U_JG_REVERSED_PE); - zend_string *const_JG_REVERSED_PE_name = zend_string_init_interned("JG_REVERSED_PE", sizeof("JG_REVERSED_PE") - 1, 1); + zend_string *const_JG_REVERSED_PE_name = zend_string_init_interned("JG_REVERSED_PE", sizeof("JG_REVERSED_PE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_REVERSED_PE_name, &const_JG_REVERSED_PE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_REVERSED_PE_name); + zend_string_release_ex(const_JG_REVERSED_PE_name, true); zval const_JG_SAD_value; ZVAL_LONG(&const_JG_SAD_value, U_JG_SAD); - zend_string *const_JG_SAD_name = zend_string_init_interned("JG_SAD", sizeof("JG_SAD") - 1, 1); + zend_string *const_JG_SAD_name = zend_string_init_interned("JG_SAD", sizeof("JG_SAD") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_SAD_name, &const_JG_SAD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_SAD_name); + zend_string_release_ex(const_JG_SAD_name, true); zval const_JG_SADHE_value; ZVAL_LONG(&const_JG_SADHE_value, U_JG_SADHE); - zend_string *const_JG_SADHE_name = zend_string_init_interned("JG_SADHE", sizeof("JG_SADHE") - 1, 1); + zend_string *const_JG_SADHE_name = zend_string_init_interned("JG_SADHE", sizeof("JG_SADHE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_SADHE_name, &const_JG_SADHE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_SADHE_name); + zend_string_release_ex(const_JG_SADHE_name, true); zval const_JG_SEEN_value; ZVAL_LONG(&const_JG_SEEN_value, U_JG_SEEN); - zend_string *const_JG_SEEN_name = zend_string_init_interned("JG_SEEN", sizeof("JG_SEEN") - 1, 1); + zend_string *const_JG_SEEN_name = zend_string_init_interned("JG_SEEN", sizeof("JG_SEEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_SEEN_name, &const_JG_SEEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_SEEN_name); + zend_string_release_ex(const_JG_SEEN_name, true); zval const_JG_SEMKATH_value; ZVAL_LONG(&const_JG_SEMKATH_value, U_JG_SEMKATH); - zend_string *const_JG_SEMKATH_name = zend_string_init_interned("JG_SEMKATH", sizeof("JG_SEMKATH") - 1, 1); + zend_string *const_JG_SEMKATH_name = zend_string_init_interned("JG_SEMKATH", sizeof("JG_SEMKATH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_SEMKATH_name, &const_JG_SEMKATH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_SEMKATH_name); + zend_string_release_ex(const_JG_SEMKATH_name, true); zval const_JG_SHIN_value; ZVAL_LONG(&const_JG_SHIN_value, U_JG_SHIN); - zend_string *const_JG_SHIN_name = zend_string_init_interned("JG_SHIN", sizeof("JG_SHIN") - 1, 1); + zend_string *const_JG_SHIN_name = zend_string_init_interned("JG_SHIN", sizeof("JG_SHIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_SHIN_name, &const_JG_SHIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_SHIN_name); + zend_string_release_ex(const_JG_SHIN_name, true); zval const_JG_SWASH_KAF_value; ZVAL_LONG(&const_JG_SWASH_KAF_value, U_JG_SWASH_KAF); - zend_string *const_JG_SWASH_KAF_name = zend_string_init_interned("JG_SWASH_KAF", sizeof("JG_SWASH_KAF") - 1, 1); + zend_string *const_JG_SWASH_KAF_name = zend_string_init_interned("JG_SWASH_KAF", sizeof("JG_SWASH_KAF") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_SWASH_KAF_name, &const_JG_SWASH_KAF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_SWASH_KAF_name); + zend_string_release_ex(const_JG_SWASH_KAF_name, true); zval const_JG_SYRIAC_WAW_value; ZVAL_LONG(&const_JG_SYRIAC_WAW_value, U_JG_SYRIAC_WAW); - zend_string *const_JG_SYRIAC_WAW_name = zend_string_init_interned("JG_SYRIAC_WAW", sizeof("JG_SYRIAC_WAW") - 1, 1); + zend_string *const_JG_SYRIAC_WAW_name = zend_string_init_interned("JG_SYRIAC_WAW", sizeof("JG_SYRIAC_WAW") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_SYRIAC_WAW_name, &const_JG_SYRIAC_WAW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_SYRIAC_WAW_name); + zend_string_release_ex(const_JG_SYRIAC_WAW_name, true); zval const_JG_TAH_value; ZVAL_LONG(&const_JG_TAH_value, U_JG_TAH); - zend_string *const_JG_TAH_name = zend_string_init_interned("JG_TAH", sizeof("JG_TAH") - 1, 1); + zend_string *const_JG_TAH_name = zend_string_init_interned("JG_TAH", sizeof("JG_TAH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_TAH_name, &const_JG_TAH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_TAH_name); + zend_string_release_ex(const_JG_TAH_name, true); zval const_JG_TAW_value; ZVAL_LONG(&const_JG_TAW_value, U_JG_TAW); - zend_string *const_JG_TAW_name = zend_string_init_interned("JG_TAW", sizeof("JG_TAW") - 1, 1); + zend_string *const_JG_TAW_name = zend_string_init_interned("JG_TAW", sizeof("JG_TAW") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_TAW_name, &const_JG_TAW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_TAW_name); + zend_string_release_ex(const_JG_TAW_name, true); zval const_JG_TEH_MARBUTA_value; ZVAL_LONG(&const_JG_TEH_MARBUTA_value, U_JG_TEH_MARBUTA); - zend_string *const_JG_TEH_MARBUTA_name = zend_string_init_interned("JG_TEH_MARBUTA", sizeof("JG_TEH_MARBUTA") - 1, 1); + zend_string *const_JG_TEH_MARBUTA_name = zend_string_init_interned("JG_TEH_MARBUTA", sizeof("JG_TEH_MARBUTA") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_TEH_MARBUTA_name, &const_JG_TEH_MARBUTA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_TEH_MARBUTA_name); + zend_string_release_ex(const_JG_TEH_MARBUTA_name, true); zval const_JG_TETH_value; ZVAL_LONG(&const_JG_TETH_value, U_JG_TETH); - zend_string *const_JG_TETH_name = zend_string_init_interned("JG_TETH", sizeof("JG_TETH") - 1, 1); + zend_string *const_JG_TETH_name = zend_string_init_interned("JG_TETH", sizeof("JG_TETH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_TETH_name, &const_JG_TETH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_TETH_name); + zend_string_release_ex(const_JG_TETH_name, true); zval const_JG_WAW_value; ZVAL_LONG(&const_JG_WAW_value, U_JG_WAW); - zend_string *const_JG_WAW_name = zend_string_init_interned("JG_WAW", sizeof("JG_WAW") - 1, 1); + zend_string *const_JG_WAW_name = zend_string_init_interned("JG_WAW", sizeof("JG_WAW") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_WAW_name, &const_JG_WAW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_WAW_name); + zend_string_release_ex(const_JG_WAW_name, true); zval const_JG_YEH_value; ZVAL_LONG(&const_JG_YEH_value, U_JG_YEH); - zend_string *const_JG_YEH_name = zend_string_init_interned("JG_YEH", sizeof("JG_YEH") - 1, 1); + zend_string *const_JG_YEH_name = zend_string_init_interned("JG_YEH", sizeof("JG_YEH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_YEH_name, &const_JG_YEH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_YEH_name); + zend_string_release_ex(const_JG_YEH_name, true); zval const_JG_YEH_BARREE_value; ZVAL_LONG(&const_JG_YEH_BARREE_value, U_JG_YEH_BARREE); - zend_string *const_JG_YEH_BARREE_name = zend_string_init_interned("JG_YEH_BARREE", sizeof("JG_YEH_BARREE") - 1, 1); + zend_string *const_JG_YEH_BARREE_name = zend_string_init_interned("JG_YEH_BARREE", sizeof("JG_YEH_BARREE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_YEH_BARREE_name, &const_JG_YEH_BARREE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_YEH_BARREE_name); + zend_string_release_ex(const_JG_YEH_BARREE_name, true); zval const_JG_YEH_WITH_TAIL_value; ZVAL_LONG(&const_JG_YEH_WITH_TAIL_value, U_JG_YEH_WITH_TAIL); - zend_string *const_JG_YEH_WITH_TAIL_name = zend_string_init_interned("JG_YEH_WITH_TAIL", sizeof("JG_YEH_WITH_TAIL") - 1, 1); + zend_string *const_JG_YEH_WITH_TAIL_name = zend_string_init_interned("JG_YEH_WITH_TAIL", sizeof("JG_YEH_WITH_TAIL") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_YEH_WITH_TAIL_name, &const_JG_YEH_WITH_TAIL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_YEH_WITH_TAIL_name); + zend_string_release_ex(const_JG_YEH_WITH_TAIL_name, true); zval const_JG_YUDH_value; ZVAL_LONG(&const_JG_YUDH_value, U_JG_YUDH); - zend_string *const_JG_YUDH_name = zend_string_init_interned("JG_YUDH", sizeof("JG_YUDH") - 1, 1); + zend_string *const_JG_YUDH_name = zend_string_init_interned("JG_YUDH", sizeof("JG_YUDH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_YUDH_name, &const_JG_YUDH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_YUDH_name); + zend_string_release_ex(const_JG_YUDH_name, true); zval const_JG_YUDH_HE_value; ZVAL_LONG(&const_JG_YUDH_HE_value, U_JG_YUDH_HE); - zend_string *const_JG_YUDH_HE_name = zend_string_init_interned("JG_YUDH_HE", sizeof("JG_YUDH_HE") - 1, 1); + zend_string *const_JG_YUDH_HE_name = zend_string_init_interned("JG_YUDH_HE", sizeof("JG_YUDH_HE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_YUDH_HE_name, &const_JG_YUDH_HE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_YUDH_HE_name); + zend_string_release_ex(const_JG_YUDH_HE_name, true); zval const_JG_ZAIN_value; ZVAL_LONG(&const_JG_ZAIN_value, U_JG_ZAIN); - zend_string *const_JG_ZAIN_name = zend_string_init_interned("JG_ZAIN", sizeof("JG_ZAIN") - 1, 1); + zend_string *const_JG_ZAIN_name = zend_string_init_interned("JG_ZAIN", sizeof("JG_ZAIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_ZAIN_name, &const_JG_ZAIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_ZAIN_name); + zend_string_release_ex(const_JG_ZAIN_name, true); zval const_JG_FE_value; ZVAL_LONG(&const_JG_FE_value, U_JG_FE); - zend_string *const_JG_FE_name = zend_string_init_interned("JG_FE", sizeof("JG_FE") - 1, 1); + zend_string *const_JG_FE_name = zend_string_init_interned("JG_FE", sizeof("JG_FE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_FE_name, &const_JG_FE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_FE_name); + zend_string_release_ex(const_JG_FE_name, true); zval const_JG_KHAPH_value; ZVAL_LONG(&const_JG_KHAPH_value, U_JG_KHAPH); - zend_string *const_JG_KHAPH_name = zend_string_init_interned("JG_KHAPH", sizeof("JG_KHAPH") - 1, 1); + zend_string *const_JG_KHAPH_name = zend_string_init_interned("JG_KHAPH", sizeof("JG_KHAPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_KHAPH_name, &const_JG_KHAPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_KHAPH_name); + zend_string_release_ex(const_JG_KHAPH_name, true); zval const_JG_ZHAIN_value; ZVAL_LONG(&const_JG_ZHAIN_value, U_JG_ZHAIN); - zend_string *const_JG_ZHAIN_name = zend_string_init_interned("JG_ZHAIN", sizeof("JG_ZHAIN") - 1, 1); + zend_string *const_JG_ZHAIN_name = zend_string_init_interned("JG_ZHAIN", sizeof("JG_ZHAIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_ZHAIN_name, &const_JG_ZHAIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_ZHAIN_name); + zend_string_release_ex(const_JG_ZHAIN_name, true); zval const_JG_BURUSHASKI_YEH_BARREE_value; ZVAL_LONG(&const_JG_BURUSHASKI_YEH_BARREE_value, U_JG_BURUSHASKI_YEH_BARREE); - zend_string *const_JG_BURUSHASKI_YEH_BARREE_name = zend_string_init_interned("JG_BURUSHASKI_YEH_BARREE", sizeof("JG_BURUSHASKI_YEH_BARREE") - 1, 1); + zend_string *const_JG_BURUSHASKI_YEH_BARREE_name = zend_string_init_interned("JG_BURUSHASKI_YEH_BARREE", sizeof("JG_BURUSHASKI_YEH_BARREE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_BURUSHASKI_YEH_BARREE_name, &const_JG_BURUSHASKI_YEH_BARREE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_BURUSHASKI_YEH_BARREE_name); + zend_string_release_ex(const_JG_BURUSHASKI_YEH_BARREE_name, true); zval const_JG_FARSI_YEH_value; ZVAL_LONG(&const_JG_FARSI_YEH_value, U_JG_FARSI_YEH); - zend_string *const_JG_FARSI_YEH_name = zend_string_init_interned("JG_FARSI_YEH", sizeof("JG_FARSI_YEH") - 1, 1); + zend_string *const_JG_FARSI_YEH_name = zend_string_init_interned("JG_FARSI_YEH", sizeof("JG_FARSI_YEH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_FARSI_YEH_name, &const_JG_FARSI_YEH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_FARSI_YEH_name); + zend_string_release_ex(const_JG_FARSI_YEH_name, true); zval const_JG_NYA_value; ZVAL_LONG(&const_JG_NYA_value, U_JG_NYA); - zend_string *const_JG_NYA_name = zend_string_init_interned("JG_NYA", sizeof("JG_NYA") - 1, 1); + zend_string *const_JG_NYA_name = zend_string_init_interned("JG_NYA", sizeof("JG_NYA") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_NYA_name, &const_JG_NYA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_NYA_name); + zend_string_release_ex(const_JG_NYA_name, true); zval const_JG_ROHINGYA_YEH_value; ZVAL_LONG(&const_JG_ROHINGYA_YEH_value, U_JG_ROHINGYA_YEH); - zend_string *const_JG_ROHINGYA_YEH_name = zend_string_init_interned("JG_ROHINGYA_YEH", sizeof("JG_ROHINGYA_YEH") - 1, 1); + zend_string *const_JG_ROHINGYA_YEH_name = zend_string_init_interned("JG_ROHINGYA_YEH", sizeof("JG_ROHINGYA_YEH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_ROHINGYA_YEH_name, &const_JG_ROHINGYA_YEH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_ROHINGYA_YEH_name); + zend_string_release_ex(const_JG_ROHINGYA_YEH_name, true); zval const_JG_MANICHAEAN_ALEPH_value; ZVAL_LONG(&const_JG_MANICHAEAN_ALEPH_value, U_JG_MANICHAEAN_ALEPH); - zend_string *const_JG_MANICHAEAN_ALEPH_name = zend_string_init_interned("JG_MANICHAEAN_ALEPH", sizeof("JG_MANICHAEAN_ALEPH") - 1, 1); + zend_string *const_JG_MANICHAEAN_ALEPH_name = zend_string_init_interned("JG_MANICHAEAN_ALEPH", sizeof("JG_MANICHAEAN_ALEPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_ALEPH_name, &const_JG_MANICHAEAN_ALEPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_ALEPH_name); + zend_string_release_ex(const_JG_MANICHAEAN_ALEPH_name, true); zval const_JG_MANICHAEAN_AYIN_value; ZVAL_LONG(&const_JG_MANICHAEAN_AYIN_value, U_JG_MANICHAEAN_AYIN); - zend_string *const_JG_MANICHAEAN_AYIN_name = zend_string_init_interned("JG_MANICHAEAN_AYIN", sizeof("JG_MANICHAEAN_AYIN") - 1, 1); + zend_string *const_JG_MANICHAEAN_AYIN_name = zend_string_init_interned("JG_MANICHAEAN_AYIN", sizeof("JG_MANICHAEAN_AYIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_AYIN_name, &const_JG_MANICHAEAN_AYIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_AYIN_name); + zend_string_release_ex(const_JG_MANICHAEAN_AYIN_name, true); zval const_JG_MANICHAEAN_BETH_value; ZVAL_LONG(&const_JG_MANICHAEAN_BETH_value, U_JG_MANICHAEAN_BETH); - zend_string *const_JG_MANICHAEAN_BETH_name = zend_string_init_interned("JG_MANICHAEAN_BETH", sizeof("JG_MANICHAEAN_BETH") - 1, 1); + zend_string *const_JG_MANICHAEAN_BETH_name = zend_string_init_interned("JG_MANICHAEAN_BETH", sizeof("JG_MANICHAEAN_BETH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_BETH_name, &const_JG_MANICHAEAN_BETH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_BETH_name); + zend_string_release_ex(const_JG_MANICHAEAN_BETH_name, true); zval const_JG_MANICHAEAN_DALETH_value; ZVAL_LONG(&const_JG_MANICHAEAN_DALETH_value, U_JG_MANICHAEAN_DALETH); - zend_string *const_JG_MANICHAEAN_DALETH_name = zend_string_init_interned("JG_MANICHAEAN_DALETH", sizeof("JG_MANICHAEAN_DALETH") - 1, 1); + zend_string *const_JG_MANICHAEAN_DALETH_name = zend_string_init_interned("JG_MANICHAEAN_DALETH", sizeof("JG_MANICHAEAN_DALETH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_DALETH_name, &const_JG_MANICHAEAN_DALETH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_DALETH_name); + zend_string_release_ex(const_JG_MANICHAEAN_DALETH_name, true); zval const_JG_MANICHAEAN_DHAMEDH_value; ZVAL_LONG(&const_JG_MANICHAEAN_DHAMEDH_value, U_JG_MANICHAEAN_DHAMEDH); - zend_string *const_JG_MANICHAEAN_DHAMEDH_name = zend_string_init_interned("JG_MANICHAEAN_DHAMEDH", sizeof("JG_MANICHAEAN_DHAMEDH") - 1, 1); + zend_string *const_JG_MANICHAEAN_DHAMEDH_name = zend_string_init_interned("JG_MANICHAEAN_DHAMEDH", sizeof("JG_MANICHAEAN_DHAMEDH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_DHAMEDH_name, &const_JG_MANICHAEAN_DHAMEDH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_DHAMEDH_name); + zend_string_release_ex(const_JG_MANICHAEAN_DHAMEDH_name, true); zval const_JG_MANICHAEAN_FIVE_value; ZVAL_LONG(&const_JG_MANICHAEAN_FIVE_value, U_JG_MANICHAEAN_FIVE); - zend_string *const_JG_MANICHAEAN_FIVE_name = zend_string_init_interned("JG_MANICHAEAN_FIVE", sizeof("JG_MANICHAEAN_FIVE") - 1, 1); + zend_string *const_JG_MANICHAEAN_FIVE_name = zend_string_init_interned("JG_MANICHAEAN_FIVE", sizeof("JG_MANICHAEAN_FIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_FIVE_name, &const_JG_MANICHAEAN_FIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_FIVE_name); + zend_string_release_ex(const_JG_MANICHAEAN_FIVE_name, true); zval const_JG_MANICHAEAN_GIMEL_value; ZVAL_LONG(&const_JG_MANICHAEAN_GIMEL_value, U_JG_MANICHAEAN_GIMEL); - zend_string *const_JG_MANICHAEAN_GIMEL_name = zend_string_init_interned("JG_MANICHAEAN_GIMEL", sizeof("JG_MANICHAEAN_GIMEL") - 1, 1); + zend_string *const_JG_MANICHAEAN_GIMEL_name = zend_string_init_interned("JG_MANICHAEAN_GIMEL", sizeof("JG_MANICHAEAN_GIMEL") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_GIMEL_name, &const_JG_MANICHAEAN_GIMEL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_GIMEL_name); + zend_string_release_ex(const_JG_MANICHAEAN_GIMEL_name, true); zval const_JG_MANICHAEAN_HETH_value; ZVAL_LONG(&const_JG_MANICHAEAN_HETH_value, U_JG_MANICHAEAN_HETH); - zend_string *const_JG_MANICHAEAN_HETH_name = zend_string_init_interned("JG_MANICHAEAN_HETH", sizeof("JG_MANICHAEAN_HETH") - 1, 1); + zend_string *const_JG_MANICHAEAN_HETH_name = zend_string_init_interned("JG_MANICHAEAN_HETH", sizeof("JG_MANICHAEAN_HETH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_HETH_name, &const_JG_MANICHAEAN_HETH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_HETH_name); + zend_string_release_ex(const_JG_MANICHAEAN_HETH_name, true); zval const_JG_MANICHAEAN_HUNDRED_value; ZVAL_LONG(&const_JG_MANICHAEAN_HUNDRED_value, U_JG_MANICHAEAN_HUNDRED); - zend_string *const_JG_MANICHAEAN_HUNDRED_name = zend_string_init_interned("JG_MANICHAEAN_HUNDRED", sizeof("JG_MANICHAEAN_HUNDRED") - 1, 1); + zend_string *const_JG_MANICHAEAN_HUNDRED_name = zend_string_init_interned("JG_MANICHAEAN_HUNDRED", sizeof("JG_MANICHAEAN_HUNDRED") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_HUNDRED_name, &const_JG_MANICHAEAN_HUNDRED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_HUNDRED_name); + zend_string_release_ex(const_JG_MANICHAEAN_HUNDRED_name, true); zval const_JG_MANICHAEAN_KAPH_value; ZVAL_LONG(&const_JG_MANICHAEAN_KAPH_value, U_JG_MANICHAEAN_KAPH); - zend_string *const_JG_MANICHAEAN_KAPH_name = zend_string_init_interned("JG_MANICHAEAN_KAPH", sizeof("JG_MANICHAEAN_KAPH") - 1, 1); + zend_string *const_JG_MANICHAEAN_KAPH_name = zend_string_init_interned("JG_MANICHAEAN_KAPH", sizeof("JG_MANICHAEAN_KAPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_KAPH_name, &const_JG_MANICHAEAN_KAPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_KAPH_name); + zend_string_release_ex(const_JG_MANICHAEAN_KAPH_name, true); zval const_JG_MANICHAEAN_LAMEDH_value; ZVAL_LONG(&const_JG_MANICHAEAN_LAMEDH_value, U_JG_MANICHAEAN_LAMEDH); - zend_string *const_JG_MANICHAEAN_LAMEDH_name = zend_string_init_interned("JG_MANICHAEAN_LAMEDH", sizeof("JG_MANICHAEAN_LAMEDH") - 1, 1); + zend_string *const_JG_MANICHAEAN_LAMEDH_name = zend_string_init_interned("JG_MANICHAEAN_LAMEDH", sizeof("JG_MANICHAEAN_LAMEDH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_LAMEDH_name, &const_JG_MANICHAEAN_LAMEDH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_LAMEDH_name); + zend_string_release_ex(const_JG_MANICHAEAN_LAMEDH_name, true); zval const_JG_MANICHAEAN_MEM_value; ZVAL_LONG(&const_JG_MANICHAEAN_MEM_value, U_JG_MANICHAEAN_MEM); - zend_string *const_JG_MANICHAEAN_MEM_name = zend_string_init_interned("JG_MANICHAEAN_MEM", sizeof("JG_MANICHAEAN_MEM") - 1, 1); + zend_string *const_JG_MANICHAEAN_MEM_name = zend_string_init_interned("JG_MANICHAEAN_MEM", sizeof("JG_MANICHAEAN_MEM") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_MEM_name, &const_JG_MANICHAEAN_MEM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_MEM_name); + zend_string_release_ex(const_JG_MANICHAEAN_MEM_name, true); zval const_JG_MANICHAEAN_NUN_value; ZVAL_LONG(&const_JG_MANICHAEAN_NUN_value, U_JG_MANICHAEAN_NUN); - zend_string *const_JG_MANICHAEAN_NUN_name = zend_string_init_interned("JG_MANICHAEAN_NUN", sizeof("JG_MANICHAEAN_NUN") - 1, 1); + zend_string *const_JG_MANICHAEAN_NUN_name = zend_string_init_interned("JG_MANICHAEAN_NUN", sizeof("JG_MANICHAEAN_NUN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_NUN_name, &const_JG_MANICHAEAN_NUN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_NUN_name); + zend_string_release_ex(const_JG_MANICHAEAN_NUN_name, true); zval const_JG_MANICHAEAN_ONE_value; ZVAL_LONG(&const_JG_MANICHAEAN_ONE_value, U_JG_MANICHAEAN_ONE); - zend_string *const_JG_MANICHAEAN_ONE_name = zend_string_init_interned("JG_MANICHAEAN_ONE", sizeof("JG_MANICHAEAN_ONE") - 1, 1); + zend_string *const_JG_MANICHAEAN_ONE_name = zend_string_init_interned("JG_MANICHAEAN_ONE", sizeof("JG_MANICHAEAN_ONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_ONE_name, &const_JG_MANICHAEAN_ONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_ONE_name); + zend_string_release_ex(const_JG_MANICHAEAN_ONE_name, true); zval const_JG_MANICHAEAN_PE_value; ZVAL_LONG(&const_JG_MANICHAEAN_PE_value, U_JG_MANICHAEAN_PE); - zend_string *const_JG_MANICHAEAN_PE_name = zend_string_init_interned("JG_MANICHAEAN_PE", sizeof("JG_MANICHAEAN_PE") - 1, 1); + zend_string *const_JG_MANICHAEAN_PE_name = zend_string_init_interned("JG_MANICHAEAN_PE", sizeof("JG_MANICHAEAN_PE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_PE_name, &const_JG_MANICHAEAN_PE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_PE_name); + zend_string_release_ex(const_JG_MANICHAEAN_PE_name, true); zval const_JG_MANICHAEAN_QOPH_value; ZVAL_LONG(&const_JG_MANICHAEAN_QOPH_value, U_JG_MANICHAEAN_QOPH); - zend_string *const_JG_MANICHAEAN_QOPH_name = zend_string_init_interned("JG_MANICHAEAN_QOPH", sizeof("JG_MANICHAEAN_QOPH") - 1, 1); + zend_string *const_JG_MANICHAEAN_QOPH_name = zend_string_init_interned("JG_MANICHAEAN_QOPH", sizeof("JG_MANICHAEAN_QOPH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_QOPH_name, &const_JG_MANICHAEAN_QOPH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_QOPH_name); + zend_string_release_ex(const_JG_MANICHAEAN_QOPH_name, true); zval const_JG_MANICHAEAN_RESH_value; ZVAL_LONG(&const_JG_MANICHAEAN_RESH_value, U_JG_MANICHAEAN_RESH); - zend_string *const_JG_MANICHAEAN_RESH_name = zend_string_init_interned("JG_MANICHAEAN_RESH", sizeof("JG_MANICHAEAN_RESH") - 1, 1); + zend_string *const_JG_MANICHAEAN_RESH_name = zend_string_init_interned("JG_MANICHAEAN_RESH", sizeof("JG_MANICHAEAN_RESH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_RESH_name, &const_JG_MANICHAEAN_RESH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_RESH_name); + zend_string_release_ex(const_JG_MANICHAEAN_RESH_name, true); zval const_JG_MANICHAEAN_SADHE_value; ZVAL_LONG(&const_JG_MANICHAEAN_SADHE_value, U_JG_MANICHAEAN_SADHE); - zend_string *const_JG_MANICHAEAN_SADHE_name = zend_string_init_interned("JG_MANICHAEAN_SADHE", sizeof("JG_MANICHAEAN_SADHE") - 1, 1); + zend_string *const_JG_MANICHAEAN_SADHE_name = zend_string_init_interned("JG_MANICHAEAN_SADHE", sizeof("JG_MANICHAEAN_SADHE") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_SADHE_name, &const_JG_MANICHAEAN_SADHE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_SADHE_name); + zend_string_release_ex(const_JG_MANICHAEAN_SADHE_name, true); zval const_JG_MANICHAEAN_SAMEKH_value; ZVAL_LONG(&const_JG_MANICHAEAN_SAMEKH_value, U_JG_MANICHAEAN_SAMEKH); - zend_string *const_JG_MANICHAEAN_SAMEKH_name = zend_string_init_interned("JG_MANICHAEAN_SAMEKH", sizeof("JG_MANICHAEAN_SAMEKH") - 1, 1); + zend_string *const_JG_MANICHAEAN_SAMEKH_name = zend_string_init_interned("JG_MANICHAEAN_SAMEKH", sizeof("JG_MANICHAEAN_SAMEKH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_SAMEKH_name, &const_JG_MANICHAEAN_SAMEKH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_SAMEKH_name); + zend_string_release_ex(const_JG_MANICHAEAN_SAMEKH_name, true); zval const_JG_MANICHAEAN_TAW_value; ZVAL_LONG(&const_JG_MANICHAEAN_TAW_value, U_JG_MANICHAEAN_TAW); - zend_string *const_JG_MANICHAEAN_TAW_name = zend_string_init_interned("JG_MANICHAEAN_TAW", sizeof("JG_MANICHAEAN_TAW") - 1, 1); + zend_string *const_JG_MANICHAEAN_TAW_name = zend_string_init_interned("JG_MANICHAEAN_TAW", sizeof("JG_MANICHAEAN_TAW") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_TAW_name, &const_JG_MANICHAEAN_TAW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_TAW_name); + zend_string_release_ex(const_JG_MANICHAEAN_TAW_name, true); zval const_JG_MANICHAEAN_TEN_value; ZVAL_LONG(&const_JG_MANICHAEAN_TEN_value, U_JG_MANICHAEAN_TEN); - zend_string *const_JG_MANICHAEAN_TEN_name = zend_string_init_interned("JG_MANICHAEAN_TEN", sizeof("JG_MANICHAEAN_TEN") - 1, 1); + zend_string *const_JG_MANICHAEAN_TEN_name = zend_string_init_interned("JG_MANICHAEAN_TEN", sizeof("JG_MANICHAEAN_TEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_TEN_name, &const_JG_MANICHAEAN_TEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_TEN_name); + zend_string_release_ex(const_JG_MANICHAEAN_TEN_name, true); zval const_JG_MANICHAEAN_TETH_value; ZVAL_LONG(&const_JG_MANICHAEAN_TETH_value, U_JG_MANICHAEAN_TETH); - zend_string *const_JG_MANICHAEAN_TETH_name = zend_string_init_interned("JG_MANICHAEAN_TETH", sizeof("JG_MANICHAEAN_TETH") - 1, 1); + zend_string *const_JG_MANICHAEAN_TETH_name = zend_string_init_interned("JG_MANICHAEAN_TETH", sizeof("JG_MANICHAEAN_TETH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_TETH_name, &const_JG_MANICHAEAN_TETH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_TETH_name); + zend_string_release_ex(const_JG_MANICHAEAN_TETH_name, true); zval const_JG_MANICHAEAN_THAMEDH_value; ZVAL_LONG(&const_JG_MANICHAEAN_THAMEDH_value, U_JG_MANICHAEAN_THAMEDH); - zend_string *const_JG_MANICHAEAN_THAMEDH_name = zend_string_init_interned("JG_MANICHAEAN_THAMEDH", sizeof("JG_MANICHAEAN_THAMEDH") - 1, 1); + zend_string *const_JG_MANICHAEAN_THAMEDH_name = zend_string_init_interned("JG_MANICHAEAN_THAMEDH", sizeof("JG_MANICHAEAN_THAMEDH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_THAMEDH_name, &const_JG_MANICHAEAN_THAMEDH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_THAMEDH_name); + zend_string_release_ex(const_JG_MANICHAEAN_THAMEDH_name, true); zval const_JG_MANICHAEAN_TWENTY_value; ZVAL_LONG(&const_JG_MANICHAEAN_TWENTY_value, U_JG_MANICHAEAN_TWENTY); - zend_string *const_JG_MANICHAEAN_TWENTY_name = zend_string_init_interned("JG_MANICHAEAN_TWENTY", sizeof("JG_MANICHAEAN_TWENTY") - 1, 1); + zend_string *const_JG_MANICHAEAN_TWENTY_name = zend_string_init_interned("JG_MANICHAEAN_TWENTY", sizeof("JG_MANICHAEAN_TWENTY") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_TWENTY_name, &const_JG_MANICHAEAN_TWENTY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_TWENTY_name); + zend_string_release_ex(const_JG_MANICHAEAN_TWENTY_name, true); zval const_JG_MANICHAEAN_WAW_value; ZVAL_LONG(&const_JG_MANICHAEAN_WAW_value, U_JG_MANICHAEAN_WAW); - zend_string *const_JG_MANICHAEAN_WAW_name = zend_string_init_interned("JG_MANICHAEAN_WAW", sizeof("JG_MANICHAEAN_WAW") - 1, 1); + zend_string *const_JG_MANICHAEAN_WAW_name = zend_string_init_interned("JG_MANICHAEAN_WAW", sizeof("JG_MANICHAEAN_WAW") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_WAW_name, &const_JG_MANICHAEAN_WAW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_WAW_name); + zend_string_release_ex(const_JG_MANICHAEAN_WAW_name, true); zval const_JG_MANICHAEAN_YODH_value; ZVAL_LONG(&const_JG_MANICHAEAN_YODH_value, U_JG_MANICHAEAN_YODH); - zend_string *const_JG_MANICHAEAN_YODH_name = zend_string_init_interned("JG_MANICHAEAN_YODH", sizeof("JG_MANICHAEAN_YODH") - 1, 1); + zend_string *const_JG_MANICHAEAN_YODH_name = zend_string_init_interned("JG_MANICHAEAN_YODH", sizeof("JG_MANICHAEAN_YODH") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_YODH_name, &const_JG_MANICHAEAN_YODH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_YODH_name); + zend_string_release_ex(const_JG_MANICHAEAN_YODH_name, true); zval const_JG_MANICHAEAN_ZAYIN_value; ZVAL_LONG(&const_JG_MANICHAEAN_ZAYIN_value, U_JG_MANICHAEAN_ZAYIN); - zend_string *const_JG_MANICHAEAN_ZAYIN_name = zend_string_init_interned("JG_MANICHAEAN_ZAYIN", sizeof("JG_MANICHAEAN_ZAYIN") - 1, 1); + zend_string *const_JG_MANICHAEAN_ZAYIN_name = zend_string_init_interned("JG_MANICHAEAN_ZAYIN", sizeof("JG_MANICHAEAN_ZAYIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_MANICHAEAN_ZAYIN_name, &const_JG_MANICHAEAN_ZAYIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_MANICHAEAN_ZAYIN_name); + zend_string_release_ex(const_JG_MANICHAEAN_ZAYIN_name, true); zval const_JG_STRAIGHT_WAW_value; ZVAL_LONG(&const_JG_STRAIGHT_WAW_value, U_JG_STRAIGHT_WAW); - zend_string *const_JG_STRAIGHT_WAW_name = zend_string_init_interned("JG_STRAIGHT_WAW", sizeof("JG_STRAIGHT_WAW") - 1, 1); + zend_string *const_JG_STRAIGHT_WAW_name = zend_string_init_interned("JG_STRAIGHT_WAW", sizeof("JG_STRAIGHT_WAW") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_STRAIGHT_WAW_name, &const_JG_STRAIGHT_WAW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_STRAIGHT_WAW_name); + zend_string_release_ex(const_JG_STRAIGHT_WAW_name, true); zval const_JG_COUNT_value; ZVAL_LONG(&const_JG_COUNT_value, U_JG_COUNT); - zend_string *const_JG_COUNT_name = zend_string_init_interned("JG_COUNT", sizeof("JG_COUNT") - 1, 1); + zend_string *const_JG_COUNT_name = zend_string_init_interned("JG_COUNT", sizeof("JG_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_JG_COUNT_name, &const_JG_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_JG_COUNT_name); + zend_string_release_ex(const_JG_COUNT_name, true); zval const_GCB_OTHER_value; ZVAL_LONG(&const_GCB_OTHER_value, U_GCB_OTHER); - zend_string *const_GCB_OTHER_name = zend_string_init_interned("GCB_OTHER", sizeof("GCB_OTHER") - 1, 1); + zend_string *const_GCB_OTHER_name = zend_string_init_interned("GCB_OTHER", sizeof("GCB_OTHER") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_OTHER_name, &const_GCB_OTHER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_OTHER_name); + zend_string_release_ex(const_GCB_OTHER_name, true); zval const_GCB_CONTROL_value; ZVAL_LONG(&const_GCB_CONTROL_value, U_GCB_CONTROL); - zend_string *const_GCB_CONTROL_name = zend_string_init_interned("GCB_CONTROL", sizeof("GCB_CONTROL") - 1, 1); + zend_string *const_GCB_CONTROL_name = zend_string_init_interned("GCB_CONTROL", sizeof("GCB_CONTROL") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_CONTROL_name, &const_GCB_CONTROL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_CONTROL_name); + zend_string_release_ex(const_GCB_CONTROL_name, true); zval const_GCB_CR_value; ZVAL_LONG(&const_GCB_CR_value, U_GCB_CR); - zend_string *const_GCB_CR_name = zend_string_init_interned("GCB_CR", sizeof("GCB_CR") - 1, 1); + zend_string *const_GCB_CR_name = zend_string_init_interned("GCB_CR", sizeof("GCB_CR") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_CR_name, &const_GCB_CR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_CR_name); + zend_string_release_ex(const_GCB_CR_name, true); zval const_GCB_EXTEND_value; ZVAL_LONG(&const_GCB_EXTEND_value, U_GCB_EXTEND); - zend_string *const_GCB_EXTEND_name = zend_string_init_interned("GCB_EXTEND", sizeof("GCB_EXTEND") - 1, 1); + zend_string *const_GCB_EXTEND_name = zend_string_init_interned("GCB_EXTEND", sizeof("GCB_EXTEND") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_EXTEND_name, &const_GCB_EXTEND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_EXTEND_name); + zend_string_release_ex(const_GCB_EXTEND_name, true); zval const_GCB_L_value; ZVAL_LONG(&const_GCB_L_value, U_GCB_L); - zend_string *const_GCB_L_name = zend_string_init_interned("GCB_L", sizeof("GCB_L") - 1, 1); + zend_string *const_GCB_L_name = zend_string_init_interned("GCB_L", sizeof("GCB_L") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_L_name, &const_GCB_L_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_L_name); + zend_string_release_ex(const_GCB_L_name, true); zval const_GCB_LF_value; ZVAL_LONG(&const_GCB_LF_value, U_GCB_LF); - zend_string *const_GCB_LF_name = zend_string_init_interned("GCB_LF", sizeof("GCB_LF") - 1, 1); + zend_string *const_GCB_LF_name = zend_string_init_interned("GCB_LF", sizeof("GCB_LF") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_LF_name, &const_GCB_LF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_LF_name); + zend_string_release_ex(const_GCB_LF_name, true); zval const_GCB_LV_value; ZVAL_LONG(&const_GCB_LV_value, U_GCB_LV); - zend_string *const_GCB_LV_name = zend_string_init_interned("GCB_LV", sizeof("GCB_LV") - 1, 1); + zend_string *const_GCB_LV_name = zend_string_init_interned("GCB_LV", sizeof("GCB_LV") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_LV_name, &const_GCB_LV_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_LV_name); + zend_string_release_ex(const_GCB_LV_name, true); zval const_GCB_LVT_value; ZVAL_LONG(&const_GCB_LVT_value, U_GCB_LVT); - zend_string *const_GCB_LVT_name = zend_string_init_interned("GCB_LVT", sizeof("GCB_LVT") - 1, 1); + zend_string *const_GCB_LVT_name = zend_string_init_interned("GCB_LVT", sizeof("GCB_LVT") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_LVT_name, &const_GCB_LVT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_LVT_name); + zend_string_release_ex(const_GCB_LVT_name, true); zval const_GCB_T_value; ZVAL_LONG(&const_GCB_T_value, U_GCB_T); - zend_string *const_GCB_T_name = zend_string_init_interned("GCB_T", sizeof("GCB_T") - 1, 1); + zend_string *const_GCB_T_name = zend_string_init_interned("GCB_T", sizeof("GCB_T") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_T_name, &const_GCB_T_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_T_name); + zend_string_release_ex(const_GCB_T_name, true); zval const_GCB_V_value; ZVAL_LONG(&const_GCB_V_value, U_GCB_V); - zend_string *const_GCB_V_name = zend_string_init_interned("GCB_V", sizeof("GCB_V") - 1, 1); + zend_string *const_GCB_V_name = zend_string_init_interned("GCB_V", sizeof("GCB_V") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_V_name, &const_GCB_V_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_V_name); + zend_string_release_ex(const_GCB_V_name, true); zval const_GCB_SPACING_MARK_value; ZVAL_LONG(&const_GCB_SPACING_MARK_value, U_GCB_SPACING_MARK); - zend_string *const_GCB_SPACING_MARK_name = zend_string_init_interned("GCB_SPACING_MARK", sizeof("GCB_SPACING_MARK") - 1, 1); + zend_string *const_GCB_SPACING_MARK_name = zend_string_init_interned("GCB_SPACING_MARK", sizeof("GCB_SPACING_MARK") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_SPACING_MARK_name, &const_GCB_SPACING_MARK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_SPACING_MARK_name); + zend_string_release_ex(const_GCB_SPACING_MARK_name, true); zval const_GCB_PREPEND_value; ZVAL_LONG(&const_GCB_PREPEND_value, U_GCB_PREPEND); - zend_string *const_GCB_PREPEND_name = zend_string_init_interned("GCB_PREPEND", sizeof("GCB_PREPEND") - 1, 1); + zend_string *const_GCB_PREPEND_name = zend_string_init_interned("GCB_PREPEND", sizeof("GCB_PREPEND") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_PREPEND_name, &const_GCB_PREPEND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_PREPEND_name); + zend_string_release_ex(const_GCB_PREPEND_name, true); zval const_GCB_REGIONAL_INDICATOR_value; ZVAL_LONG(&const_GCB_REGIONAL_INDICATOR_value, U_GCB_REGIONAL_INDICATOR); - zend_string *const_GCB_REGIONAL_INDICATOR_name = zend_string_init_interned("GCB_REGIONAL_INDICATOR", sizeof("GCB_REGIONAL_INDICATOR") - 1, 1); + zend_string *const_GCB_REGIONAL_INDICATOR_name = zend_string_init_interned("GCB_REGIONAL_INDICATOR", sizeof("GCB_REGIONAL_INDICATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_REGIONAL_INDICATOR_name, &const_GCB_REGIONAL_INDICATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_REGIONAL_INDICATOR_name); + zend_string_release_ex(const_GCB_REGIONAL_INDICATOR_name, true); zval const_GCB_COUNT_value; ZVAL_LONG(&const_GCB_COUNT_value, U_GCB_COUNT); - zend_string *const_GCB_COUNT_name = zend_string_init_interned("GCB_COUNT", sizeof("GCB_COUNT") - 1, 1); + zend_string *const_GCB_COUNT_name = zend_string_init_interned("GCB_COUNT", sizeof("GCB_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_GCB_COUNT_name, &const_GCB_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GCB_COUNT_name); + zend_string_release_ex(const_GCB_COUNT_name, true); zval const_WB_OTHER_value; ZVAL_LONG(&const_WB_OTHER_value, U_WB_OTHER); - zend_string *const_WB_OTHER_name = zend_string_init_interned("WB_OTHER", sizeof("WB_OTHER") - 1, 1); + zend_string *const_WB_OTHER_name = zend_string_init_interned("WB_OTHER", sizeof("WB_OTHER") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_OTHER_name, &const_WB_OTHER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_OTHER_name); + zend_string_release_ex(const_WB_OTHER_name, true); zval const_WB_ALETTER_value; ZVAL_LONG(&const_WB_ALETTER_value, U_WB_ALETTER); - zend_string *const_WB_ALETTER_name = zend_string_init_interned("WB_ALETTER", sizeof("WB_ALETTER") - 1, 1); + zend_string *const_WB_ALETTER_name = zend_string_init_interned("WB_ALETTER", sizeof("WB_ALETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_ALETTER_name, &const_WB_ALETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_ALETTER_name); + zend_string_release_ex(const_WB_ALETTER_name, true); zval const_WB_FORMAT_value; ZVAL_LONG(&const_WB_FORMAT_value, U_WB_FORMAT); - zend_string *const_WB_FORMAT_name = zend_string_init_interned("WB_FORMAT", sizeof("WB_FORMAT") - 1, 1); + zend_string *const_WB_FORMAT_name = zend_string_init_interned("WB_FORMAT", sizeof("WB_FORMAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_FORMAT_name, &const_WB_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_FORMAT_name); + zend_string_release_ex(const_WB_FORMAT_name, true); zval const_WB_KATAKANA_value; ZVAL_LONG(&const_WB_KATAKANA_value, U_WB_KATAKANA); - zend_string *const_WB_KATAKANA_name = zend_string_init_interned("WB_KATAKANA", sizeof("WB_KATAKANA") - 1, 1); + zend_string *const_WB_KATAKANA_name = zend_string_init_interned("WB_KATAKANA", sizeof("WB_KATAKANA") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_KATAKANA_name, &const_WB_KATAKANA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_KATAKANA_name); + zend_string_release_ex(const_WB_KATAKANA_name, true); zval const_WB_MIDLETTER_value; ZVAL_LONG(&const_WB_MIDLETTER_value, U_WB_MIDLETTER); - zend_string *const_WB_MIDLETTER_name = zend_string_init_interned("WB_MIDLETTER", sizeof("WB_MIDLETTER") - 1, 1); + zend_string *const_WB_MIDLETTER_name = zend_string_init_interned("WB_MIDLETTER", sizeof("WB_MIDLETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_MIDLETTER_name, &const_WB_MIDLETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_MIDLETTER_name); + zend_string_release_ex(const_WB_MIDLETTER_name, true); zval const_WB_MIDNUM_value; ZVAL_LONG(&const_WB_MIDNUM_value, U_WB_MIDNUM); - zend_string *const_WB_MIDNUM_name = zend_string_init_interned("WB_MIDNUM", sizeof("WB_MIDNUM") - 1, 1); + zend_string *const_WB_MIDNUM_name = zend_string_init_interned("WB_MIDNUM", sizeof("WB_MIDNUM") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_MIDNUM_name, &const_WB_MIDNUM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_MIDNUM_name); + zend_string_release_ex(const_WB_MIDNUM_name, true); zval const_WB_NUMERIC_value; ZVAL_LONG(&const_WB_NUMERIC_value, U_WB_NUMERIC); - zend_string *const_WB_NUMERIC_name = zend_string_init_interned("WB_NUMERIC", sizeof("WB_NUMERIC") - 1, 1); + zend_string *const_WB_NUMERIC_name = zend_string_init_interned("WB_NUMERIC", sizeof("WB_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_NUMERIC_name, &const_WB_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_NUMERIC_name); + zend_string_release_ex(const_WB_NUMERIC_name, true); zval const_WB_EXTENDNUMLET_value; ZVAL_LONG(&const_WB_EXTENDNUMLET_value, U_WB_EXTENDNUMLET); - zend_string *const_WB_EXTENDNUMLET_name = zend_string_init_interned("WB_EXTENDNUMLET", sizeof("WB_EXTENDNUMLET") - 1, 1); + zend_string *const_WB_EXTENDNUMLET_name = zend_string_init_interned("WB_EXTENDNUMLET", sizeof("WB_EXTENDNUMLET") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_EXTENDNUMLET_name, &const_WB_EXTENDNUMLET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_EXTENDNUMLET_name); + zend_string_release_ex(const_WB_EXTENDNUMLET_name, true); zval const_WB_CR_value; ZVAL_LONG(&const_WB_CR_value, U_WB_CR); - zend_string *const_WB_CR_name = zend_string_init_interned("WB_CR", sizeof("WB_CR") - 1, 1); + zend_string *const_WB_CR_name = zend_string_init_interned("WB_CR", sizeof("WB_CR") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_CR_name, &const_WB_CR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_CR_name); + zend_string_release_ex(const_WB_CR_name, true); zval const_WB_EXTEND_value; ZVAL_LONG(&const_WB_EXTEND_value, U_WB_EXTEND); - zend_string *const_WB_EXTEND_name = zend_string_init_interned("WB_EXTEND", sizeof("WB_EXTEND") - 1, 1); + zend_string *const_WB_EXTEND_name = zend_string_init_interned("WB_EXTEND", sizeof("WB_EXTEND") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_EXTEND_name, &const_WB_EXTEND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_EXTEND_name); + zend_string_release_ex(const_WB_EXTEND_name, true); zval const_WB_LF_value; ZVAL_LONG(&const_WB_LF_value, U_WB_LF); - zend_string *const_WB_LF_name = zend_string_init_interned("WB_LF", sizeof("WB_LF") - 1, 1); + zend_string *const_WB_LF_name = zend_string_init_interned("WB_LF", sizeof("WB_LF") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_LF_name, &const_WB_LF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_LF_name); + zend_string_release_ex(const_WB_LF_name, true); zval const_WB_MIDNUMLET_value; ZVAL_LONG(&const_WB_MIDNUMLET_value, U_WB_MIDNUMLET); - zend_string *const_WB_MIDNUMLET_name = zend_string_init_interned("WB_MIDNUMLET", sizeof("WB_MIDNUMLET") - 1, 1); + zend_string *const_WB_MIDNUMLET_name = zend_string_init_interned("WB_MIDNUMLET", sizeof("WB_MIDNUMLET") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_MIDNUMLET_name, &const_WB_MIDNUMLET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_MIDNUMLET_name); + zend_string_release_ex(const_WB_MIDNUMLET_name, true); zval const_WB_NEWLINE_value; ZVAL_LONG(&const_WB_NEWLINE_value, U_WB_NEWLINE); - zend_string *const_WB_NEWLINE_name = zend_string_init_interned("WB_NEWLINE", sizeof("WB_NEWLINE") - 1, 1); + zend_string *const_WB_NEWLINE_name = zend_string_init_interned("WB_NEWLINE", sizeof("WB_NEWLINE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_NEWLINE_name, &const_WB_NEWLINE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_NEWLINE_name); + zend_string_release_ex(const_WB_NEWLINE_name, true); zval const_WB_REGIONAL_INDICATOR_value; ZVAL_LONG(&const_WB_REGIONAL_INDICATOR_value, U_WB_REGIONAL_INDICATOR); - zend_string *const_WB_REGIONAL_INDICATOR_name = zend_string_init_interned("WB_REGIONAL_INDICATOR", sizeof("WB_REGIONAL_INDICATOR") - 1, 1); + zend_string *const_WB_REGIONAL_INDICATOR_name = zend_string_init_interned("WB_REGIONAL_INDICATOR", sizeof("WB_REGIONAL_INDICATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_REGIONAL_INDICATOR_name, &const_WB_REGIONAL_INDICATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_REGIONAL_INDICATOR_name); + zend_string_release_ex(const_WB_REGIONAL_INDICATOR_name, true); zval const_WB_HEBREW_LETTER_value; ZVAL_LONG(&const_WB_HEBREW_LETTER_value, U_WB_HEBREW_LETTER); - zend_string *const_WB_HEBREW_LETTER_name = zend_string_init_interned("WB_HEBREW_LETTER", sizeof("WB_HEBREW_LETTER") - 1, 1); + zend_string *const_WB_HEBREW_LETTER_name = zend_string_init_interned("WB_HEBREW_LETTER", sizeof("WB_HEBREW_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_HEBREW_LETTER_name, &const_WB_HEBREW_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_HEBREW_LETTER_name); + zend_string_release_ex(const_WB_HEBREW_LETTER_name, true); zval const_WB_SINGLE_QUOTE_value; ZVAL_LONG(&const_WB_SINGLE_QUOTE_value, U_WB_SINGLE_QUOTE); - zend_string *const_WB_SINGLE_QUOTE_name = zend_string_init_interned("WB_SINGLE_QUOTE", sizeof("WB_SINGLE_QUOTE") - 1, 1); + zend_string *const_WB_SINGLE_QUOTE_name = zend_string_init_interned("WB_SINGLE_QUOTE", sizeof("WB_SINGLE_QUOTE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_SINGLE_QUOTE_name, &const_WB_SINGLE_QUOTE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_SINGLE_QUOTE_name); + zend_string_release_ex(const_WB_SINGLE_QUOTE_name, true); zval const_WB_DOUBLE_QUOTE_value; ZVAL_LONG(&const_WB_DOUBLE_QUOTE_value, U_WB_DOUBLE_QUOTE); - zend_string *const_WB_DOUBLE_QUOTE_name = zend_string_init_interned("WB_DOUBLE_QUOTE", sizeof("WB_DOUBLE_QUOTE") - 1, 1); + zend_string *const_WB_DOUBLE_QUOTE_name = zend_string_init_interned("WB_DOUBLE_QUOTE", sizeof("WB_DOUBLE_QUOTE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_DOUBLE_QUOTE_name, &const_WB_DOUBLE_QUOTE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_DOUBLE_QUOTE_name); + zend_string_release_ex(const_WB_DOUBLE_QUOTE_name, true); zval const_WB_COUNT_value; ZVAL_LONG(&const_WB_COUNT_value, U_WB_COUNT); - zend_string *const_WB_COUNT_name = zend_string_init_interned("WB_COUNT", sizeof("WB_COUNT") - 1, 1); + zend_string *const_WB_COUNT_name = zend_string_init_interned("WB_COUNT", sizeof("WB_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_WB_COUNT_name, &const_WB_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WB_COUNT_name); + zend_string_release_ex(const_WB_COUNT_name, true); zval const_SB_OTHER_value; ZVAL_LONG(&const_SB_OTHER_value, U_SB_OTHER); - zend_string *const_SB_OTHER_name = zend_string_init_interned("SB_OTHER", sizeof("SB_OTHER") - 1, 1); + zend_string *const_SB_OTHER_name = zend_string_init_interned("SB_OTHER", sizeof("SB_OTHER") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_OTHER_name, &const_SB_OTHER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_OTHER_name); + zend_string_release_ex(const_SB_OTHER_name, true); zval const_SB_ATERM_value; ZVAL_LONG(&const_SB_ATERM_value, U_SB_ATERM); - zend_string *const_SB_ATERM_name = zend_string_init_interned("SB_ATERM", sizeof("SB_ATERM") - 1, 1); + zend_string *const_SB_ATERM_name = zend_string_init_interned("SB_ATERM", sizeof("SB_ATERM") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_ATERM_name, &const_SB_ATERM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_ATERM_name); + zend_string_release_ex(const_SB_ATERM_name, true); zval const_SB_CLOSE_value; ZVAL_LONG(&const_SB_CLOSE_value, U_SB_CLOSE); - zend_string *const_SB_CLOSE_name = zend_string_init_interned("SB_CLOSE", sizeof("SB_CLOSE") - 1, 1); + zend_string *const_SB_CLOSE_name = zend_string_init_interned("SB_CLOSE", sizeof("SB_CLOSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_CLOSE_name, &const_SB_CLOSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_CLOSE_name); + zend_string_release_ex(const_SB_CLOSE_name, true); zval const_SB_FORMAT_value; ZVAL_LONG(&const_SB_FORMAT_value, U_SB_FORMAT); - zend_string *const_SB_FORMAT_name = zend_string_init_interned("SB_FORMAT", sizeof("SB_FORMAT") - 1, 1); + zend_string *const_SB_FORMAT_name = zend_string_init_interned("SB_FORMAT", sizeof("SB_FORMAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_FORMAT_name, &const_SB_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_FORMAT_name); + zend_string_release_ex(const_SB_FORMAT_name, true); zval const_SB_LOWER_value; ZVAL_LONG(&const_SB_LOWER_value, U_SB_LOWER); - zend_string *const_SB_LOWER_name = zend_string_init_interned("SB_LOWER", sizeof("SB_LOWER") - 1, 1); + zend_string *const_SB_LOWER_name = zend_string_init_interned("SB_LOWER", sizeof("SB_LOWER") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_LOWER_name, &const_SB_LOWER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_LOWER_name); + zend_string_release_ex(const_SB_LOWER_name, true); zval const_SB_NUMERIC_value; ZVAL_LONG(&const_SB_NUMERIC_value, U_SB_NUMERIC); - zend_string *const_SB_NUMERIC_name = zend_string_init_interned("SB_NUMERIC", sizeof("SB_NUMERIC") - 1, 1); + zend_string *const_SB_NUMERIC_name = zend_string_init_interned("SB_NUMERIC", sizeof("SB_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_NUMERIC_name, &const_SB_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_NUMERIC_name); + zend_string_release_ex(const_SB_NUMERIC_name, true); zval const_SB_OLETTER_value; ZVAL_LONG(&const_SB_OLETTER_value, U_SB_OLETTER); - zend_string *const_SB_OLETTER_name = zend_string_init_interned("SB_OLETTER", sizeof("SB_OLETTER") - 1, 1); + zend_string *const_SB_OLETTER_name = zend_string_init_interned("SB_OLETTER", sizeof("SB_OLETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_OLETTER_name, &const_SB_OLETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_OLETTER_name); + zend_string_release_ex(const_SB_OLETTER_name, true); zval const_SB_SEP_value; ZVAL_LONG(&const_SB_SEP_value, U_SB_SEP); - zend_string *const_SB_SEP_name = zend_string_init_interned("SB_SEP", sizeof("SB_SEP") - 1, 1); + zend_string *const_SB_SEP_name = zend_string_init_interned("SB_SEP", sizeof("SB_SEP") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_SEP_name, &const_SB_SEP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_SEP_name); + zend_string_release_ex(const_SB_SEP_name, true); zval const_SB_SP_value; ZVAL_LONG(&const_SB_SP_value, U_SB_SP); - zend_string *const_SB_SP_name = zend_string_init_interned("SB_SP", sizeof("SB_SP") - 1, 1); + zend_string *const_SB_SP_name = zend_string_init_interned("SB_SP", sizeof("SB_SP") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_SP_name, &const_SB_SP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_SP_name); + zend_string_release_ex(const_SB_SP_name, true); zval const_SB_STERM_value; ZVAL_LONG(&const_SB_STERM_value, U_SB_STERM); - zend_string *const_SB_STERM_name = zend_string_init_interned("SB_STERM", sizeof("SB_STERM") - 1, 1); + zend_string *const_SB_STERM_name = zend_string_init_interned("SB_STERM", sizeof("SB_STERM") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_STERM_name, &const_SB_STERM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_STERM_name); + zend_string_release_ex(const_SB_STERM_name, true); zval const_SB_UPPER_value; ZVAL_LONG(&const_SB_UPPER_value, U_SB_UPPER); - zend_string *const_SB_UPPER_name = zend_string_init_interned("SB_UPPER", sizeof("SB_UPPER") - 1, 1); + zend_string *const_SB_UPPER_name = zend_string_init_interned("SB_UPPER", sizeof("SB_UPPER") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_UPPER_name, &const_SB_UPPER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_UPPER_name); + zend_string_release_ex(const_SB_UPPER_name, true); zval const_SB_CR_value; ZVAL_LONG(&const_SB_CR_value, U_SB_CR); - zend_string *const_SB_CR_name = zend_string_init_interned("SB_CR", sizeof("SB_CR") - 1, 1); + zend_string *const_SB_CR_name = zend_string_init_interned("SB_CR", sizeof("SB_CR") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_CR_name, &const_SB_CR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_CR_name); + zend_string_release_ex(const_SB_CR_name, true); zval const_SB_EXTEND_value; ZVAL_LONG(&const_SB_EXTEND_value, U_SB_EXTEND); - zend_string *const_SB_EXTEND_name = zend_string_init_interned("SB_EXTEND", sizeof("SB_EXTEND") - 1, 1); + zend_string *const_SB_EXTEND_name = zend_string_init_interned("SB_EXTEND", sizeof("SB_EXTEND") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_EXTEND_name, &const_SB_EXTEND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_EXTEND_name); + zend_string_release_ex(const_SB_EXTEND_name, true); zval const_SB_LF_value; ZVAL_LONG(&const_SB_LF_value, U_SB_LF); - zend_string *const_SB_LF_name = zend_string_init_interned("SB_LF", sizeof("SB_LF") - 1, 1); + zend_string *const_SB_LF_name = zend_string_init_interned("SB_LF", sizeof("SB_LF") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_LF_name, &const_SB_LF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_LF_name); + zend_string_release_ex(const_SB_LF_name, true); zval const_SB_SCONTINUE_value; ZVAL_LONG(&const_SB_SCONTINUE_value, U_SB_SCONTINUE); - zend_string *const_SB_SCONTINUE_name = zend_string_init_interned("SB_SCONTINUE", sizeof("SB_SCONTINUE") - 1, 1); + zend_string *const_SB_SCONTINUE_name = zend_string_init_interned("SB_SCONTINUE", sizeof("SB_SCONTINUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_SCONTINUE_name, &const_SB_SCONTINUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_SCONTINUE_name); + zend_string_release_ex(const_SB_SCONTINUE_name, true); zval const_SB_COUNT_value; ZVAL_LONG(&const_SB_COUNT_value, U_SB_COUNT); - zend_string *const_SB_COUNT_name = zend_string_init_interned("SB_COUNT", sizeof("SB_COUNT") - 1, 1); + zend_string *const_SB_COUNT_name = zend_string_init_interned("SB_COUNT", sizeof("SB_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SB_COUNT_name, &const_SB_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SB_COUNT_name); + zend_string_release_ex(const_SB_COUNT_name, true); zval const_LB_UNKNOWN_value; ZVAL_LONG(&const_LB_UNKNOWN_value, U_LB_UNKNOWN); - zend_string *const_LB_UNKNOWN_name = zend_string_init_interned("LB_UNKNOWN", sizeof("LB_UNKNOWN") - 1, 1); + zend_string *const_LB_UNKNOWN_name = zend_string_init_interned("LB_UNKNOWN", sizeof("LB_UNKNOWN") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_UNKNOWN_name, &const_LB_UNKNOWN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_UNKNOWN_name); + zend_string_release_ex(const_LB_UNKNOWN_name, true); zval const_LB_AMBIGUOUS_value; ZVAL_LONG(&const_LB_AMBIGUOUS_value, U_LB_AMBIGUOUS); - zend_string *const_LB_AMBIGUOUS_name = zend_string_init_interned("LB_AMBIGUOUS", sizeof("LB_AMBIGUOUS") - 1, 1); + zend_string *const_LB_AMBIGUOUS_name = zend_string_init_interned("LB_AMBIGUOUS", sizeof("LB_AMBIGUOUS") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_AMBIGUOUS_name, &const_LB_AMBIGUOUS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_AMBIGUOUS_name); + zend_string_release_ex(const_LB_AMBIGUOUS_name, true); zval const_LB_ALPHABETIC_value; ZVAL_LONG(&const_LB_ALPHABETIC_value, U_LB_ALPHABETIC); - zend_string *const_LB_ALPHABETIC_name = zend_string_init_interned("LB_ALPHABETIC", sizeof("LB_ALPHABETIC") - 1, 1); + zend_string *const_LB_ALPHABETIC_name = zend_string_init_interned("LB_ALPHABETIC", sizeof("LB_ALPHABETIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_ALPHABETIC_name, &const_LB_ALPHABETIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_ALPHABETIC_name); + zend_string_release_ex(const_LB_ALPHABETIC_name, true); zval const_LB_BREAK_BOTH_value; ZVAL_LONG(&const_LB_BREAK_BOTH_value, U_LB_BREAK_BOTH); - zend_string *const_LB_BREAK_BOTH_name = zend_string_init_interned("LB_BREAK_BOTH", sizeof("LB_BREAK_BOTH") - 1, 1); + zend_string *const_LB_BREAK_BOTH_name = zend_string_init_interned("LB_BREAK_BOTH", sizeof("LB_BREAK_BOTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_BREAK_BOTH_name, &const_LB_BREAK_BOTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_BREAK_BOTH_name); + zend_string_release_ex(const_LB_BREAK_BOTH_name, true); zval const_LB_BREAK_AFTER_value; ZVAL_LONG(&const_LB_BREAK_AFTER_value, U_LB_BREAK_AFTER); - zend_string *const_LB_BREAK_AFTER_name = zend_string_init_interned("LB_BREAK_AFTER", sizeof("LB_BREAK_AFTER") - 1, 1); + zend_string *const_LB_BREAK_AFTER_name = zend_string_init_interned("LB_BREAK_AFTER", sizeof("LB_BREAK_AFTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_BREAK_AFTER_name, &const_LB_BREAK_AFTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_BREAK_AFTER_name); + zend_string_release_ex(const_LB_BREAK_AFTER_name, true); zval const_LB_BREAK_BEFORE_value; ZVAL_LONG(&const_LB_BREAK_BEFORE_value, U_LB_BREAK_BEFORE); - zend_string *const_LB_BREAK_BEFORE_name = zend_string_init_interned("LB_BREAK_BEFORE", sizeof("LB_BREAK_BEFORE") - 1, 1); + zend_string *const_LB_BREAK_BEFORE_name = zend_string_init_interned("LB_BREAK_BEFORE", sizeof("LB_BREAK_BEFORE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_BREAK_BEFORE_name, &const_LB_BREAK_BEFORE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_BREAK_BEFORE_name); + zend_string_release_ex(const_LB_BREAK_BEFORE_name, true); zval const_LB_MANDATORY_BREAK_value; ZVAL_LONG(&const_LB_MANDATORY_BREAK_value, U_LB_MANDATORY_BREAK); - zend_string *const_LB_MANDATORY_BREAK_name = zend_string_init_interned("LB_MANDATORY_BREAK", sizeof("LB_MANDATORY_BREAK") - 1, 1); + zend_string *const_LB_MANDATORY_BREAK_name = zend_string_init_interned("LB_MANDATORY_BREAK", sizeof("LB_MANDATORY_BREAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_MANDATORY_BREAK_name, &const_LB_MANDATORY_BREAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_MANDATORY_BREAK_name); + zend_string_release_ex(const_LB_MANDATORY_BREAK_name, true); zval const_LB_CONTINGENT_BREAK_value; ZVAL_LONG(&const_LB_CONTINGENT_BREAK_value, U_LB_CONTINGENT_BREAK); - zend_string *const_LB_CONTINGENT_BREAK_name = zend_string_init_interned("LB_CONTINGENT_BREAK", sizeof("LB_CONTINGENT_BREAK") - 1, 1); + zend_string *const_LB_CONTINGENT_BREAK_name = zend_string_init_interned("LB_CONTINGENT_BREAK", sizeof("LB_CONTINGENT_BREAK") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_CONTINGENT_BREAK_name, &const_LB_CONTINGENT_BREAK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_CONTINGENT_BREAK_name); + zend_string_release_ex(const_LB_CONTINGENT_BREAK_name, true); zval const_LB_CLOSE_PUNCTUATION_value; ZVAL_LONG(&const_LB_CLOSE_PUNCTUATION_value, U_LB_CLOSE_PUNCTUATION); - zend_string *const_LB_CLOSE_PUNCTUATION_name = zend_string_init_interned("LB_CLOSE_PUNCTUATION", sizeof("LB_CLOSE_PUNCTUATION") - 1, 1); + zend_string *const_LB_CLOSE_PUNCTUATION_name = zend_string_init_interned("LB_CLOSE_PUNCTUATION", sizeof("LB_CLOSE_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_CLOSE_PUNCTUATION_name, &const_LB_CLOSE_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_CLOSE_PUNCTUATION_name); + zend_string_release_ex(const_LB_CLOSE_PUNCTUATION_name, true); zval const_LB_COMBINING_MARK_value; ZVAL_LONG(&const_LB_COMBINING_MARK_value, U_LB_COMBINING_MARK); - zend_string *const_LB_COMBINING_MARK_name = zend_string_init_interned("LB_COMBINING_MARK", sizeof("LB_COMBINING_MARK") - 1, 1); + zend_string *const_LB_COMBINING_MARK_name = zend_string_init_interned("LB_COMBINING_MARK", sizeof("LB_COMBINING_MARK") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_COMBINING_MARK_name, &const_LB_COMBINING_MARK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_COMBINING_MARK_name); + zend_string_release_ex(const_LB_COMBINING_MARK_name, true); zval const_LB_CARRIAGE_RETURN_value; ZVAL_LONG(&const_LB_CARRIAGE_RETURN_value, U_LB_CARRIAGE_RETURN); - zend_string *const_LB_CARRIAGE_RETURN_name = zend_string_init_interned("LB_CARRIAGE_RETURN", sizeof("LB_CARRIAGE_RETURN") - 1, 1); + zend_string *const_LB_CARRIAGE_RETURN_name = zend_string_init_interned("LB_CARRIAGE_RETURN", sizeof("LB_CARRIAGE_RETURN") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_CARRIAGE_RETURN_name, &const_LB_CARRIAGE_RETURN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_CARRIAGE_RETURN_name); + zend_string_release_ex(const_LB_CARRIAGE_RETURN_name, true); zval const_LB_EXCLAMATION_value; ZVAL_LONG(&const_LB_EXCLAMATION_value, U_LB_EXCLAMATION); - zend_string *const_LB_EXCLAMATION_name = zend_string_init_interned("LB_EXCLAMATION", sizeof("LB_EXCLAMATION") - 1, 1); + zend_string *const_LB_EXCLAMATION_name = zend_string_init_interned("LB_EXCLAMATION", sizeof("LB_EXCLAMATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_EXCLAMATION_name, &const_LB_EXCLAMATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_EXCLAMATION_name); + zend_string_release_ex(const_LB_EXCLAMATION_name, true); zval const_LB_GLUE_value; ZVAL_LONG(&const_LB_GLUE_value, U_LB_GLUE); - zend_string *const_LB_GLUE_name = zend_string_init_interned("LB_GLUE", sizeof("LB_GLUE") - 1, 1); + zend_string *const_LB_GLUE_name = zend_string_init_interned("LB_GLUE", sizeof("LB_GLUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_GLUE_name, &const_LB_GLUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_GLUE_name); + zend_string_release_ex(const_LB_GLUE_name, true); zval const_LB_HYPHEN_value; ZVAL_LONG(&const_LB_HYPHEN_value, U_LB_HYPHEN); - zend_string *const_LB_HYPHEN_name = zend_string_init_interned("LB_HYPHEN", sizeof("LB_HYPHEN") - 1, 1); + zend_string *const_LB_HYPHEN_name = zend_string_init_interned("LB_HYPHEN", sizeof("LB_HYPHEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_HYPHEN_name, &const_LB_HYPHEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_HYPHEN_name); + zend_string_release_ex(const_LB_HYPHEN_name, true); zval const_LB_IDEOGRAPHIC_value; ZVAL_LONG(&const_LB_IDEOGRAPHIC_value, U_LB_IDEOGRAPHIC); - zend_string *const_LB_IDEOGRAPHIC_name = zend_string_init_interned("LB_IDEOGRAPHIC", sizeof("LB_IDEOGRAPHIC") - 1, 1); + zend_string *const_LB_IDEOGRAPHIC_name = zend_string_init_interned("LB_IDEOGRAPHIC", sizeof("LB_IDEOGRAPHIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_IDEOGRAPHIC_name, &const_LB_IDEOGRAPHIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_IDEOGRAPHIC_name); + zend_string_release_ex(const_LB_IDEOGRAPHIC_name, true); zval const_LB_INSEPARABLE_value; ZVAL_LONG(&const_LB_INSEPARABLE_value, U_LB_INSEPARABLE); - zend_string *const_LB_INSEPARABLE_name = zend_string_init_interned("LB_INSEPARABLE", sizeof("LB_INSEPARABLE") - 1, 1); + zend_string *const_LB_INSEPARABLE_name = zend_string_init_interned("LB_INSEPARABLE", sizeof("LB_INSEPARABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_INSEPARABLE_name, &const_LB_INSEPARABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_INSEPARABLE_name); + zend_string_release_ex(const_LB_INSEPARABLE_name, true); zval const_LB_INSEPERABLE_value; ZVAL_LONG(&const_LB_INSEPERABLE_value, U_LB_INSEPERABLE); - zend_string *const_LB_INSEPERABLE_name = zend_string_init_interned("LB_INSEPERABLE", sizeof("LB_INSEPERABLE") - 1, 1); + zend_string *const_LB_INSEPERABLE_name = zend_string_init_interned("LB_INSEPERABLE", sizeof("LB_INSEPERABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_INSEPERABLE_name, &const_LB_INSEPERABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_INSEPERABLE_name); + zend_string_release_ex(const_LB_INSEPERABLE_name, true); zval const_LB_INFIX_NUMERIC_value; ZVAL_LONG(&const_LB_INFIX_NUMERIC_value, U_LB_INFIX_NUMERIC); - zend_string *const_LB_INFIX_NUMERIC_name = zend_string_init_interned("LB_INFIX_NUMERIC", sizeof("LB_INFIX_NUMERIC") - 1, 1); + zend_string *const_LB_INFIX_NUMERIC_name = zend_string_init_interned("LB_INFIX_NUMERIC", sizeof("LB_INFIX_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_INFIX_NUMERIC_name, &const_LB_INFIX_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_INFIX_NUMERIC_name); + zend_string_release_ex(const_LB_INFIX_NUMERIC_name, true); zval const_LB_LINE_FEED_value; ZVAL_LONG(&const_LB_LINE_FEED_value, U_LB_LINE_FEED); - zend_string *const_LB_LINE_FEED_name = zend_string_init_interned("LB_LINE_FEED", sizeof("LB_LINE_FEED") - 1, 1); + zend_string *const_LB_LINE_FEED_name = zend_string_init_interned("LB_LINE_FEED", sizeof("LB_LINE_FEED") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_LINE_FEED_name, &const_LB_LINE_FEED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_LINE_FEED_name); + zend_string_release_ex(const_LB_LINE_FEED_name, true); zval const_LB_NONSTARTER_value; ZVAL_LONG(&const_LB_NONSTARTER_value, U_LB_NONSTARTER); - zend_string *const_LB_NONSTARTER_name = zend_string_init_interned("LB_NONSTARTER", sizeof("LB_NONSTARTER") - 1, 1); + zend_string *const_LB_NONSTARTER_name = zend_string_init_interned("LB_NONSTARTER", sizeof("LB_NONSTARTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_NONSTARTER_name, &const_LB_NONSTARTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_NONSTARTER_name); + zend_string_release_ex(const_LB_NONSTARTER_name, true); zval const_LB_NUMERIC_value; ZVAL_LONG(&const_LB_NUMERIC_value, U_LB_NUMERIC); - zend_string *const_LB_NUMERIC_name = zend_string_init_interned("LB_NUMERIC", sizeof("LB_NUMERIC") - 1, 1); + zend_string *const_LB_NUMERIC_name = zend_string_init_interned("LB_NUMERIC", sizeof("LB_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_NUMERIC_name, &const_LB_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_NUMERIC_name); + zend_string_release_ex(const_LB_NUMERIC_name, true); zval const_LB_OPEN_PUNCTUATION_value; ZVAL_LONG(&const_LB_OPEN_PUNCTUATION_value, U_LB_OPEN_PUNCTUATION); - zend_string *const_LB_OPEN_PUNCTUATION_name = zend_string_init_interned("LB_OPEN_PUNCTUATION", sizeof("LB_OPEN_PUNCTUATION") - 1, 1); + zend_string *const_LB_OPEN_PUNCTUATION_name = zend_string_init_interned("LB_OPEN_PUNCTUATION", sizeof("LB_OPEN_PUNCTUATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_OPEN_PUNCTUATION_name, &const_LB_OPEN_PUNCTUATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_OPEN_PUNCTUATION_name); + zend_string_release_ex(const_LB_OPEN_PUNCTUATION_name, true); zval const_LB_POSTFIX_NUMERIC_value; ZVAL_LONG(&const_LB_POSTFIX_NUMERIC_value, U_LB_POSTFIX_NUMERIC); - zend_string *const_LB_POSTFIX_NUMERIC_name = zend_string_init_interned("LB_POSTFIX_NUMERIC", sizeof("LB_POSTFIX_NUMERIC") - 1, 1); + zend_string *const_LB_POSTFIX_NUMERIC_name = zend_string_init_interned("LB_POSTFIX_NUMERIC", sizeof("LB_POSTFIX_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_POSTFIX_NUMERIC_name, &const_LB_POSTFIX_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_POSTFIX_NUMERIC_name); + zend_string_release_ex(const_LB_POSTFIX_NUMERIC_name, true); zval const_LB_PREFIX_NUMERIC_value; ZVAL_LONG(&const_LB_PREFIX_NUMERIC_value, U_LB_PREFIX_NUMERIC); - zend_string *const_LB_PREFIX_NUMERIC_name = zend_string_init_interned("LB_PREFIX_NUMERIC", sizeof("LB_PREFIX_NUMERIC") - 1, 1); + zend_string *const_LB_PREFIX_NUMERIC_name = zend_string_init_interned("LB_PREFIX_NUMERIC", sizeof("LB_PREFIX_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_PREFIX_NUMERIC_name, &const_LB_PREFIX_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_PREFIX_NUMERIC_name); + zend_string_release_ex(const_LB_PREFIX_NUMERIC_name, true); zval const_LB_QUOTATION_value; ZVAL_LONG(&const_LB_QUOTATION_value, U_LB_QUOTATION); - zend_string *const_LB_QUOTATION_name = zend_string_init_interned("LB_QUOTATION", sizeof("LB_QUOTATION") - 1, 1); + zend_string *const_LB_QUOTATION_name = zend_string_init_interned("LB_QUOTATION", sizeof("LB_QUOTATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_QUOTATION_name, &const_LB_QUOTATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_QUOTATION_name); + zend_string_release_ex(const_LB_QUOTATION_name, true); zval const_LB_COMPLEX_CONTEXT_value; ZVAL_LONG(&const_LB_COMPLEX_CONTEXT_value, U_LB_COMPLEX_CONTEXT); - zend_string *const_LB_COMPLEX_CONTEXT_name = zend_string_init_interned("LB_COMPLEX_CONTEXT", sizeof("LB_COMPLEX_CONTEXT") - 1, 1); + zend_string *const_LB_COMPLEX_CONTEXT_name = zend_string_init_interned("LB_COMPLEX_CONTEXT", sizeof("LB_COMPLEX_CONTEXT") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_COMPLEX_CONTEXT_name, &const_LB_COMPLEX_CONTEXT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_COMPLEX_CONTEXT_name); + zend_string_release_ex(const_LB_COMPLEX_CONTEXT_name, true); zval const_LB_SURROGATE_value; ZVAL_LONG(&const_LB_SURROGATE_value, U_LB_SURROGATE); - zend_string *const_LB_SURROGATE_name = zend_string_init_interned("LB_SURROGATE", sizeof("LB_SURROGATE") - 1, 1); + zend_string *const_LB_SURROGATE_name = zend_string_init_interned("LB_SURROGATE", sizeof("LB_SURROGATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_SURROGATE_name, &const_LB_SURROGATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_SURROGATE_name); + zend_string_release_ex(const_LB_SURROGATE_name, true); zval const_LB_SPACE_value; ZVAL_LONG(&const_LB_SPACE_value, U_LB_SPACE); - zend_string *const_LB_SPACE_name = zend_string_init_interned("LB_SPACE", sizeof("LB_SPACE") - 1, 1); + zend_string *const_LB_SPACE_name = zend_string_init_interned("LB_SPACE", sizeof("LB_SPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_SPACE_name, &const_LB_SPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_SPACE_name); + zend_string_release_ex(const_LB_SPACE_name, true); zval const_LB_BREAK_SYMBOLS_value; ZVAL_LONG(&const_LB_BREAK_SYMBOLS_value, U_LB_BREAK_SYMBOLS); - zend_string *const_LB_BREAK_SYMBOLS_name = zend_string_init_interned("LB_BREAK_SYMBOLS", sizeof("LB_BREAK_SYMBOLS") - 1, 1); + zend_string *const_LB_BREAK_SYMBOLS_name = zend_string_init_interned("LB_BREAK_SYMBOLS", sizeof("LB_BREAK_SYMBOLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_BREAK_SYMBOLS_name, &const_LB_BREAK_SYMBOLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_BREAK_SYMBOLS_name); + zend_string_release_ex(const_LB_BREAK_SYMBOLS_name, true); zval const_LB_ZWSPACE_value; ZVAL_LONG(&const_LB_ZWSPACE_value, U_LB_ZWSPACE); - zend_string *const_LB_ZWSPACE_name = zend_string_init_interned("LB_ZWSPACE", sizeof("LB_ZWSPACE") - 1, 1); + zend_string *const_LB_ZWSPACE_name = zend_string_init_interned("LB_ZWSPACE", sizeof("LB_ZWSPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_ZWSPACE_name, &const_LB_ZWSPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_ZWSPACE_name); + zend_string_release_ex(const_LB_ZWSPACE_name, true); zval const_LB_NEXT_LINE_value; ZVAL_LONG(&const_LB_NEXT_LINE_value, U_LB_NEXT_LINE); - zend_string *const_LB_NEXT_LINE_name = zend_string_init_interned("LB_NEXT_LINE", sizeof("LB_NEXT_LINE") - 1, 1); + zend_string *const_LB_NEXT_LINE_name = zend_string_init_interned("LB_NEXT_LINE", sizeof("LB_NEXT_LINE") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_NEXT_LINE_name, &const_LB_NEXT_LINE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_NEXT_LINE_name); + zend_string_release_ex(const_LB_NEXT_LINE_name, true); zval const_LB_WORD_JOINER_value; ZVAL_LONG(&const_LB_WORD_JOINER_value, U_LB_WORD_JOINER); - zend_string *const_LB_WORD_JOINER_name = zend_string_init_interned("LB_WORD_JOINER", sizeof("LB_WORD_JOINER") - 1, 1); + zend_string *const_LB_WORD_JOINER_name = zend_string_init_interned("LB_WORD_JOINER", sizeof("LB_WORD_JOINER") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_WORD_JOINER_name, &const_LB_WORD_JOINER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_WORD_JOINER_name); + zend_string_release_ex(const_LB_WORD_JOINER_name, true); zval const_LB_H2_value; ZVAL_LONG(&const_LB_H2_value, U_LB_H2); - zend_string *const_LB_H2_name = zend_string_init_interned("LB_H2", sizeof("LB_H2") - 1, 1); + zend_string *const_LB_H2_name = zend_string_init_interned("LB_H2", sizeof("LB_H2") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_H2_name, &const_LB_H2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_H2_name); + zend_string_release_ex(const_LB_H2_name, true); zval const_LB_H3_value; ZVAL_LONG(&const_LB_H3_value, U_LB_H3); - zend_string *const_LB_H3_name = zend_string_init_interned("LB_H3", sizeof("LB_H3") - 1, 1); + zend_string *const_LB_H3_name = zend_string_init_interned("LB_H3", sizeof("LB_H3") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_H3_name, &const_LB_H3_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_H3_name); + zend_string_release_ex(const_LB_H3_name, true); zval const_LB_JL_value; ZVAL_LONG(&const_LB_JL_value, U_LB_JL); - zend_string *const_LB_JL_name = zend_string_init_interned("LB_JL", sizeof("LB_JL") - 1, 1); + zend_string *const_LB_JL_name = zend_string_init_interned("LB_JL", sizeof("LB_JL") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_JL_name, &const_LB_JL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_JL_name); + zend_string_release_ex(const_LB_JL_name, true); zval const_LB_JT_value; ZVAL_LONG(&const_LB_JT_value, U_LB_JT); - zend_string *const_LB_JT_name = zend_string_init_interned("LB_JT", sizeof("LB_JT") - 1, 1); + zend_string *const_LB_JT_name = zend_string_init_interned("LB_JT", sizeof("LB_JT") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_JT_name, &const_LB_JT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_JT_name); + zend_string_release_ex(const_LB_JT_name, true); zval const_LB_JV_value; ZVAL_LONG(&const_LB_JV_value, U_LB_JV); - zend_string *const_LB_JV_name = zend_string_init_interned("LB_JV", sizeof("LB_JV") - 1, 1); + zend_string *const_LB_JV_name = zend_string_init_interned("LB_JV", sizeof("LB_JV") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_JV_name, &const_LB_JV_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_JV_name); + zend_string_release_ex(const_LB_JV_name, true); zval const_LB_CLOSE_PARENTHESIS_value; ZVAL_LONG(&const_LB_CLOSE_PARENTHESIS_value, U_LB_CLOSE_PARENTHESIS); - zend_string *const_LB_CLOSE_PARENTHESIS_name = zend_string_init_interned("LB_CLOSE_PARENTHESIS", sizeof("LB_CLOSE_PARENTHESIS") - 1, 1); + zend_string *const_LB_CLOSE_PARENTHESIS_name = zend_string_init_interned("LB_CLOSE_PARENTHESIS", sizeof("LB_CLOSE_PARENTHESIS") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_CLOSE_PARENTHESIS_name, &const_LB_CLOSE_PARENTHESIS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_CLOSE_PARENTHESIS_name); + zend_string_release_ex(const_LB_CLOSE_PARENTHESIS_name, true); zval const_LB_CONDITIONAL_JAPANESE_STARTER_value; ZVAL_LONG(&const_LB_CONDITIONAL_JAPANESE_STARTER_value, U_LB_CONDITIONAL_JAPANESE_STARTER); - zend_string *const_LB_CONDITIONAL_JAPANESE_STARTER_name = zend_string_init_interned("LB_CONDITIONAL_JAPANESE_STARTER", sizeof("LB_CONDITIONAL_JAPANESE_STARTER") - 1, 1); + zend_string *const_LB_CONDITIONAL_JAPANESE_STARTER_name = zend_string_init_interned("LB_CONDITIONAL_JAPANESE_STARTER", sizeof("LB_CONDITIONAL_JAPANESE_STARTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_CONDITIONAL_JAPANESE_STARTER_name, &const_LB_CONDITIONAL_JAPANESE_STARTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_CONDITIONAL_JAPANESE_STARTER_name); + zend_string_release_ex(const_LB_CONDITIONAL_JAPANESE_STARTER_name, true); zval const_LB_HEBREW_LETTER_value; ZVAL_LONG(&const_LB_HEBREW_LETTER_value, U_LB_HEBREW_LETTER); - zend_string *const_LB_HEBREW_LETTER_name = zend_string_init_interned("LB_HEBREW_LETTER", sizeof("LB_HEBREW_LETTER") - 1, 1); + zend_string *const_LB_HEBREW_LETTER_name = zend_string_init_interned("LB_HEBREW_LETTER", sizeof("LB_HEBREW_LETTER") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_HEBREW_LETTER_name, &const_LB_HEBREW_LETTER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_HEBREW_LETTER_name); + zend_string_release_ex(const_LB_HEBREW_LETTER_name, true); zval const_LB_REGIONAL_INDICATOR_value; ZVAL_LONG(&const_LB_REGIONAL_INDICATOR_value, U_LB_REGIONAL_INDICATOR); - zend_string *const_LB_REGIONAL_INDICATOR_name = zend_string_init_interned("LB_REGIONAL_INDICATOR", sizeof("LB_REGIONAL_INDICATOR") - 1, 1); + zend_string *const_LB_REGIONAL_INDICATOR_name = zend_string_init_interned("LB_REGIONAL_INDICATOR", sizeof("LB_REGIONAL_INDICATOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_REGIONAL_INDICATOR_name, &const_LB_REGIONAL_INDICATOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_REGIONAL_INDICATOR_name); + zend_string_release_ex(const_LB_REGIONAL_INDICATOR_name, true); zval const_LB_COUNT_value; ZVAL_LONG(&const_LB_COUNT_value, U_LB_COUNT); - zend_string *const_LB_COUNT_name = zend_string_init_interned("LB_COUNT", sizeof("LB_COUNT") - 1, 1); + zend_string *const_LB_COUNT_name = zend_string_init_interned("LB_COUNT", sizeof("LB_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_LB_COUNT_name, &const_LB_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LB_COUNT_name); + zend_string_release_ex(const_LB_COUNT_name, true); zval const_NT_NONE_value; ZVAL_LONG(&const_NT_NONE_value, U_NT_NONE); - zend_string *const_NT_NONE_name = zend_string_init_interned("NT_NONE", sizeof("NT_NONE") - 1, 1); + zend_string *const_NT_NONE_name = zend_string_init_interned("NT_NONE", sizeof("NT_NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_NT_NONE_name, &const_NT_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NT_NONE_name); + zend_string_release_ex(const_NT_NONE_name, true); zval const_NT_DECIMAL_value; ZVAL_LONG(&const_NT_DECIMAL_value, U_NT_DECIMAL); - zend_string *const_NT_DECIMAL_name = zend_string_init_interned("NT_DECIMAL", sizeof("NT_DECIMAL") - 1, 1); + zend_string *const_NT_DECIMAL_name = zend_string_init_interned("NT_DECIMAL", sizeof("NT_DECIMAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_NT_DECIMAL_name, &const_NT_DECIMAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NT_DECIMAL_name); + zend_string_release_ex(const_NT_DECIMAL_name, true); zval const_NT_DIGIT_value; ZVAL_LONG(&const_NT_DIGIT_value, U_NT_DIGIT); - zend_string *const_NT_DIGIT_name = zend_string_init_interned("NT_DIGIT", sizeof("NT_DIGIT") - 1, 1); + zend_string *const_NT_DIGIT_name = zend_string_init_interned("NT_DIGIT", sizeof("NT_DIGIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_NT_DIGIT_name, &const_NT_DIGIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NT_DIGIT_name); + zend_string_release_ex(const_NT_DIGIT_name, true); zval const_NT_NUMERIC_value; ZVAL_LONG(&const_NT_NUMERIC_value, U_NT_NUMERIC); - zend_string *const_NT_NUMERIC_name = zend_string_init_interned("NT_NUMERIC", sizeof("NT_NUMERIC") - 1, 1); + zend_string *const_NT_NUMERIC_name = zend_string_init_interned("NT_NUMERIC", sizeof("NT_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_NT_NUMERIC_name, &const_NT_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NT_NUMERIC_name); + zend_string_release_ex(const_NT_NUMERIC_name, true); zval const_NT_COUNT_value; ZVAL_LONG(&const_NT_COUNT_value, U_NT_COUNT); - zend_string *const_NT_COUNT_name = zend_string_init_interned("NT_COUNT", sizeof("NT_COUNT") - 1, 1); + zend_string *const_NT_COUNT_name = zend_string_init_interned("NT_COUNT", sizeof("NT_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_NT_COUNT_name, &const_NT_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NT_COUNT_name); + zend_string_release_ex(const_NT_COUNT_name, true); zval const_HST_NOT_APPLICABLE_value; ZVAL_LONG(&const_HST_NOT_APPLICABLE_value, U_HST_NOT_APPLICABLE); - zend_string *const_HST_NOT_APPLICABLE_name = zend_string_init_interned("HST_NOT_APPLICABLE", sizeof("HST_NOT_APPLICABLE") - 1, 1); + zend_string *const_HST_NOT_APPLICABLE_name = zend_string_init_interned("HST_NOT_APPLICABLE", sizeof("HST_NOT_APPLICABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_HST_NOT_APPLICABLE_name, &const_HST_NOT_APPLICABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HST_NOT_APPLICABLE_name); + zend_string_release_ex(const_HST_NOT_APPLICABLE_name, true); zval const_HST_LEADING_JAMO_value; ZVAL_LONG(&const_HST_LEADING_JAMO_value, U_HST_LEADING_JAMO); - zend_string *const_HST_LEADING_JAMO_name = zend_string_init_interned("HST_LEADING_JAMO", sizeof("HST_LEADING_JAMO") - 1, 1); + zend_string *const_HST_LEADING_JAMO_name = zend_string_init_interned("HST_LEADING_JAMO", sizeof("HST_LEADING_JAMO") - 1, true); zend_declare_typed_class_constant(class_entry, const_HST_LEADING_JAMO_name, &const_HST_LEADING_JAMO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HST_LEADING_JAMO_name); + zend_string_release_ex(const_HST_LEADING_JAMO_name, true); zval const_HST_VOWEL_JAMO_value; ZVAL_LONG(&const_HST_VOWEL_JAMO_value, U_HST_VOWEL_JAMO); - zend_string *const_HST_VOWEL_JAMO_name = zend_string_init_interned("HST_VOWEL_JAMO", sizeof("HST_VOWEL_JAMO") - 1, 1); + zend_string *const_HST_VOWEL_JAMO_name = zend_string_init_interned("HST_VOWEL_JAMO", sizeof("HST_VOWEL_JAMO") - 1, true); zend_declare_typed_class_constant(class_entry, const_HST_VOWEL_JAMO_name, &const_HST_VOWEL_JAMO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HST_VOWEL_JAMO_name); + zend_string_release_ex(const_HST_VOWEL_JAMO_name, true); zval const_HST_TRAILING_JAMO_value; ZVAL_LONG(&const_HST_TRAILING_JAMO_value, U_HST_TRAILING_JAMO); - zend_string *const_HST_TRAILING_JAMO_name = zend_string_init_interned("HST_TRAILING_JAMO", sizeof("HST_TRAILING_JAMO") - 1, 1); + zend_string *const_HST_TRAILING_JAMO_name = zend_string_init_interned("HST_TRAILING_JAMO", sizeof("HST_TRAILING_JAMO") - 1, true); zend_declare_typed_class_constant(class_entry, const_HST_TRAILING_JAMO_name, &const_HST_TRAILING_JAMO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HST_TRAILING_JAMO_name); + zend_string_release_ex(const_HST_TRAILING_JAMO_name, true); zval const_HST_LV_SYLLABLE_value; ZVAL_LONG(&const_HST_LV_SYLLABLE_value, U_HST_LV_SYLLABLE); - zend_string *const_HST_LV_SYLLABLE_name = zend_string_init_interned("HST_LV_SYLLABLE", sizeof("HST_LV_SYLLABLE") - 1, 1); + zend_string *const_HST_LV_SYLLABLE_name = zend_string_init_interned("HST_LV_SYLLABLE", sizeof("HST_LV_SYLLABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_HST_LV_SYLLABLE_name, &const_HST_LV_SYLLABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HST_LV_SYLLABLE_name); + zend_string_release_ex(const_HST_LV_SYLLABLE_name, true); zval const_HST_LVT_SYLLABLE_value; ZVAL_LONG(&const_HST_LVT_SYLLABLE_value, U_HST_LVT_SYLLABLE); - zend_string *const_HST_LVT_SYLLABLE_name = zend_string_init_interned("HST_LVT_SYLLABLE", sizeof("HST_LVT_SYLLABLE") - 1, 1); + zend_string *const_HST_LVT_SYLLABLE_name = zend_string_init_interned("HST_LVT_SYLLABLE", sizeof("HST_LVT_SYLLABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_HST_LVT_SYLLABLE_name, &const_HST_LVT_SYLLABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HST_LVT_SYLLABLE_name); + zend_string_release_ex(const_HST_LVT_SYLLABLE_name, true); zval const_HST_COUNT_value; ZVAL_LONG(&const_HST_COUNT_value, U_HST_COUNT); - zend_string *const_HST_COUNT_name = zend_string_init_interned("HST_COUNT", sizeof("HST_COUNT") - 1, 1); + zend_string *const_HST_COUNT_name = zend_string_init_interned("HST_COUNT", sizeof("HST_COUNT") - 1, true); zend_declare_typed_class_constant(class_entry, const_HST_COUNT_name, &const_HST_COUNT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_HST_COUNT_name); + zend_string_release_ex(const_HST_COUNT_name, true); zval const_FOLD_CASE_DEFAULT_value; ZVAL_LONG(&const_FOLD_CASE_DEFAULT_value, U_FOLD_CASE_DEFAULT); - zend_string *const_FOLD_CASE_DEFAULT_name = zend_string_init_interned("FOLD_CASE_DEFAULT", sizeof("FOLD_CASE_DEFAULT") - 1, 1); + zend_string *const_FOLD_CASE_DEFAULT_name = zend_string_init_interned("FOLD_CASE_DEFAULT", sizeof("FOLD_CASE_DEFAULT") - 1, true); zend_declare_typed_class_constant(class_entry, const_FOLD_CASE_DEFAULT_name, &const_FOLD_CASE_DEFAULT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FOLD_CASE_DEFAULT_name); + zend_string_release_ex(const_FOLD_CASE_DEFAULT_name, true); zval const_FOLD_CASE_EXCLUDE_SPECIAL_I_value; ZVAL_LONG(&const_FOLD_CASE_EXCLUDE_SPECIAL_I_value, U_FOLD_CASE_EXCLUDE_SPECIAL_I); - zend_string *const_FOLD_CASE_EXCLUDE_SPECIAL_I_name = zend_string_init_interned("FOLD_CASE_EXCLUDE_SPECIAL_I", sizeof("FOLD_CASE_EXCLUDE_SPECIAL_I") - 1, 1); + zend_string *const_FOLD_CASE_EXCLUDE_SPECIAL_I_name = zend_string_init_interned("FOLD_CASE_EXCLUDE_SPECIAL_I", sizeof("FOLD_CASE_EXCLUDE_SPECIAL_I") - 1, true); zend_declare_typed_class_constant(class_entry, const_FOLD_CASE_EXCLUDE_SPECIAL_I_name, &const_FOLD_CASE_EXCLUDE_SPECIAL_I_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FOLD_CASE_EXCLUDE_SPECIAL_I_name); + zend_string_release_ex(const_FOLD_CASE_EXCLUDE_SPECIAL_I_name, true); return class_entry; } diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index a73277915405d..186485c05c6f4 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -109,7 +109,6 @@ static inline void php_json_encode_double(smart_str *buf, double d, int options) static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, php_json_encoder *encoder) /* {{{ */ { bool encode_as_object = options & PHP_JSON_FORCE_OBJECT; - bool need_comma = false; HashTable *myht, *prop_ht; zend_refcounted *recursion_rc; @@ -161,12 +160,6 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, continue; } - if (need_comma) { - smart_str_appendc(buf, ','); - } else { - need_comma = 1; - } - php_json_pretty_print_char(buf, options, '\n'); php_json_pretty_print_indent(buf, options, encoder); @@ -186,6 +179,14 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, PHP_JSON_HASH_UNPROTECT_RECURSION(obj); return FAILURE; } + + smart_str_appendc(buf, ','); + } + + bool empty = ZSTR_VAL(buf->s)[ZSTR_LEN(buf->s) - 1] != ','; + if (!empty) { + /* Drop the trailing comma. */ + ZSTR_LEN(buf->s)--; } PHP_JSON_HASH_UNPROTECT_RECURSION(obj); @@ -197,7 +198,7 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, } --encoder->depth; - if (need_comma) { + if (!empty) { php_json_pretty_print_char(buf, options, '\n'); php_json_pretty_print_indent(buf, options, encoder); } @@ -235,24 +236,20 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, uint32_t i = myht ? zend_hash_num_elements(myht) : 0; + bool empty = true; if (i > 0) { zend_string *key; zval *data; zend_ulong index; ZEND_HASH_FOREACH_KEY_VAL_IND(myht, index, key, data) { + bool need_dtor = false; zval tmp; ZVAL_UNDEF(&tmp); if (!encode_as_object) { ZEND_ASSERT(Z_TYPE_P(data) != IS_PTR); - if (need_comma) { - smart_str_appendc(buf, ','); - } else { - need_comma = 1; - } - php_json_pretty_print_char(buf, options, '\n'); php_json_pretty_print_indent(buf, options, encoder); } else { @@ -268,6 +265,7 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, if ((prop_info->flags & ZEND_ACC_VIRTUAL) && !prop_info->hooks[ZEND_PROPERTY_HOOK_GET]) { continue; } + need_dtor = true; data = zend_read_property_ex(prop_info->ce, Z_OBJ_P(val), prop_info->name, /* silent */ true, &tmp); if (EG(exception)) { PHP_JSON_HASH_UNPROTECT_RECURSION(recursion_rc); @@ -276,11 +274,6 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, } } - if (need_comma) { - smart_str_appendc(buf, ','); - } else { - need_comma = 1; - } php_json_pretty_print_char(buf, options, '\n'); php_json_pretty_print_indent(buf, options, encoder); @@ -293,12 +286,6 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, smart_str_appendl(buf, "\"\"", 2); } } else { - if (need_comma) { - smart_str_appendc(buf, ','); - } else { - need_comma = 1; - } - php_json_pretty_print_char(buf, options, '\n'); php_json_pretty_print_indent(buf, options, encoder); @@ -318,8 +305,18 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, zval_ptr_dtor(&tmp); return FAILURE; } - zval_ptr_dtor(&tmp); + if (UNEXPECTED(need_dtor)) { + zval_ptr_dtor(&tmp); + } + + smart_str_appendc(buf, ','); } ZEND_HASH_FOREACH_END(); + + empty = ZSTR_VAL(buf->s)[ZSTR_LEN(buf->s) - 1] != ','; + if (!empty) { + /* Drop the trailing comma. */ + ZSTR_LEN(buf->s)--; + } } PHP_JSON_HASH_UNPROTECT_RECURSION(recursion_rc); @@ -334,7 +331,7 @@ static zend_result php_json_encode_array(smart_str *buf, zval *val, int options, --encoder->depth; /* Only keep closing bracket on same line for empty arrays/objects */ - if (need_comma) { + if (!empty) { php_json_pretty_print_char(buf, options, '\n'); php_json_pretty_print_indent(buf, options, encoder); } diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 9878374bbe26a..9e566a4ed1dcb 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -425,7 +425,7 @@ static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashTable *control_ht) { zval* val; - zend_string *control_oid; + zend_string *control_oid, *control_oid_tmp; char** ldap_attrs = NULL; LDAPSortKey** sort_keys = NULL; zend_string *tmpstring = NULL, **tmpstrings1 = NULL, **tmpstrings2 = NULL; @@ -436,8 +436,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT return -1; } - control_oid = zval_get_string(val); - if (EG(exception)) { + control_oid = zval_try_get_tmp_string(val, &control_oid_tmp); + if (!control_oid) { return -1; } @@ -453,8 +453,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT if ((val = zend_hash_find(control_ht, ZSTR_KNOWN(ZEND_STR_VALUE))) != NULL) { if (Z_TYPE_P(val) != IS_ARRAY) { - tmpstring = zval_get_string(val); - if (EG(exception)) { + tmpstring = zval_try_get_string(val); + if (!tmpstring) { rc = -1; goto failure; } @@ -468,8 +468,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT pagesize = zval_get_long(tmp); } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(val), "cookie", sizeof("cookie") - 1)) != NULL) { - tmpstring = zval_get_string(tmp); - if (EG(exception)) { + tmpstring = zval_try_get_string(tmp); + if (!tmpstring) { rc = -1; goto failure; } @@ -477,7 +477,7 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT cookie.bv_len = ZSTR_LEN(tmpstring); } /* ldap_create_page_control_value() allocates memory for control_value.bv_val */ - control_value_alloc = 1; + control_value_alloc = true; rc = ldap_create_page_control_value(ld, pagesize, &cookie, &control_value); if (rc != LDAP_SUCCESS) { php_error_docref(NULL, E_WARNING, "Failed to create paged result control value: %s (%d)", ldap_err2string(rc), rc); @@ -488,8 +488,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT rc = -1; zend_value_error("%s(): Control must have a \"filter\" key", get_active_function_name()); } else { - zend_string* assert = zval_get_string(tmp); - if (EG(exception)) { + zend_string* assert = zval_try_get_string(tmp); + if (!assert) { rc = -1; goto failure; } @@ -498,7 +498,7 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT int success = LDAP_SUCCESS; ldap_set_option(ld, LDAP_OPT_RESULT_CODE, &success); /* ldap_create_assertion_control_value() allocates memory for control_value.bv_val */ - control_value_alloc = 1; + control_value_alloc = true; rc = ldap_create_assertion_control_value(ld, ZSTR_VAL(assert), &control_value); if (rc != LDAP_SUCCESS) { php_error_docref(NULL, E_WARNING, "Failed to create assert control value: %s (%d)", ldap_err2string(rc), rc); @@ -516,8 +516,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT rc = -1; php_error_docref(NULL, E_WARNING, "Failed to allocate control value"); } else { - tmpstring = zval_get_string(tmp); - if (EG(exception)) { + tmpstring = zval_try_get_string(tmp); + if (!tmpstring) { rc = -1; goto failure; } @@ -555,8 +555,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT goto failure; } - tmpstrings1[num_tmpstrings1] = zval_get_string(attr); - if (EG(exception)) { + tmpstrings1[num_tmpstrings1] = zval_try_get_string(attr); + if (!tmpstrings1[num_tmpstrings1]) { rc = -1; goto failure; } @@ -603,8 +603,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT goto failure; } sort_keys[i] = emalloc(sizeof(LDAPSortKey)); - tmpstrings1[num_tmpstrings1] = zval_get_string(tmp); - if (EG(exception)) { + tmpstrings1[num_tmpstrings1] = zval_try_get_string(tmp); + if (!tmpstrings1[num_tmpstrings1]) { rc = -1; goto failure; } @@ -612,8 +612,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT ++num_tmpstrings1; if ((tmp = zend_hash_str_find(Z_ARRVAL_P(sortkey), "oid", sizeof("oid") - 1)) != NULL) { - tmpstrings2[num_tmpstrings2] = zval_get_string(tmp); - if (EG(exception)) { + tmpstrings2[num_tmpstrings2] = zval_try_get_string(tmp); + if (!tmpstrings2[num_tmpstrings2]) { rc = -1; goto failure; } @@ -631,7 +631,7 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT } sort_keys[num_keys] = NULL; /* ldap_create_sort_control_value() allocates memory for control_value.bv_val */ - control_value_alloc = 1; + control_value_alloc = true; rc = ldap_create_sort_control_value(ld, sort_keys, &control_value); if (rc != LDAP_SUCCESS) { php_error_docref(NULL, E_WARNING, "Failed to create sort control value: %s (%d)", ldap_err2string(rc), rc); @@ -659,8 +659,8 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT } if ((tmp = zend_hash_str_find(Z_ARRVAL_P(val), "attrvalue", sizeof("attrvalue") - 1)) != NULL) { - tmpstring = zval_get_string(tmp); - if (EG(exception)) { + tmpstring = zval_try_get_string(tmp); + if (!tmpstring) { rc = -1; goto failure; } @@ -684,25 +684,29 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT goto failure; } + zend_string *context_str = NULL; if ((tmp = zend_hash_str_find(Z_ARRVAL_P(val), "context", sizeof("context") - 1)) != NULL) { - tmpstring = zval_get_string(tmp); - if (EG(exception)) { + context_str = zval_try_get_string(tmp); + if (!context_str) { rc = -1; goto failure; } - context.bv_val = ZSTR_VAL(tmpstring); - context.bv_len = ZSTR_LEN(tmpstring); + context.bv_val = ZSTR_VAL(context_str); + context.bv_len = ZSTR_LEN(context_str); vlvInfo.ldvlv_context = &context; } else { vlvInfo.ldvlv_context = NULL; } /* ldap_create_vlv_control_value() allocates memory for control_value.bv_val */ - control_value_alloc = 1; + control_value_alloc = true; rc = ldap_create_vlv_control_value(ld, &vlvInfo, &control_value); if (rc != LDAP_SUCCESS) { php_error_docref(NULL, E_WARNING, "Failed to create VLV control value: %s (%d)", ldap_err2string(rc), rc); } + if (context_str) { + zend_string_release_ex(context_str, false); + } } else { zend_type_error("%s(): Control OID %s cannot be of type array", get_active_function_name(), ZSTR_VAL(control_oid)); rc = -1; @@ -714,7 +718,7 @@ static int php_ldap_control_from_array(LDAP *ld, LDAPControl** ctrl, const HashT } failure: - zend_string_release(control_oid); + zend_tmp_string_release(control_oid_tmp); if (tmpstring != NULL) { zend_string_release(tmpstring); } @@ -980,7 +984,8 @@ PHP_FUNCTION(ldap_connect) #ifdef HAVE_ORALDAP if (ZEND_NUM_ARGS() == 3 || ZEND_NUM_ARGS() == 4) { - WRONG_PARAM_COUNT; + zend_wrong_param_count(); + RETURN_THROWS(); } if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!lssl", &host, &hostlen, &port, &wallet, &walletlen, &walletpasswd, &walletpasswdlen, &authmode) != SUCCESS) { @@ -2790,8 +2795,8 @@ PHP_FUNCTION(ldap_modify_batch) zend_ulong value_index = 0; zval *modification_value_zv = NULL; ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(modification_values), modification_value_zv) { - zend_string *modval = zval_get_string(modification_value_zv); - if (EG(exception)) { + zend_string *modval = zval_try_get_string(modification_value_zv); + if (!modval) { RETVAL_FALSE; ldap_mods[modification_index]->mod_bvalues[value_index] = NULL; num_mods = modification_index + 1; @@ -3932,7 +3937,7 @@ PHP_FUNCTION(ldap_escape) char *value, *ignores; size_t valuelen = 0, ignoreslen = 0; zend_long flags = 0; - bool map[256] = {0}, havecharlist = 0; + bool map[256] = {0}, havecharlist = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|sl", &value, &valuelen, &ignores, &ignoreslen, &flags) != SUCCESS) { RETURN_THROWS(); @@ -3943,18 +3948,18 @@ PHP_FUNCTION(ldap_escape) } if (flags & PHP_LDAP_ESCAPE_FILTER) { - havecharlist = 1; + havecharlist = true; php_ldap_escape_map_set_chars(map, "\\*()\0", sizeof("\\*()\0") - 1, true); } if (flags & PHP_LDAP_ESCAPE_DN) { - havecharlist = 1; + havecharlist = true; php_ldap_escape_map_set_chars(map, "\\,=+<>;\"#\r", sizeof("\\,=+<>;\"#\r") - 1, true); } if (!havecharlist) { for (uint16_t i = 0; i < 256; i++) { - map[i] = 1; + map[i] = true; } } diff --git a/ext/ldap/tests/ldap_set_option_leak_attrvalue_context.phpt b/ext/ldap/tests/ldap_set_option_leak_attrvalue_context.phpt new file mode 100644 index 0000000000000..5829ad24faf57 --- /dev/null +++ b/ext/ldap/tests/ldap_set_option_leak_attrvalue_context.phpt @@ -0,0 +1,34 @@ +--TEST-- +ldap_set_option() - Leaks attrvalue and context +--EXTENSIONS-- +ldap +--FILE-- + "2.16.840.1.113730.3.4.9", "value" => ["attrvalue" => $attrvalue, "context" => $context, "before" => 0, "after" => 0]], +]; + +ldap_set_option($link, LDAP_OPT_CLIENT_CONTROLS, $controls); +ldap_get_option($link, LDAP_OPT_CLIENT_CONTROLS, $controls_out); + +var_dump($controls_out); +?> +--EXPECTF-- +array(1) { + ["2.16.840.1.113730.3.4.9"]=> + array(3) { + ["oid"]=> + string(23) "2.16.840.1.113730.3.4.9" + ["iscritical"]=> + bool(false) + ["value"]=> + string(28) "0%0%0� attrvaluecontext" + } +} diff --git a/ext/lexbor/lexbor/url/url.c b/ext/lexbor/lexbor/url/url.c index 3483013eeaafe..0eef7a6deba46 100644 --- a/ext/lexbor/lexbor/url/url.c +++ b/ext/lexbor/lexbor/url/url.c @@ -1817,7 +1817,6 @@ lxb_url_parse_basic_h(lxb_url_parser_t *parser, lxb_url_t *url, if (override_state != LXB_URL_STATE__UNDEF && url->scheme.type == LXB_URL_SCHEMEL_TYPE_FILE) { - p -= 1; state = LXB_URL_STATE_FILE_HOST_STATE; goto again; } diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index f51e01cdf504e..0105106d9531b 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -813,9 +813,12 @@ static xmlParserInputPtr php_libxml_external_entity_loader(const char *URL, } else { /* make stream not being closed when the zval is freed */ GC_ADDREF(stream->res); + + ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") pib->context = stream; pib->readcallback = php_libxml_streams_IO_read; pib->closecallback = php_libxml_streams_IO_close; + ZEND_DIAGNOSTIC_IGNORED_END ret = xmlNewIOInputStream(context, pib, enc); if (ret == NULL) { diff --git a/ext/libxml/libxml_arginfo.h b/ext/libxml/libxml_arginfo.h index 1741b7fa98604..9e3e07c83e503 100644 --- a/ext/libxml/libxml_arginfo.h +++ b/ext/libxml/libxml_arginfo.h @@ -104,9 +104,9 @@ static zend_class_entry *register_class_LibXMLError(void) zval property_level_default_value; ZVAL_UNDEF(&property_level_default_value); - zend_string *property_level_name = zend_string_init("level", sizeof("level") - 1, 1); + zend_string *property_level_name = zend_string_init("level", sizeof("level") - 1, true); zend_declare_typed_property(class_entry, property_level_name, &property_level_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_level_name); + zend_string_release_ex(property_level_name, true); zval property_code_default_value; ZVAL_UNDEF(&property_code_default_value); @@ -114,9 +114,9 @@ static zend_class_entry *register_class_LibXMLError(void) zval property_column_default_value; ZVAL_UNDEF(&property_column_default_value); - zend_string *property_column_name = zend_string_init("column", sizeof("column") - 1, 1); + zend_string *property_column_name = zend_string_init("column", sizeof("column") - 1, true); zend_declare_typed_property(class_entry, property_column_name, &property_column_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_column_name); + zend_string_release_ex(property_column_name, true); zval property_message_default_value; ZVAL_UNDEF(&property_message_default_value); diff --git a/ext/mbstring/mbstring.c b/ext/mbstring/mbstring.c index 4044f4de9ff57..118986411a8bb 100644 --- a/ext/mbstring/mbstring.c +++ b/ext/mbstring/mbstring.c @@ -116,7 +116,8 @@ static const enum mbfl_no_encoding php_mb_default_identify_list_cn[] = { mbfl_no_encoding_ascii, mbfl_no_encoding_utf8, mbfl_no_encoding_euc_cn, - mbfl_no_encoding_cp936 + mbfl_no_encoding_cp936, + mbfl_no_encoding_gb18030_2022 }; static const enum mbfl_no_encoding php_mb_default_identify_list_tw_hk[] = { @@ -313,7 +314,7 @@ static zend_result php_mb_parse_encoding_list(const char *value, size_t value_le list = (const mbfl_encoding **)pecalloc(size, sizeof(mbfl_encoding*), persistent); entry = list; n = 0; - included_auto = 0; + included_auto = false; p1 = tmpstr; while (1) { const char *comma = memchr(p1, ',', endp - p1); @@ -333,7 +334,7 @@ static zend_result php_mb_parse_encoding_list(const char *value, size_t value_le const enum mbfl_no_encoding *src = MBSTRG(default_detect_order_list); const size_t identify_list_size = MBSTRG(default_detect_order_list_size); size_t i; - included_auto = 1; + included_auto = true; for (i = 0; i < identify_list_size; i++) { *entry++ = mbfl_no2encoding(*src++); n++; @@ -379,7 +380,7 @@ static zend_result php_mb_parse_encoding_array(HashTable *target_hash, const mbf size_t size = zend_hash_num_elements(target_hash) + MBSTRG(default_detect_order_list_size); const mbfl_encoding **list = ecalloc(size, sizeof(mbfl_encoding*)); const mbfl_encoding **entry = list; - bool included_auto = 0; + bool included_auto = false; size_t n = 0; zval *hash_entry; ZEND_HASH_FOREACH_VAL(target_hash, hash_entry) { @@ -396,7 +397,7 @@ static zend_result php_mb_parse_encoding_array(HashTable *target_hash, const mbf const size_t identify_list_size = MBSTRG(default_detect_order_list_size); size_t j; - included_auto = 1; + included_auto = true; for (j = 0; j < identify_list_size; j++) { *entry++ = mbfl_no2encoding(*src++); n++; @@ -718,6 +719,11 @@ static PHP_INI_MH(OnUpdate_mbstring_detect_order) } MBSTRG(detect_order_list) = list; MBSTRG(detect_order_list_size) = size; + + if (stage == PHP_INI_STAGE_RUNTIME) { + php_mb_populate_current_detect_order_list(); + } + return SUCCESS; } /* }}} */ @@ -729,7 +735,7 @@ static zend_result _php_mb_ini_mbstring_http_input_set(const char *new_value, si list = (const mbfl_encoding**)pecalloc(1, sizeof(mbfl_encoding*), 1); *list = &mbfl_encoding_pass; size = 1; - } else if (FAILURE == php_mb_parse_encoding_list(new_value, new_value_length, &list, &size, /* persistent */ 1, /* arg_num */ 0) || size == 0) { + } else if (FAILURE == php_mb_parse_encoding_list(new_value, new_value_length, &list, &size, /* persistent */ true, /* arg_num */ 0) || size == 0) { return FAILURE; } if (MBSTRG(http_input_list)) { @@ -2788,7 +2794,7 @@ MBSTRING_API HashTable *php_mb_convert_encoding_recursive(HashTable *input, cons case IS_FALSE: case IS_LONG: case IS_DOUBLE: - ZVAL_COPY(&entry_tmp, entry); + ZVAL_COPY_VALUE(&entry_tmp, entry); break; case IS_ARRAY: chash = php_mb_convert_encoding_recursive( @@ -5578,19 +5584,16 @@ static bool mb_check_str_encoding(zend_string *str, const mbfl_encoding *encodin static bool php_mb_check_encoding_recursive(HashTable *vars, const mbfl_encoding *encoding) { - zend_long idx; zend_string *key; zval *entry; bool valid = true; - (void)(idx); /* Suppress spurious compiler warning that `idx` is not used */ - if (GC_IS_RECURSIVE(vars)) { php_error_docref(NULL, E_WARNING, "Cannot not handle circular references"); return false; } GC_TRY_PROTECT_RECURSION(vars); - ZEND_HASH_FOREACH_KEY_VAL(vars, idx, key, entry) { + ZEND_HASH_FOREACH_STR_KEY_VAL(vars, key, entry) { ZVAL_DEREF(entry); if (key) { if (!mb_check_str_encoding(key, encoding)) { @@ -5984,6 +5987,11 @@ static void php_mb_populate_current_detect_order_list(void) entry[i] = mbfl_no2encoding(src[i]); } } + + if (MBSTRG(current_detect_order_list) != NULL) { + efree(ZEND_VOIDP(MBSTRG(current_detect_order_list))); + } + MBSTRG(current_detect_order_list) = entry; MBSTRG(current_detect_order_list_size) = nentries; } @@ -6667,13 +6675,15 @@ static zend_string* mb_mime_header_decode(zend_string *input, const mbfl_encodin p = temp; /* Decoding of MIME encoded word was successful; * Try to collapse a run of whitespace */ - if (p < e && (*p == '\n' || *p == '\r')) { + if (p < e && (*p == '\n' || *p == '\r' || *p == '\t' || *p == ' ')) { do { p++; } while (p < e && (*p == '\n' || *p == '\r' || *p == '\t' || *p == ' ')); /* We will only actually output a space if this is not immediately followed * by another valid encoded word */ space_pending = true; + } else { + space_pending = false; } continue; } diff --git a/ext/mbstring/tests/gh20674.phpt b/ext/mbstring/tests/gh20674.phpt new file mode 100644 index 0000000000000..2fb8206037dee --- /dev/null +++ b/ext/mbstring/tests/gh20674.phpt @@ -0,0 +1,40 @@ +--TEST-- +GH-20674 (mb_decode_mimeheader does not handle separator) +--EXTENSIONS-- +mbstring +--FILE-- + +--EXPECTF-- +string(11) "The PHP 8.5" +string(11) "The PHP 8.5" +string(11) "The PHP 8.5" +string(11) "The PHP 8.5" +string(3) "(a)" +string(5) "(a b)" +string(5) "(a b)" +string(4) "(ab)" +string(4) "(ab)" +string(4) "(ab)" diff --git a/ext/mbstring/tests/mb_detect_order_with_ini_set.phpt b/ext/mbstring/tests/mb_detect_order_with_ini_set.phpt new file mode 100644 index 0000000000000..ba59f3388b85e --- /dev/null +++ b/ext/mbstring/tests/mb_detect_order_with_ini_set.phpt @@ -0,0 +1,60 @@ +--TEST-- +Test mb_detect_order() function : ini set changes order +--EXTENSIONS-- +mbstring +--INI-- +mbstring.detect_order=UTF-8,ISO-8859-15,ISO-8859-1,ASCII +--FILE-- + +--EXPECT-- +array(4) { + [0]=> + string(5) "UTF-8" + [1]=> + string(11) "ISO-8859-15" + [2]=> + string(10) "ISO-8859-1" + [3]=> + string(5) "ASCII" +} +array(3) { + [0]=> + string(5) "UTF-8" + [1]=> + string(10) "ISO-8859-1" + [2]=> + string(5) "ASCII" +} +array(1) { + [0]=> + string(5) "UTF-8" +} +array(1) { + [0]=> + string(5) "UTF-8" +} +array(1) { + [0]=> + string(5) "UTF-8" +} + diff --git a/ext/mbstring/tests/zh_CN_default_encodings.phpt b/ext/mbstring/tests/zh_CN_default_encodings.phpt new file mode 100644 index 0000000000000..213c304b52c69 --- /dev/null +++ b/ext/mbstring/tests/zh_CN_default_encodings.phpt @@ -0,0 +1,24 @@ +--TEST-- +Default encodings in Simplified Chinese +--EXTENSIONS-- +mbstring +--INI-- +mbstring.language=Simplified Chinese +--FILE-- + +--EXPECT-- +array(5) { + [0]=> + string(5) "ASCII" + [1]=> + string(5) "UTF-8" + [2]=> + string(6) "EUC-CN" + [3]=> + string(5) "CP936" + [4]=> + string(12) "GB18030-2022" +} diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index a8a75eff70863..26264aa2b170f 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -136,10 +136,6 @@ void php_clear_mysql(MY_MYSQL *mysql) { zend_string_release_ex(mysql->hash_key, 0); mysql->hash_key = NULL; } - if (!Z_ISUNDEF(mysql->li_read)) { - zval_ptr_dtor(&(mysql->li_read)); - ZVAL_UNDEF(&mysql->li_read); - } } /* }}} */ @@ -316,7 +312,7 @@ static int mysqli_object_has_property(zend_object *object, zend_string *name, in zval rv; zval *value = mysqli_read_property(object, name, BP_VAR_IS, cache_slot, &rv); if (value != &EG(uninitialized_zval)) { - has_property = zval_is_true(value); + has_property = zend_is_true(value); zval_ptr_dtor(value); } break; @@ -424,6 +420,19 @@ static const MYSQLND_REVERSE_API mysqli_reverse_api = { mysqli_convert_zv_to_mysqlnd }; +static PHP_INI_MH(OnUpdateDefaultPort) +{ + zend_long value = ZEND_ATOL(ZSTR_VAL(new_value)); + + if (value < 0 || value > USHRT_MAX) { + return FAILURE; + } + + MyG(default_port) = (unsigned short)value; + + return SUCCESS; +} + /* {{{ PHP_INI_BEGIN */ PHP_INI_BEGIN() STD_PHP_INI_ENTRY_EX("mysqli.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_mysqli_globals, mysqli_globals, display_link_numbers) @@ -433,7 +442,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("mysqli.default_host", NULL, PHP_INI_ALL, OnUpdateString, default_host, zend_mysqli_globals, mysqli_globals) STD_PHP_INI_ENTRY("mysqli.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_mysqli_globals, mysqli_globals) STD_PHP_INI_ENTRY("mysqli.default_pw", NULL, PHP_INI_ALL, OnUpdateString, default_pw, zend_mysqli_globals, mysqli_globals) - STD_PHP_INI_ENTRY("mysqli.default_port", "3306", PHP_INI_ALL, OnUpdateLong, default_port, zend_mysqli_globals, mysqli_globals) + STD_PHP_INI_ENTRY("mysqli.default_port", "3306", PHP_INI_ALL, OnUpdateDefaultPort, default_port, zend_mysqli_globals, mysqli_globals) #ifdef PHP_MYSQL_UNIX_SOCK_ADDR STD_PHP_INI_ENTRY("mysqli.default_socket", MYSQL_UNIX_ADDR,PHP_INI_ALL,OnUpdateStringUnempty, default_socket, zend_mysqli_globals, mysqli_globals) #else @@ -775,7 +784,7 @@ void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags } } } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); if (fetchtype < MYSQLI_ASSOC || fetchtype > MYSQLI_BOTH) { zend_argument_value_error(ERROR_ARG_POS(2), "must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH"); diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 2a20919eee45e..1bf74dd77eeab 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -324,7 +324,7 @@ PHP_FUNCTION(mysqli_data_seek) RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); if (mysqli_result_is_unbuffered(result)) { if (hasThis()) { @@ -670,7 +670,7 @@ PHP_FUNCTION(mysqli_fetch_field) RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); if (!(field = mysql_fetch_field(result))) { RETURN_FALSE; @@ -694,7 +694,7 @@ PHP_FUNCTION(mysqli_fetch_fields) RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); array_init(return_value); num_fields = mysql_num_fields(result); @@ -727,7 +727,7 @@ PHP_FUNCTION(mysqli_fetch_field_direct) RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); if (offset >= (zend_long) mysql_num_fields(result)) { zend_argument_value_error(ERROR_ARG_POS(2), "must be less than the number of fields for this result set"); @@ -755,7 +755,7 @@ PHP_FUNCTION(mysqli_fetch_lengths) RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); // TODO Warning? if (!(ret = mysql_fetch_lengths(result))) { @@ -809,7 +809,7 @@ PHP_FUNCTION(mysqli_field_seek) RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); if ((uint32_t)fieldnr >= mysql_num_fields(result)) { zend_argument_value_error(ERROR_ARG_POS(2), "must be less than the number of fields for this result set"); @@ -830,7 +830,7 @@ PHP_FUNCTION(mysqli_field_tell) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); RETURN_LONG(mysql_field_tell(result)); } @@ -845,7 +845,7 @@ PHP_FUNCTION(mysqli_free_result) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); mysqli_free_result(result, false); MYSQLI_CLEAR_RESOURCE(mysql_result); @@ -1123,7 +1123,7 @@ PHP_FUNCTION(mysqli_num_fields) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); RETURN_LONG(mysql_num_fields(result)); } @@ -1138,7 +1138,7 @@ PHP_FUNCTION(mysqli_num_rows) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &mysql_result, mysqli_result_class_entry) == FAILURE) { RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); if (mysqli_result_is_unbuffered_and_not_everything_is_fetched(result)) { zend_throw_error(NULL, "mysqli_num_rows() cannot be used in MYSQLI_USE_RESULT mode"); @@ -1343,9 +1343,6 @@ PHP_FUNCTION(mysqli_real_query) } /* }}} */ -# define mysql_real_escape_string_quote(mysql, to, from, length, quote) \ - mysql_real_escape_string(mysql, to, from, length) - PHP_FUNCTION(mysqli_real_escape_string) { MY_MYSQL *mysql; zval *mysql_link = NULL; @@ -1359,7 +1356,7 @@ PHP_FUNCTION(mysqli_real_escape_string) { MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); newstr = zend_string_safe_alloc(2, escapestr_len, 0, 0); - ZSTR_LEN(newstr) = mysql_real_escape_string_quote(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len, '\''); + ZSTR_LEN(newstr) = mysql_real_escape_string(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len); newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0); RETURN_NEW_STR(newstr); diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index de7cfa53e0f4f..789464a762538 100644 --- a/ext/mysqli/mysqli_arginfo.h +++ b/ext/mysqli/mysqli_arginfo.h @@ -1302,27 +1302,27 @@ static zend_class_entry *register_class_mysqli_driver(void) zval property_client_info_default_value; ZVAL_UNDEF(&property_client_info_default_value); - zend_string *property_client_info_name = zend_string_init("client_info", sizeof("client_info") - 1, 1); + zend_string *property_client_info_name = zend_string_init("client_info", sizeof("client_info") - 1, true); zend_declare_typed_property(class_entry, property_client_info_name, &property_client_info_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_client_info_name); + zend_string_release_ex(property_client_info_name, true); zval property_client_version_default_value; ZVAL_UNDEF(&property_client_version_default_value); - zend_string *property_client_version_name = zend_string_init("client_version", sizeof("client_version") - 1, 1); + zend_string *property_client_version_name = zend_string_init("client_version", sizeof("client_version") - 1, true); zend_declare_typed_property(class_entry, property_client_version_name, &property_client_version_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_client_version_name); + zend_string_release_ex(property_client_version_name, true); zval property_driver_version_default_value; ZVAL_UNDEF(&property_driver_version_default_value); - zend_string *property_driver_version_name = zend_string_init("driver_version", sizeof("driver_version") - 1, 1); + zend_string *property_driver_version_name = zend_string_init("driver_version", sizeof("driver_version") - 1, true); zend_declare_typed_property(class_entry, property_driver_version_name, &property_driver_version_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_driver_version_name); + zend_string_release_ex(property_driver_version_name, true); zval property_report_mode_default_value; ZVAL_LONG(&property_report_mode_default_value, 0); - zend_string *property_report_mode_name = zend_string_init("report_mode", sizeof("report_mode") - 1, 1); + zend_string *property_report_mode_name = zend_string_init("report_mode", sizeof("report_mode") - 1, true); zend_declare_typed_property(class_entry, property_report_mode_name, &property_report_mode_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_report_mode_name); + zend_string_release_ex(property_report_mode_name, true); return class_entry; } @@ -1336,111 +1336,111 @@ static zend_class_entry *register_class_mysqli(void) zval property_affected_rows_default_value; ZVAL_UNDEF(&property_affected_rows_default_value); - zend_string *property_affected_rows_name = zend_string_init("affected_rows", sizeof("affected_rows") - 1, 1); + zend_string *property_affected_rows_name = zend_string_init("affected_rows", sizeof("affected_rows") - 1, true); zend_declare_typed_property(class_entry, property_affected_rows_name, &property_affected_rows_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_STRING)); - zend_string_release(property_affected_rows_name); + zend_string_release_ex(property_affected_rows_name, true); zval property_client_info_default_value; ZVAL_UNDEF(&property_client_info_default_value); - zend_string *property_client_info_name = zend_string_init("client_info", sizeof("client_info") - 1, 1); + zend_string *property_client_info_name = zend_string_init("client_info", sizeof("client_info") - 1, true); zend_declare_typed_property(class_entry, property_client_info_name, &property_client_info_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_client_info_name); + zend_string_release_ex(property_client_info_name, true); zval property_client_version_default_value; ZVAL_UNDEF(&property_client_version_default_value); - zend_string *property_client_version_name = zend_string_init("client_version", sizeof("client_version") - 1, 1); + zend_string *property_client_version_name = zend_string_init("client_version", sizeof("client_version") - 1, true); zend_declare_typed_property(class_entry, property_client_version_name, &property_client_version_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_client_version_name); + zend_string_release_ex(property_client_version_name, true); zval property_connect_errno_default_value; ZVAL_UNDEF(&property_connect_errno_default_value); - zend_string *property_connect_errno_name = zend_string_init("connect_errno", sizeof("connect_errno") - 1, 1); + zend_string *property_connect_errno_name = zend_string_init("connect_errno", sizeof("connect_errno") - 1, true); zend_declare_typed_property(class_entry, property_connect_errno_name, &property_connect_errno_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_connect_errno_name); + zend_string_release_ex(property_connect_errno_name, true); zval property_connect_error_default_value; ZVAL_UNDEF(&property_connect_error_default_value); - zend_string *property_connect_error_name = zend_string_init("connect_error", sizeof("connect_error") - 1, 1); + zend_string *property_connect_error_name = zend_string_init("connect_error", sizeof("connect_error") - 1, true); zend_declare_typed_property(class_entry, property_connect_error_name, &property_connect_error_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_connect_error_name); + zend_string_release_ex(property_connect_error_name, true); zval property_errno_default_value; ZVAL_UNDEF(&property_errno_default_value); - zend_string *property_errno_name = zend_string_init("errno", sizeof("errno") - 1, 1); + zend_string *property_errno_name = zend_string_init("errno", sizeof("errno") - 1, true); zend_declare_typed_property(class_entry, property_errno_name, &property_errno_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_errno_name); + zend_string_release_ex(property_errno_name, true); zval property_error_default_value; ZVAL_UNDEF(&property_error_default_value); - zend_string *property_error_name = zend_string_init("error", sizeof("error") - 1, 1); + zend_string *property_error_name = zend_string_init("error", sizeof("error") - 1, true); zend_declare_typed_property(class_entry, property_error_name, &property_error_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_error_name); + zend_string_release_ex(property_error_name, true); zval property_error_list_default_value; ZVAL_UNDEF(&property_error_list_default_value); - zend_string *property_error_list_name = zend_string_init("error_list", sizeof("error_list") - 1, 1); + zend_string *property_error_list_name = zend_string_init("error_list", sizeof("error_list") - 1, true); zend_declare_typed_property(class_entry, property_error_list_name, &property_error_list_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); - zend_string_release(property_error_list_name); + zend_string_release_ex(property_error_list_name, true); zval property_field_count_default_value; ZVAL_UNDEF(&property_field_count_default_value); - zend_string *property_field_count_name = zend_string_init("field_count", sizeof("field_count") - 1, 1); + zend_string *property_field_count_name = zend_string_init("field_count", sizeof("field_count") - 1, true); zend_declare_typed_property(class_entry, property_field_count_name, &property_field_count_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_field_count_name); + zend_string_release_ex(property_field_count_name, true); zval property_host_info_default_value; ZVAL_UNDEF(&property_host_info_default_value); - zend_string *property_host_info_name = zend_string_init("host_info", sizeof("host_info") - 1, 1); + zend_string *property_host_info_name = zend_string_init("host_info", sizeof("host_info") - 1, true); zend_declare_typed_property(class_entry, property_host_info_name, &property_host_info_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_host_info_name); + zend_string_release_ex(property_host_info_name, true); zval property_info_default_value; ZVAL_UNDEF(&property_info_default_value); - zend_string *property_info_name = zend_string_init("info", sizeof("info") - 1, 1); + zend_string *property_info_name = zend_string_init("info", sizeof("info") - 1, true); zend_declare_typed_property(class_entry, property_info_name, &property_info_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_info_name); + zend_string_release_ex(property_info_name, true); zval property_insert_id_default_value; ZVAL_UNDEF(&property_insert_id_default_value); - zend_string *property_insert_id_name = zend_string_init("insert_id", sizeof("insert_id") - 1, 1); + zend_string *property_insert_id_name = zend_string_init("insert_id", sizeof("insert_id") - 1, true); zend_declare_typed_property(class_entry, property_insert_id_name, &property_insert_id_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_STRING)); - zend_string_release(property_insert_id_name); + zend_string_release_ex(property_insert_id_name, true); zval property_server_info_default_value; ZVAL_UNDEF(&property_server_info_default_value); - zend_string *property_server_info_name = zend_string_init("server_info", sizeof("server_info") - 1, 1); + zend_string *property_server_info_name = zend_string_init("server_info", sizeof("server_info") - 1, true); zend_declare_typed_property(class_entry, property_server_info_name, &property_server_info_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_server_info_name); + zend_string_release_ex(property_server_info_name, true); zval property_server_version_default_value; ZVAL_UNDEF(&property_server_version_default_value); - zend_string *property_server_version_name = zend_string_init("server_version", sizeof("server_version") - 1, 1); + zend_string *property_server_version_name = zend_string_init("server_version", sizeof("server_version") - 1, true); zend_declare_typed_property(class_entry, property_server_version_name, &property_server_version_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_server_version_name); + zend_string_release_ex(property_server_version_name, true); zval property_sqlstate_default_value; ZVAL_UNDEF(&property_sqlstate_default_value); - zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, 1); + zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, true); zend_declare_typed_property(class_entry, property_sqlstate_name, &property_sqlstate_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_sqlstate_name); + zend_string_release_ex(property_sqlstate_name, true); zval property_protocol_version_default_value; ZVAL_UNDEF(&property_protocol_version_default_value); - zend_string *property_protocol_version_name = zend_string_init("protocol_version", sizeof("protocol_version") - 1, 1); + zend_string *property_protocol_version_name = zend_string_init("protocol_version", sizeof("protocol_version") - 1, true); zend_declare_typed_property(class_entry, property_protocol_version_name, &property_protocol_version_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_protocol_version_name); + zend_string_release_ex(property_protocol_version_name, true); zval property_thread_id_default_value; ZVAL_UNDEF(&property_thread_id_default_value); - zend_string *property_thread_id_name = zend_string_init("thread_id", sizeof("thread_id") - 1, 1); + zend_string *property_thread_id_name = zend_string_init("thread_id", sizeof("thread_id") - 1, true); zend_declare_typed_property(class_entry, property_thread_id_name, &property_thread_id_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_thread_id_name); + zend_string_release_ex(property_thread_id_name, true); zval property_warning_count_default_value; ZVAL_UNDEF(&property_warning_count_default_value); - zend_string *property_warning_count_name = zend_string_init("warning_count", sizeof("warning_count") - 1, 1); + zend_string *property_warning_count_name = zend_string_init("warning_count", sizeof("warning_count") - 1, true); zend_declare_typed_property(class_entry, property_warning_count_name, &property_warning_count_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_warning_count_name); + zend_string_release_ex(property_warning_count_name, true); zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "__construct", sizeof("__construct") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); @@ -1499,27 +1499,27 @@ static zend_class_entry *register_class_mysqli_result(zend_class_entry *class_en zval property_current_field_default_value; ZVAL_UNDEF(&property_current_field_default_value); - zend_string *property_current_field_name = zend_string_init("current_field", sizeof("current_field") - 1, 1); + zend_string *property_current_field_name = zend_string_init("current_field", sizeof("current_field") - 1, true); zend_declare_typed_property(class_entry, property_current_field_name, &property_current_field_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_current_field_name); + zend_string_release_ex(property_current_field_name, true); zval property_field_count_default_value; ZVAL_UNDEF(&property_field_count_default_value); - zend_string *property_field_count_name = zend_string_init("field_count", sizeof("field_count") - 1, 1); + zend_string *property_field_count_name = zend_string_init("field_count", sizeof("field_count") - 1, true); zend_declare_typed_property(class_entry, property_field_count_name, &property_field_count_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_field_count_name); + zend_string_release_ex(property_field_count_name, true); zval property_lengths_default_value; ZVAL_UNDEF(&property_lengths_default_value); - zend_string *property_lengths_name = zend_string_init("lengths", sizeof("lengths") - 1, 1); + zend_string *property_lengths_name = zend_string_init("lengths", sizeof("lengths") - 1, true); zend_declare_typed_property(class_entry, property_lengths_name, &property_lengths_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL)); - zend_string_release(property_lengths_name); + zend_string_release_ex(property_lengths_name, true); zval property_num_rows_default_value; ZVAL_UNDEF(&property_num_rows_default_value); - zend_string *property_num_rows_name = zend_string_init("num_rows", sizeof("num_rows") - 1, 1); + zend_string *property_num_rows_name = zend_string_init("num_rows", sizeof("num_rows") - 1, true); zend_declare_typed_property(class_entry, property_num_rows_name, &property_num_rows_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_STRING)); - zend_string_release(property_num_rows_name); + zend_string_release_ex(property_num_rows_name, true); zval property_type_default_value; ZVAL_UNDEF(&property_type_default_value); @@ -1537,63 +1537,63 @@ static zend_class_entry *register_class_mysqli_stmt(void) zval property_affected_rows_default_value; ZVAL_UNDEF(&property_affected_rows_default_value); - zend_string *property_affected_rows_name = zend_string_init("affected_rows", sizeof("affected_rows") - 1, 1); + zend_string *property_affected_rows_name = zend_string_init("affected_rows", sizeof("affected_rows") - 1, true); zend_declare_typed_property(class_entry, property_affected_rows_name, &property_affected_rows_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_STRING)); - zend_string_release(property_affected_rows_name); + zend_string_release_ex(property_affected_rows_name, true); zval property_insert_id_default_value; ZVAL_UNDEF(&property_insert_id_default_value); - zend_string *property_insert_id_name = zend_string_init("insert_id", sizeof("insert_id") - 1, 1); + zend_string *property_insert_id_name = zend_string_init("insert_id", sizeof("insert_id") - 1, true); zend_declare_typed_property(class_entry, property_insert_id_name, &property_insert_id_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_STRING)); - zend_string_release(property_insert_id_name); + zend_string_release_ex(property_insert_id_name, true); zval property_num_rows_default_value; ZVAL_UNDEF(&property_num_rows_default_value); - zend_string *property_num_rows_name = zend_string_init("num_rows", sizeof("num_rows") - 1, 1); + zend_string *property_num_rows_name = zend_string_init("num_rows", sizeof("num_rows") - 1, true); zend_declare_typed_property(class_entry, property_num_rows_name, &property_num_rows_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_STRING)); - zend_string_release(property_num_rows_name); + zend_string_release_ex(property_num_rows_name, true); zval property_param_count_default_value; ZVAL_UNDEF(&property_param_count_default_value); - zend_string *property_param_count_name = zend_string_init("param_count", sizeof("param_count") - 1, 1); + zend_string *property_param_count_name = zend_string_init("param_count", sizeof("param_count") - 1, true); zend_declare_typed_property(class_entry, property_param_count_name, &property_param_count_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_param_count_name); + zend_string_release_ex(property_param_count_name, true); zval property_field_count_default_value; ZVAL_UNDEF(&property_field_count_default_value); - zend_string *property_field_count_name = zend_string_init("field_count", sizeof("field_count") - 1, 1); + zend_string *property_field_count_name = zend_string_init("field_count", sizeof("field_count") - 1, true); zend_declare_typed_property(class_entry, property_field_count_name, &property_field_count_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_field_count_name); + zend_string_release_ex(property_field_count_name, true); zval property_errno_default_value; ZVAL_UNDEF(&property_errno_default_value); - zend_string *property_errno_name = zend_string_init("errno", sizeof("errno") - 1, 1); + zend_string *property_errno_name = zend_string_init("errno", sizeof("errno") - 1, true); zend_declare_typed_property(class_entry, property_errno_name, &property_errno_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_errno_name); + zend_string_release_ex(property_errno_name, true); zval property_error_default_value; ZVAL_UNDEF(&property_error_default_value); - zend_string *property_error_name = zend_string_init("error", sizeof("error") - 1, 1); + zend_string *property_error_name = zend_string_init("error", sizeof("error") - 1, true); zend_declare_typed_property(class_entry, property_error_name, &property_error_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_error_name); + zend_string_release_ex(property_error_name, true); zval property_error_list_default_value; ZVAL_UNDEF(&property_error_list_default_value); - zend_string *property_error_list_name = zend_string_init("error_list", sizeof("error_list") - 1, 1); + zend_string *property_error_list_name = zend_string_init("error_list", sizeof("error_list") - 1, true); zend_declare_typed_property(class_entry, property_error_list_name, &property_error_list_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); - zend_string_release(property_error_list_name); + zend_string_release_ex(property_error_list_name, true); zval property_sqlstate_default_value; ZVAL_UNDEF(&property_sqlstate_default_value); - zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, 1); + zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, true); zend_declare_typed_property(class_entry, property_sqlstate_name, &property_sqlstate_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_sqlstate_name); + zend_string_release_ex(property_sqlstate_name, true); zval property_id_default_value; ZVAL_UNDEF(&property_id_default_value); - zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, 1); + zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, true); zend_declare_typed_property(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_id_name); + zend_string_release_ex(property_id_name, true); return class_entry; } @@ -1611,15 +1611,15 @@ static zend_class_entry *register_class_mysqli_warning(void) zval property_sqlstate_default_value; ZVAL_UNDEF(&property_sqlstate_default_value); - zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, 1); + zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, true); zend_declare_typed_property(class_entry, property_sqlstate_name, &property_sqlstate_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_sqlstate_name); + zend_string_release_ex(property_sqlstate_name, true); zval property_errno_default_value; ZVAL_UNDEF(&property_errno_default_value); - zend_string *property_errno_name = zend_string_init("errno", sizeof("errno") - 1, 1); + zend_string *property_errno_name = zend_string_init("errno", sizeof("errno") - 1, true); zend_declare_typed_property(class_entry, property_errno_name, &property_errno_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_errno_name); + zend_string_release_ex(property_errno_name, true); return class_entry; } @@ -1634,9 +1634,9 @@ static zend_class_entry *register_class_mysqli_sql_exception(zend_class_entry *c zval property_sqlstate_default_value; zend_string *property_sqlstate_default_value_str = zend_string_init("00000", strlen("00000"), 1); ZVAL_STR(&property_sqlstate_default_value, property_sqlstate_default_value_str); - zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, 1); + zend_string *property_sqlstate_name = zend_string_init("sqlstate", sizeof("sqlstate") - 1, true); zend_declare_typed_property(class_entry, property_sqlstate_name, &property_sqlstate_default_value, ZEND_ACC_PROTECTED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_sqlstate_name); + zend_string_release_ex(property_sqlstate_name, true); return class_entry; } diff --git a/ext/mysqli/mysqli_nonapi.c b/ext/mysqli/mysqli_nonapi.c index e0e14eeccbc92..a3208b41574b1 100644 --- a/ext/mysqli/mysqli_nonapi.c +++ b/ext/mysqli/mysqli_nonapi.c @@ -56,12 +56,12 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b size_t hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0; bool persistent = false, ssl = false; zend_long port = 0, flags = 0; - bool port_is_null = 1; + bool port_is_null = true; zend_string *hash_key = NULL; bool new_connection = false; zend_resource *le; mysqli_plist_entry *plist = NULL; - bool self_alloced = 0; + bool self_alloced = false; #if !defined(MYSQL_USE_MYSQLND) @@ -105,9 +105,8 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b } if (!mysql) { mysql = (MY_MYSQL *) ecalloc(1, sizeof(MY_MYSQL)); - self_alloced = 1; + self_alloced = true; } - flags |= CLIENT_MULTI_RESULTS; /* needed for mysql_multi_query() */ } else { /* We have flags too */ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|s!s!s!s!l!s!l", &object, mysqli_link_class_entry, @@ -118,11 +117,10 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b mysqli_resource = (Z_MYSQLI_P(object))->ptr; MYSQLI_FETCH_RESOURCE_CONN(mysql, object, MYSQLI_STATUS_INITIALIZED); - /* set some required options */ - flags |= CLIENT_MULTI_RESULTS; /* needed for mysql_multi_query() */ /* remove some insecure options */ flags &= ~CLIENT_MULTI_STATEMENTS; /* don't allow multi_queries via connect parameter */ } + flags |= CLIENT_MULTI_RESULTS; /* needed for mysql_multi_query() */ if (!socket_len || !socket) { socket = MyG(default_socket); @@ -316,7 +314,7 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, b mysql->hash_key = NULL; mysql->persistent = false; } - if (!is_real_connect && self_alloced) { + if (self_alloced) { efree(mysql); } RETVAL_FALSE; @@ -393,7 +391,7 @@ PHP_FUNCTION(mysqli_fetch_column) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &col_no) == FAILURE) { RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES*, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES*, mysql_result, MYSQLI_STATUS_VALID); if (col_no < 0) { zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0"); @@ -425,7 +423,7 @@ PHP_FUNCTION(mysqli_fetch_all) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|l", &mysql_result, mysqli_result_class_entry, &mode) == FAILURE) { RETURN_THROWS(); } - MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, MYSQLI_STATUS_VALID); if (!mode || (mode & ~MYSQLI_BOTH)) { zend_argument_value_error(ERROR_ARG_POS(2), "must be one of MYSQLI_NUM, MYSQLI_ASSOC, or MYSQLI_BOTH"); @@ -1031,6 +1029,7 @@ PHP_FUNCTION(mysqli_begin_transaction) } if (FAIL == mysqlnd_begin_transaction(mysql->mysql, flags, name)) { + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } RETURN_TRUE; @@ -1055,6 +1054,7 @@ PHP_FUNCTION(mysqli_savepoint) } if (FAIL == mysqlnd_savepoint(mysql->mysql, name)) { + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } RETURN_TRUE; @@ -1078,6 +1078,7 @@ PHP_FUNCTION(mysqli_release_savepoint) RETURN_THROWS(); } if (FAIL == mysqlnd_release_savepoint(mysql->mysql, name)) { + MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); RETURN_FALSE; } RETURN_TRUE; diff --git a/ext/mysqli/mysqli_priv.h b/ext/mysqli/mysqli_priv.h index f08d66b7287d9..5f7c49f0b2979 100644 --- a/ext/mysqli/mysqli_priv.h +++ b/ext/mysqli/mysqli_priv.h @@ -55,7 +55,6 @@ extern void php_clear_mysql(MY_MYSQL *); extern MYSQLI_WARNING *php_get_warnings(MYSQLND_CONN_DATA * mysql); extern void php_clear_warnings(MYSQLI_WARNING *w); -extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type); extern void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error); extern void php_mysqli_report_index(const char *query, unsigned int status); extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno, char *format, ...); diff --git a/ext/mysqli/mysqli_result_iterator.c b/ext/mysqli/mysqli_result_iterator.c index 3441e47d01a4c..5dbeaf1e3b22b 100644 --- a/ext/mysqli/mysqli_result_iterator.c +++ b/ext/mysqli/mysqli_result_iterator.c @@ -98,7 +98,7 @@ static void php_mysqli_result_iterator_move_forward(zend_object_iterator *iter) mysqli_object *intern = iterator->result; MYSQL_RES *result; - MYSQLI_FETCH_RESOURCE_BY_OBJ(result, MYSQL_RES *, intern, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE_BY_OBJ(result, MYSQL_RES *, intern, MYSQLI_STATUS_VALID); zval_ptr_dtor(&iterator->current_row); php_mysqli_fetch_into_hash_aux(&iterator->current_row, result, MYSQLI_ASSOC); @@ -115,7 +115,7 @@ static void php_mysqli_result_iterator_rewind(zend_object_iterator *iter) mysqli_object *intern = iterator->result; MYSQL_RES *result; - MYSQLI_FETCH_RESOURCE_BY_OBJ(result, MYSQL_RES *, intern, "mysqli_result", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE_BY_OBJ(result, MYSQL_RES *, intern, MYSQLI_STATUS_VALID); if (mysqli_result_is_unbuffered(result)) { if (result->unbuf->eof_reached) { diff --git a/ext/mysqli/mysqli_warning.c b/ext/mysqli/mysqli_warning.c index b1427495a5066..4b0792b9684b8 100644 --- a/ext/mysqli/mysqli_warning.c +++ b/ext/mysqli/mysqli_warning.c @@ -125,7 +125,7 @@ PHP_METHOD(mysqli_warning, next) } if (obj->ptr) { - MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, ZEND_THIS, "mysqli_warning", MYSQLI_STATUS_VALID); + MYSQLI_FETCH_RESOURCE(w, MYSQLI_WARNING *, ZEND_THIS, MYSQLI_STATUS_VALID); if (w && w->next) { w = w->next; diff --git a/ext/mysqli/php_mysqli_structs.h b/ext/mysqli/php_mysqli_structs.h index c155281c8e4bc..ceab4a44f3953 100644 --- a/ext/mysqli/php_mysqli_structs.h +++ b/ext/mysqli/php_mysqli_structs.h @@ -38,32 +38,14 @@ enum mysqli_status { MYSQLI_STATUS_VALID }; -typedef struct { - char *val; - zend_ulong buflen; - zend_ulong output_len; - zend_ulong type; -} VAR_BUFFER; - -typedef struct { - unsigned int var_cnt; - VAR_BUFFER *buf; - zval *vars; - my_bool *is_null; -} BIND_BUFFER; - typedef struct { MYSQL_STMT *stmt; - BIND_BUFFER param; - BIND_BUFFER result; char *query; } MY_STMT; typedef struct { MYSQL *mysql; zend_string *hash_key; - zval li_read; - php_stream *li_stream; unsigned int multi_query; bool persistent; int async_result_fetch_type; @@ -177,7 +159,7 @@ extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * resul MYSQLI_REGISTER_RESOURCE_EX(__ptr, object)\ } -#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name, __check) \ +#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __check) \ { \ MYSQLI_RESOURCE *my_res; \ mysqli_object *intern = Z_MYSQLI_P(__id); \ @@ -192,7 +174,7 @@ extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * resul }\ } -#define MYSQLI_FETCH_RESOURCE_BY_OBJ(__ptr, __type, __obj, __name, __check) \ +#define MYSQLI_FETCH_RESOURCE_BY_OBJ(__ptr, __type, __obj, __check) \ { \ MYSQLI_RESOURCE *my_res; \ if (!(my_res = (MYSQLI_RESOURCE *)(__obj->ptr))) {\ @@ -208,7 +190,7 @@ extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * resul #define MYSQLI_FETCH_RESOURCE_CONN(__ptr, __id, __check) \ { \ - MYSQLI_FETCH_RESOURCE((__ptr), MY_MYSQL *, (__id), "mysqli_link", (__check)); \ + MYSQLI_FETCH_RESOURCE((__ptr), MY_MYSQL *, (__id), (__check)); \ if (!(__ptr)->mysql) { \ zend_throw_error(NULL, "%s object is not fully initialized", ZSTR_VAL(Z_OBJCE_P(__id)->name)); \ RETURN_THROWS(); \ @@ -217,7 +199,7 @@ extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * resul #define MYSQLI_FETCH_RESOURCE_STMT(__ptr, __id, __check) \ { \ - MYSQLI_FETCH_RESOURCE((__ptr), MY_STMT *, (__id), "mysqli_stmt", (__check)); \ + MYSQLI_FETCH_RESOURCE((__ptr), MY_STMT *, (__id), (__check)); \ ZEND_ASSERT((__ptr)->stmt && "Missing statement?"); \ } @@ -236,21 +218,21 @@ extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * resul ZEND_BEGIN_MODULE_GLOBALS(mysqli) - zend_long num_links; - zend_long max_links; - zend_long num_active_persistent; - zend_long num_inactive_persistent; - zend_long max_persistent; + unsigned short default_port; bool allow_persistent; - zend_ulong default_port; + bool allow_local_infile; char *default_host; char *default_user; char *default_pw; char *default_socket; - bool allow_local_infile; char *local_infile_directory; - zend_long error_no; char *error_msg; + zend_long num_links; + zend_long max_links; + zend_long num_active_persistent; + zend_long num_inactive_persistent; + zend_long max_persistent; + zend_long error_no; zend_long report_mode; bool rollback_on_cached_plink; ZEND_END_MODULE_GLOBALS(mysqli) diff --git a/ext/mysqli/tests/mysqli_begin_transaction_error.phpt b/ext/mysqli/tests/mysqli_begin_transaction_error.phpt new file mode 100644 index 0000000000000..e4d63f366e86b --- /dev/null +++ b/ext/mysqli/tests/mysqli_begin_transaction_error.phpt @@ -0,0 +1,42 @@ +--TEST-- +mysqli_begin_transaction() +--EXTENSIONS-- +mysqli +--SKIPIF-- +errno, $link->error)); +?> +--FILE-- + +--CLEAN-- + +--EXPECT-- +Expecting an exception. +done! diff --git a/ext/mysqli/tests/mysqli_default_port_error.phpt b/ext/mysqli/tests/mysqli_default_port_error.phpt new file mode 100644 index 0000000000000..7d3658417c96c --- /dev/null +++ b/ext/mysqli/tests/mysqli_default_port_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +default_port ini setting +--EXTENSIONS-- +mysqli +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(false) diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c index 5fad5281947ea..76a2eb640d1de 100644 --- a/ext/mysqlnd/mysqlnd_ps.c +++ b/ext/mysqlnd/mysqlnd_ps.c @@ -58,7 +58,7 @@ static bool mysqlnd_stmt_check_state(const MYSQLND_STMT_DATA *stmt) { const MYSQLND_CONN_DATA *conn = stmt->conn; if (stmt->state != MYSQLND_STMT_WAITING_USE_OR_STORE) { - return 0; + return false; } if (stmt->cursor_exists) { return GET_CONNECTION_STATE(&conn->state) == CONN_READY; diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c index a2e98cf358bb4..c60e3d327a8d7 100644 --- a/ext/mysqlnd/mysqlnd_ps_codec.c +++ b/ext/mysqlnd/mysqlnd_ps_codec.c @@ -317,7 +317,7 @@ ps_fetch_date(zval * zv, const MYSQLND_FIELD * const field, const unsigned int p const zend_uchar * to = *row; t.time_type = MYSQLND_TIMESTAMP_DATE; - t.neg = 0; + t.neg = false; t.second_part = t.hour = t.minute = t.second = 0; @@ -354,7 +354,7 @@ ps_fetch_datetime(zval * zv, const MYSQLND_FIELD * const field, const unsigned i const zend_uchar * to = *row; t.time_type = MYSQLND_TIMESTAMP_DATETIME; - t.neg = 0; + t.neg = false; t.year = (unsigned int) sint2korr(to); t.month = (unsigned int) to[2]; diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 7a6bc28718258..a6af7469cbac3 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -1306,11 +1306,14 @@ PHP_FUNCTION(odbc_exec) } /* }}} */ -#define ODBC_NUM 1 -#define ODBC_OBJECT 2 +typedef enum php_odbc_fetch_result_type_t { + ODBC_NONE = 0, + ODBC_NUM = 1, + ODBC_OBJECT = 2, +} php_odbc_fetch_result_type_t; -/* {{{ php_odbc_fetch_hash */ -static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) +/* {{{ php_odbc_fetch */ +static void php_odbc_fetch(INTERNAL_FUNCTION_PARAMETERS, bool return_array, php_odbc_fetch_result_type_t result_type) { int i; odbc_result *result; @@ -1319,29 +1322,56 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) char *buf = NULL; zend_long pv_row = 0; bool pv_row_is_null = true; - zval *pv_res, tmp; - SQLULEN crow; - SQLUSMALLINT RowStatus[1]; + zval *pv_res, *pv_res_arr, tmp; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!", &pv_res, odbc_result_ce, &pv_row, &pv_row_is_null) == FAILURE) { - RETURN_THROWS(); + if (return_array || result_type == ODBC_NONE) { + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(pv_res, odbc_result_ce) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(pv_row, pv_row_is_null) + ZEND_PARSE_PARAMETERS_END(); + /* So we can use pv_res_arr for both return value and passed */ + pv_res_arr = return_value; + } else { + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_OBJECT_OF_CLASS(pv_res, odbc_result_ce) + Z_PARAM_ZVAL(pv_res_arr) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(pv_row, pv_row_is_null) + ZEND_PARSE_PARAMETERS_END(); } result = Z_ODBC_RESULT_P(pv_res); CHECK_ODBC_RESULT(result); - /* TODO deprecate $row argument values less than 1 after PHP 8.4 */ + /* TODO deprecate $row argument values less than 1 after PHP 8.4 + * for functions other than odbc_fetch_row (see GH-13910) + */ + if (!result_type && !pv_row_is_null && pv_row < 1) { + php_error_docref(NULL, E_WARNING, "Argument #3 ($row) must be greater than or equal to 1"); + RETURN_FALSE; + } if (result->numcols == 0) { php_error_docref(NULL, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } + /* If we're initializing a passed value into an array, do it before the fetch + * so that an empty result set will still be an array. + */ + if (!return_array && result_type) { + pv_res_arr = zend_try_array_init(pv_res_arr); + if (!pv_res_arr) { + RETURN_THROWS(); + } + } + if (result->fetch_abs) { if (!pv_row_is_null && pv_row > 0) { - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,(SQLLEN)pv_row,&crow,RowStatus); + rc = SQLFetchScroll(result->stmt, SQL_FETCH_ABSOLUTE, (SQLLEN)pv_row); } else { - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus); + rc = SQLFetchScroll(result->stmt, SQL_FETCH_NEXT, 1); } } else { rc = SQLFetch(result->stmt); @@ -1349,18 +1379,28 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { if (rc == SQL_ERROR) { - odbc_sql_error(result->conn_ptr, result->stmt, "SQLExtendedFetch"); + odbc_sql_error(result->conn_ptr, result->stmt, "SQLFetchScroll"); } RETURN_FALSE; } - array_init(return_value); + /* ...but if returning an array, init only if we have a result set */ + if (return_array && result_type) { + array_init(pv_res_arr); + } if (!pv_row_is_null && pv_row > 0 && result->fetch_abs) result->fetched = (SQLLEN)pv_row; else result->fetched++; + /* For fetch_row, we don't return anything other than true, + * odbc_result will be used to fetch values instead. + */ + if (result_type == ODBC_NONE) { + RETURN_TRUE; + } + for(i = 0; i < result->numcols; i++) { sql_c_type = SQL_C_CHAR; @@ -1375,6 +1415,8 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) if (result->binmode == 1) { sql_c_type = SQL_C_BINARY; } + + /* TODO: Check this is the intended behaviour */ ZEND_FALLTHROUGH; case SQL_LONGVARCHAR: case SQL_WLONGVARCHAR: @@ -1391,7 +1433,9 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) if (rc == SQL_ERROR) { odbc_sql_error(result->conn_ptr, result->stmt, "SQLGetData"); efree(buf); - zval_ptr_dtor(return_value); + if (return_array) { + zval_ptr_dtor(pv_res_arr); + } RETURN_FALSE; } @@ -1425,18 +1469,23 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) } if (result_type & ODBC_NUM) { - zend_hash_index_update(Z_ARRVAL_P(return_value), i, &tmp); + zend_hash_index_update(Z_ARRVAL_P(pv_res_arr), i, &tmp); } else { if (!*(result->values[i].name) && Z_TYPE(tmp) == IS_STRING) { - zend_hash_update(Z_ARRVAL_P(return_value), Z_STR(tmp), &tmp); + zend_hash_update(Z_ARRVAL_P(pv_res_arr), Z_STR(tmp), &tmp); } else { - zend_hash_str_update(Z_ARRVAL_P(return_value), result->values[i].name, strlen(result->values[i].name), &tmp); + zend_hash_str_update(Z_ARRVAL_P(pv_res_arr), result->values[i].name, strlen(result->values[i].name), &tmp); } } } if (buf) { efree(buf); } + + /* return_value was set to an array otherwise */ + if (!return_array) { + RETURN_LONG(result->numcols); + } } /* }}} */ @@ -1444,7 +1493,7 @@ static void php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type) /* {{{ Fetch a result row as an object */ PHP_FUNCTION(odbc_fetch_object) { - php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, ODBC_OBJECT); + php_odbc_fetch(INTERNAL_FUNCTION_PARAM_PASSTHRU, true, ODBC_OBJECT); if (Z_TYPE_P(return_value) == IS_ARRAY) { object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, Z_ARRVAL_P(return_value)); } @@ -1454,184 +1503,21 @@ PHP_FUNCTION(odbc_fetch_object) /* {{{ Fetch a result row as an associative array */ PHP_FUNCTION(odbc_fetch_array) { - php_odbc_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, ODBC_OBJECT); + php_odbc_fetch(INTERNAL_FUNCTION_PARAM_PASSTHRU, true, ODBC_OBJECT); } /* }}} */ /* {{{ Fetch one result row into an array */ PHP_FUNCTION(odbc_fetch_into) { - int i; - odbc_result *result; - RETCODE rc; - SQLSMALLINT sql_c_type; - char *buf = NULL; - zval *pv_res, *pv_res_arr, tmp; - zend_long pv_row = 0; - bool pv_row_is_null = true; - SQLULEN crow; - SQLUSMALLINT RowStatus[1]; - - 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(); - } - - result = Z_ODBC_RESULT_P(pv_res); - CHECK_ODBC_RESULT(result); - - /* TODO deprecate $row argument values less than 1 after PHP 8.4 */ - - if (result->numcols == 0) { - php_error_docref(NULL, E_WARNING, "No tuples available at this result index"); - RETURN_FALSE; - } - - pv_res_arr = zend_try_array_init(pv_res_arr); - if (!pv_res_arr) { - RETURN_THROWS(); - } - - if (result->fetch_abs) { - if (!pv_row_is_null && pv_row > 0) { - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,(SQLLEN)pv_row,&crow,RowStatus); - } else { - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus); - } - } else { - rc = SQLFetch(result->stmt); - } - - if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - if (rc == SQL_ERROR) { - odbc_sql_error(result->conn_ptr, result->stmt, "SQLExtendedFetch"); - } - RETURN_FALSE; - } - - if (!pv_row_is_null && pv_row > 0 && result->fetch_abs) - result->fetched = (SQLLEN)pv_row; - else - result->fetched++; - - for(i = 0; i < result->numcols; i++) { - sql_c_type = SQL_C_CHAR; - - switch(result->values[i].coltype) { - case SQL_BINARY: - case SQL_VARBINARY: - case SQL_LONGVARBINARY: - if (result->binmode <= 0) { - ZVAL_EMPTY_STRING(&tmp); - break; - } - if (result->binmode == 1) sql_c_type = SQL_C_BINARY; - - /* TODO: Check this is the intended behaviour */ - ZEND_FALLTHROUGH; - case SQL_LONGVARCHAR: - case SQL_WLONGVARCHAR: - if (IS_SQL_LONG(result->values[i].coltype) && result->longreadlen <= 0) { - ZVAL_EMPTY_STRING(&tmp); - break; - } - - if (buf == NULL) { - buf = emalloc(result->longreadlen + 1); - } - rc = SQLGetData(result->stmt, (SQLUSMALLINT)(i + 1),sql_c_type, buf, result->longreadlen + 1, &result->values[i].vallen); - - if (rc == SQL_ERROR) { - odbc_sql_error(result->conn_ptr, result->stmt, "SQLGetData"); - efree(buf); - RETURN_FALSE; - } - if (rc == SQL_SUCCESS_WITH_INFO) { - ZVAL_STRINGL(&tmp, buf, result->longreadlen); - } else if (rc != SQL_SUCCESS) { - php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (retcode %u)", i + 1, rc); - ZVAL_FALSE(&tmp); - } else if (result->values[i].vallen == SQL_NULL_DATA) { - ZVAL_NULL(&tmp); - break; - } else if (result->values[i].vallen == SQL_NO_TOTAL) { - php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1); - ZVAL_FALSE(&tmp); - } else { - ZVAL_STRINGL(&tmp, buf, result->values[i].vallen); - } - break; - - default: - if (result->values[i].vallen == SQL_NULL_DATA) { - ZVAL_NULL(&tmp); - break; - } else if (result->values[i].vallen == SQL_NO_TOTAL) { - php_error_docref(NULL, E_WARNING, "Cannot get data of column #%d (driver cannot determine length)", i + 1); - ZVAL_FALSE(&tmp); - break; - } - ZVAL_STRINGL(&tmp, result->values[i].value, result->values[i].vallen); - break; - } - zend_hash_index_update(Z_ARRVAL_P(pv_res_arr), i, &tmp); - } - if (buf) efree(buf); - RETURN_LONG(result->numcols); + php_odbc_fetch(INTERNAL_FUNCTION_PARAM_PASSTHRU, false, ODBC_NUM); } /* }}} */ /* {{{ Fetch a row */ PHP_FUNCTION(odbc_fetch_row) { - odbc_result *result; - RETCODE rc; - zval *pv_res; - zend_long pv_row = 0; - bool pv_row_is_null = true; - SQLULEN crow; - SQLUSMALLINT RowStatus[1]; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|l!", &pv_res, odbc_result_ce, &pv_row, &pv_row_is_null) == FAILURE) { - RETURN_THROWS(); - } - - result = Z_ODBC_RESULT_P(pv_res); - CHECK_ODBC_RESULT(result); - - if (!pv_row_is_null && pv_row < 1) { - php_error_docref(NULL, E_WARNING, "Argument #3 ($row) must be greater than or equal to 1"); - RETURN_FALSE; - } - - if (result->numcols == 0) { - php_error_docref(NULL, E_WARNING, "No tuples available at this result index"); - RETURN_FALSE; - } - - if (result->fetch_abs) { - if (!pv_row_is_null) { - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_ABSOLUTE,(SQLLEN)pv_row,&crow,RowStatus); - } else { - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus); - } - } else { - rc = SQLFetch(result->stmt); - } - - if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { - if (rc == SQL_ERROR) { - odbc_sql_error(result->conn_ptr, result->stmt, "SQLExtendedFetch"); - } - RETURN_FALSE; - } - - if (!pv_row_is_null) { - result->fetched = (SQLLEN)pv_row; - } else { - result->fetched++; - } - - RETURN_TRUE; + php_odbc_fetch(INTERNAL_FUNCTION_PARAM_PASSTHRU, false, ODBC_NONE); } /* }}} */ @@ -1648,8 +1534,6 @@ PHP_FUNCTION(odbc_result) RETCODE rc; SQLLEN fieldsize; zval *pv_res; - SQLULEN crow; - SQLUSMALLINT RowStatus[1]; ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_OBJECT_OF_CLASS(pv_res, odbc_result_ce) @@ -1700,14 +1584,15 @@ PHP_FUNCTION(odbc_result) if (result->fetched == 0) { /* User forgot to call odbc_fetch_row(), or wants to reload the results, do it now */ - if (result->fetch_abs) - rc = SQLExtendedFetch(result->stmt, SQL_FETCH_NEXT, 1, &crow,RowStatus); - else + if (result->fetch_abs) { + rc = SQLFetchScroll(result->stmt, SQL_FETCH_NEXT, 1); + } else { rc = SQLFetch(result->stmt); + } if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { if (rc == SQL_ERROR) { - odbc_sql_error(result->conn_ptr, result->stmt, "SQLExtendedFetch"); + odbc_sql_error(result->conn_ptr, result->stmt, "SQLFetchScroll"); } RETURN_FALSE; } @@ -1850,8 +1735,6 @@ PHP_FUNCTION(odbc_result_all) char *pv_format = NULL; size_t i, pv_format_len = 0; SQLSMALLINT sql_c_type; - SQLULEN crow; - SQLUSMALLINT RowStatus[1]; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s", &pv_res, odbc_result_ce, &pv_format, &pv_format_len) == FAILURE) { RETURN_THROWS(); @@ -1864,10 +1747,11 @@ PHP_FUNCTION(odbc_result_all) php_error_docref(NULL, E_WARNING, "No tuples available at this result index"); RETURN_FALSE; } - if (result->fetch_abs) - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus); - else + if (result->fetch_abs) { + rc = SQLFetchScroll(result->stmt, SQL_FETCH_NEXT, 1); + } else { rc = SQLFetch(result->stmt); + } if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { php_printf("

No rows found

\n"); @@ -1962,10 +1846,11 @@ PHP_FUNCTION(odbc_result_all) } php_printf("\n"); - if (result->fetch_abs) - rc = SQLExtendedFetch(result->stmt,SQL_FETCH_NEXT,1,&crow,RowStatus); - else + if (result->fetch_abs) { + rc = SQLFetchScroll(result->stmt, SQL_FETCH_NEXT, 1); + } else { rc = SQLFetch(result->stmt); + } } php_printf("\n"); if (buf) efree(buf); @@ -2520,7 +2405,7 @@ PHP_FUNCTION(odbc_autocommit) { RETCODE rc; zval *pv_conn; - bool pv_onoff = 0; + bool pv_onoff = false; bool pv_onoff_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|b!", &pv_conn, odbc_connection_ce, &pv_onoff, &pv_onoff_is_null) == FAILURE) { diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 84acae980ce3a..7acb14b778f8d 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -89,7 +89,6 @@ typedef int gid_t; #ifndef ZEND_WIN32 # include # include -# include # include # include #endif @@ -664,8 +663,7 @@ static void accel_copy_permanent_strings(zend_new_interned_string_func_t new_int if (Z_FUNC(p->val)->common.function_name) { Z_FUNC(p->val)->common.function_name = new_interned_string(Z_FUNC(p->val)->common.function_name); } - if (Z_FUNC(p->val)->common.arg_info && - (Z_FUNC(p->val)->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS))) { + if (Z_FUNC(p->val)->common.arg_info) { uint32_t i; uint32_t num_args = Z_FUNC(p->val)->common.num_args + 1; zend_arg_info *arg_info = Z_FUNC(p->val)->common.arg_info - 1; @@ -674,6 +672,12 @@ static void accel_copy_permanent_strings(zend_new_interned_string_func_t new_int num_args++; } for (i = 0 ; i < num_args; i++) { + if (i > 0) { + arg_info[i].name = new_interned_string(arg_info[i].name); + if (arg_info[i].default_value) { + arg_info[i].default_value = new_interned_string(arg_info[i].default_value); + } + } accel_copy_permanent_list_types(new_interned_string, arg_info[i].type); } } @@ -715,6 +719,24 @@ static void accel_copy_permanent_strings(zend_new_interned_string_func_t new_int if (Z_FUNC(q->val)->common.function_name) { Z_FUNC(q->val)->common.function_name = new_interned_string(Z_FUNC(q->val)->common.function_name); } + if (Z_FUNC(q->val)->common.scope == ce) { + uint32_t i; + uint32_t num_args = Z_FUNC(q->val)->common.num_args + 1; + zend_arg_info *arg_info = Z_FUNC(q->val)->common.arg_info - 1; + + if (Z_FUNC(q->val)->common.fn_flags & ZEND_ACC_VARIADIC) { + num_args++; + } + for (i = 0 ; i < num_args; i++) { + if (i > 0) { + arg_info[i].name = new_interned_string(arg_info[i].name); + if (arg_info[i].default_value) { + arg_info[i].default_value = new_interned_string(arg_info[i].default_value); + } + } + accel_copy_permanent_list_types(new_interned_string, arg_info[i].type); + } + } } ZEND_HASH_FOREACH_END(); ZEND_HASH_MAP_FOREACH_BUCKET(&ce->constants_table, q) { @@ -4367,12 +4389,14 @@ static void preload_fix_trait_op_array(zend_op_array *op_array) zend_string *function_name = op_array->function_name; zend_class_entry *scope = op_array->scope; uint32_t fn_flags = op_array->fn_flags; + uint32_t fn_flags2 = op_array->fn_flags2; zend_function *prototype = op_array->prototype; HashTable *ht = op_array->static_variables; *op_array = *orig_op_array; op_array->function_name = function_name; op_array->scope = scope; op_array->fn_flags = fn_flags; + op_array->fn_flags2 = fn_flags2; op_array->prototype = prototype; op_array->static_variables = ht; } @@ -5088,13 +5112,45 @@ static zend_result accel_finish_startup(void) exit(ret == SUCCESS ? 0 : 1); } else { /* parent */ - int status; +# ifdef HAVE_SIGPROCMASK + /* Interrupting the waitpid() call below with a signal would cause the + * process to exit. This is fine when the signal disposition is set to + * terminate the process, but not otherwise. + * When running the apache2handler, preloading is performed in the + * control process. SIGUSR1 and SIGHUP are used to tell the control + * process to restart children. Exiting when these signals are received + * would unexpectedly shutdown the server instead of restarting it. + * Block the USR1 and HUP signals from being delivered during the + * syscall when running the apache2handler SAPI, as these are not + * supposed to terminate the process. See GH-20051. */ + bool is_apache2handler = strcmp(sapi_module.name, "apache2handler") == 0; + sigset_t set, oldset; + if (is_apache2handler) { + if (sigemptyset(&set) + || sigaddset(&set, SIGUSR1) + || sigaddset(&set, SIGHUP)) { + ZEND_UNREACHABLE(); + } + if (sigprocmask(SIG_BLOCK, &set, &oldset)) { + ZEND_UNREACHABLE(); + } + } +# endif + int status; if (waitpid(pid, &status, 0) < 0) { zend_shared_alloc_unlock(); zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Preloading failed to waitpid(%d)", pid); } +# ifdef HAVE_SIGPROCMASK + if (is_apache2handler) { + if (sigprocmask(SIG_SETMASK, &oldset, NULL)) { + ZEND_UNREACHABLE(); + } + } +# endif + if (ZCSG(preload_script)) { preload_load(zend_map_ptr_static_last); } diff --git a/ext/opcache/jit/ir/ir.c b/ext/opcache/jit/ir/ir.c index 81621ce11bd36..745a66b2163ae 100644 --- a/ext/opcache/jit/ir/ir.c +++ b/ext/opcache/jit/ir/ir.c @@ -118,7 +118,7 @@ void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted { char buf[128]; - if (insn->op == IR_FUNC || insn->op == IR_SYM) { + if (insn->op == IR_FUNC || insn->op == IR_SYM || insn->op == IR_LABEL) { fprintf(f, "%s", ir_get_str(ctx, insn->val.name)); return; } else if (insn->op == IR_STR) { @@ -290,6 +290,7 @@ void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted #define ir_op_kind_prb IR_OPND_PROB #define ir_op_kind_opt IR_OPND_PROB #define ir_op_kind_pro IR_OPND_PROTO +#define ir_op_kind_lbl IR_OPND_LABEL_REF #define _IR_OP_FLAGS(name, flags, op1, op2, op3) \ IR_OP_FLAGS(ir_op_flag_ ## flags, ir_op_kind_ ## op1, ir_op_kind_ ## op2, ir_op_kind_ ## op3), @@ -689,6 +690,13 @@ ir_ref ir_const_str(ir_ctx *ctx, ir_ref str) return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_STR, IR_ADDR, 0)); } +ir_ref ir_const_label(ir_ctx *ctx, ir_ref str) +{ + ir_val val; + val.u64 = str; + return ir_const_ex(ctx, val, IR_ADDR, IR_OPTX(IR_LABEL, IR_ADDR, 0)); +} + ir_ref ir_str(ir_ctx *ctx, const char *s) { size_t len; @@ -879,6 +887,17 @@ static ir_ref _ir_fold_cse(ir_ctx *ctx, uint32_t opt, ir_ref op1, ir_ref op2, ir return IR_UNUSED; } +IR_ALWAYS_INLINE ir_ref _ir_fold_cast(ir_ctx *ctx, ir_ref ref, ir_type type) +{ + if (ctx->ir_base[ref].type == type) { + return ref; + } else if (IR_IS_CONST_REF(ref) && !IR_IS_SYM_CONST(ctx->ir_base[ref].op)) { + return ir_const(ctx, ctx->ir_base[ref].val, type); + } else { + return ir_emit1(ctx, IR_OPT(IR_BITCAST, type), ref); + } +} + #define IR_FOLD(X) IR_FOLD1(X, __LINE__) #define IR_FOLD1(X, Y) IR_FOLD2(X, Y) #define IR_FOLD2(X, Y) case IR_RULE_ ## Y: @@ -1158,7 +1177,7 @@ ir_ref ir_bind(ir_ctx *ctx, ir_ref var, ir_ref def) IR_ASSERT(var < 0); if (!ir_hashtab_add(ctx->binding, def, var)) { /* Add a copy with different binding */ - def = ir_emit2(ctx, IR_OPT(IR_COPY, ctx->ir_base[def].type), def, 1); + def = ir_emit2(ctx, IR_OPT(IR_COPY, ctx->ir_base[def].type), def, IR_COPY_HARD); ir_hashtab_add(ctx->binding, def, var); } return def; @@ -1836,8 +1855,49 @@ int ir_mem_flush(void *ptr, size_t size) return 1; } #else + +#if defined(__linux__) && defined(__x86_64__) && defined(PKEY_DISABLE_WRITE) +# define HAVE_PKEY_MPROTECT 1 +#endif + +#ifdef HAVE_PKEY_MPROTECT + +#ifndef PKEY_DISABLE_EXECUTE +# define PKEY_DISABLE_EXECUTE 0 +#endif + +int pkey_mprotect(void* addr, size_t len, int prot, int pkey) __attribute__((weak)); +int pkey_alloc(unsigned int, unsigned int) __attribute__((weak)); +int pkey_free(int) __attribute__((weak)); +int pkey_set(int, unsigned) __attribute__((weak)); + +static int ir_pkey = 0; +#endif + void *ir_mem_mmap(size_t size) { +#ifdef HAVE_PKEY_MPROTECT + if (!ir_pkey && pkey_mprotect) { + int key = pkey_alloc(0, PKEY_DISABLE_WRITE); + if (key > 0) { + ir_pkey = key; + } + } + if (ir_pkey > 0) { + void *ret = mmap(NULL, size, PROT_EXEC|PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (ret == MAP_FAILED) { + return NULL; + } + if (pkey_mprotect(ret, size, PROT_EXEC|PROT_READ|PROT_WRITE, ir_pkey) != 0) { +#ifdef IR_DEBUG + fprintf(stderr, "pkey_mprotect() failed\n"); +#endif + munmap(ret, size); + return NULL; + } + return ret; + } +#endif int prot_flags = PROT_EXEC; #if defined(__NetBSD__) prot_flags |= PROT_MPROTECT(PROT_READ|PROT_WRITE); @@ -1852,11 +1912,28 @@ void *ir_mem_mmap(size_t size) int ir_mem_unmap(void *ptr, size_t size) { munmap(ptr, size); +#ifdef HAVE_PKEY_MPROTECT +// if (ir_pkey > 0) { +// pkey_free(ir_pkey); +// ir_pkey = 0; +// } +#endif return 1; } int ir_mem_protect(void *ptr, size_t size) { +#ifdef HAVE_PKEY_MPROTECT + if (ir_pkey > 0) { + if (pkey_set(ir_pkey, PKEY_DISABLE_WRITE)) { +#ifdef IR_DEBUG + fprintf(stderr, "mprotect() failed\n"); +#endif + return 0; + } + return 1; + } +#endif if (mprotect(ptr, size, PROT_READ | PROT_EXEC) != 0) { #ifdef IR_DEBUG fprintf(stderr, "mprotect() failed\n"); @@ -1868,6 +1945,17 @@ int ir_mem_protect(void *ptr, size_t size) int ir_mem_unprotect(void *ptr, size_t size) { +#ifdef HAVE_PKEY_MPROTECT + if (ir_pkey > 0) { + if (pkey_set(ir_pkey, PKEY_DISABLE_EXECUTE)) { +#ifdef IR_DEBUG + fprintf(stderr, "mprotect() failed\n"); +#endif + return 0; + } + return 1; + } +#endif if (mprotect(ptr, size, PROT_READ | PROT_WRITE) != 0) { #ifdef IR_DEBUG fprintf(stderr, "mprotect() failed\n"); @@ -2070,7 +2158,26 @@ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_load_i(ir_ctx *ctx, ir_ref ref, ir_type } } else if (insn->op == IR_RSTORE) { modified_regset |= (1 << insn->op3); - } else if (insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN || insn->op == IR_CALL || insn->op == IR_VSTORE) { + } else if (insn->op == IR_CALL) { + ir_insn *func = &ctx->ir_base[insn->op2]; + ir_ref func_proto; + const ir_proto_t *proto; + + if (func->op == IR_FUNC || func->op == IR_FUNC_ADDR) { + func_proto = func->proto; + } else if (func->op == IR_PROTO) { + func_proto = func->op2; + } else { + break; + } + if (!func_proto) { + break; + } + proto = (const ir_proto_t *)ir_get_str(ctx, func_proto); + if (!(proto->flags & (IR_CONST_FUNC|IR_PURE_FUNC))) { + break; + } + } else if (insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN || insn->op == IR_VSTORE) { return IR_UNUSED; } ref = insn->op1; @@ -2116,7 +2223,26 @@ IR_ALWAYS_INLINE ir_ref ir_find_aliasing_vload_i(ir_ctx *ctx, ir_ref ref, ir_typ break; } } - } else if (insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN || insn->op == IR_CALL || insn->op == IR_STORE) { + } else if (insn->op == IR_CALL) { + ir_insn *func = &ctx->ir_base[insn->op2]; + ir_ref func_proto; + const ir_proto_t *proto; + + if (func->op == IR_FUNC || func->op == IR_FUNC_ADDR) { + func_proto = func->proto; + } else if (func->op == IR_PROTO) { + func_proto = func->op2; + } else { + break; + } + if (!func_proto) { + break; + } + proto = (const ir_proto_t *)ir_get_str(ctx, func_proto); + if (!(proto->flags & (IR_CONST_FUNC|IR_PURE_FUNC))) { + break; + } + } else if (insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN || insn->op == IR_STORE) { break; } ref = insn->op1; @@ -3013,6 +3139,16 @@ void _ir_IJMP(ir_ctx *ctx, ir_ref addr) ctx->control = IR_UNUSED; } +ir_ref _ir_IGOTO(ir_ctx *ctx, ir_ref addr) +{ + ir_ref ref; + + IR_ASSERT(ctx->control); + ctx->control = ref = ir_emit2(ctx, IR_IGOTO, ctx->control, addr); + ctx->control = IR_UNUSED; + return ref; +} + ir_ref _ir_ADD_OFFSET(ir_ctx *ctx, ir_ref addr, uintptr_t offset) { if (offset) { @@ -3135,6 +3271,18 @@ void _ir_VSTORE(ir_ctx *ctx, ir_ref var, ir_ref val) ctx->control = ir_emit3(ctx, IR_VSTORE, ctx->control, var, val); } +ir_ref _ir_VLOAD_v(ir_ctx *ctx, ir_type type, ir_ref var) +{ + IR_ASSERT(ctx->control); + return ctx->control = ir_emit2(ctx, IR_OPT(IR_VLOAD_v, type), ctx->control, var); +} + +void _ir_VSTORE_v(ir_ctx *ctx, ir_ref var, ir_ref val) +{ + IR_ASSERT(ctx->control); + ctx->control = ir_emit3(ctx, IR_VSTORE_v, ctx->control, var, val); +} + ir_ref _ir_TLS(ir_ctx *ctx, ir_ref index, ir_ref offset) { IR_ASSERT(ctx->control); @@ -3193,6 +3341,18 @@ void _ir_STORE(ir_ctx *ctx, ir_ref addr, ir_ref val) ctx->control = ir_emit3(ctx, IR_STORE, ctx->control, addr, val); } +ir_ref _ir_LOAD_v(ir_ctx *ctx, ir_type type, ir_ref addr) +{ + IR_ASSERT(ctx->control); + return ctx->control = ir_emit2(ctx, IR_OPT(IR_LOAD_v, type), ctx->control, addr); +} + +void _ir_STORE_v(ir_ctx *ctx, ir_ref addr, ir_ref val) +{ + IR_ASSERT(ctx->control); + ctx->control = ir_emit3(ctx, IR_STORE_v, ctx->control, addr, val); +} + void _ir_VA_START(ir_ctx *ctx, ir_ref list) { IR_ASSERT(ctx->control); @@ -3217,11 +3377,13 @@ ir_ref _ir_VA_ARG(ir_ctx *ctx, ir_type type, ir_ref list) return ctx->control = ir_emit2(ctx, IR_OPT(IR_VA_ARG, type), ctx->control, list); } -ir_ref _ir_VA_ARG_EX(ir_ctx *ctx, ir_type type, ir_ref list, size_t size) +ir_ref _ir_VA_ARG_EX(ir_ctx *ctx, ir_type type, ir_ref list, size_t size, size_t align) { IR_ASSERT(ctx->control); - IR_ASSERT(size <= 0x7fffffff); - return ctx->control = ir_emit3(ctx, IR_OPT(IR_VA_ARG, type), ctx->control, list, (ir_ref)size); + IR_ASSERT(size <= 0x0fffffff); + IR_ASSERT(align != 0 && ((align & (align - 1)) == 0) && align <= 128); + return ctx->control = ir_emit3(ctx, IR_OPT(IR_VA_ARG, type), ctx->control, list, + (ir_ref)IR_VA_ARG_OP3(size, align)); } ir_ref _ir_BLOCK_BEGIN(ir_ctx *ctx) diff --git a/ext/opcache/jit/ir/ir.h b/ext/opcache/jit/ir/ir.h index 8fcfbffa7d6bc..a96650597055a 100644 --- a/ext/opcache/jit/ir/ir.h +++ b/ext/opcache/jit/ir/ir.h @@ -216,6 +216,7 @@ typedef enum _ir_type { * prb - branch probability 1-99 (0 - unspecified): (IF_TRUE, IF_FALSE, CASE_VAL, CASE_DEFAULT) * opt - optional number * pro - function prototype + * lbl - label used as value (a reference to constant): (BEGIN) * * The order of IR opcodes is carefully selected for efficient folding. * - foldable instruction go first @@ -322,6 +323,7 @@ typedef enum _ir_type { _(FUNC_ADDR, r0, ___, ___, ___) /* constant func ref */ \ _(FUNC, r0, ___, ___, ___) /* constant func ref */ \ _(SYM, r0, ___, ___, ___) /* constant symbol ref */ \ + _(LABEL, r0, ___, ___, ___) /* label address ref */ \ _(STR, r0, ___, ___, ___) /* constant str ref */ \ \ /* call ops */ \ @@ -334,11 +336,15 @@ typedef enum _ir_type { _(BLOCK_BEGIN, a1, src, ___, ___) /* stacksave */ \ _(BLOCK_END, a2, src, def, ___) /* stackrestore */ \ _(VLOAD, l2, src, var, ___) /* load value of local var */ \ + _(VLOAD_v, l2, src, var, ___) /* volatile variant of VLOAD */ \ _(VSTORE, s3, src, var, def) /* store value to local var */ \ + _(VSTORE_v, s3, src, var, def) /* volatile variant of VSTORE */ \ _(RLOAD, l1X2, src, num, opt) /* load value from register */ \ _(RSTORE, s2X1, src, def, num) /* store value into register */ \ _(LOAD, l2, src, ref, ___) /* load from memory */ \ + _(LOAD_v, l2, src, ref, ___) /* volatile variant of VLOAD */ \ _(STORE, s3, src, ref, def) /* store to memory */ \ + _(STORE_v, s3, src, ref, def) /* volatile variant of VSTORE */ \ _(TLS, l1X2, src, num, num) /* thread local variable */ \ _(TRAP, x1, src, ___, ___) /* DebugBreak */ \ /* memory reference ops (A, H, U, S, TMP, STR, NEW, X, V) ??? */ \ @@ -360,7 +366,7 @@ typedef enum _ir_type { /* control-flow nodes */ \ _(START, S0X1, ret, ___, ___) /* function start */ \ _(ENTRY, S1X1, src, num, ___) /* entry with a fake src edge */ \ - _(BEGIN, S1, src, ___, ___) /* block start */ \ + _(BEGIN, S1X1, src, lbl, ___) /* block start, optional &&lbl */ \ _(IF_TRUE, S1X1, src, prb, ___) /* IF TRUE proj. */ \ _(IF_FALSE, S1X1, src, prb, ___) /* IF FALSE proj. */ \ _(CASE_VAL, S2X1, src, def, prb) /* switch proj. */ \ @@ -372,8 +378,9 @@ typedef enum _ir_type { _(LOOP_END, E1, src, ___, ___) /* loop end */ \ _(IF, E2, src, def, ___) /* conditional control split */ \ _(SWITCH, E2, src, def, ___) /* multi-way control split */ \ + _(IGOTO, E2, src, def, ___) /* computed goto (internal) */ \ + _(IJMP, T2X1, src, def, ret) /* computed goto (terminating) */ \ _(RETURN, T2X1, src, def, ret) /* function return */ \ - _(IJMP, T2X1, src, def, ret) /* computed goto */ \ _(UNREACHABLE, T1X2, src, ___, ret) /* unreachable (tailcall, etc) */ \ \ /* deoptimization helper */ \ @@ -400,6 +407,13 @@ typedef enum _ir_op { #define IR_OPTX(op, type, n) ((uint32_t)(op) | ((uint32_t)(type) << IR_OPT_TYPE_SHIFT) | ((uint32_t)(n) << IR_OPT_INPUTS_SHIFT)) #define IR_OPT_TYPE(opt) (((opt) & IR_OPT_TYPE_MASK) >> IR_OPT_TYPE_SHIFT) +/* "opt" modifiers */ +#define IR_COPY_HARD (1<<0) + +#define IR_VA_ARG_SIZE(op3) (((uint32_t)(op3) >> 3)) +#define IR_VA_ARG_ALIGN(op3) (1U << ((uint32_t)(op3) & 0x7)) +#define IR_VA_ARG_OP3(s, a) (((s) << 3) | ir_ntzl(a)) + /* IR References */ typedef int32_t ir_ref; @@ -533,6 +547,9 @@ void ir_strtab_free(ir_strtab *strtab); #define IR_EXTERN (1<<5) #define IR_CONST (1<<6) +#define IR_CONST_FUNC (1<<6) +#define IR_PURE_FUNC (1<<7) + #define IR_INITIALIZED (1<<7) /* sym data flag: constant or an initialized variable */ #define IR_CONST_STRING (1<<8) /* sym data flag: constant string */ @@ -648,7 +665,6 @@ struct _ir_ctx { ir_ref vars; /* list of VARs (used by register allocator) */ }; ir_snapshot_create_t snapshot_create; - int32_t stack_frame_alignment; int32_t stack_frame_size; /* spill stack frame size (used by register allocator and code generator) */ int32_t call_stack_size; /* stack for parameter passing (used by register allocator and code generator) */ uint64_t used_preserved_regs; @@ -698,6 +714,7 @@ ir_ref ir_const_func_addr(ir_ctx *ctx, uintptr_t c, ir_ref proto); ir_ref ir_const_func(ir_ctx *ctx, ir_ref str, ir_ref proto); ir_ref ir_const_sym(ir_ctx *ctx, ir_ref str); ir_ref ir_const_str(ir_ctx *ctx, ir_ref str); +ir_ref ir_const_label(ir_ctx *ctx, ir_ref str); ir_ref ir_unique_const_addr(ir_ctx *ctx, uintptr_t c); @@ -893,6 +910,7 @@ struct _ir_loader { void*(*resolve_sym_name) (ir_loader *loader, const char *name, uint32_t flags); bool (*has_sym) (ir_loader *loader, const char *name); bool (*add_sym) (ir_loader *loader, const char *name, void *addr); + bool (*add_label) (ir_loader *loader, const char *name, void *addr); }; void ir_loader_init(void); diff --git a/ext/opcache/jit/ir/ir_aarch64.dasc b/ext/opcache/jit/ir/ir_aarch64.dasc index 12c3694d469f0..b553243309f54 100644 --- a/ext/opcache/jit/ir/ir_aarch64.dasc +++ b/ext/opcache/jit/ir/ir_aarch64.dasc @@ -218,6 +218,7 @@ typedef struct _ir_backend_data { dasm_State *dasm_state; ir_bitset emit_constants; int rodata_label, jmp_table_label; + bool resolved_label_syms; } ir_backend_data; #define IR_GP_REG_NAME(code, name64, name32) \ @@ -315,6 +316,7 @@ const char *ir_reg_name(int8_t reg, ir_type type) _(RETURN_VOID) \ _(RETURN_INT) \ _(RETURN_FP) \ + _(IGOTO_DUP) \ #define IR_RULE_ENUM(name) IR_ ## name, @@ -385,7 +387,7 @@ int ir_get_target_constraints(ir_ctx *ctx, ir_ref ref, ir_target_constraints *co n++; break; } - } else if (ir_rule(ctx, insn->op2) == IR_STATIC_ALLOCA) { + } else if (!IR_IS_CONST_REF(insn->op2) && ir_rule(ctx, insn->op2) == IR_STATIC_ALLOCA) { constraints->tmp_regs[n] = IR_TMP_REG(2, IR_ADDR, IR_LOAD_SUB_REF, IR_DEF_SUB_REF); n++; } @@ -478,10 +480,16 @@ int ir_get_target_constraints(ir_ctx *ctx, ir_ref ref, ir_target_constraints *co if (IR_IS_CONST_REF(insn->op1)) { constraints->tmp_regs[n] = IR_TMP_REG(1, insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF); n++; + } else if (ir_rule(ctx, insn->op1) == IR_STATIC_ALLOCA) { + constraints->tmp_regs[n] = IR_TMP_REG(1, insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF); + n++; } if (IR_IS_CONST_REF(insn->op2) && insn->op1 != insn->op2) { constraints->tmp_regs[n] = IR_TMP_REG(2, insn->type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF); n++; + } else 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++; } break; case IR_CMP_INT: @@ -520,6 +528,7 @@ int ir_get_target_constraints(ir_ctx *ctx, ir_ref ref, ir_target_constraints *co } break; case IR_VSTORE: + case IR_VSTORE_v: insn = &ctx->ir_base[ref]; if (IR_IS_CONST_REF(insn->op3)) { insn = &ctx->ir_base[insn->op3]; @@ -596,6 +605,19 @@ int ir_get_target_constraints(ir_ctx *ctx, ir_ref ref, ir_target_constraints *co } flags = IR_USE_SHOULD_BE_IN_REG | IR_OP2_MUST_BE_IN_REG | IR_OP3_SHOULD_BE_IN_REG; break; + case IR_IGOTO: + insn = &ctx->ir_base[ref]; + if (ctx->ir_base[insn->op1].op == IR_MERGE || ctx->ir_base[insn->op1].op == IR_LOOP_BEGIN) { + ir_insn *merge = &ctx->ir_base[insn->op1]; + ir_ref *p, n = merge->inputs_count; + + for (p = merge->ops + 1; n > 0; p++, n--) { + ir_ref input = *p; + IR_ASSERT(ctx->ir_base[input].op == IR_END || ctx->ir_base[input].op == IR_LOOP_END); + ctx->rules[input] = IR_IGOTO_DUP; + } + } + return insn->op; case IR_COND: insn = &ctx->ir_base[ref]; n = 0; @@ -665,7 +687,7 @@ int ir_get_target_constraints(ir_ctx *ctx, ir_ref ref, ir_target_constraints *co } break; case IR_VA_ARG: - flags = IR_USE_MUST_BE_IN_REG | IR_OP2_MUST_BE_IN_REG; + flags = IR_USE_MUST_BE_IN_REG | IR_OP2_MUST_BE_IN_REG | IR_DEF_CONFLICTS_WITH_INPUT_REGS; constraints->tmp_regs[0] = IR_TMP_REG(3, IR_ADDR, IR_LOAD_SUB_REF, IR_SAVE_SUB_REF); n = 1; insn = &ctx->ir_base[ref]; @@ -714,7 +736,8 @@ static void ir_match_fuse_addr(ir_ctx *ctx, ir_ref addr_ref, ir_type type) do { ir_insn *insn = &ctx->ir_base[*p]; - if (insn->op != IR_LOAD && (insn->op != IR_STORE || insn->op3 == addr_ref)) { + if (insn->op != IR_LOAD && insn->op != IR_LOAD_v + && ((insn->op != IR_STORE && insn->op != IR_STORE_v) || insn->op3 == addr_ref)) { return; } p++; @@ -961,7 +984,7 @@ binop_fp: ctx->flags2 |= IR_HAS_CALLS; return IR_CALL; case IR_VAR: - return IR_SKIPPED | IR_VAR; + return IR_STATIC_ALLOCA; case IR_PARAM: return ctx->use_lists[ref].count > 0 ? IR_PARAM : IR_SKIPPED | IR_PARAM; case IR_ALLOCA: @@ -978,6 +1001,7 @@ binop_fp: } return IR_ALLOCA; case IR_LOAD: + case IR_LOAD_v: ir_match_fuse_addr(ctx, insn->op2, insn->type); if (IR_IS_TYPE_INT(insn->type)) { return IR_LOAD_INT; @@ -986,6 +1010,7 @@ binop_fp: } break; case IR_STORE: + case IR_STORE_v: ir_match_fuse_addr(ctx, insn->op2, ctx->ir_base[insn->op3].type); if (IR_IS_TYPE_INT(ctx->ir_base[insn->op3].type)) { return IR_STORE_INT; @@ -1364,7 +1389,7 @@ static void ir_emit_load_imm_fp(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref sr } else if (type == IR_DOUBLE && insn->val.u64 == 0) { | fmov Rd(reg-IR_REG_FP_FIRST), xzr } else { - label = ir_const_label(ctx, src); + label = ir_get_const_label(ctx, src); if (type == IR_DOUBLE) { | ldr Rd(reg-IR_REG_FP_FIRST), =>label } else { @@ -1441,10 +1466,41 @@ static void ir_load_local_addr(ir_ctx *ctx, ir_reg reg, ir_ref src) | add Rx(reg), Rx(base), #offset } else { ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); - | add Rx(reg), sp, Rx(IR_REG_INT_TMP) + | add Rx(reg), Rx(base), Rx(IR_REG_INT_TMP) } } +static void ir_resolve_label_syms(ir_ctx *ctx) +{ + uint32_t b; + ir_block *bb; + + for (b = 1, bb = &ctx->cfg_blocks[b]; b <= ctx->cfg_blocks_count; bb++, b++) { + ir_insn *insn = &ctx->ir_base[bb->start]; + + if (insn->op == IR_BEGIN && insn->op2) { + IR_ASSERT(ctx->ir_base[insn->op2].op == IR_LABEL); + ctx->ir_base[insn->op2].val.u32_hi = b; + } + } +} + +static void ir_emit_load_label_addr(ir_ctx *ctx, ir_reg reg, ir_insn *label) +{ + ir_backend_data *data = ctx->data; + dasm_State **Dst = &data->dasm_state; + + if (!data->resolved_label_syms) { + data->resolved_label_syms = 1; + ir_resolve_label_syms(ctx); + } + + IR_ASSERT(label->op == IR_LABEL); + int b = label->val.u32_hi; + + b = ir_skip_empty_target_blocks(ctx, b); + | adr Rx(reg), =>b +} static void ir_emit_load(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref src) { @@ -1459,9 +1515,11 @@ static void ir_emit_load(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref src) } else if (insn->op == IR_STR) { ir_backend_data *data = ctx->data; dasm_State **Dst = &data->dasm_state; - int label = ir_const_label(ctx, src); + int label = ir_get_const_label(ctx, src); | adr Rx(reg), =>label + } else if (insn->op == IR_LABEL) { + ir_emit_load_label_addr(ctx, reg, insn); } else { ir_emit_load_imm_int(ctx, type, reg, insn->val.i64); } @@ -1697,6 +1755,7 @@ static void ir_emit_prologue(ir_ctx *ctx) | str Rd(i-IR_REG_FP_FIRST), [Rx(fp), #offset] } else { ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + offset -= sizeof(void*); | str Rx(prev), [Rx(fp), Rx(IR_REG_INT_TMP)] | sub Rx(IR_REG_INT_TMP), Rx(IR_REG_INT_TMP), #8 | str Rd(i-IR_REG_FP_FIRST), [Rx(fp), Rx(IR_REG_INT_TMP)] @@ -1795,7 +1854,12 @@ static void ir_emit_prologue(ir_ctx *ctx) offset += 16 * ctx->fp_reg_params; for (i = ctx->fp_reg_params; i < IR_REG_FP_ARGS; i++) { // TODO: Rd->Rq stur->str ??? - | str Rd(fp_reg_params[i]-IR_REG_FP_FIRST), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, 8)) { + | str Rd(fp_reg_params[i]-IR_REG_FP_FIRST), [Rx(fp), #offset] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | str Rd(fp_reg_params[i]-IR_REG_FP_FIRST), [Rx(fp), Rx(IR_REG_INT_TMP)] + } offset += 16; } } @@ -1828,26 +1892,44 @@ static void ir_emit_epilogue(ir_ctx *ctx) offset -= sizeof(void*) * 2; if (aarch64_may_encode_imm7_addr_offset(offset, 8)) { | ldp Rx(prev), Rx(i), [Rx(fp), #offset] - } else { - IR_ASSERT(aarch64_may_encode_addr_offset(offset, 8)); + } else if (aarch64_may_encode_addr_offset(offset + 8, 8)) { | ldr Rx(prev), [Rx(fp), #offset] | ldr Rx(i), [Rx(fp), #(offset+8)] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | ldr Rx(prev), [Rx(fp), Rx(IR_REG_INT_TMP)] + | add Rx(IR_REG_INT_TMP), Rx(IR_REG_INT_TMP), #8 + | ldr Rx(i), [Rx(fp), Rx(IR_REG_INT_TMP)] } prev = IR_REG_NONE; } else { if (prev < IR_REG_FP_FIRST) { offset -= sizeof(void*); - | ldr Rx(prev), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, 8)) { + | ldr Rx(prev), [Rx(fp), #offset] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | ldr Rx(prev), [Rx(fp), Rx(IR_REG_INT_TMP)] + } offset -= sizeof(void*); - | ldr Rd(i-IR_REG_FP_FIRST), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, 8)) { + | ldr Rd(i-IR_REG_FP_FIRST), [Rx(fp), #offset] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | ldr Rd(i-IR_REG_FP_FIRST), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } else { offset -= sizeof(void*) * 2; if (aarch64_may_encode_imm7_addr_offset(offset, 8)) { | ldp Rd(prev-IR_REG_FP_FIRST), Rd(i-IR_REG_FP_FIRST), [Rx(fp), #offset] - } else { - IR_ASSERT(aarch64_may_encode_addr_offset(offset, 8)); + } else if (aarch64_may_encode_addr_offset(offset + 8, 8)) { | ldr Rd(prev-IR_REG_FP_FIRST), [Rx(fp), #offset] | ldr Rd(i-IR_REG_FP_FIRST), [Rx(fp), #(offset+8)] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | ldr Rx(prev-IR_REG_FP_FIRST), [Rx(fp), Rx(IR_REG_INT_TMP)] + | add Rx(IR_REG_INT_TMP), Rx(IR_REG_INT_TMP), #8 + | ldr Rx(i-IR_REG_FP_FIRST), [Rx(fp), Rx(IR_REG_INT_TMP)] } } prev = IR_REG_NONE; @@ -1857,10 +1939,20 @@ static void ir_emit_epilogue(ir_ctx *ctx) if (prev != IR_REG_NONE) { if (prev < IR_REG_FP_FIRST) { offset -= sizeof(void*); - | ldr Rx(prev), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, 8)) { + | ldr Rx(prev), [Rx(fp), #offset] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | ldr Rx(prev), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } else { offset -= sizeof(void*); - | ldr Rd(prev-IR_REG_FP_FIRST), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, 8)) { + | ldr Rd(prev-IR_REG_FP_FIRST), [Rx(fp), #offset] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | ldr Rd(prev-IR_REG_FP_FIRST), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } } } @@ -1909,6 +2001,9 @@ static void ir_emit_binop_int(ir_ctx *ctx, ir_ref def, ir_insn *insn) op1_reg = IR_REG_NUM(op1_reg); ir_emit_load(ctx, type, op1_reg, op1); } + if (op2_reg == IR_REG_NONE && op1 == op2) { + op2_reg = op1_reg; + } if (op2_reg != IR_REG_NONE) { if (IR_REG_SPILLED(op2_reg)) { op2_reg = IR_REG_NUM(op2_reg); @@ -3415,25 +3510,52 @@ static void ir_emit_sext(ir_ctx *ctx, ir_ref def, ir_insn *insn) int32_t offset = ir_ref_spill_slot_offset(ctx, insn->op1, &fp); if (ir_type_size[src_type] == 1) { - if (ir_type_size[dst_type] == 2) { - | ldrsb Rw(def_reg), [Rx(fp), #offset] - } else if (ir_type_size[dst_type] == 4) { - | ldrsb Rw(def_reg), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, ir_type_size[src_type])) { + if (ir_type_size[dst_type] == 2) { + | ldrsb Rw(def_reg), [Rx(fp), #offset] + } else if (ir_type_size[dst_type] == 4) { + | ldrsb Rw(def_reg), [Rx(fp), #offset] + } else { + IR_ASSERT(ir_type_size[dst_type] == 8); + | ldrsb Rx(def_reg), [Rx(fp), #offset] + } } else { - IR_ASSERT(ir_type_size[dst_type] == 8); - | ldrsb Rx(def_reg), [Rx(fp), #offset] + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + if (ir_type_size[dst_type] == 2) { + | ldrsb Rw(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } else if (ir_type_size[dst_type] == 4) { + | ldrsb Rw(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } else { + IR_ASSERT(ir_type_size[dst_type] == 8); + | ldrsb Rx(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } } else if (ir_type_size[src_type] == 2) { - if (ir_type_size[dst_type] == 4) { - | ldrsh Rw(def_reg), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, ir_type_size[src_type])) { + if (ir_type_size[dst_type] == 4) { + | ldrsh Rw(def_reg), [Rx(fp), #offset] + } else { + IR_ASSERT(ir_type_size[dst_type] == 8); + | ldrsh Rx(def_reg), [Rx(fp), #offset] + } } else { - IR_ASSERT(ir_type_size[dst_type] == 8); - | ldrsh Rx(def_reg), [Rx(fp), #offset] + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + if (ir_type_size[dst_type] == 4) { + | ldrsh Rw(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } else { + IR_ASSERT(ir_type_size[dst_type] == 8); + | ldrsh Rx(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } } else { IR_ASSERT(ir_type_size[src_type] == 4); IR_ASSERT(ir_type_size[dst_type] == 8); - | ldrsw Rx(def_reg), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, ir_type_size[src_type])) { + | ldrsw Rx(def_reg), [Rx(fp), #offset] + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | ldrsw Rx(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } } if (IR_REG_SPILLED(ctx->regs[def][0])) { @@ -3473,14 +3595,27 @@ static void ir_emit_zext(ir_ctx *ctx, ir_ref def, ir_insn *insn) ir_reg fp; int32_t offset = ir_ref_spill_slot_offset(ctx, insn->op1, &fp); - if (ir_type_size[src_type] == 1) { - | ldrb Rw(def_reg), [Rx(fp), #offset] - } else if (ir_type_size[src_type] == 2) { - | ldrh Rw(def_reg), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, ir_type_size[src_type])) { + if (ir_type_size[src_type] == 1) { + | ldrb Rw(def_reg), [Rx(fp), #offset] + } else if (ir_type_size[src_type] == 2) { + | ldrh Rw(def_reg), [Rx(fp), #offset] + } else { + IR_ASSERT(ir_type_size[src_type] == 4); + IR_ASSERT(ir_type_size[dst_type] == 8); + | ldr Rw(def_reg), [Rx(fp), #offset] + } } else { - IR_ASSERT(ir_type_size[src_type] == 4); - IR_ASSERT(ir_type_size[dst_type] == 8); - | ldr Rw(def_reg), [Rx(fp), #offset] + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + if (ir_type_size[src_type] == 1) { + | ldrb Rw(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } else if (ir_type_size[src_type] == 2) { + | ldrh Rw(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } else { + IR_ASSERT(ir_type_size[src_type] == 4); + IR_ASSERT(ir_type_size[dst_type] == 8); + | ldr Rw(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } } if (IR_REG_SPILLED(ctx->regs[def][0])) { @@ -3579,11 +3714,21 @@ static void ir_emit_bitcast(ir_ctx *ctx, ir_ref def, ir_insn *insn) ir_reg fp; int32_t offset = ir_ref_spill_slot_offset(ctx, insn->op1, &fp); - if (src_type == IR_DOUBLE) { - | ldr Rx(def_reg), [Rx(fp), #offset] + if (aarch64_may_encode_addr_offset(offset, ir_type_size[src_type])) { + if (src_type == IR_DOUBLE) { + | ldr Rx(def_reg), [Rx(fp), #offset] + } else { + IR_ASSERT(src_type == IR_FLOAT); + | ldr Rw(def_reg), [Rx(fp), #offset] + } } else { - IR_ASSERT(src_type == IR_FLOAT); - | ldr Rw(def_reg), [Rx(fp), #offset] + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + if (src_type == IR_DOUBLE) { + | ldr Rx(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } else { + IR_ASSERT(src_type == IR_FLOAT); + | ldr Rw(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } } } } else if (IR_IS_TYPE_FP(dst_type)) { @@ -3605,12 +3750,22 @@ static void ir_emit_bitcast(ir_ctx *ctx, ir_ref def, ir_insn *insn) ir_reg fp; int32_t offset = ir_ref_spill_slot_offset(ctx, insn->op1, &fp); - if (dst_type == IR_DOUBLE) { - | ldr Rd(def_reg), [Rx(fp), #offset] - } else { - IR_ASSERT(src_type == IR_FLOAT); - | ldr Rs(def_reg), [Rx(fp), #offset] - } + if (aarch64_may_encode_addr_offset(offset, ir_type_size[src_type])) { + if (dst_type == IR_DOUBLE) { + | ldr Rd(def_reg), [Rx(fp), #offset] + } else { + IR_ASSERT(dst_type == IR_FLOAT); + | ldr Rs(def_reg), [Rx(fp), #offset] + } + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + if (dst_type == IR_DOUBLE) { + | ldr Rd(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } else { + IR_ASSERT(dst_type == IR_FLOAT); + | ldr Rs(def_reg), [Rx(fp), Rx(IR_REG_INT_TMP)] + } + } } } if (IR_REG_SPILLED(ctx->regs[def][0])) { @@ -3833,7 +3988,12 @@ static void ir_emit_vaddr(ir_ctx *ctx, ir_ref def, ir_insn *insn) IR_ASSERT(def_reg != IR_REG_NONE); offset = ir_var_spill_slot(ctx, insn->op1, &fp); - | add Rx(def_reg), Rx(fp), #offset + if (aarch64_may_encode_imm12(offset)) { + | add Rx(def_reg), Rx(fp), #offset + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, offset); + | add Rx(def_reg), Rx(fp), Rx(IR_REG_INT_TMP) + } if (IR_REG_SPILLED(ctx->regs[def][0])) { ir_emit_store(ctx, type, def, def_reg); } @@ -4221,7 +4381,12 @@ static void ir_emit_afree(ir_ctx *ctx, ir_ref def, ir_insn *insn) /* Stack must be 16 byte aligned */ size = IR_ALIGNED_SIZE(size, 16); - | add sp, sp, #size + if (aarch64_may_encode_imm12(size)) { + | add sp, sp, #size + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, size); + | add sp, sp, Rx(IR_REG_INT_TMP) + } if (!(ctx->flags & IR_USE_FRAME_POINTER)) { ctx->call_stack_size -= size; } @@ -4283,8 +4448,11 @@ static void ir_emit_frame_addr(ir_ctx *ctx, ir_ref def) if (ctx->flags & IR_USE_FRAME_POINTER) { | mov Rx(def_reg), Rx(IR_REG_X29) - } else { + } else if (aarch64_may_encode_imm12(ctx->stack_frame_size + ctx->call_stack_size)) { | add Rx(def_reg), Rx(IR_REG_X31), #(ctx->stack_frame_size + ctx->call_stack_size) + } else { + ir_emit_load_imm_int(ctx, IR_ADDR, IR_REG_INT_TMP, ctx->stack_frame_size + ctx->call_stack_size); + | add Rx(def_reg), Rx(IR_REG_X31), Rx(IR_REG_INT_TMP) } if (IR_REG_SPILLED(ctx->regs[def][0])) { ir_emit_store(ctx, IR_ADDR, def, def_reg); @@ -4377,7 +4545,7 @@ static void ir_emit_va_start(ir_ctx *ctx, ir_ref def, ir_insn *insn) if ((ctx->flags2 & (IR_HAS_VA_ARG_FP|IR_HAS_VA_COPY)) && ctx->fp_reg_params < IR_REG_FP_ARGS) { reg_save_area_offset += 16 * IR_REG_FP_ARGS; /* Set va_list.vr_top */ - if (overflow_arg_area_offset != reg_save_area_offset) { + if (overflow_arg_area_offset != reg_save_area_offset || ctx->gp_reg_params < IR_REG_INT_ARGS) { | add Rx(tmp_reg), Rx(fp), #reg_save_area_offset } | str Rx(tmp_reg), [Rx(op2_reg), #(offset+offsetof(ir_va_list, vr_top))] @@ -5246,6 +5414,19 @@ static void ir_emit_ijmp(ir_ctx *ctx, ir_ref def, ir_insn *insn) } | br Rx(op2_reg) } else if (IR_IS_CONST_REF(insn->op2)) { + if (ctx->ir_base[insn->op2].op == IR_LABEL) { + if (!data->resolved_label_syms) { + data->resolved_label_syms = 1; + ir_resolve_label_syms(ctx); + } + + uint32_t target = ctx->ir_base[insn->op2].val.u32_hi; + target = ir_skip_empty_target_blocks(ctx, target); + + | b =>target + return; + } + void *addr = ir_jmp_addr(ctx, insn, &ctx->ir_base[insn->op2]); if (aarch64_may_use_b(ctx->code_buffer, addr)) { @@ -5636,6 +5817,7 @@ static void ir_emit_param_move(ir_ctx *ctx, uint8_t type, ir_reg from_reg, ir_re { ir_reg fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER; + offset = IR_SPILL_POS_TO_OFFSET(offset); IR_ASSERT(from_reg != IR_REG_NONE || to_reg != IR_REG_NONE); if (IR_IS_TYPE_INT(type)) { @@ -5676,13 +5858,8 @@ static void ir_emit_load_params(ir_ctx *ctx) const int8_t *int_reg_params = _ir_int_reg_params; const int8_t *fp_reg_params = _ir_fp_reg_params; int32_t stack_offset = 0; + int32_t stack_start = ctx->stack_frame_size; - if (ctx->flags & IR_USE_FRAME_POINTER) { - /* skip old frame pointer and return address */ - stack_offset = sizeof(void*) * 2 + ctx->stack_frame_size + ctx->call_stack_size; - } else { - stack_offset = ctx->stack_frame_size + ctx->call_stack_size; - } n = use_list->count; for (i = 0, p = &ctx->use_edges[use_list->refs]; i < n; i++, p++) { use = *p; @@ -5706,12 +5883,9 @@ static void ir_emit_load_params(ir_ctx *ctx) if (ctx->vregs[use]) { dst_reg = IR_REG_NUM(ctx->regs[use][0]); IR_ASSERT(src_reg != IR_REG_NONE || dst_reg != IR_REG_NONE || - stack_offset == ctx->live_intervals[ctx->vregs[use]]->stack_spill_pos + - ((ctx->flags & IR_USE_FRAME_POINTER) ? - -(ctx->stack_frame_size - ctx->stack_frame_alignment) : - ctx->call_stack_size)); + stack_start + stack_offset == ctx->live_intervals[ctx->vregs[use]]->stack_spill_pos); if (src_reg != dst_reg) { - ir_emit_param_move(ctx, insn->type, src_reg, dst_reg, use, stack_offset); + ir_emit_param_move(ctx, insn->type, src_reg, dst_reg, use, stack_start + stack_offset); } if (dst_reg != IR_REG_NONE && IR_REG_SPILLED(ctx->regs[use][0])) { ir_emit_store(ctx, insn->type, use, dst_reg); @@ -5785,14 +5959,8 @@ static void ir_fix_param_spills(ir_ctx *ctx) const int8_t *int_reg_params = _ir_int_reg_params; const int8_t *fp_reg_params = _ir_fp_reg_params; int32_t stack_offset = 0; - int32_t param_stack_size = 0; + int32_t stack_start = ctx->stack_frame_size; - if (ctx->flags & IR_USE_FRAME_POINTER) { - /* skip old frame pointer and return address */ - stack_offset = sizeof(void*) * 2 + (ctx->stack_frame_size - ctx->stack_frame_alignment); - } else { - stack_offset = ctx->stack_frame_size; - } n = use_list->count; for (i = 0, p = &ctx->use_edges[use_list->refs]; i < n; i++, p++) { use = *p; @@ -5819,15 +5987,13 @@ static void ir_fix_param_spills(ir_ctx *ctx) if ((ival->flags & IR_LIVE_INTERVAL_MEM_PARAM) && ival->stack_spill_pos == -1 && (ival->next || ival->reg == IR_REG_NONE)) { - ival->stack_spill_pos = stack_offset; + ival->stack_spill_pos = stack_start + stack_offset; } } if (sizeof(void*) == 8) { stack_offset += sizeof(void*); - param_stack_size += sizeof(void*); } else { stack_offset += IR_MAX(sizeof(void*), ir_type_size[insn->type]); - param_stack_size += IR_MAX(sizeof(void*), ir_type_size[insn->type]); } } } @@ -5835,7 +6001,7 @@ static void ir_fix_param_spills(ir_ctx *ctx) ctx->gp_reg_params = IR_MIN(int_param_num, int_reg_params_count); ctx->fp_reg_params = IR_MIN(fp_param_num, fp_reg_params_count); - ctx->param_stack_size = param_stack_size; + ctx->param_stack_size = stack_offset; } static void ir_allocate_unique_spill_slots(ir_ctx *ctx) @@ -5876,6 +6042,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) case IR_MERGE: case IR_LOOP_BEGIN: case IR_LOOP_END: + case IR_IGOTO_DUP: break; default: def_flags = ir_get_target_constraints(ctx, i, &constraints); @@ -5892,7 +6059,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) IR_REGSET_EXCL(available, reg); ctx->regs[i][0] = reg | IR_REG_SPILL_STORE; } else if (def_flags & IR_USE_MUST_BE_IN_REG) { - if (insn->op == IR_VLOAD + if ((insn->op == IR_VLOAD || insn->op == IR_VLOAD_v) && ctx->live_intervals[ctx->vregs[i]] && ctx->live_intervals[ctx->vregs[i]]->stack_spill_pos != -1 && ir_is_same_mem_var(ctx, i, ctx->ir_base[insn->op2].op3)) { @@ -5932,7 +6099,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) for (i = 0, p = &ctx->use_edges[use_list->refs]; i < n; i++, p++) { use = *p; use_insn = &ctx->ir_base[use]; - if (use_insn->op == IR_VLOAD) { + if (use_insn->op == IR_VLOAD || use_insn->op == IR_VLOAD_v) { if (ctx->vregs[use] && !ctx->live_intervals[ctx->vregs[use]]) { ir_live_interval *ival = ir_arena_alloc(&ctx->arena, sizeof(ir_live_interval)); @@ -5943,7 +6110,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) ival->vreg = ctx->vregs[use]; ival->stack_spill_pos = stack_spill_pos; } - } else if (use_insn->op == IR_VSTORE) { + } else if (use_insn->op == IR_VSTORE || use_insn->op == IR_STORE_v) { if (!IR_IS_CONST_REF(use_insn->op3) && ctx->vregs[use_insn->op3] && !ctx->live_intervals[ctx->vregs[use_insn->op3]]) { @@ -6080,25 +6247,21 @@ void ir_fix_stack_frame(ir_ctx *ctx) ctx->stack_frame_size = IR_ALIGNED_SIZE(ctx->stack_frame_size, sizeof(void*)); ctx->stack_frame_size += additional_size; - ctx->stack_frame_alignment = 0; ctx->call_stack_size = 0; if (!(ctx->flags & IR_FUNCTION)) { while (IR_ALIGNED_SIZE(ctx->stack_frame_size, 16) != ctx->stack_frame_size) { ctx->stack_frame_size += sizeof(void*); - ctx->stack_frame_alignment += sizeof(void*); } } else { /* Stack must be 16 byte aligned */ if (!(ctx->flags & IR_FUNCTION)) { while (IR_ALIGNED_SIZE(ctx->stack_frame_size, 16) != ctx->stack_frame_size) { ctx->stack_frame_size += sizeof(void*); - ctx->stack_frame_alignment += sizeof(void*); } } else if (ctx->flags & IR_USE_FRAME_POINTER) { while (IR_ALIGNED_SIZE(ctx->stack_frame_size + sizeof(void*) * 2, 16) != ctx->stack_frame_size + sizeof(void*) * 2) { ctx->stack_frame_size += sizeof(void*); - ctx->stack_frame_alignment += sizeof(void*); } } else { if (!(ctx->flags & IR_NO_STACK_COMBINE)) { @@ -6107,7 +6270,6 @@ void ir_fix_stack_frame(ir_ctx *ctx) while (IR_ALIGNED_SIZE(ctx->stack_frame_size + ctx->call_stack_size, 16) != ctx->stack_frame_size + ctx->call_stack_size) { ctx->stack_frame_size += sizeof(void*); - ctx->stack_frame_alignment += sizeof(void*); } } } @@ -6143,6 +6305,8 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) int ret; void *entry; size_t size; + ir_ref igoto_dup_ref = IR_UNUSED; + uint32_t igoto_dup_block = 0; data.ra_data.unused_slot_4 = 0; data.ra_data.unused_slot_2 = 0; @@ -6150,11 +6314,11 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) data.ra_data.handled = NULL; data.rodata_label = 0; data.jmp_table_label = 0; + data.resolved_label_syms = 0; ctx->data = &data; if (!ctx->live_intervals) { ctx->stack_frame_size = 0; - ctx->stack_frame_alignment = 0; ctx->call_stack_size = 0; ctx->used_preserved_regs = 0; ir_allocate_unique_spill_slots(ctx); @@ -6176,7 +6340,6 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) } ctx->stack_frame_size = ctx->fixed_stack_frame_size; ctx->call_stack_size = ctx->fixed_call_stack_size; - ctx->stack_frame_alignment = 0; } Dst = &data.dasm_state; @@ -6386,6 +6549,35 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) case IR_TAILCALL: ir_emit_tailcall(ctx, i, insn); break; + case IR_IGOTO_DUP: + if (bb->flags & IR_BB_DESSA_MOVES) { + ir_emit_dessa_moves(ctx, b, bb); + } + IR_ASSERT(!igoto_dup_ref && !igoto_dup_block); + igoto_dup_ref = i; + igoto_dup_block = b; + b = ctx->cfg_edges[bb->successors]; + bb = &ctx->cfg_blocks[b]; + i = bb->start; + insn = &ctx->ir_base[i]; + rule = &ctx->rules[i]; + break; + case IR_IGOTO: + if ((ctx->ir_base[insn->op1].op == IR_MERGE || ctx->ir_base[insn->op1].op == IR_LOOP_BEGIN) + && (ctx->rules[ctx->ir_base[insn->op1].op1] & IR_RULE_MASK) == IR_IGOTO_DUP + && igoto_dup_ref) { + ir_emit_ijmp(ctx, i, insn); + b = igoto_dup_block; + bb = &ctx->cfg_blocks[b]; + i = igoto_dup_ref; + insn = &ctx->ir_base[i]; + rule = &ctx->rules[i]; + igoto_dup_block= 0; + igoto_dup_ref = 0; + break; + } + IR_ASSERT(!igoto_dup_ref && !igoto_dup_block); + IR_FALLTHROUGH; case IR_IJMP: ir_emit_ijmp(ctx, i, insn); break; @@ -6396,9 +6588,11 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) ir_emit_vaddr(ctx, i, insn); break; case IR_VLOAD: + case IR_VLOAD_v: ir_emit_vload(ctx, i, insn); break; case IR_VSTORE: + case IR_VSTORE_v: ir_emit_vstore(ctx, i, insn); break; case IR_RLOAD: @@ -6645,6 +6839,28 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) } while (i != 0); } + if ((ctx->flags2 & IR_HAS_BLOCK_ADDR) && ctx->loader && ctx->loader->add_label) { + for (b = 1, bb = &ctx->cfg_blocks[b]; b <= ctx->cfg_blocks_count; bb++, b++) { + ir_insn *insn = &ctx->ir_base[bb->start]; + + if (insn->op == IR_BEGIN && insn->op2) { + IR_ASSERT(ctx->ir_base[insn->op2].op == IR_LABEL); + ctx->ir_base[insn->op2].val.u32_hi = 0; + ctx->loader->add_label(ctx->loader, ir_get_str(ctx, ctx->ir_base[insn->op2].val.str), + (char*)entry + dasm_getpclabel(&data.dasm_state, ir_skip_empty_target_blocks(ctx, b))); + } + } + } else if (data.resolved_label_syms) { + for (b = 1, bb = &ctx->cfg_blocks[b]; b <= ctx->cfg_blocks_count; bb++, b++) { + ir_insn *insn = &ctx->ir_base[bb->start]; + + if (insn->op == IR_BEGIN && insn->op2) { + IR_ASSERT(ctx->ir_base[insn->op2].op == IR_LABEL); + ctx->ir_base[insn->op2].val.u32_hi = 0; + } + } + } + dasm_free(&data.dasm_state); if (ctx->code_buffer) { diff --git a/ext/opcache/jit/ir/ir_builder.h b/ext/opcache/jit/ir/ir_builder.h index c1dcffdbaa084..03add75906553 100644 --- a/ext/opcache/jit/ir/ir_builder.h +++ b/ext/opcache/jit/ir/ir_builder.h @@ -490,7 +490,7 @@ extern "C" { #define ir_ADD_OFFSET(_addr, _offset) _ir_ADD_OFFSET(_ir_CTX, (_addr), (_offset)) /* Unfoldable variant of COPY */ -#define ir_HARD_COPY(_type, _op1) ir_emit2(_ir_CTX, IR_OPT(IR_COPY, (_type)), (_op1), 1) +#define ir_HARD_COPY(_type, _op1) ir_emit2(_ir_CTX, IR_OPT(IR_COPY, (_type)), (_op1), IR_COPY_HARD) #define ir_HARD_COPY_B(_op1) ir_HARD_COPY(IR_BOOL, _op1) #define ir_HARD_COPY_U8(_op1) ir_HARD_COPY(IR_U8, _op1) #define ir_HARD_COPY_U16(_op1) ir_HARD_COPY(IR_U16, _op1) @@ -544,6 +544,8 @@ extern "C" { #define ir_VLOAD_D(_var) _ir_VLOAD(_ir_CTX, IR_DOUBLE, (_var)) #define ir_VLOAD_F(_var) _ir_VLOAD(_ir_CTX, IR_FLOAT, (_var)) #define ir_VSTORE(_var, _val) _ir_VSTORE(_ir_CTX, (_var), (_val)) +#define ir_VLOAD_v(_type, _var) _ir_VLOAD_v(_ir_CTX, (_type), (_var)) +#define ir_VSTORE_v(_var, _val) _ir_VSTORE_v(_ir_CTX, (_var), (_val)) #define ir_RLOAD(_type, _reg) _ir_RLOAD(_ir_CTX, (_type), (_reg)) #define ir_RLOAD_B(_reg) _ir_RLOAD(_ir_CTX, IR_BOOL, (_reg)) #define ir_RLOAD_U8(_reg) _ir_RLOAD(_ir_CTX, IR_U8, (_reg)) @@ -574,6 +576,8 @@ extern "C" { #define ir_LOAD_D(_addr) _ir_LOAD(_ir_CTX, IR_DOUBLE, (_addr)) #define ir_LOAD_F(_addr) _ir_LOAD(_ir_CTX, IR_FLOAT, (_addr)) #define ir_STORE(_addr, _val) _ir_STORE(_ir_CTX, (_addr), (_val)) +#define ir_LOAD_v(_type, _addr) _ir_LOAD_v(_ir_CTX, (_type), (_addr)) +#define ir_STORE_v(_addr, _val) _ir_STORE_v(_ir_CTX, (_addr), (_val)) #define ir_TLS(_index, _offset) _ir_TLS(_ir_CTX, (_index), (_offset)) #define ir_TRAP() do {_ir_CTX->control = ir_emit1(_ir_CTX, IR_TRAP, _ir_CTX->control);} while (0) @@ -586,7 +590,7 @@ extern "C" { #define ir_VA_END(_list) _ir_VA_END(_ir_CTX, _list) #define ir_VA_COPY(_dst, _src) _ir_VA_COPY(_ir_CTX, _dst, _src) #define ir_VA_ARG(_list, _type) _ir_VA_ARG(_ir_CTX, _type, _list) -#define ir_VA_ARG_EX(_list, _type, size) _ir_VA_ARG_EX(_ir_CTX, _type, _list, size) +#define ir_VA_ARG_EX(_list, _type, s, a) _ir_VA_ARG_EX(_ir_CTX, _type, _list, s, a) #define ir_START() _ir_START(_ir_CTX) #define ir_ENTRY(_src, _num) _ir_ENTRY(_ir_CTX, (_src), (_num)) @@ -607,6 +611,7 @@ extern "C" { #define ir_CASE_RANGE(_switch, _v1, _v2) _ir_CASE_RANGE(_ir_CTX, (_switch), (_v1), (_v2)) #define ir_CASE_DEFAULT(_switch) _ir_CASE_DEFAULT(_ir_CTX, (_switch)) #define ir_RETURN(_val) _ir_RETURN(_ir_CTX, (_val)) +#define ir_IGOTO(_addr) _ir_IGOTO(_ir_CTX, (_addr)) #define ir_IJMP(_addr) _ir_IJMP(_ir_CTX, (_addr)) #define ir_UNREACHABLE() _ir_UNREACHABLE(_ir_CTX) @@ -654,15 +659,19 @@ ir_ref _ir_ALLOCA(ir_ctx *ctx, ir_ref size); void _ir_AFREE(ir_ctx *ctx, ir_ref size); 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 _ir_VLOAD_v(ir_ctx *ctx, ir_type type, ir_ref var); +void _ir_VSTORE_v(ir_ctx *ctx, ir_ref var, ir_ref val); ir_ref _ir_RLOAD(ir_ctx *ctx, ir_type type, ir_ref reg); void _ir_RSTORE(ir_ctx *ctx, ir_ref reg, ir_ref val); ir_ref _ir_LOAD(ir_ctx *ctx, ir_type type, ir_ref addr); void _ir_STORE(ir_ctx *ctx, ir_ref addr, ir_ref val); +ir_ref _ir_LOAD_v(ir_ctx *ctx, ir_type type, ir_ref addr); +void _ir_STORE_v(ir_ctx *ctx, ir_ref addr, ir_ref val); void _ir_VA_START(ir_ctx *ctx, ir_ref list); void _ir_VA_END(ir_ctx *ctx, ir_ref list); void _ir_VA_COPY(ir_ctx *ctx, ir_ref dst, ir_ref src); ir_ref _ir_VA_ARG(ir_ctx *ctx, ir_type type, ir_ref list); -ir_ref _ir_VA_ARG_EX(ir_ctx *ctx, ir_type type, ir_ref list, size_t size); +ir_ref _ir_VA_ARG_EX(ir_ctx *ctx, ir_type type, ir_ref list, size_t size, size_t align); void _ir_START(ir_ctx *ctx); void _ir_ENTRY(ir_ctx *ctx, ir_ref src, ir_ref num); void _ir_BEGIN(ir_ctx *ctx, ir_ref src); @@ -688,6 +697,7 @@ void _ir_CASE_VAL(ir_ctx *ctx, ir_ref switch_ref, ir_ref val); void _ir_CASE_RANGE(ir_ctx *ctx, ir_ref switch_ref, ir_ref v1, ir_ref v2); void _ir_CASE_DEFAULT(ir_ctx *ctx, ir_ref switch_ref); void _ir_RETURN(ir_ctx *ctx, ir_ref val); +ir_ref _ir_IGOTO(ir_ctx *ctx, ir_ref addr); void _ir_IJMP(ir_ctx *ctx, ir_ref addr); void _ir_GUARD(ir_ctx *ctx, ir_ref condition, ir_ref addr); void _ir_GUARD_NOT(ir_ctx *ctx, ir_ref condition, ir_ref addr); diff --git a/ext/opcache/jit/ir/ir_cfg.c b/ext/opcache/jit/ir/ir_cfg.c index 00923387bb21c..46755067b2444 100644 --- a/ext/opcache/jit/ir/ir_cfg.c +++ b/ext/opcache/jit/ir/ir_cfg.c @@ -820,11 +820,14 @@ int ir_build_dominators_tree(ir_ctx *ctx) succ_b = ctx->cfg_edges[bb->successors]; if (bb->successors_count != 1) { /* LOOP_END/END may be linked with the following ENTRY by a fake edge */ - IR_ASSERT(bb->successors_count == 2); - if (blocks[succ_b].flags & IR_BB_ENTRY) { + if (bb->successors_count != 2) { + complete = 0; + break; + } else if (blocks[succ_b].flags & IR_BB_ENTRY) { succ_b = ctx->cfg_edges[bb->successors + 1]; - } else { - IR_ASSERT(blocks[ctx->cfg_edges[bb->successors + 1]].flags & IR_BB_ENTRY); + } else if (!(blocks[ctx->cfg_edges[bb->successors + 1]].flags & IR_BB_ENTRY)) { + complete = 0; + break; } } dom_depth = blocks[succ_b].dom_depth;; diff --git a/ext/opcache/jit/ir/ir_check.c b/ext/opcache/jit/ir/ir_check.c index c25a984aefc1d..ee951291b1b05 100644 --- a/ext/opcache/jit/ir/ir_check.c +++ b/ext/opcache/jit/ir/ir_check.c @@ -328,7 +328,9 @@ bool ir_check(const ir_ctx *ctx) } break; case IR_LOAD: + case IR_LOAD_v: case IR_STORE: + case IR_STORE_v: type = ctx->ir_base[insn->op2].type; if (type != IR_ADDR && (!IR_IS_TYPE_INT(type) || ir_type_size[type] != ir_type_size[IR_ADDR])) { @@ -338,7 +340,9 @@ bool ir_check(const ir_ctx *ctx) } break; case IR_VLOAD: + case IR_VLOAD_v: case IR_VSTORE: + case IR_VSTORE_v: if (ctx->ir_base[insn->op2].op != IR_VAR) { fprintf(stderr, "ir_base[%d].op2 must be 'VAR' (%s)\n", i, ir_op_name[ctx->ir_base[insn->op2].op]); @@ -408,6 +412,8 @@ bool ir_check(const ir_ctx *ctx) ok = 0; } break; + case IR_IGOTO: + break; default: /* skip data references */ count = n = use_list->count; diff --git a/ext/opcache/jit/ir/ir_dump.c b/ext/opcache/jit/ir/ir_dump.c index a501d261f30a7..5cc732927d412 100644 --- a/ext/opcache/jit/ir/ir_dump.c +++ b/ext/opcache/jit/ir/ir_dump.c @@ -129,6 +129,11 @@ void ir_dump_dot(const ir_ctx *ctx, const char *name, FILE *f) case IR_OPND_CONTROL_REF: fprintf(f, "\tn%d -> n%d [style=dashed,dir=back,weight=%d];\n", ref, i, REF_WEIGHT); break; + case IR_OPND_LABEL_REF: + if (ref) { + fprintf(f, "\tc%d -> n%d [color=blue,weight=%d];\n", -ref, i, REF_WEIGHT); + } + break; } } } @@ -491,6 +496,8 @@ void ir_dump_codegen(const ir_ctx *ctx, FILE *f) ir_print_proto(ctx, insn->proto, f); } else if (insn->op == IR_SYM) { fprintf(f, "sym(%s)", ir_get_str(ctx, insn->val.name)); + } else if (insn->op == IR_LABEL) { + fprintf(f, "label(%s)", ir_get_str(ctx, insn->val.name)); } else if (insn->op == IR_FUNC_ADDR) { fprintf(f, "func *"); ir_print_const(ctx, insn, f, true); @@ -648,6 +655,12 @@ void ir_dump_codegen(const ir_ctx *ctx, FILE *f) fprintf(f, "%s%d", first ? "(" : ", ", ref); first = 0; break; + case IR_OPND_LABEL_REF: + if (ref) { + IR_ASSERT(IR_IS_CONST_REF(ref)); + fprintf(f, "%sc_%d", first ? "(" : ", ", -ref); + } + break; } } else if (opnd_kind == IR_OPND_NUM) { fprintf(f, "%s%d", first ? "(" : ", ", ref); diff --git a/ext/opcache/jit/ir/ir_emit.c b/ext/opcache/jit/ir/ir_emit.c index 7a10da1322a72..847ca375b5bd0 100644 --- a/ext/opcache/jit/ir/ir_emit.c +++ b/ext/opcache/jit/ir/ir_emit.c @@ -244,32 +244,30 @@ static int ir_get_args_regs(const ir_ctx *ctx, const ir_insn *insn, int8_t *regs ir_insn *arg = &ctx->ir_base[ir_insn_op(insn, j)]; type = arg->type; if (IR_IS_TYPE_INT(type)) { - if (arg->op == IR_ARGVAL) { - continue; - } else if (int_param < int_reg_params_count) { + if (int_param < int_reg_params_count && arg->op != IR_ARGVAL) { regs[j] = int_reg_params[int_param]; count = j + 1; + int_param++; +#ifdef _WIN64 + /* WIN64 calling convention use common couter for int and fp registers */ + fp_param++; +#endif } else { regs[j] = IR_REG_NONE; } - int_param++; -#ifdef _WIN64 - /* WIN64 calling convention use common couter for int and fp registers */ - fp_param++; -#endif } else { IR_ASSERT(IR_IS_TYPE_FP(type)); if (fp_param < fp_reg_params_count) { regs[j] = fp_reg_params[fp_param]; count = j + 1; + fp_param++; +#ifdef _WIN64 + /* WIN64 calling convention use common couter for int and fp registers */ + int_param++; +#endif } else { regs[j] = IR_REG_NONE; } - fp_param++; -#ifdef _WIN64 - /* WIN64 calling convention use common couter for int and fp registers */ - int_param++; -#endif } } return count; @@ -426,7 +424,7 @@ typedef struct _ir_common_backend_data { ir_bitset emit_constants; } ir_common_backend_data; -static int ir_const_label(ir_ctx *ctx, ir_ref ref) +static int ir_get_const_label(ir_ctx *ctx, ir_ref ref) { ir_common_backend_data *data = ctx->data; int label = ctx->cfg_blocks_count - ref; @@ -1015,11 +1013,16 @@ int ir_match(ir_ctx *ctx) entries_count++; } ctx->rules[start] = IR_SKIPPED | IR_NOP; + if (ctx->ir_base[start].op == IR_BEGIN && ctx->ir_base[start].op2) { + ctx->flags2 |= IR_HAS_BLOCK_ADDR; + } ref = bb->end; if (bb->successors_count == 1) { insn = &ctx->ir_base[ref]; if (insn->op == IR_END || insn->op == IR_LOOP_END) { - ctx->rules[ref] = insn->op; + if (!ctx->rules[ref]) { + ctx->rules[ref] = insn->op; + } ref = prev_ref[ref]; if (ref == start && ctx->cfg_edges[bb->successors] != b) { if (EXPECTED(!(bb->flags & IR_BB_ENTRY))) { diff --git a/ext/opcache/jit/ir/ir_fold.h b/ext/opcache/jit/ir/ir_fold.h index 74f7818d747c4..bab6b2916075f 100644 --- a/ext/opcache/jit/ir/ir_fold.h +++ b/ext/opcache/jit/ir/ir_fold.h @@ -755,8 +755,35 @@ IR_FOLD(NEG(C_FLOAT)) } IR_FOLD(ABS(C_I8)) +{ + IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); + if (op1_insn->val.i64 >= 0) { + IR_FOLD_COPY(op1); + } else { + IR_FOLD_CONST_I(-op1_insn->val.i8); + } +} + IR_FOLD(ABS(C_I16)) +{ + IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); + if (op1_insn->val.i64 >= 0) { + IR_FOLD_COPY(op1); + } else { + IR_FOLD_CONST_I(-op1_insn->val.i16); + } +} + IR_FOLD(ABS(C_I32)) +{ + IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); + if (op1_insn->val.i64 >= 0) { + IR_FOLD_COPY(op1); + } else { + IR_FOLD_CONST_I((int32_t)-op1_insn->val.u32); + } +} + IR_FOLD(ABS(C_I64)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); @@ -847,7 +874,7 @@ IR_FOLD(MUL_OV(C_U64, C_U64)) uint64_t res; IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); res = op1_insn->val.u64 * op2_insn->val.u64; - if (op1_insn->val.u64 != 0 && res / op1_insn->val.u64 != op2_insn->val.u64 && res <= max) { + if ((op1_insn->val.u64 != 0 && res / op1_insn->val.u64 != op2_insn->val.u64) || res > max) { IR_FOLD_NEXT; } IR_FOLD_CONST_U(res); @@ -864,7 +891,7 @@ IR_FOLD(MUL_OV(C_I64, C_I64)) int64_t res; IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); res = op1_insn->val.u64 * op2_insn->val.u64; - if (op1_insn->val.i64 != 0 && res / op1_insn->val.i64 != op2_insn->val.i64 && res >= min && res <= max) { + if ((op1_insn->val.i64 != 0 && res / op1_insn->val.i64 != op2_insn->val.i64) || res < min || res > max) { IR_FOLD_NEXT; } IR_FOLD_CONST_U(res); @@ -1037,220 +1064,220 @@ IR_FOLD(SHL(C_U8, C_U8)) IR_FOLD(SHL(C_CHAR, C_CHAR)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u8 << op2_insn->val.u8); + IR_FOLD_CONST_U(op1_insn->val.u8 << (op2_insn->val.u8 & 0x7)); } IR_FOLD(SHL(C_I8, C_I8)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int8_t)(op1_insn->val.u8 << op2_insn->val.u8)); + IR_FOLD_CONST_I((int8_t)(op1_insn->val.u8 << (op2_insn->val.u8 & 0x7))); } IR_FOLD(SHL(C_U16, C_U16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u16 << op2_insn->val.u16); + IR_FOLD_CONST_U(op1_insn->val.u16 << (op2_insn->val.u16 & 0xf)); } IR_FOLD(SHL(C_I16, C_I16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int16_t)(op1_insn->val.u16 << op2_insn->val.u16)); + IR_FOLD_CONST_I((int16_t)(op1_insn->val.u16 << (op2_insn->val.u16 & 0xf))); } IR_FOLD(SHL(C_U32, C_U32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u32 << op2_insn->val.u32); + IR_FOLD_CONST_U(op1_insn->val.u32 << (op2_insn->val.u32 & 0x1f)); } IR_FOLD(SHL(C_I32, C_I32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int32_t)(op1_insn->val.u32 << op2_insn->val.u32)); + IR_FOLD_CONST_I((int32_t)(op1_insn->val.u32 << (op2_insn->val.u32 & 0x1f))); } IR_FOLD(SHL(C_U64, C_U64)) IR_FOLD(SHL(C_I64, C_I64)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u64 << op2_insn->val.u64); + IR_FOLD_CONST_U(op1_insn->val.u64 << (op2_insn->val.u64 & 0x3f)); } IR_FOLD(SHR(C_U8, C_U8)) IR_FOLD(SHR(C_CHAR, C_CHAR)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u8 >> op2_insn->val.u8); + IR_FOLD_CONST_U(op1_insn->val.u8 >> (op2_insn->val.u8 & 0x7)); } IR_FOLD(SHR(C_I8, C_I8)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int8_t)(op1_insn->val.u8 >> op2_insn->val.u8)); + IR_FOLD_CONST_I((int8_t)(op1_insn->val.u8 >> (op2_insn->val.u8 & 0x7))); } IR_FOLD(SHR(C_U16, C_U16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u16 >> op2_insn->val.u16); + IR_FOLD_CONST_U(op1_insn->val.u16 >> (op2_insn->val.u16 & 0xf)); } IR_FOLD(SHR(C_I16, C_I16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int16_t)(op1_insn->val.u16 >> op2_insn->val.u16)); + IR_FOLD_CONST_I((int16_t)(op1_insn->val.u16 >> (op2_insn->val.u16 & 0xf))); } IR_FOLD(SHR(C_U32, C_U32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u32 >> op2_insn->val.u32); + IR_FOLD_CONST_U(op1_insn->val.u32 >> (op2_insn->val.u32 & 0x1f)); } IR_FOLD(SHR(C_I32, C_I32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int32_t)(op1_insn->val.u32 >> op2_insn->val.u32)); + IR_FOLD_CONST_I((int32_t)(op1_insn->val.u32 >> (op2_insn->val.u32 & 0x1f))); } IR_FOLD(SHR(C_U64, C_U64)) IR_FOLD(SHR(C_I64, C_I64)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(op1_insn->val.u64 >> op2_insn->val.u64); + IR_FOLD_CONST_U(op1_insn->val.u64 >> (op2_insn->val.u64 & 0x3f)); } IR_FOLD(SAR(C_U8, C_U8)) IR_FOLD(SAR(C_CHAR, C_CHAR)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U((uint8_t)(op1_insn->val.i8 >> op2_insn->val.i8)); + IR_FOLD_CONST_U((uint8_t)(op1_insn->val.i8 >> (op2_insn->val.i8 & 0x7))); } IR_FOLD(SAR(C_I8, C_I8)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I(op1_insn->val.i8 >> op2_insn->val.i8); + IR_FOLD_CONST_I(op1_insn->val.i8 >> (op2_insn->val.i8 & 0x7)); } IR_FOLD(SAR(C_U16, C_U16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U((uint16_t)(op1_insn->val.i16 >> op2_insn->val.i16)); + IR_FOLD_CONST_U((uint16_t)(op1_insn->val.i16 >> (op2_insn->val.i16 & 0xf))); } IR_FOLD(SAR(C_I16, C_I16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I(op1_insn->val.i16 >> op2_insn->val.i16); + IR_FOLD_CONST_I(op1_insn->val.i16 >> (op2_insn->val.i16 & 0xf)); } IR_FOLD(SAR(C_U32, C_U32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U((uint32_t)(op1_insn->val.i32 >> op2_insn->val.i32)); + IR_FOLD_CONST_U((uint32_t)(op1_insn->val.i32 >> (op2_insn->val.i32 & 0x1f))); } IR_FOLD(SAR(C_I32, C_I32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I(op1_insn->val.i32 >> op2_insn->val.i32); + IR_FOLD_CONST_I(op1_insn->val.i32 >> (op2_insn->val.i32 & 0x1f)); } IR_FOLD(SAR(C_U64, C_U64)) IR_FOLD(SAR(C_I64, C_I64)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I(op1_insn->val.i64 >> op2_insn->val.i64); + IR_FOLD_CONST_I(op1_insn->val.i64 >> (op2_insn->val.i64 & 0x3f)); } IR_FOLD(ROL(C_U8, C_U8)) IR_FOLD(ROL(C_CHAR, C_CHAR)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_rol8(op1_insn->val.u8, op2_insn->val.u8)); + IR_FOLD_CONST_U(ir_rol8(op1_insn->val.u8, (op2_insn->val.u8 & 0x7))); } IR_FOLD(ROL(C_I8, C_I8)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int8_t)ir_rol8(op1_insn->val.u8, op2_insn->val.u8)); + IR_FOLD_CONST_I((int8_t)ir_rol8(op1_insn->val.u8, (op2_insn->val.u8 & 0x7))); } IR_FOLD(ROL(C_U16, C_U16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_rol16(op1_insn->val.u16, op2_insn->val.u16)); + IR_FOLD_CONST_U(ir_rol16(op1_insn->val.u16, (op2_insn->val.u16 & 0xf))); } IR_FOLD(ROL(C_I16, C_I16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int16_t)ir_rol16(op1_insn->val.u16, op2_insn->val.u16)); + IR_FOLD_CONST_I((int16_t)ir_rol16(op1_insn->val.u16, (op2_insn->val.u16 & 0xf))); } IR_FOLD(ROL(C_U32, C_U32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_rol32(op1_insn->val.u32, op2_insn->val.u32)); + IR_FOLD_CONST_U(ir_rol32(op1_insn->val.u32, (op2_insn->val.u32 & 0x1f))); } IR_FOLD(ROL(C_I32, C_I32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int32_t)ir_rol32(op1_insn->val.u32, op2_insn->val.u32)); + IR_FOLD_CONST_I((int32_t)ir_rol32(op1_insn->val.u32, (op2_insn->val.u32 & 0x1f))); } IR_FOLD(ROL(C_U64, C_U64)) IR_FOLD(ROL(C_I64, C_I64)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_rol64(op1_insn->val.u64, op2_insn->val.u64)); + IR_FOLD_CONST_U(ir_rol64(op1_insn->val.u64, (op2_insn->val.u64 & 0x3f))); } IR_FOLD(ROR(C_U8, C_U8)) IR_FOLD(ROR(C_CHAR, C_CHAR)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_ror8(op1_insn->val.u8, op2_insn->val.u8)); + IR_FOLD_CONST_U(ir_ror8(op1_insn->val.u8, (op2_insn->val.u8 & 0x7))); } IR_FOLD(ROR(C_I8, C_I8)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int8_t)ir_ror8(op1_insn->val.u8, op2_insn->val.u8)); + IR_FOLD_CONST_I((int8_t)ir_ror8(op1_insn->val.u8, (op2_insn->val.u8 & 0x7))); } IR_FOLD(ROR(C_U16, C_U16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_ror16(op1_insn->val.u16, op2_insn->val.u16)); + IR_FOLD_CONST_U(ir_ror16(op1_insn->val.u16, (op2_insn->val.u16 & 0xf))); } IR_FOLD(ROR(C_I16, C_I16)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int16_t)ir_ror16(op1_insn->val.u16, op2_insn->val.u16)); + IR_FOLD_CONST_I((int16_t)ir_ror16(op1_insn->val.u16, (op2_insn->val.u16 & 0xf))); } IR_FOLD(ROR(C_U32, C_U32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_ror32(op1_insn->val.u32, op2_insn->val.u32)); + IR_FOLD_CONST_U(ir_ror32(op1_insn->val.u32, (op2_insn->val.u32 & 0x1f))); } IR_FOLD(ROR(C_I32, C_I32)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_I((int32_t)ir_ror32(op1_insn->val.u32, op2_insn->val.u32)); + IR_FOLD_CONST_I((int32_t)ir_ror32(op1_insn->val.u32, (op2_insn->val.u32 & 0x1f))); } IR_FOLD(ROR(C_U64, C_U64)) IR_FOLD(ROR(C_I64, C_I64)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - IR_FOLD_CONST_U(ir_ror64(op1_insn->val.u64, op2_insn->val.u64)); + IR_FOLD_CONST_U(ir_ror64(op1_insn->val.u64, (op2_insn->val.u64 & 0x3f))); } //IR_FOLD(BSWAP(CONST)) @@ -1392,6 +1419,9 @@ IR_FOLD(TRUNC(C_U64)) IR_FOLD_CONST_U(op1_insn->val.u16); case IR_U32: IR_FOLD_CONST_U(op1_insn->val.u32); + case IR_ADDR: + IR_ASSERT(sizeof(void*) == 4); + IR_FOLD_CONST_U(op1_insn->val.u32); } } @@ -1545,7 +1575,7 @@ IR_FOLD(FP2FP(C_DOUBLE)) IR_FOLD(COPY(_)) { IR_ASSERT(IR_OPT_TYPE(opt) == op1_insn->type); - if (!op2) { + if (!(op2 & IR_COPY_HARD)) { IR_FOLD_COPY(op1); } /* skip CSE */ @@ -2075,23 +2105,23 @@ IR_FOLD(SUB(ADD, ADD)) IR_FOLD_CONST_U(0); } else if (op1_insn->op1 == op2_insn->op1) { /* (a + b) - (a + c) => b - c */ - op1 = op1_insn->op2; - op2 = op2_insn->op2; + op1 = _ir_fold_cast(ctx, op1_insn->op2, IR_OPT_TYPE(opt)); + op2 = _ir_fold_cast(ctx, op2_insn->op2, IR_OPT_TYPE(opt)); IR_FOLD_RESTART; } else if (op1_insn->op1 == op2_insn->op2) { /* (a + b) - (c + a) => b - c */ - op1 = op1_insn->op2; - op2 = op2_insn->op1; + op1 = _ir_fold_cast(ctx, op1_insn->op2, IR_OPT_TYPE(opt)); + op2 = _ir_fold_cast(ctx, op2_insn->op1, IR_OPT_TYPE(opt)); IR_FOLD_RESTART; } else if (op1_insn->op2 == op2_insn->op1) { /* (a + b) - (b + c) => a - c */ - op1 = op1_insn->op1; - op2 = op2_insn->op2; + op1 = _ir_fold_cast(ctx, op1_insn->op1, IR_OPT_TYPE(opt)); + op2 = _ir_fold_cast(ctx, op2_insn->op2, IR_OPT_TYPE(opt)); IR_FOLD_RESTART; } else if (op1_insn->op2 == op2_insn->op2) { /* (a + b) - (c + b) => a - c */ - op1 = op1_insn->op1; - op2 = op2_insn->op1; + op1 = _ir_fold_cast(ctx, op1_insn->op1, IR_OPT_TYPE(opt)); + op2 = _ir_fold_cast(ctx, op2_insn->op1, IR_OPT_TYPE(opt)); IR_FOLD_RESTART; } } diff --git a/ext/opcache/jit/ir/ir_gcm.c b/ext/opcache/jit/ir/ir_gcm.c index 043e1e7bdd853..e6486ba64a1c5 100644 --- a/ext/opcache/jit/ir/ir_gcm.c +++ b/ext/opcache/jit/ir/ir_gcm.c @@ -361,20 +361,20 @@ static bool ir_split_partially_dead_node(ir_ctx *ctx, ir_ref ref, uint32_t b) while (ir_sparse_set_in(&data->totally_useful, ctx->cfg_blocks[j].idom)) { j = ctx->cfg_blocks[j].idom; } + clone = ir_hashtab_find(&hash, j); + if (clone == IR_INVALID_VAL) { + clone = clones_count++; + ir_hashtab_add(&hash, j, clone); + clones[clone].block = j; + clones[clone].use_count = 0; + clones[clone].use = -1; + } + uses[uses_count].ref = use; + uses[uses_count].block = i; + uses[uses_count].next = clones[clone].use; + clones[clone].use_count++; + clones[clone].use = uses_count++; } - clone = ir_hashtab_find(&hash, j); - if (clone == IR_INVALID_VAL) { - clone = clones_count++; - ir_hashtab_add(&hash, j, clone); - clones[clone].block = j; - clones[clone].use_count = 0; - clones[clone].use = -1; - } - uses[uses_count].ref = use; - uses[uses_count].block = i; - uses[uses_count].next = clones[clone].use; - clones[clone].use_count++; - clones[clone].use = uses_count++; } } @@ -1007,7 +1007,11 @@ int ir_schedule(ir_ctx *ctx) start = i = bb->start; _xlat[i] = bb->start = insns_count; insn = &ctx->ir_base[i]; - if (insn->op == IR_CASE_VAL) { + if (insn->op == IR_BEGIN) { + if (insn->op2) { + consts_count += ir_count_constant(_xlat, insn->op2); + } + } else if (insn->op == IR_CASE_VAL) { IR_ASSERT(insn->op2 < IR_TRUE); consts_count += ir_count_constant(_xlat, insn->op2); } else if (insn->op == IR_CASE_RANGE) { @@ -1255,7 +1259,7 @@ int ir_schedule(ir_ctx *ctx) const char *proto = ir_get_strl(ctx, new_insn->proto, &len); new_insn->proto = ir_strl(&new_ctx, proto, len); } - } else if (new_insn->op == IR_SYM || new_insn->op == IR_STR) { + } else if (new_insn->op == IR_SYM || new_insn->op == IR_STR || new_insn->op == IR_LABEL) { size_t len; const char *str = ir_get_strl(ctx, new_insn->val.name, &len); new_insn->val.u64 = ir_strl(&new_ctx, str, len); @@ -1292,7 +1296,7 @@ int ir_schedule(ir_ctx *ctx) } else { new_insn->proto = 0; } - } else if (insn->op == IR_SYM || insn->op == IR_STR) { + } else if (insn->op == IR_SYM || insn->op == IR_STR || insn->op == IR_LABEL) { size_t len; const char *str = ir_get_strl(ctx, insn->val.name, &len); new_insn->val.u64 = ir_strl(&new_ctx, str, len); @@ -1364,6 +1368,8 @@ int ir_schedule(ir_ctx *ctx) size_t len; const char *str = ir_get_strl(ctx, insn->op2, &len); new_insn->op2 = ir_strl(&new_ctx, str, len); + } else if (new_insn->op == IR_BEGIN && insn->op2) { + new_insn->op2 = _xlat[insn->op2]; } else { new_insn->op2 = insn->op2; } diff --git a/ext/opcache/jit/ir/ir_private.h b/ext/opcache/jit/ir/ir_private.h index 2f457cbc99333..dbacc3967d0f7 100644 --- a/ext/opcache/jit/ir/ir_private.h +++ b/ext/opcache/jit/ir/ir_private.h @@ -887,7 +887,7 @@ void ir_print_escaped_str(const char *s, size_t len, FILE *f); #define IR_IS_CONST_OP(op) ((op) > IR_NOP && (op) <= IR_C_FLOAT) #define IR_IS_FOLDABLE_OP(op) ((op) <= IR_LAST_FOLDABLE_OP) -#define IR_IS_SYM_CONST(op) ((op) == IR_STR || (op) == IR_SYM || (op) == IR_FUNC) +#define IR_IS_SYM_CONST(op) ((op) == IR_STR || (op) == IR_SYM || (op) == IR_FUNC || (op) == IR_LABEL) ir_ref ir_const_ex(ir_ctx *ctx, ir_val val, uint8_t type, uint32_t optx); @@ -946,12 +946,13 @@ IR_ALWAYS_INLINE bool ir_ref_is_true(ir_ctx *ctx, ir_ref ref) #define IR_OPND_UNUSED 0x0 #define IR_OPND_DATA 0x1 #define IR_OPND_CONTROL 0x2 -#define IR_OPND_CONTROL_DEP 0x3 -#define IR_OPND_CONTROL_REF 0x4 -#define IR_OPND_STR 0x5 -#define IR_OPND_NUM 0x6 -#define IR_OPND_PROB 0x7 -#define IR_OPND_PROTO 0x8 +#define IR_OPND_LABEL_REF 0x3 +#define IR_OPND_CONTROL_DEP 0x4 +#define IR_OPND_CONTROL_REF 0x5 +#define IR_OPND_STR 0x6 +#define IR_OPND_NUM 0x7 +#define IR_OPND_PROB 0x8 +#define IR_OPND_PROTO 0x9 #define IR_OP_FLAGS(op_flags, op1_flags, op2_flags, op3_flags) \ ((op_flags) | ((op1_flags) << 20) | ((op2_flags) << 24) | ((op3_flags) << 28)) @@ -1013,6 +1014,7 @@ IR_ALWAYS_INLINE uint32_t ir_insn_len(const ir_insn *insn) #define IR_HAS_VA_ARG_FP (1<<9) #define IR_HAS_FP_RET_SLOT (1<<10) #define IR_16B_FRAME_ALIGNMENT (1<<11) +#define IR_HAS_BLOCK_ADDR (1<<12) /* Temporary: MEM2SSA -> SCCP */ #define IR_MEM2SSA_VARS (1<<25) @@ -1248,11 +1250,10 @@ struct _ir_live_range { #define IR_LIVE_INTERVAL_HAS_HINT_REGS (1<<2) #define IR_LIVE_INTERVAL_HAS_HINT_REFS (1<<3) #define IR_LIVE_INTERVAL_MEM_PARAM (1<<4) -#define IR_LIVE_INTERVAL_MEM_LOAD (1<<5) -#define IR_LIVE_INTERVAL_COALESCED (1<<6) -#define IR_LIVE_INTERVAL_SPILL_SPECIAL (1<<7) /* spill slot is pre-allocated in a special area (see ir_ctx.spill_reserved_base) */ -#define IR_LIVE_INTERVAL_SPILLED (1<<8) -#define IR_LIVE_INTERVAL_SPLIT_CHILD (1<<9) +#define IR_LIVE_INTERVAL_COALESCED (1<<5) +#define IR_LIVE_INTERVAL_SPILL_SPECIAL (1<<6) /* spill slot is pre-allocated in a special area (see ir_ctx.spill_reserved_base) */ +#define IR_LIVE_INTERVAL_SPILLED (1<<7) +#define IR_LIVE_INTERVAL_SPLIT_CHILD (1<<8) struct _ir_live_interval { uint8_t type; diff --git a/ext/opcache/jit/ir/ir_ra.c b/ext/opcache/jit/ir/ir_ra.c index 21c7ee3ac64e5..2e8a8e3f34f3f 100644 --- a/ext/opcache/jit/ir/ir_ra.c +++ b/ext/opcache/jit/ir/ir_ra.c @@ -776,9 +776,6 @@ int ir_compute_live_ranges(ir_ctx *ctx) if (insn->op == IR_PARAM) { /* We may reuse parameter stack slot for spilling */ ctx->live_intervals[v]->flags |= IR_LIVE_INTERVAL_MEM_PARAM; - } else if (insn->op == IR_VLOAD) { - /* Load may be fused into the usage instruction */ - ctx->live_intervals[v]->flags |= IR_LIVE_INTERVAL_MEM_LOAD; } def_pos = IR_DEF_LIVE_POS_FROM_REF(ref); } @@ -845,11 +842,17 @@ int ir_compute_live_ranges(ir_ctx *ctx) ival = ctx->live_intervals[v]; } ir_add_use(ctx, ival, j, use_pos, reg, IR_USE_FLAGS(def_flags, j), hint_ref); - } else if (ctx->rules) { - if (ctx->rules[input] & IR_FUSED) { - ir_add_fusion_ranges(ctx, ref, input, bb, live); - } else if (ctx->rules[input] == (IR_SKIPPED|IR_RLOAD)) { - ir_set_alocated_reg(ctx, ref, j, ctx->ir_base[input].op2); + } else { + if (ctx->rules) { + if ((ctx->rules[input] & (IR_FUSED|IR_SKIPPED)) == IR_FUSED) { + ir_add_fusion_ranges(ctx, ref, input, bb, live); + } else if (ctx->rules[input] == (IR_SKIPPED|IR_RLOAD)) { + ir_set_alocated_reg(ctx, ref, j, ctx->ir_base[input].op2); + } + } + if (reg != IR_REG_NONE) { + use_pos = IR_LOAD_LIVE_POS_FROM_REF(ref); + ir_add_fixed_live_range(ctx, reg, use_pos, use_pos + IR_USE_SUB_REF); } } } else if (reg != IR_REG_NONE) { @@ -1396,9 +1399,6 @@ int ir_compute_live_ranges(ir_ctx *ctx) if (insn->op == IR_PARAM) { /* We may reuse parameter stack slot for spilling */ ctx->live_intervals[v]->flags |= IR_LIVE_INTERVAL_MEM_PARAM; - } else if (insn->op == IR_VLOAD) { - /* Load may be fused into the usage instruction */ - ctx->live_intervals[v]->flags |= IR_LIVE_INTERVAL_MEM_LOAD; } def_pos = IR_DEF_LIVE_POS_FROM_REF(ref); } @@ -1465,17 +1465,17 @@ int ir_compute_live_ranges(ir_ctx *ctx) ival = ctx->live_intervals[v]; } ir_add_use(ctx, ival, j, use_pos, reg, IR_USE_FLAGS(def_flags, j), hint_ref); - } else if (ctx->rules) { - if (ctx->rules[input] & IR_FUSED) { - ir_add_fusion_ranges(ctx, ref, input, bb, live_in_block, b); - } else { - if (ctx->rules[input] == (IR_SKIPPED|IR_RLOAD)) { + } else { + if (ctx->rules) { + if ((ctx->rules[input] & (IR_FUSED|IR_SKIPPED)) == IR_FUSED) { + ir_add_fusion_ranges(ctx, ref, input, bb, live_in_block, b); + } else if (ctx->rules[input] == (IR_SKIPPED|IR_RLOAD)) { ir_set_alocated_reg(ctx, ref, j, ctx->ir_base[input].op2); } - if (reg != IR_REG_NONE) { - use_pos = IR_LOAD_LIVE_POS_FROM_REF(ref); - ir_add_fixed_live_range(ctx, reg, use_pos, use_pos + IR_USE_SUB_REF); - } + } + if (reg != IR_REG_NONE) { + use_pos = IR_LOAD_LIVE_POS_FROM_REF(ref); + ir_add_fixed_live_range(ctx, reg, use_pos, use_pos + IR_USE_SUB_REF); } } } else if (reg != IR_REG_NONE) { @@ -1605,7 +1605,7 @@ static void ir_vregs_join(ir_ctx *ctx, uint32_t r1, uint32_t r2) } while (*prev && ((*prev)->pos < use_pos->pos || ((*prev)->pos == use_pos->pos && - (use_pos->op_num == 0 || (*prev)->op_num < use_pos->op_num)))) { + (use_pos->op_num == 0 || ((*prev)->op_num != 0 && (*prev)->op_num < use_pos->op_num))))) { if ((*prev)->hint_ref > 0 && ctx->vregs[(*prev)->hint_ref] == r2) { (*prev)->hint_ref = 0; } @@ -1627,9 +1627,6 @@ static void ir_vregs_join(ir_ctx *ctx, uint32_t r1, uint32_t r2) ctx->live_intervals[r1]->flags |= IR_LIVE_INTERVAL_COALESCED | (ival->flags & (IR_LIVE_INTERVAL_HAS_HINT_REGS|IR_LIVE_INTERVAL_HAS_HINT_REFS)); - if (ctx->ir_base[IR_LIVE_POS_TO_REF(ctx->live_intervals[r1]->use_pos->pos)].op != IR_VLOAD) { - ctx->live_intervals[r1]->flags &= ~IR_LIVE_INTERVAL_MEM_LOAD; - } if (ival->flags & IR_LIVE_INTERVAL_MEM_PARAM) { IR_ASSERT(!(ctx->live_intervals[r1]->flags & IR_LIVE_INTERVAL_MEM_PARAM)); ctx->live_intervals[r1]->flags |= IR_LIVE_INTERVAL_MEM_PARAM; @@ -2343,16 +2340,6 @@ static ir_live_pos ir_first_use_pos_after(ir_live_interval *ival, ir_live_pos po return p ? p->pos : 0x7fffffff; } -static ir_live_pos ir_first_use_pos(ir_live_interval *ival, uint8_t flags) -{ - ir_use_pos *p = ival->use_pos; - - while (p && !(p->flags & flags)) { - p = p->next; - } - return p ? p->pos : 0x7fffffff; -} - static ir_block *ir_block_from_live_pos(ir_ctx *ctx, ir_live_pos pos) { ir_ref ref = IR_LIVE_POS_TO_REF(pos); @@ -3194,7 +3181,6 @@ static ir_reg ir_allocate_blocked_reg(ir_ctx *ctx, ir_live_interval *ival, ir_li /* split current before its first use position that requires a register */ ir_live_pos split_pos; -spill_current: if (next_use_pos == ival->range.start) { IR_ASSERT(ival->use_pos && ival->use_pos->op_num == 0); /* split right after definition */ @@ -3228,7 +3214,6 @@ static ir_reg ir_allocate_blocked_reg(ir_ctx *ctx, ir_live_interval *ival, ir_li return IR_REG_NONE; } if (split_pos >= blockPos[reg]) { -try_next_available_register: IR_REGSET_EXCL(available, reg); if (IR_REGSET_IS_EMPTY(available)) { fprintf(stderr, "LSRA Internal Error: Unsolvable conflict. Allocation is not possible\n"); @@ -3274,23 +3259,6 @@ static ir_reg ir_allocate_blocked_reg(ir_ctx *ctx, ir_live_interval *ival, ir_li } IR_LOG_LSRA(" ---- Finish", other, ""); } else { - if (ir_first_use_pos(other, IR_USE_MUST_BE_IN_REG) <= other->end) { - if (!(ival->flags & IR_LIVE_INTERVAL_TEMP)) { - next_use_pos = ir_first_use_pos(ival, IR_USE_MUST_BE_IN_REG); - if (next_use_pos == ival->range.start) { - IR_ASSERT(ival->use_pos && ival->use_pos->op_num == 0); - /* split right after definition */ - split_pos = next_use_pos + 1; - } else { - split_pos = ir_find_optimal_split_position(ctx, ival, ival->range.start, next_use_pos - 1, 1); - } - - if (split_pos > ival->range.start) { - goto spill_current; - } - } - goto try_next_available_register; - } child = other; other->reg = IR_REG_NONE; if (prev) { @@ -3400,12 +3368,13 @@ static int ir_fix_dessa_tmps(ir_ctx *ctx, uint8_t type, ir_ref from, ir_ref to) static bool ir_ival_spill_for_fuse_load(ir_ctx *ctx, ir_live_interval *ival, ir_reg_alloc_data *data) { ir_use_pos *use_pos = ival->use_pos; - ir_insn *insn; if (ival->flags & IR_LIVE_INTERVAL_MEM_PARAM) { IR_ASSERT(!ival->next && use_pos && use_pos->op_num == 0); - insn = &ctx->ir_base[IR_LIVE_POS_TO_REF(use_pos->pos)]; +#if IR_DEBUG + ir_insn *insn = &ctx->ir_base[IR_LIVE_POS_TO_REF(use_pos->pos)]; IR_ASSERT(insn->op == IR_PARAM); +#endif use_pos = use_pos->next; if (use_pos && (use_pos->next || (use_pos->flags & IR_USE_MUST_BE_IN_REG))) { return 0; @@ -3418,38 +3387,6 @@ static bool ir_ival_spill_for_fuse_load(ir_ctx *ctx, ir_live_interval *ival, ir_ } } - return 1; - } else if (ival->flags & IR_LIVE_INTERVAL_MEM_LOAD) { - insn = &ctx->ir_base[IR_LIVE_POS_TO_REF(use_pos->pos)]; - IR_ASSERT(insn->op == IR_VLOAD); - IR_ASSERT(ctx->ir_base[insn->op2].op == IR_VAR); - use_pos = use_pos->next; - if (use_pos && (use_pos->next || (use_pos->flags & IR_USE_MUST_BE_IN_REG))) { - return 0; - } - - if (use_pos) { - ir_block *bb = ir_block_from_live_pos(ctx, use_pos->pos); - if (bb->loop_depth && bb != ir_block_from_live_pos(ctx, ival->use_pos->pos)) { - return 0; - } - /* check if VAR may be clobbered between VLOAD and use */ - ir_use_list *use_list = &ctx->use_lists[insn->op2]; - ir_ref n = use_list->count; - ir_ref *p = &ctx->use_edges[use_list->refs]; - for (; n > 0; p++, n--) { - ir_ref use = *p; - if (ctx->ir_base[use].op == IR_VSTORE) { - if (use > IR_LIVE_POS_TO_REF(ival->use_pos->pos) && use < IR_LIVE_POS_TO_REF(use_pos->pos)) { - return 0; - } - } else if (ctx->ir_base[use].op == IR_VADDR) { - return 0; - } - } - } - ival->stack_spill_pos = ctx->ir_base[insn->op2].op3; - return 1; } return 0; @@ -3554,7 +3491,7 @@ static int ir_linear_scan(ir_ctx *ctx) for (j = ctx->vregs_count; j != 0; j--) { ival = ctx->live_intervals[j]; if (ival) { - if (!(ival->flags & (IR_LIVE_INTERVAL_MEM_PARAM|IR_LIVE_INTERVAL_MEM_LOAD)) + if (!(ival->flags & IR_LIVE_INTERVAL_MEM_PARAM) || !ir_ival_spill_for_fuse_load(ctx, ival, &data)) { ir_add_to_unhandled(&unhandled, ival); } diff --git a/ext/opcache/jit/ir/ir_save.c b/ext/opcache/jit/ir/ir_save.c index 5ba986fadd481..dd955172950c8 100644 --- a/ext/opcache/jit/ir/ir_save.c +++ b/ext/opcache/jit/ir/ir_save.c @@ -40,6 +40,11 @@ void ir_print_proto_ex(uint8_t flags, ir_type ret_type, uint32_t params_count, c } else if (flags & IR_BUILTIN_FUNC) { fprintf(f, " __builtin"); } + if (flags & IR_CONST_FUNC) { + fprintf(f, " __const"); + } else if (flags & IR_PURE_FUNC) { + fprintf(f, " __pure"); + } } static void ir_save_dessa_moves(const ir_ctx *ctx, int b, ir_block *bb, FILE *f) @@ -109,6 +114,10 @@ void ir_save(const ir_ctx *ctx, uint32_t save_flags, FILE *f) fprintf(f, "sym(%s%s)", (save_flags & IR_SAVE_SAFE_NAMES) ? "@" : "", ir_get_str(ctx, insn->val.name)); + } else if (insn->op == IR_LABEL) { + fprintf(f, "label(%s%s)", + (save_flags & IR_SAVE_SAFE_NAMES) ? "@" : "", + ir_get_str(ctx, insn->val.name)); } else if (insn->op == IR_FUNC_ADDR) { fprintf(f, "func *"); ir_print_const(ctx, insn, f, true); @@ -272,6 +281,13 @@ void ir_save(const ir_ctx *ctx, uint32_t save_flags, FILE *f) fprintf(f, "%s%d", first ? "(" : ", ", ref); first = 0; break; + case IR_OPND_LABEL_REF: + if (ref) { + IR_ASSERT(IR_IS_CONST_REF(ref)); + fprintf(f, "%sc_%d", first ? "(" : ", ", -ref); + first = 0; + } + break; } } else if (opnd_kind == IR_OPND_NUM) { fprintf(f, "%s%d", first ? "(" : ", ", ref); diff --git a/ext/opcache/jit/ir/ir_sccp.c b/ext/opcache/jit/ir/ir_sccp.c index 45df92ec2be6f..e2f38a058aeba 100644 --- a/ext/opcache/jit/ir/ir_sccp.c +++ b/ext/opcache/jit/ir/ir_sccp.c @@ -1508,8 +1508,8 @@ static bool ir_may_promote_f2d(ir_ctx *ctx, ir_ref ref) switch (insn->op) { case IR_FP2FP: return 1; - case IR_INT2FP: - return ctx->use_lists[ref].count == 1; +// case IR_INT2FP: +// return ctx->use_lists[ref].count == 1; case IR_NEG: case IR_ABS: return ctx->use_lists[ref].count == 1 && @@ -2110,7 +2110,9 @@ static bool ir_try_promote_induction_var_ext(ir_ctx *ctx, ir_ref ext_ref, ir_ref && !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, worklist); + ir_ref tmp = ir_ext_ref(ctx, use, use_insn->op1, op, type, worklist); + use_insn = &ctx->ir_base[use]; + use_insn->op1 = tmp; } ir_bitqueue_add(worklist, use); } @@ -2119,7 +2121,9 @@ static bool ir_try_promote_induction_var_ext(ir_ctx *ctx, ir_ref ext_ref, ir_ref && !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, worklist); + ir_ref tmp = ir_ext_ref(ctx, use, use_insn->op2, op, type, worklist); + use_insn = &ctx->ir_base[use]; + use_insn->op2 = tmp; } ir_bitqueue_add(worklist, use); } @@ -2147,7 +2151,9 @@ static bool ir_try_promote_induction_var_ext(ir_ctx *ctx, ir_ref ext_ref, ir_ref && !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, worklist); + ir_ref tmp = ir_ext_ref(ctx, use, use_insn->op1, op, type, worklist); + use_insn = &ctx->ir_base[use]; + use_insn->op1 = tmp; } ir_bitqueue_add(worklist, use); } @@ -2156,7 +2162,9 @@ static bool ir_try_promote_induction_var_ext(ir_ctx *ctx, ir_ref ext_ref, ir_ref && !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, worklist); + ir_ref tmp = ir_ext_ref(ctx, use, use_insn->op2, op, type, worklist); + use_insn = &ctx->ir_base[use]; + use_insn->op2 = tmp; } ir_bitqueue_add(worklist, use); } @@ -2178,7 +2186,8 @@ static bool ir_try_promote_induction_var_ext(ir_ctx *ctx, ir_ref ext_ref, ir_ref && !IR_IS_SYM_CONST(ctx->ir_base[phi_insn->op2].op)) { ctx->ir_base[phi_ref].op2 = ir_ext_const(ctx, &ctx->ir_base[phi_insn->op2], op, type); } else { - ctx->ir_base[phi_ref].op2 = ir_ext_ref(ctx, phi_ref, phi_insn->op2, op, type, worklist); + ir_ref tmp = ir_ext_ref(ctx, phi_ref, phi_insn->op2, op, type, worklist); + ctx->ir_base[phi_ref].op2 = tmp; } return 1; @@ -2251,42 +2260,6 @@ static void ir_merge_blocks(ir_ctx *ctx, ir_ref end, ir_ref begin, ir_bitqueue * ir_ref prev, next; ir_use_list *use_list; - if (ctx->use_lists[begin].count > 1) { - ir_ref *p, n, i, use; - ir_insn *use_insn; - ir_ref region = end; - ir_ref next = IR_UNUSED; - - while (!IR_IS_BB_START(ctx->ir_base[region].op)) { - region = ctx->ir_base[region].op1; - } - - use_list = &ctx->use_lists[begin]; - n = use_list->count; - for (p = &ctx->use_edges[use_list->refs], i = 0; i < n; p++, i++) { - use = *p; - use_insn = &ctx->ir_base[use]; - if (ir_op_flags[use_insn->op] & IR_OP_FLAG_CONTROL) { - IR_ASSERT(!next); - next = use; - } else { - IR_ASSERT(use_insn->op == IR_VAR); - IR_ASSERT(use_insn->op1 == begin); - use_insn->op1 = region; - if (ir_use_list_add(ctx, region, use)) { - /* restore after reallocation */ - use_list = &ctx->use_lists[begin]; - n = use_list->count; - p = &ctx->use_edges[use_list->refs + i]; - } - } - } - - IR_ASSERT(next); - ctx->use_edges[use_list->refs] = next; - use_list->count = 1; - } - IR_ASSERT(ctx->ir_base[begin].op == IR_BEGIN); IR_ASSERT(ctx->ir_base[end].op == IR_END); IR_ASSERT(ctx->ir_base[begin].op1 == end); @@ -3595,7 +3568,10 @@ void ir_iter_opt(ir_ctx *ctx, ir_bitqueue *worklist) if (!(ctx->flags & IR_OPT_CFG)) { /* pass */ } else if (insn->op == IR_BEGIN) { - if (insn->op1 && ctx->ir_base[insn->op1].op == IR_END) { + if (insn->op1 + && !insn->op2 /* no computed goto label */ + && ctx->use_lists[i].count == 1 + && ctx->ir_base[insn->op1].op == IR_END) { ir_merge_blocks(ctx, insn->op1, i, worklist); } } else if (insn->op == IR_MERGE) { diff --git a/ext/opcache/jit/ir/ir_x86.dasc b/ext/opcache/jit/ir/ir_x86.dasc index 42e4eee7da0fc..7f714dd11d27c 100644 --- a/ext/opcache/jit/ir/ir_x86.dasc +++ b/ext/opcache/jit/ir/ir_x86.dasc @@ -66,7 +66,7 @@ IR_ALWAYS_INLINE ir_mem IR_MEM(ir_reg base, int32_t offset, ir_reg index, int32_ #define IR_SPILL_POS_TO_OFFSET(offset) \ ((ctx->flags & IR_USE_FRAME_POINTER) ? \ - ((offset) - (ctx->stack_frame_size - ctx->stack_frame_alignment)) : \ + ((offset) - ctx->stack_frame_size) : \ ((offset) + ctx->call_stack_size)) |.macro ASM_EXPAND_OP_MEM, MACRO, op, type, op1 @@ -892,6 +892,9 @@ typedef struct _ir_backend_data { bool double_abs_const; bool float_abs_const; bool double_zero_const; + bool u2d_const; + bool u2f_const; + bool resolved_label_syms; } ir_backend_data; #define IR_GP_REG_NAME(code, name64, name32, name16, name8, name8h) \ @@ -1087,6 +1090,7 @@ const char *ir_reg_name(int8_t reg, ir_type type) _(SSE_TRUNC) \ _(SSE_NEARBYINT) \ _(BIT_OP) \ + _(IGOTO_DUP) \ #define IR_LEA_FIRST IR_LEA_OB #define IR_LEA_LAST IR_LEA_O_SYM @@ -1110,35 +1114,24 @@ const char *ir_rule_name[IR_LAST_OP] = { static bool ir_may_fuse_addr(ir_ctx *ctx, const ir_insn *addr_insn) { - if (sizeof(void*) == 4) { - return 1; + if (addr_insn->op == IR_LABEL) { + return 0; } else if (IR_IS_SYM_CONST(addr_insn->op)) { void *addr = ir_sym_addr(ctx, addr_insn); if (!addr) { return 0; } - return IR_IS_SIGNED_32BIT((int64_t)(intptr_t)addr); + return (sizeof(void*) == 4) || IR_IS_SIGNED_32BIT((int64_t)(intptr_t)addr); } else { - return IR_IS_SIGNED_32BIT(addr_insn->val.i64); + return (sizeof(void*) == 4) || IR_IS_SIGNED_32BIT(addr_insn->val.i64); } } static bool ir_may_fuse_imm(ir_ctx *ctx, const ir_insn *val_insn) { if (val_insn->type == IR_ADDR) { - if (sizeof(void*) == 4) { - return 1; - } else if (IR_IS_SYM_CONST(val_insn->op)) { - void *addr = ir_sym_addr(ctx, val_insn); - - if (!addr) { - return 0; - } - return IR_IS_SIGNED_32BIT((intptr_t)addr); - } else { - return IR_IS_SIGNED_32BIT(val_insn->val.i64); - } + return ir_may_fuse_addr(ctx, val_insn); } else { return (ir_type_size[val_insn->type] <= 4 || IR_IS_SIGNED_32BIT(val_insn->val.i64)); } @@ -1517,6 +1510,11 @@ op2_const: constraints->tmp_regs[0] = IR_TMP_REG(1, ctx->ir_base[insn->op1].type, IR_LOAD_SUB_REF, IR_DEF_SUB_REF); n = 1; } + if (IR_IS_TYPE_UNSIGNED(ctx->ir_base[insn->op1].type) + && ir_type_size[ctx->ir_base[insn->op1].type] >= sizeof(void*)) { + constraints->tmp_regs[n] = IR_TMP_REG(2, ctx->ir_base[insn->op1].type, IR_USE_SUB_REF, IR_DEF_SUB_REF); + n++; + } break; case IR_ABS_INT: flags = IR_DEF_CONFLICTS_WITH_INPUT_REGS | IR_USE_MUST_BE_IN_REG | IR_OP1_MUST_BE_IN_REG; @@ -1542,6 +1540,7 @@ op2_const: case IR_GUARD_NOT: flags = IR_OP2_SHOULD_BE_IN_REG; break; + case IR_IGOTO: case IR_IJMP: flags = IR_OP2_SHOULD_BE_IN_REG; break; @@ -1574,7 +1573,7 @@ op2_const: } break; case IR_VA_ARG: - flags = IR_USE_MUST_BE_IN_REG | IR_OP2_MUST_BE_IN_REG; + flags = IR_USE_MUST_BE_IN_REG | IR_OP2_MUST_BE_IN_REG | IR_DEF_CONFLICTS_WITH_INPUT_REGS; constraints->tmp_regs[0] = IR_TMP_REG(3, IR_ADDR, IR_LOAD_SUB_REF, IR_SAVE_SUB_REF); n = 1; insn = &ctx->ir_base[ref]; @@ -1669,7 +1668,9 @@ static void ir_match_fuse_addr(ir_ctx *ctx, ir_ref addr_ref) do { ir_insn *insn = &ctx->ir_base[*p]; - if (insn->op != IR_LOAD && (insn->op != IR_STORE || insn->op3 == addr_ref)) { + if (insn->op != IR_LOAD + && insn->op != IR_LOAD_v + && ((insn->op != IR_STORE && insn->op != IR_STORE_v) || insn->op3 == addr_ref)) { return; } p++; @@ -1752,7 +1753,7 @@ static bool ir_match_has_mem_deps(ir_ctx *ctx, ir_ref ref, ir_ref root) do { ir_insn *insn = &ctx->ir_base[pos]; - if (insn->op == IR_STORE) { + if (insn->op == IR_STORE || insn->op == IR_STORE_v || insn->op == IR_VSTORE || insn->op == IR_VSTORE_v) { // TODO: check if LOAD and STORE addresses may alias return 1; } else if (insn->op == IR_CALL) { @@ -1766,8 +1767,9 @@ static bool ir_match_has_mem_deps(ir_ctx *ctx, ir_ref ref, ir_ref root) static void ir_match_fuse_load(ir_ctx *ctx, ir_ref ref, ir_ref root) { - if (ir_in_same_block(ctx, ref) - && ctx->ir_base[ref].op == IR_LOAD) { + if (ir_in_same_block(ctx, ref) && + (ctx->ir_base[ref].op == IR_LOAD || ctx->ir_base[ref].op == IR_LOAD_v || + ctx->ir_base[ref].op == IR_VLOAD || ctx->ir_base[ref].op == IR_VLOAD_v)) { if (ctx->use_lists[ref].count == 2 && !ir_match_has_mem_deps(ctx, ref, root)) { ir_ref addr_ref = ctx->ir_base[ref].op2; @@ -1792,7 +1794,7 @@ static bool ir_match_try_fuse_load(ir_ctx *ctx, ir_ref ref, ir_ref root) ir_insn *insn = &ctx->ir_base[ref]; if (ir_in_same_block(ctx, ref) - && insn->op == IR_LOAD) { + && (insn->op == IR_LOAD || insn->op == IR_LOAD_v || insn->op == IR_VLOAD || insn->op == IR_VLOAD_v)) { if (ctx->use_lists[ref].count == 2 && !ir_match_has_mem_deps(ctx, ref, root)) { ir_ref addr_ref = ctx->ir_base[ref].op2; @@ -1814,8 +1816,6 @@ static bool ir_match_try_fuse_load(ir_ctx *ctx, ir_ref ref, ir_ref root) && ir_get_param_reg(ctx, ref) == IR_REG_NONE) { return 1; } - } else if (ctx->ir_base[ref].op == IR_VLOAD) { - return 1; } return 0; } @@ -2462,8 +2462,21 @@ binop_fp: case IR_IJMP: ir_match_fuse_load(ctx, insn->op2, ref); return insn->op; + case IR_IGOTO: + if (ctx->ir_base[insn->op1].op == IR_MERGE || ctx->ir_base[insn->op1].op == IR_LOOP_BEGIN) { + ir_insn *merge = &ctx->ir_base[insn->op1]; + ir_ref *p, n = merge->inputs_count; + + for (p = merge->ops + 1; n > 0; p++, n--) { + ir_ref input = *p; + IR_ASSERT(ctx->ir_base[input].op == IR_END || ctx->ir_base[input].op == IR_LOOP_END); + ctx->rules[input] = IR_IGOTO_DUP; + } + } + ir_match_fuse_load(ctx, insn->op2, ref); + return insn->op; case IR_VAR: - return IR_SKIPPED | IR_VAR; + return IR_STATIC_ALLOCA; case IR_PARAM: #ifndef _WIN64 if (ctx->value_params && ctx->value_params[insn->op3 - 1].align) { @@ -2617,7 +2630,15 @@ store_int: return IR_VSTORE_FP; } break; + case IR_VSTORE_v: + if (IR_IS_TYPE_INT(ctx->ir_base[insn->op3].type)) { + return IR_VSTORE_INT; + } else { + return IR_VSTORE_FP; + } + break; case IR_LOAD: + case IR_LOAD_v: ir_match_fuse_addr(ctx, insn->op2); if (IR_IS_TYPE_INT(insn->type)) { return IR_LOAD_INT; @@ -2635,6 +2656,14 @@ store_int: return IR_STORE_FP; } break; + case IR_STORE_v: + ir_match_fuse_addr(ctx, insn->op2); + if (IR_IS_TYPE_INT(ctx->ir_base[insn->op3].type)) { + return IR_STORE_INT; + } else { + return IR_STORE_FP; + } + break; case IR_RLOAD: if (IR_REGSET_IN(IR_REGSET_UNION((ir_regset)ctx->fixed_regset, IR_REGSET_FIXED), insn->op2)) { return IR_SKIPPED | IR_RLOAD; @@ -3175,7 +3204,7 @@ static void ir_emit_load_imm_fp(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref sr | xorpd xmm(reg-IR_REG_FP_FIRST), xmm(reg-IR_REG_FP_FIRST) } } else { - label = ir_const_label(ctx, src); + label = ir_get_const_label(ctx, src); | ASM_FP_REG_TXT_OP movs, type, reg, [=>label] } } @@ -3229,6 +3258,38 @@ static void ir_load_local_addr(ir_ctx *ctx, ir_reg reg, ir_ref src) } } +static void ir_resolve_label_syms(ir_ctx *ctx) +{ + uint32_t b; + ir_block *bb; + + for (b = 1, bb = &ctx->cfg_blocks[b]; b <= ctx->cfg_blocks_count; bb++, b++) { + ir_insn *insn = &ctx->ir_base[bb->start]; + + if (insn->op == IR_BEGIN && insn->op2) { + IR_ASSERT(ctx->ir_base[insn->op2].op == IR_LABEL); + ctx->ir_base[insn->op2].val.u32_hi = b; + } + } +} + +static void ir_emit_load_label_addr(ir_ctx *ctx, ir_reg reg, ir_insn *label) +{ + ir_backend_data *data = ctx->data; + dasm_State **Dst = &data->dasm_state; + + if (!data->resolved_label_syms) { + data->resolved_label_syms = 1; + ir_resolve_label_syms(ctx); + } + + IR_ASSERT(label->op == IR_LABEL); + int b = label->val.u32_hi; + + b = ir_skip_empty_target_blocks(ctx, b); + | lea Ra(reg), aword [=>b] +} + static void ir_emit_load(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref src) { if (IR_IS_CONST_REF(src)) { @@ -3241,9 +3302,11 @@ static void ir_emit_load(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref src) } else if (insn->op == IR_STR) { ir_backend_data *data = ctx->data; dasm_State **Dst = &data->dasm_state; - int label = ir_const_label(ctx, src); + int label = ir_get_const_label(ctx, src); | lea Ra(reg), aword [=>label] + } else if (insn->op == IR_LABEL) { + ir_emit_load_label_addr(ctx, reg, insn); } else { ir_emit_load_imm_int(ctx, type, reg, insn->val.i64); } @@ -3289,7 +3352,7 @@ static void ir_emit_store_mem_int_const(ir_ctx *ctx, ir_type type, ir_mem mem, i IR_ASSERT(IR_IS_CONST_REF(src)); if (val_insn->op == IR_STR) { - int label = ir_const_label(ctx, src); + int label = ir_get_const_label(ctx, src); IR_ASSERT(tmp_reg != IR_REG_NONE); |.if X64 @@ -3298,6 +3361,11 @@ static void ir_emit_store_mem_int_const(ir_ctx *ctx, ir_type type, ir_mem mem, i |.else | ASM_TMEM_TXT_OP mov, aword, mem, =>label |.endif + } else if (val_insn->op == IR_LABEL) { + IR_ASSERT(tmp_reg != IR_REG_NONE); + tmp_reg = IR_REG_NUM(tmp_reg); + ir_emit_load_label_addr(ctx, tmp_reg, val_insn); + ir_emit_store_mem_int(ctx, type, mem, tmp_reg); } else { int64_t val = val_insn->val.i64; @@ -3726,7 +3794,8 @@ static ir_mem ir_fuse_load(ir_ctx *ctx, ir_ref root, ir_ref ref) ir_insn *load_insn = &ctx->ir_base[ref]; ir_reg reg; - IR_ASSERT(load_insn->op == IR_LOAD); + IR_ASSERT(load_insn->op == IR_LOAD || load_insn->op == IR_LOAD_v || + load_insn->op == IR_VLOAD || load_insn->op == IR_VLOAD_v); if (UNEXPECTED(ctx->rules[ref] & IR_FUSED_REG)) { reg = ir_get_fused_reg(ctx, root, ref * sizeof(ir_ref) + 2); } else { @@ -3762,9 +3831,11 @@ static void ir_emit_load_ex(ir_ctx *ctx, ir_type type, ir_reg reg, ir_ref src, i } else if (insn->op == IR_STR) { ir_backend_data *data = ctx->data; dasm_State **Dst = &data->dasm_state; - int label = ir_const_label(ctx, src); + int label = ir_get_const_label(ctx, src); | lea Ra(reg), aword [=>label] + } else if (insn->op == IR_LABEL) { + ir_emit_load_label_addr(ctx, reg, insn); } else { ir_emit_load_imm_int(ctx, type, reg, insn->val.i64); } @@ -3862,7 +3933,7 @@ static void ir_emit_prologue(ir_ctx *ctx) if (ctx->flags & IR_USE_FRAME_POINTER) { fp = IR_REG_FRAME_POINTER; - offset = -(ctx->stack_frame_size - ctx->stack_frame_alignment - ctx->locals_area_size); + offset = -(ctx->stack_frame_size - ctx->locals_area_size); } else { fp = IR_REG_STACK_POINTER; offset = ctx->locals_area_size + ctx->call_stack_size; @@ -5607,7 +5678,7 @@ static void ir_emit_binop_sse2(ir_ctx *ctx, ir_ref def, ir_insn *insn) break; } } else if (IR_IS_CONST_REF(op2)) { - int label = ir_const_label(ctx, op2); + int label = ir_get_const_label(ctx, op2); switch (insn->op) { default: @@ -5714,7 +5785,7 @@ static void ir_emit_binop_avx(ir_ctx *ctx, ir_ref def, ir_insn *insn) break; } } else if (IR_IS_CONST_REF(op2)) { - int label = ir_const_label(ctx, op2); + int label = ir_get_const_label(ctx, op2); switch (insn->op) { default: @@ -6126,7 +6197,7 @@ static ir_op ir_emit_cmp_fp_common(ir_ctx *ctx, ir_ref root, ir_ref cmp_ref, ir_ } | ASM_FP_REG_REG_OP ucomis, type, op1_reg, op2_reg } else if (IR_IS_CONST_REF(op2)) { - int label = ir_const_label(ctx, op2); + int label = ir_get_const_label(ctx, op2); | ASM_FP_REG_TXT_OP ucomis, type, op1_reg, [=>label] } else { @@ -6975,7 +7046,7 @@ static void ir_emit_return_fp(ir_ctx *ctx, ir_ref ref, ir_insn *insn) } else if ((type == IR_FLOAT && value->val.f == 1.0) || (type == IR_DOUBLE && value->val.d == 1.0)) { | fld1 } else { - int label = ir_const_label(ctx, insn->op2); + int label = ir_get_const_label(ctx, insn->op2); if (type == IR_DOUBLE) { | fld qword [=>label] @@ -7260,7 +7331,20 @@ static void ir_emit_trunc(ir_ctx *ctx, ir_ref def, ir_insn *insn) ir_emit_load(ctx, src_type, op1_reg, insn->op1); } if (op1_reg != def_reg) { +#ifdef IR_TARGET_X86 + if (ir_type_size[dst_type] == 1 + && (op1_reg == IR_REG_RBP || op1_reg == IR_REG_RSI || op1_reg == IR_REG_RDI)) { + ir_backend_data *data = ctx->data; + dasm_State **Dst = &data->dasm_state; + + ir_emit_mov(ctx, src_type, def_reg, op1_reg); + | and Rb(def_reg), 0xff + } else { + ir_emit_mov(ctx, dst_type, def_reg, op1_reg); + } +#else ir_emit_mov(ctx, dst_type, def_reg, op1_reg); +#endif } } else { ir_emit_load_ex(ctx, dst_type, def_reg, insn->op1, def); @@ -7385,7 +7469,7 @@ static void ir_emit_bitcast(ir_ctx *ctx, ir_ref def, ir_insn *insn) } } } else if (IR_IS_CONST_REF(insn->op1)) { - int label = ir_const_label(ctx, insn->op1); + int label = ir_get_const_label(ctx, insn->op1); | ASM_FP_REG_TXT_OP movs, dst_type, def_reg, [=>label] } else { @@ -7417,13 +7501,80 @@ static void ir_emit_int2fp(ir_ctx *ctx, ir_ref def, ir_insn *insn) IR_ASSERT(IR_IS_TYPE_INT(src_type)); IR_ASSERT(IR_IS_TYPE_FP(dst_type)); IR_ASSERT(def_reg != IR_REG_NONE); + + if (op1_reg != IR_REG_NONE && IR_REG_SPILLED(op1_reg)) { + op1_reg = IR_REG_NUM(op1_reg); + ir_emit_load(ctx, src_type, op1_reg, insn->op1); + } + + if (IR_IS_TYPE_UNSIGNED(src_type) && ir_type_size[src_type] >= sizeof(void*)) { + ir_reg tmp_reg = ctx->regs[def][2]; + + IR_ASSERT(tmp_reg != IR_REG_NONE); + if (op1_reg == IR_REG_NONE) { + if (IR_IS_CONST_REF(insn->op1)) { + IR_ASSERT(0); + } else { + ir_mem mem; + + if (ir_rule(ctx, insn->op1) & IR_FUSED) { + mem = ir_fuse_load(ctx, def, insn->op1); + } else { + mem = ir_ref_spill_slot(ctx, insn->op1); + } + ir_emit_load_mem_int(ctx, src_type, tmp_reg, mem); + op1_reg = tmp_reg; + } + } + if (sizeof(void*) == 4) { + if (tmp_reg == op1_reg) { + | add Rd(op1_reg), 0x80000000 + } else { + | lea Rd(tmp_reg), dword [Rd(op1_reg)+0x80000000] + op1_reg = tmp_reg; + } + } else { +|.if X64 + | test Rq(op1_reg), Rq(op1_reg) + | js >1 + |.cold_code + |1: + if (tmp_reg != op1_reg) { + | mov Rq(tmp_reg), Rq(op1_reg) + } + | shr Rq(tmp_reg), 1 + | adc Rq(tmp_reg), 0 + if (dst_type == IR_DOUBLE) { + if (ctx->mflags & IR_X86_AVX) { + | vxorps xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + | vcvtsi2sd xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), Rq(tmp_reg) + | vaddsd xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + } else { + | pxor xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + | cvtsi2sd xmm(def_reg-IR_REG_FP_FIRST), Rq(tmp_reg) + | addsd xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + } + } else { + IR_ASSERT(dst_type == IR_FLOAT); + if (ctx->mflags & IR_X86_AVX) { + | vxorps xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + | vcvtsi2ss xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), Rq(tmp_reg) + | vaddss xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + } else { + | pxor xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + | cvtsi2ss xmm(def_reg-IR_REG_FP_FIRST), Rq(tmp_reg) + | addss xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST) + } + } + | jmp >2 + |.code +|.endif + } + } + if (op1_reg != IR_REG_NONE) { bool src64 = 0; - if (IR_REG_SPILLED(op1_reg)) { - op1_reg = IR_REG_NUM(op1_reg); - ir_emit_load(ctx, src_type, op1_reg, insn->op1); - } if (IR_IS_TYPE_SIGNED(src_type)) { if (ir_type_size[src_type] < 4) { |.if X64 @@ -7462,7 +7613,6 @@ static void ir_emit_int2fp(ir_ctx *ctx, ir_ref def, ir_insn *insn) || } |.endif } else { - // TODO: uint64_t -> double src64 = 1; } } @@ -7508,6 +7658,40 @@ static void ir_emit_int2fp(ir_ctx *ctx, ir_ref def, ir_insn *insn) } |.endif } + |2: + if (sizeof(void*) == 4 && IR_IS_TYPE_UNSIGNED(src_type) && ir_type_size[src_type] >= sizeof(void*)) { + if (dst_type == IR_DOUBLE) { + uint32_t c = (sizeof(void*) == 4) ? 0x41e00000 : 0x43e00000; + if (!data->u2d_const) { + data->u2d_const = 1; + ir_rodata(ctx); + |.align 8 + |->u2d_const: + |.dword 0, c + |.code + } + if (ctx->mflags & IR_X86_AVX) { + | vaddsd xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), qword [->u2d_const] + } else { + | addsd xmm(def_reg-IR_REG_FP_FIRST), qword [->u2d_const] + } + } else { + uint32_t c = (sizeof(void*) == 4) ? 0x4f000000 : 0x5f000000; + if (!data->u2f_const) { + data->u2f_const = 1; + ir_rodata(ctx); + |.align 4 + |->u2f_const: + |.dword c + |.code + } + if (ctx->mflags & IR_X86_AVX) { + | vaddss xmm(def_reg-IR_REG_FP_FIRST), xmm(def_reg-IR_REG_FP_FIRST), dword [->u2f_const] + } else { + | addss xmm(def_reg-IR_REG_FP_FIRST), dword [->u2f_const] + } + } + } } else if (IR_IS_CONST_REF(insn->op1)) { IR_ASSERT(0); } else { @@ -7625,7 +7809,7 @@ static void ir_emit_fp2int(ir_ctx *ctx, ir_ref def, ir_insn *insn) |.endif } } else if (IR_IS_CONST_REF(insn->op1)) { - int label = ir_const_label(ctx, insn->op1); + int label = ir_get_const_label(ctx, insn->op1); if (!dst64) { if (src_type == IR_DOUBLE) { @@ -7746,7 +7930,7 @@ static void ir_emit_fp2fp(ir_ctx *ctx, ir_ref def, ir_insn *insn) } } } else if (IR_IS_CONST_REF(insn->op1)) { - int label = ir_const_label(ctx, insn->op1); + int label = ir_get_const_label(ctx, insn->op1); if (src_type == IR_DOUBLE) { if (ctx->mflags & IR_X86_AVX) { @@ -8429,7 +8613,7 @@ static void ir_emit_va_start(ir_ctx *ctx, ir_ref def, ir_insn *insn) if (ctx->flags & IR_USE_FRAME_POINTER) { fp = IR_REG_FRAME_POINTER; - reg_save_area_offset = -(ctx->stack_frame_size - ctx->stack_frame_alignment - ctx->locals_area_size); + reg_save_area_offset = -(ctx->stack_frame_size - ctx->locals_area_size); overflow_arg_area_offset = sizeof(void*) * 2 + ctx->param_stack_size; } else { fp = IR_REG_STACK_POINTER; @@ -8588,11 +8772,11 @@ static void ir_emit_va_arg(ir_ctx *ctx, ir_ref def, ir_insn *insn) } | add Ra(tmp_reg), IR_MAX(ir_type_size[type], sizeof(void*)) } else { - int size = (uint32_t)insn->op3 >> 3; + int size = IR_VA_ARG_SIZE(insn->op3); if (def_reg != IR_REG_NONE) { IR_ASSERT(type == IR_ADDR); - int align = 1U << (insn->op3 & 0x7); + int align = IR_VA_ARG_ALIGN(insn->op3); if (align > (int)sizeof(void*)) { | add Ra(tmp_reg), (align-1) @@ -8604,7 +8788,7 @@ static void ir_emit_va_arg(ir_ctx *ctx, ir_ref def, ir_insn *insn) } #endif | mov aword [Ra(op2_reg)+offset], Ra(tmp_reg) - if (def_reg && IR_REG_SPILLED(ctx->regs[def][0])) { + if (def_reg != IR_REG_NONE && IR_REG_SPILLED(ctx->regs[def][0])) { ir_emit_store(ctx, type, def, def_reg); } #elif defined(IR_TARGET_X64) @@ -8632,8 +8816,8 @@ static void ir_emit_va_arg(ir_ctx *ctx, ir_ref def, ir_insn *insn) if (insn->op3) { /* long struct arguemnt */ IR_ASSERT(type == IR_ADDR); - int align = 1U << (insn->op3 & 0x7); - int size = (uint32_t)insn->op3 >> 3; + int align = IR_VA_ARG_ALIGN(insn->op3); + int size = IR_VA_ARG_SIZE(insn->op3); | mov Ra(tmp_reg), aword [Ra(op2_reg)+(offset+offsetof(ir_va_list, overflow_arg_area))] if (align > (int)sizeof(void*)) { @@ -9701,6 +9885,19 @@ static void ir_emit_ijmp(ir_ctx *ctx, ir_ref def, ir_insn *insn) ir_reg op2_reg = ctx->regs[def][2]; if (IR_IS_CONST_REF(insn->op2)) { + if (ctx->ir_base[insn->op2].op == IR_LABEL) { + if (!data->resolved_label_syms) { + data->resolved_label_syms = 1; + ir_resolve_label_syms(ctx); + } + + uint32_t target = ctx->ir_base[insn->op2].val.u32_hi; + target = ir_skip_empty_target_blocks(ctx, target); + + | jmp =>target + return; + } + void *addr = ir_jmp_addr(ctx, insn, &ctx->ir_base[insn->op2]); if (sizeof(void*) == 4 || IR_MAY_USE_32BIT_ADDR(ctx->code_buffer, addr)) { @@ -10478,6 +10675,7 @@ static void ir_emit_param_move(ir_ctx *ctx, uint8_t type, ir_reg from_reg, ir_re { ir_reg fp = (ctx->flags & IR_USE_FRAME_POINTER) ? IR_REG_FRAME_POINTER : IR_REG_STACK_POINTER; + offset = IR_SPILL_POS_TO_OFFSET(offset); IR_ASSERT(from_reg != IR_REG_NONE || to_reg != IR_REG_NONE); if (IR_IS_TYPE_INT(type)) { @@ -10518,6 +10716,7 @@ static void ir_emit_load_params(ir_ctx *ctx) const int8_t *int_reg_params = _ir_int_reg_params; const int8_t *fp_reg_params = _ir_fp_reg_params; int32_t stack_offset = 0; + int32_t stack_start = 0; #ifdef IR_TARGET_X86 if (sizeof(void*) == 4 && (ctx->flags & IR_FASTCALL_FUNC)) { @@ -10529,9 +10728,11 @@ static void ir_emit_load_params(ir_ctx *ctx) #endif if (ctx->flags & IR_USE_FRAME_POINTER) { - stack_offset = sizeof(void*) * 2; /* skip old frame pointer and return address */ + /* skip old frame pointer and return address */ + stack_start = sizeof(void*) * 2 + ctx->stack_frame_size; } else { - stack_offset = sizeof(void*) + ctx->stack_frame_size + ctx->call_stack_size; /* skip return address */ + /* skip return address */ + stack_start = sizeof(void*) + ctx->stack_frame_size; } n = use_list->count; for (i = 0, p = &ctx->use_edges[use_list->refs]; i < n; i++, p++) { @@ -10573,12 +10774,9 @@ static void ir_emit_load_params(ir_ctx *ctx) if (ctx->vregs[use]) { dst_reg = IR_REG_NUM(ctx->regs[use][0]); IR_ASSERT(src_reg != IR_REG_NONE || dst_reg != IR_REG_NONE || - stack_offset == ctx->live_intervals[ctx->vregs[use]]->stack_spill_pos + - ((ctx->flags & IR_USE_FRAME_POINTER) ? - -(ctx->stack_frame_size - ctx->stack_frame_alignment) : - ctx->call_stack_size)); + stack_start + stack_offset == ctx->live_intervals[ctx->vregs[use]]->stack_spill_pos); if (src_reg != dst_reg) { - ir_emit_param_move(ctx, insn->type, src_reg, dst_reg, use, stack_offset); + ir_emit_param_move(ctx, insn->type, src_reg, dst_reg, use, stack_start + stack_offset); } if (dst_reg != IR_REG_NONE && IR_REG_SPILLED(ctx->regs[use][0])) { ir_emit_store(ctx, insn->type, use, dst_reg); @@ -10665,7 +10863,7 @@ static void ir_fix_param_spills(ir_ctx *ctx) if (ctx->flags & IR_USE_FRAME_POINTER) { /* skip old frame pointer and return address */ - stack_start = sizeof(void*) * 2 + (ctx->stack_frame_size - ctx->stack_frame_alignment); + stack_start = sizeof(void*) * 2 + ctx->stack_frame_size; } else { /* skip return address */ stack_start = sizeof(void*) + ctx->stack_frame_size; @@ -10786,6 +10984,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) case IR_MERGE: case IR_LOOP_BEGIN: case IR_LOOP_END: + case IR_IGOTO_DUP: break; #ifndef IR_REG_FP_RET1 case IR_CALL: @@ -10810,7 +11009,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) IR_REGSET_EXCL(available, reg); ctx->regs[i][0] = reg | IR_REG_SPILL_STORE; } else if (def_flags & IR_USE_MUST_BE_IN_REG) { - if (insn->op == IR_VLOAD + if ((insn->op == IR_VLOAD || insn->op == IR_VLOAD_v) && ctx->live_intervals[ctx->vregs[i]] && ctx->live_intervals[ctx->vregs[i]]->stack_spill_pos != -1 && ir_is_same_mem_var(ctx, i, ctx->ir_base[insn->op2].op3)) { @@ -10850,7 +11049,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) for (i = 0, p = &ctx->use_edges[use_list->refs]; i < n; i++, p++) { use = *p; use_insn = &ctx->ir_base[use]; - if (use_insn->op == IR_VLOAD) { + if (use_insn->op == IR_VLOAD || use_insn->op == IR_VLOAD_v) { if (ctx->vregs[use] && !ctx->live_intervals[ctx->vregs[use]]) { ir_live_interval *ival = ir_arena_alloc(&ctx->arena, sizeof(ir_live_interval)); @@ -10861,7 +11060,7 @@ static void ir_allocate_unique_spill_slots(ir_ctx *ctx) ival->vreg = ctx->vregs[use]; ival->stack_spill_pos = stack_spill_pos; } - } else if (use_insn->op == IR_VSTORE) { + } else if (use_insn->op == IR_VSTORE || use_insn->op == IR_VSTORE_v) { if (!IR_IS_CONST_REF(use_insn->op3) && ctx->vregs[use_insn->op3] && !ctx->live_intervals[ctx->vregs[use_insn->op3]]) { @@ -11006,7 +11205,6 @@ void ir_fix_stack_frame(ir_ctx *ctx) ctx->stack_frame_size = IR_ALIGNED_SIZE(ctx->stack_frame_size, sizeof(void*)); ctx->stack_frame_size += additional_size; - ctx->stack_frame_alignment = 0; ctx->call_stack_size = 0; if (ctx->flags2 & IR_16B_FRAME_ALIGNMENT) { @@ -11014,12 +11212,10 @@ void ir_fix_stack_frame(ir_ctx *ctx) if (!(ctx->flags & IR_FUNCTION)) { while (IR_ALIGNED_SIZE(ctx->stack_frame_size, 16) != ctx->stack_frame_size) { ctx->stack_frame_size += sizeof(void*); - ctx->stack_frame_alignment += sizeof(void*); } } else if (ctx->flags & IR_USE_FRAME_POINTER) { while (IR_ALIGNED_SIZE(ctx->stack_frame_size + sizeof(void*) * 2, 16) != ctx->stack_frame_size + sizeof(void*) * 2) { ctx->stack_frame_size += sizeof(void*); - ctx->stack_frame_alignment += sizeof(void*); } } else { if (!(ctx->flags & IR_NO_STACK_COMBINE)) { @@ -11028,7 +11224,6 @@ void ir_fix_stack_frame(ir_ctx *ctx) while (IR_ALIGNED_SIZE(ctx->stack_frame_size + ctx->call_stack_size + sizeof(void*), 16) != ctx->stack_frame_size + ctx->call_stack_size + sizeof(void*)) { ctx->stack_frame_size += sizeof(void*); - ctx->stack_frame_alignment += sizeof(void*); } } } @@ -11061,6 +11256,8 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) int ret; void *entry; size_t size; + ir_ref igoto_dup_ref = IR_UNUSED; + uint32_t igoto_dup_block = 0; data.ra_data.unused_slot_4 = 0; data.ra_data.unused_slot_2 = 0; @@ -11073,11 +11270,13 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) data.double_abs_const = 0; data.float_abs_const = 0; data.double_zero_const = 0; + data.u2d_const = 0; + data.u2f_const = 0; + data.resolved_label_syms = 0; ctx->data = &data; if (!ctx->live_intervals) { ctx->stack_frame_size = 0; - ctx->stack_frame_alignment = 0; ctx->call_stack_size = 0; ctx->used_preserved_regs = 0; ir_allocate_unique_spill_slots(ctx); @@ -11099,7 +11298,6 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) } ctx->stack_frame_size = ctx->fixed_stack_frame_size; ctx->call_stack_size = ctx->fixed_call_stack_size; - ctx->stack_frame_alignment = 0; } Dst = &data.dasm_state; @@ -11420,6 +11618,35 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) case IR_TAILCALL: ir_emit_tailcall(ctx, i, insn); break; + case IR_IGOTO_DUP: + if (bb->flags & IR_BB_DESSA_MOVES) { + ir_emit_dessa_moves(ctx, b, bb); + } + IR_ASSERT(!igoto_dup_ref && !igoto_dup_block); + igoto_dup_ref = i; + igoto_dup_block = b; + b = ctx->cfg_edges[bb->successors]; + bb = &ctx->cfg_blocks[b]; + i = bb->start; + insn = &ctx->ir_base[i]; + rule = &ctx->rules[i]; + break; + case IR_IGOTO: + if ((ctx->ir_base[insn->op1].op == IR_MERGE || ctx->ir_base[insn->op1].op == IR_LOOP_BEGIN) + && (ctx->rules[ctx->ir_base[insn->op1].op1] & IR_RULE_MASK) == IR_IGOTO_DUP + && igoto_dup_ref) { + ir_emit_ijmp(ctx, i, insn); + b = igoto_dup_block; + bb = &ctx->cfg_blocks[b]; + i = igoto_dup_ref; + insn = &ctx->ir_base[i]; + rule = &ctx->rules[i]; + igoto_dup_block= 0; + igoto_dup_ref = 0; + break; + } + IR_ASSERT(!igoto_dup_ref && !igoto_dup_block); + IR_FALLTHROUGH; case IR_IJMP: ir_emit_ijmp(ctx, i, insn); break; @@ -11449,6 +11676,7 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) ir_emit_vaddr(ctx, i, insn); break; case IR_VLOAD: + case IR_VLOAD_v: ir_emit_vload(ctx, i, insn); break; case IR_VSTORE_INT: @@ -11691,6 +11919,28 @@ next_block:; } while (i != 0); } + if ((ctx->flags2 & IR_HAS_BLOCK_ADDR) && ctx->loader && ctx->loader->add_label) { + for (b = 1, bb = &ctx->cfg_blocks[b]; b <= ctx->cfg_blocks_count; bb++, b++) { + ir_insn *insn = &ctx->ir_base[bb->start]; + + if (insn->op == IR_BEGIN && insn->op2) { + IR_ASSERT(ctx->ir_base[insn->op2].op == IR_LABEL); + ctx->ir_base[insn->op2].val.u32_hi = 0; + ctx->loader->add_label(ctx->loader, ir_get_str(ctx, ctx->ir_base[insn->op2].val.str), + (char*)entry + dasm_getpclabel(&data.dasm_state, ir_skip_empty_target_blocks(ctx, b))); + } + } + } else if (data.resolved_label_syms) { + for (b = 1, bb = &ctx->cfg_blocks[b]; b <= ctx->cfg_blocks_count; bb++, b++) { + ir_insn *insn = &ctx->ir_base[bb->start]; + + if (insn->op == IR_BEGIN && insn->op2) { + IR_ASSERT(ctx->ir_base[insn->op2].op == IR_LABEL); + ctx->ir_base[insn->op2].val.u32_hi = 0; + } + } + } + dasm_free(&data.dasm_state); ir_mem_flush(entry, size); diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 00888b8b64020..3ffb669e84742 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -106,7 +106,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV zend_runtime_jit(Z static int zend_jit_trace_op_len(const zend_op *opline); static int zend_jit_trace_may_exit(const zend_op_array *op_array, const zend_op *opline); -static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags); +static uint32_t _zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags ZEND_FILE_LINE_DC); +#define zend_jit_trace_get_exit_point(to_opline, flags) _zend_jit_trace_get_exit_point(to_opline, flags ZEND_FILE_LINE_CC) static const void *zend_jit_trace_get_exit_addr(uint32_t n); 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); @@ -209,38 +210,38 @@ static int zend_jit_is_constant_cmp_long_long(const zend_op *opline, case ZEND_CASE: case ZEND_CASE_STRICT: if (op1_min == op1_max && op2_min == op2_max && op1_min == op2_min) { - *result = 1; + *result = true; return 1; } else if (op1_max < op2_min || op1_min > op2_max) { - *result = 0; + *result = false; return 1; } return 0; case ZEND_IS_NOT_EQUAL: case ZEND_IS_NOT_IDENTICAL: if (op1_min == op1_max && op2_min == op2_max && op1_min == op2_min) { - *result = 0; + *result = false; return 1; } else if (op1_max < op2_min || op1_min > op2_max) { - *result = 1; + *result = true; return 1; } return 0; case ZEND_IS_SMALLER: if (op1_max < op2_min) { - *result = 1; + *result = true; return 1; } else if (op1_min >= op2_max) { - *result = 0; + *result = false; return 1; } return 0; case ZEND_IS_SMALLER_OR_EQUAL: if (op1_max <= op2_min) { - *result = 1; + *result = true; return 1; } else if (op1_min > op2_max) { - *result = 0; + *result = false; return 1; } return 0; @@ -1237,13 +1238,13 @@ static void zend_jit_allocate_registers(zend_jit_ctx *ctx, const zend_op_array * ((ra[i].flags & ZREG_LOAD) || ((ra[i].flags & ZREG_STORE) && ssa->vars[i].definition >= 0)) && ssa->vars[i].use_chain < 0) { - bool may_remove = 1; + bool may_remove = true; zend_ssa_phi *phi = ssa->vars[i].phi_use_chain; while (phi) { if (ra[phi->ssa_var].ref && !(ra[phi->ssa_var].flags & ZREG_LOAD)) { - may_remove = 0; + may_remove = false; break; } phi = zend_ssa_next_use_phi(ssa, i, phi); @@ -1267,13 +1268,12 @@ static void zend_jit_allocate_registers(zend_jit_ctx *ctx, const zend_op_array * && ssa->vars[i].definition >= 0 && ssa->ops[op_num].result_def == i) { const zend_live_range *range = op_array->live_range; - int j; op_num++; if (op_array->opcodes[op_num].opcode == ZEND_OP_DATA) { op_num++; } - for (j = 0; j < op_array->last_live_range; range++, j++) { + for (uint32_t j = 0; j < op_array->last_live_range; range++, j++) { if (range->start > op_num) { /* further blocks will not be relevant... */ break; @@ -1298,13 +1298,13 @@ static void zend_jit_allocate_registers(zend_jit_ctx *ctx, const zend_op_array * && (ra[i].flags & ZREG_STORE) && (ssa->vars[i].use_chain < 0 || zend_ssa_next_use(ssa->ops, i, ssa->vars[i].use_chain) < 0)) { - bool may_remove = 1; + bool may_remove = true; zend_ssa_phi *phi = ssa->vars[i].phi_use_chain; while (phi) { if (ra[phi->ssa_var].ref && !(ra[phi->ssa_var].flags & ZREG_LOAD)) { - may_remove = 0; + may_remove = false; break; } phi = zend_ssa_next_use_phi(ssa, i, phi); @@ -1424,7 +1424,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op zend_vm_opcode_handler_t handler; int call_level = 0; void *checkpoint = NULL; - bool recv_emitted = 0; /* emitted at least one RECV opcode */ + bool recv_emitted = false; /* 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, op1_mem_info; @@ -1489,7 +1489,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op zend_jit_recv_entry(&ctx, b); } } - recv_emitted = 1; + recv_emitted = true; } else if (opline->opcode == ZEND_RECV) { if (!(op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS)) { /* skip */ @@ -1499,7 +1499,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op } else if (recv_emitted) { zend_jit_recv_entry(&ctx, b); } else { - recv_emitted = 1; + recv_emitted = true; } } else { if (recv_emitted) { @@ -1882,8 +1882,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op break; } ce = NULL; - ce_is_instanceof = 0; - on_this = 0; + ce_is_instanceof = false; + on_this = false; if (opline->op1_type == IS_UNUSED) { op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN; ce = op_array->scope; @@ -1892,7 +1892,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; - on_this = 1; + on_this = true; } else { op1_info = OP1_INFO(); if (!(op1_info & MAY_BE_OBJECT)) { @@ -1933,8 +1933,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op break; } ce = NULL; - ce_is_instanceof = 0; - on_this = 0; + ce_is_instanceof = false; + on_this = false; if (opline->op1_type == IS_UNUSED) { op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN; ce = op_array->scope; @@ -1943,7 +1943,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; - on_this = 1; + on_this = true; } else { op1_info = OP1_INFO(); if (!(op1_info & MAY_BE_OBJECT)) { @@ -1977,8 +1977,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op break; } ce = NULL; - ce_is_instanceof = 0; - on_this = 0; + ce_is_instanceof = false; + on_this = false; if (opline->op1_type == IS_UNUSED) { op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN; ce = op_array->scope; @@ -1987,7 +1987,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; - on_this = 1; + on_this = true; } else { op1_info = OP1_INFO(); if (!(op1_info & MAY_BE_OBJECT)) { @@ -2449,8 +2449,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op case ZEND_FETCH_OBJ_IS: case ZEND_FETCH_OBJ_W: ce = NULL; - ce_is_instanceof = 0; - on_this = 0; + ce_is_instanceof = false; + on_this = false; if (opline->op1_type == IS_UNUSED) { op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN; op1_addr = 0; @@ -2459,7 +2459,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (ce) { ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } - on_this = 1; + on_this = true; } else { op1_info = OP1_INFO(); if (!(op1_info & MAY_BE_OBJECT)) { @@ -2629,8 +2629,8 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op break; } ce = NULL; - ce_is_instanceof = 0; - on_this = 0; + ce_is_instanceof = false; + on_this = false; if (opline->op1_type == IS_UNUSED) { op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN; op1_addr = 0; @@ -2639,7 +2639,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (ce) { ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } - on_this = 1; + on_this = true; } else { op1_info = OP1_INFO(); if (!(op1_info & MAY_BE_OBJECT)) { @@ -2906,13 +2906,13 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (jit->return_inputs) { zend_jit_common_return(jit); - bool left_frame = 0; + bool left_frame = false; if (op_array->last_var > 100) { /* To many CVs to unroll */ if (!zend_jit_free_cvs(&ctx)) { goto jit_failure; } - left_frame = 1; + left_frame = true; } if (!left_frame) { int j; @@ -2922,7 +2922,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { if (!left_frame) { - left_frame = 1; + left_frame = true; if (!zend_jit_leave_frame(&ctx)) { goto jit_failure; } @@ -3920,12 +3920,12 @@ void zend_jit_deactivate(void) SHM_UNPROTECT(); zend_jit_unprotect(); - zend_jit_check_funcs(EG(function_table), 0); + zend_jit_check_funcs(EG(function_table), false); ZEND_HASH_MAP_REVERSE_FOREACH_PTR(EG(class_table), ce) { if (ce->type == ZEND_INTERNAL_CLASS) { break; } - zend_jit_check_funcs(&ce->function_table, 1); + zend_jit_check_funcs(&ce->function_table, true); } ZEND_HASH_FOREACH_END(); zend_jit_protect(); diff --git a/ext/opcache/jit/zend_jit.h b/ext/opcache/jit/zend_jit.h index 5e6b225676aa2..9b8e054d2292f 100644 --- a/ext/opcache/jit/zend_jit.h +++ b/ext/opcache/jit/zend_jit.h @@ -64,15 +64,16 @@ #define ZEND_JIT_DEBUG_SIZE (1<<9) #define ZEND_JIT_DEBUG_ASM_ADDR (1<<10) -#define ZEND_JIT_DEBUG_TRACE_START (1<<12) -#define ZEND_JIT_DEBUG_TRACE_STOP (1<<13) -#define ZEND_JIT_DEBUG_TRACE_COMPILED (1<<14) -#define ZEND_JIT_DEBUG_TRACE_EXIT (1<<15) -#define ZEND_JIT_DEBUG_TRACE_ABORT (1<<16) -#define ZEND_JIT_DEBUG_TRACE_BLACKLIST (1<<17) -#define ZEND_JIT_DEBUG_TRACE_BYTECODE (1<<18) -#define ZEND_JIT_DEBUG_TRACE_TSSA (1<<19) -#define ZEND_JIT_DEBUG_TRACE_EXIT_INFO (1<<20) +#define ZEND_JIT_DEBUG_TRACE_START (1<<12) +#define ZEND_JIT_DEBUG_TRACE_STOP (1<<13) +#define ZEND_JIT_DEBUG_TRACE_COMPILED (1<<14) +#define ZEND_JIT_DEBUG_TRACE_EXIT (1<<15) +#define ZEND_JIT_DEBUG_TRACE_ABORT (1<<16) +#define ZEND_JIT_DEBUG_TRACE_BLACKLIST (1<<17) +#define ZEND_JIT_DEBUG_TRACE_BYTECODE (1<<18) +#define ZEND_JIT_DEBUG_TRACE_TSSA (1<<19) +#define ZEND_JIT_DEBUG_TRACE_EXIT_INFO (1<<20) +#define ZEND_JIT_DEBUG_TRACE_EXIT_INFO_SRC (1<<21) #define ZEND_JIT_DEBUG_IR_SRC (1<<24) #define ZEND_JIT_DEBUG_IR_FINAL (1<<25) diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 787eb4d07a8b6..07f1b61c6b520 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1979,7 +1979,7 @@ static bool ZEND_FASTCALL zend_jit_verify_arg_slow(zval *arg, zend_arg_info *arg &arg_info->type, arg, /* ref */ NULL, /* is_return_type */ false); if (UNEXPECTED(!ret)) { zend_verify_arg_error(EX(func), arg_info, opline->op1.num, arg); - return 0; + return false; } return ret; } diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index 57c0dedb2fa2d..22bab1ddd7ffd 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -119,13 +119,13 @@ typedef uintptr_t zend_jit_addr; static zend_always_inline bool zend_jit_same_addr(zend_jit_addr addr1, zend_jit_addr addr2) { if (addr1 == addr2) { - return 1; + return true; } else if (Z_MODE(addr1) == IS_REG && Z_MODE(addr2) == IS_REG) { return Z_SSA_VAR(addr1) == Z_SSA_VAR(addr2); } else if (Z_MODE(addr1) == IS_REF_ZVAL && Z_MODE(addr2) == IS_REF_ZVAL) { return Z_IR_REF(addr1) == Z_IR_REF(addr2); } - return 0; + return false; } typedef struct _zend_jit_op_array_extension { @@ -456,6 +456,10 @@ typedef struct _zend_jit_trace_exit_info { uint32_t stack_offset; zend_jit_ref_snapshot poly_func; zend_jit_ref_snapshot poly_this; +#if ZEND_DEBUG + const char *filename; + int lineno; +#endif } zend_jit_trace_exit_info; typedef struct _zend_jit_trace_stack { @@ -702,7 +706,7 @@ static zend_always_inline const zend_op* zend_jit_trace_get_exit_opline(zend_jit } else { ZEND_UNREACHABLE(); } - *exit_if_true = 0; + *exit_if_true = false; return NULL; } diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index ec55239953aad..1c5cab899e783 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -199,7 +199,7 @@ static size_t zend_jit_trace_prologue_size = (size_t)-1; static uint32_t allowed_opt_flags = 0; static uint32_t default_mflags = 0; #endif -static bool delayed_call_chain = 0; // TODO: remove this var (use jit->delayed_call_level) ??? +static bool delayed_call_chain = false; // TODO: remove this var (use jit->delayed_call_level) ??? #ifdef ZTS static size_t tsrm_ls_cache_tcb_offset = 0; @@ -424,7 +424,7 @@ static bool zend_jit_set_veneer(ir_ctx *ctx, const void *addr, const void *venee uint32_t exit_point = zend_jit_exit_point_by_addr(addr); if (exit_point != (uint32_t)-1) { - return 1; + return true; } for (i = 0; i < count; i++) { if (zend_jit_stub_handlers[i] == addr) { @@ -449,11 +449,11 @@ static bool zend_jit_set_veneer(ir_ctx *ctx, const void *addr, const void *venee } } #endif - return 1; + return true; } } - return 0; + return false; } static void zend_jit_commit_veneers(void) @@ -472,7 +472,7 @@ static void zend_jit_commit_veneers(void) static bool zend_jit_prefer_const_addr_load(zend_jit_ctx *jit, uintptr_t addr) { #if defined(IR_TARGET_X86) - return 0; /* always use immediate value */ + return false; /* always use immediate value */ #elif defined(IR_TARGET_X64) return addr > 0xffffffff; /* prefer loading long constant from memery */ #elif defined(IR_TARGET_AARCH64) @@ -989,15 +989,15 @@ static void jit_LOAD_IP_ADDR(zend_jit_ctx *jit, const zend_op *target) static void zend_jit_track_last_valid_opline(zend_jit_ctx *jit) { - jit->use_last_valid_opline = 0; - jit->track_last_valid_opline = 1; + jit->use_last_valid_opline = false; + jit->track_last_valid_opline = true; } static void zend_jit_use_last_valid_opline(zend_jit_ctx *jit) { if (jit->track_last_valid_opline) { - jit->use_last_valid_opline = 1; - jit->track_last_valid_opline = 0; + jit->use_last_valid_opline = true; + jit->track_last_valid_opline = false; } } @@ -1009,21 +1009,21 @@ static bool zend_jit_trace_uses_initial_ip(zend_jit_ctx *jit) static void zend_jit_set_last_valid_opline(zend_jit_ctx *jit, const zend_op *opline) { if (!jit->reuse_ip) { - jit->track_last_valid_opline = 1; + jit->track_last_valid_opline = true; jit->last_valid_opline = opline; } } static void zend_jit_reset_last_valid_opline(zend_jit_ctx *jit) { - jit->track_last_valid_opline = 0; + jit->track_last_valid_opline = false; jit->last_valid_opline = NULL; } static void zend_jit_start_reuse_ip(zend_jit_ctx *jit) { zend_jit_reset_last_valid_opline(jit); - jit->reuse_ip = 1; + jit->reuse_ip = true; } static int zend_jit_reuse_ip(zend_jit_ctx *jit) @@ -1038,7 +1038,7 @@ static int zend_jit_reuse_ip(zend_jit_ctx *jit) static void zend_jit_stop_reuse_ip(zend_jit_ctx *jit) { - jit->reuse_ip = 0; + jit->reuse_ip = false; } static int zend_jit_save_call_chain(zend_jit_ctx *jit, uint32_t call_level) @@ -1062,7 +1062,7 @@ static int zend_jit_save_call_chain(zend_jit_ctx *jit, uint32_t call_level) ir_STORE(jit_EX(call), rx); jit->delayed_call_level = 0; - delayed_call_chain = 0; + delayed_call_chain = false; return 1; } @@ -1091,7 +1091,7 @@ static int zend_jit_set_ip(zend_jit_ctx *jit, const zend_op *target) } else { jit_STORE_IP(jit, ir_CONST_ADDR(target)); } - jit->reuse_ip = 0; + jit->reuse_ip = false; zend_jit_set_last_valid_opline(jit, target); return 1; } @@ -1309,7 +1309,7 @@ static bool zend_jit_spilling_may_cause_conflict(zend_jit_ctx *jit, int var, ir_ { if (jit->ctx.ir_base[val].op == IR_RLOAD) { /* Deoptimization */ - return 0; + return false; } // if (jit->ctx.ir_base[val].op == IR_LOAD // && jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op == IR_ADD @@ -1331,7 +1331,7 @@ static bool zend_jit_spilling_may_cause_conflict(zend_jit_ctx *jit, int var, ir_ && jit->ctx.ir_base[jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op2].val.addr != (uintptr_t)EX_NUM_TO_VAR(jit->ssa->vars[var].var) && EX_VAR_TO_NUM(jit->ctx.ir_base[jit->ctx.ir_base[jit->ctx.ir_base[val].op2].op2].val.addr) < jit->current_op_array->last_var) { /* binding between different CVs may cause spill conflict */ - return 1; + return true; } else if (jit->ssa->vars[var].definition >= 0 && jit->ssa->ops[jit->ssa->vars[var].definition].op1_def == var && jit->ssa->ops[jit->ssa->vars[var].definition].op1_use >= 0 @@ -1339,18 +1339,18 @@ static bool zend_jit_spilling_may_cause_conflict(zend_jit_ctx *jit, int var, ir_ && jit->ssa->vars[jit->ssa->ops[jit->ssa->vars[var].definition].op1_use].definition_phi && (jit->ssa->cfg.blocks[jit->ssa->vars[jit->ssa->ops[jit->ssa->vars[var].definition].op1_use].definition_phi->block].flags & ZEND_BB_LOOP_HEADER)) { /* Avoid moving spill store out of loop */ - return 1; + return true; } else if (jit->ssa->vars[var].definition >= 0 && jit->ssa->ops[jit->ssa->vars[var].definition].op1_def == var && jit->ssa->ops[jit->ssa->vars[var].definition].op1_use >= 0 && jit->ssa->ops[jit->ssa->vars[var].definition].op2_use >= 0 && jit->ra[jit->ssa->ops[jit->ssa->vars[var].definition].op2_use].ref == val) { /* Avoid spill conflict between of ASSIGN.op1_def and ASSIGN.op1_use */ - return 1; + return true; } - return 0; + return false; } - return 1; + return true; } static void zend_jit_def_reg(zend_jit_ctx *jit, zend_jit_addr addr, ir_ref val) @@ -1485,7 +1485,7 @@ static void zend_jit_gen_phi(zend_jit_ctx *jit, zend_ssa_phi *phi) ir_ref ref; ir_ref old_insns_count = jit->ctx.insns_count; ir_ref same_src_ref = IR_UNUSED; - bool phi_inputs_are_the_same = 1; + bool phi_inputs_are_the_same = true; ZEND_ASSERT(phi->pi < 0); ZEND_ASSERT(!(jit->ra[dst_var].flags & ZREG_LOAD)); @@ -1502,13 +1502,13 @@ static void zend_jit_gen_phi(zend_jit_ctx *jit, zend_ssa_phi *phi) ZEND_ASSERT(jit->ra[src_var].ref); if (jit->ra[src_var].ref == IR_NULL) { jit->ra[src_var].flags |= ZREG_FORWARD; - phi_inputs_are_the_same = 0; + phi_inputs_are_the_same = false; } else { ir_ref src_ref = zend_jit_use_reg(jit, ZEND_ADDR_REG(src_var)); if (i == 0) { same_src_ref = src_ref; } else if (same_src_ref != src_ref) { - phi_inputs_are_the_same = 0; + phi_inputs_are_the_same = false; } ir_set_op(&jit->ctx, ref, i + 2, src_ref); } @@ -1897,7 +1897,7 @@ static void jit_FREE_OP(zend_jit_ctx *jit, if (op_type & (IS_VAR|IS_TMP_VAR)) { jit_ZVAL_PTR_DTOR(jit, ZEND_ADDR_MEM_ZVAL(ZREG_FP, op.var), - op_info, 0, opline); + op_info, false, opline); } } @@ -2030,7 +2030,7 @@ static int zend_jit_exception_handler_free_op1_op2_stub(zend_jit_ctx *jit) } ref = ir_ADD_A(jit_FP(jit), ref); var_addr = ZEND_ADDR_REF_ZVAL(ref); - jit_ZVAL_PTR_DTOR(jit, var_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, 0, NULL); + jit_ZVAL_PTR_DTOR(jit, var_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, false, NULL); ir_MERGE_WITH_EMPTY_FALSE(if_dtor); ir_IJMP(jit_STUB_ADDR(jit, jit_stub_exception_handler_free_op2)); @@ -2053,7 +2053,7 @@ static int zend_jit_exception_handler_free_op2_stub(zend_jit_ctx *jit) } ref = ir_ADD_A(jit_FP(jit), ref); var_addr = ZEND_ADDR_REF_ZVAL(ref); - jit_ZVAL_PTR_DTOR(jit, var_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, 0, NULL); + jit_ZVAL_PTR_DTOR(jit, var_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, false, NULL); ir_MERGE_WITH_EMPTY_FALSE(if_dtor); ir_IJMP(jit_STUB_ADDR(jit, jit_stub_exception_handler_undef)); @@ -2236,7 +2236,7 @@ static int zend_jit_throw_cannot_pass_by_ref_stub(zend_jit_ctx *jit) ref = ir_ADD_A(jit_FP(jit), ref); jit_ZVAL_PTR_DTOR(jit, ZEND_ADDR_REF_ZVAL(ref), - MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, 0, NULL); + MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_REF, false, NULL); ir_MERGE_WITH_EMPTY_FALSE(if_tmp); ir_IJMP(jit_STUB_ADDR(jit, jit_stub_exception_handler)); @@ -2608,7 +2608,7 @@ static int zend_jit_assign_const_stub(zend_jit_ctx *jit) jit, NULL, var_addr, var_addr, -1, -1, IS_CONST, val_addr, val_info, - 0, 0, 0)) { + 0, 0, false)) { return 0; } ir_RETURN(IR_VOID); @@ -2628,7 +2628,7 @@ static int zend_jit_assign_tmp_stub(zend_jit_ctx *jit) jit, NULL, var_addr, var_addr, -1, -1, IS_TMP_VAR, val_addr, val_info, - 0, 0, 0)) { + 0, 0, false)) { return 0; } ir_RETURN(IR_VOID); @@ -2648,7 +2648,7 @@ static int zend_jit_assign_var_stub(zend_jit_ctx *jit) jit, NULL, var_addr, var_addr, -1, -1, IS_VAR, val_addr, val_info, - 0, 0, 0)) { + 0, 0, false)) { return 0; } ir_RETURN(IR_VOID); @@ -2668,7 +2668,7 @@ static int zend_jit_assign_cv_noref_stub(zend_jit_ctx *jit) jit, NULL, var_addr, var_addr, -1, -1, IS_CV, val_addr, val_info, - 0, 0, 0)) { + 0, 0, false)) { return 0; } ir_RETURN(IR_VOID); @@ -2700,7 +2700,7 @@ static int zend_jit_assign_cv_stub(zend_jit_ctx *jit) jit, NULL, var_addr, var_addr, -1, -1, IS_CV, val_addr, val_info, - 0, 0, 0)) { + 0, 0, false)) { return 0; } ir_RETURN(IR_VOID); @@ -2814,11 +2814,11 @@ static void zend_jit_init_ctx(zend_jit_ctx *jit, uint32_t flags) jit->ssa = NULL; jit->name = NULL; jit->last_valid_opline = NULL; - jit->use_last_valid_opline = 0; - jit->track_last_valid_opline = 0; - jit->reuse_ip = 0; + jit->use_last_valid_opline = false; + jit->track_last_valid_opline = false; + jit->reuse_ip = false; jit->delayed_call_level = 0; - delayed_call_chain = 0; + delayed_call_chain = false; jit->b = -1; #ifdef ZTS jit->tls = IR_UNUSED; @@ -3670,7 +3670,7 @@ static void zend_jit_case_start(zend_jit_ctx *jit, int switch_b, int case_b, ir_ int default_b = jit->ssa->cfg.map[default_opline - jit->op_array->opcodes]; zval *zv; ir_ref list = IR_UNUSED, idx; - bool first = 1; + bool first = true; ZEND_HASH_FOREACH_VAL(jumptable, zv) { const zend_op *target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(zv)); @@ -3686,7 +3686,7 @@ static void zend_jit_case_start(zend_jit_ctx *jit, int switch_b, int case_b, ir_ idx = ir_CONST_LONG((Bucket*)zv - jumptable->arData); } ir_CASE_VAL(switch_ref, idx); - first = 0; + first = false; } } ZEND_HASH_FOREACH_END(); if (default_b == case_b) { @@ -4509,7 +4509,7 @@ static int zend_jit_store_var_if_necessary(zend_jit_ctx *jit, int var, zend_jit_ { if (Z_MODE(src) == IS_REG && Z_STORE(src)) { zend_jit_addr dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var); - return zend_jit_spill_store(jit, src, dst, info, 1); + return zend_jit_spill_store(jit, src, dst, info, true); } return 1; } @@ -4518,7 +4518,7 @@ static int zend_jit_store_var_if_necessary_ex(zend_jit_ctx *jit, int var, zend_j { if (Z_MODE(src) == IS_REG && Z_STORE(src)) { zend_jit_addr dst = ZEND_ADDR_MEM_ZVAL(ZREG_FP, var); - bool set_type = 1; + bool set_type = true; if ((info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) == (old_info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF))) { @@ -4528,10 +4528,10 @@ static int zend_jit_store_var_if_necessary_ex(zend_jit_ctx *jit, int var, zend_j if (mem_type != IS_UNKNOWN && (info & (MAY_BE_ANY|MAY_BE_REF|MAY_BE_UNDEF)) == (1 << mem_type)) { - set_type = 0; + set_type = false; } } else { - set_type = 0; + set_type = false; } } } @@ -4982,7 +4982,7 @@ static int zend_jit_inc_dec(zend_jit_ctx *jit, const zend_op *opline, uint32_t o jit_ZVAL_COPY(jit, res_addr, res_use_info, - ZEND_ADDR_REF_ZVAL(ref), op1_info, 1); + ZEND_ADDR_REF_ZVAL(ref), op1_info, true); } if (opline->opcode == ZEND_PRE_INC || opline->opcode == ZEND_POST_INC) { if (opline->opcode == ZEND_PRE_INC && opline->result_type != IS_UNUSED) { @@ -6273,16 +6273,16 @@ static int zend_jit_simple_assign(zend_jit_ctx *jit, jit_ZVAL_COPY_CONST(jit, var_addr, var_info, var_def_info, - zv, 1); + zv, true); } else { jit_ZVAL_COPY_CONST(jit, var_addr, var_info, var_def_info, - zv, 1); + zv, true); jit_ZVAL_COPY_CONST(jit, res_addr, -1, var_def_info, - zv, 1); + zv, true); } } else { if (val_info & MAY_BE_UNDEF) { @@ -6327,7 +6327,7 @@ static int zend_jit_simple_assign(zend_jit_ctx *jit, jit_ZVAL_COPY(jit, var_addr, var_info, - ZEND_ADDR_REF_ZVAL(ref2), val_info, 1); + ZEND_ADDR_REF_ZVAL(ref2), val_info, true); } else { jit_ZVAL_COPY_2(jit, res_addr, @@ -6468,7 +6468,7 @@ static int zend_jit_assign_to_variable(zend_jit_ctx *jit, { ir_ref if_refcounted = IR_UNUSED; ir_ref simple_inputs = IR_UNUSED; - bool done = 0; + bool done = false; zend_jit_addr real_res_addr = 0; ir_refs *end_inputs; ir_refs *res_inputs; @@ -6578,11 +6578,11 @@ static int zend_jit_assign_to_variable(zend_jit_ctx *jit, ir_END_list(simple_inputs); ir_IF_TRUE_cold(if_refcounted); } else if (RC_MAY_BE_1(var_info)) { - done = 1; + done = true; } ref = jit_Z_PTR(jit, var_use_addr); if (RC_MAY_BE_1(var_info)) { - if (!zend_jit_simple_assign(jit, opline, var_addr, var_info, var_def_info, val_type, val_addr, val_info, res_addr, 0)) { + if (!zend_jit_simple_assign(jit, opline, var_addr, var_info, var_def_info, val_type, val_addr, val_info, res_addr, false)) { return 0; } counter = jit_GC_DELREF(jit, ref); @@ -6700,7 +6700,7 @@ static int zend_jit_qm_assign(zend_jit_ctx *jit, const zend_op *opline, uint32_t } } - if (!zend_jit_simple_assign(jit, opline, res_addr, res_use_info, res_info, opline->op1_type, op1_addr, op1_info, 0, 1)) { + if (!zend_jit_simple_assign(jit, opline, res_addr, res_use_info, res_info, opline->op1_type, op1_addr, op1_info, 0, true)) { return 0; } if (!zend_jit_store_var_if_necessary(jit, opline->result.var, res_addr, res_info)) { @@ -7206,11 +7206,11 @@ static int zend_jit_cmp(zend_jit_ctx *jit, op1 = jit_ZVAL_ADDR(jit, op1_addr); if (opline->op1_type == IS_CV && (op1_info & MAY_BE_UNDEF)) { - op1 = zend_jit_zval_check_undef(jit, op1, opline->op1.var, NULL, 0); + op1 = zend_jit_zval_check_undef(jit, op1, opline->op1.var, NULL, false); } op2 = jit_ZVAL_ADDR(jit, op2_addr); if (opline->op2_type == IS_CV && (op2_info & MAY_BE_UNDEF)) { - op2 = zend_jit_zval_check_undef(jit, op2, opline->op2.var, NULL, 0); + op2 = zend_jit_zval_check_undef(jit, op2, opline->op2.var, NULL, false); } ref = ir_CALL_2(IR_I32, ir_CONST_FC_FUNC(zend_compare), op1, op2); if (opline->opcode != ZEND_CASE) { @@ -7303,34 +7303,34 @@ static int zend_jit_identical(zend_jit_ctx *jit, const void *exit_addr, bool skip_comparison) { - bool always_false = 0, always_true = 0; + bool always_false = false, always_true = false; ir_ref ref = IR_UNUSED; if (opline->op1_type == IS_CV && (op1_info & MAY_BE_UNDEF)) { ir_ref op1 = jit_ZVAL_ADDR(jit, op1_addr); - op1 = zend_jit_zval_check_undef(jit, op1, opline->op1.var, opline, 0); + op1 = zend_jit_zval_check_undef(jit, op1, opline->op1.var, opline, false); op1_info |= MAY_BE_NULL; op1_addr = ZEND_ADDR_REF_ZVAL(op1); } if (opline->op2_type == IS_CV && (op2_info & MAY_BE_UNDEF)) { ir_ref op2 = jit_ZVAL_ADDR(jit, op2_addr); - op2 = zend_jit_zval_check_undef(jit, op2, opline->op2.var, opline, 0); + op2 = zend_jit_zval_check_undef(jit, op2, opline->op2.var, opline, false); op2_info |= MAY_BE_NULL; op2_addr = ZEND_ADDR_REF_ZVAL(op2); } if ((op1_info & op2_info & MAY_BE_ANY) == 0) { - always_false = 1; + always_false = true; } else if (has_concrete_type(op1_info) && has_concrete_type(op2_info) && concrete_type(op1_info) == concrete_type(op2_info) && concrete_type(op1_info) <= IS_TRUE) { - always_true = 1; + always_true = true; } else if (Z_MODE(op1_addr) == IS_CONST_ZVAL && Z_MODE(op2_addr) == IS_CONST_ZVAL) { if (zend_is_identical(Z_ZV(op1_addr), Z_ZV(op2_addr))) { - always_true = 1; + always_true = true; } else { - always_false = 1; + always_false = true; } } @@ -7532,17 +7532,17 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32 { uint32_t true_label = -1; uint32_t false_label = -1; - bool set_bool = 0; - bool set_bool_not = 0; - bool always_true = 0, always_false = 0; + bool set_bool = false; + bool set_bool_not = false; + bool always_true = false, always_false = false; ir_ref ref, end_inputs = IR_UNUSED, true_inputs = IR_UNUSED, false_inputs = IR_UNUSED; ir_type type = IR_UNUSED; if (branch_opcode == ZEND_BOOL) { - set_bool = 1; + set_bool = true; } else if (branch_opcode == ZEND_BOOL_NOT) { - set_bool = 1; - set_bool_not = 1; + set_bool = true; + set_bool_not = true; } else if (branch_opcode == ZEND_JMPZ) { true_label = target_label2; false_label = target_label; @@ -7550,11 +7550,11 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32 true_label = target_label; false_label = target_label2; } else if (branch_opcode == ZEND_JMPZ_EX) { - set_bool = 1; + set_bool = true; true_label = target_label2; false_label = target_label; } else if (branch_opcode == ZEND_JMPNZ_EX) { - set_bool = 1; + set_bool = true; true_label = target_label; false_label = target_label2; } else { @@ -7571,19 +7571,19 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32 /* NAN Value must cause a warning to be emitted */ && (Z_TYPE_P(Z_ZV(op1_addr)) != IS_DOUBLE || !zend_isnan(Z_DVAL_P(Z_ZV(op1_addr))))) { if (zend_is_true(Z_ZV(op1_addr))) { - always_true = 1; + always_true = true; } else { - always_false = 1; + always_false = true; } } else if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE)) { if (!(op1_info & ((MAY_BE_UNDEF|MAY_BE_ANY)-MAY_BE_TRUE))) { - always_true = 1; + always_true = true; } else if (!(op1_info & (MAY_BE_ANY-(MAY_BE_NULL|MAY_BE_FALSE)))) { if (opline->op1_type == IS_CV && (op1_info & MAY_BE_UNDEF)) { ref = jit_ZVAL_ADDR(jit, op1_addr); - zend_jit_zval_check_undef(jit, ref, opline->op1.var, opline, 0); + zend_jit_zval_check_undef(jit, ref, opline->op1.var, opline, false); } - always_false = 1; + always_false = true; } } @@ -7628,7 +7628,7 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32 zend_jit_type_check_undef(jit, type, opline->op1.var, - opline, 1, 0, 1); + opline, true, false, true); } if (set_bool) { jit_set_Z_TYPE_INFO(jit, res_addr, set_bool_not ? IS_TRUE : IS_FALSE); @@ -7985,7 +7985,7 @@ static int zend_jit_restore_zval(zend_jit_ctx *jit, int var, int8_t reg) zend_jit_addr reg_addr = ZEND_ADDR_REF_ZVAL(zend_jit_deopt_rload(jit, IR_ADDR, reg)); // JIT: ZVAL_COPY_OR_DUP(EX_VAR(opline->result.var), &c->value); (no dup) - jit_ZVAL_COPY(jit, var_addr, MAY_BE_ANY, reg_addr, MAY_BE_ANY, 1); + jit_ZVAL_COPY(jit, var_addr, MAY_BE_ANY, reg_addr, MAY_BE_ANY, true); return 1; } @@ -8122,7 +8122,7 @@ static int zend_jit_fetch_constant(zend_jit_ctx *jit, uint8_t type = concrete_type(res_info); zend_jit_addr const_addr = ZEND_ADDR_REF_ZVAL(ref); - const_addr = zend_jit_guard_fetch_result_type(jit, opline, const_addr, type, 0, 0, 0); + const_addr = zend_jit_guard_fetch_result_type(jit, opline, const_addr, type, false, 0, false); if (!const_addr) { return 0; } @@ -8131,7 +8131,7 @@ static int zend_jit_fetch_constant(zend_jit_ctx *jit, ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD; // JIT: ZVAL_COPY_OR_DUP(EX_VAR(opline->result.var), &c->value); (no dup) - jit_ZVAL_COPY(jit, res_addr, MAY_BE_ANY, const_addr, res_info, 1); + jit_ZVAL_COPY(jit, res_addr, MAY_BE_ANY, const_addr, res_info, true); if (!zend_jit_store_var_if_necessary(jit, opline->result.var, res_addr, res_info)) { return 0; } @@ -8139,7 +8139,7 @@ static int zend_jit_fetch_constant(zend_jit_ctx *jit, ir_ref const_addr = ZEND_ADDR_REF_ZVAL(ref); // JIT: ZVAL_COPY_OR_DUP(EX_VAR(opline->result.var), &c->value); (no dup) - jit_ZVAL_COPY(jit, res_addr, MAY_BE_ANY, const_addr, MAY_BE_ANY, 1); + jit_ZVAL_COPY(jit, res_addr, MAY_BE_ANY, const_addr, MAY_BE_ANY, true); } @@ -8250,7 +8250,7 @@ static int zend_jit_type_check(zend_jit_ctx *jit, const zend_op *opline, uint32_ } } else { ir_ref ref; - bool invert = 0; + bool invert = false; uint8_t type; switch (mask) { @@ -8262,15 +8262,15 @@ static int zend_jit_type_check(zend_jit_ctx *jit, const zend_op *opline, uint32_ case MAY_BE_STRING: type = IS_STRING; break; case MAY_BE_ARRAY: type = IS_ARRAY; break; case MAY_BE_OBJECT: type = IS_OBJECT; break; - case MAY_BE_ANY - MAY_BE_NULL: type = IS_NULL; invert = 1; break; - case MAY_BE_ANY - MAY_BE_FALSE: type = IS_FALSE; invert = 1; break; - case MAY_BE_ANY - MAY_BE_TRUE: type = IS_TRUE; invert = 1; break; - case MAY_BE_ANY - MAY_BE_LONG: type = IS_LONG; invert = 1; break; - case MAY_BE_ANY - MAY_BE_DOUBLE: type = IS_DOUBLE; invert = 1; break; - case MAY_BE_ANY - MAY_BE_STRING: type = IS_STRING; invert = 1; break; - case MAY_BE_ANY - MAY_BE_ARRAY: type = IS_ARRAY; invert = 1; break; - case MAY_BE_ANY - MAY_BE_OBJECT: type = IS_OBJECT; invert = 1; break; - case MAY_BE_ANY - MAY_BE_RESOURCE: type = IS_OBJECT; invert = 1; break; + case MAY_BE_ANY - MAY_BE_NULL: type = IS_NULL; invert = true; break; + case MAY_BE_ANY - MAY_BE_FALSE: type = IS_FALSE; invert = true; break; + case MAY_BE_ANY - MAY_BE_TRUE: type = IS_TRUE; invert = true; break; + case MAY_BE_ANY - MAY_BE_LONG: type = IS_LONG; invert = true; break; + case MAY_BE_ANY - MAY_BE_DOUBLE: type = IS_DOUBLE; invert = true; break; + case MAY_BE_ANY - MAY_BE_STRING: type = IS_STRING; invert = true; break; + case MAY_BE_ANY - MAY_BE_ARRAY: type = IS_ARRAY; invert = true; break; + case MAY_BE_ANY - MAY_BE_OBJECT: type = IS_OBJECT; invert = true; break; + case MAY_BE_ANY - MAY_BE_RESOURCE: type = IS_OBJECT; invert = true; break; default: type = 0; } @@ -8454,14 +8454,14 @@ static int zend_jit_push_call_frame(zend_jit_ctx *jit, const zend_op *opline, co { uint32_t used_stack; ir_ref used_stack_ref = IR_UNUSED; - bool stack_check = 1; + bool stack_check = true; ir_ref rx, ref, top, if_enough_stack, cold_path = IR_UNUSED; ZEND_ASSERT(func_ref != IR_NULL); if (func) { used_stack = zend_vm_calc_used_stack(opline->extended_value, func); if ((int)used_stack <= checked_stack) { - stack_check = 0; + stack_check = false; } used_stack_ref = ir_CONST_ADDR(used_stack); } else { @@ -8890,7 +8890,7 @@ jit_SET_EX_OPLINE(jit, opline); func_ref = ir_PHI_2(IR_ADDR, ref, func_ref); } - if (!zend_jit_push_call_frame(jit, opline, op_array, func, 0, 0, checked_stack, func_ref, IR_UNUSED)) { + if (!zend_jit_push_call_frame(jit, opline, op_array, func, false, false, checked_stack, func_ref, IR_UNUSED)) { return 0; } @@ -8901,7 +8901,7 @@ jit_SET_EX_OPLINE(jit, opline); } else { ZEND_ASSERT(call_level > 0); jit->delayed_call_level = call_level; - delayed_call_chain = 1; + delayed_call_chain = true; } if (trace @@ -9149,7 +9149,7 @@ static int zend_jit_init_method_call(zend_jit_ctx *jit, } if (!func || (func->common.fn_flags & ZEND_ACC_STATIC) == 0) { - if (!zend_jit_push_call_frame(jit, opline, NULL, func, 0, delayed_fetch_this, checked_stack, func_ref, this_ref)) { + if (!zend_jit_push_call_frame(jit, opline, NULL, func, false, delayed_fetch_this, checked_stack, func_ref, this_ref)) { return 0; } } @@ -9165,7 +9165,7 @@ static int zend_jit_init_method_call(zend_jit_ctx *jit, } } else { ZEND_ASSERT(call_level > 0); - delayed_call_chain = 1; + delayed_call_chain = true; jit->delayed_call_level = call_level; } @@ -9327,7 +9327,7 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit, scope_ref = ir_LOAD_A(ir_ADD_OFFSET(ir_LOAD_A(jit_EX(This.value.ref)), offsetof(zend_object, ce))); } } - if (!zend_jit_push_call_frame(jit, opline, op_array, func, 0, 0, checked_stack, func_ref, scope_ref)) { + if (!zend_jit_push_call_frame(jit, opline, op_array, func, false, false, checked_stack, func_ref, scope_ref)) { return 0; } @@ -9344,7 +9344,7 @@ static int zend_jit_init_static_method_call(zend_jit_ctx *jit, } else { ZEND_ASSERT(call_level > 0); jit->delayed_call_level = call_level; - delayed_call_chain = 1; + delayed_call_chain = true; } if (trace @@ -9425,7 +9425,7 @@ static int zend_jit_init_closure_call(zend_jit_ctx *jit, } } - if (!zend_jit_push_call_frame(jit, opline, NULL, func, 1, 0, checked_stack, ref, IR_UNUSED)) { + if (!zend_jit_push_call_frame(jit, opline, NULL, func, true, false, checked_stack, ref, IR_UNUSED)) { return 0; } @@ -9435,7 +9435,7 @@ static int zend_jit_init_closure_call(zend_jit_ctx *jit, } } else { ZEND_ASSERT(call_level > 0); - delayed_call_chain = 1; + delayed_call_chain = true; jit->delayed_call_level = call_level; } @@ -9513,12 +9513,12 @@ static int zend_jit_send_val(zend_jit_ctx *jit, const zend_op *opline, uint32_t jit_ZVAL_COPY_CONST(jit, arg_addr, MAY_BE_ANY, MAY_BE_ANY, - zv, 1); + zv, true); } else { jit_ZVAL_COPY(jit, arg_addr, MAY_BE_ANY, - op1_addr, op1_info, 0); + op1_addr, op1_info, false); } return 1; @@ -9592,7 +9592,7 @@ static int zend_jit_send_ref(zend_jit_ctx *jit, const zend_op *opline, const zen jit_ZVAL_COPY(jit, ref_addr, MAY_BE_ANY, - op1_addr, op1_info, 0); + op1_addr, op1_info, false); // JIT: ZVAL_REFERENCE(arg, ref) jit_set_Z_PTR(jit, op1_addr, ref); @@ -9666,7 +9666,7 @@ static int zend_jit_send_var(zend_jit_ctx *jit, const zend_op *opline, const zen jit_ZVAL_COPY(jit, arg_addr, MAY_BE_ANY, - op1_addr, op1_info, 0); + op1_addr, op1_info, false); if (!ARG_MAY_BE_SENT_BY_REF(JIT_G(current_frame)->call->func, arg_num)) { if (!(op1_info & MAY_BE_REF)) { @@ -9703,7 +9703,7 @@ static int zend_jit_send_var(zend_jit_ctx *jit, const zend_op *opline, const zen jit_ZVAL_COPY(jit, arg_addr, MAY_BE_ANY, - op1_addr, op1_info, 0); + op1_addr, op1_info, false); if (op1_info & MAY_BE_REF) { ir_ref if_ref = jit_if_Z_TYPE(jit, arg_addr, IS_REFERENCE); @@ -9800,7 +9800,7 @@ static int zend_jit_send_var(zend_jit_ctx *jit, const zend_op *opline, const zen jit_ZVAL_COPY(jit, arg_addr, MAY_BE_ANY, - op1_addr, op1_info, 0); + op1_addr, op1_info, false); if (op1_info & MAY_BE_REF) { // JIT: if (Z_TYPE_P(arg) == IS_REFERENCE) ir_ref if_ref = jit_if_Z_TYPE(jit, arg_addr, IS_REFERENCE); @@ -9835,7 +9835,7 @@ static int zend_jit_send_var(zend_jit_ctx *jit, const zend_op *opline, const zen jit_ZVAL_COPY(jit, arg_addr, MAY_BE_ANY, - op1_addr, op1_info, 1); + op1_addr, op1_info, true); } else { ir_ref if_ref, ref, ref2, refcount, if_not_zero, if_refcounted; zend_jit_addr ref_addr; @@ -9853,7 +9853,7 @@ static int zend_jit_send_var(zend_jit_ctx *jit, const zend_op *opline, const zen jit_ZVAL_COPY(jit, arg_addr, MAY_BE_ANY, - ref_addr, op1_info, 0); + ref_addr, op1_info, false); // JIT: if (GC_DELREF(ref) != 0) refcount = jit_GC_DELREF(jit, ref); @@ -9881,7 +9881,7 @@ static int zend_jit_send_var(zend_jit_ctx *jit, const zend_op *opline, const zen jit_ZVAL_COPY(jit, arg_addr, MAY_BE_ANY, - op1_addr, op1_info, 0); + op1_addr, op1_info, false); } } else { if (op1_addr != op1_def_addr) { @@ -10007,7 +10007,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen const zend_function *func = NULL; uint32_t i; uint32_t call_num_args = 0; - bool unknown_num_args = 0; + bool unknown_num_args = false; const void *exit_addr = NULL; const zend_op *prev_opline; ir_ref rx, func_ref = IR_UNUSED, if_user = IR_UNUSED, user_path = IR_UNUSED; @@ -10018,7 +10018,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen } if (prev_opline->opcode == ZEND_SEND_UNPACK || prev_opline->opcode == ZEND_SEND_ARRAY || prev_opline->opcode == ZEND_CHECK_UNDEF_ARGS) { - unknown_num_args = 1; + unknown_num_args = true; } if (info) { @@ -10059,7 +10059,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen TRACE_FRAME_NUM_ARGS(JIT_G(current_frame)->call) >= 0) { call_num_args = TRACE_FRAME_NUM_ARGS(JIT_G(current_frame)->call); } else { - unknown_num_args = 1; + unknown_num_args = true; } #endif } else if (trace->op == ZEND_JIT_TRACE_ENTER) { @@ -10071,7 +10071,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen TRACE_FRAME_NUM_ARGS(JIT_G(current_frame)->call) >= 0) { call_num_args = TRACE_FRAME_NUM_ARGS(JIT_G(current_frame)->call); } else { - unknown_num_args = 1; + unknown_num_args = true; } } } @@ -10116,7 +10116,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen ir_STORE(jit_EX(call), (call_level == 1) ? IR_NULL : ir_LOAD_A(jit_CALL(rx, prev_execute_data))); } - delayed_call_chain = 0; + delayed_call_chain = false; jit->delayed_call_level = 0; // JIT: call->prev_execute_data = execute_data; @@ -10184,7 +10184,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen if ((!func || func->type == ZEND_USER_FUNCTION) && opline->opcode != ZEND_DO_ICALL) { - bool recursive_call_through_jmp = 0; + bool recursive_call_through_jmp = false; uint32_t num_args = 0; // JIT: EX(call) = NULL; @@ -10276,7 +10276,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen if (!trace && op_array == &func->op_array && call_num_args >= op_array->required_num_args) { /* recursive call */ - recursive_call_through_jmp = 1; + recursive_call_through_jmp = true; } } } else { @@ -10593,7 +10593,8 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen uint32_t offset = EX_NUM_TO_VAR(i); zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_RX, offset); - jit_ZVAL_PTR_DTOR(jit, var_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN, 0, opline); + jit_ZVAL_PTR_DTOR(jit, var_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN, false, + opline); } } } else { @@ -10680,7 +10681,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen #endif } res_addr = ZEND_ADDR_REF_ZVAL(sp); - jit_ZVAL_PTR_DTOR(jit, res_addr, func_info, 1, opline); + jit_ZVAL_PTR_DTOR(jit, res_addr, func_info, true, opline); } if (!jit->ctx.fixed_call_stack_size) { // JIT: revert alloca @@ -10863,7 +10864,7 @@ static int zend_jit_recv(zend_jit_ctx *jit, const zend_op *opline, const zend_op } if (arg_info) { - if (!zend_jit_verify_arg_type(jit, opline, arg_info, 1)) { + if (!zend_jit_verify_arg_type(jit, opline, arg_info, true)) { return 0; } } @@ -10885,7 +10886,7 @@ static int zend_jit_recv_init(zend_jit_ctx *jit, const zend_op *opline, const ze jit_ZVAL_COPY_CONST(jit, res_addr, -1, -1, - zv, 1); + zv, true); } } else { if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || @@ -10898,7 +10899,7 @@ static int zend_jit_recv_init(zend_jit_ctx *jit, const zend_op *opline, const ze jit_ZVAL_COPY_CONST(jit, res_addr, -1, -1, - zv, 1); + zv, true); } if (Z_CONSTANT_P(zv)) { @@ -10909,7 +10910,7 @@ static int zend_jit_recv_init(zend_jit_ctx *jit, const zend_op *opline, const ze if_fail = ir_IF(ref); ir_IF_TRUE_cold(if_fail); - jit_ZVAL_PTR_DTOR(jit, res_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN, 1, opline); + jit_ZVAL_PTR_DTOR(jit, res_addr, MAY_BE_ANY|MAY_BE_RC1|MAY_BE_RCN, true, opline); ir_IJMP(jit_STUB_ADDR(jit, jit_stub_exception_handler)); ir_IF_FALSE(if_fail); } @@ -10946,7 +10947,7 @@ static bool zend_jit_verify_return_type(zend_jit_ctx *jit, const zend_op *opline zend_arg_info *arg_info = &op_array->arg_info[-1]; ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type)); zend_jit_addr op1_addr = OP1_ADDR(); - bool needs_slow_check = 1; + bool needs_slow_check = true; uint32_t type_mask = ZEND_TYPE_PURE_MASK(arg_info->type) & MAY_BE_ANY; ir_ref fast_path = IR_UNUSED; @@ -10954,7 +10955,7 @@ static bool zend_jit_verify_return_type(zend_jit_ctx *jit, const zend_op *opline if (((op1_info & MAY_BE_ANY) & type_mask) == 0) { /* pass */ } else if (((op1_info & MAY_BE_ANY) | type_mask) == type_mask) { - needs_slow_check = 0; + needs_slow_check = false; } else if (is_power_of_two(type_mask)) { uint32_t type_code = concrete_type(type_mask); ir_ref if_ok = jit_if_Z_TYPE(jit, op1_addr, type_code); @@ -10978,7 +10979,7 @@ static bool zend_jit_verify_return_type(zend_jit_ctx *jit, const zend_op *opline jit_SET_EX_OPLINE(jit, opline); ref = jit_ZVAL_ADDR(jit, op1_addr); if (op1_info & MAY_BE_UNDEF) { - ref = zend_jit_zval_check_undef(jit, ref, opline->op1.var, NULL, 1); + ref = zend_jit_zval_check_undef(jit, ref, opline->op1.var, NULL, true); } ir_CALL_3(IR_VOID, ir_CONST_FC_FUNC(zend_jit_verify_return_slow), @@ -10993,7 +10994,7 @@ static bool zend_jit_verify_return_type(zend_jit_ctx *jit, const zend_op *opline } } - return 1; + return true; } static int zend_jit_leave_frame(zend_jit_ctx *jit) @@ -11018,7 +11019,7 @@ static int zend_jit_free_cv(zend_jit_ctx *jit, uint32_t info, uint32_t var) if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { zend_jit_addr var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, EX_NUM_TO_VAR(var)); - jit_ZVAL_PTR_DTOR(jit, var_addr, info, 1, NULL); + jit_ZVAL_PTR_DTOR(jit, var_addr, info, true, NULL); } return 1; } @@ -11026,7 +11027,7 @@ static int zend_jit_free_cv(zend_jit_ctx *jit, uint32_t info, uint32_t var) static int zend_jit_free_op(zend_jit_ctx *jit, const zend_op *opline, uint32_t info, uint32_t var_offset) { if (info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) { - jit_ZVAL_PTR_DTOR(jit, ZEND_ADDR_MEM_ZVAL(ZREG_FP, var_offset), info, 0, opline); + jit_ZVAL_PTR_DTOR(jit, ZEND_ADDR_MEM_ZVAL(ZREG_FP, var_offset), info, false, opline); } return 1; } @@ -11065,7 +11066,7 @@ static int zend_jit_leave_func(zend_jit_ctx *jit, if (may_need_call_helper) { if (!left_frame) { - left_frame = 1; + left_frame = true; if (!zend_jit_leave_frame(jit)) { return 0; } @@ -11113,7 +11114,7 @@ static int zend_jit_leave_func(zend_jit_ctx *jit, if ((op_array->fn_flags & (ZEND_ACC_CLOSURE|ZEND_ACC_FAKE_CLOSURE)) == ZEND_ACC_CLOSURE) { if (!left_frame) { - left_frame = 1; + left_frame = true; if (!zend_jit_leave_frame(jit)) { return 0; } @@ -11124,7 +11125,7 @@ static int zend_jit_leave_func(zend_jit_ctx *jit, ir_ref if_release, fast_path = IR_UNUSED; if (!left_frame) { - left_frame = 1; + left_frame = true; if (!zend_jit_leave_frame(jit)) { return 0; } @@ -11350,9 +11351,9 @@ static int zend_jit_return(zend_jit_ctx *jit, const zend_op *opline, const zend_ if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - jit_ZVAL_COPY_CONST(jit, ret_addr, MAY_BE_ANY, MAY_BE_ANY, zv, 1); + jit_ZVAL_COPY_CONST(jit, ret_addr, MAY_BE_ANY, MAY_BE_ANY, zv, true); } else if (opline->op1_type == IS_TMP_VAR) { - jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, 0); + jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, false); } else if (opline->op1_type == IS_CV) { if (op1_info & MAY_BE_REF) { ref = jit_ZVAL_ADDR(jit, op1_addr); @@ -11364,16 +11365,16 @@ static int zend_jit_return(zend_jit_ctx *jit, const zend_op *opline, const zend_ if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || (op1_info & (MAY_BE_REF|MAY_BE_OBJECT)) || !op_array->function_name) { - jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, 1); + jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, true); } else if (return_value_used != 1) { - jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, 0); + jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, false); // JIT: if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) ZVAL_NULL(retval_ptr); jit_set_Z_TYPE_INFO(jit, op1_addr, IS_NULL); } else { - jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, 0); + jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, false); } } else { - jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, 0); + jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, false); } } else { if (op1_info & MAY_BE_REF) { @@ -11389,7 +11390,7 @@ static int zend_jit_return(zend_jit_ctx *jit, const zend_op *opline, const zend_ // JIT: ZVAL_COPY_VALUE(return_value, &ref->value) ref2 = ir_ADD_OFFSET(ref, offsetof(zend_reference, val)); ref_addr = ZEND_ADDR_REF_ZVAL(ref2); - jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, ref_addr, op1_info, 0); + jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, ref_addr, op1_info, false); ref2 = jit_GC_DELREF(jit, ref); if_non_zero = ir_IF(ref2); ir_IF_TRUE(if_non_zero); @@ -11412,7 +11413,7 @@ static int zend_jit_return(zend_jit_ctx *jit, const zend_op *opline, const zend_ ir_IF_FALSE(if_ref); } - jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, 0); + jit_ZVAL_COPY(jit, ret_addr, MAY_BE_ANY, op1_addr, op1_info, false); } if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) { @@ -11568,7 +11569,7 @@ static int zend_jit_free(zend_jit_ctx *jit, const zend_op *opline, uint32_t op1_ ir_MERGE_list(end_inputs); } - jit_ZVAL_PTR_DTOR(jit, op1_addr, op1_info, 0, opline); + jit_ZVAL_PTR_DTOR(jit, op1_addr, op1_info, false, opline); if (may_throw) { zend_jit_check_exception(jit); @@ -11611,7 +11612,7 @@ static int zend_jit_echo(zend_jit_ctx *jit, const zend_op *opline, uint32_t op1_ ir_LOAD_A(ir_ADD_OFFSET(ref, offsetof(zend_string, len)))); if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) { - jit_ZVAL_PTR_DTOR(jit, op1_addr, op1_info, 0, opline); + jit_ZVAL_PTR_DTOR(jit, op1_addr, op1_info, false, opline); } zend_jit_check_exception(jit); @@ -11950,9 +11951,9 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit, } if (op2_info & MAY_BE_LONG) { - bool op2_loaded = 0; - bool packed_loaded = 0; - bool bad_packed_key = 0; + bool op2_loaded = false; + bool packed_loaded = false; + bool bad_packed_key = false; ir_ref if_packed = IS_UNDEF; ir_ref h = IR_UNUSED; ir_ref idx_not_found_inputs = IR_UNUSED; @@ -11981,7 +11982,7 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit, if (type == BP_VAR_W) { // JIT: hval = Z_LVAL_P(dim); h = jit_Z_LVAL(jit, op2_addr); - op2_loaded = 1; + op2_loaded = true; } if (op1_info & MAY_BE_ARRAY_PACKED) { zend_long val = -1; @@ -11989,23 +11990,23 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit, if (Z_MODE(op2_addr) == IS_CONST_ZVAL) { val = Z_LVAL_P(Z_ZV(op2_addr)); if (val >= 0 && val < HT_MAX_SIZE) { - packed_loaded = 1; + packed_loaded = true; } else { - bad_packed_key = 1; + bad_packed_key = true; } h = ir_CONST_LONG(val); } else { if (!op2_loaded) { // JIT: hval = Z_LVAL_P(dim); h = jit_Z_LVAL(jit, op2_addr); - op2_loaded = 1; + op2_loaded = true; } - packed_loaded = 1; + packed_loaded = true; } if (dim_type == IS_UNDEF && type == BP_VAR_W && packed_loaded) { /* don't generate "fast" code for packed array */ - packed_loaded = 0; + packed_loaded = false; } if (packed_loaded) { @@ -12076,7 +12077,7 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit, if (!op2_loaded) { // JIT: hval = Z_LVAL_P(dim); h = jit_Z_LVAL(jit, op2_addr); - op2_loaded = 1; + op2_loaded = true; } if (packed_loaded) { ref = ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(_zend_hash_index_find), ht_ref, h); @@ -12126,7 +12127,7 @@ static int zend_jit_fetch_dimension_address_inner(zend_jit_ctx *jit, if (!op2_loaded) { // JIT: hval = Z_LVAL_P(dim); h = jit_Z_LVAL(jit, op2_addr); - op2_loaded = 1; + op2_loaded = true; } if (packed_loaded) { ref = ir_CALL_2(IR_ADDR, ir_CONST_FC_FUNC(_zend_hash_index_find), ht_ref, h); @@ -12526,8 +12527,8 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit, zend_jit_addr orig_op1_addr; const void *exit_addr = NULL; const void *not_found_exit_addr = NULL; - bool result_type_guard = 0; - bool result_avoid_refcounting = 0; + bool result_type_guard = false; + bool result_avoid_refcounting = false; uint32_t may_be_string = (opline->opcode != ZEND_FETCH_LIST_R) ? MAY_BE_STRING : 0; int may_throw = 0; ir_ref if_type = IR_UNUSED; @@ -12551,7 +12552,7 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit, && (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) { if (!(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF) - (MAY_BE_STRING|MAY_BE_LONG)))) { - result_type_guard = 1; + result_type_guard = true; res_info &= ~MAY_BE_GUARD; ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD; } @@ -12564,7 +12565,7 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit, && (ssa_op+1)->op1_use == ssa_op->result_def && !(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF) - (MAY_BE_STRING|MAY_BE_LONG))) && zend_jit_may_avoid_refcounting(opline+1, res_info)) { - result_avoid_refcounting = 1; + result_avoid_refcounting = true; ssa->var_info[ssa_op->result_def].avoid_refcounting = 1; } @@ -12688,7 +12689,7 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit, } } else { // ZVAL_COPY - jit_ZVAL_COPY(jit, res_addr, -1, val_addr, res_info, 1); + jit_ZVAL_COPY(jit, res_addr, -1, val_addr, res_info, true); } ir_END_list(end_inputs); @@ -12795,12 +12796,14 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit, jit_SET_EX_OPLINE(jit, opline); if (opline->opcode != ZEND_FETCH_DIM_IS && (op1_info & MAY_BE_UNDEF)) { may_throw = 1; - zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op1_addr), opline->op1.var, NULL, 0, 1, 0); + zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op1_addr), opline->op1.var, NULL, + false, true, false); } if (op2_info & MAY_BE_UNDEF) { may_throw = 1; - zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op2_addr), opline->op2.var, NULL, 0, 1, 0); + zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op2_addr), opline->op2.var, NULL, + false, true, false); } } @@ -13050,7 +13053,7 @@ static int zend_jit_fetch_dim(zend_jit_ctx *jit, } 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)) { + false, ht_ref, found_inputs, found_vals, &end_inputs, NULL)) { return 0; } @@ -13211,7 +13214,7 @@ static int zend_jit_isset_isempty_dim(zend_jit_ctx *jit, } 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)) { + false, ht_ref, true_inputs, NULL, &false_inputs, NULL)) { return 0; } @@ -13412,7 +13415,7 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, ir_IF_TRUE(if_ok); var_addr = ZEND_ADDR_REF_ZVAL(ref); - if (!zend_jit_simple_assign(jit, opline, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0)) { + if (!zend_jit_simple_assign(jit, opline, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, false)) { return 0; } } else { @@ -13426,7 +13429,7 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, 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)) { + false, ht_ref, found_inputs, found_values, &end_inputs, NULL)) { return 0; } @@ -13447,11 +13450,11 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, && Z_MODE(op3_addr) != IS_REG && opline->result_type == IS_UNUSED && (res_addr == 0 || Z_MODE(res_addr) != IS_REG)) { - 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)) { + 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, false)) { return 0; } } else { - if (!zend_jit_assign_to_variable(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0, 0)) { + if (!zend_jit_assign_to_variable(jit, opline, var_addr, var_addr, var_info, -1, (opline+1)->op1_type, op3_addr, val_info, res_addr, 0, false)) { return 0; } } @@ -13544,7 +13547,7 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, uint32_t var_info = MAY_BE_NULL; ir_ref if_type = IS_UNUSED; ir_ref end_inputs = IR_UNUSED, ht_ref; - bool emit_fast_path = 1; + bool emit_fast_path = true; ZEND_ASSERT(opline->result_type == IS_UNUSED); @@ -13612,7 +13615,7 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, 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)) { + false, ht_ref, found_inputs, found_values, &end_inputs, NULL)) { return 0; } @@ -13660,7 +13663,7 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, var_addr = ZEND_ADDR_REF_ZVAL(ref); } } else { - emit_fast_path = 0; + emit_fast_path = false; } } @@ -13760,7 +13763,7 @@ static int zend_jit_fe_reset(zend_jit_ctx *jit, const zend_op *opline, uint32_t if (opline->op1_type == IS_CONST) { zval *zv = RT_CONSTANT(opline, opline->op1); - jit_ZVAL_COPY_CONST(jit, res_addr, MAY_BE_ANY, MAY_BE_ANY, zv, 1); + jit_ZVAL_COPY_CONST(jit, res_addr, MAY_BE_ANY, MAY_BE_ANY, zv, true); } else { zend_jit_addr op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->op1.var); @@ -14098,12 +14101,12 @@ static int zend_jit_fe_fetch(zend_jit_ctx *jit, const zend_op *opline, uint32_t val_addr = ZEND_ADDR_REF_ZVAL(p_ref); if (opline->op2_type == IS_CV) { // JIT: zend_assign_to_variable(variable_ptr, value, IS_CV, EX_USES_STRICT_TYPES()); - if (!zend_jit_assign_to_variable(jit, opline, var_addr, var_addr, op2_info, -1, IS_CV, val_addr, val_info, 0, 0, 1)) { + if (!zend_jit_assign_to_variable(jit, opline, var_addr, var_addr, op2_info, -1, IS_CV, val_addr, val_info, 0, 0, true)) { return 0; } } else { // JIT: ZVAL_COPY(res, value); - jit_ZVAL_COPY(jit, var_addr, -1, val_addr, val_info, 1); + jit_ZVAL_COPY(jit, var_addr, -1, val_addr, val_info, true); } if (!exit_addr) { @@ -14222,7 +14225,7 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit, { zval *member; zend_property_info *prop_info; - bool may_be_dynamic = 1; + bool may_be_dynamic = true; zend_jit_addr prop_addr; uint32_t res_info = RES_INFO(); ir_ref prop_type_ref = IR_UNUSED; @@ -14313,7 +14316,7 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit, prop_info = zend_get_known_property_info(op_array, trace_ce, Z_STR_P(member), on_this, op_array->filename); if (prop_info) { ce = trace_ce; - ce_is_instanceof = 0; + ce_is_instanceof = false; if (!(op1_info & MAY_BE_CLASS_GUARD)) { if (on_this && JIT_G(current_frame) && TRACE_FRAME_IS_THIS_CLASS_CHECKED(JIT_G(current_frame))) { @@ -14638,7 +14641,7 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit, 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; + bool result_avoid_refcounting = false; ZEND_ASSERT(opline->opcode == ZEND_FETCH_OBJ_R || opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG @@ -14659,12 +14662,12 @@ static int zend_jit_fetch_obj(zend_jit_ctx *jit, && (res_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) && (ssa_op+1)->op1_use == ssa_op->result_def && zend_jit_may_avoid_refcounting(opline+1, res_info)) { - result_avoid_refcounting = 1; + result_avoid_refcounting = true; ssa->var_info[ssa_op->result_def].avoid_refcounting = 1; } val_addr = zend_jit_guard_fetch_result_type(jit, opline, val_addr, type, - 1, flags, op1_avoid_refcounting); + true, flags, op1_avoid_refcounting); if (!val_addr) { return 0; } @@ -14835,7 +14838,7 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit, prop_info = zend_get_known_property_info(op_array, trace_ce, name, on_this, op_array->filename); if (prop_info) { ce = trace_ce; - ce_is_instanceof = 0; + ce_is_instanceof = false; if (!(op1_info & MAY_BE_CLASS_GUARD)) { if (on_this && JIT_G(current_frame) && TRACE_FRAME_IS_THIS_CLASS_CHECKED(JIT_G(current_frame))) { @@ -15000,7 +15003,7 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit, if (Z_MODE(val_addr) != IS_REG && (res_addr == 0 || Z_MODE(res_addr) != IS_REG) && opline->result_type == IS_UNUSED) { - if (!zend_jit_assign_to_variable_call(jit, opline, prop_addr, prop_addr, -1, -1, (opline+1)->op1_type, val_addr, val_info, res_addr, 0)) { + if (!zend_jit_assign_to_variable_call(jit, opline, prop_addr, prop_addr, -1, -1, (opline+1)->op1_type, val_addr, val_info, res_addr, false)) { return 0; } } else { @@ -15011,7 +15014,7 @@ static int zend_jit_assign_obj(zend_jit_ctx *jit, } else { real_res_addr = res_addr; } - if (!zend_jit_assign_to_variable(jit, opline, prop_addr, prop_addr, -1, -1, (opline+1)->op1_type, val_addr, val_info, real_res_addr, 0, 0)) { + if (!zend_jit_assign_to_variable(jit, opline, prop_addr, prop_addr, -1, -1, (opline+1)->op1_type, val_addr, val_info, real_res_addr, 0, false)) { return 0; } } @@ -15117,8 +15120,8 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, zend_string *name; zend_property_info *prop_info; zend_jit_addr prop_addr; - bool use_prop_guard = 0; - bool may_throw = 0; + bool use_prop_guard = false; + bool may_throw = false; binary_op_type binary_op = get_binary_op(opline->extended_value); ir_ref obj_ref = IR_UNUSED; ir_ref prop_ref = IR_UNUSED; @@ -15167,7 +15170,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, jit_ZVAL_ADDR(jit, op1_addr), ir_CONST_ADDR(ZSTR_VAL(name))); - may_throw = 1; + may_throw = true; ir_END_list(end_inputs); ir_IF_TRUE(if_obj); @@ -15181,7 +15184,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, prop_info = zend_get_known_property_info(op_array, trace_ce, name, on_this, op_array->filename); if (prop_info) { ce = trace_ce; - ce_is_instanceof = 0; + ce_is_instanceof = false; if (!(op1_info & MAY_BE_CLASS_GUARD)) { if (on_this && JIT_G(current_frame) && TRACE_FRAME_IS_THIS_CLASS_CHECKED(JIT_G(current_frame))) { @@ -15279,7 +15282,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, if (ZEND_TYPE_IS_SET(prop_info->type)) { ir_ref if_ref, if_typed, noref_path, ref_path, reference, ref, arg2; - may_throw = 1; + may_throw = true; jit_SET_EX_OPLINE(jit, opline); @@ -15357,7 +15360,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, if (var_info & MAY_BE_REF) { ir_ref if_ref, if_typed, noref_path, ref_path, reference, ref, arg2; - may_throw = 1; + may_throw = true; if_ref = jit_if_Z_TYPE(jit, prop_addr, IS_REFERENCE); ir_IF_FALSE(if_ref); @@ -15411,7 +15414,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, if (opline->extended_value != ZEND_ADD || (var_info & MAY_BE_ANY) != MAY_BE_ARRAY || (val_info & MAY_BE_ANY) == MAY_BE_ARRAY) { - may_throw = 1; + may_throw = true; } } if (!zend_jit_math_helper(jit, opline, opline->extended_value, IS_CV, opline->op1, var_addr, var_info, val_op_type, (opline+1)->op1, val_addr, val_info, 0, var_addr, var_def_info, var_info, @@ -15426,7 +15429,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, (val_info & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) { if ((var_info & MAY_BE_ANY) != MAY_BE_STRING || (val_info & MAY_BE_ANY) != MAY_BE_STRING) { - may_throw = 1; + may_throw = true; } } goto long_math; @@ -15434,23 +15437,23 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, case ZEND_SR: if ((var_info & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || (val_info & (MAY_BE_STRING|MAY_BE_DOUBLE|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) { - may_throw = 1; + may_throw = true; } if (val_op_type != IS_CONST || Z_TYPE_P(RT_CONSTANT((opline+1), (opline+1)->op1)) != IS_LONG || Z_LVAL_P(RT_CONSTANT((opline+1), (opline+1)->op1)) < 0) { - may_throw = 1; + may_throw = true; } goto long_math; case ZEND_MOD: if ((var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) || (val_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) { - may_throw = 1; + may_throw = true; } if (val_op_type != IS_CONST || Z_TYPE_P(RT_CONSTANT((opline+1), (opline+1)->op1)) != IS_LONG || Z_LVAL_P(RT_CONSTANT((opline+1), (opline+1)->op1)) == 0) { - may_throw = 1; + may_throw = true; } long_math: if (!zend_jit_long_math_helper(jit, opline, opline->extended_value, @@ -15462,7 +15465,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, } break; case ZEND_CONCAT: - may_throw = 1; + may_throw = true; if (!zend_jit_concat_helper(jit, opline, IS_CV, opline->op1, var_addr, var_info, val_op_type, (opline+1)->op1, val_addr, val_info, var_addr, 0)) { return 0; @@ -15481,7 +15484,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, ir_MERGE_list(slow_inputs); - may_throw = 1; + may_throw = true; if (Z_MODE(val_addr) == IS_REG) { zend_jit_addr real_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, (opline+1)->op1.var); @@ -15517,7 +15520,7 @@ static int zend_jit_assign_obj_op(zend_jit_ctx *jit, if (opline->op1_type != IS_UNUSED && !delayed_fetch_this && !op1_indirect) { if ((op1_info & MAY_HAVE_DTOR) && (op1_info & MAY_BE_RC1)) { - may_throw = 1; + may_throw = true; } jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline); } @@ -15549,8 +15552,8 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit, zend_property_info *prop_info; zend_jit_addr res_addr = 0; zend_jit_addr prop_addr; - bool use_prop_guard = 0; - bool may_throw = 0; + bool use_prop_guard = false; + bool may_throw = false; uint32_t res_info = (opline->result_type != IS_UNDEF) ? RES_INFO() : 0; ir_ref obj_ref = IR_UNUSED; ir_ref prop_ref = IR_UNUSED; @@ -15611,7 +15614,7 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit, prop_info = zend_get_known_property_info(op_array, trace_ce, name, on_this, op_array->filename); if (prop_info) { ce = trace_ce; - ce_is_instanceof = 0; + ce_is_instanceof = false; if (!(op1_info & MAY_BE_CLASS_GUARD)) { if (on_this && JIT_G(current_frame) && TRACE_FRAME_IS_THIS_CLASS_CHECKED(JIT_G(current_frame))) { @@ -15704,7 +15707,7 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit, const void *func; ir_ref ref; - may_throw = 1; + may_throw = true; jit_SET_EX_OPLINE(jit, opline); if (ce && ce->ce_flags & ZEND_ACC_IMMUTABLE) { @@ -15809,7 +15812,7 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit, ZEND_UNREACHABLE(); } - may_throw = 1; + may_throw = true; jit_SET_EX_OPLINE(jit, opline); ir_CALL_2(IR_VOID, ir_CONST_FC_FUNC(func), reference, @@ -15861,13 +15864,13 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit, if (var_info & (MAY_BE_ANY - MAY_BE_LONG)) { if (var_info & (MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) { - may_throw = 1; + may_throw = true; } if (if_long) { ir_IF_FALSE_cold(if_long); } if (opline->opcode == ZEND_POST_INC_OBJ || opline->opcode == ZEND_POST_DEC_OBJ) { - jit_ZVAL_COPY(jit, res_addr, -1, var_addr, var_info, 1); + jit_ZVAL_COPY(jit, res_addr, -1, var_addr, var_info, true); } if (opline->opcode == ZEND_PRE_INC_OBJ || opline->opcode == ZEND_POST_INC_OBJ) { if (opline->opcode == ZEND_PRE_INC_OBJ && opline->result_type != IS_UNUSED) { @@ -15977,7 +15980,7 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit, ZEND_UNREACHABLE(); } - may_throw = 1; + may_throw = true; jit_SET_EX_OPLINE(jit, opline); ir_ref run_time_cache = ir_LOAD_A(jit_EX(run_time_cache)); ir_CALL_4(IR_VOID, ir_CONST_FC_FUNC(func), @@ -15995,7 +15998,7 @@ static int zend_jit_incdec_obj(zend_jit_ctx *jit, if ((opline->op1_type & (IS_VAR|IS_TMP_VAR)) && !delayed_fetch_this && !op1_indirect) { if ((op1_info & MAY_HAVE_DTOR) && (op1_info & MAY_BE_RC1)) { - may_throw = 1; + may_throw = true; } jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline); } @@ -16895,11 +16898,11 @@ static bool zend_jit_noref_guard(zend_jit_ctx *jit, const zend_op *opline, zend_ const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { - return 0; + return false; } ir_GUARD(ir_NE(jit_Z_TYPE(jit, var_addr), ir_CONST_U8(IS_REFERENCE)), ir_CONST_ADDR(exit_addr)); - return 1; + return true; } static int zend_jit_trace_opline_guard(zend_jit_ctx *jit, const zend_op *opline) @@ -16932,7 +16935,7 @@ static bool zend_jit_guard_reference(zend_jit_ctx *jit, exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { - return 0; + return false; } ref = jit_Z_TYPE(jit, var_addr); @@ -16945,7 +16948,7 @@ static bool zend_jit_guard_reference(zend_jit_ctx *jit, var_addr = ZEND_ADDR_REF_ZVAL(ref); *var_addr_ptr = var_addr; - return 1; + return true; } static bool zend_jit_fetch_reference(zend_jit_ctx *jit, @@ -16966,7 +16969,7 @@ static bool zend_jit_fetch_reference(zend_jit_ctx *jit, exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { - return 0; + return false; } } @@ -17011,7 +17014,7 @@ static bool zend_jit_fetch_reference(zend_jit_ctx *jit, } *var_info_ptr |= MAY_BE_GUARD; /* prevent generation of specialized zval dtor */ - return 1; + return true; } static bool zend_jit_fetch_indirect_var(zend_jit_ctx *jit, const zend_op *opline, uint8_t var_type, uint32_t *var_info_ptr, zend_jit_addr *var_addr_ptr, bool add_indirect_guard) @@ -17027,7 +17030,7 @@ static bool zend_jit_fetch_indirect_var(zend_jit_ctx *jit, const zend_op *opline const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { - return 0; + return false; } jit_guard_Z_TYPE(jit, var_addr, IS_INDIRECT, exit_addr); ref = jit_Z_PTR(jit, var_addr); @@ -17050,7 +17053,7 @@ static bool zend_jit_fetch_indirect_var(zend_jit_ctx *jit, const zend_op *opline exit_addr = zend_jit_trace_get_exit_addr(exit_point); if (!exit_addr) { - return 0; + return false; } jit_guard_Z_TYPE(jit, var_addr, var_type, exit_addr); @@ -17068,7 +17071,7 @@ static bool zend_jit_fetch_indirect_var(zend_jit_ctx *jit, const zend_op *opline *var_info_ptr = var_info; } - return 1; + return true; } static int zend_jit_trace_handler(zend_jit_ctx *jit, const zend_op_array *op_array, const zend_op *opline, int may_throw, zend_jit_trace_rec *trace) @@ -17161,7 +17164,7 @@ static int zend_jit_trace_handler(zend_jit_ctx *jit, const zend_op_array *op_arr zend_jit_trace_stack *stack = JIT_G(current_frame)->stack; if (zend_is_smart_branch(opline)) { - bool exit_if_true = 0; + bool exit_if_true = false; exit_opline = zend_jit_trace_get_exit_opline(trace, opline + 1, &exit_if_true); } else { switch (opline->opcode) { @@ -17445,14 +17448,14 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa case ZEND_IS_IDENTICAL: case ZEND_IS_NOT_IDENTICAL: case ZEND_CASE: - return 1; + return true; case ZEND_RETURN: 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; + return false; } op1_info = OP1_INFO(); op2_info = OP2_INFO(); @@ -17463,7 +17466,7 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa op1_info = OP1_INFO(); op2_info = OP2_INFO(); if ((op1_info & MAY_BE_UNDEF) || (op2_info & MAY_BE_UNDEF)) { - return 0; + return false; } if (trace && trace->op1_type != IS_UNKNOWN) { op1_info &= 1U << (trace->op1_type & ~(IS_TRACE_REFERENCE|IS_TRACE_INDIRECT|IS_TRACE_PACKED)); @@ -17511,11 +17514,11 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa case ZEND_JMPNZ: if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE) { if (!ssa->cfg.map) { - return 0; + return false; } if (opline > op_array->opcodes + ssa->cfg.blocks[ssa->cfg.map[opline-op_array->opcodes]].start && ((opline-1)->result_type & (IS_SMART_BRANCH_JMPZ|IS_SMART_BRANCH_JMPNZ)) != 0) { - return 0; + return false; } } ZEND_FALLTHROUGH; @@ -17523,12 +17526,12 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa case ZEND_BOOL_NOT: case ZEND_JMPZ_EX: case ZEND_JMPNZ_EX: - return 1; + return true; case ZEND_FETCH_CONSTANT: - return 1; + return true; case ZEND_ISSET_ISEMPTY_DIM_OBJ: if ((opline->extended_value & ZEND_ISEMPTY)) { - return 0; + return false; } ZEND_FALLTHROUGH; case ZEND_FETCH_DIM_R: @@ -17546,10 +17549,10 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa ((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_STRING)); case ZEND_ASSIGN_DIM_OP: if (opline->result_type != IS_UNUSED) { - return 0; + return false; } if (!zend_jit_supported_binary_op(opline->extended_value, MAY_BE_ANY, OP1_DATA_INFO())) { - return 0; + return false; } ZEND_FALLTHROUGH; case ZEND_ASSIGN_DIM: @@ -17565,13 +17568,13 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa && (opline+1)->op1_type == IS_CV && (opline+1)->op1.var == opline->op1.var) { /* skip $a[x] = $a; */ - return 0; + return false; } } 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; + return false; } } if (trace->op1_type != IS_UNKNOWN @@ -17580,7 +17583,7 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa } } else { if (opline->op1_type != IS_CV) { - return 0; + return false; } } return ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_ARRAY) && @@ -17588,10 +17591,10 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa ((op2_info & (MAY_BE_ANY|MAY_BE_UNDEF)) == MAY_BE_STRING)); case ZEND_ASSIGN_OBJ_OP: if (opline->result_type != IS_UNUSED) { - return 0; + return false; } if (!zend_jit_supported_binary_op(opline->extended_value, MAY_BE_ANY, OP1_DATA_INFO())) { - return 0; + return false; } ZEND_FALLTHROUGH; case ZEND_FETCH_OBJ_R: @@ -17599,19 +17602,19 @@ static bool zend_jit_opline_supports_reg(const zend_op_array *op_array, zend_ssa 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; + return false; } op1_info = OP1_INFO(); return opline->op1_type == IS_UNUSED || (op1_info & MAY_BE_OBJECT); } - return 0; + return false; } static bool zend_jit_var_supports_reg(zend_ssa *ssa, int var) { if (ssa->vars[var].no_val) { /* we don't need the value */ - return 0; + return false; } if (!(JIT_G(opt_flags) & ZEND_JIT_REG_ALLOC_GLOBAL)) { @@ -17619,13 +17622,13 @@ static bool zend_jit_var_supports_reg(zend_ssa *ssa, int var) * register allocation for SSA variables connected through Phi functions */ if (ssa->vars[var].definition_phi) { - return 0; + return false; } if (ssa->vars[var].phi_use_chain) { zend_ssa_phi *phi = ssa->vars[var].phi_use_chain; do { if (!ssa->vars[phi->ssa_var].no_val) { - return 0; + return false; } phi = zend_ssa_next_use_phi(ssa, var, phi); } while (phi); @@ -17635,22 +17638,22 @@ static bool zend_jit_var_supports_reg(zend_ssa *ssa, int var) if (((ssa->var_info[var].type & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF)) != MAY_BE_DOUBLE) && ((ssa->var_info[var].type & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_REF)) != MAY_BE_LONG)) { /* bad type */ - return 0; + return false; } - return 1; + return true; } static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, int var) { if (!zend_jit_var_supports_reg(ssa, var)) { - return 0; + return false; } if (ssa->vars[var].definition >= 0) { uint32_t def = ssa->vars[var].definition; if (!zend_jit_opline_supports_reg(op_array, ssa, op_array->opcodes + def, ssa->ops + def, NULL)) { - return 0; + return false; } } @@ -17660,7 +17663,7 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, do { if (!zend_ssa_is_no_val_use(op_array->opcodes + use, ssa->ops + use, var) && !zend_jit_opline_supports_reg(op_array, ssa, op_array->opcodes + use, ssa->ops + use, NULL)) { - return 0; + return false; } use = zend_ssa_next_use(ssa->ops, var, use); } while (use >= 0); @@ -17670,7 +17673,7 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, int def_block, use_block, b, use, j; zend_basic_block *bb; zend_ssa_phi *p; - bool ret = 1; + bool ret = true; zend_worklist worklist; ALLOCA_FLAG(use_heap) @@ -17716,7 +17719,7 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, b = zend_worklist_pop(&worklist); bb = &ssa->cfg.blocks[b]; if (bb->flags & (ZEND_BB_ENTRY|ZEND_BB_RECV_ENTRY)) { - ret = 0; + ret = false; break; } for (j = 0; j < bb->predecessors_count; j++) { @@ -17732,7 +17735,7 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, return ret; } - return 1; + return true; } static ir_ref jit_frameless_observer(zend_jit_ctx *jit, const zend_op *opline) { @@ -17789,7 +17792,7 @@ static void jit_frameless_icall1(zend_jit_ctx *jit, const zend_op *opline, uint3 ir_ref op1_ref = jit_ZVAL_ADDR(jit, op1_addr); jit_set_Z_TYPE_INFO(jit, res_addr, IS_NULL); if (opline->op1_type == IS_CV && (op1_info & MAY_BE_UNDEF)) { - op1_ref = zend_jit_zval_check_undef(jit, op1_ref, opline->op1.var, opline, 1); + op1_ref = zend_jit_zval_check_undef(jit, op1_ref, opline->op1.var, opline, true); op1_info &= ~MAY_BE_UNDEF; op1_info |= MAY_BE_NULL; op1_addr = ZEND_ADDR_REF_ZVAL(op1_ref); @@ -17834,13 +17837,13 @@ static void jit_frameless_icall2(zend_jit_ctx *jit, const zend_op *opline, uint3 ir_ref op2_ref = jit_ZVAL_ADDR(jit, op2_addr); jit_set_Z_TYPE_INFO(jit, res_addr, IS_NULL); if (opline->op1_type == IS_CV && (op1_info & MAY_BE_UNDEF)) { - op1_ref = zend_jit_zval_check_undef(jit, op1_ref, opline->op1.var, opline, 1); + op1_ref = zend_jit_zval_check_undef(jit, op1_ref, opline->op1.var, opline, true); op1_info &= ~MAY_BE_UNDEF; op1_info |= MAY_BE_NULL; op1_addr = ZEND_ADDR_REF_ZVAL(op1_ref); } if (opline->op2_type == IS_CV && (op2_info & MAY_BE_UNDEF)) { - op2_ref = zend_jit_zval_check_undef(jit, op2_ref, opline->op2.var, opline, 1); + op2_ref = zend_jit_zval_check_undef(jit, op2_ref, opline->op2.var, opline, true); op2_info &= ~MAY_BE_UNDEF; op2_info |= MAY_BE_NULL; op2_addr = ZEND_ADDR_REF_ZVAL(op2_ref); @@ -17906,19 +17909,19 @@ static void jit_frameless_icall3(zend_jit_ctx *jit, const zend_op *opline, uint3 ir_ref op3_ref = jit_ZVAL_ADDR(jit, op3_addr); jit_set_Z_TYPE_INFO(jit, res_addr, IS_NULL); if (opline->op1_type == IS_CV && (op1_info & MAY_BE_UNDEF)) { - op1_ref = zend_jit_zval_check_undef(jit, op1_ref, opline->op1.var, opline, 1); + op1_ref = zend_jit_zval_check_undef(jit, op1_ref, opline->op1.var, opline, true); op1_info &= ~MAY_BE_UNDEF; op1_info |= MAY_BE_NULL; op1_addr = ZEND_ADDR_REF_ZVAL(op1_ref); } if (opline->op2_type == IS_CV && (op2_info & MAY_BE_UNDEF)) { - op2_ref = zend_jit_zval_check_undef(jit, op2_ref, opline->op2.var, opline, 1); + op2_ref = zend_jit_zval_check_undef(jit, op2_ref, opline->op2.var, opline, true); op2_info &= ~MAY_BE_UNDEF; op2_info |= MAY_BE_NULL; op2_addr = ZEND_ADDR_REF_ZVAL(op2_ref); } if ((opline+1)->op1_type == IS_CV && (op1_data_info & MAY_BE_UNDEF)) { - op3_ref = zend_jit_zval_check_undef(jit, op3_ref, (opline+1)->op1.var, opline, 1); + op3_ref = zend_jit_zval_check_undef(jit, op3_ref, (opline+1)->op1.var, opline, true); op1_data_info &= ~MAY_BE_UNDEF; op1_data_info |= MAY_BE_NULL; op3_addr = ZEND_ADDR_REF_ZVAL(op3_ref); diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index 66bb380c23d8d..10be237d06b8e 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -132,7 +132,7 @@ static uint32_t zend_jit_exit_point_by_addr(const void *addr) return (uint32_t)-1; } -static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags) +static uint32_t _zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t flags ZEND_FILE_LINE_DC) { zend_jit_trace_info *t = &zend_jit_traces[ZEND_JIT_TRACE_NUM]; uint32_t exit_point; @@ -178,7 +178,13 @@ static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t && memcmp(t->stack_map + t->exit_info[i].stack_offset, stack, stack_size * sizeof(zend_jit_trace_stack)) == 0)) { if (t->exit_info[i].opline == to_opline && t->exit_info[i].flags == flags - && t->exit_info[i].stack_size == stack_size) { + && t->exit_info[i].stack_size == stack_size +#if ZEND_DEBUG + && (((JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_EXIT_INFO_SRC) == 0) + || (strcmp(t->exit_info[i].filename, __zend_filename) == 0 + && t->exit_info[i].lineno == __zend_lineno)) +#endif + ) { return i; } } @@ -202,6 +208,15 @@ static uint32_t zend_jit_trace_get_exit_point(const zend_op *to_opline, uint32_t t->exit_info[exit_point].stack_offset = stack_offset; t->exit_info[exit_point].poly_func = (zend_jit_ref_snapshot){.reg = ZREG_NONE}; t->exit_info[exit_point].poly_this = (zend_jit_ref_snapshot){.reg = ZREG_NONE}; +#if ZEND_DEBUG + if ((JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_EXIT_INFO_SRC) != 0) { + t->exit_info[exit_point].filename = __zend_filename; + t->exit_info[exit_point].lineno = __zend_lineno; + } else { + t->exit_info[exit_point].filename = NULL; + t->exit_info[exit_point].lineno = 0; + } +#endif } return exit_point; @@ -478,7 +493,7 @@ static bool zend_jit_needs_arg_dtor(const zend_function *func, uint32_t arg_num, && func->type == ZEND_INTERNAL_FUNCTION && (func->internal_function.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0 && arg_num < func->internal_function.num_args) { - const zend_internal_arg_info *arg_info = &func->internal_function.arg_info[arg_num]; + const zend_arg_info *arg_info = &func->internal_function.arg_info[arg_num]; if (ZEND_ARG_SEND_MODE(arg_info) == ZEND_SEND_BY_VAL && ZEND_TYPE_IS_SET(arg_info->type) @@ -492,7 +507,7 @@ static bool zend_jit_needs_arg_dtor(const zend_function *func, uint32_t arg_num, if (type != IS_UNKNOWN && type < IS_STRING && ZEND_TYPE_FULL_MASK(arg_info->type) & (1u << type)) { - return 0; + return false; } } if (call_info && arg_num < call_info->num_args && call_info->arg_info[arg_num].opline) { @@ -507,7 +522,7 @@ static bool zend_jit_needs_arg_dtor(const zend_function *func, uint32_t arg_num, // TODO: few functions (e.g. pcntl_exec) modify arrays in-place ??? if (type != IS_ARRAY && (ZEND_TYPE_FULL_MASK(arg_info->type) & (1u << type))) { - return 0; + return false; } } } @@ -515,7 +530,7 @@ static bool zend_jit_needs_arg_dtor(const zend_function *func, uint32_t arg_num, } } - return 1; + return true; } static zend_ssa *zend_jit_trace_build_ssa(const zend_op_array *op_array, zend_script *script) @@ -802,7 +817,7 @@ static bool zend_jit_trace_is_false_loop(const zend_op_array *op_array, const ze bb = ssa->cfg.blocks + ssa->cfg.map[opline - op_array->opcodes]; return bb->loop_header != b; } else { - return 0; + return false; } } @@ -2950,7 +2965,7 @@ static zend_jit_reg_var* zend_jit_trace_allocate_registers(zend_jit_trace_rec *t && ssa_op->op1_def >= 0 && ssa->vars[ssa_op->op1_def].alias != NO_ALIAS) { /* avoid register allocation in case of possibility of indirect modification*/ - support_opline = 0; + support_opline = false; } if (ssa_op->op1_use >= 0 @@ -3425,7 +3440,7 @@ static bool zend_jit_may_delay_fetch_this(const zend_op_array *op_array, zend_ss || ssa->vars[var].phi_use_chain || ssa->ops[use].op1_use != var || ssa->ops[use].op1_use_chain != -1) { - return 0; + return false; } opline = ssa_opcodes[use]; @@ -3437,7 +3452,7 @@ static bool zend_jit_may_delay_fetch_this(const zend_op_array *op_array, zend_ss || !JIT_G(current_frame)->call || !JIT_G(current_frame)->call->func || !TRACE_FRAME_IS_LAST_SEND_BY_VAL(JIT_G(current_frame)->call)) { - return 0; + return false; } } else if (opline->opcode != ZEND_FETCH_OBJ_R && opline->opcode != ZEND_FETCH_OBJ_IS @@ -3448,13 +3463,13 @@ static bool zend_jit_may_delay_fetch_this(const zend_op_array *op_array, zend_ss && opline->opcode != ZEND_PRE_DEC_OBJ && opline->opcode != ZEND_POST_INC_OBJ && opline->opcode != ZEND_POST_DEC_OBJ) { - return 0; + return false; } 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; + return false; } if (opline->opcode == ZEND_ASSIGN_OBJ_OP) { @@ -3462,11 +3477,11 @@ static bool zend_jit_may_delay_fetch_this(const zend_op_array *op_array, zend_ss && (opline+1)->op1_type == IS_CV && (opline+1)->op1.var == opline->op1.var) { /* skip $a->prop += $a; */ - return 0; + return false; } if (!zend_jit_supported_binary_op( opline->extended_value, MAY_BE_ANY, OP1_DATA_INFO())) { - return 0; + return false; } } @@ -3475,11 +3490,11 @@ static bool zend_jit_may_delay_fetch_this(const zend_op_array *op_array, zend_ss || ssa_opcodes[i]->opcode == ZEND_DO_FCALL_BY_NAME || ssa_opcodes[i]->opcode == ZEND_DO_FCALL || ssa_opcodes[i]->opcode == ZEND_INCLUDE_OR_EVAL) { - return 0; + return false; } } - return 1; + return true; } static int zend_jit_trace_stack_needs_deoptimization(zend_jit_trace_stack *stack, uint32_t stack_size) @@ -3889,19 +3904,19 @@ static bool zend_jit_may_skip_comparison(const zend_op *opline, const zend_ssa_o || prev_opcode == ZEND_CASE_STRICT) { if (ssa_op->op1_use < 0) { if (RT_CONSTANT(opline, opline->op1) != RT_CONSTANT(&ssa_opcodes[prev_ssa_op - ssa->ops], ssa_opcodes[prev_ssa_op - ssa->ops]->op1)) { - return 0; + return false; } } if (ssa_op->op2_use < 0) { if (RT_CONSTANT(opline, opline->op2) != RT_CONSTANT(&ssa_opcodes[prev_ssa_op - ssa->ops], ssa_opcodes[prev_ssa_op - ssa->ops]->op2)) { - return 0; + return false; } } - return 1; + return true; } } } - return 0; + return false; } static bool zend_jit_trace_next_is_send_result(const zend_op *opline, @@ -3928,9 +3943,9 @@ static bool zend_jit_trace_next_is_send_result(const zend_op *oplin zend_jit_trace_send_type(opline+1, frame->call, res_type); } } - return 1; + return true; } - return 0; + return false; } static int zend_jit_find_ssa_var(const zend_op_array *op_array, @@ -4046,11 +4061,11 @@ static bool zend_jit_trace_must_store_type(const zend_op_array *op_array, if (ssa_var >= 0) { if ((ssa->var_info[ssa_var].type & (MAY_BE_ANY|MAY_BE_UNDEF)) != (1U << type)) { - return 0; + return false; } } } - return 1; + return true; } static bool zend_jit_trace_may_throw(const zend_op *opline, @@ -4071,7 +4086,7 @@ static bool zend_jit_trace_may_throw(const zend_op *opline, && !(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; + return false; } break; default: @@ -6568,10 +6583,9 @@ static zend_vm_opcode_handler_t zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t var_num = opline->result.var; uint32_t op_num = opline - op_array->opcodes; const zend_live_range *range = op_array->live_range; - int j; op_num += zend_jit_trace_op_len(opline); - for (j = 0; j < op_array->last_live_range; range++, j++) { + for (uint32_t j = 0; j < op_array->last_live_range; range++, j++) { if (range->start > op_num) { /* further blocks will not be relevant... */ break; @@ -7413,7 +7427,7 @@ static zend_vm_opcode_handler_t zend_jit_trace_exit_to_vm(uint32_t trace_num, ui const zend_op *opline; uint32_t stack_size; zend_jit_trace_stack *stack; - bool original_handler = 0; + bool original_handler = false; if (!zend_jit_trace_exit_needs_deoptimization(trace_num, exit_num)) { return zend_jit_stub_handlers[jit_stub_trace_escape]; @@ -7438,7 +7452,7 @@ static zend_vm_opcode_handler_t zend_jit_trace_exit_to_vm(uint32_t trace_num, ui &zend_jit_traces[trace_num].exit_info[exit_num], stack, stack_size, NULL, NULL, zend_jit_traces[trace_num].constants, - 0)) { + false)) { goto jit_failure; } @@ -7450,7 +7464,7 @@ static zend_vm_opcode_handler_t zend_jit_trace_exit_to_vm(uint32_t trace_num, ui if (ZEND_OP_TRACE_INFO(opline, jit_extension->offset)->orig_handler != opline->handler) { /* prevent endless loop */ - original_handler = 1; + original_handler = true; } } zend_jit_set_ip(&ctx, opline); @@ -7759,7 +7773,7 @@ static bool zend_jit_trace_is_bad_root(const zend_op *opline, zend_jit_trace_sto if (cache_opline[i] == opline) { if (cache_count[i] >= JIT_G(blacklist_root_trace) - 1) { cache_opline[i] = NULL; - return 1; + return true; } else { #if 0 if (ZEND_OP_TRACE_INFO(opline, offset)->counter) { @@ -7769,7 +7783,7 @@ static bool zend_jit_trace_is_bad_root(const zend_op *opline, zend_jit_trace_sto #endif cache_count[i]++; cache_stop[i] = stop; - return 0; + return false; } } } @@ -7779,7 +7793,7 @@ static bool zend_jit_trace_is_bad_root(const zend_op *opline, zend_jit_trace_sto cache_stop[i] = stop; cache_slot = (i + 1) % ZEND_JIT_TRACE_BAD_ROOT_SLOTS; JIT_G(bad_root_slot) = cache_slot; - return 0; + return false; } static void zend_jit_dump_trace(zend_jit_trace_rec *trace_buffer, zend_ssa *tssa) @@ -8096,6 +8110,11 @@ static void zend_jit_dump_exit_info(zend_jit_trace_info *t) fprintf(stderr, ":unknown(zval_copy(%s))", zend_reg_name(STACK_REG(stack, j))); } } +#if ZEND_DEBUG + if ((JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_EXIT_INFO_SRC) != 0) { + fprintf(stderr, " %s:%d", t->exit_info[i].filename, t->exit_info[i].lineno); + } +#endif fprintf(stderr, "\n"); } } @@ -8287,10 +8306,10 @@ static bool zend_jit_trace_exit_is_bad(uint32_t trace_num, uint32_t exit_num) zend_jit_traces[trace_num].exit_counters + exit_num; if (*counter + 1 >= JIT_G(hot_side_exit) + JIT_G(blacklist_side_trace)) { - return 1; + return true; } (*counter)++; - return 0; + return false; } static bool zend_jit_trace_exit_is_hot(uint32_t trace_num, uint32_t exit_num) @@ -8299,10 +8318,10 @@ static bool zend_jit_trace_exit_is_hot(uint32_t trace_num, uint32_t exit_num) zend_jit_traces[trace_num].exit_counters + exit_num; if (*counter + 1 >= JIT_G(hot_side_exit)) { - return 1; + return true; } (*counter)++; - return 0; + return false; } static zend_jit_trace_stop zend_jit_compile_side_trace(zend_jit_trace_rec *trace_buffer, uint32_t parent_num, uint32_t exit_num, uint32_t polymorphism) diff --git a/ext/opcache/jit/zend_jit_vm_helpers.c b/ext/opcache/jit/zend_jit_vm_helpers.c index cb896c0cd8c6f..bed5ab59992ed 100644 --- a/ext/opcache/jit/zend_jit_vm_helpers.c +++ b/ext/opcache/jit/zend_jit_vm_helpers.c @@ -255,9 +255,9 @@ bool ZEND_FASTCALL zend_jit_deprecated_helper(OPLINE_D) } zend_vm_stack_free_call_frame(call); - return 0; + return false; } - return 1; + return true; } bool ZEND_FASTCALL zend_jit_nodiscard_helper(OPLINE_D) @@ -283,9 +283,9 @@ bool ZEND_FASTCALL zend_jit_nodiscard_helper(OPLINE_D) } zend_vm_stack_free_call_frame(call); - return 0; + return false; } - return 1; + return true; } bool ZEND_FASTCALL zend_jit_deprecated_nodiscard_helper(OPLINE_D) @@ -295,17 +295,17 @@ bool ZEND_FASTCALL zend_jit_deprecated_nodiscard_helper(OPLINE_D) if (fbc->common.fn_flags & ZEND_ACC_DEPRECATED) { if (zend_jit_deprecated_helper(OPLINE_C) == 0) { - return 0; + return false; } } if (fbc->common.fn_flags & ZEND_ACC_NODISCARD) { if (zend_jit_nodiscard_helper(OPLINE_C) == 0) { - return 0; + return false; } } - return 1; + return true; } void ZEND_FASTCALL zend_jit_undefined_long_key(EXECUTE_DATA_D) diff --git a/ext/opcache/tests/gh19867.phpt b/ext/opcache/tests/gh19867.phpt new file mode 100644 index 0000000000000..486a366722dad --- /dev/null +++ b/ext/opcache/tests/gh19867.phpt @@ -0,0 +1,36 @@ +--TEST-- +GH-19867: Avoid capturing nested arrow function parameters +--EXTENSIONS-- +opcache +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.opt_debug_level=0x20000 +--FILE-- + fn($a, $b) => $a + $b; +?> +--EXPECTF-- +$_main: + ; (lines=%d, args=0, vars=%d, tmps=%d) + ; (after optimizer) + ; %s +0000 T0 = DECLARE_LAMBDA_FUNCTION 0 +0001 FREE T0 +0002 RETURN int(1) + +{closure:%s:%d}: + ; (lines=%d, args=0, vars=%d, tmps=%d) + ; (after optimizer) + ; %s +0000 T0 = DECLARE_LAMBDA_FUNCTION 0 +0001 RETURN T0 + +{closure:%s:%d}: + ; (lines=%d, args=2, vars=%d, tmps=%d) + ; (after optimizer) + ; %s +0000 CV0($a) = RECV 1 +0001 CV1($b) = RECV 2 +0002 T2 = ADD CV0($a) CV1($b) +0003 RETURN T2 diff --git a/ext/opcache/tests/named_parameter_new.phpt b/ext/opcache/tests/named_parameter_new.phpt new file mode 100644 index 0000000000000..1f6f64333c988 --- /dev/null +++ b/ext/opcache/tests/named_parameter_new.phpt @@ -0,0 +1,72 @@ +--TEST-- +Named Parameters are optimized for known constructors +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.opt_debug_level=0x20000 +--SKIPIF-- + +--EXTENSIONS-- +opcache +--FILE-- + +--EXPECTF-- +$_main: + ; (lines=4, args=0, vars=0, tmps=%d) + ; (after optimizer) + ; %s +0000 INIT_STATIC_METHOD_CALL 1 string("MyClass") string("new") +0001 SEND_VAL int(1) 1 +0002 DO_UCALL +0003 RETURN int(1) + +MyClass::__construct: + ; (lines=7, args=2, vars=2, tmps=%d) + ; (after optimizer) + ; %s +0000 CV0($foo) = RECV 1 +0001 CV1($bar) = RECV_INIT 2 int(0) +0002 ASSIGN_OBJ THIS string("foo") +0003 OP_DATA CV0($foo) +0004 ASSIGN_OBJ THIS string("bar") +0005 OP_DATA CV1($bar) +0006 RETURN null + +MyClass::new: + ; (lines=10, args=1, vars=2, tmps=%d) + ; (after optimizer) + ; %s +0000 CV0($bar) = RECV 1 +0001 V2 = NEW 1 string("Random\\Engine\\Xoshiro256StarStar") +0002 SEND_VAL int(123) 1 +0003 DO_FCALL +0004 CV1($engine) = QM_ASSIGN V2 +0005 V2 = NEW 2 (self) (exception) +0006 SEND_VAR CV1($engine) 1 +0007 SEND_VAR CV0($bar) 2 +0008 DO_FCALL +0009 RETURN V2 +LIVE RANGES: + 2: 0002 - 0004 (new) + 2: 0006 - 0009 (new) diff --git a/ext/opcache/tests/opt/gh18107_1.phpt b/ext/opcache/tests/opt/gh18107_1.phpt index fea270a4d5a08..062ccd464559b 100644 --- a/ext/opcache/tests/opt/gh18107_1.phpt +++ b/ext/opcache/tests/opt/gh18107_1.phpt @@ -30,12 +30,12 @@ $_main: 0000 T1 = ISSET_ISEMPTY_CV (isset) CV0($badvar) 0001 JMPNZ T1 0006 0002 V3 = NEW 1 string("Exception") -0003 SEND_VAL_EX string("Should happen") 1 +0003 SEND_VAL%S string("Should happen") 1 0004 DO_FCALL 0005 THROW V3 0006 JMP 0006 0007 V6 = NEW 1 string("Exception") -0008 SEND_VAL_EX string("Should not happen") 1 +0008 SEND_VAL%S string("Should not happen") 1 0009 DO_FCALL 0010 THROW V6 0011 FAST_RET T5 diff --git a/ext/opcache/tests/opt/gh18107_2.phpt b/ext/opcache/tests/opt/gh18107_2.phpt index aaf58b4f820de..bd34a54edf6e6 100644 --- a/ext/opcache/tests/opt/gh18107_2.phpt +++ b/ext/opcache/tests/opt/gh18107_2.phpt @@ -33,7 +33,7 @@ $_main: 0000 T2 = ISSET_ISEMPTY_CV (isset) CV0($badvar) 0001 JMPNZ T2 0008 0002 V4 = NEW 1 string("Exception") -0003 SEND_VAL_EX string("Should happen") 1 +0003 SEND_VAL%S string("Should happen") 1 0004 DO_FCALL 0005 THROW V4 0006 CV1($e) = CATCH string("Throwable") @@ -41,7 +41,7 @@ $_main: 0008 T6 = FAST_CALL 0010 0009 JMP 0015 0010 V7 = NEW 1 string("Exception") -0011 SEND_VAL_EX string("Should not happen") 1 +0011 SEND_VAL%S string("Should not happen") 1 0012 DO_FCALL 0013 THROW V7 0014 FAST_RET T6 diff --git a/ext/opcache/zend_accelerator_blacklist.c b/ext/opcache/zend_accelerator_blacklist.c index b7ffb164cdd2b..631f8b34608f3 100644 --- a/ext/opcache/zend_accelerator_blacklist.c +++ b/ext/opcache/zend_accelerator_blacklist.c @@ -205,7 +205,7 @@ void zend_accel_blacklist_shutdown(zend_blacklist *blacklist) return; } - zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos; + const zend_blacklist_entry *p = blacklist->entries, *end = blacklist->entries + blacklist->pos; while (ppath); p++; @@ -336,14 +336,14 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) zend_accel_blacklist_update_regexp(blacklist); } -bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len) +bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len) { int ret = 0; - zend_regexp_list *regexp_list_it = blacklist->regexp_list; + const zend_regexp_list *regexp_list_it = blacklist->regexp_list; pcre2_match_context *mctx = php_pcre_mctx(); if (regexp_list_it == NULL) { - return 0; + return false; } while (regexp_list_it != NULL) { pcre2_match_data *match_data = php_pcre_create_match_data(0, regexp_list_it->re); @@ -363,7 +363,7 @@ bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify return ret; } -void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument) +void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument) { int i; diff --git a/ext/opcache/zend_accelerator_blacklist.h b/ext/opcache/zend_accelerator_blacklist.h index 2a7921f63d947..da6e04e31b7ce 100644 --- a/ext/opcache/zend_accelerator_blacklist.h +++ b/ext/opcache/zend_accelerator_blacklist.h @@ -45,7 +45,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist); void zend_accel_blacklist_shutdown(zend_blacklist *blacklist); void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename); -bool zend_accel_blacklist_is_blacklisted(zend_blacklist *blacklist, char *verify_path, size_t verify_path_len); -void zend_accel_blacklist_apply(zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument); +bool zend_accel_blacklist_is_blacklisted(const zend_blacklist *blacklist, const char *verify_path, size_t verify_path_len); +void zend_accel_blacklist_apply(const zend_blacklist *blacklist, blacklist_apply_func_arg_t func, void *argument); #endif /* ZEND_ACCELERATOR_BLACKLIST_H */ diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c index 2fd3dfb5ed56e..5198c0b3b78c3 100644 --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@ -138,7 +138,7 @@ zend_accel_hash_entry* zend_accel_hash_update(zend_accel_hash *accel_hash, zend_ return entry; } -static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_hash, zend_string *key, int data) +static zend_always_inline void* zend_accel_hash_find_ex(const zend_accel_hash *accel_hash, zend_string *key, bool data) { zend_ulong index; zend_accel_hash_entry *entry; @@ -176,20 +176,20 @@ static zend_always_inline void* zend_accel_hash_find_ex(zend_accel_hash *accel_h /* Returns the data associated with key on success * Returns NULL if data doesn't exist */ -void* zend_accel_hash_find(zend_accel_hash *accel_hash, zend_string *key) +void* zend_accel_hash_find(const zend_accel_hash *accel_hash, zend_string *key) { - return zend_accel_hash_find_ex(accel_hash, key, 1); + return zend_accel_hash_find_ex(accel_hash, key, true); } /* Returns the hash entry associated with key on success * Returns NULL if it doesn't exist */ -zend_accel_hash_entry* zend_accel_hash_find_entry(zend_accel_hash *accel_hash, zend_string *key) +zend_accel_hash_entry* zend_accel_hash_find_entry(const zend_accel_hash *accel_hash, zend_string *key) { - return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, 0); + return (zend_accel_hash_entry *)zend_accel_hash_find_ex(accel_hash, key, false); } -int zend_accel_hash_unlink(zend_accel_hash *accel_hash, zend_string *key) +zend_result zend_accel_hash_unlink(zend_accel_hash *accel_hash, zend_string *key) { zend_ulong hash_value; zend_ulong index; diff --git a/ext/opcache/zend_accelerator_hash.h b/ext/opcache/zend_accelerator_hash.h index 755d3f13ec516..2f91973853864 100644 --- a/ext/opcache/zend_accelerator_hash.h +++ b/ext/opcache/zend_accelerator_hash.h @@ -72,23 +72,23 @@ zend_accel_hash_entry* zend_accel_hash_update( void *data); void* zend_accel_hash_find( - zend_accel_hash *accel_hash, + const zend_accel_hash *accel_hash, zend_string *key); zend_accel_hash_entry* zend_accel_hash_find_entry( - zend_accel_hash *accel_hash, + const zend_accel_hash *accel_hash, zend_string *key); -int zend_accel_hash_unlink( +zend_result zend_accel_hash_unlink( zend_accel_hash *accel_hash, zend_string *key); -static inline bool zend_accel_hash_is_full(zend_accel_hash *accel_hash) +static inline bool zend_accel_hash_is_full(const zend_accel_hash *accel_hash) { if (accel_hash->num_entries == accel_hash->max_num_entries) { - return 1; + return true; } else { - return 0; + return false; } } diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index 6f668af9b714d..a2569e07f14c9 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -34,7 +34,6 @@ #include "SAPI.h" #include "zend_virtual_cwd.h" #include "ext/standard/info.h" -#include "ext/standard/php_filestat.h" #include "ext/date/php_date.h" #include "opcache_arginfo.h" @@ -62,7 +61,7 @@ static zif_handler orig_file_exists = NULL; static zif_handler orig_is_file = NULL; static zif_handler orig_is_readable = NULL; -static int validate_api_restriction(void) +static bool validate_api_restriction(void) { if (ZCG(accel_directives).restrict_api && *ZCG(accel_directives).restrict_api) { size_t len = strlen(ZCG(accel_directives).restrict_api); @@ -71,10 +70,10 @@ static int validate_api_restriction(void) strlen(SG(request_info).path_translated) < len || memcmp(SG(request_info).path_translated, ZCG(accel_directives).restrict_api, len) != 0) { zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " API is restricted by \"restrict_api\" configuration directive"); - return 0; + return false; } } - return 1; + return true; } static ZEND_INI_MH(OnUpdateMemoryConsumption) @@ -178,8 +177,8 @@ static ZEND_INI_MH(OnEnable) } return FAILURE; } else { - *p = 0; - ZCG(accelerator_enabled) = 0; + *p = false; + ZCG(accelerator_enabled) = false; return SUCCESS; } } @@ -363,7 +362,7 @@ ZEND_INI_BEGIN() #endif ZEND_INI_END() -static int filename_is_in_cache(zend_string *filename) +static bool filename_is_in_cache(zend_string *filename) { zend_string *key; @@ -373,27 +372,26 @@ static int filename_is_in_cache(zend_string *filename) if (persistent_script && !persistent_script->corrupted) { if (ZCG(accel_directives).validate_timestamps) { zend_file_handle handle; - int ret; + bool ret; zend_stream_init_filename_ex(&handle, filename); - ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS - ? 1 : 0; + ret = validate_timestamp_and_record_ex(persistent_script, &handle) == SUCCESS; zend_destroy_file_handle(&handle); return ret; } - return 1; + return true; } } - return 0; + return false; } -static int filename_is_in_file_cache(zend_string *filename) +static bool filename_is_in_file_cache(zend_string *filename) { zend_string *realpath = zend_resolve_path(filename); if (!realpath) { - return 0; + return false; } zend_file_handle handle; @@ -406,7 +404,7 @@ static int filename_is_in_file_cache(zend_string *filename) return result != NULL; } -static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS) +static bool accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS) { if (ZEND_NUM_ARGS() == 1) { zval *zv = ZEND_CALL_ARG(execute_data , 1); @@ -415,7 +413,7 @@ static int accel_file_in_cache(INTERNAL_FUNCTION_PARAMETERS) return filename_is_in_cache(Z_STR_P(zv)); } } - return 0; + return false; } static ZEND_NAMED_FUNCTION(accel_file_exists) @@ -670,7 +668,7 @@ ZEND_FUNCTION(opcache_get_status) { zend_long reqs; zval memory_usage, statistics, scripts; - bool fetch_scripts = 1; + bool fetch_scripts = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &fetch_scripts) == FAILURE) { RETURN_THROWS(); @@ -937,7 +935,7 @@ ZEND_FUNCTION(opcache_reset) ZEND_FUNCTION(opcache_invalidate) { zend_string *script_name; - bool force = 0; + bool force = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|b", &script_name, &force) == FAILURE) { RETURN_THROWS(); @@ -947,11 +945,7 @@ ZEND_FUNCTION(opcache_invalidate) RETURN_FALSE; } - if (zend_accel_invalidate(script_name, force) == SUCCESS) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(zend_accel_invalidate(script_name, force) == SUCCESS); } /* {{{ Prevents JIT on function. Call it before the first invocation of the given function. */ diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index 99523ca72279d..2de7854fb14c5 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -47,7 +47,7 @@ zend_persistent_script* create_persistent_script(void) return persistent_script; } -void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements) +void free_persistent_script(zend_persistent_script *persistent_script, bool destroy_elements) { if (!destroy_elements) { /* Both the keys and values have been transferred into the global tables. @@ -105,7 +105,7 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s { Bucket *p, *end; HashTable *dst; - zend_string *filename; + const zend_string *filename; dtor_func_t orig_dtor; zend_class_entry *ce; @@ -132,10 +132,10 @@ void zend_accel_move_user_classes(HashTable *src, uint32_t count, zend_script *s src->pDestructor = orig_dtor; } -static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, HashTable *source, bool call_observers) +static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, const HashTable *source, bool call_observers) { zend_function *function1, *function2; - Bucket *p, *end; + const Bucket *p, *end; zval *t; zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0); @@ -174,20 +174,20 @@ static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, } } -static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, HashTable *source) +static zend_always_inline void zend_accel_function_hash_copy(HashTable *target, const HashTable *source) { - _zend_accel_function_hash_copy(target, source, 0); + _zend_accel_function_hash_copy(target, source, false); } -static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, HashTable *source) +static zend_never_inline void zend_accel_function_hash_copy_notify(HashTable *target, const HashTable *source) { - _zend_accel_function_hash_copy(target, source, 1); + _zend_accel_function_hash_copy(target, source, true); } -static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, HashTable *source, bool call_observers) +static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, const HashTable *source, bool call_observers) { - Bucket *p, *end; - zval *t; + const Bucket *p, *end; + const zval *t; zend_hash_extend(target, target->nNumUsed + source->nNumUsed, 0); p = source->arData; @@ -209,7 +209,7 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha * value. */ continue; } else if (UNEXPECTED(!ZCG(accel_directives).ignore_dups)) { - zend_class_entry *ce1 = Z_PTR(p->val); + const zend_class_entry *ce1 = Z_PTR(p->val); if (!(ce1->ce_flags & ZEND_ACC_ANON_CLASS)) { CG(in_compilation) = 1; zend_set_compiled_filename(ce1->info.user.filename); @@ -235,25 +235,25 @@ static zend_always_inline void _zend_accel_class_hash_copy(HashTable *target, Ha target->nInternalPointer = 0; } -static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, HashTable *source) +static zend_always_inline void zend_accel_class_hash_copy(HashTable *target, const HashTable *source) { - _zend_accel_class_hash_copy(target, source, 0); + _zend_accel_class_hash_copy(target, source, false); } -static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, HashTable *source) +static zend_never_inline void zend_accel_class_hash_copy_notify(HashTable *target, const HashTable *source) { - _zend_accel_class_hash_copy(target, source, 1); + _zend_accel_class_hash_copy(target, source, true); } void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script) { - zend_op_array *op_array = &persistent_script->script.main_op_array; + const zend_op_array *op_array = &persistent_script->script.main_op_array; if (!(op_array->fn_flags & ZEND_ACC_EARLY_BINDING)) { return; } - zend_op *end = op_array->opcodes + op_array->last; - for (zend_op *opline = op_array->opcodes; opline < end; opline++) { + const zend_op *end = op_array->opcodes + op_array->last; + for (const zend_op *opline = op_array->opcodes; opline < end; opline++) { if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) { persistent_script->num_early_bindings++; } @@ -264,7 +264,7 @@ void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persist for (zend_op *opline = op_array->opcodes; opline < end; opline++) { if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) { - zval *lcname = RT_CONSTANT(opline, opline->op1); + const zval *lcname = RT_CONSTANT(opline, opline->op1); early_binding->lcname = zend_string_copy(Z_STR_P(lcname)); early_binding->rtd_key = zend_string_copy(Z_STR_P(lcname + 1)); early_binding->lc_parent_name = @@ -275,19 +275,19 @@ void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persist } } -void zend_accel_finalize_delayed_early_binding_list(zend_persistent_script *persistent_script) +void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script) { if (!persistent_script->num_early_bindings) { return; } zend_early_binding *early_binding = persistent_script->early_bindings; - zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings; - zend_op_array *op_array = &persistent_script->script.main_op_array; - zend_op *opline_end = op_array->opcodes + op_array->last; + const zend_early_binding *early_binding_end = early_binding + persistent_script->num_early_bindings; + const zend_op_array *op_array = &persistent_script->script.main_op_array; + const zend_op *opline_end = op_array->opcodes + op_array->last; for (zend_op *opline = op_array->opcodes; opline < opline_end; opline++) { if (opline->opcode == ZEND_DECLARE_CLASS_DELAYED) { - zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1); + const zend_string *rtd_key = Z_STR_P(RT_CONSTANT(opline, opline->op1) + 1); /* Skip early_binding entries that don't match, maybe their DECLARE_CLASS_DELAYED * was optimized away. */ while (!zend_string_equals(early_binding->rtd_key, rtd_key)) { @@ -310,7 +310,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste { if (persistent_script->num_early_bindings) { for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) { - zend_early_binding *early_binding = &persistent_script->early_bindings[i]; + const zend_early_binding *early_binding = &persistent_script->early_bindings[i]; zend_string_release(early_binding->lcname); zend_string_release(early_binding->rtd_key); zend_string_release(early_binding->lc_parent_name); @@ -322,7 +322,7 @@ void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persiste } static void zend_accel_do_delayed_early_binding( - zend_persistent_script *persistent_script, zend_op_array *op_array) + const zend_persistent_script *persistent_script, zend_op_array *op_array) { ZEND_ASSERT(!ZEND_MAP_PTR(op_array->run_time_cache)); ZEND_ASSERT(op_array->fn_flags & ZEND_ACC_HEAP_RT_CACHE); @@ -336,7 +336,7 @@ static void zend_accel_do_delayed_early_binding( CG(compiled_filename) = persistent_script->script.filename; CG(in_compilation) = 1; for (uint32_t i = 0; i < persistent_script->num_early_bindings; i++) { - zend_early_binding *early_binding = &persistent_script->early_bindings[i]; + const zend_early_binding *early_binding = &persistent_script->early_bindings[i]; zend_class_entry *ce = zend_hash_find_ex_ptr(EG(class_table), early_binding->lcname, 1); if (!ce) { zval *zv = zend_hash_find_known_hash(EG(class_table), early_binding->rtd_key); @@ -358,7 +358,7 @@ static void zend_accel_do_delayed_early_binding( CG(in_compilation) = orig_in_compilation; } -zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory) +zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, bool from_shared_memory) { zend_op_array *op_array; @@ -448,7 +448,7 @@ zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, #define ADLER32_SCALAR_DO8(buf, i) ADLER32_SCALAR_DO4(buf, i); ADLER32_SCALAR_DO4(buf, i + 4); #define ADLER32_SCALAR_DO16(buf) ADLER32_SCALAR_DO8(buf, 0); ADLER32_SCALAR_DO8(buf, 8); -static zend_always_inline void adler32_do16_loop(unsigned char *buf, unsigned char *end, unsigned int *s1_out, unsigned int *s2_out) +static zend_always_inline void adler32_do16_loop(unsigned char *buf, const unsigned char *end, unsigned int *s1_out, unsigned int *s2_out) { unsigned int s1 = *s1_out; unsigned int s2 = *s2_out; diff --git a/ext/opcache/zend_accelerator_util_funcs.h b/ext/opcache/zend_accelerator_util_funcs.h index 53cc1de9effaa..fa248edeef550 100644 --- a/ext/opcache/zend_accelerator_util_funcs.h +++ b/ext/opcache/zend_accelerator_util_funcs.h @@ -28,15 +28,15 @@ BEGIN_EXTERN_C() zend_persistent_script* create_persistent_script(void); -void free_persistent_script(zend_persistent_script *persistent_script, int destroy_elements); +void free_persistent_script(zend_persistent_script *persistent_script, bool destroy_elements); void zend_accel_move_user_functions(HashTable *str, uint32_t count, zend_script *script); void zend_accel_move_user_classes(HashTable *str, uint32_t count, zend_script *script); void zend_accel_build_delayed_early_binding_list(zend_persistent_script *persistent_script); -void zend_accel_finalize_delayed_early_binding_list(zend_persistent_script *persistent_script); +void zend_accel_finalize_delayed_early_binding_list(const zend_persistent_script *persistent_script); void zend_accel_free_delayed_early_binding_list(zend_persistent_script *persistent_script); -zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, int from_shared_memory); +zend_op_array* zend_accel_load_script(zend_persistent_script *persistent_script, bool from_shared_memory); #define ADLER32_INIT 1 /* initial Adler-32 value */ diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 38e58d5a16632..ef69cceb0250b 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -732,7 +732,7 @@ static void zend_persist_op_array(zval *zv) } } -static zend_op_array *zend_persist_class_method(zend_op_array *op_array, zend_class_entry *ce) +static zend_op_array *zend_persist_class_method(zend_op_array *op_array, const zend_class_entry *ce) { zend_op_array *old_op_array; @@ -834,7 +834,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop) prop->attributes = zend_persist_attributes(prop->attributes); } if (prop->prototype) { - zend_property_info *new_prototype = (zend_property_info *) zend_shared_alloc_get_xlat_entry(prop->prototype); + const zend_property_info *new_prototype = (const zend_property_info *) zend_shared_alloc_get_xlat_entry(prop->prototype); if (new_prototype) { prop->prototype = new_prototype; } @@ -854,7 +854,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop) } } #endif - zend_property_info *new_prop_info = (zend_property_info *) zend_shared_alloc_get_xlat_entry(hook->prop_info); + const zend_property_info *new_prop_info = (const zend_property_info *) zend_shared_alloc_get_xlat_entry(hook->prop_info); if (new_prop_info) { hook->prop_info = new_prop_info; } @@ -868,7 +868,7 @@ static zend_property_info *zend_persist_property_info(zend_property_info *prop) static void zend_persist_class_constant(zval *zv) { - zend_class_constant *orig_c = Z_PTR_P(zv); + const 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; @@ -967,12 +967,11 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce) } } if (ce->default_static_members_table) { - int i; ce->default_static_members_table = zend_shared_memdup_free(ce->default_static_members_table, sizeof(zval) * ce->default_static_members_count); /* Persist only static properties in this class. * Static properties from parent classes will be handled in class_copy_ctor and are marked with IS_INDIRECT */ - for (i = 0; i < ce->default_static_members_count; i++) { + for (uint32_t i = 0; i < ce->default_static_members_count; i++) { if (Z_TYPE(ce->default_static_members_table[i]) != IS_INDIRECT) { zend_persist_zval(&ce->default_static_members_table[i]); } @@ -1287,7 +1286,7 @@ void zend_update_parent_ce(zend_class_entry *ce) } #ifdef HAVE_JIT -static void zend_accel_persist_jit_op_array(zend_op_array *op_array, zend_class_entry *ce) +static void zend_accel_persist_jit_op_array(zend_op_array *op_array, const zend_class_entry *ce) { if (op_array->type == ZEND_USER_FUNCTION) { if (op_array->scope == ce @@ -1301,7 +1300,7 @@ static void zend_accel_persist_jit_op_array(zend_op_array *op_array, zend_class_ } } -static void zend_accel_persist_link_func_info(zend_op_array *op_array, zend_class_entry *ce) +static void zend_accel_persist_link_func_info(zend_op_array *op_array, const zend_class_entry *ce) { if (op_array->type == ZEND_USER_FUNCTION && !(op_array->fn_flags & ZEND_ACC_ABSTRACT)) { @@ -1421,7 +1420,7 @@ static zend_early_binding *zend_persist_early_bindings( return early_bindings; } -zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, int for_shm) +zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, bool for_shm) { Bucket *p; diff --git a/ext/opcache/zend_persist.h b/ext/opcache/zend_persist.h index 930430c9589b7..c8220217630e7 100644 --- a/ext/opcache/zend_persist.h +++ b/ext/opcache/zend_persist.h @@ -24,8 +24,8 @@ BEGIN_EXTERN_C() -uint32_t zend_accel_script_persist_calc(zend_persistent_script *script, int for_shm); -zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, int for_shm); +uint32_t zend_accel_script_persist_calc(zend_persistent_script *script, bool for_shm); +zend_persistent_script *zend_accel_script_persist(zend_persistent_script *script, bool for_shm); void zend_persist_class_entry_calc(zend_class_entry *ce); zend_class_entry *zend_persist_class_entry(zend_class_entry *ce); diff --git a/ext/opcache/zend_persist_calc.c b/ext/opcache/zend_persist_calc.c index 106a69f5dd383..c638d66619d0f 100644 --- a/ext/opcache/zend_persist_calc.c +++ b/ext/opcache/zend_persist_calc.c @@ -47,9 +47,9 @@ } while (0) static void zend_persist_zval_calc(zval *z); -static void zend_persist_op_array_calc(zval *zv); +static void zend_persist_op_array_calc(const zval *zv); -static void zend_hash_persist_calc(HashTable *ht) +static void zend_hash_persist_calc(const HashTable *ht) { if ((HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED) || ht->nNumUsed == 0) { return; @@ -79,7 +79,7 @@ static void zend_persist_ast_calc(zend_ast *ast) ADD_SIZE(sizeof(zend_ast_zval)); zend_persist_zval_calc(&((zend_ast_zval*)(ast))->val); } else if (zend_ast_is_list(ast)) { - zend_ast_list *list = zend_ast_get_list(ast); + const zend_ast_list *list = zend_ast_get_list(ast); ADD_SIZE(sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * list->children); for (i = 0; i < list->children; i++) { if (list->child[i]) { @@ -125,7 +125,7 @@ static void zend_persist_zval_calc(zval *z) } size = zend_shared_memdup_size(Z_ARR_P(z), sizeof(zend_array)); if (size) { - HashTable *ht = Z_ARRVAL_P(z); + const HashTable *ht = Z_ARRVAL_P(z); ADD_SIZE(size); zend_hash_persist_calc(ht); @@ -218,7 +218,7 @@ static void zend_persist_type_calc(zend_type *type) static void zend_persist_op_array_calc_ex(zend_op_array *op_array) { if (op_array->function_name) { - zend_string *old_name = op_array->function_name; + const zend_string *old_name = op_array->function_name; ADD_INTERNED_STRING(op_array->function_name); /* Remember old function name, so it can be released multiple times if shared. */ if (op_array->function_name != old_name @@ -258,7 +258,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array) if (op_array->literals) { zval *p = op_array->literals; - zval *end = p + op_array->last_literal; + const zval *end = p + op_array->last_literal; ADD_SIZE(sizeof(zval) * op_array->last_literal); while (p < end) { zend_persist_zval_calc(p); @@ -272,7 +272,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array) /* ZEND_ACC_PTR_OPS and ZEND_ACC_OVERRIDE use the same value */ if ((op_array->fn_flags & ZEND_ACC_PTR_OPS) && !op_array->function_name) { zend_op *op = op_array->opcodes; - zend_op *end = op + op_array->last; + const zend_op *end = op + op_array->last; while (op < end) { if (op->opcode == ZEND_DECLARE_ATTRIBUTED_CONST) { HashTable *attributes = Z_PTR_P(RT_CONSTANT(op+1, (op+1)->op1)); @@ -344,7 +344,7 @@ static void zend_persist_op_array_calc_ex(zend_op_array *op_array) ADD_SIZE(ZEND_ALIGNED_SIZE(zend_extensions_op_array_persist_calc(op_array))); } -static void zend_persist_op_array_calc(zval *zv) +static void zend_persist_op_array_calc(const zval *zv) { zend_op_array *op_array = Z_PTR_P(zv); ZEND_ASSERT(op_array->type == ZEND_USER_FUNCTION); @@ -417,7 +417,7 @@ static void zend_persist_property_info_calc(zend_property_info *prop) } } -static void zend_persist_class_constant_calc(zval *zv) +static void zend_persist_class_constant_calc(const zval *zv) { zend_class_constant *c = Z_PTR_P(zv); @@ -479,10 +479,8 @@ void zend_persist_class_entry_calc(zend_class_entry *ce) } } if (ce->default_static_members_table) { - int i; - ADD_SIZE(sizeof(zval) * ce->default_static_members_count); - for (i = 0; i < ce->default_static_members_count; i++) { + for (uint32_t i = 0; i < ce->default_static_members_count; i++) { if (Z_TYPE(ce->default_static_members_table[i]) != IS_INDIRECT) { zend_persist_zval_calc(&ce->default_static_members_table[i]); } @@ -596,7 +594,7 @@ void zend_persist_class_entry_calc(zend_class_entry *ce) } } -static void zend_accel_persist_class_table_calc(HashTable *class_table) +static void zend_accel_persist_class_table_calc(const HashTable *class_table) { Bucket *p; @@ -629,7 +627,7 @@ static void zend_persist_early_bindings_calc( } } -uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, int for_shm) +uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_script, bool for_shm) { Bucket *p; diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index cb134e9154b52..2c09b89e31200 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -303,7 +303,7 @@ bool php_openssl_check_path_ex( fs_file_path_len = file_path_len; } - if (CHECK_NULL_PATH(fs_file_path, fs_file_path_len)) { + if (zend_char_has_nul_byte(fs_file_path, fs_file_path_len)) { error_msg = "must not contain any null bytes"; error_type = E_ERROR; } else if (expand_filepath(fs_file_path, real_path) == NULL) { @@ -4370,7 +4370,7 @@ PHP_FUNCTION(openssl_open) /* {{{ Return array of available digest algorithms */ PHP_FUNCTION(openssl_get_md_methods) { - bool aliases = 0; + bool aliases = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &aliases) == FAILURE) { RETURN_THROWS(); @@ -4382,7 +4382,7 @@ PHP_FUNCTION(openssl_get_md_methods) /* {{{ Return array of available cipher algorithms */ PHP_FUNCTION(openssl_get_cipher_methods) { - bool aliases = 0; + bool aliases = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &aliases) == FAILURE) { RETURN_THROWS(); @@ -4424,7 +4424,7 @@ PHP_FUNCTION(openssl_get_curve_names) /* {{{ Computes digest hash value for given data using given method, returns raw or binhex encoded string */ PHP_FUNCTION(openssl_digest) { - bool raw_output = 0; + bool raw_output = false; char *data, *method; size_t data_len, method_len; const EVP_MD *mdtype; diff --git a/ext/openssl/openssl_backend_common.c b/ext/openssl/openssl_backend_common.c index c21e64a1306eb..611359cccaba6 100644 --- a/ext/openssl/openssl_backend_common.c +++ b/ext/openssl/openssl_backend_common.c @@ -570,12 +570,12 @@ X509 *php_openssl_x509_from_zval( zval *val, bool *free_cert, uint32_t arg_num, bool is_from_array, const char *option_name) { if (php_openssl_is_certificate_ce(val)) { - *free_cert = 0; + *free_cert = false; return php_openssl_certificate_from_obj(Z_OBJ_P(val))->x509; } - *free_cert = 1; + *free_cert = true; zend_string *str = zval_try_get_string(val); if (str == NULL) { @@ -1256,7 +1256,7 @@ EVP_PKEY *php_openssl_pkey_from_zval( cert = php_openssl_x509_from_str(val_str, arg_num, false, NULL); if (cert) { - free_cert = 1; + free_cert = true; } else { /* not a X509 certificate, try to retrieve public key */ php_openssl_errors_restore_mark(); @@ -1685,7 +1685,7 @@ zend_result php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv /* BC behavior */ *piv_len = iv_required_len; *piv = iv_new; - *free_iv = 1; + *free_iv = true; return SUCCESS; } @@ -1697,7 +1697,7 @@ zend_result php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv memcpy(iv_new, *piv, *piv_len); *piv_len = iv_required_len; *piv = iv_new; - *free_iv = 1; + *free_iv = true; return SUCCESS; } @@ -1707,7 +1707,7 @@ zend_result php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv memcpy(iv_new, *piv, iv_required_len); *piv_len = iv_required_len; *piv = iv_new; - *free_iv = 1; + *free_iv = true; return SUCCESS; } @@ -1722,7 +1722,7 @@ zend_result php_openssl_cipher_init(const EVP_CIPHER *cipher_type, int key_len, password_len; size_t max_iv_len; - *free_password = 0; + *free_password = false; max_iv_len = EVP_CIPHER_iv_length(cipher_type); if (enc && *piv_len == 0 && max_iv_len > 0 && !mode->is_aead) { @@ -1765,7 +1765,7 @@ zend_result php_openssl_cipher_init(const EVP_CIPHER *cipher_type, memcpy(key, *ppassword, password_len); *ppassword = (char *) key; *ppassword_len = key_len; - *free_password = 1; + *free_password = true; } else { if (password_len > key_len && !EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len)) { php_openssl_store_errors(); @@ -1837,7 +1837,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt( EVP_CIPHER_CTX *cipher_ctx; struct php_openssl_cipher_mode mode; int i = 0, outlen; - bool free_iv = 0, free_password = 0; + bool free_iv = false, free_password = false; zend_string *outbuf = NULL; PHP_OPENSSL_CHECK_SIZE_T_TO_INT_NULL_RETURN(data_len, data); @@ -1931,7 +1931,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt( struct php_openssl_cipher_mode mode; int i = 0, outlen; zend_string *base64_str = NULL; - bool free_iv = 0, free_password = 0; + bool free_iv = false, free_password = false; zend_string *outbuf = NULL; PHP_OPENSSL_CHECK_SIZE_T_TO_INT_NULL_RETURN(data_len, data); diff --git a/ext/openssl/openssl_backend_v1.c b/ext/openssl/openssl_backend_v1.c index 873464574fb28..81c327dbfe34b 100644 --- a/ext/openssl/openssl_backend_v1.c +++ b/ext/openssl/openssl_backend_v1.c @@ -88,23 +88,23 @@ static bool php_openssl_pkey_init_rsa_data(RSA *rsa, zval *data) OPENSSL_PKEY_SET_BN(data, e); OPENSSL_PKEY_SET_BN(data, d); if (!n || !d || !RSA_set0_key(rsa, n, e, d)) { - return 0; + return false; } OPENSSL_PKEY_SET_BN(data, p); OPENSSL_PKEY_SET_BN(data, q); if ((p || q) && !RSA_set0_factors(rsa, p, q)) { - return 0; + return false; } OPENSSL_PKEY_SET_BN(data, dmp1); OPENSSL_PKEY_SET_BN(data, dmq1); OPENSSL_PKEY_SET_BN(data, iqmp); if ((dmp1 || dmq1 || iqmp) && !RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp)) { - return 0; + return false; } - return 1; + return true; } EVP_PKEY *php_openssl_pkey_init_rsa(zval *data) @@ -141,7 +141,7 @@ static bool php_openssl_pkey_init_dsa_data(DSA *dsa, zval *data, bool *is_privat OPENSSL_PKEY_SET_BN(data, q); OPENSSL_PKEY_SET_BN(data, g); if (!p || !q || !g || !DSA_set0_pqg(dsa, p, q, g)) { - return 0; + return false; } OPENSSL_PKEY_SET_BN(data, pub_key); @@ -154,18 +154,18 @@ static bool php_openssl_pkey_init_dsa_data(DSA *dsa, zval *data, bool *is_privat /* generate key */ if (!DSA_generate_key(dsa)) { php_openssl_store_errors(); - return 0; + return false; } /* if BN_mod_exp return -1, then DSA_generate_key succeed for failed key * so we need to double check that public key is created */ DSA_get0_key(dsa, &pub_key_const, &priv_key_const); if (!pub_key_const || BN_is_zero(pub_key_const)) { - return 0; + return false; } /* all good */ *is_private = true; - return 1; + return true; } EVP_PKEY *php_openssl_pkey_init_dsa(zval *data, bool *is_private) @@ -202,7 +202,7 @@ static bool php_openssl_pkey_init_dh_data(DH *dh, zval *data, bool *is_private) OPENSSL_PKEY_SET_BN(data, q); OPENSSL_PKEY_SET_BN(data, g); if (!p || !g || !DH_set0_pqg(dh, p, q, g)) { - return 0; + return false; } OPENSSL_PKEY_SET_BN(data, priv_key); @@ -214,7 +214,7 @@ static bool php_openssl_pkey_init_dh_data(DH *dh, zval *data, bool *is_private) if (priv_key) { pub_key = php_openssl_dh_pub_from_priv(priv_key, g, p); if (pub_key == NULL) { - return 0; + return false; } return DH_set0_key(dh, pub_key, priv_key); } @@ -222,11 +222,11 @@ static bool php_openssl_pkey_init_dh_data(DH *dh, zval *data, bool *is_private) /* generate key */ if (!DH_generate_key(dh)) { php_openssl_store_errors(); - return 0; + return false; } /* all good */ *is_private = true; - return 1; + return true; } EVP_PKEY *php_openssl_pkey_init_dh(zval *data, bool *is_private) diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index ba4f63774af04..62929246a07f0 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -244,7 +244,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i switch(err) { case SSL_ERROR_ZERO_RETURN: /* SSL terminated (but socket may still be active) */ - retry = 0; + retry = false; break; case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_WRITE: @@ -261,7 +261,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i } SSL_set_shutdown(sslsock->ssl_handle, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); stream->eof = 1; - retry = 0; + retry = false; } else { char *estr = php_socket_strerror(php_socket_errno(), NULL, 0); @@ -269,7 +269,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i "SSL: %s", estr); efree(estr); - retry = 0; + retry = false; } break; } @@ -285,7 +285,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i "SSL_R_NO_SHARED_CIPHER: no suitable shared cipher could be used. " "This could be because the server is missing an SSL certificate " "(local_cert context option)"); - retry = 0; + retry = false; break; default: @@ -310,7 +310,7 @@ static int php_openssl_handle_ssl_error(php_stream *stream, int nr_bytes, bool i } } - retry = 0; + retry = false; errno = 0; } return retry; @@ -360,7 +360,7 @@ static int php_openssl_x509_fingerprint_cmp(X509 *peer, const char *method, cons zend_string *fingerprint; int result = -1; - fingerprint = php_openssl_x509_fingerprint(peer, method, 0); + fingerprint = php_openssl_x509_fingerprint(peer, method, false); if (fingerprint) { result = strcasecmp(expected, ZSTR_VAL(fingerprint)); zend_string_release_ex(fingerprint, 0); @@ -391,26 +391,26 @@ static bool php_openssl_x509_fingerprint_match(X509 *peer, zval *val) if (!zend_hash_num_elements(Z_ARRVAL_P(val))) { php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint array; [algo => fingerprint] form required"); - return 0; + return false; } ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(val), key, current) { if (key == NULL || Z_TYPE_P(current) != IS_STRING) { php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint array; [algo => fingerprint] form required"); - return 0; + return false; } if (php_openssl_x509_fingerprint_cmp(peer, ZSTR_VAL(key), Z_STRVAL_P(current)) != 0) { - return 0; + return false; } } ZEND_HASH_FOREACH_END(); - return 1; + return true; } else { php_error_docref(NULL, E_WARNING, "Invalid peer_fingerprint value; fingerprint string or array of the form [algo => fingerprint] required"); } - return 0; + return false; } static bool php_openssl_matches_wildcard_name(const char *subjectname, const char *certname) /* {{{ */ @@ -420,18 +420,18 @@ static bool php_openssl_matches_wildcard_name(const char *subjectname, const cha size_t suffix_len, subject_len; if (strcasecmp(subjectname, certname) == 0) { - return 1; + return true; } /* wildcard, if present, must only be present in the left-most component */ if (!(wildcard = strchr(certname, '*')) || memchr(certname, '.', wildcard - certname)) { - return 0; + return false; } /* 1) prefix, if not empty, must match subject */ prefix_len = wildcard - certname; if (prefix_len && strncasecmp(subjectname, certname, prefix_len) != 0) { - return 0; + return false; } suffix_len = strlen(wildcard + 1); @@ -444,7 +444,7 @@ static bool php_openssl_matches_wildcard_name(const char *subjectname, const cha memchr(subjectname + prefix_len, '.', subject_len - suffix_len - prefix_len) == NULL; } - return 0; + return false; } /* }}} */ @@ -491,7 +491,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) / OPENSSL_free(cert_name); sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free); - return 1; + return true; } OPENSSL_free(cert_name); } else if (san->type == GEN_IPADD) { @@ -505,7 +505,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) / if (strcasecmp(subject_name, (const char*)ipbuffer) == 0) { sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free); - return 1; + return true; } } #ifdef HAVE_IPV6_SAN @@ -515,7 +515,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) / if (strcasecmp((const char*)subject_name_ipv6_expanded, (const char*)ipbuffer) == 0) { sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free); - return 1; + return true; } } #endif @@ -524,7 +524,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) / sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free); - return 0; + return false; } /* }}} */ @@ -532,7 +532,7 @@ static bool php_openssl_matches_common_name(X509 *peer, const char *subject_name { char buf[1024]; X509_NAME *cert_name; - bool is_match = 0; + bool is_match = false; int cert_name_len; cert_name = X509_get_subject_name(peer); @@ -543,7 +543,7 @@ static bool php_openssl_matches_common_name(X509 *peer, const char *subject_name } else if ((size_t)cert_name_len != strlen(buf)) { php_error_docref(NULL, E_WARNING, "Peer certificate CN=`%.*s' is malformed", cert_name_len, buf); } else if (php_openssl_matches_wildcard_name(subject_name, buf)) { - is_match = 1; + is_match = true; } else { php_error_docref(NULL, E_WARNING, "Peer certificate CN=`%.*s' did not match expected CN=`%s'", @@ -679,7 +679,7 @@ static int php_openssl_win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx, php_stream *stream; php_openssl_netstream_data_t *sslsock; zval *val; - bool is_self_signed = 0; + bool is_self_signed = false; stream = (php_stream*)arg; @@ -740,7 +740,7 @@ static int php_openssl_win_cert_verify_callback(X509_STORE_CTX *x509_store_ctx, /* check if the cert is self-signed */ if (cert_chain_ctx->cChain > 0 && cert_chain_ctx->rgpChain[0]->cElement > 0 && (cert_chain_ctx->rgpChain[0]->rgpElement[0]->TrustStatus.dwInfoStatus & CERT_TRUST_IS_SELF_SIGNED) != 0) { - is_self_signed = 1; + is_self_signed = true; } /* check the depth */ @@ -1701,7 +1701,7 @@ static zend_result php_openssl_setup_crypto(php_stream *stream, } if (!SSL_set_fd(sslsock->ssl_handle, sslsock->s.socket)) { - php_openssl_handle_ssl_error(stream, 0, 1); + php_openssl_handle_ssl_error(stream, 0, true); } #ifdef HAVE_TLS_SNI @@ -2020,7 +2020,7 @@ static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, si /* Get the error code from SSL, and check to see if it's an error or not. */ int err = SSL_get_error(sslsock->ssl_handle, nr_bytes ); - retry = php_openssl_handle_ssl_error(stream, nr_bytes, 0); + retry = php_openssl_handle_ssl_error(stream, nr_bytes, false); /* If we get this (the above doesn't check) then we'll retry as well. */ if (errno == EAGAIN && err == SSL_ERROR_WANT_READ && read) { @@ -2219,8 +2219,7 @@ static int php_openssl_sockop_stat(php_stream *stream, php_stream_statbuf *ssb) static inline int php_openssl_tcp_sockop_accept(php_stream *stream, php_openssl_netstream_data_t *sock, php_stream_xport_param *xparam STREAMS_DC) /* {{{ */ { - php_socket_t clisock; - bool nodelay = 0; + bool nodelay = false; zval *tmpzval = NULL; xparam->outputs.client = NULL; @@ -2228,10 +2227,10 @@ static inline int php_openssl_tcp_sockop_accept(php_stream *stream, php_openssl_ if (PHP_STREAM_CONTEXT(stream) && (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "tcp_nodelay")) != NULL && zend_is_true(tmpzval)) { - nodelay = 1; + nodelay = true; } - clisock = php_network_accept_incoming(sock->s.socket, + php_socket_t clisock = php_network_accept_incoming(sock->s.socket, xparam->want_textaddr ? &xparam->outputs.textaddr : NULL, xparam->want_addr ? &xparam->outputs.addr : NULL, xparam->want_addr ? &xparam->outputs.addrlen : NULL, diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 4d1b5dff2e353..886a292ee290d 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -94,7 +94,7 @@ typedef cpuset_t *cpu_set_t; #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_getaffinity(p, c, m) pset_bind(PS_QUERY, P_PID, 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) diff --git a/ext/pcre/pcre2lib/pcre2_chartables.c b/ext/pcre/pcre2lib/pcre2_chartables.c index 861914d1ac3ac..7362c3f2345ab 100644 --- a/ext/pcre/pcre2lib/pcre2_chartables.c +++ b/ext/pcre/pcre2lib/pcre2_chartables.c @@ -5,7 +5,8 @@ /* This file was automatically written by the pcre2_dftables auxiliary program. It contains character tables that are used when no external tables are passed to PCRE2 by the application that calls it. The tables -are used only for characters whose code values are less than 256. */ +are used only for characters whose code values are less than 256, and +only relevant if not in UCP mode. */ /* This set of tables was written in the C locale. */ @@ -18,13 +19,6 @@ PCRE2 is configured with --enable-rebuild-chartables. However, you can run pcre2_dftables manually with the -L option to build tables using the LC_ALL locale. */ -/* The following #include is present because without it gcc 4.x may remove -the array definition from the final binary if PCRE2 is built into a static -library and dead code stripping is activated. This leads to link errors. -Pulling in the header ensures that the array gets flagged as "someone -outside this compilation unit might reference this" and so it will always -be supplied to the linker. */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -163,7 +157,7 @@ graph, print, punct, and cntrl. Other classes are built from combinations. */ 0x02 letter 0x04 lower case letter 0x08 decimal digit - 0x10 alphanumeric or '_' + 0x10 word (alphanumeric or '_') */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */ diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 8e0fb2cce5f9b..b59bd87f92385 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -1132,12 +1132,12 @@ static zend_always_inline bool is_known_valid_utf8( zend_string *subject_str, PCRE2_SIZE start_offset) { if (!ZSTR_IS_VALID_UTF8(subject_str)) { /* We don't know whether the string is valid UTF-8 or not. */ - return 0; + return false; } if (start_offset == ZSTR_LEN(subject_str)) { /* Degenerate case: Offset points to end of string. */ - return 1; + return true; } /* Check that the offset does not point to an UTF-8 continuation byte. */ @@ -1687,10 +1687,10 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su walk = ZSTR_VAL(replace_str); replace_end = walk + ZSTR_LEN(replace_str); walk_last = 0; - simple_string = 1; + simple_string = true; while (walk < replace_end) { if ('\\' == *walk || '$' == *walk) { - simple_string = 0; + simple_string = false; if (walk_last == '\\') { walk++; walk_last = 0; diff --git a/ext/pdo/pdo_arginfo.h b/ext/pdo/pdo_arginfo.h index d2df2f0b0eb23..8f452cf4b032c 100644 --- a/ext/pdo/pdo_arginfo.h +++ b/ext/pdo/pdo_arginfo.h @@ -24,9 +24,9 @@ static zend_class_entry *register_class_PDOException(zend_class_entry *class_ent zval property_errorInfo_default_value; ZVAL_NULL(&property_errorInfo_default_value); - zend_string *property_errorInfo_name = zend_string_init("errorInfo", sizeof("errorInfo") - 1, 1); + zend_string *property_errorInfo_name = zend_string_init("errorInfo", sizeof("errorInfo") - 1, true); zend_declare_typed_property(class_entry, property_errorInfo_name, &property_errorInfo_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL)); - zend_string_release(property_errorInfo_name); + zend_string_release_ex(property_errorInfo_name, true); return class_entry; } diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c index 08e398ea3682e..34f19e364faa7 100644 --- a/ext/pdo/pdo_dbh.c +++ b/ext/pdo/pdo_dbh.c @@ -805,7 +805,7 @@ PDO_API bool pdo_get_bool_param(bool *bval, const zval *value) *bval = false; return true; case IS_LONG: - *bval = zval_is_true(value); + *bval = zend_is_true(value); return true; case IS_STRING: /* TODO Should string be allowed? */ default: @@ -1190,7 +1190,7 @@ PHP_METHOD(PDO, query) pdo_stmt_t *stmt; zend_string *statement; zend_long fetch_mode; - bool fetch_mode_is_null = 1; + bool fetch_mode_is_null = true; zval *args = NULL; uint32_t num_args = 0; pdo_dbh_object_t *dbh_obj = Z_PDO_OBJECT_P(ZEND_THIS); @@ -1321,6 +1321,7 @@ static void cls_method_dtor(zval *el) /* {{{ */ { if (func->common.attributes) { zend_hash_release(func->common.attributes); } + zend_free_internal_arg_info(&func->internal_function, false); efree(func); } /* }}} */ @@ -1336,6 +1337,7 @@ static void cls_method_pdtor(zval *el) /* {{{ */ { if (func->common.attributes) { zend_hash_release(func->common.attributes); } + zend_free_internal_arg_info(&func->internal_function, true); pefree(func, 1); } /* }}} */ @@ -1408,7 +1410,19 @@ bool pdo_hash_methods(pdo_dbh_object_t *dbh_obj, int kind) if (funcs->arg_info) { zend_internal_function_info *info = (zend_internal_function_info*)funcs->arg_info; - func.arg_info = (zend_internal_arg_info*)funcs->arg_info + 1; + uint32_t num_arg_info = 1 + funcs->num_args; + if (func.fn_flags & ZEND_ACC_VARIADIC) { + num_arg_info++; + } + + zend_arg_info *arg_info = safe_pemalloc(num_arg_info, + sizeof(zend_arg_info), 0, dbh->is_persistent); + for (uint32_t i = 0; i < num_arg_info; i++) { + zend_convert_internal_arg_info(&arg_info[i], + &funcs->arg_info[i], i == 0, dbh->is_persistent); + } + + func.arg_info = arg_info + 1; func.num_args = funcs->num_args; if (info->required_num_args == (uint32_t)-1) { func.required_num_args = funcs->num_args; @@ -1594,7 +1608,7 @@ static void pdo_dbh_free_storage(zend_object *std) dbh->methods->persistent_shutdown(dbh); } zend_object_std_dtor(std); - dbh_free(dbh, 0); + dbh_free(dbh, false); } zend_object *pdo_dbh_new(zend_class_entry *ce) @@ -1618,7 +1632,7 @@ ZEND_RSRC_DTOR_FUNC(php_pdo_pdbh_dtor) /* {{{ */ { if (res->ptr) { pdo_dbh_t *dbh = (pdo_dbh_t*)res->ptr; - dbh_free(dbh, 1); + dbh_free(dbh, true); res->ptr = NULL; } } diff --git a/ext/pdo/pdo_dbh_arginfo.h b/ext/pdo/pdo_dbh_arginfo.h index 71df4c519e1a7..cc622a52e2688 100644 --- a/ext/pdo/pdo_dbh_arginfo.h +++ b/ext/pdo/pdo_dbh_arginfo.h @@ -111,454 +111,454 @@ static zend_class_entry *register_class_PDO(void) zval const_PARAM_NULL_value; ZVAL_LONG(&const_PARAM_NULL_value, LONG_CONST(PDO_PARAM_NULL)); - zend_string *const_PARAM_NULL_name = zend_string_init_interned("PARAM_NULL", sizeof("PARAM_NULL") - 1, 1); + zend_string *const_PARAM_NULL_name = zend_string_init_interned("PARAM_NULL", sizeof("PARAM_NULL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_NULL_name, &const_PARAM_NULL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_NULL_name); + zend_string_release_ex(const_PARAM_NULL_name, true); ZEND_ASSERT(LONG_CONST(PDO_PARAM_NULL) == 0); zval const_PARAM_BOOL_value; ZVAL_LONG(&const_PARAM_BOOL_value, LONG_CONST(PDO_PARAM_BOOL)); - zend_string *const_PARAM_BOOL_name = zend_string_init_interned("PARAM_BOOL", sizeof("PARAM_BOOL") - 1, 1); + zend_string *const_PARAM_BOOL_name = zend_string_init_interned("PARAM_BOOL", sizeof("PARAM_BOOL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_BOOL_name, &const_PARAM_BOOL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_BOOL_name); + zend_string_release_ex(const_PARAM_BOOL_name, true); ZEND_ASSERT(LONG_CONST(PDO_PARAM_BOOL) == 5); zval const_PARAM_INT_value; ZVAL_LONG(&const_PARAM_INT_value, LONG_CONST(PDO_PARAM_INT)); - zend_string *const_PARAM_INT_name = zend_string_init_interned("PARAM_INT", sizeof("PARAM_INT") - 1, 1); + zend_string *const_PARAM_INT_name = zend_string_init_interned("PARAM_INT", sizeof("PARAM_INT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_INT_name, &const_PARAM_INT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_INT_name); + zend_string_release_ex(const_PARAM_INT_name, true); ZEND_ASSERT(LONG_CONST(PDO_PARAM_INT) == 1); zval const_PARAM_STR_value; ZVAL_LONG(&const_PARAM_STR_value, LONG_CONST(PDO_PARAM_STR)); - zend_string *const_PARAM_STR_name = zend_string_init_interned("PARAM_STR", sizeof("PARAM_STR") - 1, 1); + zend_string *const_PARAM_STR_name = zend_string_init_interned("PARAM_STR", sizeof("PARAM_STR") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_STR_name, &const_PARAM_STR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_STR_name); + zend_string_release_ex(const_PARAM_STR_name, true); ZEND_ASSERT(LONG_CONST(PDO_PARAM_STR) == 2); zval const_PARAM_LOB_value; ZVAL_LONG(&const_PARAM_LOB_value, LONG_CONST(PDO_PARAM_LOB)); - zend_string *const_PARAM_LOB_name = zend_string_init_interned("PARAM_LOB", sizeof("PARAM_LOB") - 1, 1); + zend_string *const_PARAM_LOB_name = zend_string_init_interned("PARAM_LOB", sizeof("PARAM_LOB") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_LOB_name, &const_PARAM_LOB_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_LOB_name); + zend_string_release_ex(const_PARAM_LOB_name, true); ZEND_ASSERT(LONG_CONST(PDO_PARAM_LOB) == 3); zval const_PARAM_STMT_value; ZVAL_LONG(&const_PARAM_STMT_value, LONG_CONST(PDO_PARAM_STMT)); - zend_string *const_PARAM_STMT_name = zend_string_init_interned("PARAM_STMT", sizeof("PARAM_STMT") - 1, 1); + zend_string *const_PARAM_STMT_name = zend_string_init_interned("PARAM_STMT", sizeof("PARAM_STMT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_STMT_name, &const_PARAM_STMT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_STMT_name); + zend_string_release_ex(const_PARAM_STMT_name, true); ZEND_ASSERT(LONG_CONST(PDO_PARAM_STMT) == 4); zval const_PARAM_INPUT_OUTPUT_value; ZVAL_LONG(&const_PARAM_INPUT_OUTPUT_value, LONG_CONST(PDO_PARAM_INPUT_OUTPUT)); - zend_string *const_PARAM_INPUT_OUTPUT_name = zend_string_init_interned("PARAM_INPUT_OUTPUT", sizeof("PARAM_INPUT_OUTPUT") - 1, 1); + zend_string *const_PARAM_INPUT_OUTPUT_name = zend_string_init_interned("PARAM_INPUT_OUTPUT", sizeof("PARAM_INPUT_OUTPUT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_INPUT_OUTPUT_name, &const_PARAM_INPUT_OUTPUT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_INPUT_OUTPUT_name); + zend_string_release_ex(const_PARAM_INPUT_OUTPUT_name, true); zval const_PARAM_STR_NATL_value; ZVAL_LONG(&const_PARAM_STR_NATL_value, LONG_CONST(PDO_PARAM_STR_NATL)); - zend_string *const_PARAM_STR_NATL_name = zend_string_init_interned("PARAM_STR_NATL", sizeof("PARAM_STR_NATL") - 1, 1); + zend_string *const_PARAM_STR_NATL_name = zend_string_init_interned("PARAM_STR_NATL", sizeof("PARAM_STR_NATL") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_STR_NATL_name, &const_PARAM_STR_NATL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_STR_NATL_name); + zend_string_release_ex(const_PARAM_STR_NATL_name, true); zval const_PARAM_STR_CHAR_value; ZVAL_LONG(&const_PARAM_STR_CHAR_value, LONG_CONST(PDO_PARAM_STR_CHAR)); - zend_string *const_PARAM_STR_CHAR_name = zend_string_init_interned("PARAM_STR_CHAR", sizeof("PARAM_STR_CHAR") - 1, 1); + zend_string *const_PARAM_STR_CHAR_name = zend_string_init_interned("PARAM_STR_CHAR", sizeof("PARAM_STR_CHAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_STR_CHAR_name, &const_PARAM_STR_CHAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_STR_CHAR_name); + zend_string_release_ex(const_PARAM_STR_CHAR_name, true); zval const_PARAM_EVT_ALLOC_value; ZVAL_LONG(&const_PARAM_EVT_ALLOC_value, LONG_CONST(PDO_PARAM_EVT_ALLOC)); - zend_string *const_PARAM_EVT_ALLOC_name = zend_string_init_interned("PARAM_EVT_ALLOC", sizeof("PARAM_EVT_ALLOC") - 1, 1); + zend_string *const_PARAM_EVT_ALLOC_name = zend_string_init_interned("PARAM_EVT_ALLOC", sizeof("PARAM_EVT_ALLOC") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_EVT_ALLOC_name, &const_PARAM_EVT_ALLOC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_EVT_ALLOC_name); + zend_string_release_ex(const_PARAM_EVT_ALLOC_name, true); zval const_PARAM_EVT_FREE_value; ZVAL_LONG(&const_PARAM_EVT_FREE_value, LONG_CONST(PDO_PARAM_EVT_FREE)); - zend_string *const_PARAM_EVT_FREE_name = zend_string_init_interned("PARAM_EVT_FREE", sizeof("PARAM_EVT_FREE") - 1, 1); + zend_string *const_PARAM_EVT_FREE_name = zend_string_init_interned("PARAM_EVT_FREE", sizeof("PARAM_EVT_FREE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_EVT_FREE_name, &const_PARAM_EVT_FREE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_EVT_FREE_name); + zend_string_release_ex(const_PARAM_EVT_FREE_name, true); zval const_PARAM_EVT_EXEC_PRE_value; ZVAL_LONG(&const_PARAM_EVT_EXEC_PRE_value, LONG_CONST(PDO_PARAM_EVT_EXEC_PRE)); - zend_string *const_PARAM_EVT_EXEC_PRE_name = zend_string_init_interned("PARAM_EVT_EXEC_PRE", sizeof("PARAM_EVT_EXEC_PRE") - 1, 1); + zend_string *const_PARAM_EVT_EXEC_PRE_name = zend_string_init_interned("PARAM_EVT_EXEC_PRE", sizeof("PARAM_EVT_EXEC_PRE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_EVT_EXEC_PRE_name, &const_PARAM_EVT_EXEC_PRE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_EVT_EXEC_PRE_name); + zend_string_release_ex(const_PARAM_EVT_EXEC_PRE_name, true); zval const_PARAM_EVT_EXEC_POST_value; ZVAL_LONG(&const_PARAM_EVT_EXEC_POST_value, LONG_CONST(PDO_PARAM_EVT_EXEC_POST)); - zend_string *const_PARAM_EVT_EXEC_POST_name = zend_string_init_interned("PARAM_EVT_EXEC_POST", sizeof("PARAM_EVT_EXEC_POST") - 1, 1); + zend_string *const_PARAM_EVT_EXEC_POST_name = zend_string_init_interned("PARAM_EVT_EXEC_POST", sizeof("PARAM_EVT_EXEC_POST") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_EVT_EXEC_POST_name, &const_PARAM_EVT_EXEC_POST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_EVT_EXEC_POST_name); + zend_string_release_ex(const_PARAM_EVT_EXEC_POST_name, true); zval const_PARAM_EVT_FETCH_PRE_value; ZVAL_LONG(&const_PARAM_EVT_FETCH_PRE_value, LONG_CONST(PDO_PARAM_EVT_FETCH_PRE)); - zend_string *const_PARAM_EVT_FETCH_PRE_name = zend_string_init_interned("PARAM_EVT_FETCH_PRE", sizeof("PARAM_EVT_FETCH_PRE") - 1, 1); + zend_string *const_PARAM_EVT_FETCH_PRE_name = zend_string_init_interned("PARAM_EVT_FETCH_PRE", sizeof("PARAM_EVT_FETCH_PRE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_EVT_FETCH_PRE_name, &const_PARAM_EVT_FETCH_PRE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_EVT_FETCH_PRE_name); + zend_string_release_ex(const_PARAM_EVT_FETCH_PRE_name, true); zval const_PARAM_EVT_FETCH_POST_value; ZVAL_LONG(&const_PARAM_EVT_FETCH_POST_value, LONG_CONST(PDO_PARAM_EVT_FETCH_POST)); - zend_string *const_PARAM_EVT_FETCH_POST_name = zend_string_init_interned("PARAM_EVT_FETCH_POST", sizeof("PARAM_EVT_FETCH_POST") - 1, 1); + zend_string *const_PARAM_EVT_FETCH_POST_name = zend_string_init_interned("PARAM_EVT_FETCH_POST", sizeof("PARAM_EVT_FETCH_POST") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_EVT_FETCH_POST_name, &const_PARAM_EVT_FETCH_POST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_EVT_FETCH_POST_name); + zend_string_release_ex(const_PARAM_EVT_FETCH_POST_name, true); zval const_PARAM_EVT_NORMALIZE_value; ZVAL_LONG(&const_PARAM_EVT_NORMALIZE_value, LONG_CONST(PDO_PARAM_EVT_NORMALIZE)); - zend_string *const_PARAM_EVT_NORMALIZE_name = zend_string_init_interned("PARAM_EVT_NORMALIZE", sizeof("PARAM_EVT_NORMALIZE") - 1, 1); + zend_string *const_PARAM_EVT_NORMALIZE_name = zend_string_init_interned("PARAM_EVT_NORMALIZE", sizeof("PARAM_EVT_NORMALIZE") - 1, true); zend_declare_typed_class_constant(class_entry, const_PARAM_EVT_NORMALIZE_name, &const_PARAM_EVT_NORMALIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PARAM_EVT_NORMALIZE_name); + zend_string_release_ex(const_PARAM_EVT_NORMALIZE_name, true); zval const_FETCH_DEFAULT_value; ZVAL_LONG(&const_FETCH_DEFAULT_value, LONG_CONST(PDO_FETCH_USE_DEFAULT)); - zend_string *const_FETCH_DEFAULT_name = zend_string_init_interned("FETCH_DEFAULT", sizeof("FETCH_DEFAULT") - 1, 1); + zend_string *const_FETCH_DEFAULT_name = zend_string_init_interned("FETCH_DEFAULT", sizeof("FETCH_DEFAULT") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_DEFAULT_name, &const_FETCH_DEFAULT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_DEFAULT_name); + zend_string_release_ex(const_FETCH_DEFAULT_name, true); zval const_FETCH_LAZY_value; ZVAL_LONG(&const_FETCH_LAZY_value, LONG_CONST(PDO_FETCH_LAZY)); - zend_string *const_FETCH_LAZY_name = zend_string_init_interned("FETCH_LAZY", sizeof("FETCH_LAZY") - 1, 1); + zend_string *const_FETCH_LAZY_name = zend_string_init_interned("FETCH_LAZY", sizeof("FETCH_LAZY") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_LAZY_name, &const_FETCH_LAZY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_LAZY_name); + zend_string_release_ex(const_FETCH_LAZY_name, true); zval const_FETCH_ASSOC_value; ZVAL_LONG(&const_FETCH_ASSOC_value, LONG_CONST(PDO_FETCH_ASSOC)); - zend_string *const_FETCH_ASSOC_name = zend_string_init_interned("FETCH_ASSOC", sizeof("FETCH_ASSOC") - 1, 1); + zend_string *const_FETCH_ASSOC_name = zend_string_init_interned("FETCH_ASSOC", sizeof("FETCH_ASSOC") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_ASSOC_name, &const_FETCH_ASSOC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_ASSOC_name); + zend_string_release_ex(const_FETCH_ASSOC_name, true); zval const_FETCH_NUM_value; ZVAL_LONG(&const_FETCH_NUM_value, LONG_CONST(PDO_FETCH_NUM)); - zend_string *const_FETCH_NUM_name = zend_string_init_interned("FETCH_NUM", sizeof("FETCH_NUM") - 1, 1); + zend_string *const_FETCH_NUM_name = zend_string_init_interned("FETCH_NUM", sizeof("FETCH_NUM") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_NUM_name, &const_FETCH_NUM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_NUM_name); + zend_string_release_ex(const_FETCH_NUM_name, true); zval const_FETCH_BOTH_value; ZVAL_LONG(&const_FETCH_BOTH_value, LONG_CONST(PDO_FETCH_BOTH)); - zend_string *const_FETCH_BOTH_name = zend_string_init_interned("FETCH_BOTH", sizeof("FETCH_BOTH") - 1, 1); + zend_string *const_FETCH_BOTH_name = zend_string_init_interned("FETCH_BOTH", sizeof("FETCH_BOTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_BOTH_name, &const_FETCH_BOTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_BOTH_name); + zend_string_release_ex(const_FETCH_BOTH_name, true); zval const_FETCH_OBJ_value; ZVAL_LONG(&const_FETCH_OBJ_value, LONG_CONST(PDO_FETCH_OBJ)); - zend_string *const_FETCH_OBJ_name = zend_string_init_interned("FETCH_OBJ", sizeof("FETCH_OBJ") - 1, 1); + zend_string *const_FETCH_OBJ_name = zend_string_init_interned("FETCH_OBJ", sizeof("FETCH_OBJ") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_OBJ_name, &const_FETCH_OBJ_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_OBJ_name); + zend_string_release_ex(const_FETCH_OBJ_name, true); zval const_FETCH_BOUND_value; ZVAL_LONG(&const_FETCH_BOUND_value, LONG_CONST(PDO_FETCH_BOUND)); - zend_string *const_FETCH_BOUND_name = zend_string_init_interned("FETCH_BOUND", sizeof("FETCH_BOUND") - 1, 1); + zend_string *const_FETCH_BOUND_name = zend_string_init_interned("FETCH_BOUND", sizeof("FETCH_BOUND") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_BOUND_name, &const_FETCH_BOUND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_BOUND_name); + zend_string_release_ex(const_FETCH_BOUND_name, true); zval const_FETCH_COLUMN_value; ZVAL_LONG(&const_FETCH_COLUMN_value, LONG_CONST(PDO_FETCH_COLUMN)); - zend_string *const_FETCH_COLUMN_name = zend_string_init_interned("FETCH_COLUMN", sizeof("FETCH_COLUMN") - 1, 1); + zend_string *const_FETCH_COLUMN_name = zend_string_init_interned("FETCH_COLUMN", sizeof("FETCH_COLUMN") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_COLUMN_name, &const_FETCH_COLUMN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_COLUMN_name); + zend_string_release_ex(const_FETCH_COLUMN_name, true); zval const_FETCH_CLASS_value; ZVAL_LONG(&const_FETCH_CLASS_value, LONG_CONST(PDO_FETCH_CLASS)); - zend_string *const_FETCH_CLASS_name = zend_string_init_interned("FETCH_CLASS", sizeof("FETCH_CLASS") - 1, 1); + zend_string *const_FETCH_CLASS_name = zend_string_init_interned("FETCH_CLASS", sizeof("FETCH_CLASS") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_CLASS_name, &const_FETCH_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_CLASS_name); + zend_string_release_ex(const_FETCH_CLASS_name, true); zval const_FETCH_INTO_value; ZVAL_LONG(&const_FETCH_INTO_value, LONG_CONST(PDO_FETCH_INTO)); - zend_string *const_FETCH_INTO_name = zend_string_init_interned("FETCH_INTO", sizeof("FETCH_INTO") - 1, 1); + zend_string *const_FETCH_INTO_name = zend_string_init_interned("FETCH_INTO", sizeof("FETCH_INTO") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_INTO_name, &const_FETCH_INTO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_INTO_name); + zend_string_release_ex(const_FETCH_INTO_name, true); zval const_FETCH_FUNC_value; ZVAL_LONG(&const_FETCH_FUNC_value, LONG_CONST(PDO_FETCH_FUNC)); - zend_string *const_FETCH_FUNC_name = zend_string_init_interned("FETCH_FUNC", sizeof("FETCH_FUNC") - 1, 1); + zend_string *const_FETCH_FUNC_name = zend_string_init_interned("FETCH_FUNC", sizeof("FETCH_FUNC") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_FUNC_name, &const_FETCH_FUNC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_FUNC_name); + zend_string_release_ex(const_FETCH_FUNC_name, true); zval const_FETCH_GROUP_value; ZVAL_LONG(&const_FETCH_GROUP_value, LONG_CONST(PDO_FETCH_GROUP)); - zend_string *const_FETCH_GROUP_name = zend_string_init_interned("FETCH_GROUP", sizeof("FETCH_GROUP") - 1, 1); + zend_string *const_FETCH_GROUP_name = zend_string_init_interned("FETCH_GROUP", sizeof("FETCH_GROUP") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_GROUP_name, &const_FETCH_GROUP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_GROUP_name); + zend_string_release_ex(const_FETCH_GROUP_name, true); zval const_FETCH_UNIQUE_value; ZVAL_LONG(&const_FETCH_UNIQUE_value, LONG_CONST(PDO_FETCH_UNIQUE)); - zend_string *const_FETCH_UNIQUE_name = zend_string_init_interned("FETCH_UNIQUE", sizeof("FETCH_UNIQUE") - 1, 1); + zend_string *const_FETCH_UNIQUE_name = zend_string_init_interned("FETCH_UNIQUE", sizeof("FETCH_UNIQUE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_UNIQUE_name, &const_FETCH_UNIQUE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_UNIQUE_name); + zend_string_release_ex(const_FETCH_UNIQUE_name, true); zval const_FETCH_KEY_PAIR_value; ZVAL_LONG(&const_FETCH_KEY_PAIR_value, LONG_CONST(PDO_FETCH_KEY_PAIR)); - zend_string *const_FETCH_KEY_PAIR_name = zend_string_init_interned("FETCH_KEY_PAIR", sizeof("FETCH_KEY_PAIR") - 1, 1); + zend_string *const_FETCH_KEY_PAIR_name = zend_string_init_interned("FETCH_KEY_PAIR", sizeof("FETCH_KEY_PAIR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_KEY_PAIR_name, &const_FETCH_KEY_PAIR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_KEY_PAIR_name); + zend_string_release_ex(const_FETCH_KEY_PAIR_name, true); zval const_FETCH_CLASSTYPE_value; ZVAL_LONG(&const_FETCH_CLASSTYPE_value, LONG_CONST(PDO_FETCH_CLASSTYPE)); - zend_string *const_FETCH_CLASSTYPE_name = zend_string_init_interned("FETCH_CLASSTYPE", sizeof("FETCH_CLASSTYPE") - 1, 1); + zend_string *const_FETCH_CLASSTYPE_name = zend_string_init_interned("FETCH_CLASSTYPE", sizeof("FETCH_CLASSTYPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_CLASSTYPE_name, &const_FETCH_CLASSTYPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_CLASSTYPE_name); + zend_string_release_ex(const_FETCH_CLASSTYPE_name, true); zval const_FETCH_SERIALIZE_value; ZVAL_LONG(&const_FETCH_SERIALIZE_value, LONG_CONST(PDO_FETCH_SERIALIZE)); - zend_string *const_FETCH_SERIALIZE_name = zend_string_init_interned("FETCH_SERIALIZE", sizeof("FETCH_SERIALIZE") - 1, 1); + zend_string *const_FETCH_SERIALIZE_name = zend_string_init_interned("FETCH_SERIALIZE", sizeof("FETCH_SERIALIZE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_SERIALIZE_name, &const_FETCH_SERIALIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_SERIALIZE_name); + zend_string_release_ex(const_FETCH_SERIALIZE_name, true); zval const_FETCH_PROPS_LATE_value; ZVAL_LONG(&const_FETCH_PROPS_LATE_value, LONG_CONST(PDO_FETCH_PROPS_LATE)); - zend_string *const_FETCH_PROPS_LATE_name = zend_string_init_interned("FETCH_PROPS_LATE", sizeof("FETCH_PROPS_LATE") - 1, 1); + zend_string *const_FETCH_PROPS_LATE_name = zend_string_init_interned("FETCH_PROPS_LATE", sizeof("FETCH_PROPS_LATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_PROPS_LATE_name, &const_FETCH_PROPS_LATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_PROPS_LATE_name); + zend_string_release_ex(const_FETCH_PROPS_LATE_name, true); zval const_FETCH_NAMED_value; ZVAL_LONG(&const_FETCH_NAMED_value, LONG_CONST(PDO_FETCH_NAMED)); - zend_string *const_FETCH_NAMED_name = zend_string_init_interned("FETCH_NAMED", sizeof("FETCH_NAMED") - 1, 1); + zend_string *const_FETCH_NAMED_name = zend_string_init_interned("FETCH_NAMED", sizeof("FETCH_NAMED") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_NAMED_name, &const_FETCH_NAMED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_NAMED_name); + zend_string_release_ex(const_FETCH_NAMED_name, true); zval const_ATTR_AUTOCOMMIT_value; ZVAL_LONG(&const_ATTR_AUTOCOMMIT_value, LONG_CONST(PDO_ATTR_AUTOCOMMIT)); - zend_string *const_ATTR_AUTOCOMMIT_name = zend_string_init_interned("ATTR_AUTOCOMMIT", sizeof("ATTR_AUTOCOMMIT") - 1, 1); + zend_string *const_ATTR_AUTOCOMMIT_name = zend_string_init_interned("ATTR_AUTOCOMMIT", sizeof("ATTR_AUTOCOMMIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_AUTOCOMMIT_name, &const_ATTR_AUTOCOMMIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_AUTOCOMMIT_name); + zend_string_release_ex(const_ATTR_AUTOCOMMIT_name, true); zval const_ATTR_PREFETCH_value; ZVAL_LONG(&const_ATTR_PREFETCH_value, LONG_CONST(PDO_ATTR_PREFETCH)); - zend_string *const_ATTR_PREFETCH_name = zend_string_init_interned("ATTR_PREFETCH", sizeof("ATTR_PREFETCH") - 1, 1); + zend_string *const_ATTR_PREFETCH_name = zend_string_init_interned("ATTR_PREFETCH", sizeof("ATTR_PREFETCH") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_PREFETCH_name, &const_ATTR_PREFETCH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_PREFETCH_name); + zend_string_release_ex(const_ATTR_PREFETCH_name, true); zval const_ATTR_TIMEOUT_value; ZVAL_LONG(&const_ATTR_TIMEOUT_value, LONG_CONST(PDO_ATTR_TIMEOUT)); - zend_string *const_ATTR_TIMEOUT_name = zend_string_init_interned("ATTR_TIMEOUT", sizeof("ATTR_TIMEOUT") - 1, 1); + zend_string *const_ATTR_TIMEOUT_name = zend_string_init_interned("ATTR_TIMEOUT", sizeof("ATTR_TIMEOUT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_TIMEOUT_name, &const_ATTR_TIMEOUT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_TIMEOUT_name); + zend_string_release_ex(const_ATTR_TIMEOUT_name, true); zval const_ATTR_ERRMODE_value; ZVAL_LONG(&const_ATTR_ERRMODE_value, LONG_CONST(PDO_ATTR_ERRMODE)); - zend_string *const_ATTR_ERRMODE_name = zend_string_init_interned("ATTR_ERRMODE", sizeof("ATTR_ERRMODE") - 1, 1); + zend_string *const_ATTR_ERRMODE_name = zend_string_init_interned("ATTR_ERRMODE", sizeof("ATTR_ERRMODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_ERRMODE_name, &const_ATTR_ERRMODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_ERRMODE_name); + zend_string_release_ex(const_ATTR_ERRMODE_name, true); zval const_ATTR_SERVER_VERSION_value; ZVAL_LONG(&const_ATTR_SERVER_VERSION_value, LONG_CONST(PDO_ATTR_SERVER_VERSION)); - zend_string *const_ATTR_SERVER_VERSION_name = zend_string_init_interned("ATTR_SERVER_VERSION", sizeof("ATTR_SERVER_VERSION") - 1, 1); + zend_string *const_ATTR_SERVER_VERSION_name = zend_string_init_interned("ATTR_SERVER_VERSION", sizeof("ATTR_SERVER_VERSION") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SERVER_VERSION_name, &const_ATTR_SERVER_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SERVER_VERSION_name); + zend_string_release_ex(const_ATTR_SERVER_VERSION_name, true); zval const_ATTR_CLIENT_VERSION_value; ZVAL_LONG(&const_ATTR_CLIENT_VERSION_value, LONG_CONST(PDO_ATTR_CLIENT_VERSION)); - zend_string *const_ATTR_CLIENT_VERSION_name = zend_string_init_interned("ATTR_CLIENT_VERSION", sizeof("ATTR_CLIENT_VERSION") - 1, 1); + zend_string *const_ATTR_CLIENT_VERSION_name = zend_string_init_interned("ATTR_CLIENT_VERSION", sizeof("ATTR_CLIENT_VERSION") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_CLIENT_VERSION_name, &const_ATTR_CLIENT_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_CLIENT_VERSION_name); + zend_string_release_ex(const_ATTR_CLIENT_VERSION_name, true); zval const_ATTR_SERVER_INFO_value; ZVAL_LONG(&const_ATTR_SERVER_INFO_value, LONG_CONST(PDO_ATTR_SERVER_INFO)); - zend_string *const_ATTR_SERVER_INFO_name = zend_string_init_interned("ATTR_SERVER_INFO", sizeof("ATTR_SERVER_INFO") - 1, 1); + zend_string *const_ATTR_SERVER_INFO_name = zend_string_init_interned("ATTR_SERVER_INFO", sizeof("ATTR_SERVER_INFO") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SERVER_INFO_name, &const_ATTR_SERVER_INFO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SERVER_INFO_name); + zend_string_release_ex(const_ATTR_SERVER_INFO_name, true); zval const_ATTR_CONNECTION_STATUS_value; ZVAL_LONG(&const_ATTR_CONNECTION_STATUS_value, LONG_CONST(PDO_ATTR_CONNECTION_STATUS)); - zend_string *const_ATTR_CONNECTION_STATUS_name = zend_string_init_interned("ATTR_CONNECTION_STATUS", sizeof("ATTR_CONNECTION_STATUS") - 1, 1); + zend_string *const_ATTR_CONNECTION_STATUS_name = zend_string_init_interned("ATTR_CONNECTION_STATUS", sizeof("ATTR_CONNECTION_STATUS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_CONNECTION_STATUS_name, &const_ATTR_CONNECTION_STATUS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_CONNECTION_STATUS_name); + zend_string_release_ex(const_ATTR_CONNECTION_STATUS_name, true); zval const_ATTR_CASE_value; ZVAL_LONG(&const_ATTR_CASE_value, LONG_CONST(PDO_ATTR_CASE)); - zend_string *const_ATTR_CASE_name = zend_string_init_interned("ATTR_CASE", sizeof("ATTR_CASE") - 1, 1); + zend_string *const_ATTR_CASE_name = zend_string_init_interned("ATTR_CASE", sizeof("ATTR_CASE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_CASE_name, &const_ATTR_CASE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_CASE_name); + zend_string_release_ex(const_ATTR_CASE_name, true); zval const_ATTR_CURSOR_NAME_value; ZVAL_LONG(&const_ATTR_CURSOR_NAME_value, LONG_CONST(PDO_ATTR_CURSOR_NAME)); - zend_string *const_ATTR_CURSOR_NAME_name = zend_string_init_interned("ATTR_CURSOR_NAME", sizeof("ATTR_CURSOR_NAME") - 1, 1); + zend_string *const_ATTR_CURSOR_NAME_name = zend_string_init_interned("ATTR_CURSOR_NAME", sizeof("ATTR_CURSOR_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_CURSOR_NAME_name, &const_ATTR_CURSOR_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_CURSOR_NAME_name); + zend_string_release_ex(const_ATTR_CURSOR_NAME_name, true); zval const_ATTR_CURSOR_value; ZVAL_LONG(&const_ATTR_CURSOR_value, LONG_CONST(PDO_ATTR_CURSOR)); - zend_string *const_ATTR_CURSOR_name = zend_string_init_interned("ATTR_CURSOR", sizeof("ATTR_CURSOR") - 1, 1); + zend_string *const_ATTR_CURSOR_name = zend_string_init_interned("ATTR_CURSOR", sizeof("ATTR_CURSOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_CURSOR_name, &const_ATTR_CURSOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_CURSOR_name); + zend_string_release_ex(const_ATTR_CURSOR_name, true); zval const_ATTR_ORACLE_NULLS_value; ZVAL_LONG(&const_ATTR_ORACLE_NULLS_value, LONG_CONST(PDO_ATTR_ORACLE_NULLS)); - zend_string *const_ATTR_ORACLE_NULLS_name = zend_string_init_interned("ATTR_ORACLE_NULLS", sizeof("ATTR_ORACLE_NULLS") - 1, 1); + zend_string *const_ATTR_ORACLE_NULLS_name = zend_string_init_interned("ATTR_ORACLE_NULLS", sizeof("ATTR_ORACLE_NULLS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_ORACLE_NULLS_name, &const_ATTR_ORACLE_NULLS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_ORACLE_NULLS_name); + zend_string_release_ex(const_ATTR_ORACLE_NULLS_name, true); zval const_ATTR_PERSISTENT_value; ZVAL_LONG(&const_ATTR_PERSISTENT_value, LONG_CONST(PDO_ATTR_PERSISTENT)); - zend_string *const_ATTR_PERSISTENT_name = zend_string_init_interned("ATTR_PERSISTENT", sizeof("ATTR_PERSISTENT") - 1, 1); + zend_string *const_ATTR_PERSISTENT_name = zend_string_init_interned("ATTR_PERSISTENT", sizeof("ATTR_PERSISTENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_PERSISTENT_name, &const_ATTR_PERSISTENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_PERSISTENT_name); + zend_string_release_ex(const_ATTR_PERSISTENT_name, true); zval const_ATTR_STATEMENT_CLASS_value; ZVAL_LONG(&const_ATTR_STATEMENT_CLASS_value, LONG_CONST(PDO_ATTR_STATEMENT_CLASS)); - zend_string *const_ATTR_STATEMENT_CLASS_name = zend_string_init_interned("ATTR_STATEMENT_CLASS", sizeof("ATTR_STATEMENT_CLASS") - 1, 1); + zend_string *const_ATTR_STATEMENT_CLASS_name = zend_string_init_interned("ATTR_STATEMENT_CLASS", sizeof("ATTR_STATEMENT_CLASS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_STATEMENT_CLASS_name, &const_ATTR_STATEMENT_CLASS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_STATEMENT_CLASS_name); + zend_string_release_ex(const_ATTR_STATEMENT_CLASS_name, true); zval const_ATTR_FETCH_TABLE_NAMES_value; ZVAL_LONG(&const_ATTR_FETCH_TABLE_NAMES_value, LONG_CONST(PDO_ATTR_FETCH_TABLE_NAMES)); - zend_string *const_ATTR_FETCH_TABLE_NAMES_name = zend_string_init_interned("ATTR_FETCH_TABLE_NAMES", sizeof("ATTR_FETCH_TABLE_NAMES") - 1, 1); + zend_string *const_ATTR_FETCH_TABLE_NAMES_name = zend_string_init_interned("ATTR_FETCH_TABLE_NAMES", sizeof("ATTR_FETCH_TABLE_NAMES") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_FETCH_TABLE_NAMES_name, &const_ATTR_FETCH_TABLE_NAMES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_FETCH_TABLE_NAMES_name); + zend_string_release_ex(const_ATTR_FETCH_TABLE_NAMES_name, true); zval const_ATTR_FETCH_CATALOG_NAMES_value; ZVAL_LONG(&const_ATTR_FETCH_CATALOG_NAMES_value, LONG_CONST(PDO_ATTR_FETCH_CATALOG_NAMES)); - zend_string *const_ATTR_FETCH_CATALOG_NAMES_name = zend_string_init_interned("ATTR_FETCH_CATALOG_NAMES", sizeof("ATTR_FETCH_CATALOG_NAMES") - 1, 1); + zend_string *const_ATTR_FETCH_CATALOG_NAMES_name = zend_string_init_interned("ATTR_FETCH_CATALOG_NAMES", sizeof("ATTR_FETCH_CATALOG_NAMES") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_FETCH_CATALOG_NAMES_name, &const_ATTR_FETCH_CATALOG_NAMES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_FETCH_CATALOG_NAMES_name); + zend_string_release_ex(const_ATTR_FETCH_CATALOG_NAMES_name, true); zval const_ATTR_DRIVER_NAME_value; ZVAL_LONG(&const_ATTR_DRIVER_NAME_value, LONG_CONST(PDO_ATTR_DRIVER_NAME)); - zend_string *const_ATTR_DRIVER_NAME_name = zend_string_init_interned("ATTR_DRIVER_NAME", sizeof("ATTR_DRIVER_NAME") - 1, 1); + zend_string *const_ATTR_DRIVER_NAME_name = zend_string_init_interned("ATTR_DRIVER_NAME", sizeof("ATTR_DRIVER_NAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_DRIVER_NAME_name, &const_ATTR_DRIVER_NAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_DRIVER_NAME_name); + zend_string_release_ex(const_ATTR_DRIVER_NAME_name, true); zval const_ATTR_STRINGIFY_FETCHES_value; ZVAL_LONG(&const_ATTR_STRINGIFY_FETCHES_value, LONG_CONST(PDO_ATTR_STRINGIFY_FETCHES)); - zend_string *const_ATTR_STRINGIFY_FETCHES_name = zend_string_init_interned("ATTR_STRINGIFY_FETCHES", sizeof("ATTR_STRINGIFY_FETCHES") - 1, 1); + zend_string *const_ATTR_STRINGIFY_FETCHES_name = zend_string_init_interned("ATTR_STRINGIFY_FETCHES", sizeof("ATTR_STRINGIFY_FETCHES") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_STRINGIFY_FETCHES_name, &const_ATTR_STRINGIFY_FETCHES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_STRINGIFY_FETCHES_name); + zend_string_release_ex(const_ATTR_STRINGIFY_FETCHES_name, true); zval const_ATTR_MAX_COLUMN_LEN_value; ZVAL_LONG(&const_ATTR_MAX_COLUMN_LEN_value, LONG_CONST(PDO_ATTR_MAX_COLUMN_LEN)); - zend_string *const_ATTR_MAX_COLUMN_LEN_name = zend_string_init_interned("ATTR_MAX_COLUMN_LEN", sizeof("ATTR_MAX_COLUMN_LEN") - 1, 1); + zend_string *const_ATTR_MAX_COLUMN_LEN_name = zend_string_init_interned("ATTR_MAX_COLUMN_LEN", sizeof("ATTR_MAX_COLUMN_LEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_MAX_COLUMN_LEN_name, &const_ATTR_MAX_COLUMN_LEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_MAX_COLUMN_LEN_name); + zend_string_release_ex(const_ATTR_MAX_COLUMN_LEN_name, true); zval const_ATTR_EMULATE_PREPARES_value; ZVAL_LONG(&const_ATTR_EMULATE_PREPARES_value, LONG_CONST(PDO_ATTR_EMULATE_PREPARES)); - zend_string *const_ATTR_EMULATE_PREPARES_name = zend_string_init_interned("ATTR_EMULATE_PREPARES", sizeof("ATTR_EMULATE_PREPARES") - 1, 1); + zend_string *const_ATTR_EMULATE_PREPARES_name = zend_string_init_interned("ATTR_EMULATE_PREPARES", sizeof("ATTR_EMULATE_PREPARES") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_EMULATE_PREPARES_name, &const_ATTR_EMULATE_PREPARES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_EMULATE_PREPARES_name); + zend_string_release_ex(const_ATTR_EMULATE_PREPARES_name, true); zval const_ATTR_DEFAULT_FETCH_MODE_value; ZVAL_LONG(&const_ATTR_DEFAULT_FETCH_MODE_value, LONG_CONST(PDO_ATTR_DEFAULT_FETCH_MODE)); - zend_string *const_ATTR_DEFAULT_FETCH_MODE_name = zend_string_init_interned("ATTR_DEFAULT_FETCH_MODE", sizeof("ATTR_DEFAULT_FETCH_MODE") - 1, 1); + zend_string *const_ATTR_DEFAULT_FETCH_MODE_name = zend_string_init_interned("ATTR_DEFAULT_FETCH_MODE", sizeof("ATTR_DEFAULT_FETCH_MODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_DEFAULT_FETCH_MODE_name, &const_ATTR_DEFAULT_FETCH_MODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_DEFAULT_FETCH_MODE_name); + zend_string_release_ex(const_ATTR_DEFAULT_FETCH_MODE_name, true); zval const_ATTR_DEFAULT_STR_PARAM_value; ZVAL_LONG(&const_ATTR_DEFAULT_STR_PARAM_value, LONG_CONST(PDO_ATTR_DEFAULT_STR_PARAM)); - zend_string *const_ATTR_DEFAULT_STR_PARAM_name = zend_string_init_interned("ATTR_DEFAULT_STR_PARAM", sizeof("ATTR_DEFAULT_STR_PARAM") - 1, 1); + zend_string *const_ATTR_DEFAULT_STR_PARAM_name = zend_string_init_interned("ATTR_DEFAULT_STR_PARAM", sizeof("ATTR_DEFAULT_STR_PARAM") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_DEFAULT_STR_PARAM_name, &const_ATTR_DEFAULT_STR_PARAM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_DEFAULT_STR_PARAM_name); + zend_string_release_ex(const_ATTR_DEFAULT_STR_PARAM_name, true); zval const_ERRMODE_SILENT_value; ZVAL_LONG(&const_ERRMODE_SILENT_value, LONG_CONST(PDO_ERRMODE_SILENT)); - zend_string *const_ERRMODE_SILENT_name = zend_string_init_interned("ERRMODE_SILENT", sizeof("ERRMODE_SILENT") - 1, 1); + zend_string *const_ERRMODE_SILENT_name = zend_string_init_interned("ERRMODE_SILENT", sizeof("ERRMODE_SILENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRMODE_SILENT_name, &const_ERRMODE_SILENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRMODE_SILENT_name); + zend_string_release_ex(const_ERRMODE_SILENT_name, true); zval const_ERRMODE_WARNING_value; ZVAL_LONG(&const_ERRMODE_WARNING_value, LONG_CONST(PDO_ERRMODE_WARNING)); - zend_string *const_ERRMODE_WARNING_name = zend_string_init_interned("ERRMODE_WARNING", sizeof("ERRMODE_WARNING") - 1, 1); + zend_string *const_ERRMODE_WARNING_name = zend_string_init_interned("ERRMODE_WARNING", sizeof("ERRMODE_WARNING") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRMODE_WARNING_name, &const_ERRMODE_WARNING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRMODE_WARNING_name); + zend_string_release_ex(const_ERRMODE_WARNING_name, true); zval const_ERRMODE_EXCEPTION_value; ZVAL_LONG(&const_ERRMODE_EXCEPTION_value, LONG_CONST(PDO_ERRMODE_EXCEPTION)); - zend_string *const_ERRMODE_EXCEPTION_name = zend_string_init_interned("ERRMODE_EXCEPTION", sizeof("ERRMODE_EXCEPTION") - 1, 1); + zend_string *const_ERRMODE_EXCEPTION_name = zend_string_init_interned("ERRMODE_EXCEPTION", sizeof("ERRMODE_EXCEPTION") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRMODE_EXCEPTION_name, &const_ERRMODE_EXCEPTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRMODE_EXCEPTION_name); + zend_string_release_ex(const_ERRMODE_EXCEPTION_name, true); zval const_CASE_NATURAL_value; ZVAL_LONG(&const_CASE_NATURAL_value, LONG_CONST(PDO_CASE_NATURAL)); - zend_string *const_CASE_NATURAL_name = zend_string_init_interned("CASE_NATURAL", sizeof("CASE_NATURAL") - 1, 1); + zend_string *const_CASE_NATURAL_name = zend_string_init_interned("CASE_NATURAL", sizeof("CASE_NATURAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CASE_NATURAL_name, &const_CASE_NATURAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CASE_NATURAL_name); + zend_string_release_ex(const_CASE_NATURAL_name, true); zval const_CASE_LOWER_value; ZVAL_LONG(&const_CASE_LOWER_value, LONG_CONST(PDO_CASE_LOWER)); - zend_string *const_CASE_LOWER_name = zend_string_init_interned("CASE_LOWER", sizeof("CASE_LOWER") - 1, 1); + zend_string *const_CASE_LOWER_name = zend_string_init_interned("CASE_LOWER", sizeof("CASE_LOWER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CASE_LOWER_name, &const_CASE_LOWER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CASE_LOWER_name); + zend_string_release_ex(const_CASE_LOWER_name, true); zval const_CASE_UPPER_value; ZVAL_LONG(&const_CASE_UPPER_value, LONG_CONST(PDO_CASE_UPPER)); - zend_string *const_CASE_UPPER_name = zend_string_init_interned("CASE_UPPER", sizeof("CASE_UPPER") - 1, 1); + zend_string *const_CASE_UPPER_name = zend_string_init_interned("CASE_UPPER", sizeof("CASE_UPPER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CASE_UPPER_name, &const_CASE_UPPER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CASE_UPPER_name); + zend_string_release_ex(const_CASE_UPPER_name, true); zval const_NULL_NATURAL_value; ZVAL_LONG(&const_NULL_NATURAL_value, LONG_CONST(PDO_NULL_NATURAL)); - zend_string *const_NULL_NATURAL_name = zend_string_init_interned("NULL_NATURAL", sizeof("NULL_NATURAL") - 1, 1); + zend_string *const_NULL_NATURAL_name = zend_string_init_interned("NULL_NATURAL", sizeof("NULL_NATURAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_NULL_NATURAL_name, &const_NULL_NATURAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NULL_NATURAL_name); + zend_string_release_ex(const_NULL_NATURAL_name, true); zval const_NULL_EMPTY_STRING_value; ZVAL_LONG(&const_NULL_EMPTY_STRING_value, LONG_CONST(PDO_NULL_EMPTY_STRING)); - zend_string *const_NULL_EMPTY_STRING_name = zend_string_init_interned("NULL_EMPTY_STRING", sizeof("NULL_EMPTY_STRING") - 1, 1); + zend_string *const_NULL_EMPTY_STRING_name = zend_string_init_interned("NULL_EMPTY_STRING", sizeof("NULL_EMPTY_STRING") - 1, true); zend_declare_typed_class_constant(class_entry, const_NULL_EMPTY_STRING_name, &const_NULL_EMPTY_STRING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NULL_EMPTY_STRING_name); + zend_string_release_ex(const_NULL_EMPTY_STRING_name, true); zval const_NULL_TO_STRING_value; ZVAL_LONG(&const_NULL_TO_STRING_value, LONG_CONST(PDO_NULL_TO_STRING)); - zend_string *const_NULL_TO_STRING_name = zend_string_init_interned("NULL_TO_STRING", sizeof("NULL_TO_STRING") - 1, 1); + zend_string *const_NULL_TO_STRING_name = zend_string_init_interned("NULL_TO_STRING", sizeof("NULL_TO_STRING") - 1, true); zend_declare_typed_class_constant(class_entry, const_NULL_TO_STRING_name, &const_NULL_TO_STRING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NULL_TO_STRING_name); + zend_string_release_ex(const_NULL_TO_STRING_name, true); zval const_ERR_NONE_value; zend_string *const_ERR_NONE_value_str = zend_string_init(PDO_ERR_NONE, strlen(PDO_ERR_NONE), 1); ZVAL_STR(&const_ERR_NONE_value, const_ERR_NONE_value_str); - zend_string *const_ERR_NONE_name = zend_string_init_interned("ERR_NONE", sizeof("ERR_NONE") - 1, 1); + zend_string *const_ERR_NONE_name = zend_string_init_interned("ERR_NONE", sizeof("ERR_NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERR_NONE_name, &const_ERR_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_ERR_NONE_name); + zend_string_release_ex(const_ERR_NONE_name, true); zval const_FETCH_ORI_NEXT_value; ZVAL_LONG(&const_FETCH_ORI_NEXT_value, LONG_CONST(PDO_FETCH_ORI_NEXT)); - zend_string *const_FETCH_ORI_NEXT_name = zend_string_init_interned("FETCH_ORI_NEXT", sizeof("FETCH_ORI_NEXT") - 1, 1); + zend_string *const_FETCH_ORI_NEXT_name = zend_string_init_interned("FETCH_ORI_NEXT", sizeof("FETCH_ORI_NEXT") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_ORI_NEXT_name, &const_FETCH_ORI_NEXT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_ORI_NEXT_name); + zend_string_release_ex(const_FETCH_ORI_NEXT_name, true); zval const_FETCH_ORI_PRIOR_value; ZVAL_LONG(&const_FETCH_ORI_PRIOR_value, LONG_CONST(PDO_FETCH_ORI_PRIOR)); - zend_string *const_FETCH_ORI_PRIOR_name = zend_string_init_interned("FETCH_ORI_PRIOR", sizeof("FETCH_ORI_PRIOR") - 1, 1); + zend_string *const_FETCH_ORI_PRIOR_name = zend_string_init_interned("FETCH_ORI_PRIOR", sizeof("FETCH_ORI_PRIOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_ORI_PRIOR_name, &const_FETCH_ORI_PRIOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_ORI_PRIOR_name); + zend_string_release_ex(const_FETCH_ORI_PRIOR_name, true); zval const_FETCH_ORI_FIRST_value; ZVAL_LONG(&const_FETCH_ORI_FIRST_value, LONG_CONST(PDO_FETCH_ORI_FIRST)); - zend_string *const_FETCH_ORI_FIRST_name = zend_string_init_interned("FETCH_ORI_FIRST", sizeof("FETCH_ORI_FIRST") - 1, 1); + zend_string *const_FETCH_ORI_FIRST_name = zend_string_init_interned("FETCH_ORI_FIRST", sizeof("FETCH_ORI_FIRST") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_ORI_FIRST_name, &const_FETCH_ORI_FIRST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_ORI_FIRST_name); + zend_string_release_ex(const_FETCH_ORI_FIRST_name, true); zval const_FETCH_ORI_LAST_value; ZVAL_LONG(&const_FETCH_ORI_LAST_value, LONG_CONST(PDO_FETCH_ORI_LAST)); - zend_string *const_FETCH_ORI_LAST_name = zend_string_init_interned("FETCH_ORI_LAST", sizeof("FETCH_ORI_LAST") - 1, 1); + zend_string *const_FETCH_ORI_LAST_name = zend_string_init_interned("FETCH_ORI_LAST", sizeof("FETCH_ORI_LAST") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_ORI_LAST_name, &const_FETCH_ORI_LAST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_ORI_LAST_name); + zend_string_release_ex(const_FETCH_ORI_LAST_name, true); zval const_FETCH_ORI_ABS_value; ZVAL_LONG(&const_FETCH_ORI_ABS_value, LONG_CONST(PDO_FETCH_ORI_ABS)); - zend_string *const_FETCH_ORI_ABS_name = zend_string_init_interned("FETCH_ORI_ABS", sizeof("FETCH_ORI_ABS") - 1, 1); + zend_string *const_FETCH_ORI_ABS_name = zend_string_init_interned("FETCH_ORI_ABS", sizeof("FETCH_ORI_ABS") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_ORI_ABS_name, &const_FETCH_ORI_ABS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_ORI_ABS_name); + zend_string_release_ex(const_FETCH_ORI_ABS_name, true); zval const_FETCH_ORI_REL_value; ZVAL_LONG(&const_FETCH_ORI_REL_value, LONG_CONST(PDO_FETCH_ORI_REL)); - zend_string *const_FETCH_ORI_REL_name = zend_string_init_interned("FETCH_ORI_REL", sizeof("FETCH_ORI_REL") - 1, 1); + zend_string *const_FETCH_ORI_REL_name = zend_string_init_interned("FETCH_ORI_REL", sizeof("FETCH_ORI_REL") - 1, true); zend_declare_typed_class_constant(class_entry, const_FETCH_ORI_REL_name, &const_FETCH_ORI_REL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FETCH_ORI_REL_name); + zend_string_release_ex(const_FETCH_ORI_REL_name, true); zval const_CURSOR_FWDONLY_value; ZVAL_LONG(&const_CURSOR_FWDONLY_value, LONG_CONST(PDO_CURSOR_FWDONLY)); - zend_string *const_CURSOR_FWDONLY_name = zend_string_init_interned("CURSOR_FWDONLY", sizeof("CURSOR_FWDONLY") - 1, 1); + zend_string *const_CURSOR_FWDONLY_name = zend_string_init_interned("CURSOR_FWDONLY", sizeof("CURSOR_FWDONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURSOR_FWDONLY_name, &const_CURSOR_FWDONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURSOR_FWDONLY_name); + zend_string_release_ex(const_CURSOR_FWDONLY_name, true); zval const_CURSOR_SCROLL_value; ZVAL_LONG(&const_CURSOR_SCROLL_value, LONG_CONST(PDO_CURSOR_SCROLL)); - zend_string *const_CURSOR_SCROLL_name = zend_string_init_interned("CURSOR_SCROLL", sizeof("CURSOR_SCROLL") - 1, 1); + zend_string *const_CURSOR_SCROLL_name = zend_string_init_interned("CURSOR_SCROLL", sizeof("CURSOR_SCROLL") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURSOR_SCROLL_name, &const_CURSOR_SCROLL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURSOR_SCROLL_name); + zend_string_release_ex(const_CURSOR_SCROLL_name, true); zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "__construct", sizeof("__construct") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index a87fd473404ec..1897f9f238bf1 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -300,6 +300,12 @@ safe: } plc->quoted = stmt->dbh->methods->quoter(stmt->dbh, buf, param_type); + if (plc->quoted == NULL) { + /* bork */ + ret = -1; + strncpy(stmt->error_code, stmt->dbh->error_code, 6); + goto clean_up; + } } } diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 697940d94260d..73d4530e8f657 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -55,17 +55,17 @@ static inline bool rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_p if (stmt->named_rewrite_template) { /* this is not an error here */ - return 1; + return true; } if (!param->name) { /* do the reverse; map the parameter number to the name */ if ((name = zend_hash_index_find_ptr(stmt->bound_param_map, param->paramno)) != NULL) { param->name = zend_string_copy(name); - return 1; + return true; } /* TODO Error? */ pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined"); - return 0; + return false; } ZEND_HASH_FOREACH_PTR(stmt->bound_param_map, name) { @@ -79,29 +79,29 @@ static inline bool rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_p return -1; } param->paramno = position; - return 1; + return true; } ZEND_HASH_FOREACH_END(); /* TODO Error? */ pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined"); - return 0; + return false; } - return 1; + return true; } /* }}} */ /* trigger callback hook for parameters */ static bool dispatch_param_event(pdo_stmt_t *stmt, enum pdo_param_event event_type) /* {{{ */ { - bool ret = 1, is_param = 1; + bool ret = true, is_param = true; struct pdo_bound_param_data *param; HashTable *ht; if (stmt->dbh->skip_param_evt & (1 << event_type)) { - return 1; + return true; } if (!stmt->methods->param_hook) { - return 1; + return true; } ht = stmt->bound_params; @@ -110,14 +110,14 @@ static bool dispatch_param_event(pdo_stmt_t *stmt, enum pdo_param_event event_ty if (ht) { ZEND_HASH_FOREACH_PTR(ht, param) { if (!stmt->methods->param_hook(stmt, param, event_type)) { - ret = 0; + ret = false; break; } } ZEND_HASH_FOREACH_END(); } if (ret && is_param) { ht = stmt->bound_columns; - is_param = 0; + is_param = false; goto iterate; } @@ -272,7 +272,7 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_ if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_STR && param->max_value_len <= 0 && !Z_ISNULL_P(parameter)) { if (!try_convert_to_string(parameter)) { - return 0; + return false; } } else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_INT && (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE)) { convert_to_long(parameter); @@ -326,7 +326,7 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_ zend_string_release_ex(param->name, 0); param->name = NULL; } - return 0; + return false; } /* ask the driver to perform any normalization it needs on the @@ -340,7 +340,7 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_ zend_string_release_ex(param->name, 0); param->name = NULL; } - return 0; + return false; } } @@ -371,10 +371,10 @@ static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_ } /* param->parameter is freed by hash dtor */ ZVAL_UNDEF(¶m->parameter); - return 0; + return false; } } - return 1; + return true; } /* }}} */ @@ -563,24 +563,24 @@ static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo static bool do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* {{{ */ { if (!stmt->executed) { - return 0; + return false; } if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_PRE)) { - return 0; + return false; } if (!stmt->methods->fetcher(stmt, ori, offset)) { - return 0; + return false; } /* some drivers might need to describe the columns now */ if (!stmt->columns && !pdo_stmt_describe_columns(stmt)) { - return 0; + return false; } if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_POST)) { - return 0; + return false; } if (stmt->bound_columns) { @@ -607,7 +607,7 @@ static bool do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, ze } ZEND_HASH_FOREACH_END(); } - return 1; + return true; } /* }}} */ @@ -771,9 +771,10 @@ static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type h pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch class specified"); goto in_fetch_error; } - ctor_arguments = stmt->fetch.cls.ctor_args; } ZEND_ASSERT(ce != NULL); + + ctor_arguments = stmt->fetch.cls.ctor_args; if (flags & PDO_FETCH_SERIALIZE) { if (!ce->unserialize) { /* As this option is deprecated we do not bother to mention the class name. */ @@ -1052,7 +1053,7 @@ PHP_METHOD(PDOStatement, fetch) array_init_size(return_value, 1); bool success = pdo_do_key_pair_fetch(stmt, ori, off, Z_ARRVAL_P(return_value)); if (!success) { - zval_dtor(return_value); + zval_ptr_dtor_nogc(return_value); PDO_HANDLE_STMT_ERR(); RETURN_FALSE; } @@ -1506,9 +1507,9 @@ static bool generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, zend_lon switch (attr) { case PDO_ATTR_EMULATE_PREPARES: RETVAL_BOOL(stmt->supports_placeholders == PDO_PLACEHOLDER_NONE); - return 1; + return true; } - return 0; + return false; } PHP_METHOD(PDOStatement, getAttribute) @@ -1788,12 +1789,12 @@ static bool pdo_stmt_do_next_rowset(pdo_stmt_t *stmt) if (!stmt->methods->next_rowset(stmt)) { /* Set the executed flag to 0 to reallocate columns on next execute */ stmt->executed = 0; - return 0; + return false; } pdo_stmt_describe_columns(stmt); - return 1; + return true; } PHP_METHOD(PDOStatement, nextRowset) diff --git a/ext/pdo/pdo_stmt_arginfo.h b/ext/pdo/pdo_stmt_arginfo.h index 0d4131d5be493..0be8ee82d84d6 100644 --- a/ext/pdo/pdo_stmt_arginfo.h +++ b/ext/pdo/pdo_stmt_arginfo.h @@ -142,9 +142,9 @@ static zend_class_entry *register_class_PDOStatement(zend_class_entry *class_ent zval property_queryString_default_value; ZVAL_UNDEF(&property_queryString_default_value); - zend_string *property_queryString_name = zend_string_init("queryString", sizeof("queryString") - 1, 1); + zend_string *property_queryString_name = zend_string_init("queryString", sizeof("queryString") - 1, true); zend_declare_typed_property(class_entry, property_queryString_name, &property_queryString_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_queryString_name); + zend_string_release_ex(property_queryString_name, true); return class_entry; } @@ -158,9 +158,9 @@ static zend_class_entry *register_class_PDORow(void) zval property_queryString_default_value; ZVAL_UNDEF(&property_queryString_default_value); - zend_string *property_queryString_name = zend_string_init("queryString", sizeof("queryString") - 1, 1); + zend_string *property_queryString_name = zend_string_init("queryString", sizeof("queryString") - 1, true); zend_declare_typed_property(class_entry, property_queryString_name, &property_queryString_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_queryString_name); + zend_string_release_ex(property_queryString_name, true); return class_entry; } diff --git a/ext/pdo/tests/gh20553.phpt b/ext/pdo/tests/gh20553.phpt new file mode 100644 index 0000000000000..fe0b84c27ebb0 --- /dev/null +++ b/ext/pdo/tests/gh20553.phpt @@ -0,0 +1,97 @@ +--TEST-- +GH-20553: PHP 8.5.0 regression: PDO::FETCH_CLASSTYPE ignores $constructorArgs +--EXTENSIONS-- +pdo +--SKIPIF-- + +--FILE-- + PDO::FETCH_CLASS, + 'PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE' + => PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, + 'PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE' + => PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE, + 'PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE' + => PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE, +]; + +foreach ($fetchModes as $combinedModes => $fetchMode) { + echo '## ' . $combinedModes . PHP_EOL; + $db->query($sql)->fetchAll( + $fetchMode, + 'dumpy', + ['constructor argument #1'] + ); + echo PHP_EOL; +} +?> +--EXPECT-- +## PDO::FETCH_CLASS +'pdo_fetch_class_type_class' = 'dummy' +'foo' = 'bar' +'abc' = 'dfg' +constructor called, + my class is 'dumpy' + input parameters: array ( + 0 => 'constructor argument #1', +) + +## PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE +constructor called, + my class is 'dumpy' + input parameters: array ( + 0 => 'constructor argument #1', +) +'pdo_fetch_class_type_class' = 'dummy' +'foo' = 'bar' +'abc' = 'dfg' + +## PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE +'foo' = 'bar' +'abc' = 'dfg' +constructor called, + my class is 'dummy' + input parameters: array ( + 0 => 'constructor argument #1', +) + +## PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE | PDO::FETCH_PROPS_LATE +constructor called, + my class is 'dummy' + input parameters: array ( + 0 => 'constructor argument #1', +) +'foo' = 'bar' +'abc' = 'dfg' diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index 132e5c2e4dee1..68e251c2b6a9a 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -145,20 +145,20 @@ static zend_long dblib_handle_doer(pdo_dbh_t *dbh, const zend_string *sql) static zend_string* dblib_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype) { pdo_dblib_db_handle *H = (pdo_dblib_db_handle *)dbh->driver_data; - bool use_national_character_set = 0; + bool use_national_character_set = false; size_t i; char *q; size_t quotedlen = 0, extralen = 0; zend_string *quoted_str; if (H->assume_national_character_set_strings) { - use_national_character_set = 1; + use_national_character_set = true; } if ((paramtype & PDO_PARAM_STR_NATL) == PDO_PARAM_STR_NATL) { - use_national_character_set = 1; + use_national_character_set = true; } if ((paramtype & PDO_PARAM_STR_CHAR) == PDO_PARAM_STR_CHAR) { - use_national_character_set = 0; + use_national_character_set = false; } /* Detect quoted length, adding extra char for doubled single quotes */ diff --git a/ext/pdo_dblib/pdo_dblib_arginfo.h b/ext/pdo_dblib/pdo_dblib_arginfo.h index 1cf6c60d7a3b0..2452255265a33 100644 --- a/ext/pdo_dblib/pdo_dblib_arginfo.h +++ b/ext/pdo_dblib/pdo_dblib_arginfo.h @@ -10,45 +10,45 @@ static zend_class_entry *register_class_Pdo_Dblib(zend_class_entry *class_entry_ zval const_ATTR_CONNECTION_TIMEOUT_value; ZVAL_LONG(&const_ATTR_CONNECTION_TIMEOUT_value, PDO_DBLIB_ATTR_CONNECTION_TIMEOUT); - zend_string *const_ATTR_CONNECTION_TIMEOUT_name = zend_string_init_interned("ATTR_CONNECTION_TIMEOUT", sizeof("ATTR_CONNECTION_TIMEOUT") - 1, 1); + zend_string *const_ATTR_CONNECTION_TIMEOUT_name = zend_string_init_interned("ATTR_CONNECTION_TIMEOUT", sizeof("ATTR_CONNECTION_TIMEOUT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_CONNECTION_TIMEOUT_name, &const_ATTR_CONNECTION_TIMEOUT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_CONNECTION_TIMEOUT_name); + zend_string_release_ex(const_ATTR_CONNECTION_TIMEOUT_name, true); zval const_ATTR_QUERY_TIMEOUT_value; ZVAL_LONG(&const_ATTR_QUERY_TIMEOUT_value, PDO_DBLIB_ATTR_QUERY_TIMEOUT); - zend_string *const_ATTR_QUERY_TIMEOUT_name = zend_string_init_interned("ATTR_QUERY_TIMEOUT", sizeof("ATTR_QUERY_TIMEOUT") - 1, 1); + zend_string *const_ATTR_QUERY_TIMEOUT_name = zend_string_init_interned("ATTR_QUERY_TIMEOUT", sizeof("ATTR_QUERY_TIMEOUT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_QUERY_TIMEOUT_name, &const_ATTR_QUERY_TIMEOUT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_QUERY_TIMEOUT_name); + zend_string_release_ex(const_ATTR_QUERY_TIMEOUT_name, true); zval const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_value; ZVAL_LONG(&const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_value, PDO_DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER); - zend_string *const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_name = zend_string_init_interned("ATTR_STRINGIFY_UNIQUEIDENTIFIER", sizeof("ATTR_STRINGIFY_UNIQUEIDENTIFIER") - 1, 1); + zend_string *const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_name = zend_string_init_interned("ATTR_STRINGIFY_UNIQUEIDENTIFIER", sizeof("ATTR_STRINGIFY_UNIQUEIDENTIFIER") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_name, &const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_name); + zend_string_release_ex(const_ATTR_STRINGIFY_UNIQUEIDENTIFIER_name, true); zval const_ATTR_VERSION_value; ZVAL_LONG(&const_ATTR_VERSION_value, PDO_DBLIB_ATTR_VERSION); - zend_string *const_ATTR_VERSION_name = zend_string_init_interned("ATTR_VERSION", sizeof("ATTR_VERSION") - 1, 1); + zend_string *const_ATTR_VERSION_name = zend_string_init_interned("ATTR_VERSION", sizeof("ATTR_VERSION") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_VERSION_name, &const_ATTR_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_VERSION_name); + zend_string_release_ex(const_ATTR_VERSION_name, true); zval const_ATTR_TDS_VERSION_value; ZVAL_LONG(&const_ATTR_TDS_VERSION_value, PDO_DBLIB_ATTR_TDS_VERSION); - zend_string *const_ATTR_TDS_VERSION_name = zend_string_init_interned("ATTR_TDS_VERSION", sizeof("ATTR_TDS_VERSION") - 1, 1); + zend_string *const_ATTR_TDS_VERSION_name = zend_string_init_interned("ATTR_TDS_VERSION", sizeof("ATTR_TDS_VERSION") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_TDS_VERSION_name, &const_ATTR_TDS_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_TDS_VERSION_name); + zend_string_release_ex(const_ATTR_TDS_VERSION_name, true); zval const_ATTR_SKIP_EMPTY_ROWSETS_value; ZVAL_LONG(&const_ATTR_SKIP_EMPTY_ROWSETS_value, PDO_DBLIB_ATTR_SKIP_EMPTY_ROWSETS); - zend_string *const_ATTR_SKIP_EMPTY_ROWSETS_name = zend_string_init_interned("ATTR_SKIP_EMPTY_ROWSETS", sizeof("ATTR_SKIP_EMPTY_ROWSETS") - 1, 1); + zend_string *const_ATTR_SKIP_EMPTY_ROWSETS_name = zend_string_init_interned("ATTR_SKIP_EMPTY_ROWSETS", sizeof("ATTR_SKIP_EMPTY_ROWSETS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SKIP_EMPTY_ROWSETS_name, &const_ATTR_SKIP_EMPTY_ROWSETS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SKIP_EMPTY_ROWSETS_name); + zend_string_release_ex(const_ATTR_SKIP_EMPTY_ROWSETS_name, true); zval const_ATTR_DATETIME_CONVERT_value; ZVAL_LONG(&const_ATTR_DATETIME_CONVERT_value, PDO_DBLIB_ATTR_DATETIME_CONVERT); - zend_string *const_ATTR_DATETIME_CONVERT_name = zend_string_init_interned("ATTR_DATETIME_CONVERT", sizeof("ATTR_DATETIME_CONVERT") - 1, 1); + zend_string *const_ATTR_DATETIME_CONVERT_name = zend_string_init_interned("ATTR_DATETIME_CONVERT", sizeof("ATTR_DATETIME_CONVERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_DATETIME_CONVERT_name, &const_ATTR_DATETIME_CONVERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_DATETIME_CONVERT_name); + zend_string_release_ex(const_ATTR_DATETIME_CONVERT_name, true); return class_entry; } diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index f6d5b1144f382..8eea24a65353f 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -297,7 +297,7 @@ static FbTokenType php_firebird_get_token(const char** begin, const char* end) static int php_firebird_preprocess(const zend_string* sql, char* sql_out, HashTable* named_params) { - bool passAsIs = 1, execBlock = 0; + bool passAsIs = true, execBlock = false; zend_long pindex = -1; char pname[254], ident[253], ident2[253]; unsigned int l; @@ -354,7 +354,7 @@ static int php_firebird_preprocess(const zend_string* sql, char* sql_out, HashTa strncpy(ident2, i2, l); ident2[l] = '\0'; execBlock = !strcasecmp(ident2, "BLOCK"); - passAsIs = 0; + passAsIs = false; } else { @@ -592,7 +592,7 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */ php_firebird_rollback_transaction(dbh); } } - H->in_manually_txn = 0; + H->in_manually_txn = false; /* isc_detach_database returns 0 on success, 1 on failure. */ if (H->db && isc_detach_database(H->isc_status, &H->db)) { @@ -904,7 +904,7 @@ static bool firebird_handle_manually_begin(pdo_dbh_t *dbh) /* {{{ */ if (!php_firebird_begin_transaction(dbh, /* auto commit mode */ false)) { return false; } - H->in_manually_txn = 1; + H->in_manually_txn = true; return true; } /* }}} */ @@ -954,7 +954,7 @@ static bool firebird_handle_manually_commit(pdo_dbh_t *dbh) /* {{{ */ return false; } } - H->in_manually_txn = 0; + H->in_manually_txn = false; return true; } /* }}} */ @@ -990,7 +990,7 @@ static bool firebird_handle_manually_rollback(pdo_dbh_t *dbh) /* {{{ */ return false; } } - H->in_manually_txn = 0; + H->in_manually_txn = false; return true; } /* }}} */ @@ -1353,7 +1353,7 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* dbh->password = pestrdup(vars[5].optval, dbh->is_persistent); } - H->in_manually_txn = 0; + H->in_manually_txn = false; H->is_writable_txn = pdo_attr_lval(driver_options, PDO_FB_WRITABLE_TRANSACTION, 1); zend_long txn_isolation_level = pdo_attr_lval(driver_options, PDO_FB_TRANSACTION_ISOLATION_LEVEL, PDO_FB_REPEATABLE_READ); if (txn_isolation_level == PDO_FB_READ_COMMITTED || diff --git a/ext/pdo_firebird/pdo_firebird_arginfo.h b/ext/pdo_firebird/pdo_firebird_arginfo.h index a5a9c562c9c12..fd500a6130c0a 100644 --- a/ext/pdo_firebird/pdo_firebird_arginfo.h +++ b/ext/pdo_firebird/pdo_firebird_arginfo.h @@ -20,51 +20,51 @@ static zend_class_entry *register_class_Pdo_Firebird(zend_class_entry *class_ent zval const_ATTR_DATE_FORMAT_value; ZVAL_LONG(&const_ATTR_DATE_FORMAT_value, PDO_FB_ATTR_DATE_FORMAT); - zend_string *const_ATTR_DATE_FORMAT_name = zend_string_init_interned("ATTR_DATE_FORMAT", sizeof("ATTR_DATE_FORMAT") - 1, 1); + zend_string *const_ATTR_DATE_FORMAT_name = zend_string_init_interned("ATTR_DATE_FORMAT", sizeof("ATTR_DATE_FORMAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_DATE_FORMAT_name, &const_ATTR_DATE_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_DATE_FORMAT_name); + zend_string_release_ex(const_ATTR_DATE_FORMAT_name, true); zval const_ATTR_TIME_FORMAT_value; ZVAL_LONG(&const_ATTR_TIME_FORMAT_value, PDO_FB_ATTR_TIME_FORMAT); - zend_string *const_ATTR_TIME_FORMAT_name = zend_string_init_interned("ATTR_TIME_FORMAT", sizeof("ATTR_TIME_FORMAT") - 1, 1); + zend_string *const_ATTR_TIME_FORMAT_name = zend_string_init_interned("ATTR_TIME_FORMAT", sizeof("ATTR_TIME_FORMAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_TIME_FORMAT_name, &const_ATTR_TIME_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_TIME_FORMAT_name); + zend_string_release_ex(const_ATTR_TIME_FORMAT_name, true); zval const_ATTR_TIMESTAMP_FORMAT_value; ZVAL_LONG(&const_ATTR_TIMESTAMP_FORMAT_value, PDO_FB_ATTR_TIMESTAMP_FORMAT); - zend_string *const_ATTR_TIMESTAMP_FORMAT_name = zend_string_init_interned("ATTR_TIMESTAMP_FORMAT", sizeof("ATTR_TIMESTAMP_FORMAT") - 1, 1); + zend_string *const_ATTR_TIMESTAMP_FORMAT_name = zend_string_init_interned("ATTR_TIMESTAMP_FORMAT", sizeof("ATTR_TIMESTAMP_FORMAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_TIMESTAMP_FORMAT_name, &const_ATTR_TIMESTAMP_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_TIMESTAMP_FORMAT_name); + zend_string_release_ex(const_ATTR_TIMESTAMP_FORMAT_name, true); zval const_TRANSACTION_ISOLATION_LEVEL_value; ZVAL_LONG(&const_TRANSACTION_ISOLATION_LEVEL_value, PDO_FB_TRANSACTION_ISOLATION_LEVEL); - zend_string *const_TRANSACTION_ISOLATION_LEVEL_name = zend_string_init_interned("TRANSACTION_ISOLATION_LEVEL", sizeof("TRANSACTION_ISOLATION_LEVEL") - 1, 1); + zend_string *const_TRANSACTION_ISOLATION_LEVEL_name = zend_string_init_interned("TRANSACTION_ISOLATION_LEVEL", sizeof("TRANSACTION_ISOLATION_LEVEL") - 1, true); zend_declare_typed_class_constant(class_entry, const_TRANSACTION_ISOLATION_LEVEL_name, &const_TRANSACTION_ISOLATION_LEVEL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_ISOLATION_LEVEL_name); + zend_string_release_ex(const_TRANSACTION_ISOLATION_LEVEL_name, true); zval const_READ_COMMITTED_value; ZVAL_LONG(&const_READ_COMMITTED_value, PDO_FB_READ_COMMITTED); - zend_string *const_READ_COMMITTED_name = zend_string_init_interned("READ_COMMITTED", sizeof("READ_COMMITTED") - 1, 1); + zend_string *const_READ_COMMITTED_name = zend_string_init_interned("READ_COMMITTED", sizeof("READ_COMMITTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_READ_COMMITTED_name, &const_READ_COMMITTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_READ_COMMITTED_name); + zend_string_release_ex(const_READ_COMMITTED_name, true); zval const_REPEATABLE_READ_value; ZVAL_LONG(&const_REPEATABLE_READ_value, PDO_FB_REPEATABLE_READ); - zend_string *const_REPEATABLE_READ_name = zend_string_init_interned("REPEATABLE_READ", sizeof("REPEATABLE_READ") - 1, 1); + zend_string *const_REPEATABLE_READ_name = zend_string_init_interned("REPEATABLE_READ", sizeof("REPEATABLE_READ") - 1, true); zend_declare_typed_class_constant(class_entry, const_REPEATABLE_READ_name, &const_REPEATABLE_READ_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REPEATABLE_READ_name); + zend_string_release_ex(const_REPEATABLE_READ_name, true); zval const_SERIALIZABLE_value; ZVAL_LONG(&const_SERIALIZABLE_value, PDO_FB_SERIALIZABLE); - zend_string *const_SERIALIZABLE_name = zend_string_init_interned("SERIALIZABLE", sizeof("SERIALIZABLE") - 1, 1); + zend_string *const_SERIALIZABLE_name = zend_string_init_interned("SERIALIZABLE", sizeof("SERIALIZABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SERIALIZABLE_name, &const_SERIALIZABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SERIALIZABLE_name); + zend_string_release_ex(const_SERIALIZABLE_name, true); zval const_WRITABLE_TRANSACTION_value; ZVAL_LONG(&const_WRITABLE_TRANSACTION_value, PDO_FB_WRITABLE_TRANSACTION); - zend_string *const_WRITABLE_TRANSACTION_name = zend_string_init_interned("WRITABLE_TRANSACTION", sizeof("WRITABLE_TRANSACTION") - 1, 1); + zend_string *const_WRITABLE_TRANSACTION_name = zend_string_init_interned("WRITABLE_TRANSACTION", sizeof("WRITABLE_TRANSACTION") - 1, true); zend_declare_typed_class_constant(class_entry, const_WRITABLE_TRANSACTION_name, &const_WRITABLE_TRANSACTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WRITABLE_TRANSACTION_name); + zend_string_release_ex(const_WRITABLE_TRANSACTION_name, true); return class_entry; } diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 786bd9c606cd1..808f4acbfa37d 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -308,21 +308,21 @@ static zend_string *pdo_mysql_last_insert_id(pdo_dbh_t *dbh, const zend_string * static zend_string* mysql_handle_quoter(pdo_dbh_t *dbh, const zend_string *unquoted, enum pdo_param_type paramtype ) { pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; - bool use_national_character_set = 0; - bool use_binary = 0; + bool use_national_character_set = false; + bool use_binary = false; size_t quotedlen; if ((paramtype & PDO_PARAM_LOB) == PDO_PARAM_LOB) { - use_binary = 1; + use_binary = true; } else { if (H->assume_national_character_set_strings) { - use_national_character_set = 1; + use_national_character_set = true; } if ((paramtype & PDO_PARAM_STR_NATL) == PDO_PARAM_STR_NATL) { - use_national_character_set = 1; + use_national_character_set = true; } if ((paramtype & PDO_PARAM_STR_CHAR) == PDO_PARAM_STR_CHAR) { - use_national_character_set = 0; + use_national_character_set = false; } } diff --git a/ext/pdo_mysql/pdo_mysql_arginfo.h b/ext/pdo_mysql/pdo_mysql_arginfo.h index 0e9c04bd3cfd3..516109fa0520a 100644 --- a/ext/pdo_mysql/pdo_mysql_arginfo.h +++ b/ext/pdo_mysql/pdo_mysql_arginfo.h @@ -20,124 +20,124 @@ static zend_class_entry *register_class_Pdo_Mysql(zend_class_entry *class_entry_ zval const_ATTR_USE_BUFFERED_QUERY_value; ZVAL_LONG(&const_ATTR_USE_BUFFERED_QUERY_value, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY); - zend_string *const_ATTR_USE_BUFFERED_QUERY_name = zend_string_init_interned("ATTR_USE_BUFFERED_QUERY", sizeof("ATTR_USE_BUFFERED_QUERY") - 1, 1); + zend_string *const_ATTR_USE_BUFFERED_QUERY_name = zend_string_init_interned("ATTR_USE_BUFFERED_QUERY", sizeof("ATTR_USE_BUFFERED_QUERY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_USE_BUFFERED_QUERY_name, &const_ATTR_USE_BUFFERED_QUERY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_USE_BUFFERED_QUERY_name); + zend_string_release_ex(const_ATTR_USE_BUFFERED_QUERY_name, true); zval const_ATTR_LOCAL_INFILE_value; ZVAL_LONG(&const_ATTR_LOCAL_INFILE_value, PDO_MYSQL_ATTR_LOCAL_INFILE); - zend_string *const_ATTR_LOCAL_INFILE_name = zend_string_init_interned("ATTR_LOCAL_INFILE", sizeof("ATTR_LOCAL_INFILE") - 1, 1); + zend_string *const_ATTR_LOCAL_INFILE_name = zend_string_init_interned("ATTR_LOCAL_INFILE", sizeof("ATTR_LOCAL_INFILE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_LOCAL_INFILE_name, &const_ATTR_LOCAL_INFILE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_LOCAL_INFILE_name); + zend_string_release_ex(const_ATTR_LOCAL_INFILE_name, true); zval const_ATTR_INIT_COMMAND_value; ZVAL_LONG(&const_ATTR_INIT_COMMAND_value, PDO_MYSQL_ATTR_INIT_COMMAND); - zend_string *const_ATTR_INIT_COMMAND_name = zend_string_init_interned("ATTR_INIT_COMMAND", sizeof("ATTR_INIT_COMMAND") - 1, 1); + zend_string *const_ATTR_INIT_COMMAND_name = zend_string_init_interned("ATTR_INIT_COMMAND", sizeof("ATTR_INIT_COMMAND") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_INIT_COMMAND_name, &const_ATTR_INIT_COMMAND_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_INIT_COMMAND_name); + zend_string_release_ex(const_ATTR_INIT_COMMAND_name, true); #if !defined(PDO_USE_MYSQLND) zval const_ATTR_MAX_BUFFER_SIZE_value; ZVAL_LONG(&const_ATTR_MAX_BUFFER_SIZE_value, PDO_MYSQL_ATTR_MAX_BUFFER_SIZE); - zend_string *const_ATTR_MAX_BUFFER_SIZE_name = zend_string_init_interned("ATTR_MAX_BUFFER_SIZE", sizeof("ATTR_MAX_BUFFER_SIZE") - 1, 1); + zend_string *const_ATTR_MAX_BUFFER_SIZE_name = zend_string_init_interned("ATTR_MAX_BUFFER_SIZE", sizeof("ATTR_MAX_BUFFER_SIZE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_MAX_BUFFER_SIZE_name, &const_ATTR_MAX_BUFFER_SIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_MAX_BUFFER_SIZE_name); + zend_string_release_ex(const_ATTR_MAX_BUFFER_SIZE_name, true); zval const_ATTR_READ_DEFAULT_FILE_value; ZVAL_LONG(&const_ATTR_READ_DEFAULT_FILE_value, PDO_MYSQL_ATTR_READ_DEFAULT_FILE); - zend_string *const_ATTR_READ_DEFAULT_FILE_name = zend_string_init_interned("ATTR_READ_DEFAULT_FILE", sizeof("ATTR_READ_DEFAULT_FILE") - 1, 1); + zend_string *const_ATTR_READ_DEFAULT_FILE_name = zend_string_init_interned("ATTR_READ_DEFAULT_FILE", sizeof("ATTR_READ_DEFAULT_FILE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_READ_DEFAULT_FILE_name, &const_ATTR_READ_DEFAULT_FILE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_READ_DEFAULT_FILE_name); + zend_string_release_ex(const_ATTR_READ_DEFAULT_FILE_name, true); zval const_ATTR_READ_DEFAULT_GROUP_value; ZVAL_LONG(&const_ATTR_READ_DEFAULT_GROUP_value, PDO_MYSQL_ATTR_READ_DEFAULT_GROUP); - zend_string *const_ATTR_READ_DEFAULT_GROUP_name = zend_string_init_interned("ATTR_READ_DEFAULT_GROUP", sizeof("ATTR_READ_DEFAULT_GROUP") - 1, 1); + zend_string *const_ATTR_READ_DEFAULT_GROUP_name = zend_string_init_interned("ATTR_READ_DEFAULT_GROUP", sizeof("ATTR_READ_DEFAULT_GROUP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_READ_DEFAULT_GROUP_name, &const_ATTR_READ_DEFAULT_GROUP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_READ_DEFAULT_GROUP_name); + zend_string_release_ex(const_ATTR_READ_DEFAULT_GROUP_name, true); #endif zval const_ATTR_COMPRESS_value; ZVAL_LONG(&const_ATTR_COMPRESS_value, PDO_MYSQL_ATTR_COMPRESS); - zend_string *const_ATTR_COMPRESS_name = zend_string_init_interned("ATTR_COMPRESS", sizeof("ATTR_COMPRESS") - 1, 1); + zend_string *const_ATTR_COMPRESS_name = zend_string_init_interned("ATTR_COMPRESS", sizeof("ATTR_COMPRESS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_COMPRESS_name, &const_ATTR_COMPRESS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_COMPRESS_name); + zend_string_release_ex(const_ATTR_COMPRESS_name, true); zval const_ATTR_DIRECT_QUERY_value; ZVAL_LONG(&const_ATTR_DIRECT_QUERY_value, PDO_ATTR_EMULATE_PREPARES); - zend_string *const_ATTR_DIRECT_QUERY_name = zend_string_init_interned("ATTR_DIRECT_QUERY", sizeof("ATTR_DIRECT_QUERY") - 1, 1); + zend_string *const_ATTR_DIRECT_QUERY_name = zend_string_init_interned("ATTR_DIRECT_QUERY", sizeof("ATTR_DIRECT_QUERY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_DIRECT_QUERY_name, &const_ATTR_DIRECT_QUERY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_DIRECT_QUERY_name); + zend_string_release_ex(const_ATTR_DIRECT_QUERY_name, true); zval const_ATTR_FOUND_ROWS_value; ZVAL_LONG(&const_ATTR_FOUND_ROWS_value, PDO_MYSQL_ATTR_FOUND_ROWS); - zend_string *const_ATTR_FOUND_ROWS_name = zend_string_init_interned("ATTR_FOUND_ROWS", sizeof("ATTR_FOUND_ROWS") - 1, 1); + zend_string *const_ATTR_FOUND_ROWS_name = zend_string_init_interned("ATTR_FOUND_ROWS", sizeof("ATTR_FOUND_ROWS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_FOUND_ROWS_name, &const_ATTR_FOUND_ROWS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_FOUND_ROWS_name); + zend_string_release_ex(const_ATTR_FOUND_ROWS_name, true); zval const_ATTR_IGNORE_SPACE_value; ZVAL_LONG(&const_ATTR_IGNORE_SPACE_value, PDO_MYSQL_ATTR_IGNORE_SPACE); - zend_string *const_ATTR_IGNORE_SPACE_name = zend_string_init_interned("ATTR_IGNORE_SPACE", sizeof("ATTR_IGNORE_SPACE") - 1, 1); + zend_string *const_ATTR_IGNORE_SPACE_name = zend_string_init_interned("ATTR_IGNORE_SPACE", sizeof("ATTR_IGNORE_SPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_IGNORE_SPACE_name, &const_ATTR_IGNORE_SPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_IGNORE_SPACE_name); + zend_string_release_ex(const_ATTR_IGNORE_SPACE_name, true); zval const_ATTR_SSL_KEY_value; ZVAL_LONG(&const_ATTR_SSL_KEY_value, PDO_MYSQL_ATTR_SSL_KEY); - zend_string *const_ATTR_SSL_KEY_name = zend_string_init_interned("ATTR_SSL_KEY", sizeof("ATTR_SSL_KEY") - 1, 1); + zend_string *const_ATTR_SSL_KEY_name = zend_string_init_interned("ATTR_SSL_KEY", sizeof("ATTR_SSL_KEY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SSL_KEY_name, &const_ATTR_SSL_KEY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SSL_KEY_name); + zend_string_release_ex(const_ATTR_SSL_KEY_name, true); zval const_ATTR_SSL_CERT_value; ZVAL_LONG(&const_ATTR_SSL_CERT_value, PDO_MYSQL_ATTR_SSL_CERT); - zend_string *const_ATTR_SSL_CERT_name = zend_string_init_interned("ATTR_SSL_CERT", sizeof("ATTR_SSL_CERT") - 1, 1); + zend_string *const_ATTR_SSL_CERT_name = zend_string_init_interned("ATTR_SSL_CERT", sizeof("ATTR_SSL_CERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SSL_CERT_name, &const_ATTR_SSL_CERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SSL_CERT_name); + zend_string_release_ex(const_ATTR_SSL_CERT_name, true); zval const_ATTR_SSL_CA_value; ZVAL_LONG(&const_ATTR_SSL_CA_value, PDO_MYSQL_ATTR_SSL_CA); - zend_string *const_ATTR_SSL_CA_name = zend_string_init_interned("ATTR_SSL_CA", sizeof("ATTR_SSL_CA") - 1, 1); + zend_string *const_ATTR_SSL_CA_name = zend_string_init_interned("ATTR_SSL_CA", sizeof("ATTR_SSL_CA") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SSL_CA_name, &const_ATTR_SSL_CA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SSL_CA_name); + zend_string_release_ex(const_ATTR_SSL_CA_name, true); zval const_ATTR_SSL_CAPATH_value; ZVAL_LONG(&const_ATTR_SSL_CAPATH_value, PDO_MYSQL_ATTR_SSL_CAPATH); - zend_string *const_ATTR_SSL_CAPATH_name = zend_string_init_interned("ATTR_SSL_CAPATH", sizeof("ATTR_SSL_CAPATH") - 1, 1); + zend_string *const_ATTR_SSL_CAPATH_name = zend_string_init_interned("ATTR_SSL_CAPATH", sizeof("ATTR_SSL_CAPATH") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SSL_CAPATH_name, &const_ATTR_SSL_CAPATH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SSL_CAPATH_name); + zend_string_release_ex(const_ATTR_SSL_CAPATH_name, true); zval const_ATTR_SSL_CIPHER_value; ZVAL_LONG(&const_ATTR_SSL_CIPHER_value, PDO_MYSQL_ATTR_SSL_CIPHER); - zend_string *const_ATTR_SSL_CIPHER_name = zend_string_init_interned("ATTR_SSL_CIPHER", sizeof("ATTR_SSL_CIPHER") - 1, 1); + zend_string *const_ATTR_SSL_CIPHER_name = zend_string_init_interned("ATTR_SSL_CIPHER", sizeof("ATTR_SSL_CIPHER") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SSL_CIPHER_name, &const_ATTR_SSL_CIPHER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SSL_CIPHER_name); + zend_string_release_ex(const_ATTR_SSL_CIPHER_name, true); #if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND) zval const_ATTR_SERVER_PUBLIC_KEY_value; ZVAL_LONG(&const_ATTR_SERVER_PUBLIC_KEY_value, PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY); - zend_string *const_ATTR_SERVER_PUBLIC_KEY_name = zend_string_init_interned("ATTR_SERVER_PUBLIC_KEY", sizeof("ATTR_SERVER_PUBLIC_KEY") - 1, 1); + zend_string *const_ATTR_SERVER_PUBLIC_KEY_name = zend_string_init_interned("ATTR_SERVER_PUBLIC_KEY", sizeof("ATTR_SERVER_PUBLIC_KEY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SERVER_PUBLIC_KEY_name, &const_ATTR_SERVER_PUBLIC_KEY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SERVER_PUBLIC_KEY_name); + zend_string_release_ex(const_ATTR_SERVER_PUBLIC_KEY_name, true); #endif zval const_ATTR_MULTI_STATEMENTS_value; ZVAL_LONG(&const_ATTR_MULTI_STATEMENTS_value, PDO_MYSQL_ATTR_MULTI_STATEMENTS); - zend_string *const_ATTR_MULTI_STATEMENTS_name = zend_string_init_interned("ATTR_MULTI_STATEMENTS", sizeof("ATTR_MULTI_STATEMENTS") - 1, 1); + zend_string *const_ATTR_MULTI_STATEMENTS_name = zend_string_init_interned("ATTR_MULTI_STATEMENTS", sizeof("ATTR_MULTI_STATEMENTS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_MULTI_STATEMENTS_name, &const_ATTR_MULTI_STATEMENTS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_MULTI_STATEMENTS_name); + zend_string_release_ex(const_ATTR_MULTI_STATEMENTS_name, true); #if defined(PDO_USE_MYSQLND) zval const_ATTR_SSL_VERIFY_SERVER_CERT_value; ZVAL_LONG(&const_ATTR_SSL_VERIFY_SERVER_CERT_value, PDO_MYSQL_ATTR_SSL_VERIFY_SERVER_CERT); - zend_string *const_ATTR_SSL_VERIFY_SERVER_CERT_name = zend_string_init_interned("ATTR_SSL_VERIFY_SERVER_CERT", sizeof("ATTR_SSL_VERIFY_SERVER_CERT") - 1, 1); + zend_string *const_ATTR_SSL_VERIFY_SERVER_CERT_name = zend_string_init_interned("ATTR_SSL_VERIFY_SERVER_CERT", sizeof("ATTR_SSL_VERIFY_SERVER_CERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_SSL_VERIFY_SERVER_CERT_name, &const_ATTR_SSL_VERIFY_SERVER_CERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_SSL_VERIFY_SERVER_CERT_name); + zend_string_release_ex(const_ATTR_SSL_VERIFY_SERVER_CERT_name, true); #endif #if MYSQL_VERSION_ID >= 80021 || defined(PDO_USE_MYSQLND) zval const_ATTR_LOCAL_INFILE_DIRECTORY_value; ZVAL_LONG(&const_ATTR_LOCAL_INFILE_DIRECTORY_value, PDO_MYSQL_ATTR_LOCAL_INFILE_DIRECTORY); - zend_string *const_ATTR_LOCAL_INFILE_DIRECTORY_name = zend_string_init_interned("ATTR_LOCAL_INFILE_DIRECTORY", sizeof("ATTR_LOCAL_INFILE_DIRECTORY") - 1, 1); + zend_string *const_ATTR_LOCAL_INFILE_DIRECTORY_name = zend_string_init_interned("ATTR_LOCAL_INFILE_DIRECTORY", sizeof("ATTR_LOCAL_INFILE_DIRECTORY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_LOCAL_INFILE_DIRECTORY_name, &const_ATTR_LOCAL_INFILE_DIRECTORY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_LOCAL_INFILE_DIRECTORY_name); + zend_string_release_ex(const_ATTR_LOCAL_INFILE_DIRECTORY_name, true); #endif return class_entry; diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt index 2437e7ca12d16..910afceb27f08 100644 --- a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt @@ -73,7 +73,7 @@ MySQLPDOTest::skip(); } if (!is_object($db = new PDO($dsn, $user, $pass, array()))) - printf("[002] Expecting object got %s/%s¸\n", gettype($db), $db); + printf("[002] Expecting object got %s/%s\n", gettype($db), $db); $invalid = 999; if (is_object($db = new PDO($dsn, $user, $pass, array($invalid => true)))) diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 8e27d27173c0b..171fb7b7b1e95 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -803,7 +803,7 @@ static int odbc_stmt_set_param(pdo_stmt_t *stmt, zend_long attr, zval *val) return 0; case PDO_ODBC_ATTR_ASSUME_UTF8: - S->assume_utf8 = zval_is_true(val); + S->assume_utf8 = zend_is_true(val); return 0; default: strcpy(S->einfo.last_err_msg, "Unknown Attribute"); diff --git a/ext/pdo_odbc/pdo_odbc_arginfo.h b/ext/pdo_odbc/pdo_odbc_arginfo.h index 5b1933d7594a0..d8ee0524feb5f 100644 --- a/ext/pdo_odbc/pdo_odbc_arginfo.h +++ b/ext/pdo_odbc/pdo_odbc_arginfo.h @@ -15,33 +15,33 @@ static zend_class_entry *register_class_Pdo_Odbc(zend_class_entry *class_entry_P zval const_ATTR_USE_CURSOR_LIBRARY_value; ZVAL_LONG(&const_ATTR_USE_CURSOR_LIBRARY_value, PDO_ODBC_ATTR_USE_CURSOR_LIBRARY); - zend_string *const_ATTR_USE_CURSOR_LIBRARY_name = zend_string_init_interned("ATTR_USE_CURSOR_LIBRARY", sizeof("ATTR_USE_CURSOR_LIBRARY") - 1, 1); + zend_string *const_ATTR_USE_CURSOR_LIBRARY_name = zend_string_init_interned("ATTR_USE_CURSOR_LIBRARY", sizeof("ATTR_USE_CURSOR_LIBRARY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_USE_CURSOR_LIBRARY_name, &const_ATTR_USE_CURSOR_LIBRARY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_USE_CURSOR_LIBRARY_name); + zend_string_release_ex(const_ATTR_USE_CURSOR_LIBRARY_name, true); zval const_ATTR_ASSUME_UTF8_value; ZVAL_LONG(&const_ATTR_ASSUME_UTF8_value, PDO_ODBC_ATTR_ASSUME_UTF8); - zend_string *const_ATTR_ASSUME_UTF8_name = zend_string_init_interned("ATTR_ASSUME_UTF8", sizeof("ATTR_ASSUME_UTF8") - 1, 1); + zend_string *const_ATTR_ASSUME_UTF8_name = zend_string_init_interned("ATTR_ASSUME_UTF8", sizeof("ATTR_ASSUME_UTF8") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_ASSUME_UTF8_name, &const_ATTR_ASSUME_UTF8_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_ASSUME_UTF8_name); + zend_string_release_ex(const_ATTR_ASSUME_UTF8_name, true); zval const_SQL_USE_IF_NEEDED_value; ZVAL_LONG(&const_SQL_USE_IF_NEEDED_value, SQL_CUR_USE_IF_NEEDED); - zend_string *const_SQL_USE_IF_NEEDED_name = zend_string_init_interned("SQL_USE_IF_NEEDED", sizeof("SQL_USE_IF_NEEDED") - 1, 1); + zend_string *const_SQL_USE_IF_NEEDED_name = zend_string_init_interned("SQL_USE_IF_NEEDED", sizeof("SQL_USE_IF_NEEDED") - 1, true); zend_declare_typed_class_constant(class_entry, const_SQL_USE_IF_NEEDED_name, &const_SQL_USE_IF_NEEDED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SQL_USE_IF_NEEDED_name); + zend_string_release_ex(const_SQL_USE_IF_NEEDED_name, true); zval const_SQL_USE_DRIVER_value; ZVAL_LONG(&const_SQL_USE_DRIVER_value, SQL_CUR_USE_DRIVER); - zend_string *const_SQL_USE_DRIVER_name = zend_string_init_interned("SQL_USE_DRIVER", sizeof("SQL_USE_DRIVER") - 1, 1); + zend_string *const_SQL_USE_DRIVER_name = zend_string_init_interned("SQL_USE_DRIVER", sizeof("SQL_USE_DRIVER") - 1, true); zend_declare_typed_class_constant(class_entry, const_SQL_USE_DRIVER_name, &const_SQL_USE_DRIVER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SQL_USE_DRIVER_name); + zend_string_release_ex(const_SQL_USE_DRIVER_name, true); zval const_SQL_USE_ODBC_value; ZVAL_LONG(&const_SQL_USE_ODBC_value, SQL_CUR_USE_ODBC); - zend_string *const_SQL_USE_ODBC_name = zend_string_init_interned("SQL_USE_ODBC", sizeof("SQL_USE_ODBC") - 1, 1); + zend_string *const_SQL_USE_ODBC_name = zend_string_init_interned("SQL_USE_ODBC", sizeof("SQL_USE_ODBC") - 1, true); zend_declare_typed_class_constant(class_entry, const_SQL_USE_ODBC_name, &const_SQL_USE_ODBC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SQL_USE_ODBC_name); + zend_string_release_ex(const_SQL_USE_ODBC_name, true); return class_entry; } diff --git a/ext/pdo_pgsql/pdo_pgsql_arginfo.h b/ext/pdo_pgsql/pdo_pgsql_arginfo.h index 5cb973a79f5a3..296207471a198 100644 --- a/ext/pdo_pgsql/pdo_pgsql_arginfo.h +++ b/ext/pdo_pgsql/pdo_pgsql_arginfo.h @@ -90,47 +90,47 @@ static zend_class_entry *register_class_Pdo_Pgsql(zend_class_entry *class_entry_ zval const_ATTR_DISABLE_PREPARES_value; ZVAL_LONG(&const_ATTR_DISABLE_PREPARES_value, PDO_PGSQL_ATTR_DISABLE_PREPARES); - zend_string *const_ATTR_DISABLE_PREPARES_name = zend_string_init_interned("ATTR_DISABLE_PREPARES", sizeof("ATTR_DISABLE_PREPARES") - 1, 1); + zend_string *const_ATTR_DISABLE_PREPARES_name = zend_string_init_interned("ATTR_DISABLE_PREPARES", sizeof("ATTR_DISABLE_PREPARES") - 1, true); 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); + zend_string_release_ex(const_ATTR_DISABLE_PREPARES_name, true); #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_string *const_ATTR_RESULT_MEMORY_SIZE_name = zend_string_init_interned("ATTR_RESULT_MEMORY_SIZE", sizeof("ATTR_RESULT_MEMORY_SIZE") - 1, true); 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); + zend_string_release_ex(const_ATTR_RESULT_MEMORY_SIZE_name, true); #endif zval const_TRANSACTION_IDLE_value; ZVAL_LONG(&const_TRANSACTION_IDLE_value, PGSQL_TRANSACTION_IDLE); - zend_string *const_TRANSACTION_IDLE_name = zend_string_init_interned("TRANSACTION_IDLE", sizeof("TRANSACTION_IDLE") - 1, 1); + zend_string *const_TRANSACTION_IDLE_name = zend_string_init_interned("TRANSACTION_IDLE", sizeof("TRANSACTION_IDLE") - 1, true); zend_class_constant *const_TRANSACTION_IDLE = zend_declare_typed_class_constant(class_entry, const_TRANSACTION_IDLE_name, &const_TRANSACTION_IDLE_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_IDLE_name); + zend_string_release_ex(const_TRANSACTION_IDLE_name, true); zval const_TRANSACTION_ACTIVE_value; ZVAL_LONG(&const_TRANSACTION_ACTIVE_value, PGSQL_TRANSACTION_ACTIVE); - zend_string *const_TRANSACTION_ACTIVE_name = zend_string_init_interned("TRANSACTION_ACTIVE", sizeof("TRANSACTION_ACTIVE") - 1, 1); + zend_string *const_TRANSACTION_ACTIVE_name = zend_string_init_interned("TRANSACTION_ACTIVE", sizeof("TRANSACTION_ACTIVE") - 1, true); zend_class_constant *const_TRANSACTION_ACTIVE = zend_declare_typed_class_constant(class_entry, const_TRANSACTION_ACTIVE_name, &const_TRANSACTION_ACTIVE_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_ACTIVE_name); + zend_string_release_ex(const_TRANSACTION_ACTIVE_name, true); zval const_TRANSACTION_INTRANS_value; ZVAL_LONG(&const_TRANSACTION_INTRANS_value, PGSQL_TRANSACTION_INTRANS); - zend_string *const_TRANSACTION_INTRANS_name = zend_string_init_interned("TRANSACTION_INTRANS", sizeof("TRANSACTION_INTRANS") - 1, 1); + zend_string *const_TRANSACTION_INTRANS_name = zend_string_init_interned("TRANSACTION_INTRANS", sizeof("TRANSACTION_INTRANS") - 1, true); zend_class_constant *const_TRANSACTION_INTRANS = zend_declare_typed_class_constant(class_entry, const_TRANSACTION_INTRANS_name, &const_TRANSACTION_INTRANS_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_INTRANS_name); + zend_string_release_ex(const_TRANSACTION_INTRANS_name, true); zval const_TRANSACTION_INERROR_value; ZVAL_LONG(&const_TRANSACTION_INERROR_value, PGSQL_TRANSACTION_INERROR); - zend_string *const_TRANSACTION_INERROR_name = zend_string_init_interned("TRANSACTION_INERROR", sizeof("TRANSACTION_INERROR") - 1, 1); + zend_string *const_TRANSACTION_INERROR_name = zend_string_init_interned("TRANSACTION_INERROR", sizeof("TRANSACTION_INERROR") - 1, true); zend_class_constant *const_TRANSACTION_INERROR = zend_declare_typed_class_constant(class_entry, const_TRANSACTION_INERROR_name, &const_TRANSACTION_INERROR_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_INERROR_name); + zend_string_release_ex(const_TRANSACTION_INERROR_name, true); zval const_TRANSACTION_UNKNOWN_value; ZVAL_LONG(&const_TRANSACTION_UNKNOWN_value, PGSQL_TRANSACTION_UNKNOWN); - zend_string *const_TRANSACTION_UNKNOWN_name = zend_string_init_interned("TRANSACTION_UNKNOWN", sizeof("TRANSACTION_UNKNOWN") - 1, 1); + zend_string *const_TRANSACTION_UNKNOWN_name = zend_string_init_interned("TRANSACTION_UNKNOWN", sizeof("TRANSACTION_UNKNOWN") - 1, true); zend_class_constant *const_TRANSACTION_UNKNOWN = zend_declare_typed_class_constant(class_entry, const_TRANSACTION_UNKNOWN_name, &const_TRANSACTION_UNKNOWN_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_UNKNOWN_name); + zend_string_release_ex(const_TRANSACTION_UNKNOWN_name, true); zend_attribute *attribute_Deprecated_const_TRANSACTION_IDLE_0 = zend_add_class_constant_attribute(class_entry, const_TRANSACTION_IDLE, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c index be865c1f86838..44f70e00236d2 100644 --- a/ext/pdo_pgsql/pgsql_driver.c +++ b/ext/pdo_pgsql/pgsql_driver.c @@ -1340,6 +1340,20 @@ static const zend_function_entry *pdo_pgsql_get_driver_methods(pdo_dbh_t *dbh, i } } +static void pdo_pgsql_request_shutdown(pdo_dbh_t *dbh) +{ + PGresult *res; + pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; + + if(H->server) { + res = PQexec(H->server, "DISCARD ALL"); + + if(res) { + PQclear(res); + } + } +} + static bool pdo_pgsql_set_attr(pdo_dbh_t *dbh, zend_long attr, zval *val) { bool bval; @@ -1383,7 +1397,7 @@ static const struct pdo_dbh_methods pgsql_methods = { pdo_pgsql_get_attribute, pdo_pgsql_check_liveness, /* check_liveness */ pdo_pgsql_get_driver_methods, /* get_driver_methods */ - NULL, + pdo_pgsql_request_shutdown, pgsql_handle_in_transaction, NULL, /* get_gc */ pdo_pgsql_scanner diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c index f9320fd86ea83..426a878d8eff7 100644 --- a/ext/pdo_pgsql/pgsql_statement.c +++ b/ext/pdo_pgsql/pgsql_statement.c @@ -219,7 +219,7 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt) PQclear(S->result); /* the cursor was declared correctly */ - S->is_prepared = 1; + S->is_prepared = true; /* fetch to be able to get the number of tuples later, but don't advance the cursor pointer */ spprintf(&q, 0, "FETCH FORWARD 0 FROM %s", S->cursor_name); @@ -240,7 +240,7 @@ static int pgsql_stmt_execute(pdo_stmt_t *stmt) case PGRES_COMMAND_OK: case PGRES_TUPLES_OK: /* it worked */ - S->is_prepared = 1; + S->is_prepared = true; PQclear(S->result); S->result = NULL; break; diff --git a/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt b/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt new file mode 100644 index 0000000000000..736354cab13cb --- /dev/null +++ b/ext/pdo_pgsql/tests/ghsa-8xr5-qppj-gvwj.phpt @@ -0,0 +1,28 @@ +--TEST-- +#GHSA-8xr5-qppj-gvwj: NULL Pointer Derefernce for failed user input quoting +--EXTENSIONS-- +pdo +pdo_pgsql +--SKIPIF-- + +--FILE-- +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + +$sql = "SELECT * FROM users where username = :username"; +$stmt = $db->prepare($sql); + +$p1 = "alice\x99"; +var_dump($stmt->execute(['username' => $p1])); + +?> +--EXPECT-- +bool(false) diff --git a/ext/pdo_pgsql/tests/session_state_reset.phpt b/ext/pdo_pgsql/tests/session_state_reset.phpt new file mode 100644 index 0000000000000..ad892bb0da52e --- /dev/null +++ b/ext/pdo_pgsql/tests/session_state_reset.phpt @@ -0,0 +1,55 @@ +--TEST-- +Persistent connections: session state reset when performing disconnect-equivalent processing (general case) +--EXTENSIONS-- +pdo_pgsql +--SKIPIF-- + +--FILE-- + true])); + +require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; + +$pdo1 = PDOTest::test_factory(__DIR__ . '/common.phpt'); + +$pid1 = (int)$pdo1 + ->query('select pg_backend_pid()::int;') + ->fetchColumn(0); + +$defaultValue = (int)$pdo1 + ->query('show log_min_duration_statement;') + ->fetchColumn(0); + +$setValue = $defaultValue + 1; + +$pdo1->exec("set log_min_duration_statement = {$setValue};"); + +$pdo1 = null; + +$pdo2 = PDOTest::test_factory(__DIR__ . '/common.phpt'); + +$pid2 = (int)$pdo2 + ->query('select pg_backend_pid()::int;') + ->fetchColumn(0); + +assert($pid1 === $pid2); + +$expectedValue = (int)$pdo2 + ->query('show log_min_duration_statement;') + ->fetchColumn(0); + +echo "defaultValue: {$defaultValue}\n"; +echo "setValue: {$setValue}\n"; +echo "expectedValue: {$expectedValue}\n"; +echo "expected value should be reset to default: " . (($expectedValue === $defaultValue) ? 'success' : 'failure') . "\n"; + +?> +--EXPECTF-- +defaultValue: %i +setValue: %d +expectedValue: %i +expected value should be reset to default: success diff --git a/ext/pdo_pgsql/tests/session_state_reset_advisory_lock.phpt b/ext/pdo_pgsql/tests/session_state_reset_advisory_lock.phpt new file mode 100644 index 0000000000000..3435f6b7b402f --- /dev/null +++ b/ext/pdo_pgsql/tests/session_state_reset_advisory_lock.phpt @@ -0,0 +1,51 @@ +--TEST-- +Persistent connections: session state reset when performing disconnect-equivalent processing (advisory lock case) +--EXTENSIONS-- +pdo_pgsql +--SKIPIF-- + +--FILE-- + true])); + +require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; + +$pdo1 = PDOTest::test_factory(__DIR__ . '/common.phpt'); + +$pid1 = (int)$pdo1 + ->query('select pg_backend_pid()::int;') + ->fetchColumn(0); + +$lockResult1 = (bool)$pdo1 + ->query('select pg_try_advisory_lock(42)::int;') + ->fetchColumn(0); + +$pdo1 = null; + +$dsn = getenv('PDO_PGSQL_TEST_DSN'); +$dsn .= ';'; +putenv('PDO_PGSQL_TEST_DSN='.$dsn); + +$pdo2 = PDOTest::test_factory(__DIR__ . '/common.phpt'); + +$pid2 = (int)$pdo2 + ->query('select pg_backend_pid()::int;') + ->fetchColumn(0); + +assert($pid1 !== $pid2); + +$lockResult2 = (bool)$pdo2 + ->query('select pg_try_advisory_lock(42)::int;') + ->fetchColumn(0); + +echo "lock1: " . ($lockResult1 ? 'success' : 'failure') . "\n"; +echo "lock2: " . ($lockResult2 ? 'success' : 'failure') . "\n"; + +?> +--EXPECT-- +lock1: success +lock2: success diff --git a/ext/pdo_pgsql/tests/session_state_reset_after_interrupted.phpt b/ext/pdo_pgsql/tests/session_state_reset_after_interrupted.phpt new file mode 100644 index 0000000000000..fdafe8a00fc39 --- /dev/null +++ b/ext/pdo_pgsql/tests/session_state_reset_after_interrupted.phpt @@ -0,0 +1,52 @@ +--TEST-- +Persistent connections: session state reset after backend termination (interrupted case) +--EXTENSIONS-- +pdo_pgsql +--SKIPIF-- + +--FILE-- + true])); + +require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; + +$pdo1 = PDOTest::test_factory(__DIR__ . '/common.phpt'); + +$pid1 = (int)$pdo1 + ->query('select pg_backend_pid()::int;') + ->fetchColumn(0); + +$pid1 = (int)$pdo1 + ->query('select pg_backend_pid()::int;') + ->fetchColumn(0); + +$dsn = getenv('PDO_PGSQL_TEST_DSN'); +$dsn .= ';'; +putenv('PDO_PGSQL_TEST_DSN='.$dsn); + +$pdo2 = PDOTest::test_factory(__DIR__ . '/common.phpt'); + +$pid2 = (int)$pdo2 + ->query('select pg_backend_pid()::int;') + ->fetchColumn(0); + +assert($pid1 !== $pid2); + +$terminateResult = (bool)$pdo2 + ->query("select pg_terminate_backend({$pid1})::int") + ->fetchColumn(0); + +// Disconnect after being terminated by another connection +$pdo1 = null; + +echo 'pid of pdo1: ' . $pid1 . "\n"; +echo 'terminate result of pdo1 by pdo2: ' . ($terminateResult ? 'success' : 'failure') . "\n"; + +?> +--EXPECTF-- +pid of pdo1: %d +terminate result of pdo1 by pdo2: success diff --git a/ext/pdo_sqlite/pdo_sqlite_arginfo.h b/ext/pdo_sqlite/pdo_sqlite_arginfo.h index 44ec8bc327186..f50cdacdc2ec6 100644 --- a/ext/pdo_sqlite/pdo_sqlite_arginfo.h +++ b/ext/pdo_sqlite/pdo_sqlite_arginfo.h @@ -69,120 +69,120 @@ static zend_class_entry *register_class_Pdo_Sqlite(zend_class_entry *class_entry zval const_DETERMINISTIC_value; ZVAL_LONG(&const_DETERMINISTIC_value, SQLITE_DETERMINISTIC); - zend_string *const_DETERMINISTIC_name = zend_string_init_interned("DETERMINISTIC", sizeof("DETERMINISTIC") - 1, 1); + zend_string *const_DETERMINISTIC_name = zend_string_init_interned("DETERMINISTIC", sizeof("DETERMINISTIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_DETERMINISTIC_name, &const_DETERMINISTIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DETERMINISTIC_name); + zend_string_release_ex(const_DETERMINISTIC_name, true); #endif zval const_OPEN_READONLY_value; ZVAL_LONG(&const_OPEN_READONLY_value, SQLITE_OPEN_READONLY); - zend_string *const_OPEN_READONLY_name = zend_string_init_interned("OPEN_READONLY", sizeof("OPEN_READONLY") - 1, 1); + zend_string *const_OPEN_READONLY_name = zend_string_init_interned("OPEN_READONLY", sizeof("OPEN_READONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPEN_READONLY_name, &const_OPEN_READONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPEN_READONLY_name); + zend_string_release_ex(const_OPEN_READONLY_name, true); zval const_OPEN_READWRITE_value; ZVAL_LONG(&const_OPEN_READWRITE_value, SQLITE_OPEN_READWRITE); - zend_string *const_OPEN_READWRITE_name = zend_string_init_interned("OPEN_READWRITE", sizeof("OPEN_READWRITE") - 1, 1); + zend_string *const_OPEN_READWRITE_name = zend_string_init_interned("OPEN_READWRITE", sizeof("OPEN_READWRITE") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPEN_READWRITE_name, &const_OPEN_READWRITE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPEN_READWRITE_name); + zend_string_release_ex(const_OPEN_READWRITE_name, true); zval const_OPEN_CREATE_value; ZVAL_LONG(&const_OPEN_CREATE_value, SQLITE_OPEN_CREATE); - zend_string *const_OPEN_CREATE_name = zend_string_init_interned("OPEN_CREATE", sizeof("OPEN_CREATE") - 1, 1); + zend_string *const_OPEN_CREATE_name = zend_string_init_interned("OPEN_CREATE", sizeof("OPEN_CREATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPEN_CREATE_name, &const_OPEN_CREATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPEN_CREATE_name); + zend_string_release_ex(const_OPEN_CREATE_name, true); zval const_ATTR_OPEN_FLAGS_value; ZVAL_LONG(&const_ATTR_OPEN_FLAGS_value, PDO_SQLITE_ATTR_OPEN_FLAGS); - zend_string *const_ATTR_OPEN_FLAGS_name = zend_string_init_interned("ATTR_OPEN_FLAGS", sizeof("ATTR_OPEN_FLAGS") - 1, 1); + zend_string *const_ATTR_OPEN_FLAGS_name = zend_string_init_interned("ATTR_OPEN_FLAGS", sizeof("ATTR_OPEN_FLAGS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_OPEN_FLAGS_name, &const_ATTR_OPEN_FLAGS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_OPEN_FLAGS_name); + zend_string_release_ex(const_ATTR_OPEN_FLAGS_name, true); zval const_ATTR_READONLY_STATEMENT_value; ZVAL_LONG(&const_ATTR_READONLY_STATEMENT_value, PDO_SQLITE_ATTR_READONLY_STATEMENT); - zend_string *const_ATTR_READONLY_STATEMENT_name = zend_string_init_interned("ATTR_READONLY_STATEMENT", sizeof("ATTR_READONLY_STATEMENT") - 1, 1); + zend_string *const_ATTR_READONLY_STATEMENT_name = zend_string_init_interned("ATTR_READONLY_STATEMENT", sizeof("ATTR_READONLY_STATEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_READONLY_STATEMENT_name, &const_ATTR_READONLY_STATEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_READONLY_STATEMENT_name); + zend_string_release_ex(const_ATTR_READONLY_STATEMENT_name, true); zval const_ATTR_EXTENDED_RESULT_CODES_value; ZVAL_LONG(&const_ATTR_EXTENDED_RESULT_CODES_value, PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES); - zend_string *const_ATTR_EXTENDED_RESULT_CODES_name = zend_string_init_interned("ATTR_EXTENDED_RESULT_CODES", sizeof("ATTR_EXTENDED_RESULT_CODES") - 1, 1); + zend_string *const_ATTR_EXTENDED_RESULT_CODES_name = zend_string_init_interned("ATTR_EXTENDED_RESULT_CODES", sizeof("ATTR_EXTENDED_RESULT_CODES") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_EXTENDED_RESULT_CODES_name, &const_ATTR_EXTENDED_RESULT_CODES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_EXTENDED_RESULT_CODES_name); + zend_string_release_ex(const_ATTR_EXTENDED_RESULT_CODES_name, true); zval const_ATTR_BUSY_STATEMENT_value; ZVAL_LONG(&const_ATTR_BUSY_STATEMENT_value, PDO_SQLITE_ATTR_BUSY_STATEMENT); - zend_string *const_ATTR_BUSY_STATEMENT_name = zend_string_init_interned("ATTR_BUSY_STATEMENT", sizeof("ATTR_BUSY_STATEMENT") - 1, 1); + zend_string *const_ATTR_BUSY_STATEMENT_name = zend_string_init_interned("ATTR_BUSY_STATEMENT", sizeof("ATTR_BUSY_STATEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_BUSY_STATEMENT_name, &const_ATTR_BUSY_STATEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_BUSY_STATEMENT_name); + zend_string_release_ex(const_ATTR_BUSY_STATEMENT_name, true); zval const_ATTR_EXPLAIN_STATEMENT_value; ZVAL_LONG(&const_ATTR_EXPLAIN_STATEMENT_value, PDO_SQLITE_ATTR_EXPLAIN_STATEMENT); - zend_string *const_ATTR_EXPLAIN_STATEMENT_name = zend_string_init_interned("ATTR_EXPLAIN_STATEMENT", sizeof("ATTR_EXPLAIN_STATEMENT") - 1, 1); + zend_string *const_ATTR_EXPLAIN_STATEMENT_name = zend_string_init_interned("ATTR_EXPLAIN_STATEMENT", sizeof("ATTR_EXPLAIN_STATEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_EXPLAIN_STATEMENT_name, &const_ATTR_EXPLAIN_STATEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_EXPLAIN_STATEMENT_name); + zend_string_release_ex(const_ATTR_EXPLAIN_STATEMENT_name, true); zval const_ATTR_TRANSACTION_MODE_value; ZVAL_LONG(&const_ATTR_TRANSACTION_MODE_value, PDO_SQLITE_ATTR_TRANSACTION_MODE); - zend_string *const_ATTR_TRANSACTION_MODE_name = zend_string_init_interned("ATTR_TRANSACTION_MODE", sizeof("ATTR_TRANSACTION_MODE") - 1, 1); + zend_string *const_ATTR_TRANSACTION_MODE_name = zend_string_init_interned("ATTR_TRANSACTION_MODE", sizeof("ATTR_TRANSACTION_MODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTR_TRANSACTION_MODE_name, &const_ATTR_TRANSACTION_MODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTR_TRANSACTION_MODE_name); + zend_string_release_ex(const_ATTR_TRANSACTION_MODE_name, true); zval const_TRANSACTION_MODE_DEFERRED_value; ZVAL_LONG(&const_TRANSACTION_MODE_DEFERRED_value, 0); - zend_string *const_TRANSACTION_MODE_DEFERRED_name = zend_string_init_interned("TRANSACTION_MODE_DEFERRED", sizeof("TRANSACTION_MODE_DEFERRED") - 1, 1); + zend_string *const_TRANSACTION_MODE_DEFERRED_name = zend_string_init_interned("TRANSACTION_MODE_DEFERRED", sizeof("TRANSACTION_MODE_DEFERRED") - 1, true); zend_declare_typed_class_constant(class_entry, const_TRANSACTION_MODE_DEFERRED_name, &const_TRANSACTION_MODE_DEFERRED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_MODE_DEFERRED_name); + zend_string_release_ex(const_TRANSACTION_MODE_DEFERRED_name, true); zval const_TRANSACTION_MODE_IMMEDIATE_value; ZVAL_LONG(&const_TRANSACTION_MODE_IMMEDIATE_value, 1); - zend_string *const_TRANSACTION_MODE_IMMEDIATE_name = zend_string_init_interned("TRANSACTION_MODE_IMMEDIATE", sizeof("TRANSACTION_MODE_IMMEDIATE") - 1, 1); + zend_string *const_TRANSACTION_MODE_IMMEDIATE_name = zend_string_init_interned("TRANSACTION_MODE_IMMEDIATE", sizeof("TRANSACTION_MODE_IMMEDIATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_TRANSACTION_MODE_IMMEDIATE_name, &const_TRANSACTION_MODE_IMMEDIATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_MODE_IMMEDIATE_name); + zend_string_release_ex(const_TRANSACTION_MODE_IMMEDIATE_name, true); zval const_TRANSACTION_MODE_EXCLUSIVE_value; ZVAL_LONG(&const_TRANSACTION_MODE_EXCLUSIVE_value, 2); - zend_string *const_TRANSACTION_MODE_EXCLUSIVE_name = zend_string_init_interned("TRANSACTION_MODE_EXCLUSIVE", sizeof("TRANSACTION_MODE_EXCLUSIVE") - 1, 1); + zend_string *const_TRANSACTION_MODE_EXCLUSIVE_name = zend_string_init_interned("TRANSACTION_MODE_EXCLUSIVE", sizeof("TRANSACTION_MODE_EXCLUSIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_TRANSACTION_MODE_EXCLUSIVE_name, &const_TRANSACTION_MODE_EXCLUSIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_MODE_EXCLUSIVE_name); + zend_string_release_ex(const_TRANSACTION_MODE_EXCLUSIVE_name, true); #if SQLITE_VERSION_NUMBER >= 3043000 zval const_EXPLAIN_MODE_PREPARED_value; ZVAL_LONG(&const_EXPLAIN_MODE_PREPARED_value, 0); - zend_string *const_EXPLAIN_MODE_PREPARED_name = zend_string_init_interned("EXPLAIN_MODE_PREPARED", sizeof("EXPLAIN_MODE_PREPARED") - 1, 1); + zend_string *const_EXPLAIN_MODE_PREPARED_name = zend_string_init_interned("EXPLAIN_MODE_PREPARED", sizeof("EXPLAIN_MODE_PREPARED") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_PREPARED_name, &const_EXPLAIN_MODE_PREPARED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXPLAIN_MODE_PREPARED_name); + zend_string_release_ex(const_EXPLAIN_MODE_PREPARED_name, true); zval const_EXPLAIN_MODE_EXPLAIN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_value, 1); - zend_string *const_EXPLAIN_MODE_EXPLAIN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN", sizeof("EXPLAIN_MODE_EXPLAIN") - 1, 1); + zend_string *const_EXPLAIN_MODE_EXPLAIN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN", sizeof("EXPLAIN_MODE_EXPLAIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_name, &const_EXPLAIN_MODE_EXPLAIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXPLAIN_MODE_EXPLAIN_name); + zend_string_release_ex(const_EXPLAIN_MODE_EXPLAIN_name, true); zval const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, 2); - zend_string *const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN", sizeof("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN") - 1, 1); + zend_string *const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN", sizeof("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name, &const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name); + zend_string_release_ex(const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name, true); #endif zval const_OK_value; ZVAL_LONG(&const_OK_value, SQLITE_OK); - zend_string *const_OK_name = zend_string_init_interned("OK", sizeof("OK") - 1, 1); + zend_string *const_OK_name = zend_string_init_interned("OK", sizeof("OK") - 1, true); zend_declare_typed_class_constant(class_entry, const_OK_name, &const_OK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OK_name); + zend_string_release_ex(const_OK_name, true); zval const_DENY_value; ZVAL_LONG(&const_DENY_value, SQLITE_DENY); - zend_string *const_DENY_name = zend_string_init_interned("DENY", sizeof("DENY") - 1, 1); + zend_string *const_DENY_name = zend_string_init_interned("DENY", sizeof("DENY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DENY_name, &const_DENY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DENY_name); + zend_string_release_ex(const_DENY_name, true); zval const_IGNORE_value; ZVAL_LONG(&const_IGNORE_value, SQLITE_IGNORE); - zend_string *const_IGNORE_name = zend_string_init_interned("IGNORE", sizeof("IGNORE") - 1, 1); + zend_string *const_IGNORE_name = zend_string_init_interned("IGNORE", sizeof("IGNORE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IGNORE_name, &const_IGNORE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IGNORE_name); + zend_string_release_ex(const_IGNORE_name, true); return class_entry; } diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c index e9e7a0cc78609..ffb8c1ad4b3c8 100644 --- a/ext/pdo_sqlite/sqlite_statement.c +++ b/ext/pdo_sqlite/sqlite_statement.c @@ -335,7 +335,6 @@ static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *ret case SQLITE_BLOB: add_next_index_string(&flags, "blob"); - /* TODO Check this is correct */ ZEND_FALLTHROUGH; case SQLITE_TEXT: add_assoc_str(return_value, "native_type", ZSTR_KNOWN(ZEND_STR_STRING)); diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index f92a5e7c416dd..e3d8cb82ece91 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1223,26 +1223,55 @@ PHP_FUNCTION(pg_query) } } -static void _php_pgsql_free_params(char **params, int num_params) +/* The char pointer MUST refer to the char* of a zend_string struct */ +static void php_pgsql_zend_string_release_from_char_pointer(char *ptr) { + zend_string_release((zend_string*) (ptr - XtOffsetOf(zend_string, val))); +} + +static void _php_pgsql_free_params(char **params, uint32_t num_params) { - int i; - for (i = 0; i < num_params; i++) { + for (uint32_t i = 0; i < num_params; i++) { if (params[i]) { - efree(params[i]); + php_pgsql_zend_string_release_from_char_pointer(params[i]); } } efree(params); } +static char **php_pgsql_make_arguments(const HashTable *param_arr, int *num_params) +{ + /* This conversion is safe because of the limit of number of elements in a table. */ + *num_params = (int) zend_hash_num_elements(param_arr); + char **params = safe_emalloc(sizeof(char *), *num_params, 0); + uint32_t i = 0; + + ZEND_HASH_FOREACH_VAL(param_arr, zval *tmp) { + ZVAL_DEREF(tmp); + if (Z_TYPE_P(tmp) == IS_NULL) { + params[i] = NULL; + } else { + zend_string *param_str = zval_try_get_string(tmp); + if (!param_str) { + _php_pgsql_free_params(params, i); + return NULL; + } + params[i] = ZSTR_VAL(param_str); + } + i++; + } ZEND_HASH_FOREACH_END(); + + return params; +} + /* Execute a query */ PHP_FUNCTION(pg_query_params) { zval *pgsql_link = NULL; - zval *pv_param_arr, *tmp; + zval *pv_param_arr; char *query; size_t query_len; bool leftover = false; - int num_params = 0; + int num_params; char **params = NULL; pgsql_link_handle *link; PGconn *pgsql; @@ -1286,26 +1315,9 @@ PHP_FUNCTION(pg_query_params) php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first"); } - num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr)); - if (num_params > 0) { - int i = 0; - params = (char **)safe_emalloc(sizeof(char *), num_params, 0); - - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) { - ZVAL_DEREF(tmp); - if (Z_TYPE_P(tmp) == IS_NULL) { - params[i] = NULL; - } else { - zend_string *param_str = zval_try_get_string(tmp); - if (!param_str) { - _php_pgsql_free_params(params, i); - RETURN_THROWS(); - } - params[i] = estrndup(ZSTR_VAL(param_str), ZSTR_LEN(param_str)); - zend_string_release(param_str); - } - i++; - } ZEND_HASH_FOREACH_END(); + params = php_pgsql_make_arguments(Z_ARRVAL_P(pv_param_arr), &num_params); + if (UNEXPECTED(!params)) { + RETURN_THROWS(); } pgsql_result = PQexecParams(pgsql, query, num_params, @@ -1440,11 +1452,11 @@ PHP_FUNCTION(pg_prepare) PHP_FUNCTION(pg_execute) { zval *pgsql_link = NULL; - zval *pv_param_arr, *tmp; + zval *pv_param_arr; char *stmtname; size_t stmtname_len; bool leftover = false; - int num_params = 0; + int num_params; char **params = NULL; PGconn *pgsql; pgsql_link_handle *link; @@ -1488,25 +1500,9 @@ PHP_FUNCTION(pg_execute) php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first"); } - num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr)); - if (num_params > 0) { - int i = 0; - params = (char **)safe_emalloc(sizeof(char *), num_params, 0); - - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) { - ZVAL_DEREF(tmp); - if (Z_TYPE_P(tmp) == IS_NULL) { - params[i] = NULL; - } else { - zend_string *tmp_str; - zend_string *str = zval_get_tmp_string(tmp, &tmp_str); - - params[i] = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); - zend_tmp_string_release(tmp_str); - } - - i++; - } ZEND_HASH_FOREACH_END(); + params = php_pgsql_make_arguments(Z_ARRVAL_P(pv_param_arr), &num_params); + if (UNEXPECTED(!params)) { + RETURN_THROWS(); } pgsql_result = PQexecPrepared(pgsql, stmtname, num_params, @@ -1981,60 +1977,37 @@ PHP_FUNCTION(pg_fetch_result) } /* }}} */ -/* {{{ void php_pgsql_fetch_hash */ -static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_type, int into_object) +/* Returns true when the return_value was populated with an array, + * otherwise when an error occurs false is returned, in which case the return_value is NOT initialized */ +static bool php_pgsql_fetch_hash(zval *return_value, const zval *result, zend_long row, bool row_is_null, zend_long result_type) { - zval *result; PGresult *pgsql_result; pgsql_result_handle *pg_result; int i, num_fields, pgsql_row; - zend_long row; - bool row_is_null = true; char *field_name; - HashTable *ctor_params = NULL; - zend_class_entry *ce = NULL; - - if (into_object) { - 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 { - 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) { zend_argument_value_error(2, "must be greater than or equal to 0"); - RETURN_THROWS(); + return false; } if (!(result_type & PGSQL_BOTH)) { zend_argument_value_error(3, "must be one of PGSQL_ASSOC, PGSQL_NUM, or PGSQL_BOTH"); - RETURN_THROWS(); + return false; } pg_result = Z_PGSQL_RESULT_P(result); - CHECK_PGSQL_RESULT(pg_result); + if (UNEXPECTED(pg_result->result == NULL)) { + zend_throw_error(NULL, "PostgreSQL result has already been closed"); + return false; + } pgsql_result = pg_result->result; if (!row_is_null) { if (row >= PQntuples(pgsql_result)) { php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on PostgreSQL result index " ZEND_LONG_FMT, row, Z_LVAL_P(result)); - RETURN_FALSE; + return false; } pgsql_row = (int)row; pg_result->row = pgsql_row; @@ -2042,7 +2015,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ /* If 2nd param is NULL, use internal row counter to access next row */ pgsql_row = pg_result->row; if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) { - RETURN_FALSE; + return false; } pg_result->row++; } @@ -2058,7 +2031,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ add_assoc_null(return_value, field_name); } } else { - char *element = PQgetvalue(pgsql_result, pgsql_row, i); + const char *element = PQgetvalue(pgsql_result, pgsql_row, i); if (element) { const size_t element_len = strlen(element); @@ -2073,67 +2046,126 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, zend_long result_ } } } - - if (into_object) { - zval dataset; - - ZVAL_COPY_VALUE(&dataset, return_value); - zend_result obj_initialized = object_init_ex(return_value, ce); - if (UNEXPECTED(obj_initialized == FAILURE)) { - zval_ptr_dtor(&dataset); - RETURN_THROWS(); - } - if (!ce->default_properties_count && !ce->__set) { - Z_OBJ_P(return_value)->properties = Z_ARR(dataset); - } else { - zend_merge_properties(return_value, Z_ARRVAL(dataset)); - zval_ptr_dtor(&dataset); - } - - if (ce->constructor) { - zend_call_known_function(ce->constructor, Z_OBJ_P(return_value), Z_OBJCE_P(return_value), - /* retval */ NULL, /* argc */ 0, /* params */ NULL, ctor_params); - } else if (ctor_params && zend_hash_num_elements(ctor_params) > 0) { - zend_argument_value_error(3, - "must be empty when the specified class (%s) does not have a constructor", - ZSTR_VAL(ce->name) - ); - } - } + return true; } -/* }}} */ /* {{{ Get a row as an enumerated array */ PHP_FUNCTION(pg_fetch_row) { - php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_NUM, 0); + zval *result; + zend_long row = 0; + bool row_is_null = true; + zend_long result_type = PGSQL_NUM; + + 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 (UNEXPECTED(!php_pgsql_fetch_hash(return_value, result, row, row_is_null, result_type))) { + /* Either an exception is thrown, or we return false */ + RETURN_FALSE; + } } /* }}} */ /* {{{ Fetch a row as an assoc array */ PHP_FUNCTION(pg_fetch_assoc) { - /* pg_fetch_assoc() is added from PHP 4.3.0. It should raise error, when - there is 3rd parameter */ - if (ZEND_NUM_ARGS() > 2) - WRONG_PARAM_COUNT; - php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_ASSOC, 0); + zval *result; + zend_long row = 0; + bool row_is_null = true; + + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(result, pgsql_result_ce) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(row, row_is_null) + ZEND_PARSE_PARAMETERS_END(); + + if (UNEXPECTED(!php_pgsql_fetch_hash(return_value, result, row, row_is_null, PGSQL_ASSOC))) { + /* Either an exception is thrown, or we return false */ + RETURN_FALSE; + } } /* }}} */ /* {{{ Fetch a row as an array */ PHP_FUNCTION(pg_fetch_array) { - php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_BOTH, 0); + zval *result; + zend_long row = 0; + bool row_is_null = true; + zend_long result_type = PGSQL_BOTH; + + 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 (UNEXPECTED(!php_pgsql_fetch_hash(return_value, result, row, row_is_null, result_type))) { + /* Either an exception is thrown, or we return false */ + RETURN_FALSE; + } } /* }}} */ /* {{{ Fetch a row as an object */ PHP_FUNCTION(pg_fetch_object) { - /* pg_fetch_object() allowed result_type used to be. 3rd parameter - must be allowed for compatibility */ - php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_ASSOC, 1); + zval *result; + zend_long row = 0; + bool row_is_null = true; + zend_class_entry *ce = NULL; + HashTable *ctor_params = NULL; + + 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; + } + + if (!ce->constructor && ctor_params && zend_hash_num_elements(ctor_params) > 0) { + zend_argument_value_error(3, + "must be empty when the specified class (%s) does not have a constructor", + ZSTR_VAL(ce->name) + ); + RETURN_THROWS(); + } + + zval dataset; + if (UNEXPECTED(!php_pgsql_fetch_hash(&dataset, result, row, row_is_null, PGSQL_ASSOC))) { + /* Either an exception is thrown, or we return false */ + RETURN_FALSE; + } + + // TODO: Check CE is an instantiable class earlier? + zend_result obj_initialized = object_init_ex(return_value, ce); + if (UNEXPECTED(obj_initialized == FAILURE)) { + zval_ptr_dtor(&dataset); + RETURN_THROWS(); + } + if (!ce->default_properties_count && !ce->__set) { + Z_OBJ_P(return_value)->properties = Z_ARR(dataset); + } else { + zend_merge_properties(return_value, Z_ARRVAL(dataset)); + zval_ptr_dtor(&dataset); + } + + // TODO: Need to grab constructor via object handler as this allows instantiating internal objects with overridden get_constructor + if (ce->constructor) { + zend_call_known_function(ce->constructor, Z_OBJ_P(return_value), Z_OBJCE_P(return_value), + /* retval */ NULL, /* argc */ 0, /* params */ NULL, ctor_params); + } } /* }}} */ @@ -2867,19 +2899,18 @@ PHP_FUNCTION(pg_lo_import) Oid returned_oid; pgsql_link_handle *link; - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), - "OP|z", &pgsql_link, pgsql_link_ce, &file_in, &oid) == SUCCESS) { + /* Deprecated signature with implicit connection */ + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "P|z", &file_in, &oid) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|z", &pgsql_link, pgsql_link_ce, &file_in, &oid) == FAILURE) { + RETURN_THROWS(); + } link = Z_PGSQL_LINK_P(pgsql_link); CHECK_PGSQL_LINK(link); - } - else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), - "P|z", &file_in, &oid) == SUCCESS) { + } else { + /* Load implicit connection */ link = FETCH_DEFAULT_LINK(); CHECK_DEFAULT_LINK(link); } - else { - WRONG_PARAM_COUNT; - } if (php_check_open_basedir(ZSTR_VAL(file_in))) { RETURN_FALSE; @@ -3319,9 +3350,8 @@ PHP_FUNCTION(pg_copy_to) pgsql_link_handle *link; zend_string *table_name; zend_string *pg_delimiter = NULL; - char *pg_null_as = NULL; + char *pg_null_as = "\\\\N"; size_t pg_null_as_len = 0; - bool free_pg_null = false; char *query; PGconn *pgsql; PGresult *pgsql_result; @@ -3346,10 +3376,6 @@ PHP_FUNCTION(pg_copy_to) zend_argument_value_error(3, "must be one character"); RETURN_THROWS(); } - if (!pg_null_as) { - pg_null_as = estrdup("\\\\N"); - free_pg_null = true; - } spprintf(&query, 0, "COPY %s TO STDOUT DELIMITER E'%c' NULL AS E'%s'", ZSTR_VAL(table_name), *ZSTR_VAL(pg_delimiter), pg_null_as); @@ -3357,9 +3383,6 @@ PHP_FUNCTION(pg_copy_to) PQclear(pgsql_result); } pgsql_result = PQexec(pgsql, query); - if (free_pg_null) { - efree(pg_null_as); - } efree(query); if (pgsql_result) { @@ -3413,26 +3436,27 @@ PHP_FUNCTION(pg_copy_to) static zend_result pgsql_copy_from_query(PGconn *pgsql, PGresult *pgsql_result, zval *value) { - zend_string *tmp = zval_try_get_string(value); + zend_string *tmp_tmp; + zend_string *tmp = zval_try_get_tmp_string(value, &tmp_tmp); if (UNEXPECTED(!tmp)) { return FAILURE; } - zend_string *zquery = zend_string_alloc(ZSTR_LEN(tmp) + 2, 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) - 1] != '\n') { - ZSTR_VAL(zquery)[ZSTR_LEN(tmp)] = '\n'; - ZSTR_VAL(zquery)[ZSTR_LEN(tmp) + 1] = '\0'; - ZSTR_LEN(zquery) ++; - } - if (PQputCopyData(pgsql, ZSTR_VAL(zquery), ZSTR_LEN(zquery)) != 1) { - zend_string_release_ex(zquery, false); - zend_string_release(tmp); - return FAILURE; + + int result; + if (ZSTR_LEN(tmp) > 0 && ZSTR_VAL(tmp)[ZSTR_LEN(tmp) - 1] != '\n') { + char *zquery = emalloc(ZSTR_LEN(tmp) + 2); + memcpy(zquery, ZSTR_VAL(tmp), ZSTR_LEN(tmp) + 1); + zquery[ZSTR_LEN(tmp)] = '\n'; + zquery[ZSTR_LEN(tmp) + 1] = '\0'; + result = PQputCopyData(pgsql, zquery, ZSTR_LEN(tmp) + 1); + efree(zquery); + } else { + result = PQputCopyData(pgsql, ZSTR_VAL(tmp), ZSTR_LEN(tmp)); } - zend_string_release_ex(zquery, false); - zend_string_release(tmp); - return SUCCESS; + + zend_tmp_string_release(tmp_tmp); + + return result != 1 ? FAILURE : SUCCESS; } /* {{{ Copy table from array */ @@ -3443,9 +3467,8 @@ PHP_FUNCTION(pg_copy_from) zval *value; zend_string *table_name; zend_string *pg_delimiter = NULL; - char *pg_null_as = NULL; + char *pg_null_as = "\\\\N"; size_t pg_null_as_len; - bool pg_null_as_free = false; char *query; PGconn *pgsql; PGresult *pgsql_result; @@ -3470,10 +3493,6 @@ PHP_FUNCTION(pg_copy_from) zend_argument_value_error(4, "must be one character"); RETURN_THROWS(); } - if (!pg_null_as) { - pg_null_as = estrdup("\\\\N"); - pg_null_as_free = true; - } spprintf(&query, 0, "COPY %s FROM STDIN DELIMITER E'%c' NULL AS E'%s'", ZSTR_VAL(table_name), *ZSTR_VAL(pg_delimiter), pg_null_as); while ((pgsql_result = PQgetResult(pgsql))) { @@ -3481,9 +3500,6 @@ PHP_FUNCTION(pg_copy_from) } pgsql_result = PQexec(pgsql, query); - if (pg_null_as_free) { - efree(pg_null_as); - } efree(query); if (pgsql_result) { @@ -4037,9 +4053,9 @@ PHP_FUNCTION(pg_send_query) /* {{{ Send asynchronous parameterized query */ PHP_FUNCTION(pg_send_query_params) { - zval *pgsql_link, *pv_param_arr, *tmp; + zval *pgsql_link, *pv_param_arr; pgsql_link_handle *link; - int num_params = 0; + int num_params; char **params = NULL; char *query; size_t query_len; @@ -4069,25 +4085,9 @@ PHP_FUNCTION(pg_send_query_params) "There are results on this connection. Call pg_get_result() until it returns FALSE"); } - num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr)); - if (num_params > 0) { - int i = 0; - params = (char **)safe_emalloc(sizeof(char *), num_params, 0); - - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) { - ZVAL_DEREF(tmp); - if (Z_TYPE_P(tmp) == IS_NULL) { - params[i] = NULL; - } else { - zend_string *tmp_str; - zend_string *str = zval_get_tmp_string(tmp, &tmp_str); - - params[i] = estrndup(ZSTR_VAL(str), ZSTR_LEN(str)); - zend_tmp_string_release(tmp_str); - } - - i++; - } ZEND_HASH_FOREACH_END(); + params = php_pgsql_make_arguments(Z_ARRVAL_P(pv_param_arr), &num_params); + if (UNEXPECTED(!params)) { + RETURN_THROWS(); } if (PQsendQueryParams(pgsql, query, num_params, NULL, (const char * const *)params, NULL, NULL, 0)) { @@ -4209,8 +4209,8 @@ PHP_FUNCTION(pg_send_execute) { zval *pgsql_link; pgsql_link_handle *link; - zval *pv_param_arr, *tmp; - int num_params = 0; + zval *pv_param_arr; + int num_params; char **params = NULL; char *stmtname; size_t stmtname_len; @@ -4240,27 +4240,9 @@ PHP_FUNCTION(pg_send_execute) "There are results on this connection. Call pg_get_result() until it returns FALSE"); } - num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr)); - if (num_params > 0) { - int i = 0; - params = (char **)safe_emalloc(sizeof(char *), num_params, 0); - - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) { - ZVAL_DEREF(tmp); - if (Z_TYPE_P(tmp) == IS_NULL) { - params[i] = NULL; - } else { - zend_string *tmp_str = zval_try_get_string(tmp); - if (UNEXPECTED(!tmp_str)) { - _php_pgsql_free_params(params, i); - return; - } - params[i] = estrndup(ZSTR_VAL(tmp_str), ZSTR_LEN(tmp_str)); - zend_string_release(tmp_str); - } - - i++; - } ZEND_HASH_FOREACH_END(); + params = php_pgsql_make_arguments(Z_ARRVAL_P(pv_param_arr), &num_params); + if (UNEXPECTED(!params)) { + RETURN_THROWS(); } if (PQsendQueryPrepared(pgsql, stmtname, num_params, (const char * const *)params, NULL, NULL, 0)) { @@ -4924,7 +4906,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string * array_init(&meta); /* table_name is escaped by php_pgsql_meta_data */ - if (php_pgsql_meta_data(pg_link, table_name, &meta, 0) == FAILURE) { + if (php_pgsql_meta_data(pg_link, table_name, &meta, false) == FAILURE) { zval_ptr_dtor(&meta); return FAILURE; } @@ -4969,7 +4951,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string * break; /* break out for() */ } - if (zval_is_true(is_enum)) { + if (zend_is_true(is_enum)) { /* enums need to be treated like strings */ data_type = PG_TEXT; } else { diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index c5aa292200e86..f37599e7db117 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -188,8 +188,6 @@ static php_stream *phar_make_dirstream(const char *dir, size_t dirlen, const Has entry = safe_emalloc(keylen, 1, 1); memcpy(entry, ZSTR_VAL(str_key), keylen); entry[keylen] = '\0'; - - goto PHAR_ADD_ENTRY; } else { if (0 != memcmp(ZSTR_VAL(str_key), dir, dirlen)) { /* entry in directory not found */ @@ -199,28 +197,28 @@ static php_stream *phar_make_dirstream(const char *dir, size_t dirlen, const Has continue; } } - } - const char *save = ZSTR_VAL(str_key); - save += dirlen + 1; /* seek to just past the path separator */ + const char *save = ZSTR_VAL(str_key); + save += dirlen + 1; /* seek to just past the path separator */ - const char *has_slash = memchr(save, '/', keylen - dirlen - 1); - if (has_slash) { - /* is subdirectory */ - save -= dirlen + 1; - entry = safe_emalloc(has_slash - save + dirlen, 1, 1); - memcpy(entry, save + dirlen + 1, has_slash - save - dirlen - 1); - keylen = has_slash - save - dirlen - 1; - entry[keylen] = '\0'; - } else { - /* is file */ - save -= dirlen + 1; - entry = safe_emalloc(keylen - dirlen, 1, 1); - memcpy(entry, save + dirlen + 1, keylen - dirlen - 1); - entry[keylen - dirlen - 1] = '\0'; - keylen = keylen - dirlen - 1; + const char *has_slash = memchr(save, '/', keylen - dirlen - 1); + if (has_slash) { + /* is subdirectory */ + save -= dirlen + 1; + entry = safe_emalloc(has_slash - save + dirlen, 1, 1); + memcpy(entry, save + dirlen + 1, has_slash - save - dirlen - 1); + keylen = has_slash - save - dirlen - 1; + entry[keylen] = '\0'; + } else { + /* is file */ + save -= dirlen + 1; + entry = safe_emalloc(keylen - dirlen, 1, 1); + memcpy(entry, save + dirlen + 1, keylen - dirlen - 1); + entry[keylen - dirlen - 1] = '\0'; + keylen = keylen - dirlen - 1; + } } -PHAR_ADD_ENTRY: + if (keylen) { /** * Add an empty element to avoid duplicates @@ -349,12 +347,12 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo { phar_entry_info entry, *e; phar_archive_data *phar = NULL; - char *error, *arch, *entry2; - size_t arch_len, entry_len; + char *error, *arch; + size_t arch_len; php_url *resource = NULL; /* pre-readonly check, we need to know if this is a data phar */ - if (FAILURE == phar_split_fname(url_from, strlen(url_from), &arch, &arch_len, &entry2, &entry_len, 2, 2)) { + if (FAILURE == phar_split_fname(url_from, strlen(url_from), &arch, &arch_len, NULL, NULL, 2, 2)) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\", no phar archive specified", url_from); return 0; } @@ -364,7 +362,6 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo } efree(arch); - efree(entry2); if (PHAR_G(readonly) && (!phar || !phar->is_data)) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\", write operations disabled", url_from); @@ -395,7 +392,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo return 0; } - if ((e = phar_get_entry_info_dir(phar, ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1, 2, &error, 1))) { + if ((e = phar_get_entry_info_dir(phar, ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1, 2, &error, true))) { /* directory exists, or is a subdirectory of an existing file */ if (e->is_temp_dir) { zend_string_efree(e->filename); @@ -413,7 +410,7 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo return 0; } - if (phar_get_entry_info_dir(phar, ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1, 0, &error, 1)) { + if (phar_get_entry_info_dir(phar, ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1, 0, &error, true)) { /* entry exists as a file */ php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", file already exists", ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host)); php_url_free(resource); @@ -451,7 +448,6 @@ int phar_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url_from, int mo if (NULL == zend_hash_add_mem(&phar->manifest, entry.filename, &entry, sizeof(phar_entry_info))) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot create directory \"%s\" in phar \"%s\", adding to manifest failed", ZSTR_VAL(entry.filename), phar->fname); - efree(error); zend_string_efree(entry.filename); return 0; } @@ -477,12 +473,12 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options { phar_entry_info *entry; phar_archive_data *phar = NULL; - char *error, *arch, *entry2; - size_t arch_len, entry_len; + char *error, *arch; + size_t arch_len; php_url *resource = NULL; /* pre-readonly check, we need to know if this is a data phar */ - if (FAILURE == phar_split_fname(url, strlen(url), &arch, &arch_len, &entry2, &entry_len, 2, 2)) { + if (FAILURE == phar_split_fname(url, strlen(url), &arch, &arch_len, NULL, NULL, 2, 2)) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\", no phar archive specified, or phar archive does not exist", url); return 0; } @@ -492,7 +488,6 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options } efree(arch); - efree(entry2); if (PHAR_G(readonly) && (!phar || !phar->is_data)) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot rmdir directory \"%s\", write operations disabled", url); @@ -525,7 +520,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, int options size_t path_len = ZSTR_LEN(resource->path) - 1; - if (!(entry = phar_get_entry_info_dir(phar, ZSTR_VAL(resource->path) + 1, path_len, 2, &error, 1))) { + if (!(entry = phar_get_entry_info_dir(phar, ZSTR_VAL(resource->path) + 1, path_len, 2, &error, true))) { if (error) { php_stream_wrapper_log_error(wrapper, options, "phar error: cannot remove directory \"%s\" in phar \"%s\", %s", ZSTR_VAL(resource->path)+1, ZSTR_VAL(resource->host), error); efree(error); diff --git a/ext/phar/func_interceptors.c b/ext/phar/func_interceptors.c index f1b2b0eba1e63..f7e553a45ce80 100644 --- a/ext/phar/func_interceptors.c +++ b/ext/phar/func_interceptors.c @@ -50,12 +50,11 @@ PHP_FUNCTION(phar_opendir) /* {{{ */ goto skip_phar; } - if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) { + if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) { php_stream_context *context = NULL; php_stream *stream; char *name; - efree(entry); entry = estrndup(filename, filename_len); /* fopen within phar, if :// is not in the url, then prepend phar:/// */ entry_len = filename_len; @@ -89,8 +88,8 @@ PHP_FUNCTION(phar_opendir) /* {{{ */ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool using_include_path) { - char *arch, *entry; - size_t arch_len, entry_len; + char *arch; + size_t arch_len; zend_string *fname = zend_get_executed_filename_ex(); /* we are checking for existence of a file within the relative path. Chances are good that this is @@ -99,13 +98,10 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool return NULL; } - if (FAILURE == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) { + if (FAILURE == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) { return NULL; } - efree(entry); - entry = NULL; - entry_len = 0; /* fopen within phar, if :// is not in the url, then prepend phar:/// */ /* retrieving a file defaults to within the current directory, so use this if possible */ phar_archive_data *phar; @@ -122,8 +118,8 @@ static zend_string* phar_get_name_for_relative_paths(zend_string *filename, bool return NULL; } } else { - entry_len = ZSTR_LEN(filename); - entry = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &entry_len, 1); + size_t entry_len = ZSTR_LEN(filename); + char *entry = phar_fix_filepath(estrndup(ZSTR_VAL(filename), ZSTR_LEN(filename)), &entry_len, 1); if (entry[0] == '/') { if (!zend_hash_str_exists(&(phar->manifest), entry + 1, entry_len - 1)) { /* this file is not in the phar, use the original path */ @@ -159,10 +155,10 @@ PHP_FUNCTION(phar_file_get_contents) /* {{{ */ { zend_string *filename; zend_string *contents; - bool use_include_path = 0; + bool use_include_path = false; zend_long offset = -1; zend_long maxlen; - bool maxlen_is_null = 1; + bool maxlen_is_null = true; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { @@ -235,7 +231,7 @@ PHP_FUNCTION(phar_file_get_contents) /* {{{ */ PHP_FUNCTION(phar_readfile) /* {{{ */ { zend_string *filename; - bool use_include_path = 0; + bool use_include_path = false; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { @@ -281,7 +277,7 @@ PHP_FUNCTION(phar_fopen) /* {{{ */ zend_string *filename; char *mode; size_t mode_len; - bool use_include_path = 0; + bool use_include_path = false; zval *zcontext = NULL; if (!PHAR_G(intercepted)) { @@ -509,9 +505,7 @@ static void phar_file_stat(const char *filename, size_t filename_length, int typ phar = PHAR_G(last_phar); goto splitted; } - if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) { - - efree(entry); + if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) { entry = estrndup(filename, filename_length); /* fopen within phar, if :// is not in the url, then prepend phar:/// */ entry_len = filename_length; @@ -751,10 +745,9 @@ PHP_FUNCTION(phar_is_file) /* {{{ */ goto skip_phar; } - if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) { + if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) { phar_archive_data *phar; - efree(entry); entry = filename; /* fopen within phar, if :// is not in the url, then prepend phar:/// */ entry_len = filename_len; @@ -817,10 +810,9 @@ PHP_FUNCTION(phar_is_link) /* {{{ */ goto skip_phar; } - if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0)) { + if (SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0)) { phar_archive_data *phar; - efree(entry); entry = filename; /* fopen within phar, if :// is not in the url, then prepend phar:/// */ entry_len = filename_len; diff --git a/ext/phar/makestub.php b/ext/phar/makestub.php old mode 100644 new mode 100755 index 5808f4c38c9a0..34d270751bfb0 --- a/ext/phar/makestub.php +++ b/ext/phar/makestub.php @@ -1,3 +1,4 @@ +#!/usr/bin/env php $unused) { $stub .= ', newstub1_' . $i; diff --git a/ext/phar/phar.c b/ext/phar/phar.c index fb6b84dd8079e..385e9afeda14d 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -246,7 +246,7 @@ void phar_destroy_phar_data(phar_archive_data *phar) /* {{{ */ bool phar_archive_delref(phar_archive_data *phar) /* {{{ */ { if (phar->is_persistent) { - return 0; + return false; } if (--phar->refcount < 0) { @@ -254,33 +254,39 @@ bool phar_archive_delref(phar_archive_data *phar) /* {{{ */ || zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) { phar_destroy_phar_data(phar); } - return 1; + return true; } else if (!phar->refcount) { /* invalidate phar cache */ PHAR_G(last_phar) = NULL; PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL; + /* This is a new phar that has perhaps had an alias/metadata set, but has never been flushed. */ + bool remove_fname_cache = !zend_hash_num_elements(&phar->manifest); + if (phar->fp && (!(phar->flags & PHAR_FILE_COMPRESSION_MASK) || !phar->alias)) { /* close open file handle - allows removal or rename of the file on windows, which has greedy locking - only close if the archive was not already compressed. If it - was compressed, then the fp does not refer to the original file. - We're also closing compressed files to save resources, - but only if the archive isn't aliased. */ + only close if the archive was not already compressed. + We're also closing compressed files to save resources, but only if the archive isn't aliased. + If it was compressed, then the fp does not refer to the original compressed file: + it refers to the **uncompressed** filtered file stream. + Therefore, upon closing a compressed file we need to invalidate the phar archive such + that the code that reopens the phar will not try to use the **compressed** file as if it was uncompressed. + That would result in treating compressed file data as if it were compressed and using uncompressed file offsets + on the compressed file. */ php_stream_close(phar->fp); phar->fp = NULL; + remove_fname_cache |= phar->flags & PHAR_FILE_COMPRESSION_MASK; } - if (!zend_hash_num_elements(&phar->manifest)) { - /* this is a new phar that has perhaps had an alias/metadata set, but has never - been flushed */ + if (remove_fname_cache) { if (zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) { phar_destroy_phar_data(phar); } - return 1; + return true; } } - return 0; + return false; } /* }}}*/ @@ -414,13 +420,13 @@ void phar_entry_delref(phar_entry_data *idata) /* {{{ */ /** * Removes an entry, either by actually removing it or by marking it. */ -void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */ { phar_archive_data *phar; phar = idata->phar; - if (idata->internal_file->fp_refcount < 2) { + if (idata->internal_file->fp_refcount < 2 && idata->internal_file->fileinfo_lock_count == 0) { if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) { php_stream_close(idata->fp); } @@ -464,17 +470,10 @@ void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */ | ((uint32_t)(((unsigned char*)(buffer))[1]) << 8) \ | ((uint32_t)((unsigned char*)(buffer))[0]); \ (buffer) += 4 -# define PHAR_GET_16(buffer, var) \ - var = ((uint16_t)(((unsigned char*)(buffer))[1]) << 8) \ - | ((uint16_t)((unsigned char*)(buffer))[0]); \ - (buffer) += 2 #else # define PHAR_GET_32(buffer, var) \ memcpy(&var, buffer, sizeof(var)); \ buffer += 4 -# define PHAR_GET_16(buffer, var) \ - var = *(uint16_t*)(buffer); \ - buffer += 2 #endif #define PHAR_ZIP_16(var) ((uint16_t)((((uint16_t)var[0]) & 0xff) | \ (((uint16_t)var[1]) & 0xff) << 8)) @@ -510,7 +509,6 @@ static zend_result phar_open_parsed_phar(char *fname, size_t fname_len, char *al && ((alias && fname_len == phar->fname_len && !strncmp(fname, phar->fname, fname_len)) || !alias) ) { - phar_entry_info *stub; #ifdef PHP_WIN32 if (fname != save_fname) { free_alloca(fname, fname_use_heap); @@ -526,7 +524,7 @@ static zend_result phar_open_parsed_phar(char *fname, size_t fname_len, char *al if (!is_data) { /* prevent any ".phar" without a stub getting through */ if (!phar->halt_offset && !phar->is_brandnew && (phar->is_tar || phar->is_zip)) { - if (PHAR_G(readonly) && NULL == (stub = zend_hash_str_find_ptr(&(phar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) { + if (PHAR_G(readonly) && !zend_hash_str_exists(&(phar->manifest), ZEND_STRL(".phar/stub.php"))) { if (error) { spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname); } @@ -595,13 +593,9 @@ zend_result phar_metadata_tracker_unserialize_or_copy(phar_metadata_tracker *tra const bool has_unserialize_options = unserialize_options != NULL && zend_hash_num_elements(unserialize_options) > 0; /* It should be impossible to create a zval in a persistent phar/entry. */ ZEND_ASSERT(!persistent || Z_ISUNDEF(tracker->val)); + ZEND_ASSERT(!EG(exception)); if (Z_ISUNDEF(tracker->val) || has_unserialize_options) { - if (EG(exception)) { - /* Because other parts of the phar code haven't been updated to check for exceptions after doing something that may throw, - * check for exceptions before potentially serializing/unserializing instead. */ - return FAILURE; - } /* Persistent phars should always be unserialized. */ const char *start; /* Assert it should not be possible to create raw data in a persistent phar (i.e. from cache_list) */ @@ -740,7 +734,7 @@ static zend_result phar_parse_pharfile(php_stream *fp, char *fname, size_t fname uint32_t len; zend_long offset; size_t sig_len; - int register_alias = 0, temp_alias = 0; + bool register_alias = false, temp_alias = false; char *signature = NULL; zend_string *str; @@ -1073,15 +1067,15 @@ static zend_result phar_parse_pharfile(php_stream *fp, char *fname, size_t fname alias_len = tmp_len; alias = buffer; buffer += tmp_len; - register_alias = 1; + register_alias = true; } else if (!alias_len || !alias) { /* if we neither have an explicit nor an implicit alias, we use the filename */ alias = NULL; alias_len = 0; - register_alias = 0; + register_alias = false; } else if (alias_len) { - register_alias = 1; - temp_alias = 1; + register_alias = true; + temp_alias = true; } /* we have 5 32-bit items plus 1 byte at least */ @@ -1113,11 +1107,11 @@ static zend_result phar_parse_pharfile(php_stream *fp, char *fname, size_t fname /* set up our manifest */ zend_hash_init(&mydata->manifest, manifest_count, - zend_get_hash_value, destroy_phar_manifest_entry, (bool)mydata->is_persistent); + zend_get_hash_value, destroy_phar_manifest_entry, mydata->is_persistent); zend_hash_init(&mydata->mounted_dirs, 5, - zend_get_hash_value, NULL, (bool)mydata->is_persistent); + zend_get_hash_value, NULL, mydata->is_persistent); zend_hash_init(&mydata->virtual_dirs, manifest_count * 2, - zend_get_hash_value, NULL, (bool)mydata->is_persistent); + zend_get_hash_value, NULL, mydata->is_persistent); mydata->fname = pestrndup(fname, fname_len, mydata->is_persistent); #ifdef PHP_WIN32 phar_unixify_path_separators(mydata->fname, fname_len); @@ -1161,15 +1155,9 @@ static zend_result phar_parse_pharfile(php_stream *fp, char *fname, size_t fname PHAR_GET_32(buffer, entry.uncompressed_filesize); PHAR_GET_32(buffer, entry.timestamp); - if (offset == halt_offset + manifest_len + 4) { - mydata->min_timestamp = entry.timestamp; + if (offset == halt_offset + manifest_len + 4 + || mydata->max_timestamp < entry.timestamp) { mydata->max_timestamp = entry.timestamp; - } else { - if (mydata->min_timestamp > entry.timestamp) { - mydata->min_timestamp = entry.timestamp; - } else if (mydata->max_timestamp < entry.timestamp) { - mydata->max_timestamp = entry.timestamp; - } } PHAR_GET_32(buffer, entry.compressed_filesize); @@ -1315,7 +1303,7 @@ static zend_result phar_parse_pharfile(php_stream *fp, char *fname, size_t fname /** * Create or open a phar for writing */ -zend_result 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) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result 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) /* {{{ */ { const char *ext_str, *z; char *my_error; @@ -1324,42 +1312,33 @@ zend_result phar_open_or_create_filename(char *fname, size_t fname_len, char *al test = &unused; - if (error) { - *error = NULL; - } + *error = NULL; /* first try to open an existing file */ - if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 0, 1) == SUCCESS) { + if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 0, true) == SUCCESS) { goto check_file; } /* next try to create a new file */ - if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 1, 1)) { - if (error) { - if (ext_len == -2) { - spprintf(error, 0, "Cannot create a phar archive from a URL like \"%s\". Phar objects can only be created from local files", fname); - } else { - spprintf(error, 0, "Cannot create phar '%s', file extension (or combination) not recognised or the directory does not exist", fname); - } + if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 1, true)) { + if (ext_len == -2) { + spprintf(error, 0, "Cannot create a phar archive from a URL like \"%s\". Phar objects can only be created from local files", fname); + } else { + spprintf(error, 0, "Cannot create phar '%s', file extension (or combination) not recognised or the directory does not exist", fname); } return FAILURE; } check_file: if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, test, &my_error) == SUCCESS) { - if (pphar) { - *pphar = *test; - } + *pphar = *test; if ((*test)->is_data && !(*test)->is_tar && !(*test)->is_zip) { - if (error) { - spprintf(error, 0, "Cannot open '%s' as a PharData object. Use Phar::__construct() for executable archives", fname); - } + spprintf(error, 0, "Cannot open '%s' as a PharData object. Use Phar::__construct() for executable archives", fname); return FAILURE; } if (PHAR_G(readonly) && !(*test)->is_data && ((*test)->is_tar || (*test)->is_zip)) { - phar_entry_info *stub; - if (NULL == (stub = zend_hash_str_find_ptr(&((*test)->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) { + if (!zend_hash_str_exists(&((*test)->manifest), ZEND_STRL(".phar/stub.php"))) { spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname); return FAILURE; } @@ -1370,11 +1349,7 @@ zend_result phar_open_or_create_filename(char *fname, size_t fname_len, char *al } return SUCCESS; } else if (my_error) { - if (error) { - *error = my_error; - } else { - efree(my_error); - } + *error = my_error; return FAILURE; } @@ -1394,16 +1369,12 @@ zend_result phar_open_or_create_filename(char *fname, size_t fname_len, char *al static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char *alias, size_t alias_len, uint32_t options, phar_archive_data** pphar, char **error); -zend_result phar_create_or_parse_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) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_create_or_parse_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) /* {{{ */ { - phar_archive_data *mydata; php_stream *fp; zend_string *actual = NULL; char *p; - if (!pphar) { - pphar = &mydata; - } if (php_check_open_basedir(fname)) { return FAILURE; } @@ -1440,15 +1411,13 @@ zend_result phar_create_or_parse_filename(char *fname, size_t fname_len, char *a if (PHAR_G(readonly) && !is_data) { if (options & REPORT_ERRORS) { - if (error) { - spprintf(error, 0, "creating archive \"%s\" disabled by the php.ini setting phar.readonly", fname); - } + spprintf(error, 0, "creating archive \"%s\" disabled by the php.ini setting phar.readonly", fname); } return FAILURE; } /* set up our manifest */ - mydata = ecalloc(1, sizeof(phar_archive_data)); + phar_archive_data *mydata = ecalloc(1, sizeof(phar_archive_data)); mydata->fname = expand_filepath(fname, NULL); if (mydata->fname == NULL) { efree(mydata); @@ -1470,16 +1439,12 @@ zend_result phar_create_or_parse_filename(char *fname, size_t fname_len, char *a } } - if (pphar) { - *pphar = mydata; - } - zend_hash_init(&mydata->manifest, sizeof(phar_entry_info), zend_get_hash_value, destroy_phar_manifest_entry, 0); zend_hash_init(&mydata->mounted_dirs, sizeof(char *), zend_get_hash_value, NULL, 0); zend_hash_init(&mydata->virtual_dirs, sizeof(char *), - zend_get_hash_value, NULL, (bool)mydata->is_persistent); + zend_get_hash_value, NULL, mydata->is_persistent); mydata->fname_len = fname_len; snprintf(mydata->version, sizeof(mydata->version), "%s", PHP_PHAR_API_VERSION); mydata->is_temporary_alias = alias ? 0 : 1; @@ -1500,15 +1465,11 @@ zend_result phar_create_or_parse_filename(char *fname, size_t fname_len, char *a if (alias && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { if (SUCCESS != phar_free_alias(fd_ptr, alias, alias_len)) { - if (error) { - spprintf(error, 4096, "phar error: phar \"%s\" cannot set alias \"%s\", already in use by another phar archive", mydata->fname, alias); - } + spprintf(error, 4096, "phar error: phar \"%s\" cannot set alias \"%s\", already in use by another phar archive", mydata->fname, alias); zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len); - if (pphar) { - *pphar = NULL; - } + *pphar = NULL; return FAILURE; } @@ -1522,21 +1483,18 @@ zend_result phar_create_or_parse_filename(char *fname, size_t fname_len, char *a if (alias_len && alias) { if (NULL == zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, mydata)) { if (options & REPORT_ERRORS) { - if (error) { - spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias); - } + spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias); } zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len); - if (pphar) { - *pphar = NULL; - } + *pphar = NULL; return FAILURE; } } + *pphar = mydata; return SUCCESS; } /* }}}*/ @@ -1619,7 +1577,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l const zend_long readsize = sizeof(buffer) - sizeof(token); const zend_long tokenlen = sizeof(token) - 1; zend_long halt_offset; - size_t got; + ssize_t got; uint32_t compression = PHAR_FILE_COMPRESSED_NONE; if (error) { @@ -1637,7 +1595,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l /* Maybe it's better to compile the file instead of just searching, */ /* but we only want the offset. So we want a .re scanner to find it. */ while(!php_stream_eof(fp)) { - if ((got = php_stream_read(fp, buffer+tokenlen, readsize)) < (size_t) tokenlen) { + if ((got = php_stream_read(fp, buffer+tokenlen, readsize)) < tokenlen) { MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated entry)") } @@ -1761,7 +1719,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l } if (got >= 512) { - if (phar_is_tar((char *) pos, fname)) { /* TODO: fix const correctness */ + if (phar_is_tar(pos, fname)) { php_stream_rewind(fp); return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, compression, error); } @@ -1947,7 +1905,7 @@ static zend_result phar_check_str(const char *fname, const char *ext_str, size_t * the last parameter should be set to tell the thing to assume that filename is the full path, and only to check the * extension rules, not to iterate. */ -zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len, const char **ext_str, size_t *ext_len, int executable, int for_create, int is_complete) /* {{{ */ +zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len, const char **ext_str, size_t *ext_len, int executable, int for_create, bool is_complete) /* {{{ */ { const char *pos, *slash; @@ -2041,45 +1999,40 @@ zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len } } - // TODO Use some sort of loop here instead of a goto pos = memchr(filename + 1, '.', filename_len); -next_extension: - if (!pos) { - return FAILURE; - } - - while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) { - pos = memchr(pos + 1, '.', filename_len - (pos - filename) - 1); - if (!pos) { - return FAILURE; + while (pos) { + while (pos != filename && (*(pos - 1) == '/' || *(pos - 1) == '\0')) { + pos = memchr(pos + 1, '.', filename_len - (pos - filename) - 1); + if (!pos) { + return FAILURE; + } } - } - slash = memchr(pos, '/', filename_len - (pos - filename)); + slash = memchr(pos, '/', filename_len - (pos - filename)); - if (!slash) { - /* this is a url like "phar://blah.phar" with no directory */ - *ext_str = pos; - *ext_len = strlen(pos); + if (!slash) { + /* this is a url like "phar://blah.phar" with no directory */ + *ext_str = pos; + *ext_len = strlen(pos); - /* file extension must contain "phar" */ - return phar_check_str(filename, *ext_str, *ext_len, executable, for_create); - } + /* file extension must contain "phar" */ + return phar_check_str(filename, *ext_str, *ext_len, executable, for_create); + } - /* we've found an extension that ends at a directory separator */ - *ext_str = pos; - *ext_len = slash - pos; + /* we've found an extension that ends at a directory separator */ + *ext_str = pos; + *ext_len = slash - pos; - if (phar_check_str(filename, *ext_str, *ext_len, executable, for_create) == SUCCESS) { - return SUCCESS; - } + if (phar_check_str(filename, *ext_str, *ext_len, executable, for_create) == SUCCESS) { + return SUCCESS; + } - /* look for more extensions */ - pos = strchr(pos + 1, '.'); - if (pos) { - *ext_str = NULL; - *ext_len = 0; - goto next_extension; + /* look for more extensions */ + pos = strchr(pos + 1, '.'); + if (pos) { + *ext_str = NULL; + *ext_len = 0; + } } return FAILURE; @@ -2090,10 +2043,10 @@ static bool php_check_dots(const char *element, size_t n) /* {{{ */ { for(n-- ; n != SIZE_MAX; --n) { if (element[n] != '.') { - return 1; + return true; } } - return 0; + return false; } /* }}} */ @@ -2108,7 +2061,7 @@ static bool php_check_dots(const char *element, size_t n) /* {{{ */ /** * Remove .. and . references within a phar filename */ -char *phar_fix_filepath(char *path, size_t *new_len, int use_cwd) /* {{{ */ +char *phar_fix_filepath(char *path, size_t *new_len, bool use_cwd) /* {{{ */ { char *newpath; size_t newpath_len; @@ -2228,7 +2181,7 @@ zend_result phar_split_fname(const char *filename, size_t filename_len, char **a #endif size_t ext_len; - if (CHECK_NULL_PATH(filename, filename_len)) { + if (zend_char_has_nul_byte(filename, filename_len)) { return FAILURE; } @@ -2245,7 +2198,7 @@ zend_result phar_split_fname(const char *filename, size_t filename_len, char **a phar_unixify_path_separators((char *)filename, filename_len); } #endif - if (phar_detect_phar_fname_ext(filename, filename_len, &ext_str, &ext_len, executable, for_create, 0) == FAILURE) { + if (phar_detect_phar_fname_ext(filename, filename_len, &ext_str, &ext_len, executable, for_create, false) == FAILURE) { if (ext_len != -1) { if (!ext_str) { /* no / detected, restore arch for error message */ @@ -2271,16 +2224,18 @@ zend_result phar_split_fname(const char *filename, size_t filename_len, char **a *arch_len = ext_str - filename + ext_len; *arch = estrndup(filename, *arch_len); - if (ext_str[ext_len]) { - *entry_len = filename_len - *arch_len; - *entry = estrndup(ext_str+ext_len, *entry_len); -#ifdef PHP_WIN32 - phar_unixify_path_separators(*entry, *entry_len); -#endif - *entry = phar_fix_filepath(*entry, entry_len, 0); - } else { - *entry_len = 1; - *entry = estrndup("/", 1); + if (entry) { + if (ext_str[ext_len]) { + *entry_len = filename_len - *arch_len; + *entry = estrndup(ext_str+ext_len, *entry_len); + #ifdef PHP_WIN32 + phar_unixify_path_separators(*entry, *entry_len); + #endif + *entry = phar_fix_filepath(*entry, entry_len, 0); + } else { + *entry_len = 1; + *entry = estrndup("/", 1); + } } #ifdef PHP_WIN32 @@ -2297,29 +2252,23 @@ zend_result phar_split_fname(const char *filename, size_t filename_len, char **a * Invoked when a user calls Phar::mapPhar() from within an executing .phar * to set up its manifest directly */ -zend_result phar_open_executed_filename(char *alias, size_t alias_len, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(3) zend_result phar_open_executed_filename(char *alias, size_t alias_len, char **error) /* {{{ */ { - if (error) { - *error = NULL; - } + *error = NULL; zend_string *fname = zend_get_executed_filename_ex(); if (!fname) { - if (error) { - spprintf(error, 0, "cannot initialize a phar outside of PHP execution"); - } + *error = estrdup("cannot initialize a phar outside of PHP execution"); return FAILURE; } - if (phar_open_parsed_phar(ZSTR_VAL(fname), ZSTR_LEN(fname), alias, alias_len, 0, REPORT_ERRORS, NULL, 0) == SUCCESS) { + if (phar_open_parsed_phar(ZSTR_VAL(fname), ZSTR_LEN(fname), alias, alias_len, false, REPORT_ERRORS, NULL, NULL) == SUCCESS) { return SUCCESS; } - if (0 == zend_get_constant_str("__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")-1)) { - if (error) { - spprintf(error, 0, "__HALT_COMPILER(); must be declared in a phar"); - } + if (NULL == zend_get_constant_str("__COMPILER_HALT_OFFSET__", sizeof("__COMPILER_HALT_OFFSET__")-1)) { + *error = estrdup("__HALT_COMPILER(); must be declared in a phar"); return FAILURE; } @@ -2332,9 +2281,7 @@ zend_result phar_open_executed_filename(char *alias, size_t alias_len, char **er fp = php_stream_open_wrapper(ZSTR_VAL(fname), "rb", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, &actual); if (!fp) { - if (error) { - spprintf(error, 0, "unable to open phar for reading \"%s\"", ZSTR_VAL(fname)); - } + spprintf(error, 0, "unable to open phar for reading \"%s\"", ZSTR_VAL(fname)); if (actual) { zend_string_release_ex(actual, 0); } @@ -2358,42 +2305,43 @@ zend_result phar_open_executed_filename(char *alias, size_t alias_len, char **er /** * Validate the CRC32 of a file opened from within the phar */ -zend_result phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char **error, int process_zip) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL zend_result phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char **error, int process_zip) /* {{{ */ { php_stream *fp = idata->fp; phar_entry_info *entry = idata->internal_file; - if (error) { - *error = NULL; - } + *error = NULL; if (entry->is_zip && process_zip > 0) { /* verify local file header */ phar_zip_file_header local; phar_zip_data_desc desc; + php_stream *stream = phar_open_archive_fp(idata->phar); - if (SUCCESS != phar_open_archive_fp(idata->phar)) { - spprintf(error, 0, "phar error: unable to open zip-based phar archive \"%s\" to verify local file header for file \"%s\"", idata->phar->fname, ZSTR_VAL(entry->filename)); + if (!stream) { + spprintf(error, 0, "phar error: unable to open zip-based phar archive \"%s\" to verify local file header for file \"%s\"", + idata->phar->fname, ZSTR_VAL(entry->filename)); return FAILURE; } - php_stream_seek(phar_get_entrypfp(idata->internal_file), entry->header_offset, SEEK_SET); + php_stream_seek(stream, entry->header_offset, SEEK_SET); - if (sizeof(local) != php_stream_read(phar_get_entrypfp(idata->internal_file), (char *) &local, sizeof(local))) { - - spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local file header for file \"%s\")", idata->phar->fname, ZSTR_VAL(entry->filename)); + if (sizeof(local) != php_stream_read(stream, (char *) &local, sizeof(local))) { + spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local file header for file \"%s\")", + idata->phar->fname, ZSTR_VAL(entry->filename)); return FAILURE; } /* check for data descriptor */ if (((PHAR_ZIP_16(local.flags)) & 0x8) == 0x8) { - php_stream_seek(phar_get_entrypfp(idata->internal_file), + php_stream_seek(stream, entry->header_offset + sizeof(local) + PHAR_ZIP_16(local.filename_len) + PHAR_ZIP_16(local.extra_len) + entry->compressed_filesize, SEEK_SET); - if (sizeof(desc) != php_stream_read(phar_get_entrypfp(idata->internal_file), + if (sizeof(desc) != php_stream_read(stream, (char *) &desc, sizeof(desc))) { - spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local data descriptor for file \"%s\")", idata->phar->fname, ZSTR_VAL(entry->filename)); + spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (cannot read local data descriptor for file \"%s\")", + idata->phar->fname, ZSTR_VAL(entry->filename)); return FAILURE; } if (desc.signature[0] == 'P' && desc.signature[1] == 'K') { @@ -2405,7 +2353,8 @@ zend_result phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char * } /* verify local header */ if (ZSTR_LEN(entry->filename) != PHAR_ZIP_16(local.filename_len) || entry->crc32 != PHAR_ZIP_32(local.crc32) || entry->uncompressed_filesize != PHAR_ZIP_32(local.uncompsize) || entry->compressed_filesize != PHAR_ZIP_32(local.compsize)) { - spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (local header of file \"%s\" does not match central directory)", idata->phar->fname, ZSTR_VAL(entry->filename)); + spprintf(error, 0, "phar error: internal corruption of zip-based phar \"%s\" (local header of file \"%s\" does not match central directory)", + idata->phar->fname, ZSTR_VAL(entry->filename)); return FAILURE; } @@ -2433,7 +2382,8 @@ zend_result phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char * entry->is_crc_checked = 1; return SUCCESS; } else { - spprintf(error, 0, "phar error: internal corruption of phar \"%s\" (crc32 mismatch on file \"%s\")", idata->phar->fname, ZSTR_VAL(entry->filename)); + spprintf(error, 0, "phar error: internal corruption of phar \"%s\" (crc32 mismatch on file \"%s\")", + idata->phar->fname, ZSTR_VAL(entry->filename)); return FAILURE; } } @@ -2465,46 +2415,52 @@ static int phar_flush_clean_deleted_apply(zval *zv) /* {{{ */ #include "stub.h" /* Generated phar_get_stub() function from makestub.php script */ -zend_string *phar_create_default_stub(const char *index_php, const char *web_index, char **error) /* {{{ */ +zend_string *phar_create_default_stub(const zend_string *php_index_str, const zend_string *web_index_str, char **error) /* {{{ */ { - size_t index_len, web_len; + const char *php_index; + const char *web_index; + size_t php_len, web_len; if (error) { *error = NULL; } - if (!index_php) { - index_php = "index.php"; - } - - if (!web_index) { - web_index = "index.php"; - } - - index_len = strlen(index_php); - web_len = strlen(web_index); - - if (index_len > 400) { - /* ridiculous size not allowed for index.php startup filename */ - if (error) { - spprintf(error, 0, "Illegal filename passed in for stub creation, was %zd characters long, and only 400 or less is allowed", index_len); + if (!php_index_str) { + php_index = "index.php"; + php_len = strlen("index.php"); + } else { + php_index = ZSTR_VAL(php_index_str); + php_len = ZSTR_LEN(php_index_str); + if (php_len > 400) { + /* ridiculous size not allowed for index.php startup filename */ + if (error) { + spprintf(error, 0, "Illegal filename passed in for stub creation, was %zd characters long, and only 400 or less is allowed", php_len); + } return NULL; } } - if (web_len > 400) { - /* ridiculous size not allowed for index.php startup filename */ - if (error) { - spprintf(error, 0, "Illegal web filename passed in for stub creation, was %zd characters long, and only 400 or less is allowed", web_len); + if (!web_index_str) { + web_index = "index.php"; + web_len = strlen("index.php"); + } else { + web_index = ZSTR_VAL(web_index_str); + web_len = ZSTR_LEN(web_index_str); + + if (web_len > 400) { + /* ridiculous size not allowed for index.php startup filename */ + if (error) { + spprintf(error, 0, "Illegal web filename passed in for stub creation, was %zd characters long, and only 400 or less is allowed", web_len); + } return NULL; } } - return phar_get_stub(index_php, web_index, index_len+1, web_len+1); + return phar_get_stub(php_index, web_index, php_len+1, web_len+1); } /* }}} */ -int phar_flush(phar_archive_data *phar, char **error) { +ZEND_ATTRIBUTE_NONNULL int phar_flush(phar_archive_data *phar, char **error) { return phar_flush_ex(phar, NULL, false, error); } @@ -2513,13 +2469,14 @@ int phar_flush(phar_archive_data *phar, char **error) { * * if user_stub is NULL the default or existing stub should be used */ -int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ { static const char halt_stub[] = "__HALT_COMPILER();"; phar_entry_info *entry, *newentry; size_t halt_offset; - int restore_alias_len, global_flags = 0; + uint32_t restore_alias_len; + uint32_t global_flags = 0; bool must_close_old_file = false; bool has_dirs = false; char manifest[18], entry_buffer[24]; @@ -2538,15 +2495,11 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream *shared_cfp = NULL; if (phar->is_persistent) { - if (error) { - spprintf(error, 0, "internal error: attempt to flush cached zip-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "internal error: attempt to flush cached zip-based phar \"%s\"", phar->fname); return EOF; } - if (error) { - *error = NULL; - } + *error = NULL; if (!zend_hash_num_elements(&phar->manifest) && !user_stub) { return EOF; @@ -2576,9 +2529,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau } newfile = php_stream_fopen_tmpfile(); if (!newfile) { - if (error) { - spprintf(error, 0, "unable to create temporary file"); - } + *error = estrdup("unable to create temporary file"); if (must_close_old_file) { php_stream_close(oldfile); } @@ -2593,9 +2544,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - spprintf(error, 0, "illegal stub for phar \"%s\" (__HALT_COMPILER(); is missing)", phar->fname); - } + spprintf(error, 0, "illegal stub for phar \"%s\" (__HALT_COMPILER(); is missing)", phar->fname); return EOF; } @@ -2611,9 +2560,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to create stub from string in new phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to create stub from string in new phar \"%s\"", phar->fname); return EOF; } phar->halt_offset = len + end_sequence_len; @@ -2634,12 +2581,10 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - if (new_stub) { - spprintf(error, 0, "unable to create stub in new phar \"%s\"", phar->fname); - } else { - spprintf(error, 0, "unable to copy stub of old phar to new phar \"%s\"", phar->fname); - } + if (new_stub) { + spprintf(error, 0, "unable to create stub in new phar \"%s\"", phar->fname); + } else { + spprintf(error, 0, "unable to copy stub of old phar to new phar \"%s\"", phar->fname); } if (new_stub) { zend_string_free(new_stub); @@ -2720,7 +2665,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau } continue; } - if (!phar_get_efp(entry, 0)) { + if (!phar_get_efp(entry, false)) { /* re-open internal file pointer just-in-time */ newentry = phar_open_jit(phar, entry, error); if (!newentry) { @@ -2731,15 +2676,13 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau } entry = newentry; } - file = phar_get_efp(entry, 0); - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1)) { + file = phar_get_efp(entry, false); + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, true)) { if (must_close_old_file) { php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); return EOF; } newcrc32 = php_crc32_bulk_init(); @@ -2751,21 +2694,16 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau entry->compressed_filesize = entry->uncompressed_filesize; continue; } - filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0); + filter = php_stream_filter_create(phar_compress_filter(entry, false), NULL, 0); if (!filter) { if (must_close_old_file) { php_stream_close(oldfile); } php_stream_close(newfile); - if (entry->flags & PHAR_ENT_COMPRESSED_GZ) { - if (error) { - spprintf(error, 0, "unable to gzip compress file \"%s\" to new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } - } else { - if (error) { - spprintf(error, 0, "unable to bzip2 compress file \"%s\" to new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } - } + spprintf(error, 0, "unable to %s compress file \"%s\" to new phar \"%s\"", + entry->flags & PHAR_ENT_COMPRESSED_GZ ? "gzip" : "bzip2", + ZSTR_VAL(entry->filename), + phar->fname); return EOF; } @@ -2778,9 +2716,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau entry->cfp = shared_cfp; if (!entry->cfp) { php_stream_filter_free(filter); - if (error) { - spprintf(error, 0, "unable to create temporary file"); - } + *error = estrdup("unable to create temporary file"); if (must_close_old_file) { php_stream_close(oldfile); } @@ -2791,15 +2727,14 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau ZEND_ASSERT(entry->header_offset == 0); entry->header_offset = php_stream_tell(entry->cfp); php_stream_flush(file); - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) { php_stream_filter_free(filter); if (must_close_old_file) { php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", + ZSTR_VAL(entry->filename), phar->fname); goto cleanup; } php_stream_filter_append((&entry->cfp->writefilters), filter); @@ -2809,9 +2744,8 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to copy compressed file contents of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + spprintf(error, 0, "unable to copy compressed file contents of file \"%s\" while creating new phar \"%s\"", + ZSTR_VAL(entry->filename), phar->fname); goto cleanup; } php_stream_filter_flush(filter, 1); @@ -2871,9 +2805,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(newfile); phar->alias_len = restore_alias_len; - if (error) { - spprintf(error, 0, "unable to write manifest header of new phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to write manifest header of new phar \"%s\"", phar->fname); goto cleanup; } @@ -2892,9 +2824,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(newfile); phar->alias_len = restore_alias_len; - if (error) { - spprintf(error, 0, "unable to write manifest meta-data of new phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to write manifest meta-data of new phar \"%s\"", phar->fname); goto cleanup; } @@ -2925,12 +2855,10 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - if (entry->is_dir) { - spprintf(error, 0, "unable to write filename of directory \"%s\" to manifest of new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } else { - spprintf(error, 0, "unable to write filename of file \"%s\" to manifest of new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + if (entry->is_dir) { + spprintf(error, 0, "unable to write filename of directory \"%s\" to manifest of new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); + } else { + spprintf(error, 0, "unable to write filename of file \"%s\" to manifest of new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); } goto cleanup; } @@ -2962,9 +2890,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to write temporary manifest of file \"%s\" to manifest of new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + spprintf(error, 0, "unable to write temporary manifest of file \"%s\" to manifest of new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); goto cleanup; } @@ -2978,9 +2904,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to write manifest padding byte"); - } + *error = estrdup("unable to write manifest padding byte"); goto cleanup; } @@ -2997,15 +2921,13 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau file = entry->cfp; php_stream_seek(file, entry->header_offset, SEEK_SET); } else { - file = phar_get_efp(entry, 0); - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + file = phar_get_efp(entry, false); + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) { if (must_close_old_file) { php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); goto cleanup; } } @@ -3015,9 +2937,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(oldfile); } php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + spprintf(error, 0, "unable to seek to start of file \"%s\" while creating new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); goto cleanup; } @@ -3031,9 +2951,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau php_stream_close(newfile); - if (error) { - spprintf(error, 0, "unable to write contents of file \"%s\" to new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); - } + spprintf(error, 0, "unable to write contents of file \"%s\" to new phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); goto cleanup; } @@ -3079,12 +2997,11 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau char *digest = NULL; size_t digest_len; - if (FAILURE == phar_create_signature(phar, newfile, &digest, &digest_len, error)) { - if (error) { - char *save = *error; - spprintf(error, 0, "phar error: unable to write signature: %s", save); - efree(save); - } + char *signature_error = NULL; + if (FAILURE == phar_create_signature(phar, newfile, &digest, &digest_len, &signature_error)) { + spprintf(error, 0, "phar error: unable to write signature: %s", signature_error); + efree(signature_error); + if (digest) { efree(digest); } @@ -3141,9 +3058,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau phar->fp = php_stream_open_wrapper(phar->fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL); if (!phar->fp) { phar->fp = newfile; - if (error) { - spprintf(error, 4096, "unable to open new phar \"%s\" for writing", phar->fname); - } + spprintf(error, 4096, "unable to open new phar \"%s\" for writing", phar->fname); return EOF; } @@ -3157,9 +3072,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau zend_array_destroy(Z_ARR(filterparams)); if (!filter) { - if (error) { - spprintf(error, 4096, "unable to compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6 have a buggy zlib", phar->fname); - } + spprintf(error, 4096, "unable to compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6 have a buggy zlib", phar->fname); return EOF; } @@ -3187,9 +3100,7 @@ int phar_flush_ex(phar_archive_data *phar, zend_string *user_stub, bool is_defau } if (-1 == php_stream_seek(phar->fp, phar->halt_offset, SEEK_SET)) { - if (error) { - spprintf(error, 0, "unable to seek to __HALT_COMPILER(); in new phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to seek to __HALT_COMPILER(); in new phar \"%s\"", phar->fname); return EOF; } @@ -3243,7 +3154,7 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) { zend_op_array *res; zend_string *name = NULL; - int failed; + bool failed; phar_archive_data *phar; if (!file_handle || !file_handle->filename) { @@ -3294,11 +3205,11 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) } zend_try { - failed = 0; + failed = false; CG(zend_lineno) = 0; res = phar_orig_compile_file(file_handle, type); } zend_catch { - failed = 1; + failed = true; res = NULL; } zend_end_try(); diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index eec2e60e7855f..5ed213fb03e16 100644 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -105,8 +105,8 @@ ZEND_BEGIN_MODULE_GLOBALS(phar) /* for cached phars, this is a per-process store of fp/ufp */ phar_entry_fp *cached_fp; HashTable phar_alias_map; - int phar_SERVER_mung_list; char* cache_list; + int phar_SERVER_mung_list; bool readonly; bool manifest_cached; bool persist; @@ -150,8 +150,8 @@ ZEND_BEGIN_MODULE_GLOBALS(phar) /* phar_get_archive cache */ char* last_phar_name; uint32_t last_phar_name_len; - char* last_alias; uint32_t last_alias_len; + char* last_alias; phar_archive_data* last_phar; HashTable mime_types; ZEND_END_MODULE_GLOBALS(phar) @@ -196,6 +196,7 @@ typedef struct _phar_metadata_tracker { typedef struct _phar_entry_info { /* first bytes are exactly as in file */ uint32_t uncompressed_filesize; + /* modification time */ uint32_t timestamp; uint32_t compressed_filesize; uint32_t crc32; @@ -205,7 +206,6 @@ typedef struct _phar_entry_info { uint32_t old_flags; phar_metadata_tracker metadata_tracker; zend_string *filename; - enum phar_fp_type fp_type; /* offset within original phar file of the file contents */ zend_long offset_abs; /* offset within fp of the file contents */ @@ -214,7 +214,9 @@ typedef struct _phar_entry_info { zend_long header_offset; php_stream *fp; php_stream *cfp; + enum phar_fp_type fp_type; int fp_refcount; + unsigned int fileinfo_lock_count; char *tmp; phar_archive_data *phar; char *link; /* symbolic link to another file */ @@ -224,21 +226,21 @@ typedef struct _phar_entry_info { /* for stat */ unsigned short inode; - uint32_t is_crc_checked:1; - uint32_t is_modified:1; - uint32_t is_deleted:1; - uint32_t is_dir:1; + bool is_crc_checked:1; + bool is_modified:1; + bool is_deleted:1; + bool is_dir:1; /* this flag is used for mounted entries (external files mapped to location inside a phar */ - uint32_t is_mounted:1; + bool is_mounted:1; /* used when iterating */ - uint32_t is_temp_dir:1; + bool is_temp_dir:1; /* tar-based phar file stuff */ - uint32_t is_tar:1; + bool is_tar:1; /* zip-based phar file stuff */ - uint32_t is_zip:1; + bool is_zip:1; /* for cached phar entries */ - uint32_t is_persistent:1; + bool is_persistent:1; } phar_entry_info; /* information about a phar file (the archive itself) */ @@ -246,10 +248,10 @@ struct _phar_archive_data { char *fname; uint32_t fname_len; /* for phar_detect_fname_ext, this stores the location of the file extension within fname */ - char *ext; uint32_t ext_len; + char *ext; char *alias; - uint32_t alias_len; + uint32_t alias_len; char version[12]; size_t halt_offset; HashTable manifest; @@ -258,32 +260,31 @@ struct _phar_archive_data { /* hash of mounted directory paths */ HashTable mounted_dirs; uint32_t flags; - uint32_t min_timestamp; uint32_t max_timestamp; + int refcount; php_stream *fp; /* decompressed file contents are stored here */ php_stream *ufp; - int refcount; uint32_t sig_flags; uint32_t sig_len; char *signature; phar_metadata_tracker metadata_tracker; uint32_t phar_pos; /* if 1, then this alias was manually specified by the user and is not a permanent alias */ - uint32_t is_temporary_alias:1; - uint32_t is_modified:1; - uint32_t is_writeable:1; - uint32_t is_brandnew:1; + bool is_temporary_alias:1; + bool is_modified:1; + bool is_writeable:1; + bool is_brandnew:1; /* defer phar creation */ - uint32_t donotflush:1; + bool donotflush:1; /* zip-based phar variables */ - uint32_t is_zip:1; + bool is_zip:1; /* tar-based phar variables */ - uint32_t is_tar:1; + bool is_tar:1; /* PharData variables */ - uint32_t is_data:1; + bool is_data:1; /* for cached phar manifests */ - uint32_t is_persistent:1; + bool is_persistent:1; }; typedef struct _phar_entry_fp_info { @@ -404,27 +405,27 @@ void phar_request_initialize(void); void phar_object_init(void); void phar_destroy_phar_data(phar_archive_data *phar); -zend_result phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char **error, int process_zip); +ZEND_ATTRIBUTE_NONNULL zend_result phar_postprocess_file(phar_entry_data *idata, uint32_t crc32, char **error, int process_zip); zend_result 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); -zend_result 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); -zend_result phar_create_or_parse_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); -zend_result phar_open_executed_filename(char *alias, size_t alias_len, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result 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); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_create_or_parse_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); +ZEND_ATTRIBUTE_NONNULL_ARGS(3) zend_result phar_open_executed_filename(char *alias, size_t alias_len, char **error); zend_result phar_free_alias(phar_archive_data *phar, char *alias, size_t alias_len); zend_result phar_get_archive(phar_archive_data **archive, char *fname, size_t fname_len, char *alias, size_t alias_len, char **error); zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t sig_type, char *sig, size_t sig_len, char *fname, char **signature, size_t *signature_len, char **error); -zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, size_t *signature_length, char **error); +ZEND_ATTRIBUTE_NONNULL zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, size_t *signature_length, char **error); /* utility functions */ -zend_string *phar_create_default_stub(const char *index_php, const char *web_index, char **error); -char *phar_decompress_filter(phar_entry_info * entry, int return_unknown); -char *phar_compress_filter(phar_entry_info * entry, int return_unknown); +zend_string *phar_create_default_stub(const zend_string *php_index_str, const zend_string *web_index_str, char **error); +const char *phar_decompress_filter(const phar_entry_info *entry, bool return_unknown); +const char *phar_compress_filter(const phar_entry_info *entry, bool return_unknown); /* void phar_remove_virtual_dirs(phar_archive_data *phar, char *filename, size_t filename_len); */ void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, size_t filename_len); zend_result phar_mount_entry(phar_archive_data *phar, char *filename, size_t filename_len, char *path, size_t path_len); zend_string *phar_find_in_include_path(zend_string *file, phar_archive_data **pphar); -char *phar_fix_filepath(char *path, size_t *new_len, int use_cwd); -phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error); +char *phar_fix_filepath(char *path, size_t *new_len, bool use_cwd); +ZEND_ATTRIBUTE_NONNULL phar_entry_info * phar_open_jit(const phar_archive_data *phar, phar_entry_info *entry, char **error); void phar_parse_metadata_lazy(const char *buffer, phar_metadata_tracker *tracker, uint32_t zip_metadata_len, bool persistent); bool phar_metadata_tracker_has_data(const phar_metadata_tracker* tracker, bool persistent); /* If this has data, free it and set all values to undefined. */ @@ -434,24 +435,24 @@ void phar_metadata_tracker_clone(phar_metadata_tracker* tracker); void phar_metadata_tracker_try_ensure_has_serialized_data(phar_metadata_tracker* tracker, bool persistent); zend_result phar_metadata_tracker_unserialize_or_copy(phar_metadata_tracker* tracker, zval *value, bool persistent, HashTable *unserialize_options, const char* method_name); 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); -zend_result phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error); -zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links); +int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, bool follow_links); +php_stream *phar_get_efp(phar_entry_info *entry, bool follow_links); +ZEND_ATTRIBUTE_NONNULL zend_result phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error); +ZEND_ATTRIBUTE_NONNULL zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, bool follow_links); phar_entry_info *phar_get_link_source(phar_entry_info *entry); -zend_result phar_open_archive_fp(phar_archive_data *phar); +php_stream *phar_open_archive_fp(phar_archive_data *phar); zend_result phar_copy_on_write(phar_archive_data **pphar); /* tar functions in tar.c */ -bool phar_is_tar(char *buf, char *fname); +bool phar_is_tar(const char *buf, const char *fname); zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, uint32_t compression, char **error); -zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t alias_len, int is_data, uint32_t options, phar_archive_data** pphar, char **error); -int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error); /* zip functions in zip.c */ -int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, char **error); -int phar_open_or_create_zip(char *fname, size_t fname_len, char *alias, size_t alias_len, int is_data, uint32_t options, phar_archive_data** pphar, char **error); -int phar_zip_flush(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error); +zend_result phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_zip(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_zip_flush(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error); #ifdef PHAR_MAIN extern const php_stream_wrapper php_stream_phar_wrapper; @@ -463,13 +464,13 @@ extern HashTable cached_alias; bool phar_archive_delref(phar_archive_data *phar); 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); -phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, int security); -zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, int security); -int phar_flush_ex(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error); -int phar_flush(phar_archive_data *archive, char **error); -zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len, const char **ext_str, size_t *ext_len, int executable, int for_create, int is_complete); +phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, size_t path_len, char **error, bool security); +phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, size_t path_len, char dir, char **error, bool security); +ZEND_ATTRIBUTE_NONNULL phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, bool security, uint32_t timestamp); +ZEND_ATTRIBUTE_NONNULL zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, bool security); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_flush_ex(phar_archive_data *archive, zend_string *user_stub, bool is_default_stub, char **error); +ZEND_ATTRIBUTE_NONNULL int phar_flush(phar_archive_data *archive, char **error); +zend_result phar_detect_phar_fname_ext(const char *filename, size_t filename_len, const char **ext_str, size_t *ext_len, int executable, int for_create, bool is_complete); zend_result phar_split_fname(const char *filename, size_t filename_len, char **arch, size_t *arch_len, char **entry, size_t *entry_len, int executable, int for_create); typedef enum { @@ -484,6 +485,6 @@ typedef enum { pcr_err_empty_entry } phar_path_check_result; -phar_path_check_result phar_path_check(char **p, size_t *len, const char **error); +ZEND_ATTRIBUTE_NONNULL phar_path_check_result phar_path_check(char **p, size_t *len, const char **error); END_EXTERN_C() diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 3b12a837b08bd..17000ca3c0f17 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -34,7 +34,18 @@ static zend_class_entry *phar_ce_data; static zend_class_entry *phar_ce_PharException; static zend_class_entry *phar_ce_entry; -static int phar_file_type(HashTable *mimes, char *file, char **mime_type) /* {{{ */ +#define PHAR_FETCH_INTERNAL_EX(zv) (void *)((char *) Z_OBJ_P(zv) - Z_OBJ_P(zv)->handlers->offset); +#define PHAR_FETCH_INTERNAL() PHAR_FETCH_INTERNAL_EX(ZEND_THIS) + +#define PHAR_ARCHIVE_OBJECT() \ + phar_archive_object *phar_obj = PHAR_FETCH_INTERNAL(); \ + if (!phar_obj->archive) { \ + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ + "Cannot call method on an uninitialized Phar object"); \ + RETURN_THROWS(); \ + } + +static int phar_file_type(const HashTable *mimes, const char *file, char **mime_type) /* {{{ */ { char *ext; phar_mime_type *mime; @@ -54,7 +65,7 @@ static int phar_file_type(HashTable *mimes, char *file, char **mime_type) /* {{{ } /* }}} */ -static void phar_mung_server_vars(char *fname, char *entry, size_t entry_len, char *basename, size_t request_uri_len) /* {{{ */ +static void phar_mung_server_vars(char *fname, char *entry, size_t entry_len, const char *basename, size_t request_uri_len) /* {{{ */ { HashTable *_SERVER; zval *stuff; @@ -140,7 +151,12 @@ static void phar_mung_server_vars(char *fname, char *entry, size_t entry_len, ch } /* }}} */ -static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char *mime_type, int code, char *entry, size_t entry_len, char *arch, char *basename, char *ru, size_t ru_len) /* {{{ */ +typedef enum { + PHAR_ACT_DO_EXIT, + PHAR_ACT_GRACEFULLY_RETURN, +} phar_action_status; + +static phar_action_status phar_file_action(phar_archive_data *phar, phar_entry_info *info, char *mime_type, int code, char *entry, size_t entry_len, char *arch, const char *basename, char *ru, size_t ru_len) /* {{{ */ { char *name = NULL, buf[8192]; const char *cwd; @@ -157,7 +173,6 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char switch (code) { case PHAR_MIME_PHPS: - efree(basename); /* highlight source */ if (entry[0] == '/') { spprintf(&name, 4096, "phar://%s%s", arch, entry); @@ -169,13 +184,9 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char highlight_file(name, &syntax_highlighter_ini); efree(name); -#ifdef PHP_WIN32 - efree(arch); -#endif - zend_bailout(); + return PHAR_ACT_DO_EXIT; case PHAR_MIME_OTHER: /* send headers, output file contents */ - efree(basename); ctr.line_len = spprintf((char **) &(ctr.line), 0, "Content-type: %s", mime_type); sapi_header_op(SAPI_HEADER_REPLACE, &ctr); efree((void *) ctr.line); @@ -184,11 +195,11 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char efree((void *) ctr.line); if (FAILURE == sapi_send_headers()) { - zend_bailout(); + return PHAR_ACT_DO_EXIT; } /* prepare to output */ - fp = phar_get_efp(info, 1); + fp = phar_get_efp(info, true); if (!fp) { char *error; @@ -197,12 +208,12 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } - return -1; + return PHAR_ACT_GRACEFULLY_RETURN; } - fp = phar_get_efp(info, 1); + fp = phar_get_efp(info, true); } position = 0; - phar_seek_efp(info, 0, SEEK_SET, 0, 1); + phar_seek_efp(info, 0, SEEK_SET, 0, true); do { got = php_stream_read(fp, buf, MIN(8192, info->uncompressed_filesize - position)); @@ -215,11 +226,10 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char } } while (1); - zend_bailout(); + return PHAR_ACT_DO_EXIT; case PHAR_MIME_PHP: if (basename) { phar_mung_server_vars(arch, entry, entry_len, basename, ru_len); - efree(basename); } if (entry[0] == '/') { @@ -261,9 +271,6 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char } zend_destroy_file_handle(&file_handle); -#ifdef PHP_WIN32 - efree(arch); -#endif if (new_op_array) { ZVAL_UNDEF(&result); @@ -291,16 +298,15 @@ static int phar_file_action(phar_archive_data *phar, phar_entry_info *info, char efree(name); } zend_end_try(); - zend_bailout(); + return PHAR_ACT_DO_EXIT; } - - return PHAR_MIME_PHP; } - return -1; + + return PHAR_ACT_GRACEFULLY_RETURN; } /* }}} */ -static void phar_do_403(char *entry, size_t entry_len) /* {{{ */ +static void phar_do_403(void) /* {{{ */ { sapi_header_line ctr = {0}; @@ -314,16 +320,17 @@ static void phar_do_403(char *entry, size_t entry_len) /* {{{ */ } /* }}} */ -static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, char *f404, size_t f404_len, char *entry, size_t entry_len) /* {{{ */ +static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, zend_string *f404) /* {{{ */ { sapi_header_line ctr = {0}; phar_entry_info *info; - if (phar && f404_len) { - info = phar_get_entry_info(phar, f404, f404_len, NULL, 1); + if (phar && f404 && ZSTR_LEN(f404)) { + info = phar_get_entry_info(phar, ZSTR_VAL(f404), ZSTR_LEN(f404), NULL, true); if (info) { - phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, f404, f404_len, fname, NULL, NULL, 0); + /* Status doesn't matter, we're exiting anyway. */ + phar_file_action(phar, info, "text/html", PHAR_MIME_PHP, ZSTR_VAL(f404), ZSTR_LEN(f404), fname, NULL, NULL, 0); return; } } @@ -341,9 +348,10 @@ static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, /* post-process REQUEST_URI and retrieve the actual request URI. This is for cases like http://localhost/blah.phar/path/to/file.php/extra/stuff which calls "blah.phar" file "path/to/file.php" with PATH_INFO "/extra/stuff" */ -static void phar_postprocess_ru_web(char *fname, size_t fname_len, char **entry, size_t *entry_len, char **ru, size_t *ru_len) /* {{{ */ +static void phar_postprocess_ru_web(const char *fname, size_t fname_len, const char *entry, size_t *entry_len, char **ru, size_t *ru_len) /* {{{ */ { - char *e = *entry + 1, *u = NULL, *u1 = NULL, *saveu = NULL; + const char *e = entry + 1; + char *u = NULL, *u1 = NULL, *saveu = NULL; size_t e_len = *entry_len - 1, u_len = 0; phar_archive_data *pphar; @@ -401,9 +409,9 @@ static void phar_postprocess_ru_web(char *fname, size_t fname_len, char **entry, PHP_METHOD(Phar, running) { zend_string *fname; - char *arch, *entry; - size_t arch_len, entry_len; - bool retphar = 1; + char *arch; + size_t arch_len; + bool retphar = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &retphar) == FAILURE) { RETURN_THROWS(); @@ -416,9 +424,8 @@ PHP_METHOD(Phar, running) if ( zend_string_starts_with_literal_ci(fname, "phar://") - && SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 2, 0) + && SUCCESS == phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 2, 0) ) { - efree(entry); if (retphar) { RETVAL_STRINGL(ZSTR_VAL(fname), arch_len + 7); efree(arch); @@ -474,8 +481,7 @@ PHP_METHOD(Phar, mount) } #endif - if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) { - efree(entry); + if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, NULL, NULL, 2, 0)) { entry = NULL; if (path_len > 7 && !memcmp(path, "phar://", 7)) { @@ -550,8 +556,9 @@ PHP_METHOD(Phar, webPhar) zval *mimeoverride = NULL; zend_fcall_info rewrite_fci = {0}; zend_fcall_info_cache rewrite_fcc; - char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL; - size_t alias_len = 0, f404_len = 0, free_pathinfo = 0; + char *alias = NULL, *error, *index_php = NULL, *ru = NULL; + size_t alias_len = 0, free_pathinfo = 0; + zend_string *f404 = NULL; size_t ru_len = 0; char *fname, *path_info, *mime_type = NULL, *entry, *pt; const char *basename; @@ -561,8 +568,9 @@ PHP_METHOD(Phar, webPhar) phar_archive_data *phar = NULL; phar_entry_info *info = NULL; size_t sapi_mod_name_len = strlen(sapi_module.name); + phar_action_status status = PHAR_ACT_DO_EXIT; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!af!", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!S!af!", &alias, &alias_len, &index_php, &index_php_len, &f404, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) { RETURN_THROWS(); } @@ -601,10 +609,8 @@ PHP_METHOD(Phar, webPhar) fname_len = ZSTR_LEN(zend_file_name); #ifdef PHP_WIN32 - if (memchr(fname, '\\', fname_len)) { - fname = estrndup(fname, fname_len); - phar_unixify_path_separators(fname, fname_len); - } + fname = estrndup(fname, fname_len); + phar_unixify_path_separators(fname, fname_len); #endif basename = zend_memrchr(fname, '/', fname_len); @@ -620,7 +626,7 @@ PHP_METHOD(Phar, webPhar) || (sapi_mod_name_len == sizeof("litespeed") - 1 && !strncmp(sapi_module.name, "litespeed", sizeof("litespeed") - 1))) { if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF) { - HashTable *_server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); + const HashTable *_server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); zval *z_script_name, *z_path_info; if (NULL == (z_script_name = zend_hash_str_find(_server, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) || @@ -646,9 +652,7 @@ PHP_METHOD(Phar, webPhar) pt = estrndup(Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name)); } else { - char *testit; - - testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1); + char *testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1); if (!(pt = strstr(testit, basename))) { efree(testit); goto finish; @@ -669,6 +673,7 @@ PHP_METHOD(Phar, webPhar) } pt = estrndup(testit, (pt - testit) + (fname_len - (basename - fname))); + efree(testit); } not_cgi = 0; } else { @@ -691,6 +696,7 @@ PHP_METHOD(Phar, webPhar) zval params, retval; ZVAL_STRINGL(¶ms, entry, entry_len); + efree(entry); rewrite_fci.param_count = 1; rewrite_fci.params = ¶ms; @@ -701,54 +707,38 @@ PHP_METHOD(Phar, webPhar) if (!EG(exception)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback"); } - goto cleanup_fail; + goto cleanup_skip_entry; } zval_ptr_dtor_str(¶ms); - if (Z_TYPE_P(rewrite_fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); - goto cleanup_fail; - } - switch (Z_TYPE(retval)) { case IS_STRING: - efree(entry); + /* TODO: avoid relocation??? */ entry = estrndup(Z_STRVAL_P(rewrite_fci.retval), Z_STRLEN_P(rewrite_fci.retval)); entry_len = Z_STRLEN_P(rewrite_fci.retval); + zval_ptr_dtor_str(&retval); break; case IS_TRUE: case IS_FALSE: - phar_do_403(entry, entry_len); - - if (free_pathinfo) { - efree(path_info); - } - efree(pt); - - zend_bailout(); + phar_do_403(); + goto cleanup_skip_entry; default: + zval_ptr_dtor(&retval); zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); - -cleanup_fail: - if (free_pathinfo) { - efree(path_info); - } - efree(entry); - efree(pt); -#ifdef PHP_WIN32 - efree(fname); -#endif - RETURN_THROWS(); + goto cleanup_skip_entry; } } if (entry_len) { - phar_postprocess_ru_web(fname, fname_len, &entry, &entry_len, &ru, &ru_len); + phar_postprocess_ru_web(fname, fname_len, entry, &entry_len, &ru, &ru_len); } if (!entry_len || (entry_len == 1 && entry[0] == '/')) { efree(entry); + + bool is_entry_allocated = false; + /* direct request */ if (index_php_len) { entry = index_php; @@ -756,22 +746,17 @@ PHP_METHOD(Phar, webPhar) if (entry[0] != '/') { spprintf(&entry, 0, "/%s", index_php); ++entry_len; + is_entry_allocated = true; } } else { /* assume "index.php" is starting point */ - entry = estrndup("/index.php", sizeof("/index.php")); + entry = "/index.php"; entry_len = sizeof("/index.php")-1; } if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) || - (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) { - phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len); - - if (free_pathinfo) { - efree(path_info); - } - - zend_bailout(); + (info = phar_get_entry_info(phar, entry, entry_len, NULL, false)) == NULL) { + phar_do_404(phar, fname, fname_len, f404); } else { char *tmp = NULL, sa = '\0'; sapi_header_line ctr = {0}; @@ -798,21 +783,22 @@ PHP_METHOD(Phar, webPhar) *tmp = sa; } - if (free_pathinfo) { - efree(path_info); - } - sapi_header_op(SAPI_HEADER_REPLACE, &ctr); sapi_send_headers(); efree((void *) ctr.line); - zend_bailout(); } + + if (is_entry_allocated) { + efree(entry); + } + + goto cleanup_skip_entry; } if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) || - (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) { - phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len); - zend_bailout(); + (info = phar_get_entry_info(phar, entry, entry_len, NULL, false)) == NULL) { + phar_do_404(phar, fname, fname_len, f404); + goto cleanup; } if (mimeoverride && zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) { @@ -830,15 +816,7 @@ PHP_METHOD(Phar, webPhar) code = Z_LVAL_P(val); } else { zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed"); - if (free_pathinfo) { - efree(path_info); - } - efree(pt); - efree(entry); -#ifdef PHP_WIN32 - efree(fname); -#endif - RETURN_THROWS(); + goto cleanup; } break; case IS_STRING: @@ -847,15 +825,7 @@ PHP_METHOD(Phar, webPhar) break; default: zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed"); - if (free_pathinfo) { - efree(path_info); - } - efree(pt); - efree(entry); -#ifdef PHP_WIN32 - efree(fname); -#endif - RETURN_THROWS(); + goto cleanup; } } } @@ -864,7 +834,22 @@ PHP_METHOD(Phar, webPhar) if (!mime_type) { code = phar_file_type(&PHAR_G(mime_types), entry, &mime_type); } - phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len); + status = phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len); + +cleanup: + efree(entry); +cleanup_skip_entry: + if (free_pathinfo) { + efree(path_info); + } + efree(pt); + efree(ru); + + if (status == PHAR_ACT_DO_EXIT) { + if (!EG(exception)) { + zend_throw_unwind_exit(); + } + } finish: ; #ifdef PHP_WIN32 @@ -899,7 +884,7 @@ PHP_METHOD(Phar, mungServer) phar_request_initialize(); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(mungvalues), data) { - + ZVAL_DEREF(data); if (Z_TYPE_P(data) != IS_STRING) { zend_throw_exception_ex(phar_ce_PharException, 0, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); RETURN_THROWS(); @@ -913,8 +898,10 @@ PHP_METHOD(Phar, mungServer) PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_NAME; } else if (zend_string_equals_literal(Z_STR_P(data), "SCRIPT_FILENAME")) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_FILENAME; + } else { + zend_throw_exception_ex(phar_ce_PharException, 0, "Invalid value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); + RETURN_THROWS(); } - // TODO Warning for invalid value? } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -928,9 +915,7 @@ PHP_METHOD(Phar, mungServer) */ PHP_METHOD(Phar, interceptFileFuncs) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); phar_intercept_functions(); } /* }}} */ @@ -941,11 +926,11 @@ PHP_METHOD(Phar, interceptFileFuncs) */ PHP_METHOD(Phar, createDefaultStub) { - char *index = NULL, *webindex = NULL, *error; + zend_string *index = NULL, *webindex = NULL; + char *error; zend_string *stub; - size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|p!p!", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|P!P!", &index, &webindex) == FAILURE) { RETURN_THROWS(); } @@ -1004,9 +989,7 @@ PHP_METHOD(Phar, loadPhar) /* {{{ Returns the api version */ PHP_METHOD(Phar, apiVersion) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_STRINGL(PHP_PHAR_API_VERSION, sizeof(PHP_PHAR_API_VERSION)-1); } /* }}}*/ @@ -1023,23 +1006,11 @@ PHP_METHOD(Phar, canCompress) phar_request_initialize(); switch (method) { case PHAR_ENT_COMPRESSED_GZ: - if (PHAR_G(has_zlib)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(PHAR_G(has_zlib)); case PHAR_ENT_COMPRESSED_BZ2: - if (PHAR_G(has_bz2)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(PHAR_G(has_bz2)); default: - if (PHAR_G(has_zlib) || PHAR_G(has_bz2)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(PHAR_G(has_zlib) || PHAR_G(has_bz2)); } } /* }}} */ @@ -1047,9 +1018,7 @@ PHP_METHOD(Phar, canCompress) /* {{{ Returns whether phar extension supports writing and creating phars */ PHP_METHOD(Phar, canWrite) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_BOOL(!PHAR_G(readonly)); } /* }}} */ @@ -1061,15 +1030,13 @@ PHP_METHOD(Phar, isValidPharFilename) const char *ext_str; size_t fname_len; size_t ext_len; - int is_executable; - bool executable = 1; + bool is_executable = true; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &is_executable) == FAILURE) { RETURN_THROWS(); } - is_executable = executable; - RETVAL_BOOL(phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, is_executable, 2, 1) == SUCCESS); + RETURN_BOOL(phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, is_executable, 2, true) == SUCCESS); } /* }}} */ @@ -1124,11 +1091,11 @@ PHP_METHOD(Phar, __construct) zend_long format = 0; phar_archive_object *phar_obj; phar_archive_data *phar_data; - zval *zobj = ZEND_THIS, arg1, arg2; + zval arg1, arg2; - phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); + phar_obj = PHAR_FETCH_INTERNAL(); - is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); + is_data = instanceof_function(Z_OBJCE_P(ZEND_THIS), phar_ce_data); if (is_data) { if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { @@ -1187,8 +1154,8 @@ PHP_METHOD(Phar, __construct) } if (is_data && phar_data->is_tar && phar_data->is_brandnew && format == PHAR_FORMAT_ZIP) { - phar_data->is_zip = 1; - phar_data->is_tar = 0; + phar_data->is_zip = true; + phar_data->is_tar = false; } if (fname == arch) { @@ -1228,7 +1195,7 @@ PHP_METHOD(Phar, __construct) ZVAL_LONG(&arg2, flags); zend_call_known_instance_method_with_2_params(spl_ce_RecursiveDirectoryIterator->constructor, - Z_OBJ_P(zobj), NULL, &arg1, &arg2); + Z_OBJ_P(ZEND_THIS), NULL, &arg1, &arg2); zval_ptr_dtor(&arg1); @@ -1247,9 +1214,7 @@ PHP_METHOD(Phar, __construct) /* {{{ Return array of supported signature types */ PHP_METHOD(Phar, getSupportedSignatures) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); @@ -1274,9 +1239,7 @@ PHP_METHOD(Phar, getSupportedSignatures) /* {{{ Return array of supported comparession algorithms */ PHP_METHOD(Phar, getSupportedCompression) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); phar_request_initialize(); @@ -1294,9 +1257,9 @@ PHP_METHOD(Phar, getSupportedCompression) /* {{{ Completely remove a phar archive from memory and disk */ PHP_METHOD(Phar, unlinkArchive) { - char *fname, *error, *arch, *entry; + char *fname, *error, *arch; size_t fname_len; - size_t arch_len, entry_len; + size_t arch_len; phar_archive_data *phar; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { @@ -1323,16 +1286,14 @@ PHP_METHOD(Phar, unlinkArchive) if ( zend_file_name && zend_string_starts_with_literal_ci(zend_file_name, "phar://") - && SUCCESS == phar_split_fname(ZSTR_VAL(zend_file_name), ZSTR_LEN(zend_file_name), &arch, &arch_len, &entry, &entry_len, 2, 0) + && SUCCESS == phar_split_fname(ZSTR_VAL(zend_file_name), ZSTR_LEN(zend_file_name), &arch, &arch_len, NULL, NULL, 2, 0) ) { if (arch_len == fname_len && !memcmp(arch, fname, arch_len)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar archive \"%s\" cannot be unlinked from within itself", fname); efree(arch); - efree(entry); RETURN_THROWS(); } efree(arch); - efree(entry); } if (phar->is_persistent) { @@ -1358,24 +1319,12 @@ PHP_METHOD(Phar, unlinkArchive) } /* }}} */ -#define PHAR_ARCHIVE_OBJECT() \ - zval *zobj = ZEND_THIS; \ - phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); \ - if (!phar_obj->archive) { \ - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ - "Cannot call method on an uninitialized Phar object"); \ - RETURN_THROWS(); \ - } - /* {{{ if persistent, remove from the cache */ PHP_METHOD(Phar, __destruct) { - zval *zobj = ZEND_THIS; - phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); + phar_archive_object *phar_obj = PHAR_FETCH_INTERNAL(); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (phar_obj->archive && phar_obj->archive->is_persistent) { zend_hash_str_del(&PHAR_G(phar_persist_map), (const char *) phar_obj->archive, sizeof(phar_obj->archive)); @@ -1392,17 +1341,55 @@ struct _phar_t { int count; }; +static zend_always_inline void phar_call_method_with_unwrap(zend_object *obj, const char *name, zval *rv) +{ + zend_call_method_with_0_params(obj, obj->ce, NULL, name, rv); + if (Z_ISREF_P(rv)) { + zend_unwrap_reference(rv); + } +} + +/* This is the same as phar_get_or_create_entry_data(), but allows overriding metadata via SplFileInfo. */ +static phar_entry_data *phar_build_entry_data(char *fname, size_t fname_len, char *path, size_t path_len, char **error, zval *file_info) +{ + uint32_t timestamp; + + /* Expects an instance of SplFileInfo if it is an object, which is verified in phar_build(). */ + if (Z_TYPE_P(file_info) == IS_OBJECT && Z_OBJCE_P(file_info)->type == ZEND_USER_CLASS) { + zval rv; + phar_call_method_with_unwrap(Z_OBJ_P(file_info), "getMTime", &rv); + + if (UNEXPECTED(Z_TYPE(rv) != IS_LONG)) { + /* Either it's a tentative type failure, an exception happened, or the function returned false to indicate failure. */ + *error = estrdup("getMTime() must return an int"); + return NULL; + } + + /* Sanity check bounds. See GH-14141. */ + if (ZEND_LONG_UINT_OVFL(Z_LVAL(rv))) { + *error = estrdup("timestamp is limited to 32-bit"); + return NULL; + } + + timestamp = Z_LVAL(rv); + } else { + timestamp = time(NULL); + } + + return phar_get_or_create_entry_data(fname, fname_len, path, path_len, "w+b", 0, error, true, timestamp); +} + static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ { zval *value; - bool close_fp = 1; + bool close_fp = true; struct _phar_t *p_obj = (struct _phar_t*) puser; size_t str_key_len, base_len = ZSTR_LEN(p_obj->base); phar_entry_data *data; php_stream *fp; size_t fname_len; size_t contents_len; - char *fname, *error = NULL, *base = ZSTR_VAL(p_obj->base), *save = NULL, *temp = NULL; + char *fname = NULL, *error = NULL, *base = ZSTR_VAL(p_obj->base), *save = NULL, *temp = NULL; zend_string *opened; char *str_key; zend_class_entry *ce = p_obj->c; @@ -1457,56 +1444,71 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ return ZEND_HASH_APPLY_STOP; } - close_fp = 0; + close_fp = false; opened = ZSTR_INIT_LITERAL("[stream]", 0); goto after_open_fp; case IS_OBJECT: if (instanceof_function(Z_OBJCE_P(value), spl_ce_SplFileInfo)) { - char *test = NULL; - spl_filesystem_object *intern = (spl_filesystem_object*)((char*)Z_OBJ_P(value) - Z_OBJ_P(value)->handlers->offset); + spl_filesystem_object *intern = PHAR_FETCH_INTERNAL_EX(value); if (!base_len) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Iterator %s returns an SplFileInfo object, so base directory must be specified", ZSTR_VAL(ce->name)); return ZEND_HASH_APPLY_STOP; } - switch (intern->type) { - case SPL_FS_DIR: { - zend_string *test_str = spl_filesystem_object_get_path(intern); - fname_len = spprintf(&fname, 0, "%s%c%s", ZSTR_VAL(test_str), DEFAULT_SLASH, intern->u.dir.entry.d_name); - zend_string_release_ex(test_str, /* persistent */ false); - if (php_stream_stat_path(fname, &ssb) == 0 && S_ISDIR(ssb.sb.st_mode)) { - /* ignore directories */ - efree(fname); - return ZEND_HASH_APPLY_KEEP; - } + zend_string *tmp_dir_str = NULL; - test = expand_filepath(fname, NULL); - efree(fname); + /* Take into account that SplFileObject may be overridden. + * The purpose here is to grab the path name of the file to add. */ + if (Z_OBJCE_P(value)->type == ZEND_USER_CLASS) { + zval rv; + phar_call_method_with_unwrap(Z_OBJ_P(value), "getPathname", &rv); - if (test) { - fname = test; - fname_len = strlen(fname); - } else { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Could not resolve file path"); - return ZEND_HASH_APPLY_STOP; + if (UNEXPECTED(Z_TYPE(rv) != IS_STRING)) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "getPathname() must return a string"); + return ZEND_HASH_APPLY_STOP; + } + tmp_dir_str = Z_STR(rv); + } else { + /* Not a user class, so we can grab the data internally quickly. */ + switch (intern->type) { + case SPL_FS_DIR: { + zend_string *test_str = spl_filesystem_object_get_path(intern); + const char slash = DEFAULT_SLASH; + tmp_dir_str = zend_string_concat3( + ZSTR_VAL(test_str), ZSTR_LEN(test_str), + &slash, 1, + intern->u.dir.entry.d_name, strlen(intern->u.dir.entry.d_name) + ); + zend_string_release_ex(test_str, /* persistent */ false); + break; } + case SPL_FS_INFO: + case SPL_FS_FILE: + fname = expand_filepath(ZSTR_VAL(intern->file_name), NULL); + break; + } + } - save = fname; - goto phar_spl_fileinfo; + if (tmp_dir_str) { + if (php_stream_stat_path(ZSTR_VAL(tmp_dir_str), &ssb) == 0 && S_ISDIR(ssb.sb.st_mode)) { + /* ignore directories */ + zend_string_release_ex(tmp_dir_str, /* persistent */ false); + return ZEND_HASH_APPLY_KEEP; } - case SPL_FS_INFO: - case SPL_FS_FILE: - fname = expand_filepath(ZSTR_VAL(intern->file_name), NULL); - if (!fname) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Could not resolve file path"); - return ZEND_HASH_APPLY_STOP; - } - fname_len = strlen(fname); - save = fname; - goto phar_spl_fileinfo; + fname = expand_filepath(ZSTR_VAL(tmp_dir_str), NULL); + zend_string_release_ex(tmp_dir_str, /* persistent */ false); + } + + if (!fname) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Could not resolve file path"); + return ZEND_HASH_APPLY_STOP; } + + fname_len = strlen(fname); + save = fname; + goto phar_spl_fileinfo; } ZEND_FALLTHROUGH; default: @@ -1637,7 +1639,7 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ return ZEND_HASH_APPLY_KEEP; } - if (!(data = phar_get_or_create_entry_data(phar_obj->archive->fname, phar_obj->archive->fname_len, str_key, str_key_len, "w+b", 0, &error, 1))) { + if (!(data = phar_build_entry_data(phar_obj->archive->fname, phar_obj->archive->fname_len, str_key, str_key_len, &error, value))) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s cannot be created: %s", str_key, error); efree(error); @@ -1673,8 +1675,6 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ data->internal_file->offset_abs = data->internal_file->offset = php_stream_tell(p_obj->fp); data->fp = NULL; php_stream_copy_to_stream_ex(fp, p_obj->fp, PHP_STREAM_COPY_ALL, &contents_len); - data->internal_file->uncompressed_filesize = data->internal_file->compressed_filesize = - php_stream_tell(p_obj->fp) - data->internal_file->offset; if (php_stream_stat(fp, &ssb) != -1) { data->internal_file->flags = ssb.sb.st_mode & PHAR_ENT_PERM_MASK ; } else { @@ -1716,8 +1716,8 @@ static int phar_build(zend_object_iterator *iter, void *puser) /* {{{ */ PHP_METHOD(Phar, buildFromDirectory) { char *error; - bool apply_reg = 0; - zval arg, arg2, iter, iteriter, regexiter; + bool apply_reg = false; + zval iter, iteriter, regexiter; struct _phar_t pass; zend_string *dir, *regex = NULL; @@ -1733,54 +1733,31 @@ PHP_METHOD(Phar, buildFromDirectory) RETURN_THROWS(); } - if (SUCCESS != object_init_ex(&iter, spl_ce_RecursiveDirectoryIterator)) { - zval_ptr_dtor(&iter); - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname); - RETURN_THROWS(); - } - - ZVAL_STR(&arg, dir); - ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS); - - zend_call_known_instance_method_with_2_params(spl_ce_RecursiveDirectoryIterator->constructor, - Z_OBJ(iter), NULL, &arg, &arg2); + zval args[2]; + ZVAL_STR(&args[0], dir); + ZVAL_LONG(&args[1], SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS); - if (EG(exception)) { - zval_ptr_dtor(&iter); - RETURN_THROWS(); - } - - if (SUCCESS != object_init_ex(&iteriter, spl_ce_RecursiveIteratorIterator)) { - zval_ptr_dtor(&iter); - zval_ptr_dtor(&iteriter); - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate directory iterator for %s", phar_obj->archive->fname); + if (SUCCESS != object_init_with_constructor(&iter, spl_ce_RecursiveDirectoryIterator, 2, args, NULL)) { RETURN_THROWS(); } - zend_call_known_instance_method_with_1_params(spl_ce_RecursiveIteratorIterator->constructor, - Z_OBJ(iteriter), NULL, &iter); - - if (EG(exception)) { + if (SUCCESS != object_init_with_constructor(&iteriter, spl_ce_RecursiveIteratorIterator, 1, &iter, NULL)) { zval_ptr_dtor(&iter); - zval_ptr_dtor(&iteriter); RETURN_THROWS(); } zval_ptr_dtor(&iter); if (regex && ZSTR_LEN(regex) > 0) { - apply_reg = 1; + apply_reg = true; + + ZVAL_COPY_VALUE(&args[0], &iteriter); + ZVAL_STR(&args[1], regex); - if (SUCCESS != object_init_ex(®exiter, spl_ce_RegexIterator)) { + if (SUCCESS != object_init_with_constructor(®exiter, spl_ce_RegexIterator, 2, args, NULL)) { zval_ptr_dtor(&iteriter); - zval_ptr_dtor(®exiter); - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate regex iterator for %s", phar_obj->archive->fname); RETURN_THROWS(); } - - ZVAL_STR(&arg2, regex); - zend_call_known_instance_method_with_2_params(spl_ce_RegexIterator->constructor, - Z_OBJ(regexiter), NULL, &iteriter, &arg2); } array_init(return_value); @@ -1943,7 +1920,7 @@ static zend_result phar_copy_file_contents(phar_entry_info *entry, php_stream *f ZEND_ASSERT(!entry->link); - if (FAILURE == phar_open_entry_fp(entry, &error, 1)) { + if (FAILURE == phar_open_entry_fp(entry, &error, true)) { if (error) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot convert phar archive \"%s\", unable to open entry \"%s\" contents: %s", entry->phar->fname, ZSTR_VAL(entry->filename), error); @@ -1956,9 +1933,9 @@ static zend_result phar_copy_file_contents(phar_entry_info *entry, php_stream *f } /* copy old contents in entirety */ - phar_seek_efp(entry, 0, SEEK_SET, 0, 0); + phar_seek_efp(entry, 0, SEEK_SET, 0, false); offset = php_stream_tell(fp); - if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, false), fp, entry->uncompressed_filesize, NULL)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot convert phar archive \"%s\", unable to copy entry \"%s\" contents", entry->phar->fname, ZSTR_VAL(entry->filename)); return FAILURE; @@ -2149,7 +2126,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* goto err_reused_oldpath; } if (!phar->is_data) { - if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 1, 1, 1)) { + if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 1, 1, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar \"%s\" has invalid extension %s", phar->fname, ext); goto err_reused_oldpath; } @@ -2172,7 +2149,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* } else { - if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 0, 1, 1)) { + if (SUCCESS != phar_detect_phar_fname_ext(newpath, phar->fname_len, (const char **) &(phar->ext), &ext_len, 0, 1, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "data phar \"%s\" has invalid extension %s", phar->fname, ext); goto err_reused_oldpath; } @@ -2190,7 +2167,7 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* goto err_oldpath; } - phar_flush_ex(phar, NULL, 1, &error); + phar_flush_ex(phar, NULL, true, &error); if (error) { zend_hash_str_del(&(PHAR_G(phar_fname_map)), newpath, phar->fname_len); @@ -2208,17 +2185,12 @@ static zend_object *phar_rename_archive(phar_archive_data **sphar, char *ext) /* ce = phar_ce_archive; } - ZVAL_NULL(&ret); - if (SUCCESS != object_init_ex(&ret, ce)) { - zval_ptr_dtor(&ret); - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Unable to instantiate phar object when converting archive \"%s\"", phar->fname); + ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len); + zend_result result = object_init_with_constructor(&ret, ce, 1, &arg1, NULL); + zval_ptr_dtor_str(&arg1); + if (SUCCESS != result) { return NULL; } - - ZVAL_STRINGL(&arg1, phar->fname, phar->fname_len); - - zend_call_known_instance_method_with_1_params(ce->constructor, Z_OBJ(ret), NULL, &arg1); - zval_ptr_dtor(&arg1); return Z_OBJ(ret); err_reused_oldpath: @@ -2256,13 +2228,13 @@ static zend_object *phar_convert_to_other(phar_archive_data *source, int convert switch (convert) { case PHAR_FORMAT_TAR: - phar->is_tar = 1; + phar->is_tar = true; break; case PHAR_FORMAT_ZIP: - phar->is_zip = 1; + phar->is_zip = true; break; default: - phar->is_data = 0; + phar->is_data = false; break; } @@ -2361,12 +2333,11 @@ static zend_object *phar_convert_to_other(phar_archive_data *source, int convert PHP_METHOD(Phar, convertToExecutable) { char *ext = NULL; - int is_data; size_t ext_len = 0; uint32_t flags; zend_object *ret; zend_long format, method; - bool format_is_null = 1, method_is_null = 1; + bool format_is_null = true, method_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l!s!", &format, &format_is_null, &method, &method_is_null, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); @@ -2452,8 +2423,8 @@ PHP_METHOD(Phar, convertToExecutable) } } - is_data = phar_obj->archive->is_data; - phar_obj->archive->is_data = 0; + bool is_data = phar_obj->archive->is_data; + phar_obj->archive->is_data = false; ret = phar_convert_to_other(phar_obj->archive, format, ext, flags); phar_obj->archive->is_data = is_data; @@ -2472,12 +2443,11 @@ PHP_METHOD(Phar, convertToExecutable) PHP_METHOD(Phar, convertToData) { char *ext = NULL; - int is_data; size_t ext_len = 0; uint32_t flags; zend_object *ret; zend_long format, method; - bool format_is_null = 1, method_is_null = 1; + bool format_is_null = true, method_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!l!s!", &format, &format_is_null, &method, &method_is_null, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); @@ -2562,8 +2532,8 @@ PHP_METHOD(Phar, convertToData) } } - is_data = phar_obj->archive->is_data; - phar_obj->archive->is_data = 1; + bool is_data = phar_obj->archive->is_data; + phar_obj->archive->is_data = true; ret = phar_convert_to_other(phar_obj->archive, (int)format, ext, flags); phar_obj->archive->is_data = is_data; @@ -2580,9 +2550,7 @@ PHP_METHOD(Phar, convertToData) */ PHP_METHOD(Phar, isCompressed) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2603,9 +2571,7 @@ PHP_METHOD(Phar, isWritable) { php_stream_statbuf ssb; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2614,11 +2580,8 @@ PHP_METHOD(Phar, isWritable) } if (SUCCESS != php_stream_stat_path(phar_obj->archive->fname, &ssb)) { - if (phar_obj->archive->is_brandnew) { - /* assume it works if the file doesn't exist yet */ - RETURN_TRUE; - } - RETURN_FALSE; + /* assume it works if the file doesn't exist yet */ + RETURN_BOOL(phar_obj->archive->is_brandnew); } RETURN_BOOL((ssb.sb.st_mode & (S_IWOTH | S_IWGRP | S_IWUSR)) != 0); @@ -2676,9 +2639,7 @@ PHP_METHOD(Phar, delete) /* {{{ Returns the alias for the Phar or NULL. */ PHP_METHOD(Phar, getAlias) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2691,9 +2652,7 @@ PHP_METHOD(Phar, getAlias) /* {{{ Returns the real path to the phar archive on disk */ PHP_METHOD(Phar, getPath) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2710,7 +2669,7 @@ PHP_METHOD(Phar, setAlias) char *error, *oldalias; phar_archive_data *fd_ptr; size_t oldalias_len; - int old_temp, readd = 0; + bool old_temp, readd = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &new_alias) == FAILURE) { RETURN_THROWS(); @@ -2743,37 +2702,33 @@ PHP_METHOD(Phar, setAlias) RETURN_TRUE; } if (NULL != (fd_ptr = zend_hash_find_ptr(&(PHAR_G(phar_alias_map)), new_alias))) { - spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", ZSTR_VAL(new_alias), fd_ptr->fname); - if (SUCCESS == phar_free_alias(fd_ptr, ZSTR_VAL(new_alias), ZSTR_LEN(new_alias))) { - efree(error); - goto valid_alias; + if (SUCCESS != phar_free_alias(fd_ptr, ZSTR_VAL(new_alias), ZSTR_LEN(new_alias))) { + zend_throw_exception_ex(phar_ce_PharException, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", ZSTR_VAL(new_alias), fd_ptr->fname); + RETURN_THROWS(); } - zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); - efree(error); - RETURN_THROWS(); - } - if (!phar_validate_alias(ZSTR_VAL(new_alias), ZSTR_LEN(new_alias))) { + } else if (!phar_validate_alias(ZSTR_VAL(new_alias), ZSTR_LEN(new_alias))) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Invalid alias \"%s\" specified for phar \"%s\"", ZSTR_VAL(new_alias), phar_obj->archive->fname); RETURN_THROWS(); } -valid_alias: if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); } if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len); - readd = 1; + readd = true; } + ZEND_ASSERT(!phar_obj->archive->is_persistent); + oldalias = phar_obj->archive->alias; oldalias_len = phar_obj->archive->alias_len; old_temp = phar_obj->archive->is_temporary_alias; phar_obj->archive->alias_len = ZSTR_LEN(new_alias); if (phar_obj->archive->alias_len) { - phar_obj->archive->alias = pestrndup(ZSTR_VAL(new_alias), ZSTR_LEN(new_alias), phar_obj->archive->is_persistent); + phar_obj->archive->alias = estrndup(ZSTR_VAL(new_alias), ZSTR_LEN(new_alias)); } else { phar_obj->archive->alias = NULL; } @@ -2782,7 +2737,7 @@ PHP_METHOD(Phar, setAlias) phar_flush(phar_obj->archive, &error); if (error) { - pefree(phar_obj->archive->alias, phar_obj->archive->is_persistent); + efree(phar_obj->archive->alias); phar_obj->archive->alias = oldalias; phar_obj->archive->alias_len = oldalias_len; phar_obj->archive->is_temporary_alias = old_temp; @@ -2807,9 +2762,7 @@ PHP_METHOD(Phar, setAlias) /* {{{ Return version info of Phar archive */ PHP_METHOD(Phar, getVersion) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2820,9 +2773,7 @@ PHP_METHOD(Phar, getVersion) /* {{{ Do not flush a writeable phar (save its contents) until explicitly requested */ PHP_METHOD(Phar, startBuffering) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2833,9 +2784,7 @@ PHP_METHOD(Phar, startBuffering) /* {{{ Returns whether write operations are flushing to disk immediately. */ PHP_METHOD(Phar, isBuffering) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2848,9 +2797,7 @@ PHP_METHOD(Phar, stopBuffering) { char *error; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -2972,12 +2919,11 @@ PHP_METHOD(Phar, setStub) */ PHP_METHOD(Phar, setDefaultStub) { - char *index = NULL, *webindex = NULL, *error = NULL; + zend_string *index = NULL, *webindex = NULL; zend_string *stub = NULL; - size_t index_len = 0, webindex_len = 0; - int created_stub = 0; + bool created_stub = false; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|P!P!", &index, &webindex) == FAILURE) { RETURN_THROWS(); } @@ -3005,6 +2951,7 @@ PHP_METHOD(Phar, setDefaultStub) RETURN_THROWS(); } + char *error = NULL; if (!phar_obj->archive->is_tar && !phar_obj->archive->is_zip) { stub = phar_create_default_stub(index, webindex, &error); @@ -3096,9 +3043,7 @@ PHP_METHOD(Phar, setSignatureAlgorithm) /* {{{ Returns a hash signature, or FALSE if the archive is unsigned. */ PHP_METHOD(Phar, getSignature) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -3143,9 +3088,7 @@ PHP_METHOD(Phar, getSignature) /* {{{ Return whether phar was modified */ PHP_METHOD(Phar, getModified) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -3172,7 +3115,7 @@ static int phar_set_compression(zval *zv, void *argument) /* {{{ */ static int phar_test_compression(zval *zv, void *argument) /* {{{ */ { - phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv); + const phar_entry_info *entry = Z_PTR_P(zv); if (entry->is_deleted) { return ZEND_HASH_APPLY_KEEP; @@ -3181,12 +3124,14 @@ static int phar_test_compression(zval *zv, void *argument) /* {{{ */ if (!PHAR_G(has_bz2)) { if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) { *(int *) argument = 0; + return ZEND_HASH_APPLY_STOP; } } if (!PHAR_G(has_zlib)) { if (entry->flags & PHAR_ENT_COMPRESSED_GZ) { *(int *) argument = 0; + return ZEND_HASH_APPLY_STOP; } } @@ -3403,10 +3348,7 @@ PHP_METHOD(Phar, decompressFiles) { char *error; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -3542,7 +3484,6 @@ PHP_METHOD(Phar, copy) PHP_METHOD(Phar, offsetExists) { zend_string *file_name; - phar_entry_info *entry; if (zend_parse_parameters(ZEND_NUM_ARGS(), "P", &file_name) == FAILURE) { RETURN_THROWS(); @@ -3550,19 +3491,15 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_hash_exists(&phar_obj->archive->manifest, file_name)) { - if (NULL != (entry = zend_hash_find_ptr(&phar_obj->archive->manifest, file_name))) { - if (entry->is_deleted) { - /* entry is deleted, but has not been flushed to disk yet */ - RETURN_FALSE; - } - } - - if (zend_string_starts_with_literal(file_name, ".phar")) { - /* none of these are real files, so they don't exist */ + const phar_entry_info *entry = zend_hash_find_ptr(&phar_obj->archive->manifest, file_name); + if (entry != NULL) { + if (entry->is_deleted) { + /* entry is deleted, but has not been flushed to disk yet */ RETURN_FALSE; } - RETURN_TRUE; + + /* none of these are real files, so they don't exist */ + RETURN_BOOL(!zend_string_starts_with_literal(file_name, ".phar")); } else { /* If the info class is not based on PharFileInfo, directories are not directly instantiable */ if (UNEXPECTED(!instanceof_function(phar_obj->spl.info_class, phar_ce_entry))) { @@ -3587,7 +3524,7 @@ PHP_METHOD(Phar, offsetGet) PHAR_ARCHIVE_OBJECT(); /* security is 0 here so that we can get a better error message than "entry doesn't exist" */ - if (!(entry = phar_get_entry_info_dir(phar_obj->archive, ZSTR_VAL(file_name), ZSTR_LEN(file_name), 1, &error, 0))) { + if (!(entry = phar_get_entry_info_dir(phar_obj->archive, ZSTR_VAL(file_name), ZSTR_LEN(file_name), 1, &error, false))) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist%s%s", ZSTR_VAL(file_name), error?", ":"", error?error:""); } else { if (zend_string_equals_literal(file_name, ".phar/stub.php")) { @@ -3660,7 +3597,7 @@ static void phar_add_file(phar_archive_data **pphar, zend_string *file_name, con } #endif - if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, 1))) { + if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, filename, filename_len, "w+b", 0, &error, true, time(NULL)))) { if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist and cannot be created: %s", filename, error); efree(error); @@ -3732,7 +3669,7 @@ static void phar_mkdir(phar_archive_data **pphar, zend_string *dir_name) char *error; phar_entry_data *data; - if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, ZSTR_VAL(dir_name), ZSTR_LEN(dir_name), "w+b", 2, &error, 1))) { + if (!(data = phar_get_or_create_entry_data((*pphar)->fname, (*pphar)->fname_len, ZSTR_VAL(dir_name), ZSTR_LEN(dir_name), "w+b", 2, &error, true, time(NULL)))) { if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Directory %s does not exist and cannot be created: %s", ZSTR_VAL(dir_name), error); efree(error); @@ -3925,9 +3862,7 @@ PHP_METHOD(Phar, getStub) php_stream_filter *filter = NULL; phar_entry_info *stub; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -3942,15 +3877,15 @@ PHP_METHOD(Phar, getStub) RETURN_THROWS(); } if (stub->flags & PHAR_ENT_COMPRESSION_MASK) { - char *filter_name; + const char *filter_name = phar_decompress_filter(stub, false); - if ((filter_name = phar_decompress_filter(stub, 0)) != NULL) { + if (filter_name != NULL) { filter = php_stream_filter_create(filter_name, NULL, php_stream_is_persistent(fp)); } else { filter = NULL; } if (!filter) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", phar_obj->archive->fname, phar_decompress_filter(stub, 1)); + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "phar error: unable to read stub of phar \"%s\" (cannot create %s filter)", phar_obj->archive->fname, phar_decompress_filter(stub, true)); RETURN_THROWS(); } php_stream_filter_append(&fp->readfilters, filter); @@ -4016,9 +3951,7 @@ PHP_METHOD(Phar, getStub) /* {{{ Returns TRUE if the phar has global metadata, FALSE otherwise. */ PHP_METHOD(Phar, hasMetadata) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -4047,7 +3980,7 @@ PHP_METHOD(Phar, getMetadata) /* }}} */ /* {{{ Modifies the phar metadata or throws */ -static zend_result serialize_metadata_or_throw(phar_metadata_tracker *tracker, int persistent, zval *metadata) +static zend_result serialize_metadata_or_throw(phar_metadata_tracker *tracker, bool persistent, zval *metadata) { php_serialize_data_t metadata_hash; smart_str main_metadata_str = {0}; @@ -4119,9 +4052,7 @@ PHP_METHOD(Phar, delMetadata) { char *error; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ARCHIVE_OBJECT(); @@ -4148,7 +4079,7 @@ PHP_METHOD(Phar, delMetadata) } /* }}} */ -static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, char *dest, size_t dest_len, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, const zend_string *path, char **error) /* {{{ */ { php_stream_statbuf ssb; size_t len; @@ -4176,7 +4107,7 @@ static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, cha if (virtual_file_ex(&new_state, ZSTR_VAL(entry->filename), NULL, CWD_EXPAND) != 0 || new_state.cwd_length <= 1) { if (EINVAL == errno && ZSTR_LEN(entry->filename) > 50) { - spprintf(error, 4096, "Cannot extract \"%.50s...\" to \"%s...\", extracted filename is too long for filesystem", ZSTR_VAL(entry->filename), dest); + spprintf(error, 4096, "Cannot extract \"%.50s...\" to \"%s...\", extracted filename is too long for filesystem", ZSTR_VAL(entry->filename), ZSTR_VAL(path)); } else { spprintf(error, 4096, "Cannot extract \"%s\", internal error", ZSTR_VAL(entry->filename)); } @@ -4198,7 +4129,7 @@ static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, cha } #endif - len = spprintf(&fullpath, 0, "%s/%s", dest, filename); + len = spprintf(&fullpath, 0, "%s/%s", ZSTR_VAL(path), filename); if (len >= MAXPATHLEN) { /* truncate for error message */ @@ -4239,9 +4170,9 @@ static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, cha slash = zend_memrchr(filename, '/', filename_len); if (slash) { - fullpath[dest_len + (slash - filename) + 1] = '\0'; + fullpath[ZSTR_LEN(path) + (slash - filename) + 1] = '\0'; } else { - fullpath[dest_len] = '\0'; + fullpath[ZSTR_LEN(path)] = '\0'; } if (FAILURE == php_stream_stat_path(fullpath, &ssb)) { @@ -4263,9 +4194,9 @@ static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, cha } if (slash) { - fullpath[dest_len + (slash - filename) + 1] = '/'; + fullpath[ZSTR_LEN(path) + (slash - filename) + 1] = '/'; } else { - fullpath[dest_len] = '/'; + fullpath[ZSTR_LEN(path)] = '/'; } filename = NULL; @@ -4284,10 +4215,11 @@ static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, cha return FAILURE; } - if ((phar_get_fp_type(entry) == PHAR_FP && (entry->flags & PHAR_ENT_COMPRESSION_MASK)) || !phar_get_efp(entry, 0)) { - if (FAILURE == phar_open_entry_fp(entry, error, 1)) { - if (error) { - spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer: %s", ZSTR_VAL(entry->filename), fullpath, *error); + if ((phar_get_fp_type(entry) == PHAR_FP && (entry->flags & PHAR_ENT_COMPRESSION_MASK)) || !phar_get_efp(entry, false)) { + char *open_entry_error = NULL; + if (FAILURE == phar_open_entry_fp(entry, &open_entry_error, true)) { + if (open_entry_error) { + spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer: %s", ZSTR_VAL(entry->filename), fullpath, open_entry_error); } else { spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to open internal file pointer", ZSTR_VAL(entry->filename), fullpath); } @@ -4297,14 +4229,14 @@ static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, cha } } - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) { spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", unable to seek internal file pointer", ZSTR_VAL(entry->filename), fullpath); efree(fullpath); php_stream_close(fp); return FAILURE; } - if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, false), fp, entry->uncompressed_filesize, NULL)) { spprintf(error, 4096, "Cannot extract \"%s\" to \"%s\", copying contents failed", ZSTR_VAL(entry->filename), fullpath); efree(fullpath); php_stream_close(fp); @@ -4325,28 +4257,28 @@ static zend_result phar_extract_file(bool overwrite, phar_entry_info *entry, cha } /* }}} */ -static int extract_helper(phar_archive_data *archive, zend_string *search, char *pathto, size_t pathto_len, bool overwrite, char **error) { /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 3, 5) static int extract_helper(const phar_archive_data *archive, zend_string *search, const zend_string *path_to, bool overwrite, char **error) { /* {{{ */ int extracted = 0; phar_entry_info *entry; if (!search) { /* nothing to match -- extract all files */ ZEND_HASH_MAP_FOREACH_PTR(&archive->manifest, entry) { - if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, error)) return -1; + if (FAILURE == phar_extract_file(overwrite, entry, path_to, error)) return -1; extracted++; } ZEND_HASH_FOREACH_END(); } else if (ZSTR_LEN(search) > 0 && '/' == ZSTR_VAL(search)[ZSTR_LEN(search) - 1]) { /* ends in "/" -- extract all entries having that prefix */ ZEND_HASH_MAP_FOREACH_PTR(&archive->manifest, entry) { if (!zend_string_starts_with(entry->filename, search)) continue; - if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, error)) return -1; + if (FAILURE == phar_extract_file(overwrite, entry, path_to, error)) return -1; extracted++; } ZEND_HASH_FOREACH_END(); } else { /* otherwise, looking for an exact match */ entry = zend_hash_find_ptr(&archive->manifest, search); if (NULL == entry) return 0; - if (FAILURE == phar_extract_file(overwrite, entry, pathto, pathto_len, error)) return -1; + if (FAILURE == phar_extract_file(overwrite, entry, path_to, error)) return -1; return 1; } @@ -4359,9 +4291,8 @@ PHP_METHOD(Phar, extractTo) { php_stream *fp; php_stream_statbuf ssb; - char *pathto; + zend_string *path_to; zend_string *filename = NULL; - size_t pathto_len; int ret; zval *zval_file; HashTable *files_ht = NULL; @@ -4369,7 +4300,7 @@ PHP_METHOD(Phar, extractTo) char *error = NULL; ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_PATH(pathto, pathto_len) + Z_PARAM_PATH_STR(path_to) Z_PARAM_OPTIONAL Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(files_ht, filename) Z_PARAM_BOOL(overwrite) @@ -4387,30 +4318,27 @@ PHP_METHOD(Phar, extractTo) php_stream_close(fp); - if (pathto_len < 1) { + if (ZSTR_LEN(path_to) == 0) { zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Invalid argument, extraction path must be non-zero length"); RETURN_THROWS(); } - if (pathto_len >= MAXPATHLEN) { - char *tmp = estrndup(pathto, 50); - /* truncate for error message */ - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Cannot extract to \"%s...\", destination directory is too long for filesystem", tmp); - efree(tmp); + if (ZSTR_LEN(path_to) >= MAXPATHLEN) { + zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Cannot extract to \"%.50s...\", destination directory is too long for filesystem", ZSTR_VAL(path_to)); RETURN_THROWS(); } - if (php_stream_stat_path(pathto, &ssb) < 0) { - ret = php_stream_mkdir(pathto, 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); + if (php_stream_stat_path(ZSTR_VAL(path_to), &ssb) < 0) { + ret = php_stream_mkdir(ZSTR_VAL(path_to), 0777, PHP_STREAM_MKDIR_RECURSIVE, NULL); if (!ret) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, - "Unable to create path \"%s\" for extraction", pathto); + "Unable to create path \"%s\" for extraction", ZSTR_VAL(path_to)); RETURN_THROWS(); } } else if (!(ssb.sb.st_mode & S_IFDIR)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, - "Unable to use path \"%s\" for extraction, it is a file, must be a directory", pathto); + "Unable to use path \"%s\" for extraction, it is a file, must be a directory", ZSTR_VAL(path_to)); RETURN_THROWS(); } @@ -4426,7 +4354,7 @@ PHP_METHOD(Phar, extractTo) "Invalid argument, array of filenames to extract contains non-string value"); RETURN_THROWS(); } - switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), pathto, pathto_len, overwrite, &error)) { + switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), path_to, overwrite, &error)) { case -1: zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", phar_obj->archive->fname, error); @@ -4442,7 +4370,7 @@ PHP_METHOD(Phar, extractTo) RETURN_TRUE; } - ret = extract_helper(phar_obj->archive, filename, pathto, pathto_len, overwrite, &error); + ret = extract_helper(phar_obj->archive, filename, path_to, overwrite, &error); if (-1 == ret) { zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", phar_obj->archive->fname, error); @@ -4467,13 +4395,13 @@ PHP_METHOD(PharFileInfo, __construct) phar_entry_object *entry_obj; phar_entry_info *entry_info; phar_archive_data *phar_data; - zval *zobj = ZEND_THIS, arg1; + zval arg1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_THROWS(); } - entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); + entry_obj = PHAR_FETCH_INTERNAL(); if (entry_obj->entry) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot call constructor twice"); @@ -4500,7 +4428,7 @@ PHP_METHOD(PharFileInfo, __construct) RETURN_THROWS(); } - if ((entry_info = phar_get_entry_info_dir(phar_data, entry, entry_len, 1, &error, 1)) == NULL) { + if ((entry_info = phar_get_entry_info_dir(phar_data, entry, entry_len, 1, &error, true)) == NULL) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Cannot access phar file entry '%s' in archive '%s'%s%s", entry, arch, error ? ", " : "", error ? error : ""); efree(arch); @@ -4513,7 +4441,7 @@ PHP_METHOD(PharFileInfo, __construct) entry_obj->entry = entry_info; if (!entry_info->is_persistent && !entry_info->is_temp_dir) { - ++entry_info->fp_refcount; + ++entry_info->fileinfo_lock_count; /* The phar data must exist to keep the alias locked. */ ZEND_ASSERT(!phar_data->is_persistent); ++phar_data->refcount; @@ -4522,35 +4450,32 @@ PHP_METHOD(PharFileInfo, __construct) ZVAL_STRINGL(&arg1, fname, fname_len); zend_call_known_instance_method_with_1_params(spl_ce_SplFileInfo->constructor, - Z_OBJ_P(zobj), NULL, &arg1); + Z_OBJ_P(ZEND_THIS), NULL, &arg1); zval_ptr_dtor(&arg1); } /* }}} */ -#define PHAR_ENTRY_OBJECT() \ - zval *zobj = ZEND_THIS; \ - phar_entry_object *entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); \ +#define PHAR_ENTRY_OBJECT_EX(throw) \ + phar_entry_object *entry_obj = PHAR_FETCH_INTERNAL(); \ if (!entry_obj->entry) { \ - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ - "Cannot call method on an uninitialized PharFileInfo object"); \ - RETURN_THROWS(); \ + if (throw) { \ + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ + "Cannot call method on an uninitialized PharFileInfo object"); \ + } \ + return; \ } +#define PHAR_ENTRY_OBJECT() PHAR_ENTRY_OBJECT_EX(true) + /* {{{ clean up directory-based entry objects */ PHP_METHOD(PharFileInfo, __destruct) { - zval *zobj = ZEND_THIS; - phar_entry_object *entry_obj = (phar_entry_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); + ZEND_PARSE_PARAMETERS_NONE(); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + PHAR_ENTRY_OBJECT_EX(false); phar_entry_info *entry = entry_obj->entry; - if (!entry) { - return; - } if (entry->is_temp_dir) { if (entry->filename) { @@ -4561,7 +4486,7 @@ PHP_METHOD(PharFileInfo, __destruct) efree(entry); entry_obj->entry = NULL; } else if (!entry->is_persistent) { - --entry->fp_refcount; + --entry->fileinfo_lock_count; /* The entry itself still lives in the manifest, * which will either be freed here if the file info was the last reference; or freed later. */ entry_obj->entry = NULL; @@ -4573,9 +4498,7 @@ PHP_METHOD(PharFileInfo, __destruct) /* {{{ Returns the compressed size */ PHP_METHOD(PharFileInfo, getCompressedSize) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -4587,7 +4510,7 @@ PHP_METHOD(PharFileInfo, getCompressedSize) PHP_METHOD(PharFileInfo, isCompressed) { zend_long method; - bool method_is_null = 1; + bool method_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &method, &method_is_null) == FAILURE) { RETURN_THROWS(); @@ -4616,9 +4539,7 @@ PHP_METHOD(PharFileInfo, isCompressed) /* {{{ Returns CRC32 code or throws an exception if not CRC checked */ PHP_METHOD(PharFileInfo, getCRC32) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -4640,9 +4561,7 @@ PHP_METHOD(PharFileInfo, getCRC32) /* {{{ Returns whether file entry is CRC checked */ PHP_METHOD(PharFileInfo, isCRCChecked) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -4653,9 +4572,7 @@ PHP_METHOD(PharFileInfo, isCRCChecked) /* {{{ Returns the Phar file entry flags */ PHP_METHOD(PharFileInfo, getPharFlags) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -4728,9 +4645,7 @@ PHP_METHOD(PharFileInfo, chmod) /* {{{ Returns the metadata of the entry */ PHP_METHOD(PharFileInfo, hasMetadata) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -4813,9 +4728,7 @@ PHP_METHOD(PharFileInfo, delMetadata) { char *error; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -4870,9 +4783,7 @@ PHP_METHOD(PharFileInfo, getContent) phar_entry_info *link; zend_string *str; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -4888,20 +4799,20 @@ PHP_METHOD(PharFileInfo, getContent) link = entry_obj->entry; } - if (SUCCESS != phar_open_entry_fp(link, &error, 0)) { + if (SUCCESS != phar_open_entry_fp(link, &error, false)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar error: Cannot retrieve contents, \"%s\" in phar \"%s\": %s", ZSTR_VAL(entry_obj->entry->filename), entry_obj->entry->phar->fname, error); efree(error); RETURN_THROWS(); } - if (!(fp = phar_get_efp(link, 0))) { + if (!(fp = phar_get_efp(link, false))) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar error: Cannot retrieve contents of \"%s\" in phar \"%s\"", ZSTR_VAL(entry_obj->entry->filename), entry_obj->entry->phar->fname); RETURN_THROWS(); } - phar_seek_efp(link, 0, SEEK_SET, 0, 0); + phar_seek_efp(link, 0, SEEK_SET, 0, false); str = php_stream_copy_to_mem(fp, link->uncompressed_filesize, 0); if (str) { RETURN_STR(str); @@ -4971,7 +4882,7 @@ PHP_METHOD(PharFileInfo, compress) } /* decompress this file indirectly */ - if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) { + if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar error: Cannot decompress bzip2-compressed file \"%s\" in phar \"%s\" in order to compress with gzip: %s", ZSTR_VAL(entry_obj->entry->filename), entry_obj->entry->phar->fname, error); efree(error); @@ -5002,7 +4913,7 @@ PHP_METHOD(PharFileInfo, compress) } /* decompress this file indirectly */ - if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) { + if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar error: Cannot decompress gzip-compressed file \"%s\" in phar \"%s\" in order to compress with bzip2: %s", ZSTR_VAL(entry_obj->entry->filename), entry_obj->entry->phar->fname, error); efree(error); @@ -5044,9 +4955,7 @@ PHP_METHOD(PharFileInfo, decompress) char *error; char *compression_type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHAR_ENTRY_OBJECT(); @@ -5107,7 +5016,7 @@ PHP_METHOD(PharFileInfo, decompress) RETURN_THROWS(); } /* decompress this file indirectly */ - if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, 1)) { + if (SUCCESS != phar_open_entry_fp(entry_obj->entry, &error, true)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Phar error: Cannot decompress %s-compressed file \"%s\" in phar \"%s\": %s", compression_type, ZSTR_VAL(entry_obj->entry->filename), entry_obj->entry->phar->fname, error); efree(error); diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index e6c5ac75e9e7a..c77876fc3647f 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -624,99 +624,99 @@ static zend_class_entry *register_class_Phar(zend_class_entry *class_entry_Recur zval const_BZ2_value; ZVAL_LONG(&const_BZ2_value, PHAR_ENT_COMPRESSED_BZ2); - zend_string *const_BZ2_name = zend_string_init_interned("BZ2", sizeof("BZ2") - 1, 1); + zend_string *const_BZ2_name = zend_string_init_interned("BZ2", sizeof("BZ2") - 1, true); zend_declare_typed_class_constant(class_entry, const_BZ2_name, &const_BZ2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BZ2_name); + zend_string_release_ex(const_BZ2_name, true); zval const_GZ_value; ZVAL_LONG(&const_GZ_value, PHAR_ENT_COMPRESSED_GZ); - zend_string *const_GZ_name = zend_string_init_interned("GZ", sizeof("GZ") - 1, 1); + zend_string *const_GZ_name = zend_string_init_interned("GZ", sizeof("GZ") - 1, true); zend_declare_typed_class_constant(class_entry, const_GZ_name, &const_GZ_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GZ_name); + zend_string_release_ex(const_GZ_name, true); zval const_NONE_value; ZVAL_LONG(&const_NONE_value, PHAR_ENT_COMPRESSED_NONE); - zend_string *const_NONE_name = zend_string_init_interned("NONE", sizeof("NONE") - 1, 1); + zend_string *const_NONE_name = zend_string_init_interned("NONE", sizeof("NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_NONE_name, &const_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NONE_name); + zend_string_release_ex(const_NONE_name, true); zval const_PHAR_value; ZVAL_LONG(&const_PHAR_value, PHAR_FORMAT_PHAR); - zend_string *const_PHAR_name = zend_string_init_interned("PHAR", sizeof("PHAR") - 1, 1); + zend_string *const_PHAR_name = zend_string_init_interned("PHAR", sizeof("PHAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_PHAR_name, &const_PHAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PHAR_name); + zend_string_release_ex(const_PHAR_name, true); zval const_TAR_value; ZVAL_LONG(&const_TAR_value, PHAR_FORMAT_TAR); - zend_string *const_TAR_name = zend_string_init_interned("TAR", sizeof("TAR") - 1, 1); + zend_string *const_TAR_name = zend_string_init_interned("TAR", sizeof("TAR") - 1, true); zend_declare_typed_class_constant(class_entry, const_TAR_name, &const_TAR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TAR_name); + zend_string_release_ex(const_TAR_name, true); zval const_ZIP_value; ZVAL_LONG(&const_ZIP_value, PHAR_FORMAT_ZIP); - zend_string *const_ZIP_name = zend_string_init_interned("ZIP", sizeof("ZIP") - 1, 1); + zend_string *const_ZIP_name = zend_string_init_interned("ZIP", sizeof("ZIP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ZIP_name, &const_ZIP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ZIP_name); + zend_string_release_ex(const_ZIP_name, true); zval const_COMPRESSED_value; ZVAL_LONG(&const_COMPRESSED_value, PHAR_ENT_COMPRESSION_MASK); - zend_string *const_COMPRESSED_name = zend_string_init_interned("COMPRESSED", sizeof("COMPRESSED") - 1, 1); + zend_string *const_COMPRESSED_name = zend_string_init_interned("COMPRESSED", sizeof("COMPRESSED") - 1, true); zend_declare_typed_class_constant(class_entry, const_COMPRESSED_name, &const_COMPRESSED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_COMPRESSED_name); + zend_string_release_ex(const_COMPRESSED_name, true); zval const_PHP_value; ZVAL_LONG(&const_PHP_value, PHAR_MIME_PHP); - zend_string *const_PHP_name = zend_string_init_interned("PHP", sizeof("PHP") - 1, 1); + zend_string *const_PHP_name = zend_string_init_interned("PHP", sizeof("PHP") - 1, true); zend_declare_typed_class_constant(class_entry, const_PHP_name, &const_PHP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PHP_name); + zend_string_release_ex(const_PHP_name, true); zval const_PHPS_value; ZVAL_LONG(&const_PHPS_value, PHAR_MIME_PHPS); - zend_string *const_PHPS_name = zend_string_init_interned("PHPS", sizeof("PHPS") - 1, 1); + zend_string *const_PHPS_name = zend_string_init_interned("PHPS", sizeof("PHPS") - 1, true); zend_declare_typed_class_constant(class_entry, const_PHPS_name, &const_PHPS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PHPS_name); + zend_string_release_ex(const_PHPS_name, true); zval const_MD5_value; ZVAL_LONG(&const_MD5_value, PHAR_SIG_MD5); - zend_string *const_MD5_name = zend_string_init_interned("MD5", sizeof("MD5") - 1, 1); + zend_string *const_MD5_name = zend_string_init_interned("MD5", sizeof("MD5") - 1, true); zend_declare_typed_class_constant(class_entry, const_MD5_name, &const_MD5_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MD5_name); + zend_string_release_ex(const_MD5_name, true); zval const_OPENSSL_value; ZVAL_LONG(&const_OPENSSL_value, PHAR_SIG_OPENSSL); - zend_string *const_OPENSSL_name = zend_string_init_interned("OPENSSL", sizeof("OPENSSL") - 1, 1); + zend_string *const_OPENSSL_name = zend_string_init_interned("OPENSSL", sizeof("OPENSSL") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPENSSL_name, &const_OPENSSL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPENSSL_name); + zend_string_release_ex(const_OPENSSL_name, true); zval const_OPENSSL_SHA256_value; ZVAL_LONG(&const_OPENSSL_SHA256_value, PHAR_SIG_OPENSSL_SHA256); - zend_string *const_OPENSSL_SHA256_name = zend_string_init_interned("OPENSSL_SHA256", sizeof("OPENSSL_SHA256") - 1, 1); + zend_string *const_OPENSSL_SHA256_name = zend_string_init_interned("OPENSSL_SHA256", sizeof("OPENSSL_SHA256") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPENSSL_SHA256_name, &const_OPENSSL_SHA256_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPENSSL_SHA256_name); + zend_string_release_ex(const_OPENSSL_SHA256_name, true); zval const_OPENSSL_SHA512_value; ZVAL_LONG(&const_OPENSSL_SHA512_value, PHAR_SIG_OPENSSL_SHA512); - zend_string *const_OPENSSL_SHA512_name = zend_string_init_interned("OPENSSL_SHA512", sizeof("OPENSSL_SHA512") - 1, 1); + zend_string *const_OPENSSL_SHA512_name = zend_string_init_interned("OPENSSL_SHA512", sizeof("OPENSSL_SHA512") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPENSSL_SHA512_name, &const_OPENSSL_SHA512_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPENSSL_SHA512_name); + zend_string_release_ex(const_OPENSSL_SHA512_name, true); zval const_SHA1_value; ZVAL_LONG(&const_SHA1_value, PHAR_SIG_SHA1); - zend_string *const_SHA1_name = zend_string_init_interned("SHA1", sizeof("SHA1") - 1, 1); + zend_string *const_SHA1_name = zend_string_init_interned("SHA1", sizeof("SHA1") - 1, true); zend_declare_typed_class_constant(class_entry, const_SHA1_name, &const_SHA1_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SHA1_name); + zend_string_release_ex(const_SHA1_name, true); zval const_SHA256_value; ZVAL_LONG(&const_SHA256_value, PHAR_SIG_SHA256); - zend_string *const_SHA256_name = zend_string_init_interned("SHA256", sizeof("SHA256") - 1, 1); + zend_string *const_SHA256_name = zend_string_init_interned("SHA256", sizeof("SHA256") - 1, true); zend_declare_typed_class_constant(class_entry, const_SHA256_name, &const_SHA256_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SHA256_name); + zend_string_release_ex(const_SHA256_name, true); zval const_SHA512_value; ZVAL_LONG(&const_SHA512_value, PHAR_SIG_SHA512); - zend_string *const_SHA512_name = zend_string_init_interned("SHA512", sizeof("SHA512") - 1, 1); + zend_string *const_SHA512_name = zend_string_init_interned("SHA512", sizeof("SHA512") - 1, true); zend_declare_typed_class_constant(class_entry, const_SHA512_name, &const_SHA512_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SHA512_name); + zend_string_release_ex(const_SHA512_name, true); return class_entry; } diff --git a/ext/phar/phar_path_check.re b/ext/phar/phar_path_check.re index 77aa0b1953d3c..689ffaa512442 100644 --- a/ext/phar/phar_path_check.re +++ b/ext/phar/phar_path_check.re @@ -18,7 +18,7 @@ #include "phar_internal.h" -phar_path_check_result phar_path_check(char **s, size_t *len, const char **error) +ZEND_ATTRIBUTE_NONNULL phar_path_check_result phar_path_check(char **s, size_t *len, const char **error) { const unsigned char *p = (const unsigned char*)*s; const unsigned char *m; diff --git a/ext/phar/shortarc.php b/ext/phar/shortarc.php index 0e88198a87a4f..c85e08439e761 100644 --- a/ext/phar/shortarc.php +++ b/ext/phar/shortarc.php @@ -74,7 +74,7 @@ $a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt); if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) { header('HTTP/1.0 404 Not Found'); - echo "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>"; + echo "<html>\n <head>\n <title>File Not Found\n \n \n

404 - File Not Found

\n \n"; exit; } $b = pathinfo($a); diff --git a/ext/phar/stream.c b/ext/phar/stream.c index c99a3340187b8..4bd1e85666b85 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -191,7 +191,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha /* strip leading "/" */ internal_file = estrndup(ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1); if (mode[0] == 'w' || (mode[0] == 'r' && mode[1] == '+')) { - if (NULL == (idata = phar_get_or_create_entry_data(ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, strlen(internal_file), mode, 0, &error, 1))) { + if (NULL == (idata = phar_get_or_create_entry_data(ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, strlen(internal_file), mode, 0, &error, true, time(NULL)))) { if (error) { php_stream_wrapper_log_error(wrapper, options, "%s", error); efree(error); @@ -225,7 +225,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha metadata = pzoption; ZVAL_COPY_DEREF(&idata->internal_file->metadata_tracker.val, metadata); - idata->phar->is_modified = 1; + idata->phar->is_modified = true; } } if (opened_path) { @@ -242,7 +242,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha return NULL; } if (phar->is_tar || phar->is_zip) { - if ((FAILURE == phar_get_entry_data(&idata, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), ".phar/stub.php", sizeof(".phar/stub.php")-1, "r", 0, &error, 0)) || !idata) { + if ((FAILURE == phar_get_entry_data(&idata, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), ".phar/stub.php", sizeof(".phar/stub.php")-1, "r", 0, &error, false)) || !idata) { goto idata_error; } efree(internal_file); @@ -254,13 +254,13 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha } else { php_stream *stream = phar_get_pharfp(phar); if (stream == NULL) { - if (UNEXPECTED(FAILURE == phar_open_archive_fp(phar))) { + stream = phar_open_archive_fp(phar); + if (UNEXPECTED(!stream)) { php_stream_wrapper_log_error(wrapper, options, "phar error: could not reopen phar \"%s\"", ZSTR_VAL(resource->host)); efree(internal_file); php_url_free(resource); return NULL; } - stream = phar_get_pharfp(phar); } phar_entry_info *entry; @@ -290,7 +290,7 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha } } /* read-only access is allowed to magic files in .phar directory */ - if ((FAILURE == phar_get_entry_data(&idata, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, strlen(internal_file), "r", 0, &error, 0)) || !idata) { + if ((FAILURE == phar_get_entry_data(&idata, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, strlen(internal_file), "r", 0, &error, false)) || !idata) { idata_error: if (error) { php_stream_wrapper_log_error(wrapper, options, "%s", error); @@ -445,7 +445,7 @@ static ssize_t phar_stream_write(php_stream *stream, const char *buf, size_t cou php_stream_seek(data->fp, data->position + data->zero, SEEK_SET); if (count != php_stream_write(data->fp, buf, count)) { - php_stream_wrapper_log_error(stream->wrapper, stream->flags, "phar error: Could not write %d characters to \"%s\" in phar \"%s\"", (int) count, ZSTR_VAL(data->internal_file->filename), data->phar->fname); + php_stream_wrapper_log_error(stream->wrapper, stream->flags, "phar error: Could not write %zu characters to \"%s\" in phar \"%s\"", count, ZSTR_VAL(data->internal_file->filename), data->phar->fname); return -1; } data->position = php_stream_tell(data->fp) - data->zero; @@ -454,7 +454,7 @@ static ssize_t phar_stream_write(php_stream *stream, const char *buf, size_t cou } data->internal_file->compressed_filesize = data->internal_file->uncompressed_filesize; data->internal_file->old_flags = data->internal_file->flags; - data->internal_file->is_modified = 1; + data->internal_file->is_modified = true; return count; } /* }}} */ @@ -545,7 +545,7 @@ static int phar_stream_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ return -1; } - phar_dostat(data->phar, data->internal_file, ssb, 0); + phar_dostat(data->phar, data->internal_file, ssb, false); return 0; } /* }}} */ @@ -557,7 +557,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f php_stream_statbuf *ssb, php_stream_context *context) /* {{{ */ { php_url *resource = NULL; - char *internal_file, *error; + char *internal_file; phar_archive_data *phar; phar_entry_info *entry; size_t internal_file_len; @@ -581,19 +581,13 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f internal_file = ZSTR_VAL(resource->path) + 1; /* strip leading "/" */ /* find the phar in our trusty global hash indexed by alias (host of phar://blah.phar/file.whatever) */ - if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, &error)) { + if (FAILURE == phar_get_archive(&phar, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), NULL, 0, NULL)) { php_url_free(resource); - if (error) { - efree(error); - } return FAILURE; } - if (error) { - efree(error); - } if (*internal_file == '\0') { /* root directory requested */ - phar_dostat(phar, NULL, ssb, 1); + phar_dostat(phar, NULL, ssb, true); php_url_free(resource); return SUCCESS; } @@ -604,12 +598,12 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f internal_file_len = strlen(internal_file); /* search through the manifest of files, and if we have an exact match, it's a file */ if (NULL != (entry = zend_hash_str_find_ptr(&phar->manifest, internal_file, internal_file_len))) { - phar_dostat(phar, entry, ssb, 0); + phar_dostat(phar, entry, ssb, false); php_url_free(resource); return SUCCESS; } if (zend_hash_str_exists(&(phar->virtual_dirs), internal_file, internal_file_len)) { - phar_dostat(phar, NULL, ssb, 1); + phar_dostat(phar, NULL, ssb, true); php_url_free(resource); return SUCCESS; } @@ -645,7 +639,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, const char *url, int f if (NULL == (entry = zend_hash_str_find_ptr(&phar->manifest, internal_file, internal_file_len))) { goto free_resource; } - phar_dostat(phar, entry, ssb, 0); + phar_dostat(phar, entry, ssb, false); php_url_free(resource); return SUCCESS; } @@ -698,7 +692,7 @@ static int phar_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int /* need to copy to strip leading "/", will get touched again */ internal_file = estrndup(ZSTR_VAL(resource->path) + 1, ZSTR_LEN(resource->path) - 1); internal_file_len = ZSTR_LEN(resource->path) - 1; - if (FAILURE == phar_get_entry_data(&idata, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, internal_file_len, "r", 0, &error, 1)) { + if (FAILURE == phar_get_entry_data(&idata, ZSTR_VAL(resource->host), ZSTR_LEN(resource->host), internal_file, internal_file_len, "r", 0, &error, true)) { /* constraints of fp refcount were not met */ if (error) { php_stream_wrapper_log_error(wrapper, options, "unlink of \"%s\" failed: %s", url, error); @@ -738,8 +732,8 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from char *error; phar_archive_data *phar, *pfrom, *pto; phar_entry_info *entry; - int is_dir = 0; - int is_modified = 0; + bool is_dir = false; + bool is_modified = false; error = NULL; @@ -860,8 +854,8 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from zend_hash_del(&phar->manifest, entry->filename); return 0; } - is_modified = 1; - entry->is_modified = 1; + is_modified = true; + entry->is_modified = true; is_dir = entry->is_dir; } else { is_dir = zend_hash_str_exists(&(phar->virtual_dirs), ZSTR_VAL(resource_from->path)+1, ZSTR_LEN(resource_from->path)-1); @@ -896,8 +890,8 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from memcpy(ZSTR_VAL(new_str_key) + to_len, ZSTR_VAL(str_key) + from_len, ZSTR_LEN(str_key) - from_len); ZSTR_VAL(new_str_key)[ZSTR_LEN(new_str_key)] = 0; - is_modified = 1; - entry->is_modified = 1; + is_modified = true; + entry->is_modified = true; zend_string_release(entry->filename); entry->filename = zend_string_copy(new_str_key); diff --git a/ext/phar/stream.h b/ext/phar/stream.h index ce75b70dcba00..83b395b4cfca3 100644 --- a/ext/phar/stream.h +++ b/ext/phar/stream.h @@ -21,7 +21,7 @@ BEGIN_EXTERN_C() #include "ext/standard/url.h" php_url* phar_parse_url(php_stream_wrapper *wrapper, const char *filename, const char *mode, int options); -void phar_entry_remove(phar_entry_data *idata, char **error); +ZEND_ATTRIBUTE_NONNULL void phar_entry_remove(phar_entry_data *idata, char **error); static php_stream* phar_wrapper_open_url(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context); diff --git a/ext/phar/stub.h b/ext/phar/stub.h index aa70e703b79b7..2c62e05900ace 100644 --- a/ext/phar/stub.h +++ b/ext/phar/stub.h @@ -16,16 +16,18 @@ +----------------------------------------------------------------------+ */ -static inline zend_string* phar_get_stub(const char *index_php, const char *web, const int name_len, const int web_len) +static inline zend_string *phar_get_stub(const char *index_php, const char *web, size_t name_len, size_t web_len) { + /* Do NOT modify this file directly! + * Instead modify shortarc.php to change PHP code or makestub.php to change C code and then use makestub.php to generate this file. */ static const char newstub0[] = " 2,\n'c' => 'text/plain',\n'cc' => 'text/plain',\n'cpp' => 'text/plain',\n'c++' => 'text/plain',\n'dtd' => 'text/plain',\n'h' => 'text/plain',\n'log' => 'text/plain',\n'rng' => 'text/plain',\n'txt' => 'text/plain',\n'xsd' => 'text/plain',\n'php' => 1,\n'inc' => 1,\n'avi' => 'video/avi',\n'bmp' => 'image/bmp',\n'css' => 'text/css',\n'gif' => 'image/gif',\n'htm' => 'text/html',\n'html' => 'text/html',\n'htmls' => 'text/html',\n'ico' => 'image/x-ico',\n'jpe' => 'image/jpeg',\n'jpg' => 'image/jpeg',\n'jpeg' => 'image/jpeg',\n'js' => 'application/x-javascript',\n'midi' => 'audio/midi',\n'mid' => 'audio/midi',\n'mod' => 'audio/mod',\n'mov' => 'movie/quicktime',\n'mp3' => 'audio/mp3',\n'mpg' => 'video/mpeg',\n'mpeg' => 'video/mpeg',\n'pdf' => 'application/pdf',\n'png' => 'image/png',\n'swf' => 'application/shockwave-flash',\n'tif' => 'image/tiff',\n'tiff' => 'image/tiff',\n'wav' => 'audio/wav',\n'xbm' => 'image/xbm',\n'xml' => 'text/xml',\n);\n\nheader(\"Cache-Control: no-cache, must-revalidate\");\nheader(\"Pragma: no-cache\");\n\n$basename = basename(__FILE__);\nif (!strpos($_SERVER['REQUEST_URI'], $basename)) {\nchdir(Extract_Phar::$temp);\ninclude $web;\nreturn;\n}\n$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));\nif (!$pt || $pt == '/') {\n$pt = $web;\nheader('HTTP/1.1 301 Moved Permanently');\nheader('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);\nexit;\n}\n$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);\nif (!$a || strlen(dirname($a)) < strlen("; - static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"\\n \\n File Not Found<title>\\n </head>\\n <body>\\n <h1>404 - File Not Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '"; + static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n <title>File Not Found\\n \\n \\n

404 - File Not Found

\\n \\n\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '"; static const char newstub2[] = "';\nconst LEN = "; - static const char newstub3_0[] = ";\n\nstatic function go($return = false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L = unpack('V', $a = fread($fp, 4));\n$m = '';\n\ndo {\n$read = 8192;\nif ($L[1] - strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = fread($fp, $read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif (strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m) .'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f = $info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate')) {\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif (!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not enabled -' .\n' bzdecompress() function needed for bz2-compressed .phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp || !is_writable($temp)) {\n$sessionpath = session_save_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr ($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath) || !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .= '/pharextract/'.basename(__FILE__, '.phar');\nself::$temp = $temp;\nself::$origdir = getcwd();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::START;\n}\n}\n\nstatic fun"; - static const char newstub3_1[] = "ction tmpdir()\n{\nif (strpos(PHP_OS, 'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn $var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info = unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m = substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start = 4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len = unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m, $start, $len[1]);\n$start += $len[1];\n $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n& 0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o += $ret['m'][$savepath][2];\n$start += 24 + $ret['m'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry, $fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data .= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp, 8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n} elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif (strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error \" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] != sprintf(\"%u\", crc32($data) & 0xffffffff)) {\ndie(\"Invalid internal .phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function _removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f) {\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif (file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPILER(); ?>"; + static const char newstub3_0[] = ";\n\nstatic function go($return = false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L = unpack('V', $a = (string)fread($fp, 4));\n$m = '';\n\ndo {\n$read = 8192;\nif ($L[1] - strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = (string)fread($fp, $read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif (strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m) .'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f = $info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate')) {\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif (!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not enabled -' .\n' bzdecompress() function needed for bz2-compressed .phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp || !is_writable($temp)) {\n$sessionpath = session_save_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr ($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath) || !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .= '/pharextract/'.basename(__FILE__, '.phar');\nself::$temp = $temp;\nself::$origdir = getcwd();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::START;\n}\n"; + static const char newstub3_1[] = "}\n\nstatic function tmpdir()\n{\nif (strpos(PHP_OS, 'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn $var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info = unpack('V', substr($m, 0, 4));\n\n$l = unpack('V', substr($m, 10, 4));\n$m = substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start = 4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n\n$len = unpack('V', substr($m, $start, 4));\n$start += 4;\n\n$savepath = substr($m, $start, $len[1]);\n$start += $len[1];\n\n\n\n$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n& 0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o += $ret['m'][$savepath][2];\n$start += 24 + $ret['m'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry, $fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data .= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp, 8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n} elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif (strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error \" . strlen($data) . \" != \" .\n$entry[0] . \")\");\n}\n\nif ($entry[3] != sprintf(\"%u\", crc32($data) & 0xffffffff)) {\ndie(\"Invalid internal .phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function _removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f) {\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif (file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPILER(); ?>"; - static const int newstub_len = 6623; + static const size_t newstub_len = 6641; - return strpprintf(name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1); + return strpprintf(name_len + web_len + newstub_len, "%s%s%s%s%s%s%zu%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1); } diff --git a/ext/phar/tar.c b/ext/phar/tar.c index dfccfb97221a7..91b6b04996d67 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -87,10 +87,10 @@ static zend_result phar_tar_octal(char *buf, uint32_t val, size_t len) /* {{{ */ } /* }}} */ -static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */ +static uint32_t phar_tar_checksum(const char *buf, size_t len) /* {{{ */ { uint32_t sum = 0; - char *end = buf + len; + const char *end = buf + len; while (buf != end) { sum += (unsigned char)*buf; @@ -100,7 +100,7 @@ static uint32_t phar_tar_checksum(char *buf, size_t len) /* {{{ */ } /* }}} */ -bool phar_is_tar(char *buf, char *fname) /* {{{ */ +bool phar_is_tar(const char *buf, const char *fname) /* {{{ */ { tar_header *header = (tar_header *) buf; uint32_t checksum = phar_tar_number(header->checksum, sizeof(header->checksum)); @@ -127,7 +127,7 @@ bool phar_is_tar(char *buf, char *fname) /* {{{ */ } /* }}} */ -zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t alias_len, int is_data, uint32_t options, phar_archive_data** pphar, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error) /* {{{ */ { phar_archive_data *phar; zend_result ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error); @@ -136,9 +136,7 @@ zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, return FAILURE; } - if (pphar) { - *pphar = phar; - } + *pphar = phar; phar->is_data = is_data; @@ -153,9 +151,7 @@ zend_result phar_open_or_create_tar(char *fname, size_t fname_len, char *alias, } /* we've reached here - the phar exists and is a regular phar */ - if (error) { - spprintf(error, 4096, "phar tar error: \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a tar-based phar", fname); - } + spprintf(error, 4096, "phar tar error: \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a tar-based phar", fname); return FAILURE; } /* }}} */ @@ -210,7 +206,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch tar_header *hdr; uint32_t sum1, sum2, size, old; phar_archive_data *myphar, *actual; - int last_was_longlink = 0; + bool last_was_longlink = false; size_t linkname_len; if (error) { @@ -237,11 +233,11 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch myphar->is_persistent = PHAR_G(persist); /* estimate number of entries, can't be certain with tar files */ zend_hash_init(&myphar->manifest, 2 + (totalsize >> 12), - zend_get_hash_value, destroy_phar_manifest_entry, (bool)myphar->is_persistent); + zend_get_hash_value, destroy_phar_manifest_entry, myphar->is_persistent); zend_hash_init(&myphar->mounted_dirs, 5, - zend_get_hash_value, NULL, (bool)myphar->is_persistent); + zend_get_hash_value, NULL, myphar->is_persistent); zend_hash_init(&myphar->virtual_dirs, 4 + (totalsize >> 11), - zend_get_hash_value, NULL, (bool)myphar->is_persistent); + zend_get_hash_value, NULL, myphar->is_persistent); myphar->is_tar = 1; /* remember whether this entire phar was compressed with gz/bzip2 */ myphar->flags = compression; @@ -361,7 +357,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch } if (!last_was_longlink && hdr->typeflag == 'L') { - last_was_longlink = 1; + last_was_longlink = true; /* support the ././@LongLink system for storing long filenames */ /* Check for overflow - bug 61065 */ @@ -465,7 +461,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch GC_MAKE_PERSISTENT_LOCAL(entry.filename); } } - last_was_longlink = 0; + last_was_longlink = false; phar_add_virtual_dirs(myphar, ZSTR_VAL(entry.filename), ZSTR_LEN(entry.filename)); @@ -730,7 +726,7 @@ static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* } if (entry->is_deleted) { - if (entry->fp_refcount <= 0) { + if (entry->fp_refcount <= 0 && entry->fileinfo_lock_count == 0) { return ZEND_HASH_APPLY_REMOVE; } else { /* we can't delete this in-memory until it is closed */ @@ -819,18 +815,18 @@ static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* /* write contents */ if (entry->uncompressed_filesize) { - if (FAILURE == phar_open_entry_fp(entry, fp->error, 0)) { + if (FAILURE == phar_open_entry_fp(entry, fp->error, false)) { return ZEND_HASH_APPLY_STOP; } - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) { if (fp->error) { spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, contents of file \"%s\" could not be written, seek failed", entry->phar->fname, ZSTR_VAL(entry->filename)); } return ZEND_HASH_APPLY_STOP; } - if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), fp->new, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, false), fp->new, entry->uncompressed_filesize, NULL)) { if (fp->error) { spprintf(fp->error, 4096, "tar-based phar \"%s\" cannot be created, contents of file \"%s\" could not be written", entry->phar->fname, ZSTR_VAL(entry->filename)); } @@ -845,10 +841,10 @@ static int phar_tar_writeheaders_int(phar_entry_info *entry, void *argument) /* /* open file pointers refer to this fp, do not free the stream */ switch (entry->fp_type) { case PHAR_FP: - fp->free_fp = 0; + fp->free_fp = false; break; case PHAR_UFP: - fp->free_ufp = 0; + fp->free_ufp = false; default: break; } @@ -877,7 +873,7 @@ static int phar_tar_writeheaders(zval *zv, void *argument) /* {{{ */ } /* }}} */ -static int phar_tar_setmetadata(const phar_metadata_tracker *tracker, phar_entry_info *entry, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL static int phar_tar_setmetadata(const phar_metadata_tracker *tracker, phar_entry_info *entry, char **error) /* {{{ */ { /* Copy the metadata from tracker to the new entry being written out to temporary files */ const zend_string *serialized_str; @@ -897,7 +893,7 @@ static int phar_tar_setmetadata(const phar_metadata_tracker *tracker, phar_entry entry->fp = php_stream_fopen_tmpfile(); entry->offset = entry->offset_abs = 0; if (entry->fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return -1; } if (serialized_str && ZSTR_LEN(serialized_str) != php_stream_write(entry->fp, ZSTR_VAL(serialized_str), ZSTR_LEN(serialized_str))) { @@ -910,7 +906,7 @@ static int phar_tar_setmetadata(const phar_metadata_tracker *tracker, phar_entry } /* }}} */ -static int phar_tar_setupmetadata(zval *zv, void *argument) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL static int phar_tar_setupmetadata(zval *zv, void *argument) /* {{{ */ { struct _phar_pass_tar_info *i = (struct _phar_pass_tar_info *)argument; char **error = i->error; @@ -964,7 +960,7 @@ static int phar_tar_setupmetadata(zval *zv, void *argument) /* {{{ */ } /* }}} */ -int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ { static const char newstub[] = "is_persistent) { - if (error) { - spprintf(error, 0, "internal error: attempt to flush cached tar-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "internal error: attempt to flush cached tar-based phar \"%s\"", phar->fname); return EOF; } @@ -1002,13 +996,11 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa if (!phar->is_temporary_alias && phar->alias_len) { entry.fp = php_stream_fopen_tmpfile(); if (entry.fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); - return -1; + *error = estrdup("phar error: unable to create temporary file"); + return EOF; } if (phar->alias_len != php_stream_write(entry.fp, phar->alias, phar->alias_len)) { - if (error) { - spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"", phar->fname); php_stream_close(entry.fp); return EOF; } @@ -1028,9 +1020,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa char *pos = php_stristr(ZSTR_VAL(user_stub), halt_stub, ZSTR_LEN(user_stub), sizeof(halt_stub) - 1); if (pos == NULL) { - if (error) { - spprintf(error, 0, "illegal stub for tar-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "illegal stub for tar-based phar \"%s\"", phar->fname); return EOF; } @@ -1040,7 +1030,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa entry.fp = php_stream_fopen_tmpfile(); if (entry.fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return EOF; } entry.uncompressed_filesize = len + end_sequence_len; @@ -1049,9 +1039,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa len != php_stream_write(entry.fp, ZSTR_VAL(user_stub), len) || end_sequence_len != php_stream_write(entry.fp, end_sequence, end_sequence_len) ) { - if (error) { - spprintf(error, 0, "unable to create stub from string in new tar-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to create stub from string in new tar-based phar \"%s\"", phar->fname); php_stream_close(entry.fp); return EOF; } @@ -1062,14 +1050,13 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa /* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */ entry.fp = php_stream_fopen_tmpfile(); if (entry.fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return EOF; } if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { php_stream_close(entry.fp); - if (error) { - spprintf(error, 0, "unable to %s stub in%star-based phar \"%s\", failed", user_stub ? "overwrite" : "create", user_stub ? " " : " new ", phar->fname); - } + spprintf(error, 0, "unable to %s stub in%star-based phar \"%s\", failed", + user_stub ? "overwrite" : "create", user_stub ? " " : " new ", phar->fname); return EOF; } @@ -1081,9 +1068,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa if (NULL == zend_hash_add_mem(&phar->manifest, entry.filename, &entry, sizeof(phar_entry_info))) { php_stream_close(entry.fp); zend_string_efree(entry.filename); - if (error) { - spprintf(error, 0, "unable to create stub in tar-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to create stub in tar-based phar \"%s\"", phar->fname); return EOF; } } else { @@ -1106,9 +1091,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa newfile = php_stream_fopen_tmpfile(); if (!newfile) { - if (error) { - spprintf(error, 0, "unable to create temporary file"); - } + *error = estrdup("unable to create temporary file"); if (must_close_old_file) { php_stream_close(oldfile); } @@ -1118,8 +1101,8 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa pass.old = oldfile; pass.new = newfile; pass.error = error; - pass.free_fp = 1; - pass.free_ufp = 1; + pass.free_fp = true; + pass.free_ufp = true; if (phar_metadata_tracker_has_data(&phar->metadata_tracker, phar->is_persistent)) { phar_entry_info *mentry; @@ -1159,7 +1142,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa zend_hash_apply_with_argument(&phar->manifest, phar_tar_setupmetadata, (void *) &pass); - if (error && *error) { + if (*error) { if (must_close_old_file) { php_stream_close(oldfile); } @@ -1171,7 +1154,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa zend_hash_apply_with_argument(&phar->manifest, phar_tar_writeheaders, (void *) &pass); - if (error && *error) { + if (*error) { if (must_close_old_file) { php_stream_close(oldfile); } @@ -1183,12 +1166,10 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa /* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */ if (!phar->is_data || phar->sig_flags) { - if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, error)) { - if (error) { - char *save = *error; - spprintf(error, 0, "phar error: unable to write signature to tar-based phar: %s", save); - efree(save); - } + char *signature_error = NULL; + if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, &signature_error)) { + spprintf(error, 0, "phar error: unable to write signature to tar-based phar: %s", signature_error); + efree(signature_error); if (must_close_old_file) { php_stream_close(oldfile); @@ -1200,7 +1181,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa entry.fp = php_stream_fopen_tmpfile(); if (entry.fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); efree(signature); if (must_close_old_file) { @@ -1225,9 +1206,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa if (8 != php_stream_write(entry.fp, sigbuf, 8) || signature_length != php_stream_write(entry.fp, signature, signature_length)) { efree(signature); - if (error) { - spprintf(error, 0, "phar error: unable to write signature to tar-based phar %s", phar->fname); - } + spprintf(error, 0, "phar error: unable to write signature to tar-based phar %s", phar->fname); if (must_close_old_file) { php_stream_close(oldfile); @@ -1244,7 +1223,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa phar_tar_writeheaders_int(&entry, &pass); ZSTR_ALLOCA_FREE(entry.filename, use_heap); - if (error && *error) { + if (*error) { if (must_close_old_file) { php_stream_close(oldfile); } @@ -1263,12 +1242,6 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa php_stream_close(oldfile); } - /* on error in the hash iterator above, error is set */ - if (error && *error) { - php_stream_close(newfile); - return EOF; - } - if (phar->fp && pass.free_fp) { php_stream_close(phar->fp); } @@ -1290,9 +1263,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa phar->fp = php_stream_open_wrapper(phar->fname, "w+b", IGNORE_URL|STREAM_MUST_SEEK|REPORT_ERRORS, NULL); if (!phar->fp) { phar->fp = newfile; - if (error) { - spprintf(error, 0, "unable to open new phar \"%s\" for writing", phar->fname); - } + spprintf(error, 0, "unable to open new phar \"%s\" for writing", phar->fname); return EOF; } @@ -1314,9 +1285,7 @@ int phar_tar_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa /* copy contents uncompressed rather than lose them */ php_stream_copy_to_stream_ex(newfile, phar->fp, PHP_STREAM_COPY_ALL, NULL); php_stream_close(newfile); - if (error) { - spprintf(error, 4096, "unable to compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6 have a buggy zlib", phar->fname); - } + spprintf(error, 4096, "unable to compress all contents of phar \"%s\" using zlib, PHP versions older than 5.2.6 have a buggy zlib", phar->fname); return EOF; } diff --git a/ext/phar/tests/SplFileInfo_openFile_write.phpt b/ext/phar/tests/SplFileInfo_openFile_write.phpt new file mode 100644 index 0000000000000..f63baf5c7ad10 --- /dev/null +++ b/ext/phar/tests/SplFileInfo_openFile_write.phpt @@ -0,0 +1,31 @@ +--TEST-- +SplFileInfo::openFile() in write mode +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +--FILE-- +addFromString('test', 'contents'); +var_dump($phar['test']->openFile('w')); + +?> +--CLEAN-- + +--EXPECTF-- +object(SplFileObject)#%d (%d) { + ["pathName":"SplFileInfo":private]=> + string(%d) "phar://%stest" + ["fileName":"SplFileInfo":private]=> + string(4) "test" + ["openMode":"SplFileObject":private]=> + string(1) "w" + ["delimiter":"SplFileObject":private]=> + string(1) "," + ["enclosure":"SplFileObject":private]=> + string(1) """ +} diff --git a/ext/phar/tests/bug74154.phpt b/ext/phar/tests/bug74154.phpt new file mode 100644 index 0000000000000..ab3836ce87d46 --- /dev/null +++ b/ext/phar/tests/bug74154.phpt @@ -0,0 +1,41 @@ +--TEST-- +Bug #74154 (Phar extractTo creates empty files) +--EXTENSIONS-- +phar +zlib +--FILE-- +buildFromDirectory($dir); + +$compPhar = $phar->compress(Phar::GZ); +unset($phar); //make sure that test.tar is closed +unlink(__DIR__.'/bug74154.tar'); +unset($compPhar); //make sure that test.tar.gz is closed +$extractingPhar = new PharData(__DIR__.'/bug74154.tar.gz'); +$extractingPhar->extractTo($dir.'_out'); + +var_dump(file_get_contents($dir.'_out/1.txt')); +var_dump(file_get_contents($dir.'_out/2.txt')); + +?> +--CLEAN-- + +--EXPECT-- +string(64) "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh" +string(64) "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii" diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getMTime.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getMTime.phpt new file mode 100644 index 0000000000000..eefe352a0cbb6 --- /dev/null +++ b/ext/phar/tests/buildFromIterator_user_overrides/getMTime.phpt @@ -0,0 +1,81 @@ +--TEST-- +buildFromIterator with user overrides - getMTime() +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +phar.require_hash=0 +--CREDITS-- +Arne Blankerts +N. Dossche +--FILE-- +getPathname() . " ]\n"; + return new MySplFileInfo(parent::current()->getPathname()); + } +} + +$workdir = __DIR__.'/getMTime'; +mkdir($workdir . '/content', recursive: true); +file_put_contents($workdir . '/content/hello.txt', "Hello world."); + +$phar = new \Phar($workdir . '/test.phar'); +$phar->startBuffering(); +$phar->buildFromIterator( + new RecursiveIteratorIterator( + new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS) + ), + $workdir +); +$phar->stopBuffering(); + + +$result = new \Phar($workdir . '/test.phar', 0, 'test.phar'); +var_dump($result['content/hello.txt']); +var_dump($result['content/hello.txt']->getATime()); +var_dump($result['content/hello.txt']->getMTime()); +var_dump($result['content/hello.txt']->getCTime()); + +?> +--CLEAN-- + +--EXPECTF-- +[ Found: %shello.txt ] +[MTime] +object(PharFileInfo)#%d (2) { + ["pathName":"SplFileInfo":private]=> + string(%d) "phar://%shello.txt" + ["fileName":"SplFileInfo":private]=> + string(%d) "hello.txt" +} +int(123) +int(123) +int(123) diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getMTime_byRef.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getMTime_byRef.phpt new file mode 100644 index 0000000000000..a7f81709a34e3 --- /dev/null +++ b/ext/phar/tests/buildFromIterator_user_overrides/getMTime_byRef.phpt @@ -0,0 +1,70 @@ +--TEST-- +buildFromIterator with user overrides - getMTime() by ref +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +phar.require_hash=0 +--CREDITS-- +Arne Blankerts +N. Dossche +--FILE-- +getPathname() . " ]\n"; + return new MySplFileInfo(parent::current()->getPathname()); + } +} + +$workdir = __DIR__.'/getMTime_byRef'; +mkdir($workdir . '/content', recursive: true); +file_put_contents($workdir . '/content/hello.txt', "Hello world."); + +$phar = new \Phar($workdir . '/test.phar'); +$phar->startBuffering(); +$phar->buildFromIterator( + new RecursiveIteratorIterator( + new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS) + ), + $workdir +); +$phar->stopBuffering(); + + +$result = new \Phar($workdir . '/test.phar', 0, 'test.phar'); +var_dump($result['content/hello.txt']); +var_dump($result['content/hello.txt']->getATime()); +var_dump($result['content/hello.txt']->getMTime()); +var_dump($result['content/hello.txt']->getCTime()); + +?> +--CLEAN-- + +--EXPECTF-- +[ Found: %shello.txt ] +[MTime] +object(PharFileInfo)#%d (2) { + ["pathName":"SplFileInfo":private]=> + string(%d) "phar://%shello.txt" + ["fileName":"SplFileInfo":private]=> + string(%d) "hello.txt" +} +int(123) +int(123) +int(123) diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getMTime_errors.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getMTime_errors.phpt new file mode 100644 index 0000000000000..f43a7a496a762 --- /dev/null +++ b/ext/phar/tests/buildFromIterator_user_overrides/getMTime_errors.phpt @@ -0,0 +1,117 @@ +--TEST-- +buildFromIterator with user overrides - errors in getMTime() +--EXTENSIONS-- +phar +--SKIPIF-- + +--INI-- +phar.readonly=0 +phar.require_hash=0 +--CREDITS-- +Arne Blankerts +N. Dossche +--FILE-- +getPathname() . " ]\n"; + if ($counter === 1) { + return new MySplFileInfo1(parent::current()->getPathname()); + } else if ($counter === 2) { + return new MySplFileInfo2(parent::current()->getPathname()); + } else if ($counter === 3) { + return new MySplFileInfo3(parent::current()->getPathname()); + } else if ($counter === 4) { + return new MySplFileInfo4(parent::current()->getPathname()); + } + } +} + +$workdir = __DIR__.'/getMTime_errors'; +mkdir($workdir . '/content', recursive: true); +file_put_contents($workdir . '/content/hello.txt', "Hello world."); + +for ($i = 0; $i < 4; $i++) { + echo "--- Iteration $i ---\n"; + try { + $phar = new \Phar($workdir . "/test$i.phar"); + $phar->startBuffering(); + $phar->buildFromIterator( + new RecursiveIteratorIterator( + new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS) + ), + $workdir + ); + $phar->stopBuffering(); + } catch (Throwable $e) { + echo $e->getMessage(), "\n"; + if ($previous = $e->getPrevious()) { + echo "Previous: ", $previous->getMessage(), "\n"; + } + } +} + +?> +--CLEAN-- + +--EXPECTF-- +--- Iteration 0 --- +[ Found: %shello.txt ] +[MTime] +Entry content%chello.txt cannot be created: timestamp is limited to 32-bit +--- Iteration 1 --- +[ Found: %shello.txt ] +[MTime] +Entry content%chello.txt cannot be created: getMTime() must return an int +--- Iteration 2 --- +[ Found: %shello.txt ] +[MTime] +Entry content%chello.txt cannot be created: getMTime() must return an int +Previous: Throwing an exception inside getMTime() +--- Iteration 3 --- +[ Found: %shello.txt ] +[MTime] +Entry content%chello.txt cannot be created: getMTime() must return an int diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getPathname.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getPathname.phpt new file mode 100644 index 0000000000000..144eed1d874a6 --- /dev/null +++ b/ext/phar/tests/buildFromIterator_user_overrides/getPathname.phpt @@ -0,0 +1,67 @@ +--TEST-- +buildFromIterator with user overrides - getPathname() +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +phar.require_hash=0 +--CREDITS-- +Arne Blankerts +N. Dossche +--FILE-- +getPathname() . " ]\n"; + return new MyGlobIterator(parent::current()->getPath() . '/*'); + } +} + +$workdir = __DIR__.'/getPathname'; +mkdir($workdir . '/content', recursive: true); +file_put_contents($workdir . '/content/hello1.txt', "Hello world 1."); +file_put_contents($workdir . '/content/hello2.txt', "Hello world 2."); + +$phar = new \Phar($workdir . "/test.phar"); +$phar->startBuffering(); +$phar->buildFromIterator( + new RecursiveIteratorIterator( + new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS) + ), + $workdir +); +$phar->stopBuffering(); + +$result = new \Phar($workdir . '/test.phar', 0, 'test.phar'); +var_dump(isset($result['content/hello1.txt'])); +var_dump(isset($result['content/hello2.txt'])); + +?> +--CLEAN-- + +--EXPECTF-- +[ Found: %shello%d.txt ] +[getPathname] +string(%d) "%shello1.txt" +[ Found: %shello%d.txt ] +[getPathname] +string(%d) "%shello1.txt" +bool(false) +bool(true) diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getPathname_byRef.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_byRef.phpt new file mode 100644 index 0000000000000..0ae2946ce1ade --- /dev/null +++ b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_byRef.phpt @@ -0,0 +1,58 @@ +--TEST-- +buildFromIterator with user overrides - getPathname() by ref +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +phar.require_hash=0 +--CREDITS-- +Arne Blankerts +N. Dossche +--FILE-- +getPathname() . " ]\n"; + return new MyGlobIterator(parent::current()->getPath() . '/*'); + } +} + +$workdir = __DIR__.'/getPathname_byRef'; +mkdir($workdir . '/content', recursive: true); +file_put_contents($workdir . '/content/hello.txt', "Hello world 1."); + +$phar = new \Phar($workdir . "/test.phar"); +$phar->startBuffering(); +$phar->buildFromIterator( + new RecursiveIteratorIterator( + new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS) + ), + $workdir +); +$phar->stopBuffering(); + +$result = new \Phar($workdir . '/test.phar', 0, 'test.phar'); +var_dump(isset($result['content/hello.txt'])); + +?> +--CLEAN-- + +--EXPECTF-- +[ Found: %scontent%chello.txt ] +[getPathname] +bool(true) diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getPathname_exception.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_exception.phpt new file mode 100644 index 0000000000000..86b66050a973f --- /dev/null +++ b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_exception.phpt @@ -0,0 +1,63 @@ +--TEST-- +buildFromIterator with user overrides - exception in getPathname() +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +phar.require_hash=0 +--CREDITS-- +Arne Blankerts +N. Dossche +--FILE-- +getPathname() . " ]\n"; + return new MyGlobIterator(parent::current()->getPath() . '/*'); + } +} + +$workdir = __DIR__.'/getPathname_exception'; +mkdir($workdir . '/content', recursive: true); +file_put_contents($workdir . '/content/hello.txt', "Hello world."); + +$phar = new \Phar($workdir . "/test.phar"); +$phar->startBuffering(); +try { + $phar->buildFromIterator( + new RecursiveIteratorIterator( + new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS) + ), + $workdir + ); +} catch (Throwable $e) { + echo $e->getMessage(), "\n"; + if ($previous = $e->getPrevious()) { + echo "Previous: ", $previous->getMessage(), "\n"; + } +} +$phar->stopBuffering(); + +?> +--CLEAN-- + +--EXPECTF-- +[ Found: %shello.txt ] +[getPathname] +string(%d) "%shello.txt" +getPathname() must return a string +Previous: exception in getPathname() diff --git a/ext/phar/tests/buildFromIterator_user_overrides/getPathname_wrong_type.phpt b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_wrong_type.phpt new file mode 100644 index 0000000000000..dfb3fb5f2c550 --- /dev/null +++ b/ext/phar/tests/buildFromIterator_user_overrides/getPathname_wrong_type.phpt @@ -0,0 +1,58 @@ +--TEST-- +buildFromIterator with user overrides - wrong return type in getPathname() +--EXTENSIONS-- +phar +--INI-- +phar.readonly=0 +phar.require_hash=0 +--CREDITS-- +Arne Blankerts +N. Dossche +--FILE-- +getPathname() . " ]\n"; + return new MyGlobIterator(parent::current()->getPath() . '/*'); + } +} + +$workdir = __DIR__.'/getPathname_wrong_type'; +mkdir($workdir . '/content', recursive: true); +file_put_contents($workdir . '/content/hello.txt', "Hello world."); + +$phar = new \Phar($workdir . "/test.phar"); +$phar->startBuffering(); +try { + $phar->buildFromIterator( + new RecursiveIteratorIterator( + new MyIterator($workdir . '/content', FilesystemIterator::SKIP_DOTS) + ), + $workdir + ); +} catch (Throwable $e) { + echo $e->getMessage(), "\n"; +} +$phar->stopBuffering(); + +?> +--CLEAN-- + +--EXPECTF-- +[ Found: %scontent%chello.txt ] +[getPathname] +getPathname() must return a string diff --git a/ext/phar/tests/cache_list/copyonwrite11.phar.phpt b/ext/phar/tests/cache_list/copyonwrite11.phar.phpt index a52b8e5fed3f5..d51135894494f 100644 --- a/ext/phar/tests/cache_list/copyonwrite11.phar.phpt +++ b/ext/phar/tests/cache_list/copyonwrite11.phar.phpt @@ -18,5 +18,5 @@ echo strlen($p2->getStub()),"\n"; echo "ok\n"; __HALT_COMPILER(); ?> " -6643 +6661 ok diff --git a/ext/phar/tests/gh17808.phpt b/ext/phar/tests/gh17808.phpt index 03e54ff264bfa..a5c13a5405e24 100644 --- a/ext/phar/tests/gh17808.phpt +++ b/ext/phar/tests/gh17808.phpt @@ -5,18 +5,26 @@ phar zlib --FILE-- getContent())); -unlink("$file"); +unlink($file); var_dump($file->getATime()); ?> +--CLEAN-- + --EXPECTF-- -string(%d) "phar://%spackage.xml" +object(PharFileInfo)#%d (%d) { + ["pathName":"SplFileInfo":private]=> + string(%d) "phar://%spackage.xml" + ["fileName":"SplFileInfo":private]=> + string(11) "package.xml" +} int(6747) - -Warning: unlink(): phar error: "package.xml" in phar %s, has open file pointers, cannot unlink in %s on line %d int(33188) diff --git a/ext/phar/tests/gh20732.phpt b/ext/phar/tests/gh20732.phpt new file mode 100644 index 0000000000000..b938d16d42caf --- /dev/null +++ b/ext/phar/tests/gh20732.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-20732 (Phar::LoadPhar undefined behavior when loading directory) +--EXTENSIONS-- +phar +--FILE-- +getMessage(), "\n"; +} +?> +--EXPECTF-- +%r(internal corruption of phar "%s" \(truncated entry\)|unable to open phar for reading ".")%r diff --git a/ext/phar/tests/invalid_string_phar_mungserver.phpt b/ext/phar/tests/invalid_string_phar_mungserver.phpt new file mode 100644 index 0000000000000..46de113f6c087 --- /dev/null +++ b/ext/phar/tests/invalid_string_phar_mungserver.phpt @@ -0,0 +1,15 @@ +--TEST-- +Passing invalid string to Phar::mungServer() +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECT-- +Invalid value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt index 80c35cb784364..951506aff0f00 100644 --- a/ext/phar/tests/phar_commitwrite.phpt +++ b/ext/phar/tests/phar_commitwrite.phpt @@ -27,7 +27,7 @@ unlink(__DIR__ . '/phar_commitwrite.phar'); __HALT_COMPILER(); ?> --EXPECTF-- -int(6641) +int(6659) string(%d) " --EXPECTF-- -int(6641) +int(6659) string(%d) "getMessage() . "\n"; } ?> --EXPECT-- -string(6641) "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>"; +echo "<html>\n <head>\n <title>File Not Found\n \n \n

404 - File Not Found

\n \n"; exit; } $b = pathinfo($a); @@ -143,13 +143,13 @@ const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'index.php'; -const LEN = 6643; +const LEN = 6661; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); -$L = unpack('V', $a = fread($fp, 4)); +$L = unpack('V', $a = (string)fread($fp, 4)); $m = ''; do { @@ -157,7 +157,7 @@ $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } -$last = fread($fp, $read); +$last = (string)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); @@ -248,7 +248,8 @@ return realpath('/tmp'); static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); - $l = unpack('V', substr($m, 10, 4)); + +$l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; @@ -256,11 +257,16 @@ $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { - $len = unpack('V', substr($m, $start, 4)); + +$len = unpack('V', substr($m, $start, 4)); $start += 4; - $savepath = substr($m, $start, $len[1]); + +$savepath = substr($m, $start, $len[1]); $start += $len[1]; - $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); + + + +$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; @@ -294,7 +300,7 @@ $data = bzdecompress($data); if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . -$stat[7] . ")"); +$entry[0] . ")"); } if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { @@ -327,7 +333,7 @@ Extract_Phar::go(); __HALT_COMPILER(); ?>" ============================================================================ ============================================================================ -string(6652) "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>"; +echo "<html>\n <head>\n <title>File Not Found\n \n \n

404 - File Not Found

\n \n"; exit; } $b = pathinfo($a); @@ -437,13 +443,13 @@ const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'my/custom/thingy.php'; -const LEN = 6654; +const LEN = 6672; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); -$L = unpack('V', $a = fread($fp, 4)); +$L = unpack('V', $a = (string)fread($fp, 4)); $m = ''; do { @@ -451,7 +457,7 @@ $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } -$last = fread($fp, $read); +$last = (string)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); @@ -542,7 +548,8 @@ return realpath('/tmp'); static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); - $l = unpack('V', substr($m, 10, 4)); + +$l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; @@ -550,11 +557,16 @@ $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { - $len = unpack('V', substr($m, $start, 4)); + +$len = unpack('V', substr($m, $start, 4)); $start += 4; - $savepath = substr($m, $start, $len[1]); + +$savepath = substr($m, $start, $len[1]); $start += $len[1]; - $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); + + + +$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; @@ -588,7 +600,7 @@ $data = bzdecompress($data); if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . -$stat[7] . ")"); +$entry[0] . ")"); } if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { @@ -621,7 +633,7 @@ Extract_Phar::go(); __HALT_COMPILER(); ?>" ============================================================================ ============================================================================ -int(7032) +int(7050) ============================================================================ ============================================================================ Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed @@ -629,7 +641,7 @@ Illegal filename passed in for stub creation, was 401 characters long, and only ============================================================================ ============================================================================ ============================================================================ -string(6654) "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>"; +echo "<html>\n <head>\n <title>File Not Found\n \n \n

404 - File Not Found

\n \n"; exit; } $b = pathinfo($a); @@ -739,13 +751,13 @@ const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'my/custom/thingy.php'; -const LEN = 6656; +const LEN = 6674; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); -$L = unpack('V', $a = fread($fp, 4)); +$L = unpack('V', $a = (string)fread($fp, 4)); $m = ''; do { @@ -753,7 +765,7 @@ $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } -$last = fread($fp, $read); +$last = (string)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); @@ -844,7 +856,8 @@ return realpath('/tmp'); static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); - $l = unpack('V', substr($m, 10, 4)); + +$l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; @@ -852,11 +865,16 @@ $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { - $len = unpack('V', substr($m, $start, 4)); + +$len = unpack('V', substr($m, $start, 4)); $start += 4; - $savepath = substr($m, $start, $len[1]); + +$savepath = substr($m, $start, $len[1]); $start += $len[1]; - $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); + + + +$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; @@ -890,7 +908,7 @@ $data = bzdecompress($data); if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . -$stat[7] . ")"); +$entry[0] . ")"); } if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { @@ -923,5 +941,5 @@ Extract_Phar::go(); __HALT_COMPILER(); ?>" ============================================================================ ============================================================================ -int(7032) +int(7050) Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed diff --git a/ext/phar/tests/phar_offset_check.phpt b/ext/phar/tests/phar_offset_check.phpt index c1a8d201c8bc7..5a039d2d89346 100644 --- a/ext/phar/tests/phar_offset_check.phpt +++ b/ext/phar/tests/phar_offset_check.phpt @@ -68,8 +68,8 @@ var_dump($phar->getAlias()); Entry .phar/stub.php does not exist Entry .phar/alias.txt does not exist Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub -int(6643) -int(6643) +int(6661) +int(6661) Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias string(5) "susan" string(5) "susan" diff --git a/ext/phar/tests/phar_setdefaultstub.phpt b/ext/phar/tests/phar_setdefaultstub.phpt index c5db64a308e6f..ea05a03bc1a7f 100644 --- a/ext/phar/tests/phar_setdefaultstub.phpt +++ b/ext/phar/tests/phar_setdefaultstub.phpt @@ -53,7 +53,7 @@ try { unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?> --EXPECT-- -string(6643) "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>"; +echo "<html>\n <head>\n <title>File Not Found\n \n \n

404 - File Not Found

\n \n"; exit; } $b = pathinfo($a); @@ -163,13 +163,13 @@ const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'index.php'; -const LEN = 6643; +const LEN = 6661; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); -$L = unpack('V', $a = fread($fp, 4)); +$L = unpack('V', $a = (string)fread($fp, 4)); $m = ''; do { @@ -177,7 +177,7 @@ $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } -$last = fread($fp, $read); +$last = (string)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); @@ -268,7 +268,8 @@ return realpath('/tmp'); static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); - $l = unpack('V', substr($m, 10, 4)); + +$l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; @@ -276,11 +277,16 @@ $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { - $len = unpack('V', substr($m, $start, 4)); + +$len = unpack('V', substr($m, $start, 4)); $start += 4; - $savepath = substr($m, $start, $len[1]); + +$savepath = substr($m, $start, $len[1]); $start += $len[1]; - $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); + + + +$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; @@ -314,7 +320,7 @@ $data = bzdecompress($data); if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . -$stat[7] . ")"); +$entry[0] . ")"); } if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { @@ -348,7 +354,7 @@ __HALT_COMPILER(); ?> " ============================================================================ ============================================================================ -string(6654) "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>"; +echo "<html>\n <head>\n <title>File Not Found\n \n \n

404 - File Not Found

\n \n"; exit; } $b = pathinfo($a); @@ -458,13 +464,13 @@ const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'my/custom/thingy.php'; -const LEN = 6654; +const LEN = 6672; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); -$L = unpack('V', $a = fread($fp, 4)); +$L = unpack('V', $a = (string)fread($fp, 4)); $m = ''; do { @@ -472,7 +478,7 @@ $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } -$last = fread($fp, $read); +$last = (string)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); @@ -563,7 +569,8 @@ return realpath('/tmp'); static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); - $l = unpack('V', substr($m, 10, 4)); + +$l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; @@ -571,11 +578,16 @@ $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { - $len = unpack('V', substr($m, $start, 4)); + +$len = unpack('V', substr($m, $start, 4)); $start += 4; - $savepath = substr($m, $start, $len[1]); + +$savepath = substr($m, $start, $len[1]); $start += $len[1]; - $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); + + + +$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; @@ -609,7 +621,7 @@ $data = bzdecompress($data); if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . -$stat[7] . ")"); +$entry[0] . ")"); } if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { @@ -643,7 +655,7 @@ __HALT_COMPILER(); ?> " ============================================================================ ============================================================================ -string(6656) "\n \n File Not Found<title>\n </head>\n <body>\n <h1>404 - File Not Found</h1>\n </body>\n</html>"; +echo "<html>\n <head>\n <title>File Not Found\n \n \n

404 - File Not Found

\n \n"; exit; } $b = pathinfo($a); @@ -753,13 +765,13 @@ const GZ = 0x1000; const BZ2 = 0x2000; const MASK = 0x3000; const START = 'my/custom/thingy.php'; -const LEN = 6656; +const LEN = 6674; static function go($return = false) { $fp = fopen(__FILE__, 'rb'); fseek($fp, self::LEN); -$L = unpack('V', $a = fread($fp, 4)); +$L = unpack('V', $a = (string)fread($fp, 4)); $m = ''; do { @@ -767,7 +779,7 @@ $read = 8192; if ($L[1] - strlen($m) < 8192) { $read = $L[1] - strlen($m); } -$last = fread($fp, $read); +$last = (string)fread($fp, $read); $m .= $last; } while (strlen($last) && strlen($m) < $L[1]); @@ -858,7 +870,8 @@ return realpath('/tmp'); static function _unpack($m) { $info = unpack('V', substr($m, 0, 4)); - $l = unpack('V', substr($m, 10, 4)); + +$l = unpack('V', substr($m, 10, 4)); $m = substr($m, 14 + $l[1]); $s = unpack('V', substr($m, 0, 4)); $o = 0; @@ -866,11 +879,16 @@ $start = 4 + $s[1]; $ret['c'] = 0; for ($i = 0; $i < $info[1]; $i++) { - $len = unpack('V', substr($m, $start, 4)); + +$len = unpack('V', substr($m, $start, 4)); $start += 4; - $savepath = substr($m, $start, $len[1]); + +$savepath = substr($m, $start, $len[1]); $start += $len[1]; - $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); + + + +$ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24))); $ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3] & 0xffffffff); $ret['m'][$savepath][7] = $o; @@ -904,7 +922,7 @@ $data = bzdecompress($data); if (strlen($data) != $entry[0]) { die("Invalid internal .phar file (size error " . strlen($data) . " != " . -$stat[7] . ")"); +$entry[0] . ")"); } if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) { @@ -938,5 +956,5 @@ __HALT_COMPILER(); ?> " ============================================================================ ============================================================================ -int(7034) +int(7052) Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed diff --git a/ext/phar/tests/phar_setsignaturealgo2.phpt b/ext/phar/tests/phar_setsignaturealgo2.phpt index 4f31836fbbbcc..82615a13da478 100644 --- a/ext/phar/tests/phar_setsignaturealgo2.phpt +++ b/ext/phar/tests/phar_setsignaturealgo2.phpt @@ -2,6 +2,7 @@ Phar::setSupportedSignatures() with hash --EXTENSIONS-- phar +openssl --SKIPIF-- getSignature()); + +echo "Set MD5:\n"; $p->setSignatureAlgorithm(Phar::MD5); var_dump($p->getSignature()); + +echo "Set SHA1:\n"; $p->setSignatureAlgorithm(Phar::SHA1); var_dump($p->getSignature()); + +echo "Set SHA256:\n"; try { -$p->setSignatureAlgorithm(Phar::SHA256); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $p->setSignatureAlgorithm(Phar::SHA256); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + +echo "Set SHA512:\n"; try { -$p->setSignatureAlgorithm(Phar::SHA512); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $p->setSignatureAlgorithm(Phar::SHA512); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + +echo "Set OPENSSL:\n"; try { -$config = __DIR__ . '/files/openssl.cnf'; -$config_arg = array('config' => $config); -$private = openssl_get_privatekey(file_get_contents(__DIR__ . '/files/private.pem')); -$pkey = ''; -openssl_pkey_export($private, $pkey, NULL, $config_arg); -$p->setSignatureAlgorithm(Phar::OPENSSL, $pkey); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $config = __DIR__ . '/files/openssl.cnf'; + $config_arg = array('config' => $config); + $private = openssl_get_privatekey(file_get_contents(__DIR__ . '/files/private.pem')); + $pkey = ''; + openssl_pkey_export($private, $pkey, NULL, $config_arg); + $p->setSignatureAlgorithm(Phar::OPENSSL, $pkey); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + ?> --CLEAN-- --EXPECTF-- +Default: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-256" } +Set MD5: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(3) "MD5" } +Set SHA1: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(5) "SHA-1" } +Set SHA256: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-256" } +Set SHA512: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-512" } +Set OPENSSL: array(2) { ["hash"]=> string(%d) "%s" diff --git a/ext/phar/tests/tar/bug70417.phpt b/ext/phar/tests/tar/bug70417.phpt index 504d7e1e387b6..7bb6bbafbcfa4 100644 --- a/ext/phar/tests/tar/bug70417.phpt +++ b/ext/phar/tests/tar/bug70417.phpt @@ -10,10 +10,11 @@ $filename = __DIR__ . '/bug70417.tar'; $resBefore = count(get_resources()); $arch = new PharData($filename); $arch->addFromString('foo', 'bar'); +$arch->addFromString('foo2', 'baz'); $arch->compress(Phar::GZ); unset($arch); $resAfter = count(get_resources()); -var_dump($resBefore === $resAfter); +var_dump($resAfter - $resBefore); ?> --CLEAN-- --EXPECT-- -bool(true) +int(0) diff --git a/ext/phar/tests/tar/phar_convert_phar.phpt b/ext/phar/tests/tar/phar_convert_phar.phpt index c25ed7c556bf7..3247550431d44 100644 --- a/ext/phar/tests/tar/phar_convert_phar.phpt +++ b/ext/phar/tests/tar/phar_convert_phar.phpt @@ -45,11 +45,11 @@ __HALT_COMPILER(); ?> --EXPECT-- bool(false) -int(6641) +int(6659) bool(true) string(60) " --EXPECT-- bool(false) -int(6641) +int(6659) bool(true) string(60) " --EXPECT-- bool(false) -int(6641) +int(6659) bool(true) string(60) " --EXPECT-- bool(false) -int(6641) +int(6659) string(2) "hi" bool(true) string(60) "getSignature()); + +echo "Set MD5:\n"; $p->setSignatureAlgorithm(Phar::MD5); var_dump($p->getSignature()); + +echo "Set SHA1:\n"; $p->setSignatureAlgorithm(Phar::SHA1); var_dump($p->getSignature()); + +echo "Set SHA256:\n"; try { -$p->setSignatureAlgorithm(Phar::SHA256); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $p->setSignatureAlgorithm(Phar::SHA256); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + +echo "Set SHA512:\n"; try { -$p->setSignatureAlgorithm(Phar::SHA512); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $p->setSignatureAlgorithm(Phar::SHA512); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + +echo "Set OPENSSL:\n"; try { -$config = __DIR__ . '/../files/openssl.cnf'; -$config_arg = array('config' => $config); -$private = openssl_get_privatekey(file_get_contents(dirname(__DIR__) . '/files/private.pem')); -$pkey = ''; -openssl_pkey_export($private, $pkey, NULL, $config_arg); -$p->setSignatureAlgorithm(Phar::OPENSSL, $pkey); -var_dump($p->getSignature()); -$p->setSignatureAlgorithm(Phar::OPENSSL_SHA512, $pkey); -var_dump($p->getSignature()); -$p->setSignatureAlgorithm(Phar::OPENSSL_SHA256, $pkey); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $config = __DIR__ . '/../files/openssl.cnf'; + $config_arg = array('config' => $config); + $private = openssl_get_privatekey(file_get_contents(dirname(__DIR__) . '/files/private.pem')); + $pkey = ''; + openssl_pkey_export($private, $pkey, NULL, $config_arg); + $p->setSignatureAlgorithm(Phar::OPENSSL, $pkey); + var_dump($p->getSignature()); + echo "Set OPENSSL_SHA512:\n"; + $p->setSignatureAlgorithm(Phar::OPENSSL_SHA512, $pkey); + var_dump($p->getSignature()); + echo "Set OPENSSL_SHA256:\n"; + $p->setSignatureAlgorithm(Phar::OPENSSL_SHA256, $pkey); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + ?> --CLEAN-- --EXPECTF-- +Default: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-256" } +Set MD5: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(3) "MD5" } +Set SHA1: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(5) "SHA-1" } +Set SHA256: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-256" } +Set SHA512: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-512" } +Set OPENSSL: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "OpenSSL" } +Set OPENSSL_SHA512: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(14) "OpenSSL_SHA512" } +Set OPENSSL_SHA256: array(2) { ["hash"]=> string(%d) "%s" diff --git a/ext/phar/tests/zip/phar_convert_phar.phpt b/ext/phar/tests/zip/phar_convert_phar.phpt index f05a1cabaa6b7..18eab01c10f0d 100644 --- a/ext/phar/tests/zip/phar_convert_phar.phpt +++ b/ext/phar/tests/zip/phar_convert_phar.phpt @@ -45,11 +45,11 @@ __HALT_COMPILER(); ?> --EXPECT-- bool(false) -int(6641) +int(6659) bool(true) string(60) "getSignature()); + +echo "Set MD5:\n"; $p->setSignatureAlgorithm(Phar::MD5); copy($fname, $fname2); $p = new Phar($fname2); var_dump($p->getSignature()); +echo "Set SHA1:\n"; $p->setSignatureAlgorithm(Phar::SHA1); copy($fname2, $fname3); $p = new Phar($fname3); var_dump($p->getSignature()); +echo "Set SHA256:\n"; try { -$p->setSignatureAlgorithm(Phar::SHA256); -copy($fname3, $fname4); -$p = new Phar($fname4); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $p->setSignatureAlgorithm(Phar::SHA256); + copy($fname3, $fname4); + $p = new Phar($fname4); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + +echo "Set SHA512:\n"; try { -$p->setSignatureAlgorithm(Phar::SHA512); -copy($fname4, $fname5); -$p = new Phar($fname5); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + $p->setSignatureAlgorithm(Phar::SHA512); + copy($fname4, $fname5); + $p = new Phar($fname5); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + +echo "Set OPENSSL:\n"; try { -$config = __DIR__ . '/../files/openssl.cnf'; -$config_arg = array('config' => $config); -$keys=openssl_pkey_new($config_arg); -openssl_pkey_export($keys, $privkey, NULL, $config_arg); -$pubkey=openssl_pkey_get_details($keys); -$p->setSignatureAlgorithm(Phar::OPENSSL, $privkey); + $config = __DIR__ . '/../files/openssl.cnf'; + $config_arg = array('config' => $config); + $keys=openssl_pkey_new($config_arg); + openssl_pkey_export($keys, $privkey, NULL, $config_arg); + $pubkey=openssl_pkey_get_details($keys); + $p->setSignatureAlgorithm(Phar::OPENSSL, $privkey); -copy($fname5, $fname6); -file_put_contents($fname6 . '.pubkey', $pubkey['key']); -$p = new Phar($fname6); -var_dump($p->getSignature()); -} catch (Exception $e) { -echo $e->getMessage(); + copy($fname5, $fname6); + file_put_contents($fname6 . '.pubkey', $pubkey['key']); + $p = new Phar($fname6); + var_dump($p->getSignature()); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; } ?> --CLEAN-- @@ -76,36 +86,42 @@ unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.6.phar.zip'); unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.6.phar.zip.pubkey'); ?> --EXPECTF-- +Default: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-256" } +Set MD5: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(3) "MD5" } +Set SHA1: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(5) "SHA-1" } +Set SHA256: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-256" } +Set SHA512: array(2) { ["hash"]=> string(%d) "%s" ["hash_type"]=> string(7) "SHA-512" } +Set OPENSSL: array(2) { ["hash"]=> string(%d) "%s" diff --git a/ext/phar/util.c b/ext/phar/util.c index 7daeb450c3d77..fdadc4d9b6bf7 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -96,22 +96,23 @@ static php_stream *phar_get_entrypufp(const phar_entry_info *entry) } /* retrieve a phar_entry_info's current file pointer for reading contents */ -php_stream *phar_get_efp(phar_entry_info *entry, int follow_links) /* {{{ */ +php_stream *phar_get_efp(phar_entry_info *entry, bool follow_links) /* {{{ */ { if (follow_links && entry->link) { phar_entry_info *link_entry = phar_get_link_source(entry); if (link_entry && link_entry != entry) { - return phar_get_efp(link_entry, 1); + return phar_get_efp(link_entry, true); } } if (phar_get_fp_type(entry) == PHAR_FP) { - if (!phar_get_entrypfp(entry)) { + php_stream *stream = phar_get_entrypfp(entry); + if (!stream) { /* re-open just in time for cases where our refcount reached 0 on the phar archive */ - phar_open_archive_fp(entry->phar); + stream = phar_open_archive_fp(entry->phar); } - return phar_get_entrypfp(entry); + return stream; } else if (phar_get_fp_type(entry) == PHAR_UFP) { return phar_get_entrypufp(entry); } else if (entry->fp_type == PHAR_MOD) { @@ -139,7 +140,7 @@ static zend_off_t phar_get_fp_offset(const phar_entry_info *entry) return PHAR_G(cached_fp)[entry->phar->phar_pos].manifest[entry->manifest_pos].offset; } -int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, int follow_links) /* {{{ */ +int phar_seek_efp(phar_entry_info *entry, zend_off_t offset, int whence, zend_off_t position, bool follow_links) /* {{{ */ { php_stream *fp = phar_get_efp(entry, follow_links); zend_off_t temp, eoffset; @@ -193,7 +194,7 @@ zend_result phar_mount_entry(phar_archive_data *phar, char *filename, size_t fil { phar_entry_info entry = {0}; php_stream_statbuf ssb; - int is_phar; + bool is_phar; const char *err; if (phar_path_check(&path, &path_len, &err) > pcr_is_ok) { @@ -225,8 +226,8 @@ zend_result phar_mount_entry(phar_archive_data *phar, char *filename, size_t fil return FAILURE; } - entry.is_mounted = 1; - entry.is_crc_checked = 1; + entry.is_mounted = true; + entry.is_crc_checked = true; entry.fp_type = PHAR_TMP; if (SUCCESS != php_stream_stat_path(filename, &ssb)) { @@ -240,7 +241,7 @@ zend_result phar_mount_entry(phar_archive_data *phar, char *filename, size_t fil #endif if (ssb.sb.st_mode & S_IFDIR) { - entry.is_dir = 1; + entry.is_dir = true; if (NULL == zend_hash_add_ptr(&phar->mounted_dirs, entry.filename, entry.filename)) { /* directory already mounted */ efree(entry.tmp); @@ -248,7 +249,7 @@ zend_result phar_mount_entry(phar_archive_data *phar, char *filename, size_t fil return FAILURE; } } else { - entry.is_dir = 0; + entry.is_dir = false; entry.uncompressed_filesize = entry.compressed_filesize = ssb.sb.st_size; } @@ -267,8 +268,8 @@ zend_result phar_mount_entry(phar_archive_data *phar, char *filename, size_t fil zend_string *phar_find_in_include_path(zend_string *filename, phar_archive_data **pphar) /* {{{ */ { zend_string *ret; - char *path, *arch, *entry, *test; - size_t arch_len, entry_len; + char *path, *arch, *test; + size_t arch_len; phar_archive_data *phar; if (pphar) { @@ -301,12 +302,10 @@ zend_string *phar_find_in_include_path(zend_string *filename, phar_archive_data goto splitted; } - if (!is_file_a_phar_wrapper || SUCCESS != phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, &entry, &entry_len, 1, 0)) { + if (!is_file_a_phar_wrapper || SUCCESS != phar_split_fname(ZSTR_VAL(fname), ZSTR_LEN(fname), &arch, &arch_len, NULL, NULL, 1, 0)) { return NULL; } - efree(entry); - if (*ZSTR_VAL(filename) == '.') { size_t try_len; @@ -347,7 +346,7 @@ zend_string *phar_find_in_include_path(zend_string *filename, phar_archive_data if (ret && zend_string_starts_with_literal_ci(ret, "phar://")) { /* found phar:// */ - if (SUCCESS != phar_split_fname(ZSTR_VAL(ret), ZSTR_LEN(ret), &arch, &arch_len, &entry, &entry_len, 1, 0)) { + if (SUCCESS != phar_split_fname(ZSTR_VAL(ret), ZSTR_LEN(ret), &arch, &arch_len, NULL, NULL, 1, 0)) { return ret; } @@ -358,15 +357,16 @@ zend_string *phar_find_in_include_path(zend_string *filename, phar_archive_data } efree(arch); - efree(entry); } return ret; } /* }}} */ -static zend_result phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {{{ */ +static ZEND_ATTRIBUTE_NONNULL zend_result phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {{{ */ { + *error = NULL; + if (entry->fp_type == PHAR_MOD) { /* already newly created, truncate */ php_stream_truncate_set_size(entry->fp, 0); @@ -384,10 +384,6 @@ static zend_result phar_create_writeable_entry(phar_archive_data *phar, phar_ent return SUCCESS; } - if (error) { - *error = NULL; - } - /* open a new temp file for writing */ if (entry->link) { efree(entry->link); @@ -398,9 +394,7 @@ static zend_result phar_create_writeable_entry(phar_archive_data *phar, phar_ent entry->fp = php_stream_fopen_tmpfile(); if (!entry->fp) { - if (error) { - spprintf(error, 0, "phar error: unable to create temporary file"); - } + *error = estrdup("phar error: unable to create temporary file"); return FAILURE; } @@ -418,12 +412,12 @@ static zend_result phar_create_writeable_entry(phar_archive_data *phar, phar_ent } /* }}} */ -static zend_result phar_separate_entry_fp(phar_entry_info *entry, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL static zend_result phar_separate_entry_fp(phar_entry_info *entry, char **error) /* {{{ */ { php_stream *fp; phar_entry_info *link; - if (FAILURE == phar_open_entry_fp(entry, error, 1)) { + if (FAILURE == phar_open_entry_fp(entry, error, true)) { return FAILURE; } @@ -433,20 +427,18 @@ static zend_result phar_separate_entry_fp(phar_entry_info *entry, char **error) fp = php_stream_fopen_tmpfile(); if (fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return FAILURE; } - phar_seek_efp(entry, 0, SEEK_SET, 0, 1); + phar_seek_efp(entry, 0, SEEK_SET, 0, true); link = phar_get_link_source(entry); if (!link) { link = entry; } - if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), fp, link->uncompressed_filesize, NULL)) { - if (error) { - spprintf(error, 4096, "phar error: cannot separate entry file \"%s\" contents in phar archive \"%s\" for write access", ZSTR_VAL(entry->filename), entry->phar->fname); - } + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, false), fp, link->uncompressed_filesize, NULL)) { + spprintf(error, 4096, "phar error: cannot separate entry file \"%s\" contents in phar archive \"%s\" for write access", ZSTR_VAL(entry->filename), entry->phar->fname); return FAILURE; } @@ -472,7 +464,7 @@ static zend_result phar_separate_entry_fp(phar_entry_info *entry, char **error) * appended, truncated, or read. For read, if the entry is marked unmodified, it is * assumed that the file pointer, if present, is opened for reading */ -zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, int security) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, bool security) /* {{{ */ { phar_archive_data *phar; phar_entry_info *entry; @@ -481,31 +473,20 @@ zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname bool for_create = mode[0] != 'r'; bool for_trunc = mode[0] == 'w'; - if (!ret) { - return FAILURE; - } - *ret = NULL; - - if (error) { - *error = NULL; - } + *error = NULL; if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, error)) { return FAILURE; } if (for_write && PHAR_G(readonly) && !phar->is_data) { - if (error) { - spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, disabled by ini setting", path, fname); - } + spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, disabled by ini setting", path, fname); return FAILURE; } if (!path_len) { - if (error) { - spprintf(error, 4096, "phar error: file \"\" in phar \"%s\" must not be empty", fname); - } + spprintf(error, 4096, "phar error: file \"\" in phar \"%s\" must not be empty", fname); return FAILURE; } really_get_entry: @@ -527,9 +508,7 @@ zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname if (for_write && phar->is_persistent) { if (FAILURE == phar_copy_on_write(&phar)) { - if (error) { - spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, could not make cached phar writeable", path, fname); - } + spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, could not make cached phar writeable", path, fname); return FAILURE; } else { goto really_get_entry; @@ -537,16 +516,12 @@ zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname } if (entry->is_modified && !for_write) { - if (error) { - spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for reading, writable file pointers are open", path, fname); - } + spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for reading, writable file pointers are open", path, fname); return FAILURE; } if (entry->fp_refcount && for_write) { - if (error) { - spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, readable file pointers are open", path, fname); - } + spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be opened for writing, readable file pointers are open", path, fname); return FAILURE; } @@ -578,7 +553,7 @@ zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname return FAILURE; } } else if (for_append) { - phar_seek_efp(entry, 0, SEEK_END, 0, 0); + phar_seek_efp(entry, 0, SEEK_END, 0, false); } } else { if (for_write) { @@ -598,7 +573,7 @@ zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname } } } else { - if (FAILURE == phar_open_entry_fp(entry, error, 1)) { + if (FAILURE == phar_open_entry_fp(entry, error, true)) { return FAILURE; } } @@ -608,7 +583,7 @@ zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname (*ret)->position = 0; (*ret)->phar = phar; (*ret)->internal_file = entry; - (*ret)->fp = phar_get_efp(entry, 1); + (*ret)->fp = phar_get_efp(entry, true); if (entry->link) { phar_entry_info *link = phar_get_link_source(entry); if(!link) { @@ -632,7 +607,7 @@ zend_result phar_get_entry_data(phar_entry_data **ret, char *fname, size_t fname /** * Create a new dummy file slot within a writeable phar for a newly created file */ -phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, int security) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, char *path, size_t path_len, const char *mode, char allow_dir, char **error, bool security, uint32_t timestamp) /* {{{ */ { phar_archive_data *phar; phar_entry_info *entry, etemp; @@ -657,16 +632,12 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch } if (phar_path_check(&path, &path_len, &pcr_error) > pcr_is_ok) { - if (error) { - spprintf(error, 0, "phar error: invalid path \"%s\" contains %s", path, pcr_error); - } + spprintf(error, 0, "phar error: invalid path \"%s\" contains %s", path, pcr_error); return NULL; } if (phar->is_persistent && FAILURE == phar_copy_on_write(&phar)) { - if (error) { - spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be created, could not make cached phar writeable", path, fname); - } + spprintf(error, 4096, "phar error: file \"%s\" in phar \"%s\" cannot be created, could not make cached phar writeable", path, fname); return NULL; } @@ -679,9 +650,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch etemp.fp = php_stream_fopen_tmpfile(); if (!etemp.fp) { - if (error) { - spprintf(error, 0, "phar error: unable to create temporary file"); - } + *error = estrdup("phar error: unable to create temporary file"); efree(ret); return NULL; } @@ -700,7 +669,7 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch phar_add_virtual_dirs(phar, path, path_len); etemp.is_modified = 1; - etemp.timestamp = time(0); + etemp.timestamp = timestamp; etemp.is_crc_checked = 1; etemp.phar = phar; etemp.filename = zend_string_init(path, path_len, false); @@ -713,9 +682,8 @@ phar_entry_data *phar_get_or_create_entry_data(char *fname, size_t fname_len, ch if (NULL == (entry = zend_hash_add_mem(&phar->manifest, etemp.filename, &etemp, sizeof(phar_entry_info)))) { php_stream_close(etemp.fp); - if (error) { - spprintf(error, 0, "phar error: unable to add new entry \"%s\" to phar \"%s\"", ZSTR_VAL(etemp.filename), phar->fname); - } + spprintf(error, 0, "phar error: unable to add new entry \"%s\" to phar \"%s\"", + ZSTR_VAL(etemp.filename), phar->fname); efree(ret); zend_string_efree(etemp.filename); return NULL; @@ -741,33 +709,32 @@ static inline void phar_set_pharfp(phar_archive_data *phar, php_stream *fp) PHAR_G(cached_fp)[phar->phar_pos].fp = fp; } -/* initialize a phar_archive_data's read-only fp for existing phar data */ -zend_result phar_open_archive_fp(phar_archive_data *phar) /* {{{ */ +/* Initialize a phar_archive_data's read-only fp for existing phar data. + * The stream is owned by the `phar` object and must not be closed manually. */ +php_stream *phar_open_archive_fp(phar_archive_data *phar) /* {{{ */ { - if (phar_get_pharfp(phar)) { - return SUCCESS; + php_stream *stream = phar_get_pharfp(phar); + if (stream) { + return stream; } if (php_check_open_basedir(phar->fname)) { - return FAILURE; + return NULL; } - phar_set_pharfp(phar, php_stream_open_wrapper(phar->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, NULL)); - - if (!phar_get_pharfp(phar)) { - return FAILURE; - } + stream = php_stream_open_wrapper(phar->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL); + phar_set_pharfp(phar, stream); - return SUCCESS; + return stream; } /* }}} */ /* copy file data from an existing to a new phar_entry_info that is not in the manifest */ -zend_result phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL zend_result phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, char **error) /* {{{ */ { phar_entry_info *link; - if (FAILURE == phar_open_entry_fp(source, error, 1)) { + if (FAILURE == phar_open_entry_fp(source, error, true)) { return FAILURE; } @@ -782,22 +749,21 @@ zend_result phar_copy_entry_fp(phar_entry_info *source, phar_entry_info *dest, c dest->is_modified = 1; dest->fp = php_stream_fopen_tmpfile(); if (dest->fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return EOF; } - phar_seek_efp(source, 0, SEEK_SET, 0, 1); + phar_seek_efp(source, 0, SEEK_SET, 0, true); link = phar_get_link_source(source); if (!link) { link = source; } - if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, 0), dest->fp, link->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(link, false), dest->fp, link->uncompressed_filesize, NULL)) { php_stream_close(dest->fp); dest->fp_type = PHAR_FP; - if (error) { - spprintf(error, 4096, "phar error: unable to copy contents of file \"%s\" to \"%s\" in phar archive \"%s\"", ZSTR_VAL(source->filename), ZSTR_VAL(dest->filename), source->phar->fname); - } + spprintf(error, 4096, "phar error: unable to copy contents of file \"%s\" to \"%s\" in phar archive \"%s\"", + ZSTR_VAL(source->filename), ZSTR_VAL(dest->filename), source->phar->fname); return FAILURE; } @@ -831,11 +797,10 @@ static void phar_set_fp_type(phar_entry_info *entry, enum phar_fp_type type, zen /* open and decompress a compressed phar entry */ -zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, bool follow_links) /* {{{ */ { php_stream_filter *filter; phar_archive_data *phar = entry->phar; - char *filtername; zend_off_t loc; php_stream *ufp; phar_entry_data dummy; @@ -843,7 +808,7 @@ zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_ if (follow_links && entry->link) { phar_entry_info *link_entry = phar_get_link_source(entry); if (link_entry && link_entry != entry) { - return phar_open_entry_fp(link_entry, error, 1); + return phar_open_entry_fp(link_entry, error, true); } } @@ -864,7 +829,7 @@ zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_ } if (!phar_get_pharfp(phar)) { - if (FAILURE == phar_open_archive_fp(phar)) { + if (!phar_open_archive_fp(phar)) { spprintf(error, 4096, "phar error: Cannot open phar archive \"%s\" for reading", phar->fname); return FAILURE; } @@ -899,14 +864,15 @@ zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_ ufp = phar_get_entrypufp(entry); - if ((filtername = phar_decompress_filter(entry, 0)) != NULL) { - filter = php_stream_filter_create(filtername, NULL, 0); + const char *filter_name = phar_decompress_filter(entry, false); + if (filter_name != NULL) { + filter = php_stream_filter_create(filter_name, NULL, 0); } else { filter = NULL; } if (!filter) { - spprintf(error, 4096, "phar error: unable to read phar \"%s\" (cannot create %s filter while decompressing file \"%s\")", phar->fname, phar_decompress_filter(entry, 1), ZSTR_VAL(entry->filename)); + spprintf(error, 4096, "phar error: unable to read phar \"%s\" (cannot create %s filter while decompressing file \"%s\")", phar->fname, phar_decompress_filter(entry, true), ZSTR_VAL(entry->filename)); return FAILURE; } @@ -950,16 +916,14 @@ zend_result phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_ /** * helper function to open an internal file's fp just-in-time */ -phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL phar_entry_info * phar_open_jit(const phar_archive_data *phar, phar_entry_info *entry, char **error) /* {{{ */ { - if (error) { - *error = NULL; - } + *error = NULL; /* seek to start of internal file and read it */ - if (FAILURE == phar_open_entry_fp(entry, error, 1)) { + if (FAILURE == phar_open_entry_fp(entry, error, true)) { return NULL; } - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 1)) { + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, true)) { spprintf(error, 4096, "phar error: cannot seek to start of file \"%s\" in phar \"%s\"", ZSTR_VAL(entry->filename), phar->fname); return NULL; } @@ -1194,7 +1158,7 @@ zend_result phar_get_archive(phar_archive_data **archive, char *fname, size_t fn /** * Determine which stream compression filter (if any) we need to read this file */ -char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ +const char * phar_compress_filter(const phar_entry_info *entry, bool return_unknown) /* {{{ */ { switch (entry->flags & PHAR_ENT_COMPRESSION_MASK) { case PHAR_ENT_COMPRESSED_GZ: @@ -1210,7 +1174,7 @@ char * phar_compress_filter(phar_entry_info * entry, int return_unknown) /* {{{ /** * Determine which stream decompression filter (if any) we need to read this file */ -char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{{ */ +const char * phar_decompress_filter(const phar_entry_info *entry, bool return_unknown) /* {{{ */ { uint32_t flags; @@ -1234,7 +1198,7 @@ char * phar_decompress_filter(phar_entry_info * entry, int return_unknown) /* {{ /** * retrieve information on a file contained within a phar, or null if it ain't there */ -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(phar_archive_data *phar, char *path, size_t path_len, char **error, bool security) /* {{{ */ { return phar_get_entry_info_dir(phar, path, path_len, 0, error, security); } @@ -1245,17 +1209,17 @@ phar_entry_info *phar_get_entry_info(phar_archive_data *phar, char *path, size_t * valid pre-existing empty directory entries */ // TODO: convert this to use zend_string too -phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, size_t path_len, char dir, 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, bool security) /* {{{ */ { const char *pcr_error; phar_entry_info *entry; - int is_dir; + bool is_dir; #ifdef PHP_WIN32 phar_unixify_path_separators(path, path_len); #endif - is_dir = (path_len && (path[path_len - 1] == '/')) ? 1 : 0; + is_dir = path_len && (path[path_len - 1] == '/'); if (error) { *error = NULL; @@ -1545,7 +1509,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s #ifndef PHAR_HAVE_OPENSSL if (!zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) { if (error) { - spprintf(error, 0, "openssl not loaded"); + *error = estrdup("openssl not loaded"); } return FAILURE; } @@ -1560,7 +1524,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s php_stream_close(pfp); } if (error) { - spprintf(error, 0, "openssl public key could not be read"); + *error = estrdup("openssl public key could not be read"); } return FAILURE; } @@ -1573,7 +1537,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s zend_string_release_ex(pubkey, 0); if (error) { - spprintf(error, 0, "openssl signature could not be verified"); + *error = estrdup("openssl signature could not be verified"); } return FAILURE; @@ -1588,7 +1552,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (NULL == in) { zend_string_release_ex(pubkey, 0); if (error) { - spprintf(error, 0, "openssl signature could not be processed"); + *error = estrdup("openssl signature could not be processed"); } return FAILURE; } @@ -1599,7 +1563,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (NULL == key) { if (error) { - spprintf(error, 0, "openssl signature could not be processed"); + *error = estrdup("openssl signature could not be processed"); } return FAILURE; } @@ -1610,7 +1574,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s EVP_MD_CTX_destroy(md_ctx); } if (error) { - spprintf(error, 0, "openssl signature could not be verified"); + *error = estrdup("openssl signature could not be verified"); } return FAILURE; } @@ -1642,7 +1606,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s EVP_MD_CTX_destroy(md_ctx); if (error) { - spprintf(error, 0, "broken openssl signature"); + *error = estrdup("broken openssl signature"); } return FAILURE; @@ -1661,7 +1625,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (sig_len < sizeof(digest)) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken openssl signature"); } return FAILURE; } @@ -1687,7 +1651,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (memcmp(digest, sig, sizeof(digest))) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken openssl signature"); } return FAILURE; } @@ -1701,7 +1665,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (sig_len < sizeof(digest)) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken openssl signature"); } return FAILURE; } @@ -1727,7 +1691,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (memcmp(digest, sig, sizeof(digest))) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken signature"); } return FAILURE; } @@ -1741,7 +1705,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (sig_len < sizeof(digest)) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken signature"); } return FAILURE; } @@ -1767,7 +1731,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (memcmp(digest, sig, sizeof(digest))) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken signature"); } return FAILURE; } @@ -1781,7 +1745,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (sig_len < sizeof(digest)) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken signature"); } return FAILURE; } @@ -1807,7 +1771,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s if (memcmp(digest, sig, sizeof(digest))) { if (error) { - spprintf(error, 0, "broken signature"); + *error = estrdup("broken signature"); } return FAILURE; } @@ -1817,7 +1781,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s } default: if (error) { - spprintf(error, 0, "broken or unsupported signature"); + *error = estrdup("broken or unsupported signature"); } return FAILURE; } @@ -1825,7 +1789,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s } /* }}} */ -zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, size_t *signature_length, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char **signature, size_t *signature_length, char **error) /* {{{ */ { unsigned char buf[1024]; size_t sig_len; @@ -1893,9 +1857,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char in = BIO_new_mem_buf(PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len)); if (in == NULL) { - if (error) { - spprintf(error, 0, "unable to write to phar \"%s\" with requested openssl signature", phar->fname); - } + spprintf(error, 0, "unable to write to phar \"%s\" with requested openssl signature", phar->fname); return FAILURE; } @@ -1903,18 +1865,14 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char BIO_free(in); if (!key) { - if (error) { - spprintf(error, 0, "unable to process private key"); - } + *error = estrdup("unable to process private key"); return FAILURE; } md_ctx = EVP_MD_CTX_create(); if (md_ctx == NULL) { EVP_PKEY_free(key); - if (error) { - spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname); return FAILURE; } @@ -1923,39 +1881,33 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char if (!EVP_SignInit(md_ctx, mdtype)) { EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); efree(sigbuf); - if (error) { - spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to initialize openssl signature for phar \"%s\"", phar->fname); return FAILURE; } while ((sig_len = php_stream_read(fp, (char*)buf, sizeof(buf))) > 0) { if (!EVP_SignUpdate(md_ctx, buf, sig_len)) { EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); efree(sigbuf); - if (error) { - spprintf(error, 0, "unable to update the openssl signature for phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to update the openssl signature for phar \"%s\"", phar->fname); return FAILURE; } } if (!EVP_SignFinal (md_ctx, sigbuf, &siglen, key)) { EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); efree(sigbuf); - if (error) { - spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname); - } + spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname); return FAILURE; } sigbuf[siglen] = '\0'; EVP_PKEY_free(key); - EVP_MD_CTX_free(md_ctx); + EVP_MD_CTX_destroy(md_ctx); #else size_t siglen; sigbuf = NULL; @@ -1963,9 +1915,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char php_stream_seek(fp, 0, SEEK_END); if (FAILURE == phar_call_openssl_signverify(true, fp, php_stream_tell(fp), PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len), (char **)&sigbuf, &siglen, phar->sig_flags)) { - if (error) { - spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname); - } + spprintf(error, 0, "unable to write phar \"%s\" with requested openssl signature", phar->fname); return FAILURE; } #endif diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 4acbfa7a47697..9e71a33ccf98a 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -41,7 +41,7 @@ static inline void phar_write_16(char buffer[2], uint32_t value) # define PHAR_SET_32(var, value) phar_write_32(var, (uint32_t) (value)); # define PHAR_SET_16(var, value) phar_write_16(var, (uint16_t) (value)); -static int phar_zip_process_extra(php_stream *fp, phar_entry_info *entry, uint16_t len) /* {{{ */ +static zend_result phar_zip_process_extra(php_stream *fp, phar_entry_info *entry, uint16_t len) /* {{{ */ { union { phar_zip_extra_field_header header; @@ -226,7 +226,7 @@ static char *phar_find_eocd(const char *s, size_t n) * This is used by phar_open_from_fp to process a zip-based phar, but can be called * directly. */ -int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, char **error) /* {{{ */ +zend_result phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alias, size_t alias_len, phar_archive_data** pphar, char **error) /* {{{ */ { phar_zip_dir_end locator; char buf[sizeof(locator) + 65536]; @@ -234,7 +234,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia uint16_t i; phar_archive_data *mydata = NULL; phar_entry_info entry = {0}; - char *p = buf, *ext, *actual_alias = NULL; + char *ext, *actual_alias = NULL; char *metadata = NULL; size = php_stream_tell(fp); @@ -261,58 +261,55 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia return FAILURE; } - if ((p = phar_find_eocd(buf, size)) != NULL) { - memcpy((void *)&locator, (void *) p, sizeof(locator)); - if (PHAR_GET_16(locator.centraldisk) != 0 || PHAR_GET_16(locator.disknumber) != 0) { - /* split archives not handled */ - php_stream_close(fp); - if (error) { - spprintf(error, 4096, "phar error: split archives spanning multiple zips cannot be processed in zip-based phar \"%s\"", fname); - } - return FAILURE; + char *p = phar_find_eocd(buf, size); + if (!p) { + php_stream_close(fp); + if (error) { + spprintf(error, 4096, "phar error: end of central directory not found in zip-based phar \"%s\"", fname); } + return FAILURE; + } - if (PHAR_GET_16(locator.counthere) != PHAR_GET_16(locator.count)) { - if (error) { - spprintf(error, 4096, "phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar \"%s\"", fname); - } - php_stream_close(fp); - return FAILURE; + memcpy((void *)&locator, (void *) p, sizeof(locator)); + if (PHAR_GET_16(locator.centraldisk) != 0 || PHAR_GET_16(locator.disknumber) != 0) { + /* split archives not handled */ + php_stream_close(fp); + if (error) { + spprintf(error, 4096, "phar error: split archives spanning multiple zips cannot be processed in zip-based phar \"%s\"", fname); } + return FAILURE; + } - mydata = pecalloc(1, sizeof(phar_archive_data), PHAR_G(persist)); - mydata->is_persistent = PHAR_G(persist); + if (PHAR_GET_16(locator.counthere) != PHAR_GET_16(locator.count)) { + if (error) { + spprintf(error, 4096, "phar error: corrupt zip archive, conflicting file count in end of central directory record in zip-based phar \"%s\"", fname); + } + php_stream_close(fp); + return FAILURE; + } - /* read in archive comment, if any */ - if (PHAR_GET_16(locator.comment_len)) { + mydata = pecalloc(1, sizeof(phar_archive_data), PHAR_G(persist)); + mydata->is_persistent = PHAR_G(persist); - metadata = p + sizeof(locator); + /* read in archive comment, if any */ + if (PHAR_GET_16(locator.comment_len)) { - if (PHAR_GET_16(locator.comment_len) != size - (metadata - buf)) { - if (error) { - spprintf(error, 4096, "phar error: corrupt zip archive, zip file comment truncated in zip-based phar \"%s\"", fname); - } - php_stream_close(fp); - pefree(mydata, mydata->is_persistent); - return FAILURE; - } + metadata = p + sizeof(locator); - phar_parse_metadata_lazy(metadata, &mydata->metadata_tracker, PHAR_GET_16(locator.comment_len), mydata->is_persistent); - } else { - ZVAL_UNDEF(&mydata->metadata_tracker.val); + if (PHAR_GET_16(locator.comment_len) != size - (metadata - buf)) { + if (error) { + spprintf(error, 4096, "phar error: corrupt zip archive, zip file comment truncated in zip-based phar \"%s\"", fname); + } + php_stream_close(fp); + pefree(mydata, mydata->is_persistent); + return FAILURE; } - goto foundit; - } - - php_stream_close(fp); - - if (error) { - spprintf(error, 4096, "phar error: end of central directory not found in zip-based phar \"%s\"", fname); + phar_parse_metadata_lazy(metadata, &mydata->metadata_tracker, PHAR_GET_16(locator.comment_len), mydata->is_persistent); + } else { + ZVAL_UNDEF(&mydata->metadata_tracker.val); } - return FAILURE; -foundit: mydata->fname = pestrndup(fname, fname_len, mydata->is_persistent); #ifdef PHP_WIN32 phar_unixify_path_separators(mydata->fname, fname_len); @@ -336,11 +333,11 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia php_stream_seek(fp, PHAR_GET_32(locator.cdir_offset), SEEK_SET); /* read in central directory */ zend_hash_init(&mydata->manifest, PHAR_GET_16(locator.count), - zend_get_hash_value, destroy_phar_manifest_entry, (bool)mydata->is_persistent); + zend_get_hash_value, destroy_phar_manifest_entry, mydata->is_persistent); zend_hash_init(&mydata->mounted_dirs, 5, - zend_get_hash_value, NULL, (bool)mydata->is_persistent); + zend_get_hash_value, NULL, mydata->is_persistent); zend_hash_init(&mydata->virtual_dirs, PHAR_GET_16(locator.count) * 2, - zend_get_hash_value, NULL, (bool)mydata->is_persistent); + zend_get_hash_value, NULL, mydata->is_persistent); entry.phar = mydata; entry.is_zip = 1; entry.fp_type = PHAR_FP; @@ -619,13 +616,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia zend_off_t restore_pos = php_stream_tell(fp); php_stream_seek(fp, entry.offset, SEEK_SET); - /* these next lines should be for php < 5.2.6 after 5.3 filters are fixed */ - fp->writepos = 0; - fp->readpos = 0; - php_stream_seek(fp, entry.offset, SEEK_SET); - fp->writepos = 0; - fp->readpos = 0; - /* the above lines should be for php < 5.2.6 after 5.3 filters are fixed */ mydata->alias_len = entry.uncompressed_filesize; if (entry.flags & PHAR_ENT_COMPRESSED_GZ) { @@ -805,18 +795,16 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia /** * Create or open a zip-based phar for writing */ -int phar_open_or_create_zip(char *fname, size_t fname_len, char *alias, size_t alias_len, int is_data, uint32_t options, phar_archive_data** pphar, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 7, 8) zend_result phar_open_or_create_zip(char *fname, size_t fname_len, char *alias, size_t alias_len, bool is_data, uint32_t options, phar_archive_data** pphar, char **error) /* {{{ */ { phar_archive_data *phar; - int ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error); + zend_result ret = phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, &phar, error); if (FAILURE == ret) { return FAILURE; } - if (pphar) { - *pphar = phar; - } + *pphar = phar; phar->is_data = is_data; @@ -831,9 +819,7 @@ int phar_open_or_create_zip(char *fname, size_t fname_len, char *alias, size_t a } /* we've reached here - the phar exists and is a regular phar */ - if (error) { - spprintf(error, 4096, "phar zip error: phar \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a zip-based phar", fname); - } + spprintf(error, 4096, "phar zip error: phar \"%s\" already exists as a regular phar and must be deleted from disk prior to creating as a zip-based phar", fname); return FAILURE; } @@ -856,7 +842,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ struct _phar_zip_pass *p; uint32_t newcrc32; zend_off_t offset; - int not_really_modified = 0; + bool not_really_modified = false; p = (struct _phar_zip_pass*) arg; uint16_t general_purpose_flags; @@ -865,7 +851,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ } if (entry->is_deleted) { - if (entry->fp_refcount <= 0) { + if (entry->fp_refcount <= 0 && entry->fileinfo_lock_count == 0) { return ZEND_HASH_APPLY_REMOVE; } else { /* we can't delete this in-memory until it is closed */ @@ -930,23 +916,23 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ goto continue_dir; } - if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) { + if (FAILURE == phar_open_entry_fp(entry, p->error, false)) { spprintf(p->error, 0, "unable to open file contents of file \"%s\" in zip-based phar \"%s\"", ZSTR_VAL(entry->filename), entry->phar->fname); return ZEND_HASH_APPLY_STOP; } /* we can be modified and already be compressed, such as when chmod() is executed */ if (entry->flags & PHAR_ENT_COMPRESSION_MASK && (entry->old_flags == entry->flags || !entry->old_flags)) { - not_really_modified = 1; + not_really_modified = true; goto is_compressed; } - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) { spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", ZSTR_VAL(entry->filename), entry->phar->fname); return ZEND_HASH_APPLY_STOP; } - efp = phar_get_efp(entry, 0); + efp = phar_get_efp(entry, false); newcrc32 = php_crc32_bulk_init(); php_crc32_stream_bulk_update(&newcrc32, efp, entry->uncompressed_filesize); @@ -963,7 +949,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ goto not_compressed; } - filter = php_stream_filter_create(phar_compress_filter(entry, 0), NULL, 0); + filter = php_stream_filter_create(phar_compress_filter(entry, false), NULL, 0); if (!filter) { if (entry->flags & PHAR_ENT_COMPRESSED_GZ) { @@ -987,7 +973,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ php_stream_flush(efp); - if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) { + if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, false)) { php_stream_filter_free(filter); spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", ZSTR_VAL(entry->filename), entry->phar->fname); return ZEND_HASH_APPLY_STOP; @@ -1100,13 +1086,13 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ php_stream_close(entry->cfp); entry->cfp = NULL; } else { - if (FAILURE == phar_open_entry_fp(entry, p->error, 0)) { + if (FAILURE == phar_open_entry_fp(entry, p->error, false)) { return ZEND_HASH_APPLY_STOP; } - phar_seek_efp(entry, 0, SEEK_SET, 0, 0); + phar_seek_efp(entry, 0, SEEK_SET, 0, false); - if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, 0), p->filefp, entry->uncompressed_filesize, NULL)) { + if (SUCCESS != php_stream_copy_to_stream_ex(phar_get_efp(entry, false), p->filefp, entry->uncompressed_filesize, NULL)) { spprintf(p->error, 0, "unable to write contents of file \"%s\" in zip-based phar \"%s\"", ZSTR_VAL(entry->filename), entry->phar->fname); return ZEND_HASH_APPLY_STOP; } @@ -1123,10 +1109,10 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{ /* open file pointers refer to this fp, do not free the stream */ switch (entry->fp_type) { case PHAR_FP: - p->free_fp = 0; + p->free_fp = false; break; case PHAR_UFP: - p->free_ufp = 0; + p->free_ufp = false; default: break; } @@ -1159,7 +1145,7 @@ static int phar_zip_changed_apply(zval *zv, void *arg) /* {{{ */ } /* }}} */ -static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pass *pass) /* {{{ */ +static zend_result phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pass *pass) /* {{{ */ { /* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */ if (!phar->is_data || phar->sig_flags) { @@ -1185,11 +1171,11 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas php_stream_write(newfile, ZSTR_VAL(phar->metadata_tracker.str), ZSTR_LEN(phar->metadata_tracker.str)); } - if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, pass->error)) { - if (pass->error) { - char *save = *(pass->error); - spprintf(pass->error, 0, "phar error: unable to write signature to zip-based phar: %s", save); - efree(save); + char *signature_error = NULL; + if (FAILURE == phar_create_signature(phar, newfile, &signature, &signature_length, &signature_error)) { + if (signature_error) { + spprintf(pass->error, 0, "phar error: unable to write signature to zip-based phar: %s", signature_error); + efree(signature_error); } php_stream_close(newfile); @@ -1238,7 +1224,7 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas } /* }}} */ -int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 4) int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_default_stub, char **error) /* {{{ */ { static const char newstub[] = "is_persistent) { - if (error) { - spprintf(error, 0, "internal error: attempt to flush cached zip-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "internal error: attempt to flush cached zip-based phar \"%s\"", phar->fname); return EOF; } @@ -1274,14 +1255,12 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa if (!phar->is_temporary_alias && phar->alias_len) { entry.fp = php_stream_fopen_tmpfile(); if (entry.fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return EOF; } if (phar->alias_len != php_stream_write(entry.fp, phar->alias, phar->alias_len)) { php_stream_close(entry.fp); - if (error) { - spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname); return EOF; } @@ -1305,9 +1284,7 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa char *pos = php_stristr(ZSTR_VAL(user_stub), halt_stub, ZSTR_LEN(user_stub), strlen(halt_stub)); if (pos == NULL) { - if (error) { - spprintf(error, 0, "illegal stub for zip-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "illegal stub for zip-based phar \"%s\"", phar->fname); return EOF; } @@ -1317,7 +1294,7 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa entry.fp = php_stream_fopen_tmpfile(); if (entry.fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return EOF; } entry.uncompressed_filesize = len + end_sequence_len; @@ -1326,9 +1303,7 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa len != php_stream_write(entry.fp, ZSTR_VAL(user_stub), len) || end_sequence_len != php_stream_write(entry.fp, end_sequence, end_sequence_len) ) { - if (error) { - spprintf(error, 0, "unable to create stub from string in new zip-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to create stub from string in new zip-based phar \"%s\"", phar->fname); php_stream_close(entry.fp); return EOF; } @@ -1340,14 +1315,12 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa /* Either this is a brand new phar (add the stub), or the default stub is required (overwrite the stub) */ entry.fp = php_stream_fopen_tmpfile(); if (entry.fp == NULL) { - spprintf(error, 0, "phar error: unable to create temporary file"); + *error = estrdup("phar error: unable to create temporary file"); return EOF; } if (sizeof(newstub)-1 != php_stream_write(entry.fp, newstub, sizeof(newstub)-1)) { php_stream_close(entry.fp); - if (error) { - spprintf(error, 0, "unable to %s stub in%szip-based phar \"%s\", failed", user_stub ? "overwrite" : "create", user_stub ? " " : " new ", phar->fname); - } + spprintf(error, 0, "unable to %s stub in%szip-based phar \"%s\", failed", user_stub ? "overwrite" : "create", user_stub ? " " : " new ", phar->fname); return EOF; } @@ -1359,9 +1332,7 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa if (NULL == zend_hash_add_mem(&phar->manifest, entry.filename, &entry, sizeof(phar_entry_info))) { php_stream_close(entry.fp); zend_string_efree(entry.filename); - if (error) { - spprintf(error, 0, "unable to create stub in zip-based phar \"%s\"", phar->fname); - } + spprintf(error, 0, "unable to create stub in zip-based phar \"%s\"", phar->fname); return EOF; } } else { @@ -1383,6 +1354,9 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa } /* save modified files to the zip */ + char *pass_error = NULL; + struct _phar_zip_pass pass; + pass.error = &pass_error; pass.old = oldfile; pass.filefp = php_stream_fopen_tmpfile(); @@ -1391,9 +1365,7 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa if (must_close_old_file) { php_stream_close(oldfile); } - if (error) { - spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to open temporary file", phar->fname); - } + spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to open temporary file", phar->fname); return EOF; } @@ -1404,7 +1376,7 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa goto fperror; } - pass.free_fp = pass.free_ufp = 1; + pass.free_fp = pass.free_ufp = true; memset(&eocd, 0, sizeof(eocd)); memcpy(eocd.signature, "PK\5\6", 4); @@ -1421,13 +1393,11 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa zend_hash_apply_with_argument(&phar->manifest, phar_zip_changed_apply, (void *) &pass); phar_metadata_tracker_try_ensure_has_serialized_data(&phar->metadata_tracker, phar->is_persistent); - if (temperr) { -temperror: - if (error) { - spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr); - } - efree(temperr); -notemperror: + if (pass_error + || FAILURE == phar_zip_applysignature(phar, &pass)) { + spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, pass_error); + efree(pass_error); +nopasserror: php_stream_close(pass.centralfp); nocentralerror: php_stream_close(pass.filefp); @@ -1437,10 +1407,6 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa return EOF; } - if (FAILURE == phar_zip_applysignature(phar, &pass)) { - goto temperror; - } - /* save zip */ cdir_size = php_stream_tell(pass.centralfp); cdir_offset = php_stream_tell(pass.filefp); @@ -1450,12 +1416,10 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa { size_t clen; - int ret = php_stream_copy_to_stream_ex(pass.centralfp, pass.filefp, PHP_STREAM_COPY_ALL, &clen); + zend_result ret = php_stream_copy_to_stream_ex(pass.centralfp, pass.filefp, PHP_STREAM_COPY_ALL, &clen); if (SUCCESS != ret || clen != cdir_size) { - if (error) { - spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname); - } - goto notemperror; + spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname); + goto nopasserror; } } @@ -1467,23 +1431,17 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa PHAR_SET_16(eocd.comment_len, ZSTR_LEN(phar->metadata_tracker.str)); if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) { - if (error) { - spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname); - } + spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname); goto nocentralerror; } if (ZSTR_LEN(phar->metadata_tracker.str) != php_stream_write(pass.filefp, ZSTR_VAL(phar->metadata_tracker.str), ZSTR_LEN(phar->metadata_tracker.str))) { - if (error) { - spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname); - } + spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write metadata to zip comment", phar->fname); goto nocentralerror; } } else { if (sizeof(eocd) != php_stream_write(pass.filefp, (char *)&eocd, sizeof(eocd))) { - if (error) { - spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname); - } + spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write end of central-directory", phar->fname); goto nocentralerror; } } @@ -1512,9 +1470,7 @@ int phar_zip_flush(phar_archive_data *phar, zend_string *user_stub, bool is_defa php_stream_close(oldfile); } phar->fp = pass.filefp; - if (error) { - spprintf(error, 4096, "unable to open new phar \"%s\" for writing", phar->fname); - } + spprintf(error, 4096, "unable to open new phar \"%s\" for writing", phar->fname); return EOF; } php_stream_rewind(pass.filefp); diff --git a/ext/posix/posix.c b/ext/posix/posix.c index ff878b3acfc1b..b7acf8c751270 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -699,7 +699,8 @@ static void php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ for (count = 0;; count++) { /* gr_mem entries may be misaligned on macos. */ char *gr_mem; - memcpy(&gr_mem, &g->gr_mem[count], sizeof(char *)); + char *entry = (char *)g->gr_mem + (count * sizeof (char *)); + memcpy(&gr_mem, entry, sizeof(char *)); if (!gr_mem) { break; } diff --git a/ext/random/engine_mt19937.c b/ext/random/engine_mt19937.c index 6400999091038..f2cb2fd7e9bcb 100644 --- a/ext/random/engine_mt19937.c +++ b/ext/random/engine_mt19937.c @@ -324,8 +324,7 @@ PHP_METHOD(Random_Engine_Mt19937, __serialize) array_init(return_value); /* members */ - ZVAL_ARR(&t, zend_std_get_properties(&engine->std)); - Z_TRY_ADDREF(t); + ZVAL_EMPTY_ARRAY(&t); zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &t); /* state */ diff --git a/ext/random/random_arginfo.h b/ext/random/random_arginfo.h index ec22af1bd2b11..94c024b122369 100644 --- a/ext/random/random_arginfo.h +++ b/ext/random/random_arginfo.h @@ -318,10 +318,10 @@ static zend_class_entry *register_class_Random_Randomizer(void) zval property_engine_default_value; ZVAL_UNDEF(&property_engine_default_value); - zend_string *property_engine_name = zend_string_init("engine", sizeof("engine") - 1, 1); + zend_string *property_engine_name = zend_string_init("engine", sizeof("engine") - 1, true); zend_string *property_engine_class_Random_Engine = zend_string_init("Random\\Engine", sizeof("Random\\Engine")-1, 1); zend_declare_typed_property(class_entry, property_engine_name, &property_engine_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_engine_class_Random_Engine, 0, 0)); - zend_string_release(property_engine_name); + zend_string_release_ex(property_engine_name, true); return class_entry; } diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 583717a66d6b6..64e79651913fb 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -763,11 +763,6 @@ static void format_default_value(smart_str *str, zval *value) { } } -static inline bool has_internal_arg_info(const zend_function *fptr) { - return fptr->type == ZEND_INTERNAL_FUNCTION - && !(fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO); -} - /* {{{ _parameter_string */ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_arg_info *arg_info, uint32_t offset, bool required, char* indent) { @@ -789,17 +784,15 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_ if (ZEND_ARG_IS_VARIADIC(arg_info)) { smart_str_appends(str, "..."); } - smart_str_append_printf(str, "$%s", has_internal_arg_info(fptr) - ? ((zend_internal_arg_info*)arg_info)->name : ZSTR_VAL(arg_info->name)); + smart_str_append_printf(str, "$%s", ZSTR_VAL(arg_info->name)); if (!required && !ZEND_ARG_IS_VARIADIC(arg_info)) { if (fptr->type == ZEND_INTERNAL_FUNCTION) { smart_str_appends(str, " = "); /* TODO: We don't have a way to fetch the default value for an internal function * with userland arg info. */ - if (has_internal_arg_info(fptr) - && ((zend_internal_arg_info*)arg_info)->default_value) { - smart_str_appends(str, ((zend_internal_arg_info*)arg_info)->default_value); + if (arg_info->default_value) { + smart_str_append(str, arg_info->default_value); } else { smart_str_appends(str, ""); } @@ -1432,13 +1425,7 @@ static void reflection_extension_factory_ex(zval *object, zend_module_entry *mod static void reflection_extension_factory(zval *object, const char *name_str) { size_t name_len = strlen(name_str); - zend_string *lcname; - struct _zend_module_entry *module; - - lcname = zend_string_alloc(name_len, 0); - zend_str_tolower_copy(ZSTR_VAL(lcname), name_str, name_len); - module = zend_hash_find_ptr(&module_registry, lcname); - zend_string_efree(lcname); + struct _zend_module_entry *module = zend_hash_str_find_ptr_lc(&module_registry, name_str, name_len); if (!module) { return; } @@ -1469,11 +1456,7 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje } prop_name = reflection_prop_name(object); - if (has_internal_arg_info(fptr)) { - ZVAL_STRING(prop_name, ((zend_internal_arg_info*)arg_info)->name); - } else { - ZVAL_STR_COPY(prop_name, arg_info->name); - } + ZVAL_STR_COPY(prop_name, arg_info->name); } /* }}} */ @@ -1659,8 +1642,7 @@ static zend_result get_parameter_default(zval *result, parameter_reference *para /* We don't have a way to determine the default value for this case right now. */ return FAILURE; } - return zend_get_default_from_internal_arg_info( - result, (zend_internal_arg_info *) param->arg_info); + return zend_get_default_from_internal_arg_info(result, param->arg_info); } else { zval *default_value = get_default_from_recv((zend_op_array *) param->fptr, param->offset); if (!default_value) { @@ -2141,16 +2123,10 @@ ZEND_METHOD(ReflectionFunction, invoke) zend_call_known_fcc(&fcc, &retval, num_args, params, named_params); - if (Z_TYPE(retval) == IS_UNDEF && !EG(exception)) { - zend_throw_exception_ex(reflection_exception_ptr, 0, - "Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name)); - RETURN_THROWS(); - } - if (Z_ISREF(retval)) { zend_unwrap_reference(&retval); } - ZVAL_COPY_VALUE(return_value, &retval); + RETURN_COPY_VALUE(&retval); } /* }}} */ @@ -2180,16 +2156,10 @@ ZEND_METHOD(ReflectionFunction, invokeArgs) zend_call_known_fcc(&fcc, &retval, /* num_params */ 0, /* params */ NULL, params); - if (Z_TYPE(retval) == IS_UNDEF && !EG(exception)) { - zend_throw_exception_ex(reflection_exception_ptr, 0, - "Invocation of function %s() failed", ZSTR_VAL(fptr->common.function_name)); - RETURN_THROWS(); - } - if (Z_ISREF(retval)) { zend_unwrap_reference(&retval); } - ZVAL_COPY_VALUE(return_value, &retval); + RETURN_COPY_VALUE(&retval); } /* }}} */ @@ -2608,22 +2578,11 @@ ZEND_METHOD(ReflectionParameter, __construct) uint32_t i; position = -1; - if (has_internal_arg_info(fptr)) { - for (i = 0; i < num_args; i++) { - if (arg_info[i].name) { - if (strcmp(((zend_internal_arg_info*)arg_info)[i].name, ZSTR_VAL(arg_name)) == 0) { - position = i; - break; - } - } - } - } else { - for (i = 0; i < num_args; i++) { - if (arg_info[i].name) { - if (zend_string_equals(arg_name, arg_info[i].name)) { - position = i; - break; - } + for (i = 0; i < num_args; i++) { + if (arg_info[i].name) { + if (zend_string_equals(arg_name, arg_info[i].name)) { + position = i; + break; } } } @@ -2664,11 +2623,7 @@ ZEND_METHOD(ReflectionParameter, __construct) prop_name = reflection_prop_name(object); zval_ptr_dtor(prop_name); - if (has_internal_arg_info(fptr)) { - ZVAL_STRING(prop_name, ((zend_internal_arg_info*)arg_info)[position].name); - } else { - ZVAL_STR_COPY(prop_name, arg_info[position].name); - } + ZVAL_STR_COPY(prop_name, arg_info[position].name); return; failure: @@ -2707,11 +2662,7 @@ ZEND_METHOD(ReflectionParameter, getName) ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); - if (has_internal_arg_info(param->fptr)) { - RETURN_STRING(((zend_internal_arg_info *) param->arg_info)->name); - } else { - RETURN_STR_COPY(param->arg_info->name); - } + RETURN_STR_COPY(param->arg_info->name); } /* }}} */ @@ -2832,7 +2783,7 @@ ZEND_METHOD(ReflectionParameter, getType) if (!ZEND_TYPE_IS_SET(param->arg_info->type)) { RETURN_NULL(); } - reflection_type_factory(param->arg_info->type, return_value, 1); + reflection_type_factory(param->arg_info->type, return_value, true); } /* }}} */ @@ -2965,8 +2916,7 @@ ZEND_METHOD(ReflectionParameter, isDefaultValueAvailable) GET_REFLECTION_OBJECT_PTR(param); if (param->fptr->type == ZEND_INTERNAL_FUNCTION) { - RETURN_BOOL(!(param->fptr->common.fn_flags & ZEND_ACC_USER_ARG_INFO) - && ((zend_internal_arg_info*) (param->arg_info))->default_value); + RETURN_BOOL(param->arg_info->default_value); } else { zval *default_value = get_default_from_recv((zend_op_array *)param->fptr, param->offset); RETURN_BOOL(default_value != NULL); @@ -3177,7 +3127,7 @@ static void append_type(zval *return_value, zend_type type) { ZEND_TYPE_FULL_MASK(type) &= ~_ZEND_TYPE_ITERABLE_BIT; } - reflection_type_factory(type, &reflection_type, 0); + reflection_type_factory(type, &reflection_type, false); zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &reflection_type); } @@ -3496,16 +3446,10 @@ static void reflection_method_invoke(INTERNAL_FUNCTION_PARAMETERS, int variadic) callback = _copy_function(mptr); zend_call_known_function(callback, (object ? Z_OBJ_P(object) : NULL), intern->ce, &retval, argc, params, named_params); - if (Z_TYPE(retval) == IS_UNDEF && !EG(exception)) { - zend_throw_exception_ex(reflection_exception_ptr, 0, - "Invocation of method %s::%s() failed", ZSTR_VAL(mptr->common.scope->name), ZSTR_VAL(mptr->common.function_name)); - RETURN_THROWS(); - } - if (Z_ISREF(retval)) { zend_unwrap_reference(&retval); } - ZVAL_COPY_VALUE(return_value, &retval); + RETURN_COPY_VALUE(&retval); } /* }}} */ @@ -3679,7 +3623,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getReturnType) RETURN_NULL(); } - reflection_type_factory(fptr->common.arg_info[-1].type, return_value, 1); + reflection_type_factory(fptr->common.arg_info[-1].type, return_value, true); } /* }}} */ @@ -3711,7 +3655,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getTentativeReturnType) RETURN_NULL(); } - reflection_type_factory(fptr->common.arg_info[-1].type, return_value, 1); + reflection_type_factory(fptr->common.arg_info[-1].type, return_value, true); } /* }}} */ @@ -3914,7 +3858,7 @@ ZEND_METHOD(ReflectionClassConstant, getType) RETURN_NULL(); } - reflection_type_factory(ref->type, return_value, 1); + reflection_type_factory(ref->type, return_value, true); } /* Returns whether class constant has a type */ @@ -4314,8 +4258,8 @@ ZEND_METHOD(ReflectionClass, getDefaultProperties) if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) { RETURN_THROWS(); } - add_class_vars(ce, 1, return_value); - add_class_vars(ce, 0, return_value); + add_class_vars(ce, true, return_value); + add_class_vars(ce, false, return_value); } /* }}} */ @@ -4552,7 +4496,7 @@ ZEND_METHOD(ReflectionClass, getMethods) zend_class_entry *ce; zend_function *mptr; zend_long filter; - bool filter_is_null = 1; + bool filter_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) { RETURN_THROWS(); @@ -4730,7 +4674,7 @@ ZEND_METHOD(ReflectionClass, getProperties) zend_string *key; zend_property_info *prop_info; zend_long filter; - bool filter_is_null = 1; + bool filter_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) { RETURN_THROWS(); @@ -4786,7 +4730,7 @@ ZEND_METHOD(ReflectionClass, getConstants) zend_class_constant *constant; zval val; zend_long filter; - bool filter_is_null = 1; + bool filter_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) { RETURN_THROWS(); @@ -4820,7 +4764,7 @@ ZEND_METHOD(ReflectionClass, getReflectionConstants) zend_string *name; zend_class_constant *constant; zend_long filter; - bool filter_is_null = 1; + bool filter_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &filter, &filter_is_null) == FAILURE) { RETURN_THROWS(); @@ -6429,7 +6373,7 @@ ZEND_METHOD(ReflectionProperty, getType) RETURN_NULL(); } - reflection_type_factory(ref->prop->type, return_value, 1); + reflection_type_factory(ref->prop->type, return_value, true); } /* }}} */ @@ -6451,7 +6395,7 @@ ZEND_METHOD(ReflectionProperty, getSettableType) /* Get-only virtual property can never be written to. */ if (prop->hooks && (prop->flags & ZEND_ACC_VIRTUAL) && !prop->hooks[ZEND_PROPERTY_HOOK_SET]) { zend_type never_type = ZEND_TYPE_INIT_CODE(IS_NEVER, 0, 0); - reflection_type_factory(never_type, return_value, 1); + reflection_type_factory(never_type, return_value, true); return; } @@ -6461,7 +6405,7 @@ ZEND_METHOD(ReflectionProperty, getSettableType) if (!ZEND_TYPE_IS_SET(arg_info->type)) { RETURN_NULL(); } - reflection_type_factory(arg_info->type, return_value, 1); + reflection_type_factory(arg_info->type, return_value, true); return; } @@ -6469,7 +6413,7 @@ ZEND_METHOD(ReflectionProperty, getSettableType) if (!ZEND_TYPE_IS_SET(ref->prop->type)) { RETURN_NULL(); } - reflection_type_factory(ref->prop->type, return_value, 1); + reflection_type_factory(ref->prop->type, return_value, true); } /* {{{ Returns whether property has a type */ @@ -6661,28 +6605,21 @@ ZEND_METHOD(ReflectionProperty, isFinal) ZEND_METHOD(ReflectionExtension, __construct) { zval *object; - char *lcname; reflection_object *intern; zend_module_entry *module; - char *name_str; - size_t name_len; - ALLOCA_FLAG(use_heap) + zend_string *name_str; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &name_str) == FAILURE) { RETURN_THROWS(); } object = ZEND_THIS; intern = Z_REFLECTION_P(object); - lcname = do_alloca(name_len + 1, use_heap); - zend_str_tolower_copy(lcname, name_str, name_len); - if ((module = zend_hash_str_find_ptr(&module_registry, lcname, name_len)) == NULL) { - free_alloca(lcname, use_heap); + if ((module = zend_hash_find_ptr_lc(&module_registry, name_str)) == NULL) { zend_throw_exception_ex(reflection_exception_ptr, 0, - "Extension \"%s\" does not exist", name_str); + "Extension \"%s\" does not exist", ZSTR_VAL(name_str)); RETURN_THROWS(); } - free_alloca(lcname, use_heap); zval *prop_name = reflection_prop_name(object); zval_ptr_dtor(prop_name); ZVAL_STRING(prop_name, module->name); @@ -6849,7 +6786,7 @@ ZEND_METHOD(ReflectionExtension, getClasses) array_init(return_value); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) { - add_extension_class(ce, key, return_value, module, 1); + add_extension_class(ce, key, return_value, module, true); } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -6867,7 +6804,7 @@ ZEND_METHOD(ReflectionExtension, getClassNames) array_init(return_value); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(EG(class_table), key, ce) { - add_extension_class(ce, key, return_value, module, 0); + add_extension_class(ce, key, return_value, module, false); } ZEND_HASH_FOREACH_END(); } /* }}} */ @@ -7175,7 +7112,7 @@ ZEND_METHOD(ReflectionReference, getId) RETURN_THROWS(); } - REFLECTION_G(key_initialized) = 1; + REFLECTION_G(key_initialized) = true; } /* SHA1(ref || key) to avoid directly exposing memory addresses. */ @@ -7510,7 +7447,7 @@ ZEND_METHOD(ReflectionEnum, getBackingType) RETURN_NULL(); } else { zend_type type = ZEND_TYPE_INIT_CODE(ce->enum_backing_type, 0, 0); - reflection_type_factory(type, return_value, 0); + reflection_type_factory(type, return_value, false); } } @@ -8033,7 +7970,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */ reflection_property_hook_type_ptr = register_class_PropertyHookType(); - REFLECTION_G(key_initialized) = 0; + REFLECTION_G(key_initialized) = false; return SUCCESS; } /* }}} */ diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h index bee9cbfc764a8..62275423b3caf 100644 --- a/ext/reflection/php_reflection_arginfo.h +++ b/ext/reflection/php_reflection_arginfo.h @@ -1421,9 +1421,9 @@ static zend_class_entry *register_class_ReflectionFunction(zend_class_entry *cla zval const_IS_DEPRECATED_value; ZVAL_LONG(&const_IS_DEPRECATED_value, ZEND_ACC_DEPRECATED); - zend_string *const_IS_DEPRECATED_name = zend_string_init_interned("IS_DEPRECATED", sizeof("IS_DEPRECATED") - 1, 1); + zend_string *const_IS_DEPRECATED_name = zend_string_init_interned("IS_DEPRECATED", sizeof("IS_DEPRECATED") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_DEPRECATED_name, &const_IS_DEPRECATED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_DEPRECATED_name); + zend_string_release_ex(const_IS_DEPRECATED_name, true); zend_attribute *attribute_Deprecated_func_isdisabled_0 = zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "isdisabled", sizeof("isdisabled") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); @@ -1455,39 +1455,39 @@ static zend_class_entry *register_class_ReflectionMethod(zend_class_entry *class zval const_IS_STATIC_value; ZVAL_LONG(&const_IS_STATIC_value, ZEND_ACC_STATIC); - zend_string *const_IS_STATIC_name = zend_string_init_interned("IS_STATIC", sizeof("IS_STATIC") - 1, 1); + zend_string *const_IS_STATIC_name = zend_string_init_interned("IS_STATIC", sizeof("IS_STATIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_STATIC_name, &const_IS_STATIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_STATIC_name); + zend_string_release_ex(const_IS_STATIC_name, true); zval const_IS_PUBLIC_value; ZVAL_LONG(&const_IS_PUBLIC_value, ZEND_ACC_PUBLIC); - zend_string *const_IS_PUBLIC_name = zend_string_init_interned("IS_PUBLIC", sizeof("IS_PUBLIC") - 1, 1); + zend_string *const_IS_PUBLIC_name = zend_string_init_interned("IS_PUBLIC", sizeof("IS_PUBLIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PUBLIC_name, &const_IS_PUBLIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PUBLIC_name); + zend_string_release_ex(const_IS_PUBLIC_name, true); zval const_IS_PROTECTED_value; ZVAL_LONG(&const_IS_PROTECTED_value, ZEND_ACC_PROTECTED); - zend_string *const_IS_PROTECTED_name = zend_string_init_interned("IS_PROTECTED", sizeof("IS_PROTECTED") - 1, 1); + zend_string *const_IS_PROTECTED_name = zend_string_init_interned("IS_PROTECTED", sizeof("IS_PROTECTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PROTECTED_name, &const_IS_PROTECTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PROTECTED_name); + zend_string_release_ex(const_IS_PROTECTED_name, true); zval const_IS_PRIVATE_value; ZVAL_LONG(&const_IS_PRIVATE_value, ZEND_ACC_PRIVATE); - zend_string *const_IS_PRIVATE_name = zend_string_init_interned("IS_PRIVATE", sizeof("IS_PRIVATE") - 1, 1); + zend_string *const_IS_PRIVATE_name = zend_string_init_interned("IS_PRIVATE", sizeof("IS_PRIVATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PRIVATE_name, &const_IS_PRIVATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PRIVATE_name); + zend_string_release_ex(const_IS_PRIVATE_name, true); zval const_IS_ABSTRACT_value; ZVAL_LONG(&const_IS_ABSTRACT_value, ZEND_ACC_ABSTRACT); - zend_string *const_IS_ABSTRACT_name = zend_string_init_interned("IS_ABSTRACT", sizeof("IS_ABSTRACT") - 1, 1); + zend_string *const_IS_ABSTRACT_name = zend_string_init_interned("IS_ABSTRACT", sizeof("IS_ABSTRACT") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_ABSTRACT_name, &const_IS_ABSTRACT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_ABSTRACT_name); + zend_string_release_ex(const_IS_ABSTRACT_name, true); zval const_IS_FINAL_value; ZVAL_LONG(&const_IS_FINAL_value, ZEND_ACC_FINAL); - zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, 1); + zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_FINAL_name, &const_IS_FINAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_FINAL_name); + zend_string_release_ex(const_IS_FINAL_name, true); zval property_class_default_value; ZVAL_UNDEF(&property_class_default_value); @@ -1514,39 +1514,39 @@ static zend_class_entry *register_class_ReflectionClass(zend_class_entry *class_ zval const_IS_IMPLICIT_ABSTRACT_value; ZVAL_LONG(&const_IS_IMPLICIT_ABSTRACT_value, ZEND_ACC_IMPLICIT_ABSTRACT_CLASS); - zend_string *const_IS_IMPLICIT_ABSTRACT_name = zend_string_init_interned("IS_IMPLICIT_ABSTRACT", sizeof("IS_IMPLICIT_ABSTRACT") - 1, 1); + zend_string *const_IS_IMPLICIT_ABSTRACT_name = zend_string_init_interned("IS_IMPLICIT_ABSTRACT", sizeof("IS_IMPLICIT_ABSTRACT") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_IMPLICIT_ABSTRACT_name, &const_IS_IMPLICIT_ABSTRACT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_IMPLICIT_ABSTRACT_name); + zend_string_release_ex(const_IS_IMPLICIT_ABSTRACT_name, true); zval const_IS_EXPLICIT_ABSTRACT_value; ZVAL_LONG(&const_IS_EXPLICIT_ABSTRACT_value, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_string *const_IS_EXPLICIT_ABSTRACT_name = zend_string_init_interned("IS_EXPLICIT_ABSTRACT", sizeof("IS_EXPLICIT_ABSTRACT") - 1, 1); + zend_string *const_IS_EXPLICIT_ABSTRACT_name = zend_string_init_interned("IS_EXPLICIT_ABSTRACT", sizeof("IS_EXPLICIT_ABSTRACT") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_EXPLICIT_ABSTRACT_name, &const_IS_EXPLICIT_ABSTRACT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_EXPLICIT_ABSTRACT_name); + zend_string_release_ex(const_IS_EXPLICIT_ABSTRACT_name, true); zval const_IS_FINAL_value; ZVAL_LONG(&const_IS_FINAL_value, ZEND_ACC_FINAL); - zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, 1); + zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_FINAL_name, &const_IS_FINAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_FINAL_name); + zend_string_release_ex(const_IS_FINAL_name, true); zval const_IS_READONLY_value; ZVAL_LONG(&const_IS_READONLY_value, ZEND_ACC_READONLY_CLASS); - zend_string *const_IS_READONLY_name = zend_string_init_interned("IS_READONLY", sizeof("IS_READONLY") - 1, 1); + zend_string *const_IS_READONLY_name = zend_string_init_interned("IS_READONLY", sizeof("IS_READONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_READONLY_name, &const_IS_READONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_READONLY_name); + zend_string_release_ex(const_IS_READONLY_name, true); zval const_SKIP_INITIALIZATION_ON_SERIALIZE_value; ZVAL_LONG(&const_SKIP_INITIALIZATION_ON_SERIALIZE_value, ZEND_LAZY_OBJECT_SKIP_INITIALIZATION_ON_SERIALIZE); - zend_string *const_SKIP_INITIALIZATION_ON_SERIALIZE_name = zend_string_init_interned("SKIP_INITIALIZATION_ON_SERIALIZE", sizeof("SKIP_INITIALIZATION_ON_SERIALIZE") - 1, 1); + zend_string *const_SKIP_INITIALIZATION_ON_SERIALIZE_name = zend_string_init_interned("SKIP_INITIALIZATION_ON_SERIALIZE", sizeof("SKIP_INITIALIZATION_ON_SERIALIZE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SKIP_INITIALIZATION_ON_SERIALIZE_name, &const_SKIP_INITIALIZATION_ON_SERIALIZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SKIP_INITIALIZATION_ON_SERIALIZE_name); + zend_string_release_ex(const_SKIP_INITIALIZATION_ON_SERIALIZE_name, true); zval const_SKIP_DESTRUCTOR_value; ZVAL_LONG(&const_SKIP_DESTRUCTOR_value, ZEND_LAZY_OBJECT_SKIP_DESTRUCTOR); - zend_string *const_SKIP_DESTRUCTOR_name = zend_string_init_interned("SKIP_DESTRUCTOR", sizeof("SKIP_DESTRUCTOR") - 1, 1); + zend_string *const_SKIP_DESTRUCTOR_name = zend_string_init_interned("SKIP_DESTRUCTOR", sizeof("SKIP_DESTRUCTOR") - 1, true); zend_declare_typed_class_constant(class_entry, const_SKIP_DESTRUCTOR_name, &const_SKIP_DESTRUCTOR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SKIP_DESTRUCTOR_name); + zend_string_release_ex(const_SKIP_DESTRUCTOR_name, true); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); @@ -1592,63 +1592,63 @@ static zend_class_entry *register_class_ReflectionProperty(zend_class_entry *cla zval const_IS_STATIC_value; ZVAL_LONG(&const_IS_STATIC_value, ZEND_ACC_STATIC); - zend_string *const_IS_STATIC_name = zend_string_init_interned("IS_STATIC", sizeof("IS_STATIC") - 1, 1); + zend_string *const_IS_STATIC_name = zend_string_init_interned("IS_STATIC", sizeof("IS_STATIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_STATIC_name, &const_IS_STATIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_STATIC_name); + zend_string_release_ex(const_IS_STATIC_name, true); zval const_IS_READONLY_value; ZVAL_LONG(&const_IS_READONLY_value, ZEND_ACC_READONLY); - zend_string *const_IS_READONLY_name = zend_string_init_interned("IS_READONLY", sizeof("IS_READONLY") - 1, 1); + zend_string *const_IS_READONLY_name = zend_string_init_interned("IS_READONLY", sizeof("IS_READONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_READONLY_name, &const_IS_READONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_READONLY_name); + zend_string_release_ex(const_IS_READONLY_name, true); zval const_IS_PUBLIC_value; ZVAL_LONG(&const_IS_PUBLIC_value, ZEND_ACC_PUBLIC); - zend_string *const_IS_PUBLIC_name = zend_string_init_interned("IS_PUBLIC", sizeof("IS_PUBLIC") - 1, 1); + zend_string *const_IS_PUBLIC_name = zend_string_init_interned("IS_PUBLIC", sizeof("IS_PUBLIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PUBLIC_name, &const_IS_PUBLIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PUBLIC_name); + zend_string_release_ex(const_IS_PUBLIC_name, true); zval const_IS_PROTECTED_value; ZVAL_LONG(&const_IS_PROTECTED_value, ZEND_ACC_PROTECTED); - zend_string *const_IS_PROTECTED_name = zend_string_init_interned("IS_PROTECTED", sizeof("IS_PROTECTED") - 1, 1); + zend_string *const_IS_PROTECTED_name = zend_string_init_interned("IS_PROTECTED", sizeof("IS_PROTECTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PROTECTED_name, &const_IS_PROTECTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PROTECTED_name); + zend_string_release_ex(const_IS_PROTECTED_name, true); zval const_IS_PRIVATE_value; ZVAL_LONG(&const_IS_PRIVATE_value, ZEND_ACC_PRIVATE); - zend_string *const_IS_PRIVATE_name = zend_string_init_interned("IS_PRIVATE", sizeof("IS_PRIVATE") - 1, 1); + zend_string *const_IS_PRIVATE_name = zend_string_init_interned("IS_PRIVATE", sizeof("IS_PRIVATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PRIVATE_name, &const_IS_PRIVATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PRIVATE_name); + zend_string_release_ex(const_IS_PRIVATE_name, true); zval const_IS_ABSTRACT_value; ZVAL_LONG(&const_IS_ABSTRACT_value, ZEND_ACC_ABSTRACT); - zend_string *const_IS_ABSTRACT_name = zend_string_init_interned("IS_ABSTRACT", sizeof("IS_ABSTRACT") - 1, 1); + zend_string *const_IS_ABSTRACT_name = zend_string_init_interned("IS_ABSTRACT", sizeof("IS_ABSTRACT") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_ABSTRACT_name, &const_IS_ABSTRACT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_ABSTRACT_name); + zend_string_release_ex(const_IS_ABSTRACT_name, true); zval const_IS_PROTECTED_SET_value; ZVAL_LONG(&const_IS_PROTECTED_SET_value, ZEND_ACC_PROTECTED_SET); - zend_string *const_IS_PROTECTED_SET_name = zend_string_init_interned("IS_PROTECTED_SET", sizeof("IS_PROTECTED_SET") - 1, 1); + zend_string *const_IS_PROTECTED_SET_name = zend_string_init_interned("IS_PROTECTED_SET", sizeof("IS_PROTECTED_SET") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PROTECTED_SET_name, &const_IS_PROTECTED_SET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PROTECTED_SET_name); + zend_string_release_ex(const_IS_PROTECTED_SET_name, true); zval const_IS_PRIVATE_SET_value; ZVAL_LONG(&const_IS_PRIVATE_SET_value, ZEND_ACC_PRIVATE_SET); - zend_string *const_IS_PRIVATE_SET_name = zend_string_init_interned("IS_PRIVATE_SET", sizeof("IS_PRIVATE_SET") - 1, 1); + zend_string *const_IS_PRIVATE_SET_name = zend_string_init_interned("IS_PRIVATE_SET", sizeof("IS_PRIVATE_SET") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PRIVATE_SET_name, &const_IS_PRIVATE_SET_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PRIVATE_SET_name); + zend_string_release_ex(const_IS_PRIVATE_SET_name, true); zval const_IS_VIRTUAL_value; ZVAL_LONG(&const_IS_VIRTUAL_value, ZEND_ACC_VIRTUAL); - zend_string *const_IS_VIRTUAL_name = zend_string_init_interned("IS_VIRTUAL", sizeof("IS_VIRTUAL") - 1, 1); + zend_string *const_IS_VIRTUAL_name = zend_string_init_interned("IS_VIRTUAL", sizeof("IS_VIRTUAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_VIRTUAL_name, &const_IS_VIRTUAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_VIRTUAL_name); + zend_string_release_ex(const_IS_VIRTUAL_name, true); zval const_IS_FINAL_value; ZVAL_LONG(&const_IS_FINAL_value, ZEND_ACC_FINAL); - zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, 1); + zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_FINAL_name, &const_IS_FINAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_FINAL_name); + zend_string_release_ex(const_IS_FINAL_name, true); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); @@ -1679,27 +1679,27 @@ static zend_class_entry *register_class_ReflectionClassConstant(zend_class_entry zval const_IS_PUBLIC_value; ZVAL_LONG(&const_IS_PUBLIC_value, ZEND_ACC_PUBLIC); - zend_string *const_IS_PUBLIC_name = zend_string_init_interned("IS_PUBLIC", sizeof("IS_PUBLIC") - 1, 1); + zend_string *const_IS_PUBLIC_name = zend_string_init_interned("IS_PUBLIC", sizeof("IS_PUBLIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PUBLIC_name, &const_IS_PUBLIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PUBLIC_name); + zend_string_release_ex(const_IS_PUBLIC_name, true); zval const_IS_PROTECTED_value; ZVAL_LONG(&const_IS_PROTECTED_value, ZEND_ACC_PROTECTED); - zend_string *const_IS_PROTECTED_name = zend_string_init_interned("IS_PROTECTED", sizeof("IS_PROTECTED") - 1, 1); + zend_string *const_IS_PROTECTED_name = zend_string_init_interned("IS_PROTECTED", sizeof("IS_PROTECTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PROTECTED_name, &const_IS_PROTECTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PROTECTED_name); + zend_string_release_ex(const_IS_PROTECTED_name, true); zval const_IS_PRIVATE_value; ZVAL_LONG(&const_IS_PRIVATE_value, ZEND_ACC_PRIVATE); - zend_string *const_IS_PRIVATE_name = zend_string_init_interned("IS_PRIVATE", sizeof("IS_PRIVATE") - 1, 1); + zend_string *const_IS_PRIVATE_name = zend_string_init_interned("IS_PRIVATE", sizeof("IS_PRIVATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_PRIVATE_name, &const_IS_PRIVATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_PRIVATE_name); + zend_string_release_ex(const_IS_PRIVATE_name, true); zval const_IS_FINAL_value; ZVAL_LONG(&const_IS_FINAL_value, ZEND_ACC_FINAL); - zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, 1); + zend_string *const_IS_FINAL_name = zend_string_init_interned("IS_FINAL", sizeof("IS_FINAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_FINAL_name, &const_IS_FINAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_FINAL_name); + zend_string_release_ex(const_IS_FINAL_name, true); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); @@ -1838,9 +1838,9 @@ static zend_class_entry *register_class_ReflectionAttribute(zend_class_entry *cl zval const_IS_INSTANCEOF_value; ZVAL_LONG(&const_IS_INSTANCEOF_value, REFLECTION_ATTRIBUTE_IS_INSTANCEOF); - zend_string *const_IS_INSTANCEOF_name = zend_string_init_interned("IS_INSTANCEOF", sizeof("IS_INSTANCEOF") - 1, 1); + zend_string *const_IS_INSTANCEOF_name = zend_string_init_interned("IS_INSTANCEOF", sizeof("IS_INSTANCEOF") - 1, true); zend_declare_typed_class_constant(class_entry, const_IS_INSTANCEOF_name, &const_IS_INSTANCEOF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IS_INSTANCEOF_name); + zend_string_release_ex(const_IS_INSTANCEOF_name, true); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); diff --git a/ext/reflection/tests/ReflectionFunction__toString_bound_variables.phpt b/ext/reflection/tests/ReflectionFunction__toString_bound_variables.phpt new file mode 100644 index 0000000000000..142e661361496 --- /dev/null +++ b/ext/reflection/tests/ReflectionFunction__toString_bound_variables.phpt @@ -0,0 +1,32 @@ +--TEST-- +ReflectionFunction::__toString() with bound variables +--FILE-- + 0; + +$rf = new ReflectionFunction($closure_without_bounds); +echo (string) $rf; + +$global = ""; +$closure_with_bounds = function() use($global) { + static $counter = 0; + return $counter++; +}; + +$rf = new ReflectionFunction($closure_with_bounds); +echo (string) $rf; + +?> +--EXPECTF-- +Closure [ function {closure:%s:%d} ] { + @@ %sReflectionFunction__toString_bound_variables.php 3 - 3 +} +Closure [ function {closure:%s:%d} ] { + @@ %sReflectionFunction__toString_bound_variables.php 9 - 12 + + - Bound Variables [2] { + Variable #0 [ $global ] + Variable #1 [ $counter ] + } +} diff --git a/ext/session/config.w32 b/ext/session/config.w32 index 825bc8b61d291..40f9f78a313ed 100644 --- a/ext/session/config.w32 +++ b/ext/session/config.w32 @@ -3,10 +3,10 @@ ARG_ENABLE("session", "session support", "yes"); if (PHP_SESSION == "yes") { - EXTENSION("session", "mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); + EXTENSION("session", "mod_user_class.c session.c mod_files.c mod_user.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); ADD_EXTENSION_DEP('session', 'date'); // https://bugs.php.net/53141 ADD_EXTENSION_DEP('session', 'spl', true); AC_DEFINE("HAVE_PHP_SESSION", 1, "Define to 1 if the PHP extension 'session' is available."); - PHP_INSTALL_HEADERS("ext/session", "mod_mm.h php_session.h mod_files.h mod_user.h"); + PHP_INSTALL_HEADERS("ext/session", "php_session.h mod_files.h mod_user.h"); } diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c index b997a2bdcff54..76de6035a315c 100644 --- a/ext/session/mod_mm.c +++ b/ext/session/mod_mm.c @@ -207,7 +207,7 @@ static zend_result ps_mm_key_exists(ps_mm *data, const zend_string *key) if (!key) { return FAILURE; } - sd = ps_sd_lookup(data, key, 0); + sd = ps_sd_lookup(data, key, false); if (sd) { return SUCCESS; } @@ -264,7 +264,7 @@ static void ps_mm_destroy(ps_mm *data) PHP_MINIT_FUNCTION(ps_mm) { - size_t save_path_len = strlen(PS(save_path)); + size_t save_path_len = ZSTR_LEN(PS(save_path)); size_t mod_name_len = strlen(sapi_module.name); size_t euid_len; char *ps_mm_path, euid[30]; @@ -284,8 +284,8 @@ PHP_MINIT_FUNCTION(ps_mm) /* Directory + '/' + File + Module Name + Effective UID + \0 */ ps_mm_path = emalloc(save_path_len + 1 + (sizeof(PS_MM_FILE) - 1) + mod_name_len + euid_len + 1); - memcpy(ps_mm_path, PS(save_path), save_path_len); - if (save_path_len && PS(save_path)[save_path_len - 1] != DEFAULT_SLASH) { + memcpy(ps_mm_path, ZSTR_VAL(PS(save_path)), save_path_len); + if (save_path_len && ZSTR_VAL(PS(save_path))[save_path_len - 1] != DEFAULT_SLASH) { ps_mm_path[save_path_len] = DEFAULT_SLASH; save_path_len++; } @@ -365,7 +365,7 @@ PS_READ_FUNC(mm) PS(session_status) = php_session_active; } - sd = ps_sd_lookup(data, PS(id), 0); + sd = ps_sd_lookup(data, PS(id), false); if (sd) { *val = zend_string_init(sd->data, sd->datalen, 0); ret = SUCCESS; @@ -383,7 +383,7 @@ PS_WRITE_FUNC(mm) mm_lock(data->mm, MM_LOCK_RW); - sd = ps_sd_lookup(data, key, 1); + sd = ps_sd_lookup(data, key, true); if (!sd) { sd = ps_sd_new(data, key); ps_mm_debug(("new entry for %s\n", ZSTR_VAL(key))); @@ -422,7 +422,7 @@ PS_DESTROY_FUNC(mm) mm_lock(data->mm, MM_LOCK_RW); - sd = ps_sd_lookup(data, key, 0); + sd = ps_sd_lookup(data, key, false); if (sd) { ps_sd_destroy(data, sd); } diff --git a/ext/session/session.c b/ext/session/session.c index 489f82d6f142f..8796005e9232f 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -487,7 +487,7 @@ static zend_result php_session_initialize(void) } /* GC must be done after read */ - php_session_gc(0); + php_session_gc(false); if (PS(session_vars)) { zend_string_release_ex(PS(session_vars), 0); @@ -1635,16 +1635,16 @@ PHPAPI zend_result php_session_reset_id(void) } /* Apply trans sid if sid cookie is not set */ - apply_trans_sid = 0; + apply_trans_sid = false; if (APPLY_TRANS_SID) { - apply_trans_sid = 1; + apply_trans_sid = true; if (PS(use_cookies) && (data = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_COOKIE")))) { ZVAL_DEREF(data); if (Z_TYPE_P(data) == IS_ARRAY && (potential_session_id = zend_hash_find(Z_ARRVAL_P(data), PS(session_name)))) { ZVAL_DEREF(potential_session_id); - apply_trans_sid = 0; + apply_trans_sid = false; } } } @@ -1858,15 +1858,15 @@ PHP_FUNCTION(session_set_cookie_params) domain = zval_get_string(value); found++; } else if (zend_string_equals_literal_ci(key, "secure")) { - secure = zval_is_true(value); + secure = zend_is_true(value); secure_null = 0; found++; } else if (zend_string_equals_literal_ci(key, "partitioned")) { - partitioned = zval_is_true(value); + partitioned = zend_is_true(value); partitioned_null = 0; found++; } else if (zend_string_equals_literal_ci(key, "httponly")) { - httponly = zval_is_true(value); + httponly = zend_is_true(value); httponly_null = 0; found++; } else if (zend_string_equals_literal_ci(key, "samesite")) { @@ -2113,7 +2113,7 @@ PHP_FUNCTION(session_set_save_handler) /* OOP Version */ if (ZEND_NUM_ARGS() <= 2) { zval *obj = NULL; - bool register_shutdown = 1; + bool register_shutdown = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|b", &obj, php_session_iface_entry, ®ister_shutdown) == FAILURE) { RETURN_THROWS(); @@ -2336,7 +2336,7 @@ PHP_FUNCTION(session_id) /* Update the current session id with a newly generated one. If delete_old_session is set to true, remove the old session. */ PHP_FUNCTION(session_regenerate_id) { - bool del_ses = 0; + bool del_ses = false; zend_string *data; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &del_ses) == FAILURE) { @@ -2535,7 +2535,7 @@ PHP_FUNCTION(session_cache_limiter) PHP_FUNCTION(session_cache_expire) { zend_long expires; - bool expires_is_null = 1; + bool expires_is_null = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &expires, &expires_is_null) == FAILURE) { RETURN_THROWS(); @@ -2741,7 +2741,7 @@ PHP_FUNCTION(session_gc) RETURN_FALSE; } - num = php_session_gc(1); + num = php_session_gc(true); if (num < 0) { RETURN_FALSE; } @@ -3069,17 +3069,17 @@ static bool early_find_sid_in(zval *dest, int where, php_session_rfc1867_progres zval *potential_session_id; if (Z_ISUNDEF(PG(http_globals)[where])) { - return 0; + return false; } if ((potential_session_id = zend_hash_find(Z_ARRVAL(PG(http_globals)[where]), PS(session_name))) && Z_TYPE_P(potential_session_id) == IS_STRING) { zval_ptr_dtor(dest); ZVAL_COPY_DEREF(dest, potential_session_id); - return 1; + return true; } - return 0; + return false; } static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *progress) @@ -3088,7 +3088,7 @@ static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *pro if (PS(use_cookies)) { sapi_module.treat_data(PARSE_COOKIE, NULL, NULL); if (early_find_sid_in(&progress->sid, TRACK_VARS_COOKIE, progress)) { - progress->apply_trans_sid = 0; + progress->apply_trans_sid = false; return; } } @@ -3104,13 +3104,13 @@ static bool php_check_cancel_upload(php_session_rfc1867_progress *progress) zval *progress_ary, *cancel_upload; if ((progress_ary = zend_symtable_find(Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))), progress->key.s)) == NULL) { - return 0; + return false; } if (Z_TYPE_P(progress_ary) != IS_ARRAY) { - return 0; + return false; } if ((cancel_upload = zend_hash_str_find(Z_ARRVAL_P(progress_ary), ZEND_STRL("cancel_upload"))) == NULL) { - return 0; + return false; } return Z_TYPE_P(cancel_upload) == IS_TRUE; } @@ -3247,7 +3247,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_ progress->post_bytes_processed = zend_hash_str_find(Z_ARRVAL(progress->data), ZEND_STRL("bytes_processed")); - php_rinit_session(0); + php_rinit_session(false); PS(id) = zend_string_copy(Z_STR(progress->sid)); if (progress->apply_trans_sid) { /* Enable trans sid by modifying flags */ @@ -3274,7 +3274,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_ progress->current_file_bytes_processed = zend_hash_str_find(Z_ARRVAL(progress->current_file), ZEND_STRL("bytes_processed")); Z_LVAL_P(progress->current_file_bytes_processed) = data->post_bytes_processed; - php_session_rfc1867_update(progress, 0); + php_session_rfc1867_update(progress, false); } break; case MULTIPART_EVENT_FILE_DATA: { @@ -3287,7 +3287,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_ Z_LVAL_P(progress->current_file_bytes_processed) = data->offset + data->length; Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed; - php_session_rfc1867_update(progress, 0); + php_session_rfc1867_update(progress, false); } break; case MULTIPART_EVENT_FILE_END: { @@ -3306,7 +3306,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_ Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed; - php_session_rfc1867_update(progress, 0); + php_session_rfc1867_update(progress, false); } break; case MULTIPART_EVENT_END: { @@ -3320,7 +3320,7 @@ static zend_result php_session_rfc1867_callback(unsigned int event, void *event_ SEPARATE_ARRAY(&progress->data); add_assoc_bool_ex(&progress->data, ZEND_STRL("done"), 1); Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed; - php_session_rfc1867_update(progress, 1); + php_session_rfc1867_update(progress, true); } } php_rshutdown_session_globals(); diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 875be2b6e23c5..16a8aaa22fc3a 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1413,14 +1413,10 @@ PHP_METHOD(SimpleXMLElement, asXML) static inline void sxe_add_namespace_name_raw(zval *return_value, const char *prefix, const char *href) { - 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, href); - zend_hash_add_new(Z_ARRVAL_P(return_value), key, &zv); + zval *zv = zend_hash_str_lookup(Z_ARRVAL_P(return_value), prefix, strlen(prefix)); + if (Z_ISNULL_P(zv)) { + ZVAL_STRING(zv, href); } - zend_string_release_ex(key, 0); } static inline void sxe_add_namespace_name(zval *return_value, xmlNsPtr ns) /* {{{ */ @@ -1489,7 +1485,7 @@ static inline void sxe_object_free_iterxpath(php_sxe_object *sxe) /* {{{ Return all namespaces in use */ PHP_METHOD(SimpleXMLElement, getNamespaces) { - bool recursive = 0; + bool recursive = false; php_sxe_object *sxe; xmlNodePtr node; @@ -1551,7 +1547,7 @@ static void sxe_add_registered_namespaces(php_sxe_object *sxe, xmlNodePtr node, /* {{{ Return all namespaces registered with document */ PHP_METHOD(SimpleXMLElement, getDocNamespaces) { - bool recursive = 0, from_root = 1; + bool recursive = false, from_root = true; php_sxe_object *sxe; xmlNodePtr node; @@ -1589,7 +1585,7 @@ PHP_METHOD(SimpleXMLElement, children) php_sxe_object *sxe; zend_string *nsprefix = NULL; xmlNodePtr node; - bool isprefix = 0; + bool isprefix = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!b", &nsprefix, &isprefix) == FAILURE) { RETURN_THROWS(); @@ -1641,7 +1637,7 @@ PHP_METHOD(SimpleXMLElement, attributes) php_sxe_object *sxe; zend_string *nsprefix = NULL; xmlNodePtr node; - bool isprefix = 0; + bool isprefix = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!b", &nsprefix, &isprefix) == FAILURE) { RETURN_THROWS(); @@ -2028,7 +2024,7 @@ PHP_METHOD(SimpleXMLElement, key) } curnode = intern->node->node; - RETURN_STRINGL((char*)curnode->name, xmlStrlen(curnode->name)); + RETURN_STRINGL_FAST((char*)curnode->name, xmlStrlen(curnode->name)); } /* }}} */ @@ -2208,7 +2204,7 @@ PHP_FUNCTION(simplexml_load_file) zend_long options = 0; zend_class_entry *ce= ce_SimpleXMLElement; zend_function *fptr_count; - bool isprefix = 0; + bool isprefix = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|C!lSb", &filename, &filename_len, &ce, &options, &ns, &isprefix) == FAILURE) { RETURN_THROWS(); @@ -2254,7 +2250,7 @@ PHP_FUNCTION(simplexml_load_string) zend_long options = 0; zend_class_entry *ce= ce_SimpleXMLElement; zend_function *fptr_count; - bool isprefix = 0; + bool isprefix = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|C!lSb", &data, &data_len, &ce, &options, &ns, &isprefix) == FAILURE) { RETURN_THROWS(); @@ -2306,7 +2302,7 @@ PHP_METHOD(SimpleXMLElement, __construct) size_t data_len; xmlDocPtr docp; zend_long options = 0; - bool is_url = 0, isprefix = 0; + bool is_url = false, isprefix = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lbSb", &data, &data_len, &options, &is_url, &ns, &isprefix) == FAILURE) { RETURN_THROWS(); diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index db2d0ad87867e..0ff8d41c1e6ce 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -34,7 +34,6 @@ #include "php_snmp.h" #include "zend_exceptions.h" -#include "zend_smart_string.h" #include "ext/spl/spl_exceptions.h" #ifdef HAVE_SNMP diff --git a/ext/snmp/snmp_arginfo.h b/ext/snmp/snmp_arginfo.h index 18ed9c7356634..dd0fdee92969d 100644 --- a/ext/snmp/snmp_arginfo.h +++ b/ext/snmp/snmp_arginfo.h @@ -270,123 +270,123 @@ static zend_class_entry *register_class_SNMP(void) zval const_VERSION_1_value; ZVAL_LONG(&const_VERSION_1_value, SNMP_VERSION_1); - zend_string *const_VERSION_1_name = zend_string_init_interned("VERSION_1", sizeof("VERSION_1") - 1, 1); + zend_string *const_VERSION_1_name = zend_string_init_interned("VERSION_1", sizeof("VERSION_1") - 1, true); zend_declare_typed_class_constant(class_entry, const_VERSION_1_name, &const_VERSION_1_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_VERSION_1_name); + zend_string_release_ex(const_VERSION_1_name, true); zval const_VERSION_2c_value; ZVAL_LONG(&const_VERSION_2c_value, SNMP_VERSION_2c); - zend_string *const_VERSION_2c_name = zend_string_init_interned("VERSION_2c", sizeof("VERSION_2c") - 1, 1); + zend_string *const_VERSION_2c_name = zend_string_init_interned("VERSION_2c", sizeof("VERSION_2c") - 1, true); zend_declare_typed_class_constant(class_entry, const_VERSION_2c_name, &const_VERSION_2c_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_VERSION_2c_name); + zend_string_release_ex(const_VERSION_2c_name, true); zval const_VERSION_2C_value; ZVAL_LONG(&const_VERSION_2C_value, SNMP_VERSION_2c); - zend_string *const_VERSION_2C_name = zend_string_init_interned("VERSION_2C", sizeof("VERSION_2C") - 1, 1); + zend_string *const_VERSION_2C_name = zend_string_init_interned("VERSION_2C", sizeof("VERSION_2C") - 1, true); zend_declare_typed_class_constant(class_entry, const_VERSION_2C_name, &const_VERSION_2C_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_VERSION_2C_name); + zend_string_release_ex(const_VERSION_2C_name, true); zval const_VERSION_3_value; ZVAL_LONG(&const_VERSION_3_value, SNMP_VERSION_3); - zend_string *const_VERSION_3_name = zend_string_init_interned("VERSION_3", sizeof("VERSION_3") - 1, 1); + zend_string *const_VERSION_3_name = zend_string_init_interned("VERSION_3", sizeof("VERSION_3") - 1, true); zend_declare_typed_class_constant(class_entry, const_VERSION_3_name, &const_VERSION_3_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_VERSION_3_name); + zend_string_release_ex(const_VERSION_3_name, true); zval const_ERRNO_NOERROR_value; ZVAL_LONG(&const_ERRNO_NOERROR_value, PHP_SNMP_ERRNO_NOERROR); - zend_string *const_ERRNO_NOERROR_name = zend_string_init_interned("ERRNO_NOERROR", sizeof("ERRNO_NOERROR") - 1, 1); + zend_string *const_ERRNO_NOERROR_name = zend_string_init_interned("ERRNO_NOERROR", sizeof("ERRNO_NOERROR") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_NOERROR_name, &const_ERRNO_NOERROR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_NOERROR_name); + zend_string_release_ex(const_ERRNO_NOERROR_name, true); zval const_ERRNO_ANY_value; ZVAL_LONG(&const_ERRNO_ANY_value, PHP_SNMP_ERRNO_ANY); - zend_string *const_ERRNO_ANY_name = zend_string_init_interned("ERRNO_ANY", sizeof("ERRNO_ANY") - 1, 1); + zend_string *const_ERRNO_ANY_name = zend_string_init_interned("ERRNO_ANY", sizeof("ERRNO_ANY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_ANY_name, &const_ERRNO_ANY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_ANY_name); + zend_string_release_ex(const_ERRNO_ANY_name, true); zval const_ERRNO_GENERIC_value; ZVAL_LONG(&const_ERRNO_GENERIC_value, PHP_SNMP_ERRNO_GENERIC); - zend_string *const_ERRNO_GENERIC_name = zend_string_init_interned("ERRNO_GENERIC", sizeof("ERRNO_GENERIC") - 1, 1); + zend_string *const_ERRNO_GENERIC_name = zend_string_init_interned("ERRNO_GENERIC", sizeof("ERRNO_GENERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_GENERIC_name, &const_ERRNO_GENERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_GENERIC_name); + zend_string_release_ex(const_ERRNO_GENERIC_name, true); zval const_ERRNO_TIMEOUT_value; ZVAL_LONG(&const_ERRNO_TIMEOUT_value, PHP_SNMP_ERRNO_TIMEOUT); - zend_string *const_ERRNO_TIMEOUT_name = zend_string_init_interned("ERRNO_TIMEOUT", sizeof("ERRNO_TIMEOUT") - 1, 1); + zend_string *const_ERRNO_TIMEOUT_name = zend_string_init_interned("ERRNO_TIMEOUT", sizeof("ERRNO_TIMEOUT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_TIMEOUT_name, &const_ERRNO_TIMEOUT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_TIMEOUT_name); + zend_string_release_ex(const_ERRNO_TIMEOUT_name, true); zval const_ERRNO_ERROR_IN_REPLY_value; ZVAL_LONG(&const_ERRNO_ERROR_IN_REPLY_value, PHP_SNMP_ERRNO_ERROR_IN_REPLY); - zend_string *const_ERRNO_ERROR_IN_REPLY_name = zend_string_init_interned("ERRNO_ERROR_IN_REPLY", sizeof("ERRNO_ERROR_IN_REPLY") - 1, 1); + zend_string *const_ERRNO_ERROR_IN_REPLY_name = zend_string_init_interned("ERRNO_ERROR_IN_REPLY", sizeof("ERRNO_ERROR_IN_REPLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_ERROR_IN_REPLY_name, &const_ERRNO_ERROR_IN_REPLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_ERROR_IN_REPLY_name); + zend_string_release_ex(const_ERRNO_ERROR_IN_REPLY_name, true); zval const_ERRNO_OID_NOT_INCREASING_value; ZVAL_LONG(&const_ERRNO_OID_NOT_INCREASING_value, PHP_SNMP_ERRNO_OID_NOT_INCREASING); - zend_string *const_ERRNO_OID_NOT_INCREASING_name = zend_string_init_interned("ERRNO_OID_NOT_INCREASING", sizeof("ERRNO_OID_NOT_INCREASING") - 1, 1); + zend_string *const_ERRNO_OID_NOT_INCREASING_name = zend_string_init_interned("ERRNO_OID_NOT_INCREASING", sizeof("ERRNO_OID_NOT_INCREASING") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_OID_NOT_INCREASING_name, &const_ERRNO_OID_NOT_INCREASING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_OID_NOT_INCREASING_name); + zend_string_release_ex(const_ERRNO_OID_NOT_INCREASING_name, true); zval const_ERRNO_OID_PARSING_ERROR_value; ZVAL_LONG(&const_ERRNO_OID_PARSING_ERROR_value, PHP_SNMP_ERRNO_OID_PARSING_ERROR); - zend_string *const_ERRNO_OID_PARSING_ERROR_name = zend_string_init_interned("ERRNO_OID_PARSING_ERROR", sizeof("ERRNO_OID_PARSING_ERROR") - 1, 1); + zend_string *const_ERRNO_OID_PARSING_ERROR_name = zend_string_init_interned("ERRNO_OID_PARSING_ERROR", sizeof("ERRNO_OID_PARSING_ERROR") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_OID_PARSING_ERROR_name, &const_ERRNO_OID_PARSING_ERROR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_OID_PARSING_ERROR_name); + zend_string_release_ex(const_ERRNO_OID_PARSING_ERROR_name, true); zval const_ERRNO_MULTIPLE_SET_QUERIES_value; ZVAL_LONG(&const_ERRNO_MULTIPLE_SET_QUERIES_value, PHP_SNMP_ERRNO_MULTIPLE_SET_QUERIES); - zend_string *const_ERRNO_MULTIPLE_SET_QUERIES_name = zend_string_init_interned("ERRNO_MULTIPLE_SET_QUERIES", sizeof("ERRNO_MULTIPLE_SET_QUERIES") - 1, 1); + zend_string *const_ERRNO_MULTIPLE_SET_QUERIES_name = zend_string_init_interned("ERRNO_MULTIPLE_SET_QUERIES", sizeof("ERRNO_MULTIPLE_SET_QUERIES") - 1, true); zend_declare_typed_class_constant(class_entry, const_ERRNO_MULTIPLE_SET_QUERIES_name, &const_ERRNO_MULTIPLE_SET_QUERIES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ERRNO_MULTIPLE_SET_QUERIES_name); + zend_string_release_ex(const_ERRNO_MULTIPLE_SET_QUERIES_name, true); zval property_info_default_value; ZVAL_UNDEF(&property_info_default_value); - zend_string *property_info_name = zend_string_init("info", sizeof("info") - 1, 1); + zend_string *property_info_name = zend_string_init("info", sizeof("info") - 1, true); zend_declare_typed_property(class_entry, property_info_name, &property_info_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); - zend_string_release(property_info_name); + zend_string_release_ex(property_info_name, true); zval property_max_oids_default_value; ZVAL_UNDEF(&property_max_oids_default_value); - zend_string *property_max_oids_name = zend_string_init("max_oids", sizeof("max_oids") - 1, 1); + zend_string *property_max_oids_name = zend_string_init("max_oids", sizeof("max_oids") - 1, true); zend_declare_typed_property(class_entry, property_max_oids_name, &property_max_oids_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property_max_oids_name); + zend_string_release_ex(property_max_oids_name, true); zval property_valueretrieval_default_value; ZVAL_UNDEF(&property_valueretrieval_default_value); - zend_string *property_valueretrieval_name = zend_string_init("valueretrieval", sizeof("valueretrieval") - 1, 1); + zend_string *property_valueretrieval_name = zend_string_init("valueretrieval", sizeof("valueretrieval") - 1, true); zend_declare_typed_property(class_entry, property_valueretrieval_name, &property_valueretrieval_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_valueretrieval_name); + zend_string_release_ex(property_valueretrieval_name, true); zval property_quick_print_default_value; ZVAL_UNDEF(&property_quick_print_default_value); - zend_string *property_quick_print_name = zend_string_init("quick_print", sizeof("quick_print") - 1, 1); + zend_string *property_quick_print_name = zend_string_init("quick_print", sizeof("quick_print") - 1, true); zend_declare_typed_property(class_entry, property_quick_print_name, &property_quick_print_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_quick_print_name); + zend_string_release_ex(property_quick_print_name, true); zval property_enum_print_default_value; ZVAL_UNDEF(&property_enum_print_default_value); - zend_string *property_enum_print_name = zend_string_init("enum_print", sizeof("enum_print") - 1, 1); + zend_string *property_enum_print_name = zend_string_init("enum_print", sizeof("enum_print") - 1, true); zend_declare_typed_property(class_entry, property_enum_print_name, &property_enum_print_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_enum_print_name); + zend_string_release_ex(property_enum_print_name, true); zval property_oid_output_format_default_value; ZVAL_UNDEF(&property_oid_output_format_default_value); - zend_string *property_oid_output_format_name = zend_string_init("oid_output_format", sizeof("oid_output_format") - 1, 1); + zend_string *property_oid_output_format_name = zend_string_init("oid_output_format", sizeof("oid_output_format") - 1, true); zend_declare_typed_property(class_entry, property_oid_output_format_name, &property_oid_output_format_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_oid_output_format_name); + zend_string_release_ex(property_oid_output_format_name, true); zval property_oid_increasing_check_default_value; ZVAL_UNDEF(&property_oid_increasing_check_default_value); - zend_string *property_oid_increasing_check_name = zend_string_init("oid_increasing_check", sizeof("oid_increasing_check") - 1, 1); + zend_string *property_oid_increasing_check_name = zend_string_init("oid_increasing_check", sizeof("oid_increasing_check") - 1, true); zend_declare_typed_property(class_entry, property_oid_increasing_check_name, &property_oid_increasing_check_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_oid_increasing_check_name); + zend_string_release_ex(property_oid_increasing_check_name, true); zval property_exceptions_enabled_default_value; ZVAL_UNDEF(&property_exceptions_enabled_default_value); - zend_string *property_exceptions_enabled_name = zend_string_init("exceptions_enabled", sizeof("exceptions_enabled") - 1, 1); + zend_string *property_exceptions_enabled_name = zend_string_init("exceptions_enabled", sizeof("exceptions_enabled") - 1, true); zend_declare_typed_property(class_entry, property_exceptions_enabled_name, &property_exceptions_enabled_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_exceptions_enabled_name); + zend_string_release_ex(property_exceptions_enabled_name, true); return class_entry; } diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 6ba4b95c1bd17..77d97b566fc19 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -284,7 +284,7 @@ static bool soap_check_zval_ref(zval *data, xmlNodePtr node) { smart_str prefix = {0}; if (node_ptr == node) { - return 0; + return false; } if (SOAP_GLOBAL(soap_version) == SOAP_1_1) { attr = get_attribute(attr, "id"); @@ -322,12 +322,12 @@ static bool soap_check_zval_ref(zval *data, xmlNodePtr node) { set_ns_prop(node, SOAP_1_2_ENC_NAMESPACE, "ref", id); } smart_str_free(&prefix); - return 1; + return true; } else { zend_hash_index_update_ptr(SOAP_GLOBAL(ref_map), (zend_ulong)data, node); } } - return 0; + return false; } static bool soap_check_xml_ref(zval *data, xmlNodePtr node) @@ -341,11 +341,11 @@ static bool soap_check_xml_ref(zval *data, xmlNodePtr node) Z_COUNTED_P(data) != Z_COUNTED_P(data_ptr)) { zval_ptr_dtor(data); ZVAL_COPY(data, data_ptr); - return 1; + return true; } } } - return 0; + return false; } static void soap_add_xml_ref(zval *data, xmlNodePtr node) @@ -1797,9 +1797,9 @@ static sdlTypePtr model_array_element(sdlContentModelPtr model) ZEND_HASH_FOREACH_PTR(model->u.content, tmp) { return model_array_element(tmp); } ZEND_HASH_FOREACH_END(); + + break; } - /* TODO Check this is correct */ - ZEND_FALLTHROUGH; case XSD_CONTENT_GROUP: { return model_array_element(model->u.group->model); } diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 7d8538b36c2db..63c0093eb05c8 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -329,7 +329,7 @@ static bool in_domain(const zend_string *host, const zend_string *domain) if (ZSTR_LEN(host) > ZSTR_LEN(domain)) { return strcmp(ZSTR_VAL(host)+ZSTR_LEN(host)-ZSTR_LEN(domain), ZSTR_VAL(domain)) == 0; } else { - return 0; + return false; } } else { return zend_string_equals(host,domain); @@ -363,9 +363,9 @@ int make_http_soap_request( char *http_msg = NULL; bool old_allow_url_fopen; php_stream_context *context = NULL; - bool has_authorization = 0; - bool has_proxy_authorization = 0; - bool has_cookies = 0; + bool has_authorization = false; + bool has_proxy_authorization = false; + bool has_cookies = false; if (this_ptr == NULL || Z_TYPE_P(this_ptr) != IS_OBJECT) { return FALSE; @@ -680,7 +680,7 @@ int make_http_soap_request( if (Z_TYPE_P(login) == IS_STRING) { zval *digest = Z_CLIENT_DIGEST_P(this_ptr); - has_authorization = 1; + has_authorization = true; if (Z_TYPE_P(digest) == IS_ARRAY) { char HA1[33], HA2[33], response[33], cnonce[33], nc[9]; unsigned char nonce[16]; @@ -858,7 +858,7 @@ int make_http_soap_request( if (zend_hash_num_elements(Z_ARRVAL_P(cookies)) != 0 && !HT_IS_PACKED(Z_ARRVAL_P(cookies))) { zval *data; zend_string *key; - has_cookies = 1; + has_cookies = true; bool first_cookie = true; smart_str_append_const(&soap_headers, "Cookie: "); ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(cookies), key, data) { @@ -1014,8 +1014,7 @@ int make_http_soap_request( char *eqpos = strstr(cookie, "="); char *sempos = strstr(cookie, ";"); if (eqpos != NULL && (sempos == NULL || sempos > eqpos)) { - smart_str name = {0}; - int cookie_len; + size_t cookie_len; zval zcookie; if (sempos != NULL) { @@ -1024,8 +1023,7 @@ int make_http_soap_request( cookie_len = strlen(cookie)-(eqpos-cookie)-1; } - smart_str_appendl(&name, cookie, eqpos - cookie); - smart_str_0(&name); + zend_string *name = zend_string_init(cookie, eqpos - cookie, false); array_init(&zcookie); add_index_stringl(&zcookie, 0, eqpos + 1, cookie_len); @@ -1063,8 +1061,8 @@ int make_http_soap_request( GC_ADDREF(uri->host); } - zend_symtable_update(Z_ARRVAL_P(cookies), name.s, &zcookie); - smart_str_free(&name); + zend_symtable_update(Z_ARRVAL_P(cookies), name, &zcookie); + zend_string_release_ex(name, false); } cookie_itt = cookie_itt + cookie_len; diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c index cc01b598bd9c3..e6871cd6e9b31 100644 --- a/ext/soap/php_sdl.c +++ b/ext/soap/php_sdl.c @@ -3157,8 +3157,8 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl) smart_str headers = {0}; char* key = NULL; time_t t = time(0); - bool has_proxy_authorization = 0; - bool has_authorization = 0; + bool has_proxy_authorization = false; + bool has_authorization = false; ZVAL_UNDEF(&orig_context); ZVAL_UNDEF(&new_context); @@ -3312,7 +3312,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl) sdl = load_wsdl(this_ptr, uri); if (sdl) { - sdl->is_persistent = 0; + sdl->is_persistent = false; } SOAP_GLOBAL(error_code) = old_error_code; @@ -3359,7 +3359,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl) } psdl = make_persistent_sdl(sdl); - psdl->is_persistent = 1; + psdl->is_persistent = true; p.time = t; p.sdl = psdl; diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c index b6b0c09b9d48b..a2536b98f39bb 100644 --- a/ext/soap/php_xml.c +++ b/ext/soap/php_xml.c @@ -79,12 +79,15 @@ static xmlDocPtr soap_xmlParse_ex(xmlParserCtxtPtr ctxt) { xmlDocPtr ret; if (ctxt) { +#if LIBXML_VERSION >= 21300 + xmlCtxtSetOptions(ctxt, XML_PARSE_HUGE | XML_PARSE_NO_XXE | XML_PARSE_NONET | XML_PARSE_NOBLANKS); +#else php_libxml_sanitize_parse_ctxt_options(ctxt); - /* TODO: In libxml2 2.14.0 change this to the new options API so we don't rely on deprecated APIs. */ ZEND_DIAGNOSTIC_IGNORED_START("-Wdeprecated-declarations") ctxt->keepBlanks = 0; ctxt->options |= XML_PARSE_HUGE; ZEND_DIAGNOSTIC_IGNORED_END +#endif ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace; ctxt->sax->comment = soap_Comment; ctxt->sax->warning = NULL; diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 55bcdf3eb8841..471b2d622d98a 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -767,7 +767,7 @@ PHP_METHOD(SoapVar, __construct) { zval *data, *this_ptr; zend_long type; - bool type_is_null = 1; + bool type_is_null = true; zend_string *stype = NULL, *ns = NULL, *name = NULL, *namens = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z!l!|S!S!S!S!", &data, &type, &type_is_null, &stype, &ns, &name, &namens) == FAILURE) { @@ -1971,7 +1971,7 @@ static void soap_error_handler(int error_num, zend_string *error_filename, const /* {{{ */ PHP_FUNCTION(use_soap_error_handler) { - bool handler = 1; + bool handler = true; ZVAL_BOOL(return_value, SOAP_GLOBAL(use_soap_error_handler)); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &handler) == SUCCESS) { @@ -2553,7 +2553,7 @@ static void soap_client_call_common( if (soap_headers) { if (!free_soap_headers) { soap_headers = zend_array_dup(soap_headers); - free_soap_headers = 1; + free_soap_headers = true; } ZEND_HASH_FOREACH_VAL(default_headers, tmp) { if(Z_TYPE_P(tmp) == IS_OBJECT) { @@ -2563,7 +2563,7 @@ static void soap_client_call_common( } ZEND_HASH_FOREACH_END(); } else { soap_headers = Z_ARRVAL_P(tmp); - free_soap_headers = 0; + free_soap_headers = false; } } @@ -2796,7 +2796,7 @@ PHP_METHOD(SoapClient, __doRequest) char *action; size_t action_size; zend_long version; - bool one_way = 0; + bool one_way = false; zval *this_ptr = ZEND_THIS; if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSsl|bS!", @@ -2807,7 +2807,7 @@ PHP_METHOD(SoapClient, __doRequest) RETURN_THROWS(); } if (SOAP_GLOBAL(features) & SOAP_WAIT_ONE_WAY_CALLS) { - one_way = 0; + one_way = false; } if (one_way) { if (make_http_soap_request(this_ptr, buf, location, action, version, uri_parser_class, NULL)) { @@ -2835,12 +2835,12 @@ PHP_METHOD(SoapClient, __setCookie) zval *cookies = Z_CLIENT_COOKIES_P(ZEND_THIS); SEPARATE_ARRAY(cookies); if (val == NULL) { - zend_hash_del(Z_ARRVAL_P(cookies), name); + zend_symtable_del(Z_ARRVAL_P(cookies), name); } else { zval zcookie; array_init(&zcookie); add_index_str(&zcookie, 0, zend_string_copy(val)); - zend_hash_update(Z_ARRVAL_P(cookies), name, &zcookie); + zend_symtable_update(Z_ARRVAL_P(cookies), name, &zcookie); } } /* }}} */ diff --git a/ext/soap/soap_arginfo.h b/ext/soap/soap_arginfo.h index 155348e9e98bb..7efa15cde2f9d 100644 --- a/ext/soap/soap_arginfo.h +++ b/ext/soap/soap_arginfo.h @@ -355,15 +355,15 @@ static zend_class_entry *register_class_SoapParam(void) zval property_param_name_default_value; ZVAL_UNDEF(&property_param_name_default_value); - zend_string *property_param_name_name = zend_string_init("param_name", sizeof("param_name") - 1, 1); + zend_string *property_param_name_name = zend_string_init("param_name", sizeof("param_name") - 1, true); zend_declare_typed_property(class_entry, property_param_name_name, &property_param_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_param_name_name); + zend_string_release_ex(property_param_name_name, true); zval property_param_data_default_value; ZVAL_UNDEF(&property_param_data_default_value); - zend_string *property_param_data_name = zend_string_init("param_data", sizeof("param_data") - 1, 1); + zend_string *property_param_data_name = zend_string_init("param_data", sizeof("param_data") - 1, true); zend_declare_typed_property(class_entry, property_param_data_name, &property_param_data_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_param_data_name); + zend_string_release_ex(property_param_data_name, true); return class_entry; } @@ -377,9 +377,9 @@ static zend_class_entry *register_class_SoapHeader(void) zval property_namespace_default_value; ZVAL_UNDEF(&property_namespace_default_value); - zend_string *property_namespace_name = zend_string_init("namespace", sizeof("namespace") - 1, 1); + zend_string *property_namespace_name = zend_string_init("namespace", sizeof("namespace") - 1, true); zend_declare_typed_property(class_entry, property_namespace_name, &property_namespace_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_namespace_name); + zend_string_release_ex(property_namespace_name, true); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); @@ -387,21 +387,21 @@ static zend_class_entry *register_class_SoapHeader(void) zval property_data_default_value; ZVAL_NULL(&property_data_default_value); - zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, 1); + zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, true); zend_declare_typed_property(class_entry, property_data_name, &property_data_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_data_name); + zend_string_release_ex(property_data_name, true); zval property_mustUnderstand_default_value; ZVAL_UNDEF(&property_mustUnderstand_default_value); - zend_string *property_mustUnderstand_name = zend_string_init("mustUnderstand", sizeof("mustUnderstand") - 1, 1); + zend_string *property_mustUnderstand_name = zend_string_init("mustUnderstand", sizeof("mustUnderstand") - 1, true); zend_declare_typed_property(class_entry, property_mustUnderstand_name, &property_mustUnderstand_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_mustUnderstand_name); + zend_string_release_ex(property_mustUnderstand_name, true); zval property_actor_default_value; ZVAL_UNDEF(&property_actor_default_value); - zend_string *property_actor_name = zend_string_init("actor", sizeof("actor") - 1, 1); + zend_string *property_actor_name = zend_string_init("actor", sizeof("actor") - 1, true); zend_declare_typed_property(class_entry, property_actor_name, &property_actor_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property_actor_name); + zend_string_release_ex(property_actor_name, true); return class_entry; } @@ -415,51 +415,51 @@ static zend_class_entry *register_class_SoapFault(zend_class_entry *class_entry_ zval property_faultstring_default_value; ZVAL_UNDEF(&property_faultstring_default_value); - zend_string *property_faultstring_name = zend_string_init("faultstring", sizeof("faultstring") - 1, 1); + zend_string *property_faultstring_name = zend_string_init("faultstring", sizeof("faultstring") - 1, true); zend_declare_typed_property(class_entry, property_faultstring_name, &property_faultstring_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_faultstring_name); + zend_string_release_ex(property_faultstring_name, true); zval property_faultcode_default_value; ZVAL_NULL(&property_faultcode_default_value); - zend_string *property_faultcode_name = zend_string_init("faultcode", sizeof("faultcode") - 1, 1); + zend_string *property_faultcode_name = zend_string_init("faultcode", sizeof("faultcode") - 1, true); zend_declare_typed_property(class_entry, property_faultcode_name, &property_faultcode_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_faultcode_name); + zend_string_release_ex(property_faultcode_name, true); zval property_faultcodens_default_value; ZVAL_NULL(&property_faultcodens_default_value); - zend_string *property_faultcodens_name = zend_string_init("faultcodens", sizeof("faultcodens") - 1, 1); + zend_string *property_faultcodens_name = zend_string_init("faultcodens", sizeof("faultcodens") - 1, true); zend_declare_typed_property(class_entry, property_faultcodens_name, &property_faultcodens_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_faultcodens_name); + zend_string_release_ex(property_faultcodens_name, true); zval property_faultactor_default_value; ZVAL_NULL(&property_faultactor_default_value); - zend_string *property_faultactor_name = zend_string_init("faultactor", sizeof("faultactor") - 1, 1); + zend_string *property_faultactor_name = zend_string_init("faultactor", sizeof("faultactor") - 1, true); zend_declare_typed_property(class_entry, property_faultactor_name, &property_faultactor_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_faultactor_name); + zend_string_release_ex(property_faultactor_name, true); zval property_detail_default_value; ZVAL_NULL(&property_detail_default_value); - zend_string *property_detail_name = zend_string_init("detail", sizeof("detail") - 1, 1); + zend_string *property_detail_name = zend_string_init("detail", sizeof("detail") - 1, true); zend_declare_typed_property(class_entry, property_detail_name, &property_detail_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_detail_name); + zend_string_release_ex(property_detail_name, true); zval property__name_default_value; ZVAL_NULL(&property__name_default_value); - zend_string *property__name_name = zend_string_init("_name", sizeof("_name") - 1, 1); + zend_string *property__name_name = zend_string_init("_name", sizeof("_name") - 1, true); zend_declare_typed_property(class_entry, property__name_name, &property__name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__name_name); + zend_string_release_ex(property__name_name, true); zval property_headerfault_default_value; ZVAL_NULL(&property_headerfault_default_value); - zend_string *property_headerfault_name = zend_string_init("headerfault", sizeof("headerfault") - 1, 1); + zend_string *property_headerfault_name = zend_string_init("headerfault", sizeof("headerfault") - 1, true); zend_declare_typed_property(class_entry, property_headerfault_name, &property_headerfault_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_headerfault_name); + zend_string_release_ex(property_headerfault_name, true); zval property_lang_default_value; ZVAL_EMPTY_STRING(&property_lang_default_value); - zend_string *property_lang_name = zend_string_init("lang", sizeof("lang") - 1, 1); + zend_string *property_lang_name = zend_string_init("lang", sizeof("lang") - 1, true); zend_declare_typed_property(class_entry, property_lang_name, &property_lang_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_lang_name); + zend_string_release_ex(property_lang_name, true); return class_entry; } @@ -473,39 +473,39 @@ static zend_class_entry *register_class_SoapVar(void) zval property_enc_type_default_value; ZVAL_UNDEF(&property_enc_type_default_value); - zend_string *property_enc_type_name = zend_string_init("enc_type", sizeof("enc_type") - 1, 1); + zend_string *property_enc_type_name = zend_string_init("enc_type", sizeof("enc_type") - 1, true); zend_declare_typed_property(class_entry, property_enc_type_name, &property_enc_type_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_enc_type_name); + zend_string_release_ex(property_enc_type_name, true); zval property_enc_value_default_value; ZVAL_NULL(&property_enc_value_default_value); - zend_string *property_enc_value_name = zend_string_init("enc_value", sizeof("enc_value") - 1, 1); + zend_string *property_enc_value_name = zend_string_init("enc_value", sizeof("enc_value") - 1, true); zend_declare_typed_property(class_entry, property_enc_value_name, &property_enc_value_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_enc_value_name); + zend_string_release_ex(property_enc_value_name, true); zval property_enc_stype_default_value; ZVAL_NULL(&property_enc_stype_default_value); - zend_string *property_enc_stype_name = zend_string_init("enc_stype", sizeof("enc_stype") - 1, 1); + zend_string *property_enc_stype_name = zend_string_init("enc_stype", sizeof("enc_stype") - 1, true); zend_declare_typed_property(class_entry, property_enc_stype_name, &property_enc_stype_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_enc_stype_name); + zend_string_release_ex(property_enc_stype_name, true); zval property_enc_ns_default_value; ZVAL_NULL(&property_enc_ns_default_value); - zend_string *property_enc_ns_name = zend_string_init("enc_ns", sizeof("enc_ns") - 1, 1); + zend_string *property_enc_ns_name = zend_string_init("enc_ns", sizeof("enc_ns") - 1, true); zend_declare_typed_property(class_entry, property_enc_ns_name, &property_enc_ns_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_enc_ns_name); + zend_string_release_ex(property_enc_ns_name, true); zval property_enc_name_default_value; ZVAL_NULL(&property_enc_name_default_value); - zend_string *property_enc_name_name = zend_string_init("enc_name", sizeof("enc_name") - 1, 1); + zend_string *property_enc_name_name = zend_string_init("enc_name", sizeof("enc_name") - 1, true); zend_declare_typed_property(class_entry, property_enc_name_name, &property_enc_name_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_enc_name_name); + zend_string_release_ex(property_enc_name_name, true); zval property_enc_namens_default_value; ZVAL_NULL(&property_enc_namens_default_value); - zend_string *property_enc_namens_name = zend_string_init("enc_namens", sizeof("enc_namens") - 1, 1); + zend_string *property_enc_namens_name = zend_string_init("enc_namens", sizeof("enc_namens") - 1, true); zend_declare_typed_property(class_entry, property_enc_namens_name, &property_enc_namens_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_enc_namens_name); + zend_string_release_ex(property_enc_namens_name, true); return class_entry; } @@ -519,10 +519,10 @@ static zend_class_entry *register_class_SoapServer(void) zval property___soap_fault_default_value; ZVAL_NULL(&property___soap_fault_default_value); - zend_string *property___soap_fault_name = zend_string_init("__soap_fault", sizeof("__soap_fault") - 1, 1); + zend_string *property___soap_fault_name = zend_string_init("__soap_fault", sizeof("__soap_fault") - 1, true); zend_string *property___soap_fault_class_SoapFault = zend_string_init("SoapFault", sizeof("SoapFault")-1, 1); zend_declare_typed_property(class_entry, property___soap_fault_name, &property___soap_fault_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property___soap_fault_class_SoapFault, 0, MAY_BE_NULL)); - zend_string_release(property___soap_fault_name); + zend_string_release_ex(property___soap_fault_name, true); return class_entry; } @@ -536,27 +536,27 @@ static zend_class_entry *register_class_SoapClient(void) zval property_uri_default_value; ZVAL_NULL(&property_uri_default_value); - zend_string *property_uri_name = zend_string_init("uri", sizeof("uri") - 1, 1); + zend_string *property_uri_name = zend_string_init("uri", sizeof("uri") - 1, true); zend_declare_typed_property(class_entry, property_uri_name, &property_uri_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_uri_name); + zend_string_release_ex(property_uri_name, true); zval property_style_default_value; ZVAL_NULL(&property_style_default_value); - zend_string *property_style_name = zend_string_init("style", sizeof("style") - 1, 1); + zend_string *property_style_name = zend_string_init("style", sizeof("style") - 1, true); zend_declare_typed_property(class_entry, property_style_name, &property_style_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property_style_name); + zend_string_release_ex(property_style_name, true); zval property_use_default_value; ZVAL_NULL(&property_use_default_value); - zend_string *property_use_name = zend_string_init("use", sizeof("use") - 1, 1); + zend_string *property_use_name = zend_string_init("use", sizeof("use") - 1, true); zend_declare_typed_property(class_entry, property_use_name, &property_use_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property_use_name); + zend_string_release_ex(property_use_name, true); zval property_location_default_value; ZVAL_NULL(&property_location_default_value); - zend_string *property_location_name = zend_string_init("location", sizeof("location") - 1, 1); + zend_string *property_location_name = zend_string_init("location", sizeof("location") - 1, true); zend_declare_typed_property(class_entry, property_location_name, &property_location_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_location_name); + zend_string_release_ex(property_location_name, true); zval property_trace_default_value; ZVAL_FALSE(&property_trace_default_value); @@ -564,192 +564,192 @@ static zend_class_entry *register_class_SoapClient(void) zval property_compression_default_value; ZVAL_NULL(&property_compression_default_value); - zend_string *property_compression_name = zend_string_init("compression", sizeof("compression") - 1, 1); + zend_string *property_compression_name = zend_string_init("compression", sizeof("compression") - 1, true); zend_declare_typed_property(class_entry, property_compression_name, &property_compression_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property_compression_name); + zend_string_release_ex(property_compression_name, true); 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_string *property_sdl_name = zend_string_init("sdl", sizeof("sdl") - 1, true); 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); + zend_string_release_ex(property_sdl_name, true); 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_string *property_typemap_name = zend_string_init("typemap", sizeof("typemap") - 1, true); 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); + zend_string_release_ex(property_typemap_name, true); zval property_httpsocket_default_value; ZVAL_NULL(&property_httpsocket_default_value); - zend_string *property_httpsocket_name = zend_string_init("httpsocket", sizeof("httpsocket") - 1, 1); + zend_string *property_httpsocket_name = zend_string_init("httpsocket", sizeof("httpsocket") - 1, true); zend_declare_typed_property(class_entry, property_httpsocket_name, &property_httpsocket_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0)); - zend_string_release(property_httpsocket_name); + zend_string_release_ex(property_httpsocket_name, true); 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_string *property_httpurl_name = zend_string_init("httpurl", sizeof("httpurl") - 1, true); 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); + zend_string_release_ex(property_httpurl_name, true); zval property__login_default_value; ZVAL_NULL(&property__login_default_value); - zend_string *property__login_name = zend_string_init("_login", sizeof("_login") - 1, 1); + zend_string *property__login_name = zend_string_init("_login", sizeof("_login") - 1, true); zend_declare_typed_property(class_entry, property__login_name, &property__login_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__login_name); + zend_string_release_ex(property__login_name, true); zval property__password_default_value; ZVAL_NULL(&property__password_default_value); - zend_string *property__password_name = zend_string_init("_password", sizeof("_password") - 1, 1); + zend_string *property__password_name = zend_string_init("_password", sizeof("_password") - 1, true); zend_declare_typed_property(class_entry, property__password_name, &property__password_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__password_name); + zend_string_release_ex(property__password_name, true); zval property__use_digest_default_value; ZVAL_FALSE(&property__use_digest_default_value); - zend_string *property__use_digest_name = zend_string_init("_use_digest", sizeof("_use_digest") - 1, 1); + zend_string *property__use_digest_name = zend_string_init("_use_digest", sizeof("_use_digest") - 1, true); zend_declare_typed_property(class_entry, property__use_digest_name, &property__use_digest_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property__use_digest_name); + zend_string_release_ex(property__use_digest_name, true); zval property__digest_default_value; ZVAL_NULL(&property__digest_default_value); - zend_string *property__digest_name = zend_string_init("_digest", sizeof("_digest") - 1, 1); + zend_string *property__digest_name = zend_string_init("_digest", sizeof("_digest") - 1, true); zend_declare_typed_property(class_entry, property__digest_name, &property__digest_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__digest_name); + zend_string_release_ex(property__digest_name, true); zval property__proxy_host_default_value; ZVAL_NULL(&property__proxy_host_default_value); - zend_string *property__proxy_host_name = zend_string_init("_proxy_host", sizeof("_proxy_host") - 1, 1); + zend_string *property__proxy_host_name = zend_string_init("_proxy_host", sizeof("_proxy_host") - 1, true); zend_declare_typed_property(class_entry, property__proxy_host_name, &property__proxy_host_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__proxy_host_name); + zend_string_release_ex(property__proxy_host_name, true); zval property__proxy_port_default_value; ZVAL_NULL(&property__proxy_port_default_value); - zend_string *property__proxy_port_name = zend_string_init("_proxy_port", sizeof("_proxy_port") - 1, 1); + zend_string *property__proxy_port_name = zend_string_init("_proxy_port", sizeof("_proxy_port") - 1, true); zend_declare_typed_property(class_entry, property__proxy_port_name, &property__proxy_port_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property__proxy_port_name); + zend_string_release_ex(property__proxy_port_name, true); zval property__proxy_login_default_value; ZVAL_NULL(&property__proxy_login_default_value); - zend_string *property__proxy_login_name = zend_string_init("_proxy_login", sizeof("_proxy_login") - 1, 1); + zend_string *property__proxy_login_name = zend_string_init("_proxy_login", sizeof("_proxy_login") - 1, true); zend_declare_typed_property(class_entry, property__proxy_login_name, &property__proxy_login_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__proxy_login_name); + zend_string_release_ex(property__proxy_login_name, true); zval property__proxy_password_default_value; ZVAL_NULL(&property__proxy_password_default_value); - zend_string *property__proxy_password_name = zend_string_init("_proxy_password", sizeof("_proxy_password") - 1, 1); + zend_string *property__proxy_password_name = zend_string_init("_proxy_password", sizeof("_proxy_password") - 1, true); zend_declare_typed_property(class_entry, property__proxy_password_name, &property__proxy_password_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__proxy_password_name); + zend_string_release_ex(property__proxy_password_name, true); zval property__exceptions_default_value; ZVAL_TRUE(&property__exceptions_default_value); - zend_string *property__exceptions_name = zend_string_init("_exceptions", sizeof("_exceptions") - 1, 1); + zend_string *property__exceptions_name = zend_string_init("_exceptions", sizeof("_exceptions") - 1, true); zend_declare_typed_property(class_entry, property__exceptions_name, &property__exceptions_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property__exceptions_name); + zend_string_release_ex(property__exceptions_name, true); zval property__encoding_default_value; ZVAL_NULL(&property__encoding_default_value); - zend_string *property__encoding_name = zend_string_init("_encoding", sizeof("_encoding") - 1, 1); + zend_string *property__encoding_name = zend_string_init("_encoding", sizeof("_encoding") - 1, true); zend_declare_typed_property(class_entry, property__encoding_name, &property__encoding_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__encoding_name); + zend_string_release_ex(property__encoding_name, true); zval property__classmap_default_value; ZVAL_NULL(&property__classmap_default_value); - zend_string *property__classmap_name = zend_string_init("_classmap", sizeof("_classmap") - 1, 1); + zend_string *property__classmap_name = zend_string_init("_classmap", sizeof("_classmap") - 1, true); zend_declare_typed_property(class_entry, property__classmap_name, &property__classmap_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL)); - zend_string_release(property__classmap_name); + zend_string_release_ex(property__classmap_name, true); zval property__features_default_value; ZVAL_NULL(&property__features_default_value); - zend_string *property__features_name = zend_string_init("_features", sizeof("_features") - 1, 1); + zend_string *property__features_name = zend_string_init("_features", sizeof("_features") - 1, true); zend_declare_typed_property(class_entry, property__features_name, &property__features_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property__features_name); + zend_string_release_ex(property__features_name, true); zval property__connection_timeout_default_value; ZVAL_LONG(&property__connection_timeout_default_value, 0); - zend_string *property__connection_timeout_name = zend_string_init("_connection_timeout", sizeof("_connection_timeout") - 1, 1); + zend_string *property__connection_timeout_name = zend_string_init("_connection_timeout", sizeof("_connection_timeout") - 1, true); zend_declare_typed_property(class_entry, property__connection_timeout_name, &property__connection_timeout_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property__connection_timeout_name); + zend_string_release_ex(property__connection_timeout_name, true); zval property__stream_context_default_value; ZVAL_NULL(&property__stream_context_default_value); - zend_string *property__stream_context_name = zend_string_init("_stream_context", sizeof("_stream_context") - 1, 1); + zend_string *property__stream_context_name = zend_string_init("_stream_context", sizeof("_stream_context") - 1, true); zend_declare_typed_property(class_entry, property__stream_context_name, &property__stream_context_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0)); - zend_string_release(property__stream_context_name); + zend_string_release_ex(property__stream_context_name, true); zval property__user_agent_default_value; ZVAL_NULL(&property__user_agent_default_value); - zend_string *property__user_agent_name = zend_string_init("_user_agent", sizeof("_user_agent") - 1, 1); + zend_string *property__user_agent_name = zend_string_init("_user_agent", sizeof("_user_agent") - 1, true); zend_declare_typed_property(class_entry, property__user_agent_name, &property__user_agent_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property__user_agent_name); + zend_string_release_ex(property__user_agent_name, true); zval property__keep_alive_default_value; ZVAL_TRUE(&property__keep_alive_default_value); - zend_string *property__keep_alive_name = zend_string_init("_keep_alive", sizeof("_keep_alive") - 1, 1); + zend_string *property__keep_alive_name = zend_string_init("_keep_alive", sizeof("_keep_alive") - 1, true); zend_declare_typed_property(class_entry, property__keep_alive_name, &property__keep_alive_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property__keep_alive_name); + zend_string_release_ex(property__keep_alive_name, true); zval property__ssl_method_default_value; ZVAL_NULL(&property__ssl_method_default_value); - zend_string *property__ssl_method_name = zend_string_init("_ssl_method", sizeof("_ssl_method") - 1, 1); + zend_string *property__ssl_method_name = zend_string_init("_ssl_method", sizeof("_ssl_method") - 1, true); zend_declare_typed_property(class_entry, property__ssl_method_name, &property__ssl_method_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property__ssl_method_name); + zend_string_release_ex(property__ssl_method_name, true); zval property__soap_version_default_value; ZVAL_UNDEF(&property__soap_version_default_value); - zend_string *property__soap_version_name = zend_string_init("_soap_version", sizeof("_soap_version") - 1, 1); + zend_string *property__soap_version_name = zend_string_init("_soap_version", sizeof("_soap_version") - 1, true); zend_declare_typed_property(class_entry, property__soap_version_name, &property__soap_version_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property__soap_version_name); + zend_string_release_ex(property__soap_version_name, true); zval property__use_proxy_default_value; ZVAL_NULL(&property__use_proxy_default_value); - zend_string *property__use_proxy_name = zend_string_init("_use_proxy", sizeof("_use_proxy") - 1, 1); + zend_string *property__use_proxy_name = zend_string_init("_use_proxy", sizeof("_use_proxy") - 1, true); zend_declare_typed_property(class_entry, property__use_proxy_name, &property__use_proxy_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property__use_proxy_name); + zend_string_release_ex(property__use_proxy_name, true); zval property__cookies_default_value; ZVAL_EMPTY_ARRAY(&property__cookies_default_value); - zend_string *property__cookies_name = zend_string_init("_cookies", sizeof("_cookies") - 1, 1); + zend_string *property__cookies_name = zend_string_init("_cookies", sizeof("_cookies") - 1, true); zend_declare_typed_property(class_entry, property__cookies_name, &property__cookies_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); - zend_string_release(property__cookies_name); + zend_string_release_ex(property__cookies_name, true); zval property___default_headers_default_value; ZVAL_NULL(&property___default_headers_default_value); - zend_string *property___default_headers_name = zend_string_init("__default_headers", sizeof("__default_headers") - 1, 1); + zend_string *property___default_headers_name = zend_string_init("__default_headers", sizeof("__default_headers") - 1, true); zend_declare_typed_property(class_entry, property___default_headers_name, &property___default_headers_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL)); - zend_string_release(property___default_headers_name); + zend_string_release_ex(property___default_headers_name, true); zval property___soap_fault_default_value; ZVAL_NULL(&property___soap_fault_default_value); - zend_string *property___soap_fault_name = zend_string_init("__soap_fault", sizeof("__soap_fault") - 1, 1); + zend_string *property___soap_fault_name = zend_string_init("__soap_fault", sizeof("__soap_fault") - 1, true); zend_string *property___soap_fault_class_SoapFault = zend_string_init("SoapFault", sizeof("SoapFault")-1, 1); zend_declare_typed_property(class_entry, property___soap_fault_name, &property___soap_fault_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property___soap_fault_class_SoapFault, 0, MAY_BE_NULL)); - zend_string_release(property___soap_fault_name); + zend_string_release_ex(property___soap_fault_name, true); zval property___last_request_default_value; ZVAL_NULL(&property___last_request_default_value); - zend_string *property___last_request_name = zend_string_init("__last_request", sizeof("__last_request") - 1, 1); + zend_string *property___last_request_name = zend_string_init("__last_request", sizeof("__last_request") - 1, true); zend_declare_typed_property(class_entry, property___last_request_name, &property___last_request_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property___last_request_name); + zend_string_release_ex(property___last_request_name, true); zval property___last_response_default_value; ZVAL_NULL(&property___last_response_default_value); - zend_string *property___last_response_name = zend_string_init("__last_response", sizeof("__last_response") - 1, 1); + zend_string *property___last_response_name = zend_string_init("__last_response", sizeof("__last_response") - 1, true); zend_declare_typed_property(class_entry, property___last_response_name, &property___last_response_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property___last_response_name); + zend_string_release_ex(property___last_response_name, true); zval property___last_request_headers_default_value; ZVAL_NULL(&property___last_request_headers_default_value); - zend_string *property___last_request_headers_name = zend_string_init("__last_request_headers", sizeof("__last_request_headers") - 1, 1); + zend_string *property___last_request_headers_name = zend_string_init("__last_request_headers", sizeof("__last_request_headers") - 1, true); zend_declare_typed_property(class_entry, property___last_request_headers_name, &property___last_request_headers_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property___last_request_headers_name); + zend_string_release_ex(property___last_request_headers_name, true); zval property___last_response_headers_default_value; ZVAL_NULL(&property___last_response_headers_default_value); - zend_string *property___last_response_headers_name = zend_string_init("__last_response_headers", sizeof("__last_response_headers") - 1, 1); + zend_string *property___last_response_headers_name = zend_string_init("__last_response_headers", sizeof("__last_response_headers") - 1, true); zend_declare_typed_property(class_entry, property___last_response_headers_name, &property___last_response_headers_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property___last_response_headers_name); + zend_string_release_ex(property___last_response_headers_name, true); return class_entry; } diff --git a/ext/soap/tests/soap_set_cookie.phpt b/ext/soap/tests/soap_set_cookie.phpt new file mode 100644 index 0000000000000..a23aa18bb4b75 --- /dev/null +++ b/ext/soap/tests/soap_set_cookie.phpt @@ -0,0 +1,22 @@ +--TEST-- +SoapClient::__setCookie with numeric keys +--EXTENSIONS-- +soap +--FILE-- + 'mo:http://www.w3.org/', 'location' => 'http://example.com')); +$client->__setCookie("123", "456"); +var_dump($client->__getCookies()); +$client->__setCookie("123", NULL); +var_dump($client->__getCookies()); +?> +--EXPECT-- +array(1) { + [123]=> + array(1) { + [0]=> + string(3) "456" + } +} +array(0) { +} diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index f331fd177ebfd..522e6b346f66d 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -293,7 +293,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock, goto dosockopt; case IP_MULTICAST_LOOP: - ipv4_mcast_ttl_lback = (unsigned char) zval_is_true(arg4); + ipv4_mcast_ttl_lback = (unsigned char) zend_is_true(arg4); goto ipv4_loop_ttl; case IP_MULTICAST_TTL: @@ -357,7 +357,7 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock, goto dosockopt; case IPV6_MULTICAST_LOOP: - ov = (int) zval_is_true(arg4); + ov = (int) zend_is_true(arg4); goto ipv6_loop_hops; case IPV6_MULTICAST_HOPS: convert_to_long(arg4); diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 6fb75e2db1db3..b76818830fc06 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -18,6 +18,7 @@ +----------------------------------------------------------------------+ */ +#include "zend_exceptions.h" #ifdef HAVE_CONFIG_H #include #endif @@ -250,7 +251,7 @@ static bool php_open_listen_sock(php_socket *sock, unsigned short port, int back #else if ((hp = php_network_gethostbyname("localhost")) == NULL) { #endif - return 0; + return false; } memcpy((char *) &la.sin_addr, hp->h_addr, hp->h_length); @@ -262,7 +263,7 @@ static bool php_open_listen_sock(php_socket *sock, unsigned short port, int back if (IS_INVALID_SOCKET(sock)) { PHP_SOCKET_ERROR(sock, "unable to create listening socket", errno); - return 0; + return false; } sock->type = PF_INET; @@ -270,16 +271,16 @@ static bool php_open_listen_sock(php_socket *sock, unsigned short port, int back if (bind(sock->bsd_socket, (struct sockaddr *)&la, sizeof(la)) != 0) { PHP_SOCKET_ERROR(sock, "unable to bind to given address", errno); close(sock->bsd_socket); - return 0; + return false; } if (listen(sock->bsd_socket, backlog) != 0) { PHP_SOCKET_ERROR(sock, "unable to listen on socket", errno); close(sock->bsd_socket); - return 0; + return false; } - return 1; + return true; } /* }}} */ @@ -295,14 +296,14 @@ static bool php_accept_connect(php_socket *in_sock, php_socket *out_sock, struct if (IS_INVALID_SOCKET(out_sock)) { PHP_SOCKET_ERROR(out_sock, "unable to accept incoming connection", errno); - return 0; + return false; } #else out_sock->bsd_socket = accept(in_sock->bsd_socket, la, la_len); if (IS_INVALID_SOCKET(out_sock)) { PHP_SOCKET_ERROR(out_sock, "unable to accept incoming connection", errno); - return 0; + return false; } #if !defined(PHP_WIN32) @@ -314,7 +315,7 @@ static bool php_accept_connect(php_socket *in_sock, php_socket *out_sock, struct if ((mode = fcntl(out_sock->bsd_socket, F_GETFD)) < 0) { PHP_SOCKET_ERROR(out_sock, "unable to get fcntl mode on the socket", errno); - return 0; + return false; } int cloexec = (mode | FD_CLOEXEC); @@ -322,7 +323,7 @@ static bool php_accept_connect(php_socket *in_sock, php_socket *out_sock, struct if (mode != cloexec) { if (fcntl(out_sock->bsd_socket, F_SETFD, cloexec) < 0) { PHP_SOCKET_ERROR(out_sock, "unable to set cloexec mode on the socket", errno); - return 0; + return false; } } #endif @@ -332,7 +333,7 @@ static bool php_accept_connect(php_socket *in_sock, php_socket *out_sock, struct out_sock->blocking = 1; out_sock->type = la->sa_family; - return 1; + return true; } /* }}} */ @@ -1580,7 +1581,11 @@ PHP_FUNCTION(socket_recvfrom) if (arg6 == NULL) { zend_string_efree(recv_buf); - WRONG_PARAM_COUNT; + zend_throw_exception( + zend_ce_argument_count_error, + "socket_recvfrom() expects exactly 6 arguments when argument #1 ($socket) is of type AF_INET or AF_INET6", + 0); + RETURN_THROWS(); } retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (socklen_t *)&slen); @@ -1607,7 +1612,11 @@ PHP_FUNCTION(socket_recvfrom) if (arg6 == NULL) { zend_string_efree(recv_buf); - WRONG_PARAM_COUNT; + zend_throw_exception( + zend_ce_argument_count_error, + "socket_recvfrom() expects exactly 6 arguments when argument #1 ($socket) is of type AF_INET or AF_INET6", + 0); + RETURN_THROWS(); } retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, (socklen_t *)&slen); @@ -1764,7 +1773,7 @@ PHP_FUNCTION(socket_sendto) RETURN_THROWS(); } - memset(&sll, 0, sizeof(sll)); + memset(&sll, 0, sizeof(sll)); sll.sll_family = AF_PACKET; sll.sll_ifindex = port; @@ -2121,6 +2130,28 @@ PHP_FUNCTION(socket_set_option) } #endif +#if defined(TCP_USER_TIMEOUT) + case TCP_USER_TIMEOUT: { + zend_long timeout = zval_get_long(arg4); + + // TCP_USER_TIMEOUT unsigned int + if (timeout < 0 || timeout > UINT_MAX) { + zend_argument_value_error(4, "must be of between 0 and %u", UINT_MAX); + RETURN_THROWS(); + } + + unsigned int val = (unsigned int)timeout; + optlen = sizeof(val); + opt_ptr = &val; + if (setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen) != 0) { + PHP_SOCKET_ERROR(php_sock, "Unable to set socket option", errno); + RETURN_FALSE; + } + + RETURN_TRUE; + } +#endif + } } @@ -2557,7 +2588,7 @@ bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket *retsock) retsock->type = addr.ss_family; } else { PHP_SOCKET_ERROR(retsock, "Unable to obtain socket family", errno); - return 0; + return false; } /* determine blocking mode */ @@ -2565,13 +2596,13 @@ bool socket_import_file_descriptor(PHP_SOCKET socket, php_socket *retsock) t = fcntl(socket, F_GETFL); if (t == -1) { PHP_SOCKET_ERROR(retsock, "Unable to obtain blocking state", errno); - return 0; + return false; } else { retsock->blocking = !(t & O_NONBLOCK); } #endif - return 1; + return true; } /* {{{ Imports a stream that encapsulates a socket into a socket extension resource. */ diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index 6050a89414565..04fb702807e0a 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -602,6 +602,13 @@ */ const TCP_SYNCNT = UNKNOWN; #endif +#ifdef TCP_USER_TIMEOUT +/** + * @var int + * @cvalue TCP_USER_TIMEOUT + */ +const TCP_USER_TIMEOUT = UNKNOWN; +#endif #ifdef SO_ZEROCOPY /** * @var int @@ -643,11 +650,15 @@ * @cvalue TCP_KEEPIDLE */ const TCP_KEEPIDLE = UNKNOWN; +#endif +#ifdef TCP_KEEPINTVL /** * @var int * @cvalue TCP_KEEPINTVL */ const TCP_KEEPINTVL = UNKNOWN; +#endif +#ifdef TCP_KEEPCNT /** * @var int * @cvalue TCP_KEEPCNT diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index b7af6eb6b89ac..0145d01252881 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: 7b1baf47dce2fb08faa5616068238ea078d1609b */ + * Stub hash: 038081ca7bb98076d4b559d93b4c9300acc47160 */ 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) @@ -527,6 +527,9 @@ static void register_sockets_symbols(int module_number) #if defined(TCP_SYNCNT) REGISTER_LONG_CONSTANT("TCP_SYNCNT", TCP_SYNCNT, CONST_PERSISTENT); #endif +#if defined(TCP_USER_TIMEOUT) + REGISTER_LONG_CONSTANT("TCP_USER_TIMEOUT", TCP_USER_TIMEOUT, CONST_PERSISTENT); +#endif #if defined(SO_ZEROCOPY) REGISTER_LONG_CONSTANT("SO_ZEROCOPY", SO_ZEROCOPY, CONST_PERSISTENT); #endif @@ -544,7 +547,11 @@ static void register_sockets_symbols(int module_number) #endif #if defined(TCP_KEEPIDLE) REGISTER_LONG_CONSTANT("TCP_KEEPIDLE", TCP_KEEPIDLE, CONST_PERSISTENT); +#endif +#if defined(TCP_KEEPINTVL) REGISTER_LONG_CONSTANT("TCP_KEEPINTVL", TCP_KEEPINTVL, CONST_PERSISTENT); +#endif +#if defined(TCP_KEEPCNT) REGISTER_LONG_CONSTANT("TCP_KEEPCNT", TCP_KEEPCNT, CONST_PERSISTENT); #endif #if defined(TCP_FUNCTION_BLK) diff --git a/ext/sockets/tests/socket_recvfrom_ipv4_missing_port_arg.phpt b/ext/sockets/tests/socket_recvfrom_ipv4_missing_port_arg.phpt new file mode 100644 index 0000000000000..0554818fb67c8 --- /dev/null +++ b/ext/sockets/tests/socket_recvfrom_ipv4_missing_port_arg.phpt @@ -0,0 +1,17 @@ +--TEST-- +socket_recvfrom() with IPv4 socket missing port argument +--EXTENSIONS-- +sockets +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +ArgumentCountError: socket_recvfrom() expects exactly 6 arguments when argument #1 ($socket) is of type AF_INET or AF_INET6 diff --git a/ext/sockets/tests/socket_recvfrom_ipv6_missing_port_arg.phpt b/ext/sockets/tests/socket_recvfrom_ipv6_missing_port_arg.phpt new file mode 100644 index 0000000000000..957751a949763 --- /dev/null +++ b/ext/sockets/tests/socket_recvfrom_ipv6_missing_port_arg.phpt @@ -0,0 +1,21 @@ +--TEST-- +socket_recvfrom() with IPv6 socket missing port argument +--EXTENSIONS-- +sockets +--SKIPIF-- + +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +ArgumentCountError: socket_recvfrom() expects exactly 6 arguments when argument #1 ($socket) is of type AF_INET or AF_INET6 diff --git a/ext/sockets/tests/socket_setoption_tcpusertimeout_32bit.phpt b/ext/sockets/tests/socket_setoption_tcpusertimeout_32bit.phpt new file mode 100644 index 0000000000000..3f12120e54d89 --- /dev/null +++ b/ext/sockets/tests/socket_setoption_tcpusertimeout_32bit.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test if socket_set_option() works, option:TCP_USER_TIMEOUT +--EXTENSIONS-- +sockets +--SKIPIF-- + +--FILE-- +getMessage(), PHP_EOL; +} + +$timeout = 200; +$retval_2 = socket_set_option($socket, SOL_TCP, TCP_USER_TIMEOUT, $timeout); +$retval_3 = socket_get_option($socket, SOL_TCP, TCP_USER_TIMEOUT); +var_dump($retval_2); +var_dump($retval_3 === $timeout); +socket_close($socket); +?> +--EXPECTF-- +socket_setopt(): Argument #4 ($value) must be of between 0 and %d +bool(true) +bool(true) diff --git a/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt b/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt new file mode 100644 index 0000000000000..8dbb7f80e48b1 --- /dev/null +++ b/ext/sockets/tests/socket_setoption_tcpusertimeout_64bit.phpt @@ -0,0 +1,41 @@ +--TEST-- +Test if socket_set_option() works, option:TCP_USER_TIMEOUT +--EXTENSIONS-- +sockets +--SKIPIF-- + +--FILE-- +getMessage(), PHP_EOL; +} + +try { + socket_setopt($socket, SOL_TCP, TCP_USER_TIMEOUT, PHP_INT_MAX); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +$timeout = 200; +$retval_2 = socket_set_option($socket, SOL_TCP, TCP_USER_TIMEOUT, $timeout); +$retval_3 = socket_get_option($socket, SOL_TCP, TCP_USER_TIMEOUT); +var_dump($retval_2); +var_dump($retval_3 === $timeout); +socket_close($socket); +?> +--EXPECTF-- +socket_setopt(): Argument #4 ($value) must be of between 0 and %d +socket_setopt(): Argument #4 ($value) must be of between 0 and %d +bool(true) +bool(true) diff --git a/ext/sockets/tests/socket_tcp_keepalive.phpt b/ext/sockets/tests/socket_tcp_keepalive.phpt new file mode 100644 index 0000000000000..cef570dc62b2b --- /dev/null +++ b/ext/sockets/tests/socket_tcp_keepalive.phpt @@ -0,0 +1,52 @@ +--TEST-- +Test SO_KEEPALIVE and TCP keepalive constants +--EXTENSIONS-- +sockets +--SKIPIF-- + +--FILE-- + +--EXPECT-- +SO_KEEPALIVE: enabled +TCP_KEEPIDLE: 60 +TCP_KEEPINTVL: 10 +TCP_KEEPCNT: 5 diff --git a/ext/sodium/sodium_pwhash.c b/ext/sodium/sodium_pwhash.c index eea7fe9eb0f1d..32e4f72634c38 100644 --- a/ext/sodium/sodium_pwhash.c +++ b/ext/sodium/sodium_pwhash.c @@ -87,7 +87,7 @@ static zend_string *php_sodium_argon2_hash(const zend_string *password, zend_arr static bool php_sodium_argon2_verify(const zend_string *password, const zend_string *hash) { if ((ZSTR_LEN(password) >= 0xffffffff) || (ZSTR_LEN(hash) >= 0xffffffff)) { - return 0; + return false; } return crypto_pwhash_str_verify(ZSTR_VAL(hash), ZSTR_VAL(password), ZSTR_LEN(password)) == 0; } @@ -96,7 +96,7 @@ static bool php_sodium_argon2_needs_rehash(const zend_string *hash, zend_array * size_t opslimit, memlimit; if (get_options(options, &memlimit, &opslimit) == FAILURE) { - return 1; + return true; } return crypto_pwhash_str_needs_rehash(ZSTR_VAL(hash), opslimit, memlimit); } diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index f796b936daeec..0acfcbc5c16d0 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -66,7 +66,7 @@ PHP_FUNCTION(class_parents) { zval *obj; zend_class_entry *parent_class, *ce; - bool autoload = 1; + bool autoload = true; /* We do not use Z_PARAM_OBJ_OR_STR here to be able to exclude int, float, and bool which are bogus class names */ if (zend_parse_parameters(ZEND_NUM_ARGS(), "z|b", &obj, &autoload) == FAILURE) { @@ -99,7 +99,7 @@ PHP_FUNCTION(class_parents) PHP_FUNCTION(class_implements) { zval *obj; - bool autoload = 1; + bool autoload = true; zend_class_entry *ce; /* We do not use Z_PARAM_OBJ_OR_STR here to be able to exclude int, float, and bool which are bogus class names */ @@ -128,7 +128,7 @@ PHP_FUNCTION(class_implements) PHP_FUNCTION(class_uses) { zval *obj; - bool autoload = 1; + bool autoload = true; zend_class_entry *ce; /* We do not use Z_PARAM_OBJ_OR_STR here to be able to exclude int, float, and bool which are bogus class names */ @@ -216,9 +216,7 @@ PHP_FUNCTION(class_uses) /* {{{ Return an array containing the names of all classes and interfaces defined in SPL */ PHP_FUNCTION(spl_classes) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); @@ -619,9 +617,7 @@ PHP_FUNCTION(spl_autoload_functions) { autoload_func_info *alfi; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); if (spl_autoload_functions) { diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index ea21b422229b3..3d6870a7ee953 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -621,13 +621,13 @@ static bool spl_array_has_dimension_ex(bool check_inherited, zend_object *object if (!zend_is_true(&rv)) { zval_ptr_dtor(&rv); - return 0; + return false; } zval_ptr_dtor(&rv); /* For isset calls we don't need to check the value, so return early */ if (!check_empty) { - return 1; + return true; } else if (intern->fptr_offset_get) { value = spl_array_read_dimension_ex(1, object, offset, BP_VAR_R, &rv); } @@ -639,7 +639,7 @@ static bool spl_array_has_dimension_ex(bool check_inherited, zend_object *object if (get_hash_key(&key, intern, offset) == FAILURE) { zend_illegal_container_offset(object->ce->name, offset, BP_VAR_IS); - return 0; + return false; } if (key.key) { @@ -650,13 +650,13 @@ static bool spl_array_has_dimension_ex(bool check_inherited, zend_object *object } if (!tmp) { - return 0; + return false; } /* check_empty is only equal to 2 if it is called from offsetExists on this class, * where it needs to report an offset exists even if the value is null */ if (check_empty == 2) { - return 1; + return true; } if (check_empty && check_inherited && intern->fptr_offset_get) { @@ -753,9 +753,7 @@ PHP_METHOD(ArrayObject, getArrayCopy) zval *object = ZEND_THIS; spl_array_object *intern = Z_SPLARRAY_P(object); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_ARR(zend_array_dup(spl_array_get_hash_table(intern))); } /* }}} */ @@ -777,11 +775,11 @@ static HashTable *spl_array_get_properties_for(zend_object *object, zend_prop_pu * meantime. */ switch (purpose) { case ZEND_PROP_PURPOSE_ARRAY_CAST: - dup = 1; + dup = true; break; case ZEND_PROP_PURPOSE_VAR_EXPORT: case ZEND_PROP_PURPOSE_JSON: - dup = 0; + dup = false; break; default: return zend_std_get_properties_for(object, purpose); @@ -875,7 +873,7 @@ static zval *spl_array_get_property_ptr_ptr(zend_object *object, zend_string *na return NULL; } ZVAL_STR(&member, name); - return spl_array_get_dimension_ptr(1, intern, object->ce->name, &member, type); + return spl_array_get_dimension_ptr(true, intern, object->ce->name, &member, type); } return zend_std_get_property_ptr_ptr(object, name, type, cache_slot); } /* }}} */ @@ -1086,9 +1084,7 @@ PHP_METHOD(ArrayObject, getIteratorClass) zval *object = ZEND_THIS; spl_array_object *intern = Z_SPLARRAY_P(object); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_string_addref(intern->ce_get_iterator->name); RETURN_STR(intern->ce_get_iterator->name); @@ -1101,9 +1097,7 @@ PHP_METHOD(ArrayObject, getFlags) zval *object = ZEND_THIS; spl_array_object *intern = Z_SPLARRAY_P(object); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(intern->ar_flags & ~SPL_ARRAY_INT_MASK); } @@ -1140,7 +1134,7 @@ PHP_METHOD(ArrayObject, exchangeArray) } RETVAL_ARR(zend_array_dup(spl_array_get_hash_table(intern))); - spl_array_set_array(object, intern, array, 0L, 1); + spl_array_set_array(object, intern, array, 0L, true); } /* }}} */ @@ -1150,9 +1144,7 @@ PHP_METHOD(ArrayObject, getIterator) zval *object = ZEND_THIS; spl_array_object *intern = Z_SPLARRAY_P(object); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_OBJ(spl_array_object_new_ex(intern->ce_get_iterator, Z_OBJ_P(object), 0)); } @@ -1203,9 +1195,7 @@ PHP_METHOD(ArrayObject, count) { spl_array_object *intern = Z_SPLARRAY_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(spl_array_object_count_elements_helper(intern)); } /* }}} */ @@ -1305,9 +1295,7 @@ PHP_METHOD(ArrayObject, serialize) php_serialize_data_t var_hash; smart_str buf = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHP_VAR_SERIALIZE_INIT(var_hash); @@ -1413,7 +1401,7 @@ PHP_METHOD(ArrayObject, unserialize) ZVAL_NULL(array); SEPARATE_ARRAY(&intern->array); } else { - spl_array_set_array(object, intern, array, 0L, 1); + spl_array_set_array(object, intern, array, 0L, true); } if (*p != ';') { @@ -1453,9 +1441,7 @@ PHP_METHOD(ArrayObject, __serialize) spl_array_object *intern = Z_SPLARRAY_P(ZEND_THIS); zval tmp; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); @@ -1526,7 +1512,7 @@ PHP_METHOD(ArrayObject, __unserialize) zend_throw_exception(spl_ce_InvalidArgumentException, "Passed variable is not an array or object", 0); RETURN_THROWS(); } - spl_array_set_array(ZEND_THIS, intern, storage_zv, 0L, 1); + spl_array_set_array(ZEND_THIS, intern, storage_zv, 0L, true); } object_properties_load(&intern->std, Z_ARRVAL_P(members_zv)); @@ -1559,9 +1545,7 @@ PHP_METHOD(ArrayObject, __unserialize) /* {{{ */ PHP_METHOD(ArrayObject, __debugInfo) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_ARR(spl_array_get_debug_info(Z_OBJ_P(ZEND_THIS))); } /* }}} */ @@ -1739,9 +1723,7 @@ PHP_METHOD(ArrayIterator, rewind) zval *object = ZEND_THIS; spl_array_object *intern = Z_SPLARRAY_P(object); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_array_rewind(intern); } @@ -1783,9 +1765,7 @@ PHP_METHOD(ArrayIterator, current) zval *entry; HashTable *aht = spl_array_get_hash_table(intern); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) { RETURN_NULL(); @@ -1812,9 +1792,7 @@ void spl_array_iterator_key(zval *object, zval *return_value) /* {{{ */ /* {{{ Return current array key */ PHP_METHOD(ArrayIterator, key) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_array_iterator_key(ZEND_THIS, return_value); } /* }}} */ @@ -1826,9 +1804,7 @@ PHP_METHOD(ArrayIterator, next) spl_array_object *intern = Z_SPLARRAY_P(object); HashTable *aht = spl_array_get_hash_table(intern); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_array_next_ex(intern, aht); } @@ -1841,9 +1817,7 @@ PHP_METHOD(ArrayIterator, valid) spl_array_object *intern = Z_SPLARRAY_P(object); HashTable *aht = spl_array_get_hash_table(intern); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_BOOL(zend_hash_has_more_elements_ex(aht, spl_array_get_pos_ptr(aht, intern)) == SUCCESS); } @@ -1858,9 +1832,7 @@ PHP_METHOD(RecursiveArrayIterator, hasChildren) spl_array_object *intern = Z_SPLARRAY_P(object); HashTable *aht = spl_array_get_hash_table(intern); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) { RETURN_FALSE; @@ -1898,9 +1870,7 @@ PHP_METHOD(RecursiveArrayIterator, getChildren) spl_array_object *intern = Z_SPLARRAY_P(object); HashTable *aht = spl_array_get_hash_table(intern); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) { RETURN_NULL(); diff --git a/ext/spl/spl_array_arginfo.h b/ext/spl/spl_array_arginfo.h index 24dcadac661c8..da3b7ddb8c909 100644 --- a/ext/spl/spl_array_arginfo.h +++ b/ext/spl/spl_array_arginfo.h @@ -264,15 +264,15 @@ static zend_class_entry *register_class_ArrayObject(zend_class_entry *class_entr zval const_STD_PROP_LIST_value; ZVAL_LONG(&const_STD_PROP_LIST_value, SPL_ARRAY_STD_PROP_LIST); - zend_string *const_STD_PROP_LIST_name = zend_string_init_interned("STD_PROP_LIST", sizeof("STD_PROP_LIST") - 1, 1); + zend_string *const_STD_PROP_LIST_name = zend_string_init_interned("STD_PROP_LIST", sizeof("STD_PROP_LIST") - 1, true); zend_declare_typed_class_constant(class_entry, const_STD_PROP_LIST_name, &const_STD_PROP_LIST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_STD_PROP_LIST_name); + zend_string_release_ex(const_STD_PROP_LIST_name, true); zval const_ARRAY_AS_PROPS_value; ZVAL_LONG(&const_ARRAY_AS_PROPS_value, SPL_ARRAY_ARRAY_AS_PROPS); - zend_string *const_ARRAY_AS_PROPS_name = zend_string_init_interned("ARRAY_AS_PROPS", sizeof("ARRAY_AS_PROPS") - 1, 1); + zend_string *const_ARRAY_AS_PROPS_name = zend_string_init_interned("ARRAY_AS_PROPS", sizeof("ARRAY_AS_PROPS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ARRAY_AS_PROPS_name, &const_ARRAY_AS_PROPS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ARRAY_AS_PROPS_name); + zend_string_release_ex(const_ARRAY_AS_PROPS_name, true); return class_entry; } @@ -287,15 +287,15 @@ static zend_class_entry *register_class_ArrayIterator(zend_class_entry *class_en zval const_STD_PROP_LIST_value; ZVAL_LONG(&const_STD_PROP_LIST_value, SPL_ARRAY_STD_PROP_LIST); - zend_string *const_STD_PROP_LIST_name = zend_string_init_interned("STD_PROP_LIST", sizeof("STD_PROP_LIST") - 1, 1); + zend_string *const_STD_PROP_LIST_name = zend_string_init_interned("STD_PROP_LIST", sizeof("STD_PROP_LIST") - 1, true); zend_declare_typed_class_constant(class_entry, const_STD_PROP_LIST_name, &const_STD_PROP_LIST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_STD_PROP_LIST_name); + zend_string_release_ex(const_STD_PROP_LIST_name, true); zval const_ARRAY_AS_PROPS_value; ZVAL_LONG(&const_ARRAY_AS_PROPS_value, SPL_ARRAY_ARRAY_AS_PROPS); - zend_string *const_ARRAY_AS_PROPS_name = zend_string_init_interned("ARRAY_AS_PROPS", sizeof("ARRAY_AS_PROPS") - 1, 1); + zend_string *const_ARRAY_AS_PROPS_name = zend_string_init_interned("ARRAY_AS_PROPS", sizeof("ARRAY_AS_PROPS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ARRAY_AS_PROPS_name, &const_ARRAY_AS_PROPS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ARRAY_AS_PROPS_name); + zend_string_release_ex(const_ARRAY_AS_PROPS_name, true); return class_entry; } @@ -310,9 +310,9 @@ static zend_class_entry *register_class_RecursiveArrayIterator(zend_class_entry zval const_CHILD_ARRAYS_ONLY_value; ZVAL_LONG(&const_CHILD_ARRAYS_ONLY_value, SPL_ARRAY_CHILD_ARRAYS_ONLY); - zend_string *const_CHILD_ARRAYS_ONLY_name = zend_string_init_interned("CHILD_ARRAYS_ONLY", sizeof("CHILD_ARRAYS_ONLY") - 1, 1); + zend_string *const_CHILD_ARRAYS_ONLY_name = zend_string_init_interned("CHILD_ARRAYS_ONLY", sizeof("CHILD_ARRAYS_ONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHILD_ARRAYS_ONLY_name, &const_CHILD_ARRAYS_ONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHILD_ARRAYS_ONLY_name); + zend_string_release_ex(const_CHILD_ARRAYS_ONLY_name, true); return class_entry; } diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 049d850d12fc7..86e4b11334c81 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -292,6 +292,11 @@ static void spl_filesystem_dir_open(spl_filesystem_object* intern, zend_string * intern->type = SPL_FS_DIR; intern->u.dir.dirp = php_stream_opendir(ZSTR_VAL(path), REPORT_ERRORS, FG(default_context)); + if (intern->u.dir.dirp) { + /* we prevent potential UAF with conflicting explicit fclose(), relying on the object destructor for this */ + intern->u.dir.dirp->flags |= PHP_STREAM_FLAG_NO_FCLOSE; + } + if (ZSTR_LEN(path) > 1 && IS_SLASH_AT(ZSTR_VAL(path), ZSTR_LEN(path)-1)) { intern->path = zend_string_init(ZSTR_VAL(path), ZSTR_LEN(path)-1, 0); } else { @@ -409,7 +414,7 @@ static zend_object *spl_filesystem_object_clone(zend_object *old_object) spl_filesystem_dir_open(intern, source->path); /* read until we hit the position in which we were before */ bool skip_dots = SPL_HAS_FLAG(source->flags, SPL_FILE_DIR_SKIPDOTS); - int index; + zend_long index; for (index = 0; index < source->u.dir.index; ++index) { do { spl_filesystem_dir_read(intern); @@ -480,9 +485,8 @@ static spl_filesystem_object *spl_filesystem_object_create_info(zend_string *fil RETVAL_OBJ(&intern->std); if (ce->constructor->common.scope != spl_ce_SplFileInfo) { - ZVAL_STR_COPY(&arg1, file_path); + ZVAL_STR(&arg1, file_path); zend_call_method_with_1_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1); - zval_ptr_dtor(&arg1); } else { spl_filesystem_info_set_filename(intern, file_path); } @@ -493,7 +497,7 @@ static spl_filesystem_object *spl_filesystem_object_create_info(zend_string *fil static spl_filesystem_object *spl_filesystem_object_create_type(int num_args, spl_filesystem_object *source, int type, zend_class_entry *ce, zval *return_value) /* {{{ */ { spl_filesystem_object *intern; - bool use_include_path = 0; + bool use_include_path = false; zval arg1, arg2; zend_error_handling error_handling; @@ -520,9 +524,8 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int num_args, sp } if (ce->constructor->common.scope != spl_ce_SplFileInfo) { - ZVAL_STR_COPY(&arg1, source->file_name); + ZVAL_STR(&arg1, source->file_name); zend_call_method_with_1_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1); - zval_ptr_dtor(&arg1); } else { intern->file_name = zend_string_copy(source->file_name); intern->path = spl_filesystem_object_get_path(source); @@ -549,11 +552,9 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int num_args, sp } if (ce->constructor->common.scope != spl_ce_SplFileObject) { - ZVAL_STR_COPY(&arg1, source->file_name); - ZVAL_STR_COPY(&arg2, open_mode); + ZVAL_STR(&arg1, source->file_name); + ZVAL_STR(&arg2, open_mode); zend_call_method_with_2_params(Z_OBJ_P(return_value), ce, &ce->constructor, "__construct", NULL, &arg1, &arg2); - zval_ptr_dtor(&arg1); - zval_ptr_dtor(&arg2); } else { intern->file_name = source->file_name; intern->path = spl_filesystem_object_get_path(source); @@ -737,9 +738,7 @@ PHP_METHOD(DirectoryIterator, rewind) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern); intern->u.dir.index = 0; @@ -753,9 +752,7 @@ PHP_METHOD(DirectoryIterator, key) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern); RETURN_LONG(intern->u.dir.index); @@ -765,9 +762,7 @@ PHP_METHOD(DirectoryIterator, key) /* {{{ Return this (needed for Iterator interface) */ PHP_METHOD(DirectoryIterator, current) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS))); RETURN_OBJ_COPY(Z_OBJ_P(ZEND_THIS)); @@ -780,9 +775,7 @@ PHP_METHOD(DirectoryIterator, next) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); bool skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern); intern->u.dir.index++; @@ -831,9 +824,7 @@ PHP_METHOD(DirectoryIterator, valid) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern); RETURN_BOOL(intern->u.dir.entry.d_name[0] != '\0'); @@ -846,9 +837,7 @@ PHP_METHOD(SplFileInfo, getPath) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); zend_string *path; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); path = spl_filesystem_object_get_path(intern); if (path) { @@ -865,9 +854,7 @@ PHP_METHOD(SplFileInfo, getFilename) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); zend_string *path; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (!intern->file_name) { zend_throw_error(NULL, "Object not initialized"); @@ -894,9 +881,7 @@ PHP_METHOD(DirectoryIterator, getFilename) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern); RETURN_STRING(intern->u.dir.entry.d_name); @@ -914,9 +899,7 @@ PHP_METHOD(SplFileInfo, getExtension) size_t idx; zend_string *ret; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (!intern->file_name) { zend_throw_error(NULL, "Object not initialized"); @@ -959,9 +942,7 @@ PHP_METHOD(DirectoryIterator, getExtension) size_t idx; zend_string *fname; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern); fname = php_basename(intern->u.dir.entry.d_name, strlen(intern->u.dir.entry.d_name), NULL, 0); @@ -1039,9 +1020,7 @@ PHP_METHOD(SplFileInfo, getPathname) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); zend_string *path; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); path = spl_filesystem_object_get_pathname(intern); if (path) { RETURN_STR_COPY(path); @@ -1056,9 +1035,7 @@ PHP_METHOD(FilesystemIterator, key) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (SPL_FILE_DIR_KEY(intern, SPL_FILE_DIR_KEY_AS_FILENAME)) { RETURN_STRING(intern->u.dir.entry.d_name); @@ -1076,9 +1053,7 @@ PHP_METHOD(FilesystemIterator, current) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (SPL_FILE_DIR_CURRENT(intern, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) { if (spl_filesystem_object_get_file_name(intern) == FAILURE) { @@ -1101,9 +1076,7 @@ PHP_METHOD(DirectoryIterator, isDot) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_DIRECTORY_ITERATOR_IS_INITIALIZED(intern); RETURN_BOOL(spl_filesystem_is_dot(intern->u.dir.entry.d_name)); @@ -1137,9 +1110,7 @@ PHP_METHOD(SplFileInfo, func_name) \ { \ spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); \ zend_error_handling error_handling; \ - if (zend_parse_parameters_none() == FAILURE) { \ - RETURN_THROWS(); \ - } \ + ZEND_PARSE_PARAMETERS_NONE(); \ if (spl_filesystem_object_get_file_name(intern) == FAILURE) { \ RETURN_THROWS(); \ } \ @@ -1216,9 +1187,7 @@ PHP_METHOD(SplFileInfo, getLinkTarget) ssize_t ret; char buff[MAXPATHLEN]; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (intern->file_name == NULL) { if (spl_filesystem_object_get_file_name(intern) == FAILURE) { @@ -1263,9 +1232,7 @@ PHP_METHOD(SplFileInfo, getRealPath) char buff[MAXPATHLEN]; char *filename; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (intern->type == SPL_FS_DIR && !intern->file_name && intern->u.dir.entry.d_name[0]) { if (spl_filesystem_object_get_file_name(intern) == FAILURE) { @@ -1375,9 +1342,7 @@ PHP_METHOD(SplFileInfo, getPathInfo) /* {{{ */ PHP_METHOD(SplFileInfo, __debugInfo) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_ARR(spl_filesystem_object_get_debug_info(Z_OBJ_P(ZEND_THIS))); } /* }}} */ @@ -1385,9 +1350,7 @@ PHP_METHOD(SplFileInfo, __debugInfo) /* {{{ */ PHP_METHOD(SplFileInfo, _bad_state_ex) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_throw_error(NULL, "The parent constructor was not called: the object is in an invalid state"); RETURN_THROWS(); } @@ -1406,9 +1369,7 @@ PHP_METHOD(FilesystemIterator, rewind) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); bool skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern->u.dir.index = 0; if (intern->u.dir.dirp) { @@ -1425,9 +1386,7 @@ PHP_METHOD(FilesystemIterator, getFlags) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(intern->flags & (SPL_FILE_DIR_KEY_MODE_MASK | SPL_FILE_DIR_CURRENT_MODE_MASK | SPL_FILE_DIR_OTHERS_MASK)); } /* }}} */ @@ -1491,9 +1450,7 @@ PHP_METHOD(RecursiveDirectoryIterator, getChildren) spl_filesystem_object *subdir; char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (spl_filesystem_object_get_file_name(intern) == FAILURE) { RETURN_THROWS(); @@ -1534,9 +1491,7 @@ PHP_METHOD(RecursiveDirectoryIterator, getSubPath) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (intern->u.dir.sub_path) { RETURN_STR_COPY(intern->u.dir.sub_path); @@ -1552,9 +1507,7 @@ PHP_METHOD(RecursiveDirectoryIterator, getSubPathname) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (intern->u.dir.sub_path) { RETURN_NEW_STR(strpprintf(0, "%s%c%s", ZSTR_VAL(intern->u.dir.sub_path), slash, intern->u.dir.entry.d_name)); @@ -1583,9 +1536,7 @@ PHP_METHOD(GlobIterator, count) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (EXPECTED(spl_intern_is_glob(intern))) { RETURN_LONG(php_glob_stream_get_count(intern->u.dir.dirp, NULL)); @@ -2014,7 +1965,7 @@ PHP_METHOD(SplFileObject, __construct) zend_string *file_name = NULL; zend_string *open_mode = ZSTR_CHAR('r'); zval *stream_context = NULL; - bool use_include_path = 0; + bool use_include_path = false; size_t path_len; zend_error_handling error_handling; @@ -2100,9 +2051,7 @@ PHP_METHOD(SplFileObject, rewind) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_filesystem_file_rewind(ZEND_THIS, intern); } /* }}} */ @@ -2112,9 +2061,7 @@ PHP_METHOD(SplFileObject, eof) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2126,9 +2073,7 @@ PHP_METHOD(SplFileObject, valid) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) { RETURN_BOOL(intern->u.file.current_line || !Z_ISUNDEF(intern->u.file.current_zval)); @@ -2144,9 +2089,7 @@ PHP_METHOD(SplFileObject, fgets) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2161,9 +2104,7 @@ PHP_METHOD(SplFileObject, current) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2185,9 +2126,7 @@ PHP_METHOD(SplFileObject, key) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); /* Do not read the next line to support correct counting with fgetc() if (!intern->u.file.current_line) { @@ -2201,9 +2140,7 @@ PHP_METHOD(SplFileObject, next) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_filesystem_file_free_line(intern); if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) { @@ -2227,9 +2164,7 @@ PHP_METHOD(SplFileObject, getFlags) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(intern->flags & SPL_FILE_OBJECT_MASK); } /* }}} */ @@ -2258,9 +2193,7 @@ PHP_METHOD(SplFileObject, getMaxLineLen) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG((zend_long)intern->u.file.max_line_len); } /* }}} */ @@ -2268,9 +2201,7 @@ PHP_METHOD(SplFileObject, getMaxLineLen) /* {{{ Return false */ PHP_METHOD(SplFileObject, hasChildren) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_FALSE; } /* }}} */ @@ -2278,9 +2209,7 @@ PHP_METHOD(SplFileObject, hasChildren) /* {{{ Read NULL */ PHP_METHOD(SplFileObject, getChildren) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); /* return NULL */ } /* }}} */ @@ -2431,9 +2360,7 @@ PHP_METHOD(SplFileObject, getCsvControl) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); char delimiter[2], enclosure[2], escape[2]; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); @@ -2476,9 +2403,7 @@ PHP_METHOD(SplFileObject, fflush) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2491,9 +2416,7 @@ PHP_METHOD(SplFileObject, ftell) spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); zend_long ret; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2527,9 +2450,7 @@ PHP_METHOD(SplFileObject, fgetc) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2552,9 +2473,7 @@ PHP_METHOD(SplFileObject, fpassthru) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2583,7 +2502,8 @@ PHP_METHOD(SplFileObject, fscanf) int result = php_sscanf_internal(ZSTR_VAL(intern->u.file.current_line), ZSTR_VAL(format_str), (int)num_varargs, varargs, 0, return_value); if (SCAN_ERROR_WRONG_PARAM_COUNT == result) { - WRONG_PARAM_COUNT; + zend_wrong_param_count(); + RETURN_THROWS(); } } /* }}} */ @@ -2654,9 +2574,7 @@ PHP_METHOD(SplFileObject, fstat) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); @@ -2722,9 +2640,7 @@ PHP_METHOD(SplFileObject, seek) PHP_METHOD(SplFileObject, __toString) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h index 549dfb1dc4d0f..a2d1d8d854750 100644 --- a/ext/spl/spl_directory.h +++ b/ext/spl/spl_directory.h @@ -62,7 +62,7 @@ struct _spl_filesystem_object { struct { php_stream *dirp; zend_string *sub_path; - int index; + zend_long index; zend_function *func_rewind; zend_function *func_next; zend_function *func_valid; diff --git a/ext/spl/spl_directory_arginfo.h b/ext/spl/spl_directory_arginfo.h index 434abefef4c68..3b37c1ed6fd0e 100644 --- a/ext/spl/spl_directory_arginfo.h +++ b/ext/spl/spl_directory_arginfo.h @@ -508,75 +508,75 @@ static zend_class_entry *register_class_FilesystemIterator(zend_class_entry *cla zval const_CURRENT_MODE_MASK_value; ZVAL_LONG(&const_CURRENT_MODE_MASK_value, SPL_FILE_DIR_CURRENT_MODE_MASK); - zend_string *const_CURRENT_MODE_MASK_name = zend_string_init_interned("CURRENT_MODE_MASK", sizeof("CURRENT_MODE_MASK") - 1, 1); + zend_string *const_CURRENT_MODE_MASK_name = zend_string_init_interned("CURRENT_MODE_MASK", sizeof("CURRENT_MODE_MASK") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENT_MODE_MASK_name, &const_CURRENT_MODE_MASK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENT_MODE_MASK_name); + zend_string_release_ex(const_CURRENT_MODE_MASK_name, true); zval const_CURRENT_AS_PATHNAME_value; ZVAL_LONG(&const_CURRENT_AS_PATHNAME_value, SPL_FILE_DIR_CURRENT_AS_PATHNAME); - zend_string *const_CURRENT_AS_PATHNAME_name = zend_string_init_interned("CURRENT_AS_PATHNAME", sizeof("CURRENT_AS_PATHNAME") - 1, 1); + zend_string *const_CURRENT_AS_PATHNAME_name = zend_string_init_interned("CURRENT_AS_PATHNAME", sizeof("CURRENT_AS_PATHNAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENT_AS_PATHNAME_name, &const_CURRENT_AS_PATHNAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENT_AS_PATHNAME_name); + zend_string_release_ex(const_CURRENT_AS_PATHNAME_name, true); zval const_CURRENT_AS_FILEINFO_value; ZVAL_LONG(&const_CURRENT_AS_FILEINFO_value, SPL_FILE_DIR_CURRENT_AS_FILEINFO); - zend_string *const_CURRENT_AS_FILEINFO_name = zend_string_init_interned("CURRENT_AS_FILEINFO", sizeof("CURRENT_AS_FILEINFO") - 1, 1); + zend_string *const_CURRENT_AS_FILEINFO_name = zend_string_init_interned("CURRENT_AS_FILEINFO", sizeof("CURRENT_AS_FILEINFO") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENT_AS_FILEINFO_name, &const_CURRENT_AS_FILEINFO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENT_AS_FILEINFO_name); + zend_string_release_ex(const_CURRENT_AS_FILEINFO_name, true); zval const_CURRENT_AS_SELF_value; ZVAL_LONG(&const_CURRENT_AS_SELF_value, SPL_FILE_DIR_CURRENT_AS_SELF); - zend_string *const_CURRENT_AS_SELF_name = zend_string_init_interned("CURRENT_AS_SELF", sizeof("CURRENT_AS_SELF") - 1, 1); + zend_string *const_CURRENT_AS_SELF_name = zend_string_init_interned("CURRENT_AS_SELF", sizeof("CURRENT_AS_SELF") - 1, true); zend_declare_typed_class_constant(class_entry, const_CURRENT_AS_SELF_name, &const_CURRENT_AS_SELF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CURRENT_AS_SELF_name); + zend_string_release_ex(const_CURRENT_AS_SELF_name, true); zval const_KEY_MODE_MASK_value; ZVAL_LONG(&const_KEY_MODE_MASK_value, SPL_FILE_DIR_KEY_MODE_MASK); - zend_string *const_KEY_MODE_MASK_name = zend_string_init_interned("KEY_MODE_MASK", sizeof("KEY_MODE_MASK") - 1, 1); + zend_string *const_KEY_MODE_MASK_name = zend_string_init_interned("KEY_MODE_MASK", sizeof("KEY_MODE_MASK") - 1, true); zend_declare_typed_class_constant(class_entry, const_KEY_MODE_MASK_name, &const_KEY_MODE_MASK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_KEY_MODE_MASK_name); + zend_string_release_ex(const_KEY_MODE_MASK_name, true); zval const_KEY_AS_PATHNAME_value; ZVAL_LONG(&const_KEY_AS_PATHNAME_value, SPL_FILE_DIR_KEY_AS_PATHNAME); - zend_string *const_KEY_AS_PATHNAME_name = zend_string_init_interned("KEY_AS_PATHNAME", sizeof("KEY_AS_PATHNAME") - 1, 1); + zend_string *const_KEY_AS_PATHNAME_name = zend_string_init_interned("KEY_AS_PATHNAME", sizeof("KEY_AS_PATHNAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_KEY_AS_PATHNAME_name, &const_KEY_AS_PATHNAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_KEY_AS_PATHNAME_name); + zend_string_release_ex(const_KEY_AS_PATHNAME_name, true); zval const_FOLLOW_SYMLINKS_value; ZVAL_LONG(&const_FOLLOW_SYMLINKS_value, SPL_FILE_DIR_FOLLOW_SYMLINKS); - zend_string *const_FOLLOW_SYMLINKS_name = zend_string_init_interned("FOLLOW_SYMLINKS", sizeof("FOLLOW_SYMLINKS") - 1, 1); + zend_string *const_FOLLOW_SYMLINKS_name = zend_string_init_interned("FOLLOW_SYMLINKS", sizeof("FOLLOW_SYMLINKS") - 1, true); zend_declare_typed_class_constant(class_entry, const_FOLLOW_SYMLINKS_name, &const_FOLLOW_SYMLINKS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FOLLOW_SYMLINKS_name); + zend_string_release_ex(const_FOLLOW_SYMLINKS_name, true); zval const_KEY_AS_FILENAME_value; ZVAL_LONG(&const_KEY_AS_FILENAME_value, SPL_FILE_DIR_KEY_AS_FILENAME); - zend_string *const_KEY_AS_FILENAME_name = zend_string_init_interned("KEY_AS_FILENAME", sizeof("KEY_AS_FILENAME") - 1, 1); + zend_string *const_KEY_AS_FILENAME_name = zend_string_init_interned("KEY_AS_FILENAME", sizeof("KEY_AS_FILENAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_KEY_AS_FILENAME_name, &const_KEY_AS_FILENAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_KEY_AS_FILENAME_name); + zend_string_release_ex(const_KEY_AS_FILENAME_name, true); zval const_NEW_CURRENT_AND_KEY_value; ZVAL_LONG(&const_NEW_CURRENT_AND_KEY_value, SPL_FILE_NEW_CURRENT_AND_KEY); - zend_string *const_NEW_CURRENT_AND_KEY_name = zend_string_init_interned("NEW_CURRENT_AND_KEY", sizeof("NEW_CURRENT_AND_KEY") - 1, 1); + zend_string *const_NEW_CURRENT_AND_KEY_name = zend_string_init_interned("NEW_CURRENT_AND_KEY", sizeof("NEW_CURRENT_AND_KEY") - 1, true); zend_declare_typed_class_constant(class_entry, const_NEW_CURRENT_AND_KEY_name, &const_NEW_CURRENT_AND_KEY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NEW_CURRENT_AND_KEY_name); + zend_string_release_ex(const_NEW_CURRENT_AND_KEY_name, true); zval const_OTHER_MODE_MASK_value; ZVAL_LONG(&const_OTHER_MODE_MASK_value, SPL_FILE_DIR_OTHERS_MASK); - zend_string *const_OTHER_MODE_MASK_name = zend_string_init_interned("OTHER_MODE_MASK", sizeof("OTHER_MODE_MASK") - 1, 1); + zend_string *const_OTHER_MODE_MASK_name = zend_string_init_interned("OTHER_MODE_MASK", sizeof("OTHER_MODE_MASK") - 1, true); zend_declare_typed_class_constant(class_entry, const_OTHER_MODE_MASK_name, &const_OTHER_MODE_MASK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OTHER_MODE_MASK_name); + zend_string_release_ex(const_OTHER_MODE_MASK_name, true); zval const_SKIP_DOTS_value; ZVAL_LONG(&const_SKIP_DOTS_value, SPL_FILE_DIR_SKIPDOTS); - zend_string *const_SKIP_DOTS_name = zend_string_init_interned("SKIP_DOTS", sizeof("SKIP_DOTS") - 1, 1); + zend_string *const_SKIP_DOTS_name = zend_string_init_interned("SKIP_DOTS", sizeof("SKIP_DOTS") - 1, true); zend_declare_typed_class_constant(class_entry, const_SKIP_DOTS_name, &const_SKIP_DOTS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SKIP_DOTS_name); + zend_string_release_ex(const_SKIP_DOTS_name, true); zval const_UNIX_PATHS_value; ZVAL_LONG(&const_UNIX_PATHS_value, SPL_FILE_DIR_UNIXPATHS); - zend_string *const_UNIX_PATHS_name = zend_string_init_interned("UNIX_PATHS", sizeof("UNIX_PATHS") - 1, 1); + zend_string *const_UNIX_PATHS_name = zend_string_init_interned("UNIX_PATHS", sizeof("UNIX_PATHS") - 1, true); zend_declare_typed_class_constant(class_entry, const_UNIX_PATHS_name, &const_UNIX_PATHS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UNIX_PATHS_name); + zend_string_release_ex(const_UNIX_PATHS_name, true); return class_entry; } @@ -613,27 +613,27 @@ static zend_class_entry *register_class_SplFileObject(zend_class_entry *class_en zval const_DROP_NEW_LINE_value; ZVAL_LONG(&const_DROP_NEW_LINE_value, SPL_FILE_OBJECT_DROP_NEW_LINE); - zend_string *const_DROP_NEW_LINE_name = zend_string_init_interned("DROP_NEW_LINE", sizeof("DROP_NEW_LINE") - 1, 1); + zend_string *const_DROP_NEW_LINE_name = zend_string_init_interned("DROP_NEW_LINE", sizeof("DROP_NEW_LINE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_NEW_LINE_name, &const_DROP_NEW_LINE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_NEW_LINE_name); + zend_string_release_ex(const_DROP_NEW_LINE_name, true); zval const_READ_AHEAD_value; ZVAL_LONG(&const_READ_AHEAD_value, SPL_FILE_OBJECT_READ_AHEAD); - zend_string *const_READ_AHEAD_name = zend_string_init_interned("READ_AHEAD", sizeof("READ_AHEAD") - 1, 1); + zend_string *const_READ_AHEAD_name = zend_string_init_interned("READ_AHEAD", sizeof("READ_AHEAD") - 1, true); zend_declare_typed_class_constant(class_entry, const_READ_AHEAD_name, &const_READ_AHEAD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_READ_AHEAD_name); + zend_string_release_ex(const_READ_AHEAD_name, true); zval const_SKIP_EMPTY_value; ZVAL_LONG(&const_SKIP_EMPTY_value, SPL_FILE_OBJECT_SKIP_EMPTY); - zend_string *const_SKIP_EMPTY_name = zend_string_init_interned("SKIP_EMPTY", sizeof("SKIP_EMPTY") - 1, 1); + zend_string *const_SKIP_EMPTY_name = zend_string_init_interned("SKIP_EMPTY", sizeof("SKIP_EMPTY") - 1, true); zend_declare_typed_class_constant(class_entry, const_SKIP_EMPTY_name, &const_SKIP_EMPTY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SKIP_EMPTY_name); + zend_string_release_ex(const_SKIP_EMPTY_name, true); zval const_READ_CSV_value; ZVAL_LONG(&const_READ_CSV_value, SPL_FILE_OBJECT_READ_CSV); - zend_string *const_READ_CSV_name = zend_string_init_interned("READ_CSV", sizeof("READ_CSV") - 1, 1); + zend_string *const_READ_CSV_name = zend_string_init_interned("READ_CSV", sizeof("READ_CSV") - 1, true); zend_declare_typed_class_constant(class_entry, const_READ_CSV_name, &const_READ_CSV_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_READ_CSV_name); + zend_string_release_ex(const_READ_CSV_name, true); return class_entry; } diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 0f525e627d305..867f492fab16d 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -511,9 +511,7 @@ PHP_METHOD(SplDoublyLinkedList, pop) { spl_dllist_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLDLLIST_P(ZEND_THIS); spl_ptr_llist_pop(intern->llist, return_value); @@ -530,9 +528,7 @@ PHP_METHOD(SplDoublyLinkedList, shift) { spl_dllist_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLDLLIST_P(ZEND_THIS); spl_ptr_llist_shift(intern->llist, return_value); @@ -550,9 +546,7 @@ PHP_METHOD(SplDoublyLinkedList, top) zval *value; spl_dllist_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLDLLIST_P(ZEND_THIS); value = spl_ptr_llist_last(intern->llist); @@ -572,9 +566,7 @@ PHP_METHOD(SplDoublyLinkedList, bottom) zval *value; spl_dllist_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLDLLIST_P(ZEND_THIS); value = spl_ptr_llist_first(intern->llist); @@ -594,9 +586,7 @@ PHP_METHOD(SplDoublyLinkedList, count) zend_long count; spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); count = spl_ptr_llist_count(intern->llist); RETURN_LONG(count); @@ -608,9 +598,7 @@ PHP_METHOD(SplDoublyLinkedList, isEmpty) { zend_long count; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_dllist_object_count_elements(Z_OBJ_P(ZEND_THIS), &count); RETURN_BOOL(count == 0); @@ -646,9 +634,7 @@ PHP_METHOD(SplDoublyLinkedList, getIteratorMode) { spl_dllist_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLDLLIST_P(ZEND_THIS); @@ -702,7 +688,7 @@ PHP_METHOD(SplDoublyLinkedList, offsetGet) PHP_METHOD(SplDoublyLinkedList, offsetSet) { zend_long index; - bool index_is_null = 1; + bool index_is_null = true; zval *value; spl_dllist_object *intern; @@ -914,9 +900,7 @@ PHP_METHOD(SplDoublyLinkedList, key) { spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(intern->traverse_position); } @@ -927,9 +911,7 @@ PHP_METHOD(SplDoublyLinkedList, prev) { spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_dllist_it_helper_move_forward(&intern->traverse_pointer, &intern->traverse_position, intern->llist, intern->flags ^ SPL_DLLIST_IT_LIFO); } @@ -940,9 +922,7 @@ PHP_METHOD(SplDoublyLinkedList, next) { spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_dllist_it_helper_move_forward(&intern->traverse_pointer, &intern->traverse_position, intern->llist, intern->flags); } @@ -953,9 +933,7 @@ PHP_METHOD(SplDoublyLinkedList, valid) { spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_BOOL(intern->traverse_pointer != NULL); } @@ -966,9 +944,7 @@ PHP_METHOD(SplDoublyLinkedList, rewind) { spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_dllist_it_helper_rewind(&intern->traverse_pointer, &intern->traverse_position, intern->llist, intern->flags); } @@ -980,9 +956,7 @@ PHP_METHOD(SplDoublyLinkedList, current) spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS); spl_ptr_llist_element *element = intern->traverse_pointer; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (element == NULL || Z_ISUNDEF(element->data)) { RETURN_NULL(); @@ -1001,9 +975,7 @@ PHP_METHOD(SplDoublyLinkedList, serialize) zval flags; php_serialize_data_t var_hash; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHP_VAR_SERIALIZE_INIT(var_hash); @@ -1099,9 +1071,7 @@ PHP_METHOD(SplDoublyLinkedList, __serialize) spl_ptr_llist_element *current = intern->llist->head; zval tmp; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); @@ -1205,9 +1175,7 @@ PHP_METHOD(SplDoublyLinkedList, add) /* {{{ */ PHP_METHOD(SplDoublyLinkedList, __debugInfo) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_ARR(spl_dllist_object_get_debug_info(Z_OBJ_P(ZEND_THIS))); } /* }}} */ diff --git a/ext/spl/spl_dllist_arginfo.h b/ext/spl/spl_dllist_arginfo.h index a5b1510655138..e6ceb3dca42de 100644 --- a/ext/spl/spl_dllist_arginfo.h +++ b/ext/spl/spl_dllist_arginfo.h @@ -156,27 +156,27 @@ static zend_class_entry *register_class_SplDoublyLinkedList(zend_class_entry *cl zval const_IT_MODE_LIFO_value; ZVAL_LONG(&const_IT_MODE_LIFO_value, SPL_DLLIST_IT_LIFO); - zend_string *const_IT_MODE_LIFO_name = zend_string_init_interned("IT_MODE_LIFO", sizeof("IT_MODE_LIFO") - 1, 1); + zend_string *const_IT_MODE_LIFO_name = zend_string_init_interned("IT_MODE_LIFO", sizeof("IT_MODE_LIFO") - 1, true); zend_declare_typed_class_constant(class_entry, const_IT_MODE_LIFO_name, &const_IT_MODE_LIFO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IT_MODE_LIFO_name); + zend_string_release_ex(const_IT_MODE_LIFO_name, true); zval const_IT_MODE_FIFO_value; ZVAL_LONG(&const_IT_MODE_FIFO_value, SPL_DLLIST_IT_FIFO); - zend_string *const_IT_MODE_FIFO_name = zend_string_init_interned("IT_MODE_FIFO", sizeof("IT_MODE_FIFO") - 1, 1); + zend_string *const_IT_MODE_FIFO_name = zend_string_init_interned("IT_MODE_FIFO", sizeof("IT_MODE_FIFO") - 1, true); zend_declare_typed_class_constant(class_entry, const_IT_MODE_FIFO_name, &const_IT_MODE_FIFO_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IT_MODE_FIFO_name); + zend_string_release_ex(const_IT_MODE_FIFO_name, true); zval const_IT_MODE_DELETE_value; ZVAL_LONG(&const_IT_MODE_DELETE_value, SPL_DLLIST_IT_DELETE); - zend_string *const_IT_MODE_DELETE_name = zend_string_init_interned("IT_MODE_DELETE", sizeof("IT_MODE_DELETE") - 1, 1); + zend_string *const_IT_MODE_DELETE_name = zend_string_init_interned("IT_MODE_DELETE", sizeof("IT_MODE_DELETE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IT_MODE_DELETE_name, &const_IT_MODE_DELETE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IT_MODE_DELETE_name); + zend_string_release_ex(const_IT_MODE_DELETE_name, true); zval const_IT_MODE_KEEP_value; ZVAL_LONG(&const_IT_MODE_KEEP_value, SPL_DLLIST_IT_KEEP); - zend_string *const_IT_MODE_KEEP_name = zend_string_init_interned("IT_MODE_KEEP", sizeof("IT_MODE_KEEP") - 1, 1); + zend_string *const_IT_MODE_KEEP_name = zend_string_init_interned("IT_MODE_KEEP", sizeof("IT_MODE_KEEP") - 1, true); zend_declare_typed_class_constant(class_entry, const_IT_MODE_KEEP_name, &const_IT_MODE_KEEP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IT_MODE_KEEP_name); + zend_string_release_ex(const_IT_MODE_KEEP_name, true); return class_entry; } diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 9e552cc83ef36..6f976923341bc 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -303,12 +303,12 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z static zend_object *spl_fixedarray_new(zend_class_entry *class_type) { - return spl_fixedarray_object_new_ex(class_type, NULL, 0); + return spl_fixedarray_object_new_ex(class_type, NULL, false); } static zend_object *spl_fixedarray_object_clone(zend_object *old_object) { - zend_object *new_object = spl_fixedarray_object_new_ex(old_object->ce, old_object, 1); + zend_object *new_object = spl_fixedarray_object_new_ex(old_object->ce, old_object, true); zend_objects_clone_members(new_object, old_object); @@ -562,9 +562,7 @@ PHP_METHOD(SplFixedArray, __wakeup) HashTable *intern_ht = zend_std_get_properties(Z_OBJ_P(ZEND_THIS)); zval *data; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (intern->array.size == 0) { int index = 0; @@ -589,9 +587,7 @@ PHP_METHOD(SplFixedArray, __serialize) zval *current; zend_string *key; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); HashTable *ht = zend_std_get_properties(&intern->std); uint32_t num_properties = zend_hash_num_elements(ht); @@ -666,9 +662,7 @@ PHP_METHOD(SplFixedArray, count) zval *object = ZEND_THIS; spl_fixedarray_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLFIXEDARRAY_P(object); RETURN_LONG(intern->array.size); @@ -678,9 +672,7 @@ PHP_METHOD(SplFixedArray, toArray) { spl_fixedarray_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLFIXEDARRAY_P(ZEND_THIS); @@ -706,7 +698,7 @@ PHP_METHOD(SplFixedArray, fromArray) spl_fixedarray array; spl_fixedarray_object *intern; int num; - bool save_indexes = 1; + bool save_indexes = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|b", &data, &save_indexes) == FAILURE) { RETURN_THROWS(); @@ -774,9 +766,7 @@ PHP_METHOD(SplFixedArray, getSize) zval *object = ZEND_THIS; spl_fixedarray_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLFIXEDARRAY_P(object); RETURN_LONG(intern->array.size); @@ -815,7 +805,7 @@ PHP_METHOD(SplFixedArray, offsetExists) intern = Z_SPLFIXEDARRAY_P(ZEND_THIS); - RETURN_BOOL(spl_fixedarray_object_has_dimension_helper(intern, zindex, 0)); + RETURN_BOOL(spl_fixedarray_object_has_dimension_helper(intern, zindex, false)); } /* Returns the value at the specified $index. */ @@ -871,9 +861,7 @@ PHP_METHOD(SplFixedArray, offsetUnset) /* Create a new iterator from a SplFixedArray instance. */ PHP_METHOD(SplFixedArray, getIterator) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_create_internal_iterator_zval(return_value, ZEND_THIS); } diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 5d36266393b04..85fc5f8bb698b 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -575,9 +575,7 @@ PHP_METHOD(SplHeap, count) zend_long count; spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); count = spl_ptr_heap_count(intern->heap); RETURN_LONG(count); @@ -589,9 +587,7 @@ PHP_METHOD(SplHeap, isEmpty) { spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_BOOL(spl_ptr_heap_count(intern->heap) == 0); } @@ -640,9 +636,7 @@ PHP_METHOD(SplHeap, extract) { spl_heap_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLHEAP_P(ZEND_THIS); @@ -705,9 +699,7 @@ PHP_METHOD(SplPriorityQueue, extract) spl_pqueue_elem elem; spl_heap_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLHEAP_P(ZEND_THIS); @@ -731,9 +723,7 @@ PHP_METHOD(SplPriorityQueue, top) spl_heap_object *intern; spl_pqueue_elem *elem; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLHEAP_P(ZEND_THIS); @@ -780,9 +770,7 @@ PHP_METHOD(SplPriorityQueue, getExtractFlags) { spl_heap_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLHEAP_P(ZEND_THIS); @@ -795,9 +783,7 @@ PHP_METHOD(SplHeap, recoverFromCorruption) { spl_heap_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLHEAP_P(ZEND_THIS); @@ -812,9 +798,7 @@ PHP_METHOD(SplHeap, isCorrupted) { spl_heap_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLHEAP_P(ZEND_THIS); @@ -841,9 +825,7 @@ PHP_METHOD(SplHeap, top) zval *value; spl_heap_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_SPLHEAP_P(ZEND_THIS); @@ -970,9 +952,7 @@ PHP_METHOD(SplHeap, key) { spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(intern->heap->count - 1); } @@ -983,9 +963,7 @@ PHP_METHOD(SplHeap, next) { spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_ptr_heap_delete_top(intern->heap, NULL, ZEND_THIS); } @@ -996,9 +974,7 @@ PHP_METHOD(SplHeap, valid) { spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_BOOL(intern->heap->count != 0); } @@ -1007,9 +983,7 @@ PHP_METHOD(SplHeap, valid) /* {{{ Rewind the datastructure back to the start */ PHP_METHOD(SplHeap, rewind) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); /* do nothing, the iterator always points to the top element */ } /* }}} */ @@ -1019,9 +993,7 @@ PHP_METHOD(SplHeap, current) { spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (!intern->heap->count) { RETURN_NULL(); @@ -1037,9 +1009,7 @@ PHP_METHOD(SplPriorityQueue, current) { spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (!intern->heap->count) { RETURN_NULL(); @@ -1053,9 +1023,7 @@ PHP_METHOD(SplPriorityQueue, current) /* {{{ */ PHP_METHOD(SplHeap, __debugInfo) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_ARR(spl_heap_object_get_debug_info(spl_ce_SplHeap, Z_OBJ_P(ZEND_THIS))); } /* }}} */ @@ -1063,9 +1031,7 @@ PHP_METHOD(SplHeap, __debugInfo) /* {{{ */ PHP_METHOD(SplPriorityQueue, __debugInfo) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_ARR(spl_heap_object_get_debug_info(spl_ce_SplPriorityQueue, Z_OBJ_P(ZEND_THIS))); } /* }}} */ diff --git a/ext/spl/spl_heap_arginfo.h b/ext/spl/spl_heap_arginfo.h index be5318a68f8c6..8b79ee0902ddf 100644 --- a/ext/spl/spl_heap_arginfo.h +++ b/ext/spl/spl_heap_arginfo.h @@ -184,21 +184,21 @@ static zend_class_entry *register_class_SplPriorityQueue(zend_class_entry *class zval const_EXTR_BOTH_value; ZVAL_LONG(&const_EXTR_BOTH_value, SPL_PQUEUE_EXTR_BOTH); - zend_string *const_EXTR_BOTH_name = zend_string_init_interned("EXTR_BOTH", sizeof("EXTR_BOTH") - 1, 1); + zend_string *const_EXTR_BOTH_name = zend_string_init_interned("EXTR_BOTH", sizeof("EXTR_BOTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXTR_BOTH_name, &const_EXTR_BOTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXTR_BOTH_name); + zend_string_release_ex(const_EXTR_BOTH_name, true); zval const_EXTR_PRIORITY_value; ZVAL_LONG(&const_EXTR_PRIORITY_value, SPL_PQUEUE_EXTR_PRIORITY); - zend_string *const_EXTR_PRIORITY_name = zend_string_init_interned("EXTR_PRIORITY", sizeof("EXTR_PRIORITY") - 1, 1); + zend_string *const_EXTR_PRIORITY_name = zend_string_init_interned("EXTR_PRIORITY", sizeof("EXTR_PRIORITY") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXTR_PRIORITY_name, &const_EXTR_PRIORITY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXTR_PRIORITY_name); + zend_string_release_ex(const_EXTR_PRIORITY_name, true); zval const_EXTR_DATA_value; ZVAL_LONG(&const_EXTR_DATA_value, SPL_PQUEUE_EXTR_DATA); - zend_string *const_EXTR_DATA_name = zend_string_init_interned("EXTR_DATA", sizeof("EXTR_DATA") - 1, 1); + zend_string *const_EXTR_DATA_name = zend_string_init_interned("EXTR_DATA", sizeof("EXTR_DATA") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXTR_DATA_name, &const_EXTR_DATA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXTR_DATA_name); + zend_string_release_ex(const_EXTR_DATA_name, true); return class_entry; } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 1ae4dae1eaa35..a73e69519db51 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -222,7 +222,7 @@ static zend_result spl_recursive_it_valid_ex(spl_recursive_it_object *object, zv if (object->endIteration && object->in_iteration) { zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->endIteration, "endIteration", NULL); } - object->in_iteration = 0; + object->in_iteration = false; return FAILURE; } @@ -460,7 +460,7 @@ static void spl_recursive_it_rewind_ex(spl_recursive_it_object *object, zval *zt if (!EG(exception) && object->beginIteration && !object->in_iteration) { zend_call_method_with_0_params(Z_OBJ_P(zthis), object->ce, &object->beginIteration, "beginIteration", NULL); } - object->in_iteration = 1; + object->in_iteration = true; spl_recursive_it_move_forward_ex(object, zthis); } @@ -614,7 +614,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla intern->mode = mode; intern->flags = (int)flags; intern->max_depth = -1; - intern->in_iteration = 0; + intern->in_iteration = false; intern->ce = Z_OBJCE_P(object); intern->beginIteration = zend_hash_str_find_ptr(&intern->ce->function_table, "beginiteration", sizeof("beginiteration") - 1); @@ -740,7 +740,7 @@ PHP_METHOD(RecursiveIteratorIterator, getSubIterator) { spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS); zend_long level; - bool level_is_null = 1; + bool level_is_null = true; zval *value; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &level, &level_is_null) == FAILURE) { diff --git a/ext/spl/spl_iterators_arginfo.h b/ext/spl/spl_iterators_arginfo.h index 439236643471e..ebd57693632d9 100644 --- a/ext/spl/spl_iterators_arginfo.h +++ b/ext/spl/spl_iterators_arginfo.h @@ -653,27 +653,27 @@ static zend_class_entry *register_class_RecursiveIteratorIterator(zend_class_ent zval const_LEAVES_ONLY_value; ZVAL_LONG(&const_LEAVES_ONLY_value, RIT_LEAVES_ONLY); - zend_string *const_LEAVES_ONLY_name = zend_string_init_interned("LEAVES_ONLY", sizeof("LEAVES_ONLY") - 1, 1); + zend_string *const_LEAVES_ONLY_name = zend_string_init_interned("LEAVES_ONLY", sizeof("LEAVES_ONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_LEAVES_ONLY_name, &const_LEAVES_ONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LEAVES_ONLY_name); + zend_string_release_ex(const_LEAVES_ONLY_name, true); zval const_SELF_FIRST_value; ZVAL_LONG(&const_SELF_FIRST_value, RIT_SELF_FIRST); - zend_string *const_SELF_FIRST_name = zend_string_init_interned("SELF_FIRST", sizeof("SELF_FIRST") - 1, 1); + zend_string *const_SELF_FIRST_name = zend_string_init_interned("SELF_FIRST", sizeof("SELF_FIRST") - 1, true); zend_declare_typed_class_constant(class_entry, const_SELF_FIRST_name, &const_SELF_FIRST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SELF_FIRST_name); + zend_string_release_ex(const_SELF_FIRST_name, true); zval const_CHILD_FIRST_value; ZVAL_LONG(&const_CHILD_FIRST_value, RIT_CHILD_FIRST); - zend_string *const_CHILD_FIRST_name = zend_string_init_interned("CHILD_FIRST", sizeof("CHILD_FIRST") - 1, 1); + zend_string *const_CHILD_FIRST_name = zend_string_init_interned("CHILD_FIRST", sizeof("CHILD_FIRST") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHILD_FIRST_name, &const_CHILD_FIRST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHILD_FIRST_name); + zend_string_release_ex(const_CHILD_FIRST_name, true); zval const_CATCH_GET_CHILD_value; ZVAL_LONG(&const_CATCH_GET_CHILD_value, RIT_CATCH_GET_CHILD); - zend_string *const_CATCH_GET_CHILD_name = zend_string_init_interned("CATCH_GET_CHILD", sizeof("CATCH_GET_CHILD") - 1, 1); + zend_string *const_CATCH_GET_CHILD_name = zend_string_init_interned("CATCH_GET_CHILD", sizeof("CATCH_GET_CHILD") - 1, true); zend_declare_typed_class_constant(class_entry, const_CATCH_GET_CHILD_name, &const_CATCH_GET_CHILD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CATCH_GET_CHILD_name); + zend_string_release_ex(const_CATCH_GET_CHILD_name, true); return class_entry; } @@ -762,39 +762,39 @@ static zend_class_entry *register_class_CachingIterator(zend_class_entry *class_ zval const_CALL_TOSTRING_value; ZVAL_LONG(&const_CALL_TOSTRING_value, CIT_CALL_TOSTRING); - zend_string *const_CALL_TOSTRING_name = zend_string_init_interned("CALL_TOSTRING", sizeof("CALL_TOSTRING") - 1, 1); + zend_string *const_CALL_TOSTRING_name = zend_string_init_interned("CALL_TOSTRING", sizeof("CALL_TOSTRING") - 1, true); zend_declare_typed_class_constant(class_entry, const_CALL_TOSTRING_name, &const_CALL_TOSTRING_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CALL_TOSTRING_name); + zend_string_release_ex(const_CALL_TOSTRING_name, true); zval const_CATCH_GET_CHILD_value; ZVAL_LONG(&const_CATCH_GET_CHILD_value, CIT_CATCH_GET_CHILD); - zend_string *const_CATCH_GET_CHILD_name = zend_string_init_interned("CATCH_GET_CHILD", sizeof("CATCH_GET_CHILD") - 1, 1); + zend_string *const_CATCH_GET_CHILD_name = zend_string_init_interned("CATCH_GET_CHILD", sizeof("CATCH_GET_CHILD") - 1, true); zend_declare_typed_class_constant(class_entry, const_CATCH_GET_CHILD_name, &const_CATCH_GET_CHILD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CATCH_GET_CHILD_name); + zend_string_release_ex(const_CATCH_GET_CHILD_name, true); zval const_TOSTRING_USE_KEY_value; ZVAL_LONG(&const_TOSTRING_USE_KEY_value, CIT_TOSTRING_USE_KEY); - zend_string *const_TOSTRING_USE_KEY_name = zend_string_init_interned("TOSTRING_USE_KEY", sizeof("TOSTRING_USE_KEY") - 1, 1); + zend_string *const_TOSTRING_USE_KEY_name = zend_string_init_interned("TOSTRING_USE_KEY", sizeof("TOSTRING_USE_KEY") - 1, true); zend_declare_typed_class_constant(class_entry, const_TOSTRING_USE_KEY_name, &const_TOSTRING_USE_KEY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TOSTRING_USE_KEY_name); + zend_string_release_ex(const_TOSTRING_USE_KEY_name, true); zval const_TOSTRING_USE_CURRENT_value; ZVAL_LONG(&const_TOSTRING_USE_CURRENT_value, CIT_TOSTRING_USE_CURRENT); - zend_string *const_TOSTRING_USE_CURRENT_name = zend_string_init_interned("TOSTRING_USE_CURRENT", sizeof("TOSTRING_USE_CURRENT") - 1, 1); + zend_string *const_TOSTRING_USE_CURRENT_name = zend_string_init_interned("TOSTRING_USE_CURRENT", sizeof("TOSTRING_USE_CURRENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_TOSTRING_USE_CURRENT_name, &const_TOSTRING_USE_CURRENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TOSTRING_USE_CURRENT_name); + zend_string_release_ex(const_TOSTRING_USE_CURRENT_name, true); zval const_TOSTRING_USE_INNER_value; ZVAL_LONG(&const_TOSTRING_USE_INNER_value, CIT_TOSTRING_USE_INNER); - zend_string *const_TOSTRING_USE_INNER_name = zend_string_init_interned("TOSTRING_USE_INNER", sizeof("TOSTRING_USE_INNER") - 1, 1); + zend_string *const_TOSTRING_USE_INNER_name = zend_string_init_interned("TOSTRING_USE_INNER", sizeof("TOSTRING_USE_INNER") - 1, true); zend_declare_typed_class_constant(class_entry, const_TOSTRING_USE_INNER_name, &const_TOSTRING_USE_INNER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TOSTRING_USE_INNER_name); + zend_string_release_ex(const_TOSTRING_USE_INNER_name, true); zval const_FULL_CACHE_value; ZVAL_LONG(&const_FULL_CACHE_value, CIT_FULL_CACHE); - zend_string *const_FULL_CACHE_name = zend_string_init_interned("FULL_CACHE", sizeof("FULL_CACHE") - 1, 1); + zend_string *const_FULL_CACHE_name = zend_string_init_interned("FULL_CACHE", sizeof("FULL_CACHE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FULL_CACHE_name, &const_FULL_CACHE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FULL_CACHE_name); + zend_string_release_ex(const_FULL_CACHE_name, true); return class_entry; } @@ -849,51 +849,51 @@ static zend_class_entry *register_class_RegexIterator(zend_class_entry *class_en zval const_USE_KEY_value; ZVAL_LONG(&const_USE_KEY_value, REGIT_USE_KEY); - zend_string *const_USE_KEY_name = zend_string_init_interned("USE_KEY", sizeof("USE_KEY") - 1, 1); + zend_string *const_USE_KEY_name = zend_string_init_interned("USE_KEY", sizeof("USE_KEY") - 1, true); zend_declare_typed_class_constant(class_entry, const_USE_KEY_name, &const_USE_KEY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_USE_KEY_name); + zend_string_release_ex(const_USE_KEY_name, true); zval const_INVERT_MATCH_value; ZVAL_LONG(&const_INVERT_MATCH_value, REGIT_INVERTED); - zend_string *const_INVERT_MATCH_name = zend_string_init_interned("INVERT_MATCH", sizeof("INVERT_MATCH") - 1, 1); + zend_string *const_INVERT_MATCH_name = zend_string_init_interned("INVERT_MATCH", sizeof("INVERT_MATCH") - 1, true); zend_declare_typed_class_constant(class_entry, const_INVERT_MATCH_name, &const_INVERT_MATCH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INVERT_MATCH_name); + zend_string_release_ex(const_INVERT_MATCH_name, true); zval const_MATCH_value; ZVAL_LONG(&const_MATCH_value, REGIT_MODE_MATCH); - zend_string *const_MATCH_name = zend_string_init_interned("MATCH", sizeof("MATCH") - 1, 1); + zend_string *const_MATCH_name = zend_string_init_interned("MATCH", sizeof("MATCH") - 1, true); zend_declare_typed_class_constant(class_entry, const_MATCH_name, &const_MATCH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MATCH_name); + zend_string_release_ex(const_MATCH_name, true); zval const_GET_MATCH_value; ZVAL_LONG(&const_GET_MATCH_value, REGIT_MODE_GET_MATCH); - zend_string *const_GET_MATCH_name = zend_string_init_interned("GET_MATCH", sizeof("GET_MATCH") - 1, 1); + zend_string *const_GET_MATCH_name = zend_string_init_interned("GET_MATCH", sizeof("GET_MATCH") - 1, true); zend_declare_typed_class_constant(class_entry, const_GET_MATCH_name, &const_GET_MATCH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_GET_MATCH_name); + zend_string_release_ex(const_GET_MATCH_name, true); zval const_ALL_MATCHES_value; ZVAL_LONG(&const_ALL_MATCHES_value, REGIT_MODE_ALL_MATCHES); - zend_string *const_ALL_MATCHES_name = zend_string_init_interned("ALL_MATCHES", sizeof("ALL_MATCHES") - 1, 1); + zend_string *const_ALL_MATCHES_name = zend_string_init_interned("ALL_MATCHES", sizeof("ALL_MATCHES") - 1, true); zend_declare_typed_class_constant(class_entry, const_ALL_MATCHES_name, &const_ALL_MATCHES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ALL_MATCHES_name); + zend_string_release_ex(const_ALL_MATCHES_name, true); zval const_SPLIT_value; ZVAL_LONG(&const_SPLIT_value, REGIT_MODE_SPLIT); - zend_string *const_SPLIT_name = zend_string_init_interned("SPLIT", sizeof("SPLIT") - 1, 1); + zend_string *const_SPLIT_name = zend_string_init_interned("SPLIT", sizeof("SPLIT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SPLIT_name, &const_SPLIT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SPLIT_name); + zend_string_release_ex(const_SPLIT_name, true); zval const_REPLACE_value; ZVAL_LONG(&const_REPLACE_value, REGIT_MODE_REPLACE); - zend_string *const_REPLACE_name = zend_string_init_interned("REPLACE", sizeof("REPLACE") - 1, 1); + zend_string *const_REPLACE_name = zend_string_init_interned("REPLACE", sizeof("REPLACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_REPLACE_name, &const_REPLACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REPLACE_name); + zend_string_release_ex(const_REPLACE_name, true); zval property_replacement_default_value; ZVAL_NULL(&property_replacement_default_value); - zend_string *property_replacement_name = zend_string_init("replacement", sizeof("replacement") - 1, 1); + zend_string *property_replacement_name = zend_string_init("replacement", sizeof("replacement") - 1, true); zend_declare_typed_property(class_entry, property_replacement_name, &property_replacement_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_replacement_name); + zend_string_release_ex(property_replacement_name, true); return class_entry; } @@ -918,51 +918,51 @@ static zend_class_entry *register_class_RecursiveTreeIterator(zend_class_entry * zval const_BYPASS_CURRENT_value; ZVAL_LONG(&const_BYPASS_CURRENT_value, RTIT_BYPASS_CURRENT); - zend_string *const_BYPASS_CURRENT_name = zend_string_init_interned("BYPASS_CURRENT", sizeof("BYPASS_CURRENT") - 1, 1); + zend_string *const_BYPASS_CURRENT_name = zend_string_init_interned("BYPASS_CURRENT", sizeof("BYPASS_CURRENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_BYPASS_CURRENT_name, &const_BYPASS_CURRENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BYPASS_CURRENT_name); + zend_string_release_ex(const_BYPASS_CURRENT_name, true); zval const_BYPASS_KEY_value; ZVAL_LONG(&const_BYPASS_KEY_value, RTIT_BYPASS_KEY); - zend_string *const_BYPASS_KEY_name = zend_string_init_interned("BYPASS_KEY", sizeof("BYPASS_KEY") - 1, 1); + zend_string *const_BYPASS_KEY_name = zend_string_init_interned("BYPASS_KEY", sizeof("BYPASS_KEY") - 1, true); zend_declare_typed_class_constant(class_entry, const_BYPASS_KEY_name, &const_BYPASS_KEY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_BYPASS_KEY_name); + zend_string_release_ex(const_BYPASS_KEY_name, true); zval const_PREFIX_LEFT_value; ZVAL_LONG(&const_PREFIX_LEFT_value, 0); - zend_string *const_PREFIX_LEFT_name = zend_string_init_interned("PREFIX_LEFT", sizeof("PREFIX_LEFT") - 1, 1); + zend_string *const_PREFIX_LEFT_name = zend_string_init_interned("PREFIX_LEFT", sizeof("PREFIX_LEFT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PREFIX_LEFT_name, &const_PREFIX_LEFT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PREFIX_LEFT_name); + zend_string_release_ex(const_PREFIX_LEFT_name, true); zval const_PREFIX_MID_HAS_NEXT_value; ZVAL_LONG(&const_PREFIX_MID_HAS_NEXT_value, 1); - zend_string *const_PREFIX_MID_HAS_NEXT_name = zend_string_init_interned("PREFIX_MID_HAS_NEXT", sizeof("PREFIX_MID_HAS_NEXT") - 1, 1); + zend_string *const_PREFIX_MID_HAS_NEXT_name = zend_string_init_interned("PREFIX_MID_HAS_NEXT", sizeof("PREFIX_MID_HAS_NEXT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PREFIX_MID_HAS_NEXT_name, &const_PREFIX_MID_HAS_NEXT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PREFIX_MID_HAS_NEXT_name); + zend_string_release_ex(const_PREFIX_MID_HAS_NEXT_name, true); zval const_PREFIX_MID_LAST_value; ZVAL_LONG(&const_PREFIX_MID_LAST_value, 2); - zend_string *const_PREFIX_MID_LAST_name = zend_string_init_interned("PREFIX_MID_LAST", sizeof("PREFIX_MID_LAST") - 1, 1); + zend_string *const_PREFIX_MID_LAST_name = zend_string_init_interned("PREFIX_MID_LAST", sizeof("PREFIX_MID_LAST") - 1, true); zend_declare_typed_class_constant(class_entry, const_PREFIX_MID_LAST_name, &const_PREFIX_MID_LAST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PREFIX_MID_LAST_name); + zend_string_release_ex(const_PREFIX_MID_LAST_name, true); zval const_PREFIX_END_HAS_NEXT_value; ZVAL_LONG(&const_PREFIX_END_HAS_NEXT_value, 3); - zend_string *const_PREFIX_END_HAS_NEXT_name = zend_string_init_interned("PREFIX_END_HAS_NEXT", sizeof("PREFIX_END_HAS_NEXT") - 1, 1); + zend_string *const_PREFIX_END_HAS_NEXT_name = zend_string_init_interned("PREFIX_END_HAS_NEXT", sizeof("PREFIX_END_HAS_NEXT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PREFIX_END_HAS_NEXT_name, &const_PREFIX_END_HAS_NEXT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PREFIX_END_HAS_NEXT_name); + zend_string_release_ex(const_PREFIX_END_HAS_NEXT_name, true); zval const_PREFIX_END_LAST_value; ZVAL_LONG(&const_PREFIX_END_LAST_value, 4); - zend_string *const_PREFIX_END_LAST_name = zend_string_init_interned("PREFIX_END_LAST", sizeof("PREFIX_END_LAST") - 1, 1); + zend_string *const_PREFIX_END_LAST_name = zend_string_init_interned("PREFIX_END_LAST", sizeof("PREFIX_END_LAST") - 1, true); zend_declare_typed_class_constant(class_entry, const_PREFIX_END_LAST_name, &const_PREFIX_END_LAST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PREFIX_END_LAST_name); + zend_string_release_ex(const_PREFIX_END_LAST_name, true); zval const_PREFIX_RIGHT_value; ZVAL_LONG(&const_PREFIX_RIGHT_value, 5); - zend_string *const_PREFIX_RIGHT_name = zend_string_init_interned("PREFIX_RIGHT", sizeof("PREFIX_RIGHT") - 1, 1); + zend_string *const_PREFIX_RIGHT_name = zend_string_init_interned("PREFIX_RIGHT", sizeof("PREFIX_RIGHT") - 1, true); zend_declare_typed_class_constant(class_entry, const_PREFIX_RIGHT_name, &const_PREFIX_RIGHT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PREFIX_RIGHT_name); + zend_string_release_ex(const_PREFIX_RIGHT_name, true); return class_entry; } diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index 540e5c2c0ff94..801c091fbb42d 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -673,9 +673,7 @@ PHP_METHOD(SplObjectStorage, rewind) { spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos); intern->index = 0; @@ -686,9 +684,7 @@ PHP_METHOD(SplObjectStorage, valid) { spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_BOOL(zend_hash_has_more_elements_ex(&intern->storage, &intern->pos) == SUCCESS); } /* }}} */ @@ -698,9 +694,7 @@ PHP_METHOD(SplObjectStorage, key) { spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(intern->index); } /* }}} */ @@ -711,9 +705,7 @@ PHP_METHOD(SplObjectStorage, current) spl_SplObjectStorageElement *element; spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) == NULL) { zend_throw_exception(spl_ce_RuntimeException, "Called current() on invalid iterator", 0); @@ -728,9 +720,7 @@ PHP_METHOD(SplObjectStorage, getInfo) spl_SplObjectStorageElement *element; spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) == NULL) { RETURN_NULL(); @@ -763,9 +753,7 @@ PHP_METHOD(SplObjectStorage, next) { spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_hash_move_forward_ex(&intern->storage, &intern->pos); intern->index++; @@ -825,9 +813,7 @@ PHP_METHOD(SplObjectStorage, serialize) php_serialize_data_t var_hash; smart_str buf = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); PHP_VAR_SERIALIZE_INIT(var_hash); @@ -999,9 +985,7 @@ PHP_METHOD(SplObjectStorage, __serialize) spl_SplObjectStorageElement *elem; zval tmp; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); array_init(return_value); @@ -1069,9 +1053,7 @@ PHP_METHOD(SplObjectStorage, __unserialize) /* {{{ */ PHP_METHOD(SplObjectStorage, __debugInfo) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_ARR(spl_object_storage_debug_info(Z_OBJ_P(ZEND_THIS))); } @@ -1100,9 +1082,7 @@ PHP_METHOD(MultipleIterator, getFlags) { spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(intern->flags); } /* }}} */ @@ -1193,9 +1173,7 @@ PHP_METHOD(MultipleIterator, countIterators) { spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_LONG(zend_hash_num_elements(&intern->storage)); } @@ -1208,9 +1186,7 @@ PHP_METHOD(MultipleIterator, rewind) intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos); while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) { @@ -1229,9 +1205,7 @@ PHP_METHOD(MultipleIterator, next) intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos); while ((element = zend_hash_get_current_data_ptr_ex(&intern->storage, &intern->pos)) != NULL && !EG(exception)) { @@ -1252,9 +1226,7 @@ PHP_METHOD(MultipleIterator, valid) intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (!zend_hash_num_elements(&intern->storage)) { RETURN_FALSE; @@ -1361,9 +1333,7 @@ PHP_METHOD(MultipleIterator, current) spl_SplObjectStorage *intern; intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_CURRENT, return_value); } @@ -1375,9 +1345,7 @@ PHP_METHOD(MultipleIterator, key) spl_SplObjectStorage *intern; intern = Z_SPLOBJSTORAGE_P(ZEND_THIS); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); spl_multiple_iterator_get_all(intern, SPL_MULTIPLE_ITERATOR_GET_ALL_KEY, return_value); } diff --git a/ext/spl/spl_observer_arginfo.h b/ext/spl/spl_observer_arginfo.h index ae648edd7e818..fec3ccb84203d 100644 --- a/ext/spl/spl_observer_arginfo.h +++ b/ext/spl/spl_observer_arginfo.h @@ -293,27 +293,27 @@ static zend_class_entry *register_class_MultipleIterator(zend_class_entry *class zval const_MIT_NEED_ANY_value; ZVAL_LONG(&const_MIT_NEED_ANY_value, MIT_NEED_ANY); - zend_string *const_MIT_NEED_ANY_name = zend_string_init_interned("MIT_NEED_ANY", sizeof("MIT_NEED_ANY") - 1, 1); + zend_string *const_MIT_NEED_ANY_name = zend_string_init_interned("MIT_NEED_ANY", sizeof("MIT_NEED_ANY") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIT_NEED_ANY_name, &const_MIT_NEED_ANY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIT_NEED_ANY_name); + zend_string_release_ex(const_MIT_NEED_ANY_name, true); zval const_MIT_NEED_ALL_value; ZVAL_LONG(&const_MIT_NEED_ALL_value, MIT_NEED_ALL); - zend_string *const_MIT_NEED_ALL_name = zend_string_init_interned("MIT_NEED_ALL", sizeof("MIT_NEED_ALL") - 1, 1); + zend_string *const_MIT_NEED_ALL_name = zend_string_init_interned("MIT_NEED_ALL", sizeof("MIT_NEED_ALL") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIT_NEED_ALL_name, &const_MIT_NEED_ALL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIT_NEED_ALL_name); + zend_string_release_ex(const_MIT_NEED_ALL_name, true); zval const_MIT_KEYS_NUMERIC_value; ZVAL_LONG(&const_MIT_KEYS_NUMERIC_value, MIT_KEYS_NUMERIC); - zend_string *const_MIT_KEYS_NUMERIC_name = zend_string_init_interned("MIT_KEYS_NUMERIC", sizeof("MIT_KEYS_NUMERIC") - 1, 1); + zend_string *const_MIT_KEYS_NUMERIC_name = zend_string_init_interned("MIT_KEYS_NUMERIC", sizeof("MIT_KEYS_NUMERIC") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIT_KEYS_NUMERIC_name, &const_MIT_KEYS_NUMERIC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIT_KEYS_NUMERIC_name); + zend_string_release_ex(const_MIT_KEYS_NUMERIC_name, true); zval const_MIT_KEYS_ASSOC_value; ZVAL_LONG(&const_MIT_KEYS_ASSOC_value, MIT_KEYS_ASSOC); - zend_string *const_MIT_KEYS_ASSOC_name = zend_string_init_interned("MIT_KEYS_ASSOC", sizeof("MIT_KEYS_ASSOC") - 1, 1); + zend_string *const_MIT_KEYS_ASSOC_name = zend_string_init_interned("MIT_KEYS_ASSOC", sizeof("MIT_KEYS_ASSOC") - 1, true); zend_declare_typed_class_constant(class_entry, const_MIT_KEYS_ASSOC_name, &const_MIT_KEYS_ASSOC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_MIT_KEYS_ASSOC_name); + zend_string_release_ex(const_MIT_KEYS_ASSOC_name, true); return class_entry; } diff --git a/ext/spl/tests/gh20678.phpt b/ext/spl/tests/gh20678.phpt new file mode 100644 index 0000000000000..00364db7f8044 --- /dev/null +++ b/ext/spl/tests/gh20678.phpt @@ -0,0 +1,13 @@ +--TEST-- +GH-20678 (resource created by GlobalIterator crashes when it is called with fclose()) +--CREDITS-- +chongwick +--FILE-- + +--EXPECTF-- +Warning: fclose(): cannot close the provided stream, as it must not be manually closed in %s on line %d diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index 21b6840a8d1b2..da24b037861a8 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -318,7 +318,7 @@ PHP_METHOD(SQLite3, enableExtendedResultCodes) { php_sqlite3_db_object *db_obj; zval *object = ZEND_THIS; - bool enable = 1; + bool enable = true; db_obj = Z_SQLITE3_DB_P(object); int ret; @@ -648,7 +648,7 @@ static void sqlite_value_to_zval(sqlite3_stmt *stmt, int column, zval *data) /* break; case SQLITE3_TEXT: - ZVAL_STRING(data, (char*)sqlite3_column_text(stmt, column)); + ZVAL_STRINGL(data, (const char *) sqlite3_column_text(stmt, column), sqlite3_column_bytes(stmt, column)); break; case SQLITE_BLOB: @@ -666,7 +666,7 @@ PHP_METHOD(SQLite3, querySingle) zend_string *sql; char *errtext = NULL; int return_code; - bool entire_row = 0; + bool entire_row = false; sqlite3_stmt *stmt; db_obj = Z_SQLITE3_DB_P(object); @@ -1285,7 +1285,7 @@ PHP_METHOD(SQLite3, enableExceptions) { php_sqlite3_db_object *db_obj; zval *object = ZEND_THIS; - bool enableExceptions = 0; + bool enableExceptions = false; db_obj = Z_SQLITE3_DB_P(object); @@ -1916,7 +1916,6 @@ PHP_METHOD(SQLite3Stmt, __construct) errcode = sqlite3_prepare_v2(db_obj->db, ZSTR_VAL(sql), ZSTR_LEN(sql), &(stmt_obj->stmt), NULL); if (errcode != SQLITE_OK) { php_sqlite3_error(db_obj, errcode, "Unable to prepare statement: %s", sqlite3_errmsg(db_obj->db)); - zval_ptr_dtor(return_value); RETURN_FALSE; } stmt_obj->initialised = true; @@ -2044,6 +2043,7 @@ PHP_METHOD(SQLite3Result, fetchArray) default: php_sqlite3_error(result_obj->db_obj, sqlite3_errcode(sqlite3_db_handle(result_obj->stmt_obj->stmt)), "Unable to execute statement: %s", sqlite3_errmsg(sqlite3_db_handle(result_obj->stmt_obj->stmt))); + RETURN_FALSE; } } /* }}} */ diff --git a/ext/sqlite3/sqlite3_arginfo.h b/ext/sqlite3/sqlite3_arginfo.h index 54ca70cad5c53..12c1c7d0ce961 100644 --- a/ext/sqlite3/sqlite3_arginfo.h +++ b/ext/sqlite3/sqlite3_arginfo.h @@ -332,226 +332,226 @@ static zend_class_entry *register_class_SQLite3(void) zval const_OK_value; ZVAL_LONG(&const_OK_value, SQLITE_OK); - zend_string *const_OK_name = zend_string_init_interned("OK", sizeof("OK") - 1, 1); + zend_string *const_OK_name = zend_string_init_interned("OK", sizeof("OK") - 1, true); zend_declare_typed_class_constant(class_entry, const_OK_name, &const_OK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OK_name); + zend_string_release_ex(const_OK_name, true); zval const_DENY_value; ZVAL_LONG(&const_DENY_value, SQLITE_DENY); - zend_string *const_DENY_name = zend_string_init_interned("DENY", sizeof("DENY") - 1, 1); + zend_string *const_DENY_name = zend_string_init_interned("DENY", sizeof("DENY") - 1, true); zend_declare_typed_class_constant(class_entry, const_DENY_name, &const_DENY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DENY_name); + zend_string_release_ex(const_DENY_name, true); zval const_IGNORE_value; ZVAL_LONG(&const_IGNORE_value, SQLITE_IGNORE); - zend_string *const_IGNORE_name = zend_string_init_interned("IGNORE", sizeof("IGNORE") - 1, 1); + zend_string *const_IGNORE_name = zend_string_init_interned("IGNORE", sizeof("IGNORE") - 1, true); zend_declare_typed_class_constant(class_entry, const_IGNORE_name, &const_IGNORE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_IGNORE_name); + zend_string_release_ex(const_IGNORE_name, true); zval const_CREATE_INDEX_value; ZVAL_LONG(&const_CREATE_INDEX_value, SQLITE_CREATE_INDEX); - zend_string *const_CREATE_INDEX_name = zend_string_init_interned("CREATE_INDEX", sizeof("CREATE_INDEX") - 1, 1); + zend_string *const_CREATE_INDEX_name = zend_string_init_interned("CREATE_INDEX", sizeof("CREATE_INDEX") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_INDEX_name, &const_CREATE_INDEX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_INDEX_name); + zend_string_release_ex(const_CREATE_INDEX_name, true); zval const_CREATE_TABLE_value; ZVAL_LONG(&const_CREATE_TABLE_value, SQLITE_CREATE_TABLE); - zend_string *const_CREATE_TABLE_name = zend_string_init_interned("CREATE_TABLE", sizeof("CREATE_TABLE") - 1, 1); + zend_string *const_CREATE_TABLE_name = zend_string_init_interned("CREATE_TABLE", sizeof("CREATE_TABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_TABLE_name, &const_CREATE_TABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_TABLE_name); + zend_string_release_ex(const_CREATE_TABLE_name, true); zval const_CREATE_TEMP_INDEX_value; ZVAL_LONG(&const_CREATE_TEMP_INDEX_value, SQLITE_CREATE_TEMP_INDEX); - zend_string *const_CREATE_TEMP_INDEX_name = zend_string_init_interned("CREATE_TEMP_INDEX", sizeof("CREATE_TEMP_INDEX") - 1, 1); + zend_string *const_CREATE_TEMP_INDEX_name = zend_string_init_interned("CREATE_TEMP_INDEX", sizeof("CREATE_TEMP_INDEX") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_TEMP_INDEX_name, &const_CREATE_TEMP_INDEX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_TEMP_INDEX_name); + zend_string_release_ex(const_CREATE_TEMP_INDEX_name, true); zval const_CREATE_TEMP_TABLE_value; ZVAL_LONG(&const_CREATE_TEMP_TABLE_value, SQLITE_CREATE_TEMP_TABLE); - zend_string *const_CREATE_TEMP_TABLE_name = zend_string_init_interned("CREATE_TEMP_TABLE", sizeof("CREATE_TEMP_TABLE") - 1, 1); + zend_string *const_CREATE_TEMP_TABLE_name = zend_string_init_interned("CREATE_TEMP_TABLE", sizeof("CREATE_TEMP_TABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_TEMP_TABLE_name, &const_CREATE_TEMP_TABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_TEMP_TABLE_name); + zend_string_release_ex(const_CREATE_TEMP_TABLE_name, true); zval const_CREATE_TEMP_TRIGGER_value; ZVAL_LONG(&const_CREATE_TEMP_TRIGGER_value, SQLITE_CREATE_TEMP_TRIGGER); - zend_string *const_CREATE_TEMP_TRIGGER_name = zend_string_init_interned("CREATE_TEMP_TRIGGER", sizeof("CREATE_TEMP_TRIGGER") - 1, 1); + zend_string *const_CREATE_TEMP_TRIGGER_name = zend_string_init_interned("CREATE_TEMP_TRIGGER", sizeof("CREATE_TEMP_TRIGGER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_TEMP_TRIGGER_name, &const_CREATE_TEMP_TRIGGER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_TEMP_TRIGGER_name); + zend_string_release_ex(const_CREATE_TEMP_TRIGGER_name, true); zval const_CREATE_TEMP_VIEW_value; ZVAL_LONG(&const_CREATE_TEMP_VIEW_value, SQLITE_CREATE_TEMP_VIEW); - zend_string *const_CREATE_TEMP_VIEW_name = zend_string_init_interned("CREATE_TEMP_VIEW", sizeof("CREATE_TEMP_VIEW") - 1, 1); + zend_string *const_CREATE_TEMP_VIEW_name = zend_string_init_interned("CREATE_TEMP_VIEW", sizeof("CREATE_TEMP_VIEW") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_TEMP_VIEW_name, &const_CREATE_TEMP_VIEW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_TEMP_VIEW_name); + zend_string_release_ex(const_CREATE_TEMP_VIEW_name, true); zval const_CREATE_TRIGGER_value; ZVAL_LONG(&const_CREATE_TRIGGER_value, SQLITE_CREATE_TRIGGER); - zend_string *const_CREATE_TRIGGER_name = zend_string_init_interned("CREATE_TRIGGER", sizeof("CREATE_TRIGGER") - 1, 1); + zend_string *const_CREATE_TRIGGER_name = zend_string_init_interned("CREATE_TRIGGER", sizeof("CREATE_TRIGGER") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_TRIGGER_name, &const_CREATE_TRIGGER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_TRIGGER_name); + zend_string_release_ex(const_CREATE_TRIGGER_name, true); zval const_CREATE_VIEW_value; ZVAL_LONG(&const_CREATE_VIEW_value, SQLITE_CREATE_VIEW); - zend_string *const_CREATE_VIEW_name = zend_string_init_interned("CREATE_VIEW", sizeof("CREATE_VIEW") - 1, 1); + zend_string *const_CREATE_VIEW_name = zend_string_init_interned("CREATE_VIEW", sizeof("CREATE_VIEW") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_VIEW_name, &const_CREATE_VIEW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_VIEW_name); + zend_string_release_ex(const_CREATE_VIEW_name, true); zval const_DELETE_value; ZVAL_LONG(&const_DELETE_value, SQLITE_DELETE); - zend_string *const_DELETE_name = zend_string_init_interned("DELETE", sizeof("DELETE") - 1, 1); + zend_string *const_DELETE_name = zend_string_init_interned("DELETE", sizeof("DELETE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DELETE_name, &const_DELETE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DELETE_name); + zend_string_release_ex(const_DELETE_name, true); zval const_DROP_INDEX_value; ZVAL_LONG(&const_DROP_INDEX_value, SQLITE_DROP_INDEX); - zend_string *const_DROP_INDEX_name = zend_string_init_interned("DROP_INDEX", sizeof("DROP_INDEX") - 1, 1); + zend_string *const_DROP_INDEX_name = zend_string_init_interned("DROP_INDEX", sizeof("DROP_INDEX") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_INDEX_name, &const_DROP_INDEX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_INDEX_name); + zend_string_release_ex(const_DROP_INDEX_name, true); zval const_DROP_TABLE_value; ZVAL_LONG(&const_DROP_TABLE_value, SQLITE_DROP_TABLE); - zend_string *const_DROP_TABLE_name = zend_string_init_interned("DROP_TABLE", sizeof("DROP_TABLE") - 1, 1); + zend_string *const_DROP_TABLE_name = zend_string_init_interned("DROP_TABLE", sizeof("DROP_TABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_TABLE_name, &const_DROP_TABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_TABLE_name); + zend_string_release_ex(const_DROP_TABLE_name, true); zval const_DROP_TEMP_INDEX_value; ZVAL_LONG(&const_DROP_TEMP_INDEX_value, SQLITE_DROP_TEMP_INDEX); - zend_string *const_DROP_TEMP_INDEX_name = zend_string_init_interned("DROP_TEMP_INDEX", sizeof("DROP_TEMP_INDEX") - 1, 1); + zend_string *const_DROP_TEMP_INDEX_name = zend_string_init_interned("DROP_TEMP_INDEX", sizeof("DROP_TEMP_INDEX") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_TEMP_INDEX_name, &const_DROP_TEMP_INDEX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_TEMP_INDEX_name); + zend_string_release_ex(const_DROP_TEMP_INDEX_name, true); zval const_DROP_TEMP_TABLE_value; ZVAL_LONG(&const_DROP_TEMP_TABLE_value, SQLITE_DROP_TEMP_TABLE); - zend_string *const_DROP_TEMP_TABLE_name = zend_string_init_interned("DROP_TEMP_TABLE", sizeof("DROP_TEMP_TABLE") - 1, 1); + zend_string *const_DROP_TEMP_TABLE_name = zend_string_init_interned("DROP_TEMP_TABLE", sizeof("DROP_TEMP_TABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_TEMP_TABLE_name, &const_DROP_TEMP_TABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_TEMP_TABLE_name); + zend_string_release_ex(const_DROP_TEMP_TABLE_name, true); zval const_DROP_TEMP_TRIGGER_value; ZVAL_LONG(&const_DROP_TEMP_TRIGGER_value, SQLITE_DROP_TEMP_TRIGGER); - zend_string *const_DROP_TEMP_TRIGGER_name = zend_string_init_interned("DROP_TEMP_TRIGGER", sizeof("DROP_TEMP_TRIGGER") - 1, 1); + zend_string *const_DROP_TEMP_TRIGGER_name = zend_string_init_interned("DROP_TEMP_TRIGGER", sizeof("DROP_TEMP_TRIGGER") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_TEMP_TRIGGER_name, &const_DROP_TEMP_TRIGGER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_TEMP_TRIGGER_name); + zend_string_release_ex(const_DROP_TEMP_TRIGGER_name, true); zval const_DROP_TEMP_VIEW_value; ZVAL_LONG(&const_DROP_TEMP_VIEW_value, SQLITE_DROP_TEMP_VIEW); - zend_string *const_DROP_TEMP_VIEW_name = zend_string_init_interned("DROP_TEMP_VIEW", sizeof("DROP_TEMP_VIEW") - 1, 1); + zend_string *const_DROP_TEMP_VIEW_name = zend_string_init_interned("DROP_TEMP_VIEW", sizeof("DROP_TEMP_VIEW") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_TEMP_VIEW_name, &const_DROP_TEMP_VIEW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_TEMP_VIEW_name); + zend_string_release_ex(const_DROP_TEMP_VIEW_name, true); zval const_DROP_TRIGGER_value; ZVAL_LONG(&const_DROP_TRIGGER_value, SQLITE_DROP_TRIGGER); - zend_string *const_DROP_TRIGGER_name = zend_string_init_interned("DROP_TRIGGER", sizeof("DROP_TRIGGER") - 1, 1); + zend_string *const_DROP_TRIGGER_name = zend_string_init_interned("DROP_TRIGGER", sizeof("DROP_TRIGGER") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_TRIGGER_name, &const_DROP_TRIGGER_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_TRIGGER_name); + zend_string_release_ex(const_DROP_TRIGGER_name, true); zval const_DROP_VIEW_value; ZVAL_LONG(&const_DROP_VIEW_value, SQLITE_DROP_VIEW); - zend_string *const_DROP_VIEW_name = zend_string_init_interned("DROP_VIEW", sizeof("DROP_VIEW") - 1, 1); + zend_string *const_DROP_VIEW_name = zend_string_init_interned("DROP_VIEW", sizeof("DROP_VIEW") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_VIEW_name, &const_DROP_VIEW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_VIEW_name); + zend_string_release_ex(const_DROP_VIEW_name, true); zval const_INSERT_value; ZVAL_LONG(&const_INSERT_value, SQLITE_INSERT); - zend_string *const_INSERT_name = zend_string_init_interned("INSERT", sizeof("INSERT") - 1, 1); + zend_string *const_INSERT_name = zend_string_init_interned("INSERT", sizeof("INSERT") - 1, true); zend_declare_typed_class_constant(class_entry, const_INSERT_name, &const_INSERT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_INSERT_name); + zend_string_release_ex(const_INSERT_name, true); zval const_PRAGMA_value; ZVAL_LONG(&const_PRAGMA_value, SQLITE_PRAGMA); - zend_string *const_PRAGMA_name = zend_string_init_interned("PRAGMA", sizeof("PRAGMA") - 1, 1); + zend_string *const_PRAGMA_name = zend_string_init_interned("PRAGMA", sizeof("PRAGMA") - 1, true); zend_declare_typed_class_constant(class_entry, const_PRAGMA_name, &const_PRAGMA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PRAGMA_name); + zend_string_release_ex(const_PRAGMA_name, true); zval const_READ_value; ZVAL_LONG(&const_READ_value, SQLITE_READ); - zend_string *const_READ_name = zend_string_init_interned("READ", sizeof("READ") - 1, 1); + zend_string *const_READ_name = zend_string_init_interned("READ", sizeof("READ") - 1, true); zend_declare_typed_class_constant(class_entry, const_READ_name, &const_READ_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_READ_name); + zend_string_release_ex(const_READ_name, true); zval const_SELECT_value; ZVAL_LONG(&const_SELECT_value, SQLITE_SELECT); - zend_string *const_SELECT_name = zend_string_init_interned("SELECT", sizeof("SELECT") - 1, 1); + zend_string *const_SELECT_name = zend_string_init_interned("SELECT", sizeof("SELECT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SELECT_name, &const_SELECT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SELECT_name); + zend_string_release_ex(const_SELECT_name, true); zval const_TRANSACTION_value; ZVAL_LONG(&const_TRANSACTION_value, SQLITE_TRANSACTION); - zend_string *const_TRANSACTION_name = zend_string_init_interned("TRANSACTION", sizeof("TRANSACTION") - 1, 1); + zend_string *const_TRANSACTION_name = zend_string_init_interned("TRANSACTION", sizeof("TRANSACTION") - 1, true); zend_declare_typed_class_constant(class_entry, const_TRANSACTION_name, &const_TRANSACTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TRANSACTION_name); + zend_string_release_ex(const_TRANSACTION_name, true); zval const_UPDATE_value; ZVAL_LONG(&const_UPDATE_value, SQLITE_UPDATE); - zend_string *const_UPDATE_name = zend_string_init_interned("UPDATE", sizeof("UPDATE") - 1, 1); + zend_string *const_UPDATE_name = zend_string_init_interned("UPDATE", sizeof("UPDATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_UPDATE_name, &const_UPDATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_UPDATE_name); + zend_string_release_ex(const_UPDATE_name, true); zval const_ATTACH_value; ZVAL_LONG(&const_ATTACH_value, SQLITE_ATTACH); - zend_string *const_ATTACH_name = zend_string_init_interned("ATTACH", sizeof("ATTACH") - 1, 1); + zend_string *const_ATTACH_name = zend_string_init_interned("ATTACH", sizeof("ATTACH") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTACH_name, &const_ATTACH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTACH_name); + zend_string_release_ex(const_ATTACH_name, true); zval const_DETACH_value; ZVAL_LONG(&const_DETACH_value, SQLITE_DETACH); - zend_string *const_DETACH_name = zend_string_init_interned("DETACH", sizeof("DETACH") - 1, 1); + zend_string *const_DETACH_name = zend_string_init_interned("DETACH", sizeof("DETACH") - 1, true); zend_declare_typed_class_constant(class_entry, const_DETACH_name, &const_DETACH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DETACH_name); + zend_string_release_ex(const_DETACH_name, true); zval const_ALTER_TABLE_value; ZVAL_LONG(&const_ALTER_TABLE_value, SQLITE_ALTER_TABLE); - zend_string *const_ALTER_TABLE_name = zend_string_init_interned("ALTER_TABLE", sizeof("ALTER_TABLE") - 1, 1); + zend_string *const_ALTER_TABLE_name = zend_string_init_interned("ALTER_TABLE", sizeof("ALTER_TABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ALTER_TABLE_name, &const_ALTER_TABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ALTER_TABLE_name); + zend_string_release_ex(const_ALTER_TABLE_name, true); zval const_REINDEX_value; ZVAL_LONG(&const_REINDEX_value, SQLITE_REINDEX); - zend_string *const_REINDEX_name = zend_string_init_interned("REINDEX", sizeof("REINDEX") - 1, 1); + zend_string *const_REINDEX_name = zend_string_init_interned("REINDEX", sizeof("REINDEX") - 1, true); zend_declare_typed_class_constant(class_entry, const_REINDEX_name, &const_REINDEX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_REINDEX_name); + zend_string_release_ex(const_REINDEX_name, true); zval const_ANALYZE_value; ZVAL_LONG(&const_ANALYZE_value, SQLITE_ANALYZE); - zend_string *const_ANALYZE_name = zend_string_init_interned("ANALYZE", sizeof("ANALYZE") - 1, 1); + zend_string *const_ANALYZE_name = zend_string_init_interned("ANALYZE", sizeof("ANALYZE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ANALYZE_name, &const_ANALYZE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ANALYZE_name); + zend_string_release_ex(const_ANALYZE_name, true); zval const_CREATE_VTABLE_value; ZVAL_LONG(&const_CREATE_VTABLE_value, SQLITE_CREATE_VTABLE); - zend_string *const_CREATE_VTABLE_name = zend_string_init_interned("CREATE_VTABLE", sizeof("CREATE_VTABLE") - 1, 1); + zend_string *const_CREATE_VTABLE_name = zend_string_init_interned("CREATE_VTABLE", sizeof("CREATE_VTABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_VTABLE_name, &const_CREATE_VTABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_VTABLE_name); + zend_string_release_ex(const_CREATE_VTABLE_name, true); zval const_DROP_VTABLE_value; ZVAL_LONG(&const_DROP_VTABLE_value, SQLITE_DROP_VTABLE); - zend_string *const_DROP_VTABLE_name = zend_string_init_interned("DROP_VTABLE", sizeof("DROP_VTABLE") - 1, 1); + zend_string *const_DROP_VTABLE_name = zend_string_init_interned("DROP_VTABLE", sizeof("DROP_VTABLE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DROP_VTABLE_name, &const_DROP_VTABLE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DROP_VTABLE_name); + zend_string_release_ex(const_DROP_VTABLE_name, true); zval const_FUNCTION_value; ZVAL_LONG(&const_FUNCTION_value, SQLITE_FUNCTION); - zend_string *const_FUNCTION_name = zend_string_init_interned("FUNCTION", sizeof("FUNCTION") - 1, 1); + zend_string *const_FUNCTION_name = zend_string_init_interned("FUNCTION", sizeof("FUNCTION") - 1, true); zend_declare_typed_class_constant(class_entry, const_FUNCTION_name, &const_FUNCTION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FUNCTION_name); + zend_string_release_ex(const_FUNCTION_name, true); zval const_SAVEPOINT_value; ZVAL_LONG(&const_SAVEPOINT_value, SQLITE_SAVEPOINT); - zend_string *const_SAVEPOINT_name = zend_string_init_interned("SAVEPOINT", sizeof("SAVEPOINT") - 1, 1); + zend_string *const_SAVEPOINT_name = zend_string_init_interned("SAVEPOINT", sizeof("SAVEPOINT") - 1, true); zend_declare_typed_class_constant(class_entry, const_SAVEPOINT_name, &const_SAVEPOINT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SAVEPOINT_name); + zend_string_release_ex(const_SAVEPOINT_name, true); zval const_COPY_value; ZVAL_LONG(&const_COPY_value, SQLITE_COPY); - zend_string *const_COPY_name = zend_string_init_interned("COPY", sizeof("COPY") - 1, 1); + zend_string *const_COPY_name = zend_string_init_interned("COPY", sizeof("COPY") - 1, true); zend_declare_typed_class_constant(class_entry, const_COPY_name, &const_COPY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_COPY_name); + zend_string_release_ex(const_COPY_name, true); #if defined(SQLITE_RECURSIVE) zval const_RECURSIVE_value; ZVAL_LONG(&const_RECURSIVE_value, SQLITE_RECURSIVE); - zend_string *const_RECURSIVE_name = zend_string_init_interned("RECURSIVE", sizeof("RECURSIVE") - 1, 1); + zend_string *const_RECURSIVE_name = zend_string_init_interned("RECURSIVE", sizeof("RECURSIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_RECURSIVE_name, &const_RECURSIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_RECURSIVE_name); + zend_string_release_ex(const_RECURSIVE_name, true); #endif return class_entry; @@ -567,21 +567,21 @@ static zend_class_entry *register_class_SQLite3Stmt(void) zval const_EXPLAIN_MODE_PREPARED_value; ZVAL_LONG(&const_EXPLAIN_MODE_PREPARED_value, 0); - zend_string *const_EXPLAIN_MODE_PREPARED_name = zend_string_init_interned("EXPLAIN_MODE_PREPARED", sizeof("EXPLAIN_MODE_PREPARED") - 1, 1); + zend_string *const_EXPLAIN_MODE_PREPARED_name = zend_string_init_interned("EXPLAIN_MODE_PREPARED", sizeof("EXPLAIN_MODE_PREPARED") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_PREPARED_name, &const_EXPLAIN_MODE_PREPARED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXPLAIN_MODE_PREPARED_name); + zend_string_release_ex(const_EXPLAIN_MODE_PREPARED_name, true); zval const_EXPLAIN_MODE_EXPLAIN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_value, 1); - zend_string *const_EXPLAIN_MODE_EXPLAIN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN", sizeof("EXPLAIN_MODE_EXPLAIN") - 1, 1); + zend_string *const_EXPLAIN_MODE_EXPLAIN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN", sizeof("EXPLAIN_MODE_EXPLAIN") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_name, &const_EXPLAIN_MODE_EXPLAIN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXPLAIN_MODE_EXPLAIN_name); + zend_string_release_ex(const_EXPLAIN_MODE_EXPLAIN_name, true); zval const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value; ZVAL_LONG(&const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, 2); - zend_string *const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN", sizeof("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN") - 1, 1); + zend_string *const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name = zend_string_init_interned("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN", sizeof("EXPLAIN_MODE_EXPLAIN_QUERY_PLAN") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name, &const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name); + zend_string_release_ex(const_EXPLAIN_MODE_EXPLAIN_QUERY_PLAN_name, true); #endif return class_entry; diff --git a/ext/sqlite3/tests/gh20699.phpt b/ext/sqlite3/tests/gh20699.phpt new file mode 100644 index 0000000000000..1b53bfc98e39f --- /dev/null +++ b/ext/sqlite3/tests/gh20699.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-20699 (SQLite3Result fetchArray return array|false, null returned) +--EXTENSIONS-- +sqlite3 +--CREDITS-- +plusminmax +--FILE-- +prepare('BEGIN;')->execute()->fetchArray()); +?> +--EXPECTF-- +Warning: SQLite3Result::fetchArray(): Unable to execute statement: cannot start a transaction within a transaction in %s on line %d +bool(false) diff --git a/ext/sqlite3/tests/text_column_NUL_bytes.phpt b/ext/sqlite3/tests/text_column_NUL_bytes.phpt new file mode 100644 index 0000000000000..cf9403d91302d --- /dev/null +++ b/ext/sqlite3/tests/text_column_NUL_bytes.phpt @@ -0,0 +1,38 @@ +--TEST-- +Text column with NUL bytes +--EXTENSIONS-- +sqlite3 +--FILE-- +exec( + 'CREATE TABLE messages ( + content TEXT + )' +); + +$insert = $db->prepare( + 'INSERT INTO messages (content) VALUES (:content)' +); + +$insert->bindValue(':content', "with\0null", SQLITE3_TEXT); +$insert->execute(); +$insert->bindValue(':content', "\0", SQLITE3_TEXT); +$insert->execute(); + +$result = $db->query('SELECT * FROM messages'); +while ($row = $result->fetchArray(SQLITE3_ASSOC)) { + var_dump($row); +} + +?> +--EXPECTF-- +array(1) { + ["content"]=> + string(9) "with%0null" +} +array(1) { + ["content"]=> + string(1) "%0" +} diff --git a/ext/standard/array.c b/ext/standard/array.c index 44d226b2d822a..893e07dd8f99a 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -214,7 +214,7 @@ static zend_always_inline int php_array_key_compare_string_unstable_i(Bucket *f, } /* }}} */ -static int php_array_key_compare_string_natural_general(Bucket *f, Bucket *s, int fold_case) /* {{{ */ +static int php_array_key_compare_string_natural_general(Bucket *f, Bucket *s, bool fold_case) /* {{{ */ { const char *s1, *s2; size_t l1, l2; @@ -241,25 +241,25 @@ static int php_array_key_compare_string_natural_general(Bucket *f, Bucket *s, in static int php_array_key_compare_string_natural_case(Bucket *a, Bucket *b) /* {{{ */ { - RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(a, b, 1)); + RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(a, b, true)); } /* }}} */ static int php_array_reverse_key_compare_string_natural_case(Bucket *a, Bucket *b) /* {{{ */ { - RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(b, a, 1)); + RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(b, a, true)); } /* }}} */ static int php_array_key_compare_string_natural(Bucket *a, Bucket *b) /* {{{ */ { - RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(a, b, 0)); + RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(a, b, false)); } /* }}} */ static int php_array_reverse_key_compare_string_natural(Bucket *a, Bucket *b) /* {{{ */ { - RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(b, a, 0)); + RETURN_STABLE_SORT(a, b, php_array_key_compare_string_natural_general(b, a, false)); } /* }}} */ @@ -327,7 +327,7 @@ static zend_always_inline int php_array_data_compare_string_unstable_i(Bucket *f } /* }}} */ -static int php_array_natural_general_compare(Bucket *f, Bucket *s, int fold_case) /* {{{ */ +static int php_array_natural_general_compare(Bucket *f, Bucket *s, bool fold_case) /* {{{ */ { zend_string *tmp_str1, *tmp_str2; zend_string *str1 = zval_get_tmp_string(&f->val, &tmp_str1); @@ -343,13 +343,13 @@ static int php_array_natural_general_compare(Bucket *f, Bucket *s, int fold_case static zend_always_inline int php_array_natural_compare_unstable_i(Bucket *a, Bucket *b) /* {{{ */ { - return php_array_natural_general_compare(a, b, 0); + return php_array_natural_general_compare(a, b, false); } /* }}} */ static zend_always_inline int php_array_natural_case_compare_unstable_i(Bucket *a, Bucket *b) /* {{{ */ { - return php_array_natural_general_compare(a, b, 1); + return php_array_natural_general_compare(a, b, true); } /* }}} */ @@ -372,135 +372,127 @@ DEFINE_SORT_VARIANTS(data_compare_string_locale); DEFINE_SORT_VARIANTS(natural_compare); DEFINE_SORT_VARIANTS(natural_case_compare); -static bucket_compare_func_t php_get_key_compare_func(zend_long sort_type, int reverse) /* {{{ */ +static bucket_compare_func_t php_get_key_compare_func(zend_long sort_type) { switch (sort_type & ~PHP_SORT_FLAG_CASE) { case PHP_SORT_NUMERIC: - if (reverse) { - return php_array_reverse_key_compare_numeric; - } else { - return php_array_key_compare_numeric; - } - break; + return php_array_key_compare_numeric; case PHP_SORT_STRING: if (sort_type & PHP_SORT_FLAG_CASE) { - if (reverse) { - return php_array_reverse_key_compare_string_case; - } else { - return php_array_key_compare_string_case; - } + return php_array_key_compare_string_case; } else { - if (reverse) { - return php_array_reverse_key_compare_string; - } else { - return php_array_key_compare_string; - } + return php_array_key_compare_string; } - break; case PHP_SORT_NATURAL: if (sort_type & PHP_SORT_FLAG_CASE) { - if (reverse) { - return php_array_reverse_key_compare_string_natural_case; - } else { - return php_array_key_compare_string_natural_case; - } + return php_array_key_compare_string_natural_case; } else { - if (reverse) { - return php_array_reverse_key_compare_string_natural; - } else { - return php_array_key_compare_string_natural; - } + return php_array_key_compare_string_natural; } - break; case PHP_SORT_LOCALE_STRING: - if (reverse) { - return php_array_reverse_key_compare_string_locale; - } else { - return php_array_key_compare_string_locale; - } - break; + return php_array_key_compare_string_locale; case PHP_SORT_REGULAR: default: - if (reverse) { - return php_array_reverse_key_compare; - } else { - return php_array_key_compare; - } - break; + return php_array_key_compare; } return NULL; } -/* }}} */ -static bucket_compare_func_t php_get_data_compare_func(zend_long sort_type, int reverse) /* {{{ */ +static bucket_compare_func_t php_get_key_reverse_compare_func(zend_long sort_type) { switch (sort_type & ~PHP_SORT_FLAG_CASE) { case PHP_SORT_NUMERIC: - if (reverse) { - return php_array_reverse_data_compare_numeric; - } else { - return php_array_data_compare_numeric; - } - break; + return php_array_reverse_key_compare_numeric; case PHP_SORT_STRING: if (sort_type & PHP_SORT_FLAG_CASE) { - if (reverse) { - return php_array_reverse_data_compare_string_case; - } else { - return php_array_data_compare_string_case; - } + return php_array_reverse_key_compare_string_case; } else { - if (reverse) { - return php_array_reverse_data_compare_string; - } else { - return php_array_data_compare_string; - } + return php_array_reverse_key_compare_string; } - break; case PHP_SORT_NATURAL: if (sort_type & PHP_SORT_FLAG_CASE) { - if (reverse) { - return php_array_reverse_natural_case_compare; - } else { - return php_array_natural_case_compare; - } + return php_array_reverse_key_compare_string_natural_case; } else { - if (reverse) { - return php_array_reverse_natural_compare; - } else { - return php_array_natural_compare; - } + return php_array_reverse_key_compare_string_natural; } - break; case PHP_SORT_LOCALE_STRING: - if (reverse) { - return php_array_reverse_data_compare_string_locale; + return php_array_reverse_key_compare_string_locale; + + case PHP_SORT_REGULAR: + default: + return php_array_reverse_key_compare; + } + return NULL; +} + +static bucket_compare_func_t php_get_data_compare_func(zend_long sort_type) /* {{{ */ +{ + switch (sort_type & ~PHP_SORT_FLAG_CASE) { + case PHP_SORT_NUMERIC: + return php_array_data_compare_numeric; + + case PHP_SORT_STRING: + if (sort_type & PHP_SORT_FLAG_CASE) { + return php_array_data_compare_string_case; } else { - return php_array_data_compare_string_locale; + return php_array_data_compare_string; + } + + case PHP_SORT_NATURAL: + if (sort_type & PHP_SORT_FLAG_CASE) { + return php_array_natural_case_compare; + } else { + return php_array_natural_compare; } - break; + + case PHP_SORT_LOCALE_STRING: + return php_array_data_compare_string_locale; case PHP_SORT_REGULAR: default: - if (reverse) { - return php_array_reverse_data_compare; + return php_array_data_compare; + } + return NULL; +} + +static bucket_compare_func_t php_get_data_reverse_compare_func(zend_long sort_type) /* {{{ */ +{ + switch (sort_type & ~PHP_SORT_FLAG_CASE) { + case PHP_SORT_NUMERIC: + return php_array_reverse_data_compare_numeric; + + case PHP_SORT_STRING: + if (sort_type & PHP_SORT_FLAG_CASE) { + return php_array_reverse_data_compare_string_case; } else { - return php_array_data_compare; + return php_array_reverse_data_compare_string; } - break; + + case PHP_SORT_NATURAL: + if (sort_type & PHP_SORT_FLAG_CASE) { + return php_array_reverse_natural_case_compare; + } else { + return php_array_reverse_natural_compare; + } + + case PHP_SORT_LOCALE_STRING: + return php_array_reverse_data_compare_string_locale; + + case PHP_SORT_REGULAR: + default: + return php_array_reverse_data_compare; } return NULL; } -/* }}} */ -static bucket_compare_func_t php_get_data_compare_func_unstable(zend_long sort_type, int reverse) /* {{{ */ +static bucket_compare_func_t php_get_data_compare_func_unstable(zend_long sort_type, bool reverse) /* {{{ */ { switch (sort_type & ~PHP_SORT_FLAG_CASE) { case PHP_SORT_NUMERIC: @@ -564,48 +556,6 @@ static bucket_compare_func_t php_get_data_compare_func_unstable(zend_long sort_t } /* }}} */ -/* {{{ Sort an array by key value in reverse order */ -PHP_FUNCTION(krsort) -{ - zval *array; - zend_long sort_type = PHP_SORT_REGULAR; - bucket_compare_func_t cmp; - - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY_EX(array, 0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(sort_type) - ZEND_PARSE_PARAMETERS_END(); - - cmp = php_get_key_compare_func(sort_type, 1); - - zend_hash_sort(Z_ARRVAL_P(array), cmp, 0); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ Sort an array by key */ -PHP_FUNCTION(ksort) -{ - zval *array; - zend_long sort_type = PHP_SORT_REGULAR; - bucket_compare_func_t cmp; - - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY_EX(array, 0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(sort_type) - ZEND_PARSE_PARAMETERS_END(); - - cmp = php_get_key_compare_func(sort_type, 0); - - zend_hash_sort(Z_ARRVAL_P(array), cmp, 0); - - RETURN_TRUE; -} -/* }}} */ - PHPAPI zend_long php_count_recursive(HashTable *ht) /* {{{ */ { zend_long cnt = 0; @@ -702,119 +652,92 @@ PHP_FUNCTION(count) } /* }}} */ -static void php_natsort(INTERNAL_FUNCTION_PARAMETERS, int fold_case) /* {{{ */ +static void php_natsort(INTERNAL_FUNCTION_PARAMETERS, bucket_compare_func_t sort_fn) { - zval *array; + HashTable *array; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY_EX(array, 0, 1) + Z_PARAM_ARRAY_HT_EX(array, 0, 1) ZEND_PARSE_PARAMETERS_END(); - if (fold_case) { - zend_array_sort(Z_ARRVAL_P(array), php_array_natural_case_compare, 0); - } else { - zend_array_sort(Z_ARRVAL_P(array), php_array_natural_compare, 0); - } + zend_array_sort(array, sort_fn, false); RETURN_TRUE; } -/* }}} */ /* {{{ Sort an array using natural sort */ PHP_FUNCTION(natsort) { - php_natsort(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); + php_natsort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_natural_compare); } /* }}} */ /* {{{ Sort an array using case-insensitive natural sort */ PHP_FUNCTION(natcasesort) { - php_natsort(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); + php_natsort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_natural_case_compare); } /* }}} */ -/* {{{ Sort an array and maintain index association */ -PHP_FUNCTION(asort) -{ - zval *array; +typedef bucket_compare_func_t(*get_compare_function)(zend_long); + +static zend_always_inline void php_sort(INTERNAL_FUNCTION_PARAMETERS, get_compare_function get_cmp, bool renumber) { + HashTable *array; zend_long sort_type = PHP_SORT_REGULAR; bucket_compare_func_t cmp; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY_EX(array, 0, 1) + Z_PARAM_ARRAY_HT_EX(array, 0, 1) Z_PARAM_OPTIONAL Z_PARAM_LONG(sort_type) ZEND_PARSE_PARAMETERS_END(); - cmp = php_get_data_compare_func(sort_type, 0); + cmp = get_cmp(sort_type); - zend_array_sort(Z_ARRVAL_P(array), cmp, 0); + zend_array_sort(array, cmp, renumber); RETURN_TRUE; } + +/* {{{ Sort an array and maintain index association */ +PHP_FUNCTION(asort) +{ + php_sort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_get_data_compare_func, false); +} /* }}} */ /* {{{ Sort an array in reverse order and maintain index association */ PHP_FUNCTION(arsort) { - zval *array; - zend_long sort_type = PHP_SORT_REGULAR; - bucket_compare_func_t cmp; - - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY_EX(array, 0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(sort_type) - ZEND_PARSE_PARAMETERS_END(); - - cmp = php_get_data_compare_func(sort_type, 1); - - zend_array_sort(Z_ARRVAL_P(array), cmp, 0); - - RETURN_TRUE; + php_sort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_get_data_reverse_compare_func, false); } /* }}} */ /* {{{ Sort an array */ PHP_FUNCTION(sort) { - zval *array; - zend_long sort_type = PHP_SORT_REGULAR; - bucket_compare_func_t cmp; - - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY_EX(array, 0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(sort_type) - ZEND_PARSE_PARAMETERS_END(); - - cmp = php_get_data_compare_func(sort_type, 0); - - zend_array_sort(Z_ARRVAL_P(array), cmp, 1); - - RETURN_TRUE; + php_sort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_get_data_compare_func, true); } /* }}} */ /* {{{ Sort an array in reverse order */ PHP_FUNCTION(rsort) { - zval *array; - zend_long sort_type = PHP_SORT_REGULAR; - bucket_compare_func_t cmp; - - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY_EX(array, 0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(sort_type) - ZEND_PARSE_PARAMETERS_END(); - - cmp = php_get_data_compare_func(sort_type, 1); + php_sort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_get_data_reverse_compare_func, true); +} +/* }}} */ - zend_array_sort(Z_ARRVAL_P(array), cmp, 1); +/* {{{ Sort an array by key value in reverse order */ +PHP_FUNCTION(krsort) +{ + php_sort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_get_key_reverse_compare_func, false); +} +/* }}} */ - RETURN_TRUE; +/* {{{ Sort an array by key */ +PHP_FUNCTION(ksort) +{ + php_sort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_get_key_compare_func, false); } /* }}} */ @@ -912,14 +835,14 @@ static void php_usort(INTERNAL_FUNCTION_PARAMETERS, bucket_compare_func_t compar /* {{{ Sort an array by values using a user-defined comparison function */ PHP_FUNCTION(usort) { - php_usort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_user_compare, 1); + php_usort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_user_compare, true); } /* }}} */ /* {{{ Sort an array with a user-defined comparison function and maintain index association */ PHP_FUNCTION(uasort) { - php_usort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_user_compare, 0); + php_usort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_user_compare, false); } /* }}} */ @@ -986,7 +909,7 @@ static int php_array_user_key_compare(Bucket *a, Bucket *b) /* {{{ */ /* {{{ Sort an array by keys using a user-defined comparison function */ PHP_FUNCTION(uksort) { - php_usort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_user_key_compare, 0); + php_usort(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_array_user_key_compare, false); } /* }}} */ @@ -1457,7 +1380,7 @@ static zend_result php_array_walk( /* Set up known arguments */ ZVAL_UNDEF(&args[1]); if (userdata) { - ZVAL_COPY(&args[2], userdata); + ZVAL_COPY_VALUE(&args[2], userdata); } fci.retval = &retval; @@ -1531,21 +1454,14 @@ static zend_result php_array_walk( } zval_ptr_dtor(&ref); } else { - ZVAL_COPY(&args[0], zv); + ZVAL_COPY_VALUE(&args[0], zv); /* Call the userland function */ result = zend_call_function(&fci, &context->fci_cache); - if (result == SUCCESS) { - zval_ptr_dtor(&retval); - } - - zval_ptr_dtor(&args[0]); + zval_ptr_dtor(&retval); } - if (Z_TYPE(args[1]) != IS_UNDEF) { - zval_ptr_dtor(&args[1]); - ZVAL_UNDEF(&args[1]); - } + zval_ptr_dtor_str(&args[1]); if (result == FAILURE) { break; @@ -1565,9 +1481,6 @@ static zend_result php_array_walk( } } while (!EG(exception)); - if (userdata) { - zval_ptr_dtor(&args[2]); - } zend_hash_iterator_del(ht_iter); return result; } @@ -1762,9 +1675,8 @@ PHP_FUNCTION(array_search) } /* }}} */ -static zend_always_inline int php_valid_var_name(const char *var_name, size_t var_name_len) /* {{{ */ +static zend_always_inline bool php_valid_var_name(const zend_string *var_name) /* {{{ */ { -#if 1 /* first 256 bits for first character, and second 256 bits for the next */ static const uint32_t charset[8] = { /* 31 0 63 32 95 64 127 96 */ @@ -1774,67 +1686,37 @@ static zend_always_inline int php_valid_var_name(const char *var_name, size_t va /* 31 0 63 32 95 64 127 96 */ 0x00000000, 0x03ff0000, 0x87fffffe, 0x07fffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}; -#endif - size_t i; - uint32_t ch; - if (UNEXPECTED(!var_name_len)) { - return 0; + if (UNEXPECTED(!ZSTR_LEN(var_name))) { + return false; } /* These are allowed as first char: [a-zA-Z_\x7f-\xff] */ - ch = (uint32_t)((unsigned char *)var_name)[0]; -#if 1 + uint32_t ch = (uint32_t)((unsigned char *)ZSTR_VAL(var_name))[0]; if (UNEXPECTED(!ZEND_BIT_TEST(charset, ch))) { -#else - if (var_name[0] != '_' && - (ch < 65 /* A */ || /* Z */ ch > 90) && - (ch < 97 /* a */ || /* z */ ch > 122) && - (ch < 127 /* 0x7f */ || /* 0xff */ ch > 255) - ) { -#endif - return 0; + return false; } /* And these as the rest: [a-zA-Z0-9_\x7f-\xff] */ - if (var_name_len > 1) { - i = 1; + if (ZSTR_LEN(var_name) > 1) { + size_t i = 1; do { - ch = (uint32_t)((unsigned char *)var_name)[i]; -#if 1 + ch = (uint32_t)((unsigned char *)ZSTR_VAL(var_name))[i]; if (UNEXPECTED(!ZEND_BIT_TEST(charset2, ch))) { -#else - if (var_name[i] != '_' && - (ch < 48 /* 0 */ || /* 9 */ ch > 57) && - (ch < 65 /* A */ || /* Z */ ch > 90) && - (ch < 97 /* a */ || /* z */ ch > 122) && - (ch < 127 /* 0x7f */ || /* 0xff */ ch > 255) - ) { -#endif - return 0; + return false; } - } while (++i < var_name_len); + } while (++i < ZSTR_LEN(var_name)); } - return 1; + return true; } /* }}} */ -PHPAPI int php_prefix_varname(zval *result, zend_string *prefix, const char *var_name, size_t var_name_len, bool add_underscore) /* {{{ */ +static zend_string* php_prefix_varname(const zend_string *prefix, const zend_string *var_name) { - ZVAL_NEW_STR(result, zend_string_alloc(ZSTR_LEN(prefix) + (add_underscore ? 1 : 0) + var_name_len, 0)); - memcpy(Z_STRVAL_P(result), ZSTR_VAL(prefix), ZSTR_LEN(prefix)); - - if (add_underscore) { - Z_STRVAL_P(result)[ZSTR_LEN(prefix)] = '_'; - } - - memcpy(Z_STRVAL_P(result) + ZSTR_LEN(prefix) + (add_underscore ? 1 : 0), var_name, var_name_len + 1); - - return SUCCESS; + return zend_string_concat3(ZSTR_VAL(prefix), ZSTR_LEN(prefix), ZEND_STRL("_"), ZSTR_VAL(var_name), ZSTR_LEN(var_name)); } -/* }}} */ -static zend_long php_extract_ref_if_exists(zend_array *arr, zend_array *symbol_table) /* {{{ */ +static zend_long php_extract_ref_if_exists(const zend_array *arr, const zend_array *symbol_table) /* {{{ */ { zend_long count = 0; zend_string *var_name; @@ -1855,7 +1737,7 @@ static zend_long php_extract_ref_if_exists(zend_array *arr, zend_array *symbol_t continue; } } - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals_literal(var_name, "GLOBALS")) { @@ -1880,7 +1762,7 @@ static zend_long php_extract_ref_if_exists(zend_array *arr, zend_array *symbol_t } /* }}} */ -static zend_long php_extract_if_exists(zend_array *arr, zend_array *symbol_table) /* {{{ */ +static zend_long php_extract_if_exists(const zend_array *arr, const zend_array *symbol_table) /* {{{ */ { zend_long count = 0; zend_string *var_name; @@ -1901,7 +1783,7 @@ static zend_long php_extract_if_exists(zend_array *arr, zend_array *symbol_table continue; } } - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals_literal(var_name, "GLOBALS")) { @@ -1924,7 +1806,7 @@ static zend_long php_extract_if_exists(zend_array *arr, zend_array *symbol_table } /* }}} */ -static zend_long php_extract_ref_overwrite(zend_array *arr, zend_array *symbol_table) /* {{{ */ +static zend_long php_extract_ref_overwrite(const zend_array *arr, zend_array *symbol_table) /* {{{ */ { zend_long count = 0; zend_string *var_name; @@ -1937,7 +1819,7 @@ static zend_long php_extract_ref_overwrite(zend_array *arr, zend_array *symbol_t if (!var_name) { continue; } - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { @@ -1976,7 +1858,7 @@ static zend_long php_extract_ref_overwrite(zend_array *arr, zend_array *symbol_t } /* }}} */ -static zend_long php_extract_overwrite(zend_array *arr, zend_array *symbol_table) /* {{{ */ +static zend_long php_extract_overwrite(const zend_array *arr, zend_array *symbol_table) /* {{{ */ { zend_long count = 0; zend_string *var_name; @@ -1989,7 +1871,7 @@ static zend_long php_extract_overwrite(zend_array *arr, zend_array *symbol_table if (!var_name) { continue; } - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { @@ -2021,11 +1903,11 @@ static zend_long php_extract_overwrite(zend_array *arr, zend_array *symbol_table } /* }}} */ -static zend_long php_extract_ref_prefix_if_exists(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_ref_prefix_if_exists(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; if (HT_IS_PACKED(arr)) { return 0; @@ -2049,30 +1931,28 @@ static zend_long php_extract_ref_prefix_if_exists(zend_array *arr, zend_array *s continue; } } - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); - if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; + zend_string *final_name = php_prefix_varname(prefix, var_name); + if (php_valid_var_name(final_name)) { + /* Prefixed varname cannot be equal to "this" due to underscore between prefix and name */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + if (Z_ISREF_P(entry)) { + Z_ADDREF_P(entry); } else { - if (Z_ISREF_P(entry)) { - Z_ADDREF_P(entry); - } else { - ZVAL_MAKE_REF_EX(entry, 2); - } - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - zval_ptr_dtor(orig_var); - ZVAL_REF(orig_var, Z_REF_P(entry)); - } else { - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); + ZVAL_MAKE_REF_EX(entry, 2); + } + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + zval_ptr_dtor(orig_var); + ZVAL_REF(orig_var, Z_REF_P(entry)); + } else { + zend_hash_add_new(symbol_table, final_name, entry); } + count++; } - zval_ptr_dtor_str(&final_name); + zend_string_release_ex(final_name, false); } } ZEND_HASH_FOREACH_END(); @@ -2080,11 +1960,11 @@ static zend_long php_extract_ref_prefix_if_exists(zend_array *arr, zend_array *s } /* }}} */ -static zend_long php_extract_prefix_if_exists(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_prefix_if_exists(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; if (HT_IS_PACKED(arr)) { return 0; @@ -2103,30 +1983,28 @@ static zend_long php_extract_prefix_if_exists(zend_array *arr, zend_array *symbo continue; } } - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); - if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; - } else { - ZVAL_DEREF(entry); - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); - if (UNEXPECTED(EG(exception))) { - zend_string_release_ex(Z_STR(final_name), 0); - return -1; - } - } else { - Z_TRY_ADDREF_P(entry); - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); + zend_string *final_name = php_prefix_varname(prefix, var_name); + if (php_valid_var_name(final_name)) { + /* Prefixed varname cannot be equal to "this" due to underscore between prefix and name */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + ZVAL_DEREF(entry); + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); + if (UNEXPECTED(EG(exception))) { + zend_string_release_ex(final_name, 0); + return -1; + } + } else { + Z_TRY_ADDREF_P(entry); + zend_hash_add_new(symbol_table, final_name, entry); } + count++; } - zval_ptr_dtor_str(&final_name); + zend_string_release_ex(final_name, false); } } ZEND_HASH_FOREACH_END(); @@ -2134,11 +2012,11 @@ static zend_long php_extract_prefix_if_exists(zend_array *arr, zend_array *symbo } /* }}} */ -static zend_long php_extract_ref_prefix_same(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_ref_prefix_same(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; if (HT_IS_PACKED(arr)) { return 0; @@ -2165,33 +2043,31 @@ static zend_long php_extract_ref_prefix_same(zend_array *arr, zend_array *symbol continue; } } -prefix: - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); - if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; +prefix:; + zend_string *final_name = php_prefix_varname(prefix, var_name); + if (php_valid_var_name(final_name)) { + /* Prefixed varname cannot be equal to "this" due to underscore between prefix and name */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + if (Z_ISREF_P(entry)) { + Z_ADDREF_P(entry); } else { - if (Z_ISREF_P(entry)) { - Z_ADDREF_P(entry); - } else { - ZVAL_MAKE_REF_EX(entry, 2); - } - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - zval_ptr_dtor(orig_var); - ZVAL_REF(orig_var, Z_REF_P(entry)); - } else { - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); + ZVAL_MAKE_REF_EX(entry, 2); + } + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + zval_ptr_dtor(orig_var); + ZVAL_REF(orig_var, Z_REF_P(entry)); + } else { + zend_hash_add_new(symbol_table, final_name, entry); } + count++; } - zval_ptr_dtor_str(&final_name); + zend_string_release_ex(final_name, false); } else { - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { @@ -2211,11 +2087,11 @@ static zend_long php_extract_ref_prefix_same(zend_array *arr, zend_array *symbol } /* }}} */ -static zend_long php_extract_prefix_same(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_prefix_same(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; if (HT_IS_PACKED(arr)) { return 0; @@ -2237,33 +2113,31 @@ static zend_long php_extract_prefix_same(zend_array *arr, zend_array *symbol_tab continue; } } -prefix: - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); - if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; - } else { - ZVAL_DEREF(entry); - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); - if (UNEXPECTED(EG(exception))) { - zend_string_release_ex(Z_STR(final_name), 0); - return -1; - } - } else { - Z_TRY_ADDREF_P(entry); - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); +prefix:; + zend_string *final_name = php_prefix_varname(prefix, var_name); + if (php_valid_var_name(final_name)) { + /* Prefixed varname cannot be equal to "this" due to underscore between prefix and name */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + ZVAL_DEREF(entry); + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); + if (UNEXPECTED(EG(exception))) { + zend_string_release_ex(final_name, false); + return -1; + } + } else { + Z_TRY_ADDREF_P(entry); + zend_hash_add_new(symbol_table, final_name, entry); } + count++; } - zval_ptr_dtor_str(&final_name); + zend_string_release_ex(final_name, false); } else { - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { @@ -2280,211 +2154,210 @@ static zend_long php_extract_prefix_same(zend_array *arr, zend_array *symbol_tab } /* }}} */ -static zend_long php_extract_ref_prefix_all(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_ref_prefix_all(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; zend_ulong num_key; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; ZEND_HASH_FOREACH_KEY_VAL(arr, num_key, var_name, entry) { + zend_string *final_name; if (var_name) { if (ZSTR_LEN(var_name) == 0) { continue; } - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); + final_name = php_prefix_varname(prefix, var_name); } else { zend_string *str = zend_long_to_str(num_key); - php_prefix_varname(&final_name, prefix, ZSTR_VAL(str), ZSTR_LEN(str), 1); - zend_string_release_ex(str, 0); + final_name = php_prefix_varname(prefix, str); + zend_string_release_ex(str, false); } - if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; + if (php_valid_var_name(final_name)) { + /* Prefixed varname cannot be equal to "this" due to underscore between prefix and name */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + if (Z_ISREF_P(entry)) { + Z_ADDREF_P(entry); } else { - if (Z_ISREF_P(entry)) { - Z_ADDREF_P(entry); - } else { - ZVAL_MAKE_REF_EX(entry, 2); - } - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - zval_ptr_dtor(orig_var); - ZVAL_REF(orig_var, Z_REF_P(entry)); - } else { - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); + ZVAL_MAKE_REF_EX(entry, 2); + } + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + zval_ptr_dtor(orig_var); + ZVAL_REF(orig_var, Z_REF_P(entry)); + } else { + zend_hash_add_new(symbol_table, final_name, entry); } + count++; } - zval_ptr_dtor_str(&final_name); + zend_string_release_ex(final_name, false); } ZEND_HASH_FOREACH_END(); return count; } /* }}} */ -static zend_long php_extract_prefix_all(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_prefix_all(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; zend_ulong num_key; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; ZEND_HASH_FOREACH_KEY_VAL(arr, num_key, var_name, entry) { + zend_string *final_name; if (var_name) { if (ZSTR_LEN(var_name) == 0) { continue; } - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); + final_name = php_prefix_varname(prefix, var_name); } else { zend_string *str = zend_long_to_str(num_key); - php_prefix_varname(&final_name, prefix, ZSTR_VAL(str), ZSTR_LEN(str), 1); - zend_string_release_ex(str, 0); + final_name = php_prefix_varname(prefix, str); + zend_string_release_ex(str, false); } - if (php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; - } else { - ZVAL_DEREF(entry); - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); - if (UNEXPECTED(EG(exception))) { - zend_string_release_ex(Z_STR(final_name), 0); - return -1; - } - } else { - Z_TRY_ADDREF_P(entry); - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); + if (php_valid_var_name(final_name)) { + /* Prefixed varname cannot be equal to "this" due to underscore between prefix and name */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + ZVAL_DEREF(entry); + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); + if (UNEXPECTED(EG(exception))) { + zend_string_release_ex(final_name, false); + return -1; + } + } else { + Z_TRY_ADDREF_P(entry); + zend_hash_add_new(symbol_table, final_name, entry); } + count++; } - zval_ptr_dtor_str(&final_name); + zend_string_release_ex(final_name, false); } ZEND_HASH_FOREACH_END(); return count; } /* }}} */ -static zend_long php_extract_ref_prefix_invalid(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_ref_prefix_invalid(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; zend_ulong num_key; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; ZEND_HASH_FOREACH_KEY_VAL(arr, num_key, var_name, entry) { + zend_string *final_name; if (var_name) { - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name)) - || zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); - if (!php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - zval_ptr_dtor_str(&final_name); + if (!php_valid_var_name(var_name) || zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { + final_name = php_prefix_varname(prefix, var_name); + + if (!php_valid_var_name(final_name)) { + zend_string_release_ex(final_name, false); continue; } } else { - ZVAL_STR_COPY(&final_name, var_name); + final_name = zend_string_copy(var_name); } } else { zend_string *str = zend_long_to_str(num_key); - php_prefix_varname(&final_name, prefix, ZSTR_VAL(str), ZSTR_LEN(str), 1); - zend_string_release_ex(str, 0); - if (!php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - zval_ptr_dtor_str(&final_name); + final_name = php_prefix_varname(prefix, str); + zend_string_release_ex(str, false); + if (!php_valid_var_name(final_name)) { + zend_string_release_ex(final_name, false); continue; } } - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; + + /* We previously checked if the var name is "this" to prefix it */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + if (Z_ISREF_P(entry)) { + Z_ADDREF_P(entry); } else { - if (Z_ISREF_P(entry)) { - Z_ADDREF_P(entry); - } else { - ZVAL_MAKE_REF_EX(entry, 2); - } - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - zval_ptr_dtor(orig_var); - ZVAL_REF(orig_var, Z_REF_P(entry)); - } else { - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); + ZVAL_MAKE_REF_EX(entry, 2); + } + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + zval_ptr_dtor(orig_var); + ZVAL_REF(orig_var, Z_REF_P(entry)); + } else { + zend_hash_add_new(symbol_table, final_name, entry); } - zval_ptr_dtor_str(&final_name); + count++; + + zend_string_release_ex(final_name, false); } ZEND_HASH_FOREACH_END(); return count; } /* }}} */ -static zend_long php_extract_prefix_invalid(zend_array *arr, zend_array *symbol_table, zend_string *prefix) /* {{{ */ +static zend_long php_extract_prefix_invalid(const zend_array *arr, zend_array *symbol_table, const zend_string *prefix) /* {{{ */ { zend_long count = 0; zend_string *var_name; zend_ulong num_key; - zval *entry, *orig_var, final_name; + zval *entry, *orig_var; ZEND_HASH_FOREACH_KEY_VAL(arr, num_key, var_name, entry) { + zend_string *final_name; if (var_name) { - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name)) - || zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { - php_prefix_varname(&final_name, prefix, ZSTR_VAL(var_name), ZSTR_LEN(var_name), 1); - if (!php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - zval_ptr_dtor_str(&final_name); + if (!php_valid_var_name(var_name) || zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { + final_name = php_prefix_varname(prefix, var_name); + if (!php_valid_var_name(final_name)) { + zend_string_release_ex(final_name, false); continue; } } else { - ZVAL_STR_COPY(&final_name, var_name); + final_name = zend_string_copy(var_name); } } else { zend_string *str = zend_long_to_str(num_key); - php_prefix_varname(&final_name, prefix, ZSTR_VAL(str), ZSTR_LEN(str), 1); + final_name = php_prefix_varname(prefix, str); zend_string_release_ex(str, 0); - if (!php_valid_var_name(Z_STRVAL(final_name), Z_STRLEN(final_name))) { - zval_ptr_dtor_str(&final_name); + if (!php_valid_var_name(final_name)) { + zend_string_release_ex(final_name, false); continue; } } - if (zend_string_equals(Z_STR(final_name), ZSTR_KNOWN(ZEND_STR_THIS))) { - zend_throw_error(NULL, "Cannot re-assign $this"); - return -1; - } else { - ZVAL_DEREF(entry); - if ((orig_var = zend_hash_find(symbol_table, Z_STR(final_name))) != NULL) { - if (Z_TYPE_P(orig_var) == IS_INDIRECT) { - orig_var = Z_INDIRECT_P(orig_var); - } - ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); - if (UNEXPECTED(EG(exception))) { - zend_string_release_ex(Z_STR(final_name), 0); - return -1; - } - } else { - Z_TRY_ADDREF_P(entry); - zend_hash_add_new(symbol_table, Z_STR(final_name), entry); + + /* We previously checked if the var name is "this" to prefix it */ + ZEND_ASSERT(!zend_string_equals(final_name, ZSTR_KNOWN(ZEND_STR_THIS))); + + ZVAL_DEREF(entry); + if ((orig_var = zend_hash_find(symbol_table, final_name)) != NULL) { + if (Z_TYPE_P(orig_var) == IS_INDIRECT) { + orig_var = Z_INDIRECT_P(orig_var); } - count++; + ZEND_TRY_ASSIGN_COPY_EX(orig_var, entry, 0); + if (UNEXPECTED(EG(exception))) { + zend_string_release_ex(final_name, false); + return -1; + } + } else { + Z_TRY_ADDREF_P(entry); + zend_hash_add_new(symbol_table, final_name, entry); } - zval_ptr_dtor_str(&final_name); + count++; + + zend_string_release_ex(final_name, false); } ZEND_HASH_FOREACH_END(); return count; } /* }}} */ -static zend_long php_extract_ref_skip(zend_array *arr, zend_array *symbol_table) /* {{{ */ +static zend_long php_extract_ref_skip(const zend_array *arr, zend_array *symbol_table) /* {{{ */ { zend_long count = 0; zend_string *var_name; @@ -2497,7 +2370,7 @@ static zend_long php_extract_ref_skip(zend_array *arr, zend_array *symbol_table) if (!var_name) { continue; } - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { @@ -2532,7 +2405,7 @@ static zend_long php_extract_ref_skip(zend_array *arr, zend_array *symbol_table) } /* }}} */ -static zend_long php_extract_skip(zend_array *arr, zend_array *symbol_table) /* {{{ */ +static zend_long php_extract_skip(const zend_array *arr, zend_array *symbol_table) /* {{{ */ { zend_long count = 0; zend_string *var_name; @@ -2545,7 +2418,7 @@ static zend_long php_extract_skip(zend_array *arr, zend_array *symbol_table) /* if (!var_name) { continue; } - if (!php_valid_var_name(ZSTR_VAL(var_name), ZSTR_LEN(var_name))) { + if (!php_valid_var_name(var_name)) { continue; } if (zend_string_equals(var_name, ZSTR_KNOWN(ZEND_STR_THIS))) { @@ -2606,7 +2479,7 @@ PHP_FUNCTION(extract) } if (prefix) { - if (ZSTR_LEN(prefix) && !php_valid_var_name(ZSTR_VAL(prefix), ZSTR_LEN(prefix))) { + if (ZSTR_LEN(prefix) && !php_valid_var_name(prefix)) { zend_argument_value_error(3, "must be a valid identifier"); RETURN_THROWS(); } @@ -2830,16 +2703,19 @@ PHP_FUNCTION(array_fill_keys) ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), entry) { ZVAL_DEREF(entry); - Z_TRY_ADDREF_P(val); if (Z_TYPE_P(entry) == IS_LONG) { - zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL_P(entry), val); + zend_hash_index_add(Z_ARRVAL_P(return_value), Z_LVAL_P(entry), val); } else { zend_string *tmp_key; zend_string *key = zval_get_tmp_string(entry, &tmp_key); - zend_symtable_update(Z_ARRVAL_P(return_value), key, val); + zend_symtable_add(Z_ARRVAL_P(return_value), key, val); zend_tmp_string_release(tmp_key); } } ZEND_HASH_FOREACH_END(); + + if (Z_REFCOUNTED_P(val)) { + GC_ADDREF_EX(Z_COUNTED_P(val), zend_hash_num_elements(Z_ARRVAL_P(return_value))); + } } /* }}} */ @@ -3047,18 +2923,18 @@ PHP_FUNCTION(range) if (start_type == IS_STRING || end_type == IS_STRING) { php_error_docref(NULL, E_WARNING, "Argument #3 ($step) must be of type int when generating an array" " of characters, inputs converted to 0"); - } - if (UNEXPECTED(EG(exception))) { - RETURN_THROWS(); + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); + } } end_type = IS_LONG; start_type = IS_LONG; goto handle_numeric_inputs; } - /* Generate array of characters */ - unsigned char low = (unsigned char)Z_STRVAL_P(user_start)[0]; - unsigned char high = (unsigned char)Z_STRVAL_P(user_end)[0]; + /* Generate array of characters, as zero-extended ints to make bounds checking possible in the loop condition */ + int low = (unsigned char) Z_STRVAL_P(user_start)[0]; + int high = (unsigned char) Z_STRVAL_P(user_end)[0]; /* Decreasing char range */ if (low > high) { @@ -3069,12 +2945,9 @@ PHP_FUNCTION(range) array_init_size(return_value, (uint32_t)(((low - high) / step) + 1)); zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { - for (; low >= high; low -= (unsigned int)step) { + for (; low >= high; low -= step) { ZEND_HASH_FILL_SET_INTERNED_STR(ZSTR_CHAR(low)); ZEND_HASH_FILL_NEXT(); - if (((signed int)low - step) < 0) { - break; - } } } ZEND_HASH_FILL_END(); } else if (high > low) { /* Increasing char range */ @@ -3087,12 +2960,9 @@ PHP_FUNCTION(range) array_init_size(return_value, (uint32_t)(((high - low) / step) + 1)); zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { - for (; low <= high; low += (unsigned int)step) { + for (; low <= high; low += step) { ZEND_HASH_FILL_SET_INTERNED_STR(ZSTR_CHAR(low)); ZEND_HASH_FILL_NEXT(); - if (((signed int)low + step) > 255) { - break; - } } } ZEND_HASH_FILL_END(); } else { @@ -3750,18 +3620,34 @@ PHP_FUNCTION(array_unshift) ZEND_PARSE_PARAMETERS_END(); zend_hash_init(&new_hash, zend_hash_num_elements(Z_ARRVAL_P(stack)) + argc, NULL, ZVAL_PTR_DTOR, 0); - for (uint32_t i = 0; i < argc; i++) { - Z_TRY_ADDREF(args[i]); - zend_hash_next_index_insert_new(&new_hash, &args[i]); - } - ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(stack), key, value) { - if (key) { - zend_hash_add_new(&new_hash, key, value); - } else { - zend_hash_next_index_insert_new(&new_hash, value); + if (HT_IS_PACKED(Z_ARRVAL_P(stack))) { + zend_hash_real_init_packed(&new_hash); + + ZEND_HASH_FILL_PACKED(&new_hash) { + for (uint32_t i = 0; i < argc; i++) { + Z_TRY_ADDREF(args[i]); + ZEND_HASH_FILL_ADD(&args[i]); + } + + ZEND_HASH_PACKED_FOREACH_VAL(Z_ARRVAL_P(stack), value) { + ZEND_HASH_FILL_ADD(value); + } ZEND_HASH_FOREACH_END(); + } ZEND_HASH_FILL_END(); + } else { + for (uint32_t i = 0; i < argc; i++) { + Z_TRY_ADDREF(args[i]); + zend_hash_next_index_insert_new(&new_hash, &args[i]); } - } ZEND_HASH_FOREACH_END(); + + ZEND_HASH_MAP_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(stack), key, value) { + if (key) { + zend_hash_add_new(&new_hash, key, value); + } else { + zend_hash_next_index_insert_new(&new_hash, value); + } + } ZEND_HASH_FOREACH_END(); + } if (UNEXPECTED(HT_HAS_ITERATORS(Z_ARRVAL_P(stack)))) { zend_hash_iterators_advance(Z_ARRVAL_P(stack), argc); @@ -3860,7 +3746,6 @@ static inline Bucket* find_bucket_at_offset(HashTable* ht, zend_long offset) ZEND_ASSERT(offset >= 0 && offset <= ht->nNumOfElements); if (HT_IS_WITHOUT_HOLES(ht)) { /* There's no need to iterate over the array to filter out holes if there are no holes */ - /* This properly handles both packed and unpacked arrays. */ return ht->arData + offset; } /* Otherwise, this code has to iterate over the HashTable and skip holes in the array. */ @@ -3887,7 +3772,6 @@ static inline zval* find_packed_val_at_offset(HashTable* ht, zend_long offset) ZEND_ASSERT(offset >= 0 && offset <= ht->nNumOfElements); if (HT_IS_WITHOUT_HOLES(ht)) { /* There's no need to iterate over the array to filter out holes if there are no holes */ - /* This properly handles both packed and unpacked arrays. */ return ht->arPacked + offset; } /* Otherwise, this code has to iterate over the HashTable and skip holes in the array. */ @@ -4272,7 +4156,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET uint32_t argc, i; zval *src_entry; HashTable *src, *dest; - uint32_t count = 0; + uint64_t count = 0; ZEND_PARSE_PARAMETERS_START(0, -1) Z_PARAM_VARIADIC('+', args, argc) @@ -4292,6 +4176,11 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET count += zend_hash_num_elements(Z_ARRVAL_P(arg)); } + if (UNEXPECTED(count >= HT_MAX_SIZE)) { + zend_throw_error(NULL, "The total number of elements must be lower than %u", HT_MAX_SIZE); + RETURN_THROWS(); + } + if (argc == 2) { zval *ret = NULL; @@ -4303,22 +4192,20 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET if (ret) { if (HT_IS_PACKED(Z_ARRVAL_P(ret))) { if (HT_IS_WITHOUT_HOLES(Z_ARRVAL_P(ret))) { - ZVAL_COPY(return_value, ret); - return; + RETURN_COPY(ret); } } else { - bool copy = 1; + bool copy = true; zend_string *string_key; - ZEND_HASH_FOREACH_STR_KEY(Z_ARRVAL_P(ret), string_key) { + ZEND_HASH_MAP_FOREACH_STR_KEY(Z_ARRVAL_P(ret), string_key) { if (!string_key) { - copy = 0; + copy = false; break; } } ZEND_HASH_FOREACH_END(); if (copy) { - ZVAL_COPY(return_value, ret); - return; + RETURN_COPY(ret); } } } @@ -4333,7 +4220,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET if (HT_IS_WITHOUT_HOLES(src) && zend_may_modify_arg_in_place(arg)) { dest = src; in_place = true; - ZVAL_ARR(return_value, dest); + RETVAL_ARR(dest); } else { array_init_size(return_value, count); dest = Z_ARRVAL_P(return_value); @@ -5015,7 +4902,7 @@ PHP_FUNCTION(array_unique) return; } - cmp = php_get_data_compare_func_unstable(sort_type, 0); + cmp = php_get_data_compare_func_unstable(sort_type, false); bool in_place = zend_may_modify_arg_in_place(array); if (in_place) { @@ -5152,13 +5039,13 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa val = Z_REFVAL_P(val); } if (key == NULL) { - ok = 1; + ok = true; for (i = 1; i < argc; i++) { if ((data = zend_hash_index_find(Z_ARRVAL(args[i]), h)) == NULL || (intersect_data_compare_func && intersect_data_compare_func(val, data) != 0) ) { - ok = 0; + ok = false; break; } } @@ -5167,13 +5054,13 @@ static void php_array_intersect_key(INTERNAL_FUNCTION_PARAMETERS, int data_compa zend_hash_index_add_new(Z_ARRVAL_P(return_value), h, val); } } else { - ok = 1; + ok = true; for (i = 1; i < argc; i++) { if ((data = zend_hash_find_known_hash(Z_ARRVAL(args[i]), key)) == NULL || (intersect_data_compare_func && intersect_data_compare_func(val, data) != 0) ) { - ok = 0; + ok = false; break; } } @@ -5548,13 +5435,13 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty val = Z_REFVAL_P(val); } if (key == NULL) { - ok = 1; + ok = true; for (i = 1; i < argc; i++) { if ((data = zend_hash_index_find(Z_ARRVAL(args[i]), h)) != NULL && (!diff_data_compare_func || diff_data_compare_func(val, data) == 0) ) { - ok = 0; + ok = false; break; } } @@ -5563,13 +5450,13 @@ static void php_array_diff_key(INTERNAL_FUNCTION_PARAMETERS, int data_compare_ty zend_hash_index_add_new(Z_ARRVAL_P(return_value), h, val); } } else { - ok = 1; + ok = true; for (i = 1; i < argc; i++) { if ((data = zend_hash_find_known_hash(Z_ARRVAL(args[i]), key)) != NULL && (!diff_data_compare_func || diff_data_compare_func(val, data) == 0) ) { - ok = 0; + ok = false; break; } } @@ -6766,11 +6653,11 @@ PHP_FUNCTION(array_all) PHP_FUNCTION(array_map) { zval *arrays = NULL; - int n_arrays = 0; + uint32_t n_arrays = 0; zval result; zend_fcall_info fci; zend_fcall_info_cache fci_cache; - int i; + uint32_t i; uint32_t k, maxlen = 0; ZEND_PARSE_PARAMETERS_START(2, -1) @@ -6812,8 +6699,7 @@ PHP_FUNCTION(array_map) ZEND_IGNORE_VALUE(ret); if (UNEXPECTED(Z_ISUNDEF(result))) { ZEND_HASH_FILL_FINISH(); - zend_array_destroy(output); - RETURN_NULL(); + RETURN_THROWS(); } } else { ZVAL_UNDEF(&result); @@ -6836,8 +6722,7 @@ PHP_FUNCTION(array_map) ZEND_ASSERT(ret == SUCCESS); ZEND_IGNORE_VALUE(ret); if (UNEXPECTED(Z_ISUNDEF(result))) { - zend_array_destroy(output); - RETURN_NULL(); + RETURN_THROWS(); } if (str_key) { _zend_hash_append(output, str_key, &result); @@ -6847,12 +6732,9 @@ PHP_FUNCTION(array_map) } ZEND_HASH_FOREACH_END(); } } else { - uint32_t *array_pos = (HashPosition *)ecalloc(n_arrays, sizeof(HashPosition)); - for (i = 0; i < n_arrays; i++) { if (Z_TYPE(arrays[i]) != IS_ARRAY) { zend_argument_type_error(i + 2, "must be of type array, %s given", zend_zval_value_name(&arrays[i])); - efree(array_pos); RETURN_THROWS(); } if (zend_hash_num_elements(Z_ARRVAL(arrays[i])) > maxlen) { @@ -6863,6 +6745,7 @@ PHP_FUNCTION(array_map) array_init_size(return_value, maxlen); if (!ZEND_FCI_INITIALIZED(fci)) { + uint32_t *array_pos = ecalloc(n_arrays, sizeof(HashPosition)); zval zv; /* We iterate through all the arrays at once. */ @@ -6906,23 +6789,34 @@ PHP_FUNCTION(array_map) zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &result); } + + efree(array_pos); } else { zval *params = (zval *)safe_emalloc(n_arrays, sizeof(zval), 0); + /* Remember next starting point in the array, initialize those as zeros. */ + for (i = 0; i < n_arrays; i++) { + Z_EXTRA(params[i]) = 0; + } + + fci.retval = &result; + fci.param_count = n_arrays; + fci.params = params; + /* We iterate through all the arrays at once. */ for (k = 0; k < maxlen; k++) { for (i = 0; i < n_arrays; i++) { /* If this array still has elements, add the current one to the * parameter list, otherwise use null value. */ - uint32_t pos = array_pos[i]; + uint32_t pos = Z_EXTRA(params[i]); if (HT_IS_PACKED(Z_ARRVAL(arrays[i]))) { while (1) { if (pos >= Z_ARRVAL(arrays[i])->nNumUsed) { ZVAL_NULL(¶ms[i]); break; } else if (Z_TYPE(Z_ARRVAL(arrays[i])->arPacked[pos]) != IS_UNDEF) { - ZVAL_COPY(¶ms[i], &Z_ARRVAL(arrays[i])->arPacked[pos]); - array_pos[i] = pos + 1; + ZVAL_COPY_VALUE(¶ms[i], &Z_ARRVAL(arrays[i])->arPacked[pos]); + Z_EXTRA(params[i]) = pos + 1; break; } pos++; @@ -6933,8 +6827,8 @@ PHP_FUNCTION(array_map) ZVAL_NULL(¶ms[i]); break; } else if (Z_TYPE(Z_ARRVAL(arrays[i])->arData[pos].val) != IS_UNDEF) { - ZVAL_COPY(¶ms[i], &Z_ARRVAL(arrays[i])->arData[pos].val); - array_pos[i] = pos + 1; + ZVAL_COPY_VALUE(¶ms[i], &Z_ARRVAL(arrays[i])->arData[pos].val); + Z_EXTRA(params[i]) = pos + 1; break; } pos++; @@ -6942,26 +6836,13 @@ PHP_FUNCTION(array_map) } } - fci.retval = &result; - fci.param_count = n_arrays; - fci.params = params; - zend_result ret = zend_call_function(&fci, &fci_cache); ZEND_ASSERT(ret == SUCCESS); ZEND_IGNORE_VALUE(ret); if (Z_TYPE(result) == IS_UNDEF) { - efree(array_pos); - zend_array_destroy(Z_ARR_P(return_value)); - for (i = 0; i < n_arrays; i++) { - zval_ptr_dtor(¶ms[i]); - } efree(params); - RETURN_NULL(); - } else { - for (i = 0; i < n_arrays; i++) { - zval_ptr_dtor(¶ms[i]); - } + RETURN_THROWS(); } zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &result); @@ -6969,7 +6850,6 @@ PHP_FUNCTION(array_map) efree(params); } - efree(array_pos); } } /* }}} */ @@ -7045,8 +6925,7 @@ PHP_FUNCTION(array_chunk) if (size > num_in) { if (num_in == 0) { - RETVAL_EMPTY_ARRAY(); - return; + RETURN_EMPTY_ARRAY(); } size = num_in; } @@ -7054,12 +6933,11 @@ PHP_FUNCTION(array_chunk) array_init_size(return_value, (uint32_t)(((num_in - 1) / size) + 1)); zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); - ZVAL_UNDEF(&chunk); - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_key, str_key, entry) { /* If new chunk, create and initialize it. */ - if (Z_TYPE(chunk) == IS_UNDEF) { + if (current == 0) { array_init_size(&chunk, (uint32_t)size); + add_next_index_zval(return_value, &chunk); } /* Add entry to the chunk, preserving keys if necessary. */ @@ -7074,19 +6952,10 @@ PHP_FUNCTION(array_chunk) } zval_add_ref(entry); - /* If reached the chunk size, add it to the result array, and reset the - * pointer. */ if (++current == size) { - add_next_index_zval(return_value, &chunk); - ZVAL_UNDEF(&chunk); current = 0; } } ZEND_HASH_FOREACH_END(); - - /* Add the final chunk if there is one. */ - if (Z_TYPE(chunk) != IS_UNDEF) { - add_next_index_zval(return_value, &chunk); - } } /* }}} */ diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index e0c4230dae27c..8b72ffffc8379 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -561,7 +561,7 @@ PHP_FUNCTION(inet_pton) char buffer[17]; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(address, address_len) + Z_PARAM_PATH(address, address_len) ZEND_PARSE_PARAMETERS_END(); memset(buffer, 0, sizeof(buffer)); @@ -593,7 +593,7 @@ PHP_FUNCTION(ip2long) struct in_addr ip; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(addr, addr_len) + Z_PARAM_PATH(addr, addr_len) ZEND_PARSE_PARAMETERS_END(); if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) { @@ -2139,8 +2139,8 @@ PHP_FUNCTION(getservbyname) struct servent *serv; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_STRING(proto, proto_len) + Z_PARAM_PATH_STR(name) + Z_PARAM_PATH(proto, proto_len) ZEND_PARSE_PARAMETERS_END(); @@ -2183,7 +2183,7 @@ PHP_FUNCTION(getservbyport) ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(port) - Z_PARAM_STRING(proto, proto_len) + Z_PARAM_PATH(proto, proto_len) ZEND_PARSE_PARAMETERS_END(); serv = getservbyport(htons((unsigned short) port), proto); @@ -2210,7 +2210,7 @@ PHP_FUNCTION(getprotobyname) struct protoent *ent; ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STRING(name, name_len) + Z_PARAM_PATH(name, name_len) ZEND_PARSE_PARAMETERS_END(); ent = getprotobyname(name); diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index bad6fcf4e645e..8c8c6ba58dfd6 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -49,7 +49,6 @@ PHP_RSHUTDOWN_FUNCTION(browscap); /* Left for BC (not binary safe!) */ PHPAPI int _php_error_log(int opt_err, const char *message, const char *opt, const char *headers); PHPAPI int _php_error_log_ex(int opt_err, const char *message, size_t message_len, const char *opt, const char *headers); -PHPAPI int php_prefix_varname(zval *result, zend_string *prefix, const char *var_name, size_t var_name_len, bool add_underscore); typedef struct _php_basic_globals { HashTable *user_shutdown_function_names; diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 7913ca0e00194..e27dca069c55b 100644 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1606,6 +1606,12 @@ function min(mixed $value, mixed ...$values): mixed {} */ function max(mixed $value, mixed ...$values): mixed {} +/** + * @compile-time-eval + * @frameless-function {"arity": 3} + */ +function clamp(mixed $value, mixed $min, mixed $max): mixed {} + function array_walk(array|object &$array, callable $callback, mixed $arg = UNKNOWN): true {} function array_walk_recursive(array|object &$array, callable $callback, mixed $arg = UNKNOWN): true {} diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 668eca9aadc20..6f202c01463fd 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f6bf6cdd07080c01d3a0cb08d71409d05b1084f9 */ + * Stub hash: 1a1667a5c59111f096a758d5bb4aa7cf3ec09cfe */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0) @@ -138,6 +138,12 @@ ZEND_END_ARG_INFO() #define arginfo_max arginfo_min +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_clamp, 0, 3, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, min, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, max, IS_MIXED, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_walk, 0, 2, IS_TRUE, 0) ZEND_ARG_TYPE_MASK(1, array, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL) ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0) @@ -2197,6 +2203,12 @@ static const zend_frameless_function_info frameless_function_infos_max[] = { { 0 }, }; +ZEND_FRAMELESS_FUNCTION(clamp, 3); +static const zend_frameless_function_info frameless_function_infos_clamp[] = { + { ZEND_FRAMELESS_FUNCTION_NAME(clamp, 3), 3 }, + { 0 }, +}; + ZEND_FRAMELESS_FUNCTION(in_array, 2); ZEND_FRAMELESS_FUNCTION(in_array, 3); static const zend_frameless_function_info frameless_function_infos_in_array[] = { @@ -2332,6 +2344,7 @@ ZEND_FUNCTION(current); ZEND_FUNCTION(key); ZEND_FUNCTION(min); ZEND_FUNCTION(max); +ZEND_FUNCTION(clamp); ZEND_FUNCTION(array_walk); ZEND_FUNCTION(array_walk_recursive); ZEND_FUNCTION(in_array); @@ -2925,6 +2938,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(key, arginfo_key) ZEND_RAW_FENTRY("min", zif_min, arginfo_min, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_min, NULL) ZEND_RAW_FENTRY("max", zif_max, arginfo_max, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_max, NULL) + ZEND_RAW_FENTRY("clamp", zif_clamp, arginfo_clamp, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_clamp, NULL) ZEND_FE(array_walk, arginfo_array_walk) ZEND_FE(array_walk_recursive, arginfo_array_walk_recursive) ZEND_RAW_FENTRY("in_array", zif_in_array, arginfo_in_array, ZEND_ACC_COMPILE_TIME_EVAL, frameless_function_infos_in_array, NULL) @@ -3971,9 +3985,9 @@ static zend_class_entry *register_class___PHP_Incomplete_Class(void) INIT_CLASS_ENTRY(ce, "__PHP_Incomplete_Class", NULL); class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES); - zend_string *attribute_name_AllowDynamicProperties_class___PHP_Incomplete_Class_0 = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, 1); + zend_string *attribute_name_AllowDynamicProperties_class___PHP_Incomplete_Class_0 = zend_string_init_interned("AllowDynamicProperties", sizeof("AllowDynamicProperties") - 1, true); zend_add_class_attribute(class_entry, attribute_name_AllowDynamicProperties_class___PHP_Incomplete_Class_0, 0); - zend_string_release(attribute_name_AllowDynamicProperties_class___PHP_Incomplete_Class_0); + zend_string_release_ex(attribute_name_AllowDynamicProperties_class___PHP_Incomplete_Class_0, true); return class_entry; } diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 685fe09357d06..5009c7793688c 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -277,7 +277,7 @@ static HashTable *browscap_entry_to_array(browser_data *bdata, browscap_entry *e zval tmp; HashTable *ht = zend_new_array(2 + (entry->parent ? 1 : 0) + (entry->kv_end - entry->kv_start)); - ZVAL_STR(&tmp, browscap_convert_pattern(entry->pattern, 0)); + ZVAL_STR(&tmp, browscap_convert_pattern(entry->pattern, false)); zend_string *key = ZSTR_INIT_LITERAL("browser_name_regex", 0); ZSTR_H(key) = zend_inline_hash_func("browser_name_regex", sizeof("browser_name_regex")-1); zend_hash_add_new(ht, key, &tmp); @@ -485,7 +485,7 @@ PHP_INI_MH(OnChangeBrowscap) } else if (stage == PHP_INI_STAGE_ACTIVATE) { browser_data *bdata = &BROWSCAP_G(activation_bdata); if (bdata->filename[0] != '\0') { - browscap_bdata_dtor(bdata, 0); + browscap_bdata_dtor(bdata, false); } if (VCWD_REALPATH(ZSTR_VAL(new_value), bdata->filename) == NULL) { return FAILURE; @@ -520,7 +520,7 @@ PHP_RSHUTDOWN_FUNCTION(browscap) /* {{{ */ { browser_data *bdata = &BROWSCAP_G(activation_bdata); if (bdata->filename[0] != '\0') { - browscap_bdata_dtor(bdata, 0); + browscap_bdata_dtor(bdata, false); } return SUCCESS; @@ -529,7 +529,7 @@ PHP_RSHUTDOWN_FUNCTION(browscap) /* {{{ */ PHP_MSHUTDOWN_FUNCTION(browscap) /* {{{ */ { - browscap_bdata_dtor(&global_bdata, 1); + browscap_bdata_dtor(&global_bdata, true); return SUCCESS; } diff --git a/ext/standard/crypt_sha256.c b/ext/standard/crypt_sha256.c index 5bc3e93fe15fb..2673dcf2b08e8 100644 --- a/ext/standard/crypt_sha256.c +++ b/ext/standard/crypt_sha256.c @@ -338,7 +338,7 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b char *s_bytes; /* Default number of rounds. */ size_t rounds = ROUNDS_DEFAULT; - bool rounds_custom = 0; + bool rounds_custom = false; /* Find beginning of salt string. The prefix should normally always be present. Just in case it is not. */ @@ -358,7 +358,7 @@ char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int b } rounds = srounds; - rounds_custom = 1; + rounds_custom = true; } } diff --git a/ext/standard/crypt_sha512.c b/ext/standard/crypt_sha512.c index e6410fb916228..e8cedaa55c205 100644 --- a/ext/standard/crypt_sha512.c +++ b/ext/standard/crypt_sha512.c @@ -375,7 +375,7 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) char *s_bytes; /* Default number of rounds. */ size_t rounds = ROUNDS_DEFAULT; - bool rounds_custom = 0; + bool rounds_custom = false; /* Find beginning of salt string. The prefix should normally always be present. Just in case it is not. */ @@ -396,7 +396,7 @@ php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) } rounds = srounds; - rounds_custom = 1; + rounds_custom = true; } } diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 918b92fab456f..7c1f8efe68875 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -558,11 +558,15 @@ PHP_FUNCTION(scandir) RETURN_FALSE; } - array_init(return_value); + array_init_size(return_value, n); + zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); - for (i = 0; i < n; i++) { - add_next_index_str(return_value, namelist[i]); - } + ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { + for (i = 0; i < n; i++) { + ZEND_HASH_FILL_SET_STR(namelist[i]); + ZEND_HASH_FILL_NEXT(); + } + } ZEND_HASH_FILL_END(); if (n) { efree(namelist); diff --git a/ext/standard/dir_arginfo.h b/ext/standard/dir_arginfo.h index 703088d1eb0d5..d4cfc19556353 100644 --- a/ext/standard/dir_arginfo.h +++ b/ext/standard/dir_arginfo.h @@ -66,9 +66,9 @@ static zend_class_entry *register_class_Directory(void) zval property_handle_default_value; ZVAL_UNDEF(&property_handle_default_value); - zend_string *property_handle_name = zend_string_init("handle", sizeof("handle") - 1, 1); + zend_string *property_handle_name = zend_string_init("handle", sizeof("handle") - 1, true); zend_declare_typed_property(class_entry, property_handle_name, &property_handle_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_handle_name); + zend_string_release_ex(property_handle_name, true); return class_entry; } diff --git a/ext/standard/dns.c b/ext/standard/dns.c index bd5720210fdaf..a574d8dd9aeb8 100644 --- a/ext/standard/dns.c +++ b/ext/standard/dns.c @@ -382,7 +382,7 @@ PHP_FUNCTION(dns_check_record) #endif ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STRING(hostname, hostname_len) + Z_PARAM_PATH(hostname, hostname_len) Z_PARAM_OPTIONAL Z_PARAM_STR(rectype) ZEND_PARSE_PARAMETERS_END(); @@ -829,7 +829,7 @@ PHP_FUNCTION(dns_get_record) bool raw = 0; ZEND_PARSE_PARAMETERS_START(1, 5) - Z_PARAM_STRING(hostname, hostname_len) + Z_PARAM_PATH(hostname, hostname_len) Z_PARAM_OPTIONAL Z_PARAM_LONG(type_param) Z_PARAM_ZVAL(authns) @@ -1067,7 +1067,7 @@ PHP_FUNCTION(dns_get_mx) #endif ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STRING(hostname, hostname_len) + Z_PARAM_PATH(hostname, hostname_len) Z_PARAM_ZVAL(mx_list) Z_PARAM_OPTIONAL Z_PARAM_ZVAL(weight_list) diff --git a/ext/standard/dns_win32.c b/ext/standard/dns_win32.c index 26c6487902e1a..1f7c6c0146e47 100644 --- a/ext/standard/dns_win32.c +++ b/ext/standard/dns_win32.c @@ -32,7 +32,7 @@ PHP_FUNCTION(dns_get_mx) /* {{{ */ DNS_STATUS status; /* Return value of DnsQuery_A() function */ PDNS_RECORD pResult, pRec; /* Pointer to DNS_RECORD structure */ - if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz|z", &hostname, &hostname_len, &mx_list, &weight_list) == FAILURE) { RETURN_THROWS(); } @@ -86,7 +86,7 @@ PHP_FUNCTION(dns_check_record) DNS_STATUS status; /* Return value of DnsQuery_A() function */ PDNS_RECORD pResult; /* Pointer to DNS_RECORD structure */ - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|S", &hostname, &hostname_len, &rectype) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|S", &hostname, &hostname_len, &rectype) == FAILURE) { RETURN_THROWS(); } @@ -341,9 +341,9 @@ PHP_FUNCTION(dns_get_record) zend_long type_param = PHP_DNS_ANY; zval *authns = NULL, *addtl = NULL; int type, type_to_fetch, first_query = 1, store_results = 1; - bool raw = 0; + bool raw = false; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lz!z!b", + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|lz!z!b", &hostname, &hostname_len, &type_param, &authns, &addtl, &raw) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/standard/file.c b/ext/standard/file.c index ab6ed4fbadd2d..bd6ee252875e5 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -663,11 +663,10 @@ PHP_FUNCTION(file) p = e; goto parse_eol; } - } - if (target_buf) { - zend_string_free(target_buf); + zend_string_efree(target_buf); } + php_stream_close(stream); } /* }}} */ @@ -961,7 +960,8 @@ PHP_FUNCTION(fscanf) efree(buf); if (SCAN_ERROR_WRONG_PARAM_COUNT == result) { - WRONG_PARAM_COUNT; + zend_wrong_param_count(); + RETURN_THROWS(); } } /* }}} */ @@ -1554,7 +1554,6 @@ PHPAPI PHP_FUNCTION(fread) str = php_stream_read_to_str(stream, len); if (!str) { - zval_ptr_dtor_str(return_value); RETURN_FALSE; } diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index b2c287c02900c..b0fbfcc89099f 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -103,7 +103,7 @@ php_sprintf_appendstring(zend_string **buffer, size_t *pos, char *add, if (req_size > ZSTR_LEN(*buffer)) { size_t size = ZSTR_LEN(*buffer); while (req_size > size) { - if (size > ZEND_SIZE_MAX/2) { + if (size > SIZE_MAX/2) { zend_error_noreturn(E_ERROR, "Field width %zd is too long", req_size); } size <<= 1; @@ -298,9 +298,9 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos, char exp_char = fmt == 'G' || fmt == 'H' ? 'E' : 'e'; /* We use &num_buf[ 1 ], so that we have room for the sign. */ s = zend_gcvt(number, precision, decimal_point, exp_char, &num_buf[1]); - is_negative = 0; + is_negative = false; if (*s == '-') { - is_negative = 1; + is_negative = true; s = &num_buf[1]; } else if (always_sign) { num_buf[0] = '+'; diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index b36d232de9534..d1bb3aeeccd68 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -421,7 +421,7 @@ php_stream * php_stream_url_wrap_ftp(php_stream_wrapper *wrapper, const char *pa php_stream *reuseid=NULL; size_t file_size = 0; zval *tmpzval; - bool allow_overwrite = 0; + bool allow_overwrite = false; int8_t read_write = 0; char *transport; int transport_len; diff --git a/ext/standard/head.c b/ext/standard/head.c index 087ba6a34806c..76ba89dc01713 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -213,13 +213,13 @@ static zend_result php_head_parse_cookie_options_array(HashTable *options, zend_ } else if (zend_string_equals_literal_ci(key, "domain")) { *domain = zval_get_string(value); } else if (zend_string_equals_literal_ci(key, "secure")) { - *secure = zval_is_true(value); + *secure = zend_is_true(value); } else if (zend_string_equals_literal_ci(key, "httponly")) { - *httponly = zval_is_true(value); + *httponly = zend_is_true(value); } else if (zend_string_equals_literal_ci(key, "samesite")) { *samesite = zval_get_string(value); } else if (zend_string_equals_literal_ci(key, "partitioned")) { - *partitioned = zval_is_true(value); + *partitioned = zend_is_true(value); } else { zend_value_error("%s(): option \"%s\" is invalid", get_active_function_name(), ZSTR_VAL(key)); return FAILURE; diff --git a/ext/standard/hrtime.c b/ext/standard/hrtime.c index 10853493b6390..652531bd3ed4f 100644 --- a/ext/standard/hrtime.c +++ b/ext/standard/hrtime.c @@ -31,9 +31,9 @@ } while (0) #endif #define PHP_RETURN_HRTIME(t) do { \ - char _a[ZEND_LTOA_BUF_LEN]; \ + char _a[65]; \ double _d; \ - HRTIME_U64A(t, _a, ZEND_LTOA_BUF_LEN); \ + HRTIME_U64A(t, _a, sizeof(_a)); \ _d = zend_strtod(_a, NULL); \ RETURN_DOUBLE(_d); \ } while (0) diff --git a/ext/standard/html.c b/ext/standard/html.c index af6e6ec94443b..eaba9ddffc1d0 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1017,7 +1017,7 @@ PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int fl } if (all) { - charset = determine_charset(hint_charset, /* quiet */ 0); + charset = determine_charset(hint_charset, /* quiet */ false); } else { charset = cs_8859_1; /* charset shouldn't matter, use ISO-8859-1 for performance */ } @@ -1043,7 +1043,7 @@ PHPAPI zend_string *php_unescape_html_entities(zend_string *str, int all, int fl PHPAPI zend_string *php_escape_html_entities(const unsigned char *old, size_t oldlen, int all, int flags, const char *hint_charset) { - return php_escape_html_entities_ex(old, oldlen, all, flags, hint_charset, 1, /* quiet */ 0); + return php_escape_html_entities_ex(old, oldlen, all, flags, hint_charset, true, /* quiet */ false); } /* {{{ find_entity_for_char */ diff --git a/ext/standard/http.c b/ext/standard/http.c index 9aae62479e24c..47443f74ffe98 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -124,14 +124,14 @@ PHPAPI void php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, } ZEND_HASH_FOREACH_KEY_VAL(ht, idx, key, zdata) { - bool is_dynamic = 1; + bool is_dynamic = true; if (Z_TYPE_P(zdata) == IS_INDIRECT) { zdata = Z_INDIRECT_P(zdata); if (Z_ISUNDEF_P(zdata)) { continue; } - is_dynamic = 0; + is_dynamic = false; } /* handling for private & protected object properties */ diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index e342c77666662..da150381f43f3 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -111,11 +111,11 @@ static bool check_has_header(const char *headers, const char *header) { const char *s = headers; while ((s = strstr(s, header))) { if (s == headers || (*(s-1) == '\n' && *(s-2) == '\r')) { - return 1; + return true; } s++; } - return 0; + return false; } static zend_result php_stream_handle_proxy_authorization_header(const char *s, smart_str *header) @@ -159,7 +159,7 @@ static void php_stream_http_response_header_info_init( php_stream_http_response_header_info *header_info) { memset(header_info, 0, sizeof(php_stream_http_response_header_info)); - header_info->follow_location = 1; + header_info->follow_location = true; } /* Trim white spaces from response header line and update its length */ @@ -276,14 +276,14 @@ static zend_string *php_stream_http_response_headers_parse(php_stream_wrapper *w if (!strncasecmp(last_header_line, "Location:", sizeof("Location:")-1)) { /* Check if the location should be followed. */ if (context && (tmpzval = php_stream_context_get_option(context, "http", "follow_location")) != NULL) { - header_info->follow_location = zval_is_true(tmpzval); + header_info->follow_location = zend_is_true(tmpzval); } else if (!((response_code >= 300 && response_code < 304) || 307 == response_code || 308 == response_code)) { /* The redirection should not be automatic if follow_location is not set and * response_code not in (300, 301, 302, 303 and 307) * see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1 * RFC 7238 defines 308: http://tools.ietf.org/html/rfc7238 */ - header_info->follow_location = 0; + header_info->follow_location = false; } size_t last_header_value_len = strlen(last_header_value); if (last_header_value_len > HTTP_HEADER_MAX_LOCATION_SIZE) { @@ -603,7 +603,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, redirect_max = (int)zval_get_long(tmpzval); } - custom_request_method = 0; + custom_request_method = false; if (context && (tmpzval = php_stream_context_get_option(context, "http", "method")) != NULL) { if (Z_TYPE_P(tmpzval) == IS_STRING && Z_STRLEN_P(tmpzval) > 0) { /* As per the RFC, automatically redirected requests MUST NOT use other methods than @@ -612,7 +612,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, || zend_string_equals_literal(Z_STR_P(tmpzval), "GET") || zend_string_equals_literal(Z_STR_P(tmpzval), "HEAD") ) { - custom_request_method = 1; + custom_request_method = true; smart_str_append(&req_buf, Z_STR_P(tmpzval)); smart_str_appendc(&req_buf, ' '); } diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c index 44dd33bab10ac..5078c0813ccb8 100644 --- a/ext/standard/iptc.c +++ b/ext/standard/iptc.c @@ -308,7 +308,6 @@ PHP_FUNCTION(iptcparse) unsigned char *buffer, recnum, dataset; char *str, key[16]; size_t str_len; - zval values, *element; ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STRING(str, str_len) @@ -357,10 +356,9 @@ PHP_FUNCTION(iptcparse) array_init(return_value); } - if ((element = zend_hash_str_find(Z_ARRVAL_P(return_value), key, strlen(key))) == NULL) { - array_init(&values); - - element = zend_hash_str_update(Z_ARRVAL_P(return_value), key, strlen(key), &values); + zval *element = zend_hash_str_lookup(Z_ARRVAL_P(return_value), key, strlen(key)); + if (Z_ISNULL_P(element)) { + array_init(element); } add_next_index_stringl(element, (char *) buffer+inx, len); diff --git a/ext/standard/mail.c b/ext/standard/mail.c index 8c8b4e6717e0b..b631d12e4c7e2 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -218,7 +218,8 @@ PHPAPI zend_string *php_mail_build_headers(HashTable *headers) ZEND_HASH_FOREACH_KEY_VAL(headers, idx, key, val) { if (!key) { zend_type_error("Header name cannot be numeric, " ZEND_LONG_FMT " given", idx); - break; + smart_str_free(&s); + return NULL; } ZVAL_DEREF(val); /* https://tools.ietf.org/html/rfc2822#section-3.6 */ diff --git a/ext/standard/math.c b/ext/standard/math.c index 142d473864f75..95384c06588ac 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -389,6 +389,62 @@ PHP_FUNCTION(round) } /* }}} */ +/* Return the given value if in range of min and max */ +static void php_math_clamp(zval *return_value, zval *value, zval *min, zval *max) +{ + if (Z_TYPE_P(min) == IS_DOUBLE && UNEXPECTED(zend_isnan(Z_DVAL_P(min)))) { + zend_argument_value_error(2, "must not be NAN"); + RETURN_THROWS(); + } + + if (Z_TYPE_P(max) == IS_DOUBLE && UNEXPECTED(zend_isnan(Z_DVAL_P(max)))) { + zend_argument_value_error(3, "must not be NAN"); + RETURN_THROWS(); + } + + if (zend_compare(max, min) == -1) { + zend_argument_value_error(2, "must be smaller than or equal to argument #3 ($max)"); + RETURN_THROWS(); + } + + if (zend_compare(max, value) == -1) { + RETURN_COPY(max); + } + + if (zend_compare(value, min) == -1) { + RETURN_COPY(min); + } + + RETURN_COPY(value); +} + +/* {{{ Return the given value if in range of min and max */ +PHP_FUNCTION(clamp) +{ + zval *zvalue, *zmin, *zmax; + + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(zvalue) + Z_PARAM_ZVAL(zmin) + Z_PARAM_ZVAL(zmax) + ZEND_PARSE_PARAMETERS_END(); + + php_math_clamp(return_value, zvalue, zmin, zmax); +} +/* }}} */ + +/* {{{ Return the given value if in range of min and max */ +ZEND_FRAMELESS_FUNCTION(clamp, 3) +{ + zval *zvalue, *zmin, *zmax; + Z_FLF_PARAM_ZVAL(1, zvalue); + Z_FLF_PARAM_ZVAL(2, zmin); + Z_FLF_PARAM_ZVAL(3, zmax); + + php_math_clamp(return_value, zvalue, zmin, zmax); +} +/* }}} */ + /* {{{ Returns the sine of the number in radians */ PHP_FUNCTION(sin) { diff --git a/ext/standard/password.c b/ext/standard/password.c index 99dea810806cd..a8aab315657c0 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -140,7 +140,7 @@ static bool php_password_bcrypt_needs_rehash(const zend_string *hash, zend_array if (!php_password_bcrypt_valid(hash)) { /* Should never get called this way. */ - return 1; + return true; } sscanf(ZSTR_VAL(hash), "$2y$" ZEND_LONG_FMT "$", &old_cost); @@ -156,12 +156,12 @@ static bool php_password_bcrypt_verify(const zend_string *password, const zend_s zend_string *ret = php_crypt(ZSTR_VAL(password), (int)ZSTR_LEN(password), ZSTR_VAL(hash), (int)ZSTR_LEN(hash), 1); if (!ret) { - return 0; + return false; } if (ZSTR_LEN(hash) < 13) { zend_string_free(ret); - return 0; + return false; } /* We're using this method instead of == in order to provide diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 51c537de6e628..ef62329ba8eda 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -29,9 +29,9 @@ PHP_MINIT_FUNCTION(string_intrin); #endif #define strnatcmp(a, b) \ - strnatcmp_ex(a, strlen(a), b, strlen(b), 0) + strnatcmp_ex(a, strlen(a), b, strlen(b), false) #define strnatcasecmp(a, b) \ - strnatcmp_ex(a, strlen(a), b, strlen(b), 1) + strnatcmp_ex(a, strlen(a), b, strlen(b), true) PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len, bool is_case_insensitive); PHPAPI struct lconv *localeconv_r(struct lconv *out); PHPAPI char *php_strtr(char *str, size_t len, const char *str_from, const char *str_to, size_t trlen); diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 690e23e0d3538..55f4dd4849587 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -503,7 +503,7 @@ typedef struct _descriptorspec_item { } descriptorspec_item; static zend_string *get_valid_arg_string(zval *zv, uint32_t elem_num) { - zend_string *str = zval_get_string(zv); + zend_string *str = zval_try_get_string(zv); if (!str) { return NULL; } @@ -643,7 +643,7 @@ static zend_string *create_win_command_from_args(HashTable *args) append_win_escaped_arg(&str, arg_str, !is_prog_name && is_cmd_execution); - is_prog_name = 0; + is_prog_name = false; zend_string_release(arg_str); } ZEND_HASH_FOREACH_END(); smart_str_0(&str); diff --git a/ext/standard/string.c b/ext/standard/string.c index 8b76a179061cc..0b7d5be1a2576 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1348,15 +1348,15 @@ static bool _is_basename_start(const char *start, const char *pos) && *(pos-1) != '/' && *(pos-1) != '\\') { if (pos - start == 1) { - return 1; + return true; } else if (*(pos-2) == '/' || *(pos-2) == '\\') { - return 1; + return true; } else if (*(pos-2) == ':' && _is_basename_start(start, pos - 2)) { - return 1; + return true; } } - return 0; + return false; } #endif @@ -2109,13 +2109,11 @@ PHP_FUNCTION(strripos) needle_dup = zend_string_tolower(needle); if ((found = (char *)zend_memnrstr(p, ZSTR_VAL(needle_dup), ZSTR_LEN(needle_dup), e))) { RETVAL_LONG(found - ZSTR_VAL(haystack_dup)); - zend_string_release_ex(needle_dup, 0); - zend_string_release_ex(haystack_dup, 0); } else { - zend_string_release_ex(needle_dup, 0); - zend_string_release_ex(haystack_dup, 0); - RETURN_FALSE; + RETVAL_FALSE; } + zend_string_release_ex(needle_dup, false); + zend_string_release_ex(haystack_dup, false); } /* }}} */ @@ -2972,7 +2970,7 @@ static void php_strtr_array_ex(zval *return_value, zend_string *input, HashTable len = ZSTR_LEN(key_used); if (UNEXPECTED(len > slen)) { /* skip long patterns */ - zend_string_release(key_used); + zend_string_release_ex(key_used, false); continue; } if (len > maxlen) { @@ -4957,7 +4955,7 @@ PHP_FUNCTION(setlocale) for (uint32_t i = 0; i < num_args; i++) { if (UNEXPECTED(Z_TYPE(args[i]) != IS_ARRAY && !zend_parse_arg_str(&args[i], &strings[i], true, i + 2))) { - zend_wrong_parameter_type_error(i + 2, Z_EXPECTED_ARRAY_OR_STRING, &args[i]); + zend_wrong_parameter_type_error(i + 2, Z_EXPECTED_ARRAY_OR_STRING_OR_NULL, &args[i]); goto out; } } @@ -5036,11 +5034,11 @@ static bool php_tag_find(char *tag, size_t len, const char *set) { char c, *n; const char *t; int state = 0; - bool done = 0; + bool done = false; char *norm; if (len == 0) { - return 0; + return false; } norm = emalloc(len+1); @@ -5059,7 +5057,7 @@ static bool php_tag_find(char *tag, size_t len, const char *set) { *(n++) = c; break; case '>': - done =1; + done = true; break; default: if (!isspace((int)c)) { @@ -5071,7 +5069,7 @@ static bool php_tag_find(char *tag, size_t len, const char *set) { } } else { if (state == 1) - done=1; + done = true; } break; } @@ -5080,9 +5078,9 @@ static bool php_tag_find(char *tag, size_t len, const char *set) { *(n++) = '>'; *n = '\0'; if (strstr(set, norm)) { - done=1; + done = true; } else { - done=0; + done = false; } efree(norm); return done; @@ -5091,7 +5089,7 @@ static bool php_tag_find(char *tag, size_t len, const char *set) { PHPAPI size_t php_strip_tags(char *rbuf, size_t len, const char *allow, size_t allow_len) /* {{{ */ { - return php_strip_tags_ex(rbuf, len, allow, allow_len, 0); + return php_strip_tags_ex(rbuf, len, allow, allow_len, false); } /* }}} */ @@ -5756,6 +5754,27 @@ PHP_FUNCTION(substr_count) } /* }}} */ +static void php_str_pad_fill(zend_string *result, size_t pad_chars, const char *pad_str, size_t pad_str_len) { + char *p = ZSTR_VAL(result) + ZSTR_LEN(result); + + if (pad_str_len == 1) { + memset(p, pad_str[0], pad_chars); + ZSTR_LEN(result) += pad_chars; + return; + } + + const char *end = p + pad_chars; + while (p + pad_str_len <= end) { + p = zend_mempcpy(p, pad_str, pad_str_len); + } + + if (p < end) { + memcpy(p, pad_str, end - p); + } + + ZSTR_LEN(result) += pad_chars; +} + /* {{{ Returns input string padded on the left or right to specified length with pad_string */ PHP_FUNCTION(str_pad) { @@ -5768,7 +5787,7 @@ PHP_FUNCTION(str_pad) char *pad_str = " "; /* Pointer to padding string */ size_t pad_str_len = 1; zend_long pad_type_val = PHP_STR_PAD_RIGHT; /* The padding type value */ - size_t i, left_pad=0, right_pad=0; + size_t left_pad=0, right_pad=0; zend_string *result = NULL; /* Resulting string */ ZEND_PARSE_PARAMETERS_START(2, 4) @@ -5818,16 +5837,18 @@ PHP_FUNCTION(str_pad) } /* First we pad on the left. */ - for (i = 0; i < left_pad; i++) - ZSTR_VAL(result)[ZSTR_LEN(result)++] = pad_str[i % pad_str_len]; + if (left_pad > 0) { + php_str_pad_fill(result, left_pad, pad_str, pad_str_len); + } /* Then we copy the input string. */ memcpy(ZSTR_VAL(result) + ZSTR_LEN(result), ZSTR_VAL(input), ZSTR_LEN(input)); ZSTR_LEN(result) += ZSTR_LEN(input); /* Finally, we pad on the right. */ - for (i = 0; i < right_pad; i++) - ZSTR_VAL(result)[ZSTR_LEN(result)++] = pad_str[i % pad_str_len]; + if (right_pad > 0) { + php_str_pad_fill(result, right_pad, pad_str, pad_str_len); + } ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0'; @@ -5852,7 +5873,8 @@ PHP_FUNCTION(sscanf) result = php_sscanf_internal(str, format, num_args, args, 0, return_value); if (SCAN_ERROR_WRONG_PARAM_COUNT == result) { - WRONG_PARAM_COUNT; + zend_wrong_param_count(); + RETURN_THROWS(); } } /* }}} */ @@ -6131,23 +6153,31 @@ PHP_FUNCTION(str_split) } array_init_size(return_value, 1); - add_next_index_stringl(return_value, ZSTR_VAL(str), ZSTR_LEN(str)); + GC_TRY_ADDREF(str); + add_next_index_str(return_value, str); return; } array_init_size(return_value, (uint32_t)(((ZSTR_LEN(str) - 1) / split_length) + 1)); + zend_hash_real_init_packed(Z_ARRVAL_P(return_value)); n_reg_segments = ZSTR_LEN(str) / split_length; p = ZSTR_VAL(str); - while (n_reg_segments-- > 0) { - add_next_index_stringl(return_value, p, split_length); - p += split_length; - } + ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) { + zval zv; + while (n_reg_segments-- > 0) { + ZEND_ASSERT(split_length > 0); + ZVAL_STRINGL_FAST(&zv, p, split_length); + ZEND_HASH_FILL_ADD(&zv); + p += split_length; + } - if (p != (ZSTR_VAL(str) + ZSTR_LEN(str))) { - add_next_index_stringl(return_value, p, (ZSTR_VAL(str) + ZSTR_LEN(str) - p)); - } + if (p != (ZSTR_VAL(str) + ZSTR_LEN(str))) { + ZVAL_STRINGL_FAST(&zv, p, (ZSTR_VAL(str) + ZSTR_LEN(str) - p)); + ZEND_HASH_FILL_ADD(&zv); + } + } ZEND_HASH_FILL_END(); } /* }}} */ diff --git a/ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt b/ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt new file mode 100644 index 0000000000000..2e3e85357e13c --- /dev/null +++ b/ext/standard/tests/array/GHSA-h96m-rvf9-jgm2.phpt @@ -0,0 +1,16 @@ +--TEST-- +GHSA-h96m-rvf9-jgm2 +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECTF-- +The total number of elements must be lower than %d diff --git a/ext/standard/tests/array/extract_negative_keys.phpt b/ext/standard/tests/array/extract_negative_keys.phpt new file mode 100644 index 0000000000000..55fce2a656570 --- /dev/null +++ b/ext/standard/tests/array/extract_negative_keys.phpt @@ -0,0 +1,31 @@ +--TEST-- +extract() with negative keys +--FILE-- + 'hello', 'world', 2 => 'positive', 'check' => 'extracted']; + +function foo(array $a) { + extract($a, EXTR_PREFIX_ALL, 'prefix'); + var_dump(get_defined_vars()); +} + +foo($a); +?> +--EXPECT-- +array(3) { + ["a"]=> + array(4) { + [-5]=> + string(5) "hello" + [-4]=> + string(5) "world" + [2]=> + string(8) "positive" + ["check"]=> + string(9) "extracted" + } + ["prefix_2"]=> + string(8) "positive" + ["prefix_check"]=> + string(9) "extracted" +} diff --git a/ext/standard/tests/array/extract_negative_keys2.phpt b/ext/standard/tests/array/extract_negative_keys2.phpt new file mode 100644 index 0000000000000..dd2a1fa7a18a4 --- /dev/null +++ b/ext/standard/tests/array/extract_negative_keys2.phpt @@ -0,0 +1,11 @@ +--TEST-- +extract() with negative keys +--FILE-- + "foo"]; +var_dump(extract($arr, EXTR_PREFIX_ALL | EXTR_REFS, "prefix")); + +?> +--EXPECT-- +int(0) diff --git a/ext/standard/tests/file/windows_mb_path/bug54028.phpt b/ext/standard/tests/file/windows_mb_path/bug54028.phpt index 61913a1a7218f..3603bced34d8a 100644 --- a/ext/standard/tests/file/windows_mb_path/bug54028.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug54028.phpt @@ -4,12 +4,8 @@ Bug #54028 Directory::read() cannot handle non-unicode chars properly mbstring --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- ---EXPECTF-- +--EXPECT-- Active code page: 65001 filetype()[dir ] == is_dir()[dir ] -> OK: . filetype()[dir ] == is_dir()[dir ] -> OK: .. @@ -58,4 +55,3 @@ filetype()[dir ] == is_dir()[dir ] -> OK: ソ filetype()[dir ] == is_dir()[dir ] -> OK: ゾ filetype()[dir ] == is_dir()[dir ] -> OK: 多国語 filetype()[dir ] == is_dir()[dir ] -> OK: 表 -Active code page: %d diff --git a/ext/standard/tests/file/windows_mb_path/bug70903.phpt b/ext/standard/tests/file/windows_mb_path/bug70903.phpt index 48cbf524c96d8..25a6f92b0abcc 100644 --- a/ext/standard/tests/file/windows_mb_path/bug70903.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug70903.phpt @@ -2,12 +2,8 @@ Bug #70903 scandir wrongly interprets the Turkish "ı" character --SKIPIF-- --FILE-- --CONFLICTS-- bug71509 diff --git a/ext/standard/tests/file/windows_mb_path/bug74923.phpt b/ext/standard/tests/file/windows_mb_path/bug74923.phpt index 9cffd5860f601..fb87f2b266d54 100644 --- a/ext/standard/tests/file/windows_mb_path/bug74923.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug74923.phpt @@ -2,11 +2,8 @@ Bug #74923 Crash when crawling through network share --SKIPIF-- --FILE-- --INI-- default_charset=cp1251 diff --git a/ext/standard/tests/file/windows_mb_path/bug75063_utf8.phpt b/ext/standard/tests/file/windows_mb_path/bug75063_utf8.phpt index a1878bb88a37c..615b76d196fb6 100644 --- a/ext/standard/tests/file/windows_mb_path/bug75063_utf8.phpt +++ b/ext/standard/tests/file/windows_mb_path/bug75063_utf8.phpt @@ -2,12 +2,8 @@ Bug #75063 Many filesystem-related functions do not work with multibyte file names, UTF-8 --SKIPIF-- --FILE-- 259) die("skip Unsuitable starting path length"); ?> --FILE-- diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt index 794c1a2f7b878..7dc11a6167b5d 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading big5 path diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_1.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_1.phpt index d4821b23be0e4..7a88f57b7cf0d 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir big5 path diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt index d7652615dea4e..89a8970344814 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write big5 to UTF-8 path diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt index b355267f851d9..c68bd58be0fc6 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_0.phpt @@ -2,12 +2,8 @@ Test fopen() for reading big5 to UTF-8 path --SKIPIF-- --CONFLICTS-- file_big5 diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_1.phpt index 5076768c955b3..33573f04ec39e 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_1.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir big5 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_big5 diff --git a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt index 4f94f898796f3..2451ebca18e95 100644 --- a/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_big5_to_utf8_2.phpt @@ -2,12 +2,8 @@ Test fopen() for write big5 to UTF-8 path --SKIPIF-- --CONFLICTS-- file_big5 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt index 98c716678a6d7..20e5de98e07f9 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_0.phpt @@ -2,12 +2,8 @@ Test fopen() for reading UTF-8 path with cp1250 specific symbols --SKIPIF-- --CONFLICTS-- file_cp1250 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_1.phpt index ad09ff1967caf..1411911f6d54c 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_1.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir UTF-8 path with cp1250 specific symbols --SKIPIF-- --CONFLICTS-- dir_cp1250 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt index 61e1b4eaa598b..72cf60068d246 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_2.phpt @@ -2,12 +2,8 @@ Test fopen() for write to UTF-8 path with cp1250 specific symbols --SKIPIF-- --CONFLICTS-- dir_cp1250 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt index 2f3ae9afd608d..4c07d5a6de656 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_3.phpt @@ -2,12 +2,8 @@ Test fopen() for reading UTF-8 path with cp1250 specific symbols --SKIPIF-- --CONFLICTS-- file_cp1250 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_4.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_4.phpt index 8992a847eb507..9d2a13de2b949 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_4.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_4.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir UTF-8 path with cp1250 specific symbols --SKIPIF-- --CONFLICTS-- dir_cp1250 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt index 392c486a767f7..4ed862f08b086 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1250_to_utf8_5.phpt @@ -2,12 +2,8 @@ Test fopen() for write to UTF-8 path with cp1250 specific symbols --SKIPIF-- --CONFLICTS-- dir_cp1250 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt index bf30b4baeb040..7766d6dfd327e 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading CP1251 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_1.phpt index 0ea67f575e563..1ea343ae30ce1 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir CP1251 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt index f65b38eafdad0..60a7dbf07fd89 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write CP1251 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt index 0cd657e94c596..6cb74e468eaeb 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_0.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for reading CP1251 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file_cp1251 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_1.phpt index 6e53ff48c99d9..7776b908a8de9 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_1.phpt @@ -1,13 +1,11 @@ --TEST-- Test mkdir/rmdir CP1251 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_cp1251 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt index 95b75985c6188..90c9ddf01254c 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_to_utf8_2.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for write CP1251 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file_cp1251 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt index 8b800ed3bdeab..f962c5c0b0240 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_0.phpt @@ -7,12 +7,8 @@ zend.multibyte=1 zend.script_encoding=cp1251 --SKIPIF-- --CONFLICTS-- file_cp1251 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_1.phpt index 31db615f4d2c8..6d8a1f5d0050f 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_1.phpt @@ -7,12 +7,8 @@ zend.multibyte=1 zend.script_encoding=cp1251 --SKIPIF-- --CONFLICTS-- dir_cp1251 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt index d6075da559c92..63745231771de 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1251_zend_multibyte_2.phpt @@ -7,12 +7,8 @@ zend.multibyte=1 zend.script_encoding=cp1251 --SKIPIF-- --CONFLICTS-- file_cp1251 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_0.phpt index f2671aa6054a5..aa3bc38dded21 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_0.phpt @@ -4,9 +4,8 @@ cp1252 cmd test diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt index 45234243cee44..c7631eb601538 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_0.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for reading cp1252 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file_cp1252 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_1.phpt index 5f5a6a78385a7..ea14608ad4c03 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_1.phpt @@ -1,13 +1,11 @@ --TEST-- Test mkdir/rmdir cp1252 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_cp1252 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt index 04baef95b0252..381b64eda6045 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_2.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for write cp1252 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_cp1252 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt index f6559253d2de4..ef441bcbbfddf 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_3.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for reading cp1252 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file2_cp1252 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_4.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_4.phpt index a3359f686c1b3..739413dd74848 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_4.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_4.phpt @@ -1,13 +1,11 @@ --TEST-- Test mkdir/rmdir cp1252 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir2_cp1252 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt index 42212d027126c..9cf7a31feea1b 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1252_to_utf8_5.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for write cp1252 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir2_cp1252 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt index 93b63a536e839..11116849036b1 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading cp1253 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_1.phpt index 9ffdb11b2b83e..998ab348a0dc3 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir cp1253 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt index 642e4aaabd194..01177620bd549 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write cp1253 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt index d12a174a7feaf..a592ed1f85bc6 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_0.phpt @@ -2,12 +2,8 @@ Test fopen() for reading cp1253 to UTF-8 path --SKIPIF-- --CONFLICTS-- file_cp1253 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_1.phpt index c84e9c95b3694..addc407f3e976 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_1.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir cp1253 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1253 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt index c0723d18b1228..cf88d95a4c696 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1253_to_utf8_2.phpt @@ -2,12 +2,8 @@ Test fopen() for write cp1253 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1253 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt index 77b52e0f1a2d6..83a413549ab31 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading cp1254 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_1.phpt index 82d74c750961b..9dc8225598358 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir cp1254 to UTF-8 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt index f14a4c3de086e..2e386b3af45b9 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write cp1254 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_3.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_3.phpt index 0e0e83d285a3b..076bf2eba50ea 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_3.phpt @@ -4,9 +4,8 @@ cp1254 cmd test diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt index 211233de1c8e4..8dff7615dbfb5 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_0.phpt @@ -2,12 +2,8 @@ Test fopen() for reading cp1254 to UTF-8 path --SKIPIF-- --CONFLICTS-- file_cp1254 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_1.phpt index 42b241176ffb6..7b83cdbb395b3 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_1.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir cp1254 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1254 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt index b0c4f5ec83f0e..5ec63de4bc6e8 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_2.phpt @@ -2,12 +2,8 @@ Test fopen() for write cp1254 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1254 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_3.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_3.phpt index 67549daf601d2..1e70dc8fe5b14 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1254_to_utf8_3.phpt @@ -2,12 +2,8 @@ cp1254 cmd test --SKIPIF-- --CONFLICTS-- file_cp1254 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt index e9adaf843fb6a..61bb6b4155dc0 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading cp1255 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_1.phpt index 2cf42239267ad..a539ce8fd34e3 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir cp1255 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt index e4779b721ba92..7fe2fecb7ea39 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write cp1255 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt index 1b65143553425..e8b35687e2fa8 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_0.phpt @@ -2,12 +2,8 @@ Test fopen() for reading cp1255 to UTF-8 path --SKIPIF-- --CONFLICTS-- file_cp1255 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_1.phpt index 356143ca7876a..48fa4f26a4b73 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_1.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir cp1255 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1255 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt index b378a7231d15e..358908ae56bd2 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1255_to_utf8_2.phpt @@ -2,12 +2,8 @@ Test fopen() for write cp1255 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1255 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt index 40910894b8ee7..9c0abe4c83269 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading cp1256 to UTF-8 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_1.phpt index 244758fe7bd67..f19bd04e9da98 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir cp1256 to UTF-8 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt index f5b5db8935277..c734e24205d6a 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write cp1256 to UTF-8 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt index 901026f3899b0..9af7d83df2ad9 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_0.phpt @@ -2,12 +2,8 @@ Test fopen() for reading cp1256 to UTF-8 path --SKIPIF-- --CONFLICTS-- file_cp1256 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_1.phpt index b630f37648bc4..6da6d789e45ee 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_1.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir cp1256 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1256 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt index 6aa29f43c4268..2cce0b5411169 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp1256_to_utf8_2.phpt @@ -2,12 +2,8 @@ Test fopen() for write cp1256 to UTF-8 path --SKIPIF-- --CONFLICTS-- dir_cp1256 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt index e8bc394a5d0d1..cbab58e84855c 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp874_0.phpt @@ -4,9 +4,8 @@ Thai cp874 basic test diff --git a/ext/standard/tests/file/windows_mb_path/test_cp874_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp874_1.phpt index 9d948d4023aa6..cd438c52f361e 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp874_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp874_1.phpt @@ -4,9 +4,8 @@ Thai cp874 cmd test diff --git a/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt index c21f124b6e195..b8ed1c23758a3 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp874_to_utf8_0.phpt @@ -2,12 +2,8 @@ Thai UTF-8 basic test --SKIPIF-- --FILE-- --CONFLICTS-- file_cp874 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt index ccb273a94ce0f..d2a8e06a61cb0 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading cp932 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_1.phpt index 744d1a592be95..3f58aa5614f5c 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir cp932 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt index 737a4d3eb869b..dc474cf9dff38 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write to cp932 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_3.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_3.phpt index 4fdfb925a82db..d54d90e17beed 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_3.phpt @@ -4,9 +4,8 @@ cp932 cmd test diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt index df855aaca4e3b..925e0558ab26a 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_0.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for reading cp932 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file_cp932 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_1.phpt index b9575302c8abc..8346c86a4d195 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_1.phpt @@ -1,13 +1,11 @@ --TEST-- Test mkdir/rmdir cp932 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_cp932 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt index 7c3870593692e..5d0f10f647acd 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp932_to_utf8_2.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for write cp932 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_cp932 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt index b1a4f8744f94c..3199aa979355e 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_0.phpt @@ -4,9 +4,8 @@ Test fopen() for reading cp936 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_1.phpt index 529808aad5fb2..8ee68392ff318 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_1.phpt @@ -4,9 +4,8 @@ Test mkdir/rmdir cp936 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt index e872c05942a68..024e84d4317fc 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_2.phpt @@ -4,9 +4,8 @@ Test fopen() for write cp936 path diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt index 2797d25904f7f..39f989371968d 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_0.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for reading cp936 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file_cp936 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_1.phpt index f9730b6fe9a08..7321ea0ed9d59 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_1.phpt @@ -1,13 +1,11 @@ --TEST-- Test mkdir/rmdir cp936 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_cp936 diff --git a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt index 31ff1db318b84..8b3eb208f12fe 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cp936_to_utf8_2.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for write cp936 to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file_cp936 diff --git a/ext/standard/tests/file/windows_mb_path/test_cwd_mb_names.phpt b/ext/standard/tests/file/windows_mb_path/test_cwd_mb_names.phpt index 3cb09f777d37f..9f9d1f24e6cdc 100644 --- a/ext/standard/tests/file/windows_mb_path/test_cwd_mb_names.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_cwd_mb_names.phpt @@ -2,15 +2,8 @@ Test chdir()/getcwd() with a dir for multibyte filenames --SKIPIF-- --CONFLICTS-- dir_mb @@ -24,8 +17,9 @@ $prefix = create_data("dir_mb"); $dirw = $prefix . DIRECTORY_SEPARATOR . "テストマルチバイト・パス42"; touch($dirw . DIRECTORY_SEPARATOR . "dummy.txt"); -$old_cp = get_active_cp(); -set_active_cp(65001); +$old_cp = sapi_windows_cp_get(); +sapi_windows_cp_set(65001); +echo "Active code page: ", sapi_windows_cp_get(), "\n"; $oldcwd = getcwd(); var_dump(chdir($dirw)); @@ -33,7 +27,7 @@ var_dump(getcwd()); var_dump(file_exists("dummy.txt")); -set_active_cp($old_cp); +sapi_windows_cp_set($old_cp); chdir($oldcwd); remove_data("dir_mb"); @@ -44,4 +38,3 @@ Active code page: 65001 bool(true) string(%d) "%s\テストマルチバイト・パス42" bool(true) -Active code page: %d diff --git a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt index 7a06f53b7dd0c..48f2443017d6c 100644 --- a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_0.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for reading eucjp to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- file_eucjp diff --git a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_1.phpt index e3111ba33af7e..922f9e8290644 100644 --- a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_1.phpt @@ -1,13 +1,11 @@ --TEST-- Test mkdir/rmdir eucjp to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_eucjp diff --git a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt index 9425a1cc1cea8..b4a9895428d53 100644 --- a/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_eucjp_to_utf8_2.phpt @@ -1,13 +1,11 @@ --TEST-- Test fopen() for write eucjp to UTF-8 path +--EXTENSIONS-- +iconv --SKIPIF-- --CONFLICTS-- dir_eucjp diff --git a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt index 0840610c2058e..f3c4f18131fa7 100644 --- a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_0.phpt @@ -2,12 +2,8 @@ Test fopen() for reading Kartuli UTF-8 path --SKIPIF-- --CONFLICTS-- file_kartuli diff --git a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_1.phpt b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_1.phpt index d348ccfd3c8fd..16f68f0f0ecb8 100644 --- a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_1.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_1.phpt @@ -2,12 +2,8 @@ Test mkdir/rmdir Kartuli UTF-8 path --SKIPIF-- --CONFLICTS-- dir_kartuli diff --git a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt index 2e57dc0c91fa0..ca6c887a24ed9 100644 --- a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_2.phpt @@ -2,12 +2,8 @@ Test fopen() for write Kartuli UTF-8 path --SKIPIF-- --CONFLICTS-- dir_kartuli diff --git a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_3.phpt b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_3.phpt index 8d498d19907b1..e0984b0dd73bd 100644 --- a/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_3.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_kartuli_utf8_3.phpt @@ -2,12 +2,8 @@ Kartuli UTF-8 cmd test --SKIPIF-- --CONFLICTS-- file_kartuli diff --git a/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt b/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt index 6a5b60f08bbeb..daabfaad17fe4 100644 --- a/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_long_path_0.phpt @@ -4,12 +4,8 @@ Basic long path test mbstring --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- 248 has be a long path --SKIPIF-- 260 || strlen($start) > 248) { +if (strlen($start) > 260 || strlen($start) < 248) { die("skip the starting path length is unsuitable for this test"); } diff --git a/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt b/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt index 84fe5e327335b..65a0dada9f4c4 100644 --- a/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_readdir_mb_names.phpt @@ -2,12 +2,8 @@ Test readdir() with a dir for multibyte filenames --SKIPIF-- --CONFLICTS-- mb_names @@ -38,8 +34,9 @@ create_verify_dir($prefix, "żółć"); $dirw = $prefix . DIRECTORY_SEPARATOR; -$old_cp = get_active_cp(); -set_active_cp(65001); +$old_cp = sapi_windows_cp_get(); +sapi_windows_cp_set(65001); +echo "Active code page: ", sapi_windows_cp_get(), "\n"; if (is_dir($dirw)) { if ($dh = opendir($dirw)) { @@ -51,12 +48,12 @@ if (is_dir($dirw)) { } else { echo "is_dir failed\n"; } -set_active_cp($old_cp); +sapi_windows_cp_set($old_cp); remove_data("mb_names"); ?> ---EXPECTF-- +--EXPECT-- Active code page: 65001 filename: . : filetype: dir filename: .. : filetype: dir @@ -76,4 +73,3 @@ filename: テストマルチバイト・パス : filetype: file filename: テストマルチバイト・パス42 : filetype: dir filename: 測試多字節路徑 : filetype: file filename: 測試多字節路徑5 : filetype: dir -Active code page: %d diff --git a/ext/standard/tests/file/windows_mb_path/test_rename_mb_names.phpt b/ext/standard/tests/file/windows_mb_path/test_rename_mb_names.phpt index 53dd1bd3ea862..ce040d1eda545 100644 --- a/ext/standard/tests/file/windows_mb_path/test_rename_mb_names.phpt +++ b/ext/standard/tests/file/windows_mb_path/test_rename_mb_names.phpt @@ -2,62 +2,42 @@ Test rename() with a dir for multibyte filenames --SKIPIF-- --CONFLICTS-- file2_mb --FILE-- ---EXPECTF-- +--EXPECT-- Active code page: 65001 bool(true) string(21) "Ελλάδα_copy.txt" @@ -66,4 +46,3 @@ bool(true) string(27) "測試多字節路徑17.txt" bool(true) bool(true) -Active code page: %d diff --git a/ext/standard/tests/file/windows_mb_path/util.inc b/ext/standard/tests/file/windows_mb_path/util.inc index a26a66c01751b..c8f0f6c586cb3 100644 --- a/ext/standard/tests/file/windows_mb_path/util.inc +++ b/ext/standard/tests/file/windows_mb_path/util.inc @@ -1,36 +1,7 @@ --FILE-- +--EXTENSIONS-- +zlib --FILE-- +--EXTENSIONS-- +zlib --FILE-- datalen; + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } +} + +stream_filter_register("pass", "pass_filter"); +$fp = fopen("php://memory", "w"); +stream_filter_append($fp, "pass"); + +try { + fwrite($fp, "data"); +} catch (TypeError $e) { + echo $e::class, ": ", $e->getMessage(), "\n"; +} + +try { + fclose($fp); +} catch (TypeError $e) { + echo $e::class, ": ", $e->getMessage(), "\n"; +} + +unset($fp); // prevent cleanup at shutdown + +?> +--EXPECTF-- +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d +TypeError: Cannot assign resource to property pass_filter::$stream of type int +TypeError: Cannot assign resource to property pass_filter::$stream of type int diff --git a/ext/standard/tests/filters/gh20370_dynamic_stream_property.phpt b/ext/standard/tests/filters/gh20370_dynamic_stream_property.phpt new file mode 100644 index 0000000000000..97f24b854c5ea --- /dev/null +++ b/ext/standard/tests/filters/gh20370_dynamic_stream_property.phpt @@ -0,0 +1,51 @@ +--TEST-- +GH-20370 (User filters should update dynamic stream property if it exists) +--FILE-- +stream = null; + return true; + } + + function filter($in, $out, &$consumed, $closing): int + { + while ($bucket = stream_bucket_make_writeable($in)) { + $consumed += $bucket->datalen; + stream_bucket_append($out, $bucket); + } + var_dump(property_exists($this, 'stream')); + if (is_resource($this->stream)) { + var_dump(get_resource_type($this->stream)); + } + return PSFS_PASS_ON; + } +} + +stream_filter_register("pass", "pass_filter"); +$fp = fopen("php://memory", "w"); +stream_filter_append($fp, "pass"); + +fwrite($fp, "data"); +rewind($fp); +echo fread($fp, 1024) . "\n"; + +?> +--EXPECTF-- +bool(true) +string(6) "stream" +bool(true) +string(6) "stream" +bool(true) +string(6) "stream" +bool(true) +string(6) "stream" +data +bool(true) diff --git a/ext/standard/tests/filters/gh20370_no_stream_property.phpt b/ext/standard/tests/filters/gh20370_no_stream_property.phpt new file mode 100644 index 0000000000000..1b52c4c4155b8 --- /dev/null +++ b/ext/standard/tests/filters/gh20370_no_stream_property.phpt @@ -0,0 +1,37 @@ +--TEST-- +GH-20370 (User filters should not create stream property if not declared) +--FILE-- +datalen; + stream_bucket_append($out, $bucket); + } + + var_dump(property_exists($this, 'stream')); + return PSFS_PASS_ON; + } +} + +stream_filter_register("pass", "pass_filter"); +$fp = fopen("php://memory", "w"); +stream_filter_append($fp, "pass"); +fwrite($fp, "data"); +rewind($fp); +echo fread($fp, 1024) . "\n"; + +?> +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) +data +bool(false) diff --git a/ext/standard/tests/filters/gh20370_private_stream_property.phpt b/ext/standard/tests/filters/gh20370_private_stream_property.phpt new file mode 100644 index 0000000000000..bfbbba6099ad0 --- /dev/null +++ b/ext/standard/tests/filters/gh20370_private_stream_property.phpt @@ -0,0 +1,38 @@ +--TEST-- +GH-20370 (User filters should handle private stream property correctly) +--FILE-- +datalen; + stream_bucket_append($out, $bucket); + } + return PSFS_PASS_ON; + } + + function onClose() + { + var_dump($this->stream); // should be null + } +} + +stream_filter_register("pass", "pass_filter"); +$fp = fopen("php://memory", "w"); +stream_filter_append($fp, "pass", STREAM_FILTER_WRITE); + +fwrite($fp, "data"); +rewind($fp); +echo fread($fp, 1024) . "\n"; + +?> +--EXPECT-- +data +NULL diff --git a/ext/standard/tests/streams/stream_filter_register.phpt b/ext/standard/tests/filters/stream_filter_register.phpt similarity index 100% rename from ext/standard/tests/streams/stream_filter_register.phpt rename to ext/standard/tests/filters/stream_filter_register.phpt diff --git a/ext/standard/tests/filters/stream_filter_register_class_coerce_consumed_by_ref_param.phpt b/ext/standard/tests/filters/stream_filter_register_class_coerce_consumed_by_ref_param.phpt new file mode 100644 index 0000000000000..f5f0ecca79751 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_class_coerce_consumed_by_ref_param.phpt @@ -0,0 +1,32 @@ +--TEST-- +stream_filter_register() with a class that coerces the $consumed parameter of filter method +--XFAIL-- +This leaks memory +--FILE-- + +--EXPECTF-- +bool(true) +resource(4) of type (stream filter) + +Warning: Object of class stdClass could not be converted to int in %s on line %d + +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d +int(1) + +Warning: Object of class stdClass could not be converted to int in Unknown on line 0 diff --git a/ext/standard/tests/filters/stream_filter_register_class_completely_invalid.phpt b/ext/standard/tests/filters/stream_filter_register_class_completely_invalid.phpt new file mode 100644 index 0000000000000..6bd3e7bc1c9dc --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_class_completely_invalid.phpt @@ -0,0 +1,33 @@ +--TEST-- +stream_filter_register() with a class name that exist but does not extend php_user_filter nor mock anything +--FILE-- + +--EXPECTF-- +bool(true) + +Deprecated: Creation of dynamic property foo::$filtername is deprecated in %s on line %d + +Deprecated: Creation of dynamic property foo::$params is deprecated in %s on line %d +resource(%d) of type (stream filter) + +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d + +Fatal error: Uncaught Error: Invalid callback foo::filter, class foo does not have a method "filter" in %s:%d +Stack trace: +#0 %s(%d): fwrite(Resource id #%d, 'Hello\n') +#1 {main} + thrown in %s on line %d + +Fatal error: Invalid callback foo::filter, class foo does not have a method "filter" in Unknown on line 0 diff --git a/ext/standard/tests/filters/stream_filter_register_class_completely_invalid_filtername_prop_type.phpt b/ext/standard/tests/filters/stream_filter_register_class_completely_invalid_filtername_prop_type.phpt new file mode 100644 index 0000000000000..793c112791a99 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_class_completely_invalid_filtername_prop_type.phpt @@ -0,0 +1,28 @@ +--TEST-- +stream_filter_register() with a class name exist but does not extend php_user_filter and defines a $filtername prop with different type +--FILE-- + +--EXPECTF-- +bool(true) + +Deprecated: Creation of dynamic property foo::$params is deprecated in %s on line %d + +Fatal error: Uncaught TypeError: Cannot assign string to property foo::$filtername of type array in %s:%d +Stack trace: +#0 %s(%d): stream_filter_append(Resource id #2, 'invalid_filter') +#1 {main} + thrown in %s on line %d + +Fatal error: Invalid callback foo::filter, class foo does not have a method "filter" in Unknown on line 0 diff --git a/ext/standard/tests/filters/stream_filter_register_class_completely_invalid_no_dynamic_props.phpt b/ext/standard/tests/filters/stream_filter_register_class_completely_invalid_no_dynamic_props.phpt new file mode 100644 index 0000000000000..86994d5c1b665 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_class_completely_invalid_no_dynamic_props.phpt @@ -0,0 +1,28 @@ +--TEST-- +stream_filter_register() with a class name exist but does not extend php_user_filter and cannot have dynamic properties +--FILE-- + +--EXPECTF-- +bool(true) + +Fatal error: Uncaught Error: Cannot create dynamic property SensitiveParameter::$filtername in %s:%d +Stack trace: +#0 %s(%d): stream_filter_append(Resource id #%d, 'invalid_filter') +#1 {main} + +Next Error: Cannot create dynamic property SensitiveParameter::$params in %s:%d +Stack trace: +#0 %s(%d): stream_filter_append(Resource id #%d, 'invalid_filter') +#1 {main} + thrown in %s on line %d + +Fatal error: Invalid callback SensitiveParameter::filter, class SensitiveParameter does not have a method "filter" in Unknown on line 0 diff --git a/ext/standard/tests/filters/stream_filter_register_class_private_filtername_prop.phpt b/ext/standard/tests/filters/stream_filter_register_class_private_filtername_prop.phpt new file mode 100644 index 0000000000000..6b9be4bbbb4b7 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_class_private_filtername_prop.phpt @@ -0,0 +1,28 @@ +--TEST-- +stream_filter_register() with a class name exist but does not extend php_user_filter and defines a private $filtername prop +--FILE-- + +--EXPECTF-- +bool(true) + +Deprecated: Creation of dynamic property foo::$params is deprecated in %s on line %d + +Fatal error: Uncaught Error: Cannot access private property foo::$filtername in %s:%d +Stack trace: +#0 %s(%d): stream_filter_append(Resource id #2, 'invalid_filter') +#1 {main} + thrown in %s on line %d + +Fatal error: Invalid callback foo::filter, class foo does not have a method "filter" in Unknown on line 0 diff --git a/ext/standard/tests/filters/stream_filter_register_class_throwing_onclose.phpt b/ext/standard/tests/filters/stream_filter_register_class_throwing_onclose.phpt new file mode 100644 index 0000000000000..76b925cc0483a --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_class_throwing_onclose.phpt @@ -0,0 +1,30 @@ +--TEST-- +stream_filter_register() with a class that has a onclose method that throws +--FILE-- + +--EXPECTF-- +bool(true) +resource(4) of type (stream filter) + +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d +bool(false) + +Fatal error: Uncaught Exception: No in %s:%d +Stack trace: +#0 [internal function]: foo->onclose() +#1 {main} + thrown in %s on line %d diff --git a/ext/standard/tests/filters/stream_filter_register_class_throwing_oncreate.phpt b/ext/standard/tests/filters/stream_filter_register_class_throwing_oncreate.phpt new file mode 100644 index 0000000000000..3e429a2cc343a --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_class_throwing_oncreate.phpt @@ -0,0 +1,27 @@ +--TEST-- +stream_filter_register() with a class that has a oncreate method that throws +--FILE-- + +--EXPECTF-- +bool(true) + +Fatal error: Uncaught Exception: No in %s:%d +Stack trace: +#0 [internal function]: foo->oncreate() +#1 %s(%d): stream_filter_append(Resource id #2, 'invalid_filter') +#2 {main} + thrown in %s on line %d diff --git a/ext/standard/tests/filters/stream_filter_register_filter_always_feed.phpt b/ext/standard/tests/filters/stream_filter_register_filter_always_feed.phpt new file mode 100644 index 0000000000000..7a3d3f8899938 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_filter_always_feed.phpt @@ -0,0 +1,24 @@ +--TEST-- +stream_filter_register() with a filter method always returning PSFS_FEED_ME +--FILE-- + +--EXPECTF-- +bool(true) +resource(4) of type (stream filter) + +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d +int(0) diff --git a/ext/standard/tests/filters/stream_filter_register_mock_class_filter.phpt b/ext/standard/tests/filters/stream_filter_register_mock_class_filter.phpt new file mode 100644 index 0000000000000..4d2309a718eb5 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_mock_class_filter.phpt @@ -0,0 +1,30 @@ +--TEST-- +stream_filter_register() with a class name exist that mocks php_user_filter with a filter method +--XFAIL-- +This leaks memory +--FILE-- + +--EXPECTF-- +bool(true) +resource(4) of type (stream filter) + +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d +int(0) diff --git a/ext/standard/tests/filters/stream_filter_register_mock_class_filter_incorect_return_type.phpt b/ext/standard/tests/filters/stream_filter_register_mock_class_filter_incorect_return_type.phpt new file mode 100644 index 0000000000000..b5ec8da3dde1b --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_mock_class_filter_incorect_return_type.phpt @@ -0,0 +1,32 @@ +--TEST-- +stream_filter_register() with a class name exist that mocks php_user_filter with a filter method returning not an int +--FILE-- + +--EXPECTF-- +bool(true) +resource(4) of type (stream filter) + +Warning: Object of class stdClass could not be converted to int in %s on line %d + +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d +int(0) + +Warning: Object of class stdClass could not be converted to int in Unknown on line 0 diff --git a/ext/standard/tests/filters/stream_filter_register_mock_class_filter_is_private.phpt b/ext/standard/tests/filters/stream_filter_register_mock_class_filter_is_private.phpt new file mode 100644 index 0000000000000..6abffe1ff5f80 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_mock_class_filter_is_private.phpt @@ -0,0 +1,35 @@ +--TEST-- +stream_filter_register() with a class name exist that mocks php_user_filter with a private filter method +--FILE-- + +--EXPECTF-- +bool(true) +resource(%d) of type (stream filter) + +Warning: fwrite(): Unprocessed filter buckets remaining on input brigade in %s on line %d + +Fatal error: Uncaught Error: Invalid callback foo::filter, cannot access private method foo::filter() in %s:%d +Stack trace: +#0 %s(%d): fwrite(Resource id #%d, 'Hello\n') +#1 {main} + thrown in %s on line %d + +Fatal error: Invalid callback foo::filter, cannot access private method foo::filter() in Unknown on line 0 diff --git a/ext/standard/tests/filters/stream_filter_register_non_existing_class.phpt b/ext/standard/tests/filters/stream_filter_register_non_existing_class.phpt new file mode 100644 index 0000000000000..1c08201cff0c5 --- /dev/null +++ b/ext/standard/tests/filters/stream_filter_register_non_existing_class.phpt @@ -0,0 +1,21 @@ +--TEST-- +stream_filter_register() with a class name that does not exist +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: stream_filter_append(): User-filter "not_existing_filter" requires class "not_existing", but that class is not defined in %s on line %d + +Warning: stream_filter_append(): Unable to create or locate filter "not_existing_filter" in %s on line %d +Hello +int(6) diff --git a/ext/standard/tests/streams/stream_multi_filters_close.phpt b/ext/standard/tests/filters/stream_multi_filters_close.phpt similarity index 100% rename from ext/standard/tests/streams/stream_multi_filters_close.phpt rename to ext/standard/tests/filters/stream_multi_filters_close.phpt diff --git a/ext/standard/tests/streams/user_streams_consumed_bug.phpt b/ext/standard/tests/filters/user_streams_consumed_bug.phpt similarity index 100% rename from ext/standard/tests/streams/user_streams_consumed_bug.phpt rename to ext/standard/tests/filters/user_streams_consumed_bug.phpt diff --git a/ext/standard/tests/file/userfilters.phpt b/ext/standard/tests/filters/userfilters.phpt similarity index 100% rename from ext/standard/tests/file/userfilters.phpt rename to ext/standard/tests/filters/userfilters.phpt diff --git a/ext/standard/tests/gh20695.phpt b/ext/standard/tests/gh20695.phpt new file mode 100644 index 0000000000000..64c81ab9fdb54 --- /dev/null +++ b/ext/standard/tests/gh20695.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-20695 (Assertion failure in normalize_value() when parsing malformed INI input via parse_ini_string()) +--FILE-- + +--EXPECT-- +array(1) { + [8]=> + array(1) { + ["["]=> + int(0) + } +} diff --git a/ext/standard/tests/http/http_build_query/gh20583.phpt b/ext/standard/tests/http/http_build_query/gh20583.phpt index c0331a830b1e0..5ea0dbe9006bc 100644 --- a/ext/standard/tests/http/http_build_query/gh20583.phpt +++ b/ext/standard/tests/http/http_build_query/gh20583.phpt @@ -10,11 +10,11 @@ if (getenv('SKIP_ASAN')) { } ?> --INI-- -zend.max_allowed_stack_size=512K +zend.max_allowed_stack_size=128K --FILE-- $a]; } try { diff --git a/ext/standard/tests/mail/gh20776.phpt b/ext/standard/tests/mail/gh20776.phpt new file mode 100644 index 0000000000000..aec68c4719202 --- /dev/null +++ b/ext/standard/tests/mail/gh20776.phpt @@ -0,0 +1,15 @@ +--TEST-- +GH-20776: mail() memory leak when header array contains numeric keys +--FILE-- + 'Value', 5 => 'invalid key'])); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +?> +--EXPECT-- +TypeError: Header name cannot be numeric, 5 given diff --git a/ext/standard/tests/math/clamp.phpt b/ext/standard/tests/math/clamp.phpt new file mode 100644 index 0000000000000..beb4c8d53148d --- /dev/null +++ b/ext/standard/tests/math/clamp.phpt @@ -0,0 +1,104 @@ +--TEST-- +clamp() tests +--INI-- +precision=14 +date.timezone=UTC +zend.assertions=1 +--FILE-- +getMessage(), "\n"; + } + + try { + var_dump(make_clamp_fcc()($value, $min, $max)); + } catch (ValueError $error) { + echo $error->getMessage(), "\n"; + } +} + +var_dump(check_clamp_result(2, 1, 3)); +var_dump(check_clamp_result(0, 1, 3)); +var_dump(check_clamp_result(6, 1, 3)); +var_dump(check_clamp_result(2, 1.3, 3.4)); +var_dump(check_clamp_result(2.5, 1, 3)); +var_dump(check_clamp_result(2.5, 1.3, 3.4)); +var_dump(check_clamp_result(0, 1.3, 3.4)); +var_dump(check_clamp_result(M_PI, -INF, INF)); +var_dump(check_clamp_result(NAN, 4, 6)); +var_dump(check_clamp_result("a", "c", "g")); +var_dump(check_clamp_result("d", "c", "g")); +echo check_clamp_result('2025-08-01', '2025-08-15', '2025-09-15'), "\n"; +echo check_clamp_result('2025-08-20', '2025-08-15', '2025-09-15'), "\n"; +echo check_clamp_result(new \DateTimeImmutable('2025-08-01'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; +echo check_clamp_result(new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15'))->format('Y-m-d'), "\n"; +var_dump(check_clamp_result(null, -1, 1)); +var_dump(check_clamp_result(null, 1, 3)); +var_dump(check_clamp_result(null, -3, -1)); +var_dump(check_clamp_result(-9999, null, 10)); +var_dump(check_clamp_result(12, null, 10)); + +$a = new \InvalidArgumentException('a'); +$b = new \RuntimeException('b'); +$c = new \LogicException('c'); +echo check_clamp_result($a, $b, $c)::class, "\n"; +echo check_clamp_result($b, $a, $c)::class, "\n"; +echo check_clamp_result($c, $a, $b)::class, "\n"; + +check_clamp_exception(4, NAN, 6); +check_clamp_exception(7, 6, NAN); +check_clamp_exception(1, 3, 2); +check_clamp_exception(-9999, 5, null); +check_clamp_exception(12, -5, null); + +?> +--EXPECT-- +int(2) +int(1) +int(3) +int(2) +float(2.5) +float(2.5) +float(1.3) +float(3.141592653589793) +float(NAN) +string(1) "c" +string(1) "d" +2025-08-15 +2025-08-20 +2025-08-15 +2025-08-20 +int(-1) +int(1) +int(-3) +int(-9999) +int(10) +InvalidArgumentException +RuntimeException +LogicException +clamp(): Argument #2 ($min) must not be NAN +clamp(): Argument #2 ($min) must not be NAN +clamp(): Argument #3 ($max) must not be NAN +clamp(): Argument #3 ($max) must not be NAN +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) +clamp(): Argument #2 ($min) must be smaller than or equal to argument #3 ($max) diff --git a/ext/standard/tests/network/ghsa-www2-q4fc-65wf.phpt b/ext/standard/tests/network/ghsa-www2-q4fc-65wf.phpt new file mode 100644 index 0000000000000..3d082c8e95226 --- /dev/null +++ b/ext/standard/tests/network/ghsa-www2-q4fc-65wf.phpt @@ -0,0 +1,62 @@ +--TEST-- +GHSA-www2-q4fc-65wf +--DESCRIPTION-- +This is a ZPP test but *keep* this as it is security-sensitive! +--FILE-- +getMessage(), "\n"; +} +try { + dns_get_mx("\0", $out); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + dns_get_record("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getprotobyname("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getservbyname("\0", "tcp"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getservbyname("x", "tcp\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + getservbyport(0, "tcp\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + inet_pton("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +try { + ip2long("\0"); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +dns_check_record(): Argument #1 ($hostname) must not contain any null bytes +dns_get_mx(): Argument #1 ($hostname) must not contain any null bytes +dns_get_record(): Argument #1 ($hostname) must not contain any null bytes +getprotobyname(): Argument #1 ($protocol) must not contain any null bytes +getservbyname(): Argument #1 ($service) must not contain any null bytes +getservbyname(): Argument #2 ($protocol) must not contain any null bytes +getservbyport(): Argument #2 ($protocol) must not contain any null bytes +inet_pton(): Argument #1 ($ip) must not contain any null bytes +ip2long(): Argument #1 ($ip) must not contain any null bytes diff --git a/ext/standard/tests/network/so_reuseaddr.phpt b/ext/standard/tests/network/so_reuseaddr.phpt new file mode 100644 index 0000000000000..d400a81ac33d3 --- /dev/null +++ b/ext/standard/tests/network/so_reuseaddr.phpt @@ -0,0 +1,73 @@ +--TEST-- +stream_socket_server() SO_REUSEADDR context option test +--FILE-- + ['so_reuseaddr' => false]]); +$server3 = stream_socket_server("tcp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context); +if (!$server3) { + die('Unable to create server3'); +} + +$addr = stream_socket_get_name($server3, false); +$port = (int)substr(strrchr($addr, ':'), 1); + +$client3 = stream_socket_client("tcp://127.0.0.1:$port"); +$accepted = stream_socket_accept($server3, 1); + +// Force real TCP connection with data +fwrite($client3, "test"); +fread($accepted, 4); +fwrite($accepted, "response"); +fread($client3, 8); + +// Client closes first (becomes active closer) +fclose($client3); // This enters TIME_WAIT +if (!$is_win) { // Windows would always succeed if server is closed + fclose($server3); +} + +// Try immediate bind with SO_REUSEADDR disabled (should fail) +$server4 = @stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context); +if ($server4) { + echo "Disabled: Server restart succeeded\n"; + fclose($server4); +} else { + echo "Disabled: Server restart failed\n"; +} +?> +--EXPECT-- +Default: Server restart succeeded +Disabled: Server restart failed diff --git a/ext/standard/tests/network/so_reuseport.phpt b/ext/standard/tests/network/so_reuseport.phpt new file mode 100644 index 0000000000000..12a07bbd42364 --- /dev/null +++ b/ext/standard/tests/network/so_reuseport.phpt @@ -0,0 +1,136 @@ +--TEST-- +stream_socket_server() SO_REUSEPORT context option test +--SKIPIF-- + +--FILE-- + ['so_reuseport' => true]]); +$server1 = stream_socket_server("tcp://127.0.0.1:0", $errno, $errstr, + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context1); + +if (!$server1) { + die('Unable to create server1'); +} + +$addr = stream_socket_get_name($server1, false); +$port = (int)substr(strrchr($addr, ':'), 1); + +// Establish actual connection on server1 +$client1 = stream_socket_client("tcp://127.0.0.1:$port"); +$accepted1 = stream_socket_accept($server1, 1); + +// Force real TCP connection with data +fwrite($client1, "test"); +fread($accepted1, 4); +fwrite($accepted1, "response"); +fread($client1, 8); + +// Try to bind second server to SAME port with SO_REUSEPORT (while server1 still active) +$context2 = stream_context_create(['socket' => ['so_reuseport' => true]]); +$server2 = @stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context2); + +if ($server2) { + echo "SO_REUSEPORT enabled: Multiple servers succeeded\n"; + + // Verify server2 can also accept connections + $client2 = stream_socket_client("tcp://127.0.0.1:$port"); + $accepted2_on_srv1 = @stream_socket_accept($server1, 0.1); + $accepted2_on_srv2 = @stream_socket_accept($server2, 0.1); + + if ($accepted2_on_srv1 || $accepted2_on_srv2) { + echo "SO_REUSEPORT enabled: Connections accepted\n"; + } + + if ($accepted2_on_srv1) fclose($accepted2_on_srv1); + if ($accepted2_on_srv2) fclose($accepted2_on_srv2); + if ($client2) fclose($client2); + + fclose($server2); +} else { + echo "SO_REUSEPORT enabled: Multiple servers failed\n"; +} + +fclose($accepted1); +fclose($client1); +fclose($server1); + +// SO_REUSEPORT disabled (default) - should NOT allow multiple servers +$server3 = stream_socket_server("tcp://127.0.0.1:0", $errno, $errstr, + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN); + +if (!$server3) { + die('Unable to create server3'); +} + +$addr = stream_socket_get_name($server3, false); +$port = (int)substr(strrchr($addr, ':'), 1); + +$client3 = stream_socket_client("tcp://127.0.0.1:$port"); +$accepted3 = stream_socket_accept($server3, 1); + +fwrite($client3, "test"); +fread($accepted3, 4); +fwrite($accepted3, "response"); +fread($client3, 8); + +// Try to bind second server WITHOUT SO_REUSEPORT (while server3 still active) +$server4 = @stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN); + +if ($server4) { + echo "SO_REUSEPORT disabled: Multiple servers succeeded\n"; + fclose($server4); +} else { + echo "SO_REUSEPORT disabled: Multiple servers failed\n"; +} + +fclose($accepted3); +fclose($client3); +fclose($server3); + +// SO_REUSEPORT explicitly disabled +$context3 = stream_context_create(['socket' => ['so_reuseport' => false]]); +$server5 = stream_socket_server("tcp://127.0.0.1:0", $errno, $errstr, + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context3); + +if (!$server5) { + die('Unable to create server5'); +} + +$addr = stream_socket_get_name($server5, false); +$port = (int)substr(strrchr($addr, ':'), 1); + +$client5 = stream_socket_client("tcp://127.0.0.1:$port"); +$accepted5 = stream_socket_accept($server5, 1); + +fwrite($client5, "test"); +fread($accepted5, 4); +fwrite($accepted5, "response"); +fread($client5, 8); + +$context4 = stream_context_create(['socket' => ['so_reuseport' => false]]); +$server6 = @stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, $context4); + +if ($server6) { + echo "SO_REUSEPORT explicitly disabled: Multiple servers succeeded\n"; + fclose($server6); +} else { + echo "SO_REUSEPORT explicitly disabled: Multiple servers failed\n"; +} + +fclose($accepted5); +fclose($client5); +fclose($server5); +?> +--EXPECT-- +SO_REUSEPORT enabled: Multiple servers succeeded +SO_REUSEPORT enabled: Connections accepted +SO_REUSEPORT disabled: Multiple servers failed +SO_REUSEPORT explicitly disabled: Multiple servers failed diff --git a/ext/standard/tests/strings/gh18823_strict.phpt b/ext/standard/tests/strings/gh18823_strict.phpt index 80b21d2093172..3735eab006707 100644 --- a/ext/standard/tests/strings/gh18823_strict.phpt +++ b/ext/standard/tests/strings/gh18823_strict.phpt @@ -15,5 +15,5 @@ try { } ?> --EXPECT-- -setlocale(): Argument #2 ($locales) must be of type array|string, int given -setlocale(): Argument #3 must be of type array|string, int given +setlocale(): Argument #2 ($locales) must be of type array|string|null, int given +setlocale(): Argument #3 must be of type array|string|null, int given diff --git a/ext/standard/type.c b/ext/standard/type.c index 4557014ff5a33..c05926b1a3770 100644 --- a/ext/standard/type.c +++ b/ext/standard/type.c @@ -173,14 +173,17 @@ PHP_FUNCTION(intval) } if (strval[offset] == '0' && (strval[offset + 1] == 'b' || strval[offset + 1] == 'B')) { + if (strval[0] != '-') { + /* Either "+0b", or "0b" */ + RETURN_LONG(ZEND_STRTOL(strval + 2 + offset, NULL, 2)); + } + char *tmpval; strlen -= 2; /* Removing "0b" */ tmpval = emalloc(strlen + 1); - /* Place the unary symbol at pos 0 if there was one */ - if (offset) { - tmpval[0] = strval[0]; - } + /* Place the unary symbol at pos 0 */ + tmpval[0] = '-'; /* Copy the data from after "0b" to the end of the buffer */ memcpy(tmpval + offset, strval + offset + 2, strlen - offset); diff --git a/ext/standard/url.c b/ext/standard/url.c index 504805484ef2c..4ddf7f80c64f9 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -93,7 +93,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port php_url *ret = ecalloc(1, sizeof(php_url)); char const *s, *e, *p, *pp, *ue; - *has_port = 0; + *has_port = false; s = str; ue = s + length; @@ -183,7 +183,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port port_buf[pp - p] = '\0'; port = ZEND_STRTOL(port_buf, &end, 10); if (port >= 0 && port <= 65535 && end != port_buf) { - *has_port = 1; + *has_port = true; ret->port = (unsigned short) port; if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */ s += 2; @@ -249,7 +249,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port port_buf[e - p] = '\0'; port = ZEND_STRTOL(port_buf, &end, 10); if (port >= 0 && port <= 65535 && end != port_buf) { - *has_port = 1; + *has_port = true; ret->port = (unsigned short)port; } else { php_url_free(ret); diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index 05eed4dab4ac3..da8260dfd6de3 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -148,14 +148,31 @@ static php_stream_filter_status_t userfilter_filter( uint32_t orig_no_fclose = stream->flags & PHP_STREAM_FLAG_NO_FCLOSE; stream->flags |= PHP_STREAM_FLAG_NO_FCLOSE; - zval *stream_prop = zend_hash_str_find_ind(Z_OBJPROP_P(obj), "stream", sizeof("stream")-1); - if (stream_prop) { - /* Give the userfilter class a hook back to the stream */ - zval_ptr_dtor(stream_prop); - php_stream_to_zval(stream, stream_prop); - Z_ADDREF_P(stream_prop); + /* Give the userfilter class a hook back to the stream */ + const zend_class_entry *old_scope = EG(fake_scope); + EG(fake_scope) = Z_OBJCE_P(obj); + + zend_string *stream_name = ZSTR_INIT_LITERAL("stream", 0); + bool stream_property_exists = Z_OBJ_HT_P(obj)->has_property(Z_OBJ_P(obj), stream_name, ZEND_PROPERTY_EXISTS, NULL); + if (stream_property_exists) { + zval stream_zval; + php_stream_to_zval(stream, &stream_zval); + zend_update_property_ex(Z_OBJCE_P(obj), Z_OBJ_P(obj), stream_name, &stream_zval); + /* If property update threw an exception, skip filter execution */ + if (EG(exception)) { + EG(fake_scope) = old_scope; + if (buckets_in->head) { + php_error_docref(NULL, E_WARNING, "Unprocessed filter buckets remaining on input brigade"); + } + zend_string_release(stream_name); + stream->flags &= ~PHP_STREAM_FLAG_NO_FCLOSE; + stream->flags |= orig_no_fclose; + return PSFS_ERR_FATAL; + } } + EG(fake_scope) = old_scope; + ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1); /* Setup calling arguments */ @@ -196,11 +213,16 @@ static php_stream_filter_status_t userfilter_filter( /* filter resources are cleaned up by the stream destructor, * keeping a reference to the stream resource here would prevent it - * from being destroyed properly */ - if (stream_prop) { - convert_to_null(stream_prop); + * from being destroyed properly. + * Since the property accepted a resource assignment above, it must have + * no type hint or be typed as mixed, so we can safely assign null. + */ + if (stream_property_exists) { + zend_update_property_null(Z_OBJCE_P(obj), Z_OBJ_P(obj), ZSTR_VAL(stream_name), ZSTR_LEN(stream_name)); } + zend_string_release(stream_name); + zval_ptr_dtor(&args[3]); zval_ptr_dtor(&args[2]); zval_ptr_dtor(&args[1]); @@ -237,7 +259,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, len = strlen(filtername); /* determine the classname/class entry */ - if (NULL == (fdat = zend_hash_str_find_ptr(BG(user_filter_map), (char*)filtername, len))) { + if (NULL == (fdat = zend_hash_str_find_ptr(BG(user_filter_map), filtername, len))) { char *period; /* Userspace Filters using ambiguous wildcards could cause problems. @@ -285,7 +307,7 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, filter = php_stream_filter_alloc(&userfilter_ops, NULL, 0); /* filtername */ - add_property_string(&obj, "filtername", (char*)filtername); + add_property_string(&obj, "filtername", filtername); /* and the parameters, if any */ if (filterparams) { @@ -301,9 +323,6 @@ static php_stream_filter *user_filter_factory_create(const char *filtername, if (Z_TYPE(retval) != IS_UNDEF) { if (Z_TYPE(retval) == IS_FALSE) { - /* User reported filter creation error "return false;" */ - zval_ptr_dtor(&retval); - /* Kill the filter (safely) */ ZVAL_UNDEF(&filter->abstract); php_stream_filter_free(filter); diff --git a/ext/standard/user_filters_arginfo.h b/ext/standard/user_filters_arginfo.h index 0411355b71222..9fd13204e2322 100644 --- a/ext/standard/user_filters_arginfo.h +++ b/ext/standard/user_filters_arginfo.h @@ -44,21 +44,21 @@ static zend_class_entry *register_class_php_user_filter(void) zval property_filtername_default_value; ZVAL_EMPTY_STRING(&property_filtername_default_value); - zend_string *property_filtername_name = zend_string_init("filtername", sizeof("filtername") - 1, 1); + zend_string *property_filtername_name = zend_string_init("filtername", sizeof("filtername") - 1, true); zend_declare_typed_property(class_entry, property_filtername_name, &property_filtername_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_filtername_name); + zend_string_release_ex(property_filtername_name, true); zval property_params_default_value; ZVAL_EMPTY_STRING(&property_params_default_value); - zend_string *property_params_name = zend_string_init("params", sizeof("params") - 1, 1); + zend_string *property_params_name = zend_string_init("params", sizeof("params") - 1, true); zend_declare_typed_property(class_entry, property_params_name, &property_params_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_params_name); + zend_string_release_ex(property_params_name, true); zval property_stream_default_value; ZVAL_NULL(&property_stream_default_value); - zend_string *property_stream_name = zend_string_init("stream", sizeof("stream") - 1, 1); + zend_string *property_stream_name = zend_string_init("stream", sizeof("stream") - 1, true); zend_declare_typed_property(class_entry, property_stream_name, &property_stream_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0)); - zend_string_release(property_stream_name); + zend_string_release_ex(property_stream_name, true); return class_entry; } @@ -72,27 +72,27 @@ static zend_class_entry *register_class_StreamBucket(void) zval property_bucket_default_value; ZVAL_NULL(&property_bucket_default_value); - zend_string *property_bucket_name = zend_string_init("bucket", sizeof("bucket") - 1, 1); + zend_string *property_bucket_name = zend_string_init("bucket", sizeof("bucket") - 1, true); zend_declare_typed_property(class_entry, property_bucket_name, &property_bucket_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0)); - zend_string_release(property_bucket_name); + zend_string_release_ex(property_bucket_name, true); zval property_data_default_value; ZVAL_UNDEF(&property_data_default_value); - zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, 1); + zend_string *property_data_name = zend_string_init("data", sizeof("data") - 1, true); zend_declare_typed_property(class_entry, property_data_name, &property_data_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_data_name); + zend_string_release_ex(property_data_name, true); zval property_datalen_default_value; ZVAL_UNDEF(&property_datalen_default_value); - zend_string *property_datalen_name = zend_string_init("datalen", sizeof("datalen") - 1, 1); + zend_string *property_datalen_name = zend_string_init("datalen", sizeof("datalen") - 1, true); zend_declare_typed_property(class_entry, property_datalen_name, &property_datalen_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_datalen_name); + zend_string_release_ex(property_datalen_name, true); zval property_dataLength_default_value; ZVAL_UNDEF(&property_dataLength_default_value); - zend_string *property_dataLength_name = zend_string_init("dataLength", sizeof("dataLength") - 1, 1); + zend_string *property_dataLength_name = zend_string_init("dataLength", sizeof("dataLength") - 1, true); zend_declare_typed_property(class_entry, property_dataLength_name, &property_dataLength_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_dataLength_name); + zend_string_release_ex(property_dataLength_name, true); return class_entry; } diff --git a/ext/standard/var.c b/ext/standard/var.c index df262eb520c60..a1ef60410a338 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -984,7 +984,7 @@ static void php_var_serialize_nested_data(smart_str *buf, zval *struc, HashTable ZEND_HASH_FOREACH_KEY_VAL_IND(ht, index, key, data) { if (incomplete_class && zend_string_equals_literal(key, MAGIC_MEMBER)) { - incomplete_class = 0; + incomplete_class = false; continue; } @@ -1023,7 +1023,8 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, HashTable *ht, if (php_var_serialize_get_sleep_props(&props, struc, ht) == SUCCESS) { php_var_serialize_class_name(buf, struc); php_var_serialize_nested_data( - buf, struc, &props, zend_hash_num_elements(&props), /* incomplete_class */ 0, var_hash, GC_REFCOUNT(&props) > 1); + buf, struc, &props, zend_hash_num_elements(&props), /* incomplete_class */ false, var_hash, + GC_REFCOUNT(&props) > 1); } zend_hash_destroy(&props); } @@ -1299,8 +1300,8 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_ smart_str_appendl(buf, "a:", 2); myht = Z_ARRVAL_P(struc); php_var_serialize_nested_data( - buf, struc, myht, zend_array_count(myht), /* incomplete_class */ 0, var_hash, - !is_root && (in_rcn_array || GC_REFCOUNT(myht) > 1)); + buf, struc, myht, zend_array_count(myht), /* incomplete_class */ false, var_hash, + !is_root && (in_rcn_array || GC_REFCOUNT(myht) > 1)); return; case IS_REFERENCE: struc = Z_REFVAL_P(struc); diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c index 456a6f51735e0..65d29d12c0f9e 100644 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@ -256,7 +256,7 @@ PHP_FUNCTION(msg_receive) zval *out_message, *queue, *out_msgtype, *zerrcode = NULL; zend_long desiredmsgtype, maxsize, flags = 0; zend_long realflags = 0; - bool do_unserialize = 1; + bool do_unserialize = true; sysvmsg_queue_t *mq = NULL; struct php_msgbuf *messagebuffer = NULL; /* buffer to transmit */ int result; @@ -337,7 +337,7 @@ PHP_FUNCTION(msg_send) { zval *message, *queue, *zerror=NULL; zend_long msgtype; - bool do_serialize = 1, blocking = 1; + bool do_serialize = true, blocking = true; sysvmsg_queue_t * mq = NULL; struct php_msgbuf * messagebuffer = NULL; /* buffer to transmit */ int result; diff --git a/ext/sysvsem/sysvsem.c b/ext/sysvsem/sysvsem.c index 99ebda92273ef..ce624ab4b2372 100644 --- a/ext/sysvsem/sysvsem.c +++ b/ext/sysvsem/sysvsem.c @@ -172,7 +172,7 @@ PHP_MINFO_FUNCTION(sysvsem) PHP_FUNCTION(sem_get) { zend_long key, max_acquire = 1, perm = 0666; - bool auto_release = 1; + bool auto_release = true; int semid; struct sembuf sop[3]; int count; @@ -269,7 +269,7 @@ PHP_FUNCTION(sem_get) static void php_sysvsem_semop(INTERNAL_FUNCTION_PARAMETERS, bool acquire) { zval *arg_id; - bool nowait = 0; + bool nowait = false; sysvsem_sem *sem_ptr; struct sembuf sop; diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index c1372368a34b8..55ee6493bfb0a 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -131,7 +131,7 @@ PHP_FUNCTION(shm_attach) char *shm_ptr; sysvshm_chunk_head *chunk_ptr; zend_long shm_key, shm_id, shm_size, shm_flag = 0666; - bool shm_size_is_null = 1; + bool shm_size_is_null = true; if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "l|l!l", &shm_key, &shm_size, &shm_size_is_null, &shm_flag)) { RETURN_THROWS(); diff --git a/ext/tidy/config.m4 b/ext/tidy/config.m4 index ef1f5878287d0..18fa9acb3d4bd 100644 --- a/ext/tidy/config.m4 +++ b/ext/tidy/config.m4 @@ -81,7 +81,8 @@ if test "$PHP_TIDY" != "no"; then ]) AS_VAR_IF([php_ac_cv_have_tidyoptgetcategory], [yes], [AC_DEFINE([HAVE_TIDYOPTGETCATEGORY], [1], - [Define to 1 if tidyOptGetCategory is available.])]) + [Define to 1 if Tidy library has the 'tidyOptGetCategory' function and + supports the 'TidyInternalCategory' enumeration.])]) CPPFLAGS=$old_CPPFLAGS diff --git a/ext/tidy/config.w32 b/ext/tidy/config.w32 index a1f93f2976af8..1b2436ac9dfad 100644 --- a/ext/tidy/config.w32 +++ b/ext/tidy/config.w32 @@ -21,6 +21,7 @@ if (PHP_TIDY != "no") { AC_DEFINE('HAVE_TIDY_H', 1, "Define to 1 if you have the header file.") AC_DEFINE('HAVE_TIDYOPTGETDOC', 1, "Define to 1 if Tidy library has the 'tidyOptGetDoc' function.") AC_DEFINE('HAVE_TIDYRELEASEDATE', 1, "Define to 1 if Tidy library has the 'tidyReleaseDate' function.") + AC_DEFINE('HAVE_TIDYOPTGETCATEGORY', 1, "Define to 1 if Tidy library has the 'tidyOptGetCategory' function and supports the 'TidyInternalCategory' enumeration.") ADD_FLAG('CFLAGS_TIDY', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1'); if (!PHP_TIDY_SHARED) { ADD_DEF_FILE("ext\\tidy\\php_tidy.def"); diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index b1daeae9d1bad..8cf45dc7fcbbc 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -615,12 +615,14 @@ static void tidy_add_node_default_properties(PHPTidyObj *obj) do { const char *attr_name = tidyAttrName(tempattr); if (attr_name) { + zval value; const char *val = tidyAttrValue(tempattr); if (val) { - add_assoc_string(&attribute, attr_name, val); + ZVAL_STRING_FAST(&value, val); } else { - add_assoc_str(&attribute, attr_name, zend_empty_string); + ZVAL_EMPTY_STRING(&value); } + zend_hash_str_add_new(Z_ARRVAL(attribute), attr_name, strlen(attr_name), &value); } } while((tempattr = tidyAttrNext(tempattr))); } else { diff --git a/ext/tidy/tidy_arginfo.h b/ext/tidy/tidy_arginfo.h index 4084a29f4d908..2448b3bca2940 100644 --- a/ext/tidy/tidy_arginfo.h +++ b/ext/tidy/tidy_arginfo.h @@ -476,9 +476,9 @@ static zend_class_entry *register_class_tidy(void) zval property_errorBuffer_default_value; ZVAL_NULL(&property_errorBuffer_default_value); - zend_string *property_errorBuffer_name = zend_string_init("errorBuffer", sizeof("errorBuffer") - 1, 1); + zend_string *property_errorBuffer_name = zend_string_init("errorBuffer", sizeof("errorBuffer") - 1, true); zend_declare_typed_property(class_entry, property_errorBuffer_name, &property_errorBuffer_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING|MAY_BE_NULL)); - zend_string_release(property_errorBuffer_name); + zend_string_release_ex(property_errorBuffer_name, true); zval property_value_default_value; ZVAL_NULL(&property_value_default_value); @@ -512,33 +512,33 @@ static zend_class_entry *register_class_tidyNode(void) zval property_column_default_value; ZVAL_UNDEF(&property_column_default_value); - zend_string *property_column_name = zend_string_init("column", sizeof("column") - 1, 1); + zend_string *property_column_name = zend_string_init("column", sizeof("column") - 1, true); zend_declare_typed_property(class_entry, property_column_name, &property_column_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_column_name); + zend_string_release_ex(property_column_name, true); zval property_proprietary_default_value; ZVAL_UNDEF(&property_proprietary_default_value); - zend_string *property_proprietary_name = zend_string_init("proprietary", sizeof("proprietary") - 1, 1); + zend_string *property_proprietary_name = zend_string_init("proprietary", sizeof("proprietary") - 1, true); zend_declare_typed_property(class_entry, property_proprietary_name, &property_proprietary_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_proprietary_name); + zend_string_release_ex(property_proprietary_name, true); zval property_id_default_value; ZVAL_UNDEF(&property_id_default_value); - zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, 1); + zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, true); zend_declare_typed_property(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_NULL)); - zend_string_release(property_id_name); + zend_string_release_ex(property_id_name, true); zval property_attribute_default_value; ZVAL_UNDEF(&property_attribute_default_value); - zend_string *property_attribute_name = zend_string_init("attribute", sizeof("attribute") - 1, 1); + zend_string *property_attribute_name = zend_string_init("attribute", sizeof("attribute") - 1, true); zend_declare_typed_property(class_entry, property_attribute_name, &property_attribute_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL)); - zend_string_release(property_attribute_name); + zend_string_release_ex(property_attribute_name, true); zval property_child_default_value; ZVAL_UNDEF(&property_child_default_value); - zend_string *property_child_name = zend_string_init("child", sizeof("child") - 1, 1); + zend_string *property_child_name = zend_string_init("child", sizeof("child") - 1, true); zend_declare_typed_property(class_entry, property_child_name, &property_child_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY|MAY_BE_NULL)); - zend_string_release(property_child_name); + zend_string_release_ex(property_child_name, true); return class_entry; } diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c index 203a9b9c36323..e594bc62ab389 100644 --- a/ext/tokenizer/tokenizer.c +++ b/ext/tokenizer/tokenizer.c @@ -381,7 +381,7 @@ static bool tokenize(zval *return_value, zend_string *source, zend_class_entry * zend_restore_lexical_state(&original_lex_state); zend_hash_destroy(&interned_strings); - return 1; + return true; } struct event_context { diff --git a/ext/tokenizer/tokenizer_arginfo.h b/ext/tokenizer/tokenizer_arginfo.h index b98a5655b6c74..f5040b70cf280 100644 --- a/ext/tokenizer/tokenizer_arginfo.h +++ b/ext/tokenizer/tokenizer_arginfo.h @@ -72,15 +72,15 @@ static zend_class_entry *register_class_PhpToken(zend_class_entry *class_entry_S zval property_id_default_value; ZVAL_UNDEF(&property_id_default_value); - zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, 1); + zend_string *property_id_name = zend_string_init("id", sizeof("id") - 1, true); zend_declare_typed_property(class_entry, property_id_name, &property_id_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_id_name); + zend_string_release_ex(property_id_name, true); zval property_text_default_value; ZVAL_UNDEF(&property_text_default_value); - zend_string *property_text_name = zend_string_init("text", sizeof("text") - 1, 1); + zend_string *property_text_name = zend_string_init("text", sizeof("text") - 1, true); zend_declare_typed_property(class_entry, property_text_name, &property_text_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_text_name); + zend_string_release_ex(property_text_name, true); zval property_line_default_value; ZVAL_UNDEF(&property_line_default_value); @@ -88,9 +88,9 @@ static zend_class_entry *register_class_PhpToken(zend_class_entry *class_entry_S zval property_pos_default_value; ZVAL_UNDEF(&property_pos_default_value); - zend_string *property_pos_name = zend_string_init("pos", sizeof("pos") - 1, 1); + zend_string *property_pos_name = zend_string_init("pos", sizeof("pos") - 1, true); zend_declare_typed_property(class_entry, property_pos_name, &property_pos_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_pos_name); + zend_string_release_ex(property_pos_name, true); return class_entry; } diff --git a/ext/uri/config.m4 b/ext/uri/config.m4 index 99e0d6b476779..390d8eb223cb9 100644 --- a/ext/uri/config.m4 +++ b/ext/uri/config.m4 @@ -33,7 +33,7 @@ if test "$PHP_EXTERNAL_URIPARSER" = "no"; then $URIPARSER_DIR/src/UriSetScheme.c $URIPARSER_DIR/src/UriSetUserInfo.c $URIPARSER_DIR/src/UriShorten.c $URIPARSER_DIR/src/UriVersion.c" URI_CFLAGS="-DURI_STATIC_BUILD" else - PKG_CHECK_MODULES([LIBURIPARSER], [liburiparser >= 0.9.10]) + PKG_CHECK_MODULES([LIBURIPARSER], [liburiparser >= 1.0.0]) PHP_EVAL_LIBLINE([$LIBURIPARSER_LIBS], [URI_SHARED_LIBADD]) PHP_EVAL_INCLINE([$LIBURIPARSER_CFLAGS]) fi diff --git a/ext/uri/php_uri.c b/ext/uri/php_uri.c index 29b26f7b8ce27..77fc627b6a99d 100644 --- a/ext/uri/php_uri.c +++ b/ext/uri/php_uri.c @@ -30,7 +30,7 @@ #include "uri_parser_rfc3986.h" #include "uri_parser_php_parse_url.h" #include "php_uri_arginfo.h" -#include "uriparser/UriBase.h" +#include "uriparser/Uri.h" zend_class_entry *php_uri_ce_rfc3986_uri; zend_class_entry *php_uri_ce_whatwg_url; diff --git a/ext/uri/php_uri_arginfo.h b/ext/uri/php_uri_arginfo.h index 602e996b1a226..d3a9c4fde7bca 100644 --- a/ext/uri/php_uri_arginfo.h +++ b/ext/uri/php_uri_arginfo.h @@ -374,9 +374,9 @@ static zend_class_entry *register_class_Uri_WhatWg_InvalidUrlException(zend_clas zval property_errors_default_value; ZVAL_UNDEF(&property_errors_default_value); - zend_string *property_errors_name = zend_string_init("errors", sizeof("errors") - 1, 1); + zend_string *property_errors_name = zend_string_init("errors", sizeof("errors") - 1, true); zend_declare_typed_property(class_entry, property_errors_name, &property_errors_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY)); - zend_string_release(property_errors_name); + zend_string_release_ex(property_errors_name, true); return class_entry; } @@ -455,9 +455,9 @@ static zend_class_entry *register_class_Uri_WhatWg_UrlValidationError(void) zval property_context_default_value; ZVAL_UNDEF(&property_context_default_value); - zend_string *property_context_name = zend_string_init("context", sizeof("context") - 1, 1); + zend_string *property_context_name = zend_string_init("context", sizeof("context") - 1, true); zend_declare_typed_property(class_entry, property_context_name, &property_context_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_context_name); + zend_string_release_ex(property_context_name, true); zval property_type_default_value; ZVAL_UNDEF(&property_type_default_value); @@ -466,9 +466,9 @@ static zend_class_entry *register_class_Uri_WhatWg_UrlValidationError(void) zval property_failure_default_value; ZVAL_UNDEF(&property_failure_default_value); - zend_string *property_failure_name = zend_string_init("failure", sizeof("failure") - 1, 1); + zend_string *property_failure_name = zend_string_init("failure", sizeof("failure") - 1, true); zend_declare_typed_property(class_entry, property_failure_name, &property_failure_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_failure_name); + zend_string_release_ex(property_failure_name, true); return class_entry; } diff --git a/ext/uri/tests/whatwg/getters/gh20771.phpt b/ext/uri/tests/whatwg/getters/gh20771.phpt new file mode 100644 index 0000000000000..19f1d1fb0f500 --- /dev/null +++ b/ext/uri/tests/whatwg/getters/gh20771.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-20771 (Assertion failure when getUnicodeHost() returns empty string) +--EXTENSIONS-- +uri +--FILE-- +getUnicodeHost()); + +?> +--EXPECT-- +string(0) "" diff --git a/ext/uri/uri_parser_rfc3986.c b/ext/uri/uri_parser_rfc3986.c index 29d2025899420..69bd6ef9ecdc4 100644 --- a/ext/uri/uri_parser_rfc3986.c +++ b/ext/uri/uri_parser_rfc3986.c @@ -149,7 +149,7 @@ static zend_result php_uri_parser_rfc3986_scheme_write(void *uri, zval *value, z } } -ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_userinfo_read(void *uri, php_uri_component_read_mode read_mode, zval *retval) +ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_userinfo_read(php_uri_parser_rfc3986_uris *uri, php_uri_component_read_mode read_mode, zval *retval) { const UriUriA *uriparser_uri = get_uri_for_reading(uri, read_mode); @@ -162,7 +162,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result php_uri_parser_rfc3986_userinfo_read(void *ur return SUCCESS; } -zend_result php_uri_parser_rfc3986_userinfo_write(void *uri, zval *value, zval *errors) +zend_result php_uri_parser_rfc3986_userinfo_write(php_uri_parser_rfc3986_uris *uri, zval *value, zval *errors) { UriUriA *uriparser_uri = get_uri_for_writing(uri); int result; diff --git a/ext/uri/uri_parser_rfc3986.h b/ext/uri/uri_parser_rfc3986.h index fbbfefb30af61..4d88478b6063d 100644 --- a/ext/uri/uri_parser_rfc3986.h +++ b/ext/uri/uri_parser_rfc3986.h @@ -23,8 +23,8 @@ PHPAPI extern const php_uri_parser php_uri_parser_rfc3986; typedef struct php_uri_parser_rfc3986_uris php_uri_parser_rfc3986_uris; -zend_result php_uri_parser_rfc3986_userinfo_read(void *uri, php_uri_component_read_mode read_mode, zval *retval); -zend_result php_uri_parser_rfc3986_userinfo_write(void *uri, zval *value, zval *errors); +zend_result php_uri_parser_rfc3986_userinfo_read(php_uri_parser_rfc3986_uris *uri, php_uri_component_read_mode read_mode, zval *retval); +zend_result php_uri_parser_rfc3986_userinfo_write(php_uri_parser_rfc3986_uris *uri, zval *value, zval *errors); php_uri_parser_rfc3986_uris *php_uri_parser_rfc3986_parse_ex(const char *uri_str, size_t uri_str_len, const php_uri_parser_rfc3986_uris *uriparser_base_url, bool silent); diff --git a/ext/uri/uri_parser_whatwg.c b/ext/uri/uri_parser_whatwg.c index 2e9ffad22d463..055f130af7c65 100644 --- a/ext/uri/uri_parser_whatwg.c +++ b/ext/uri/uri_parser_whatwg.c @@ -365,7 +365,7 @@ static zend_result php_uri_parser_whatwg_host_read(void *uri, php_uri_component_ lxb_url_serialize_host_unicode(&lexbor_idna, &lexbor_uri->host, serialize_to_smart_str_callback, &host_str); lxb_unicode_idna_clean(&lexbor_idna); - ZVAL_NEW_STR(retval, smart_str_extract(&host_str)); + ZVAL_STR(retval, smart_str_extract(&host_str)); break; } case PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII: diff --git a/ext/uri/uriparser/include/uriparser/Uri.h b/ext/uri/uriparser/include/uriparser/Uri.h index ea52097d6de58..88976a4846271 100644 --- a/ext/uri/uriparser/include/uriparser/Uri.h +++ b/ext/uri/uriparser/include/uriparser/Uri.h @@ -1,4 +1,4 @@ -/* 207ee4485d5a4690064bec14d369884451a49ae32e907b5bc6502c2bfa338ca1 (0.9.9+) +/* 5abed1007be99942f49ffe603a894d277066b79b9cb824547af0f3b9481cb9ca (1.0.0+) * * uriparser - RFC 3986 URI parsing library * diff --git a/ext/uri/uriparser/include/uriparser/UriBase.h b/ext/uri/uriparser/include/uriparser/UriBase.h index f8256951fe34a..3a9a868e3bb18 100644 --- a/ext/uri/uriparser/include/uriparser/UriBase.h +++ b/ext/uri/uriparser/include/uriparser/UriBase.h @@ -50,9 +50,9 @@ # define URI_ANSI_TO_UNICODE(x) URI_ANSI_TO_UNICODE_HELPER(x) /* Version */ -# define URI_VER_MAJOR 0 -# define URI_VER_MINOR 9 -# define URI_VER_RELEASE 9 +# define URI_VER_MAJOR 1 +# define URI_VER_MINOR 0 +# define URI_VER_RELEASE 0 # define URI_VER_SUFFIX_ANSI "" # define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI) @@ -394,7 +394,7 @@ URI_PUBLIC int uriTestMemoryManager(UriMemoryManager * memory); * @see uriEmulateReallocarray * @see UriMemoryManager * @see uriTestMemoryManager - * @since 0.9.10 + * @since 1.0.0 */ URI_PUBLIC int uriTestMemoryManagerEx(UriMemoryManager * memory, UriBool challengeAlignment); diff --git a/ext/uri/uriparser/src/UriCommon.c b/ext/uri/uriparser/src/UriCommon.c index a594fcceed716..3644e8828f35f 100644 --- a/ext/uri/uriparser/src/UriCommon.c +++ b/ext/uri/uriparser/src/UriCommon.c @@ -62,6 +62,7 @@ # ifndef URI_DOXYGEN # include # include "UriCommon.h" +# include "UriSets.h" # endif # include @@ -468,32 +469,11 @@ UriBool URI_FUNC(RemoveDotSegmentsAbsolute)(URI_TYPE(Uri) * uri, unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig) { switch (hexdig) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): + case URI_SET_DIGIT(_UT): return (unsigned char)(9 + hexdig - _UT('9')); - - case _UT('a'): - case _UT('b'): - case _UT('c'): - case _UT('d'): - case _UT('e'): - case _UT('f'): + case URI_SET_HEX_LETTER_LOWER(_UT): return (unsigned char)(15 + hexdig - _UT('f')); - - case _UT('A'): - case _UT('B'): - case _UT('C'): - case _UT('D'): - case _UT('E'): - case _UT('F'): + case URI_SET_HEX_LETTER_UPPER(_UT): return (unsigned char)(15 + hexdig - _UT('F')); default: diff --git a/ext/uri/uriparser/src/UriEscape.c b/ext/uri/uriparser/src/UriEscape.c index b23050783fb33..a1763f97153cf 100644 --- a/ext/uri/uriparser/src/UriEscape.c +++ b/ext/uri/uriparser/src/UriEscape.c @@ -62,6 +62,7 @@ # ifndef URI_DOXYGEN # include # include "UriCommon.h" +# include "UriSets.h" # endif URI_CHAR * URI_FUNC(Escape)(const URI_CHAR * in, URI_CHAR * out, UriBool spaceToPlus, @@ -108,72 +109,7 @@ URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst, const URI_CHAR * inAfter prevWasCr = URI_FALSE; break; - case _UT('a'): /* ALPHA */ - case _UT('A'): - case _UT('b'): - case _UT('B'): - case _UT('c'): - case _UT('C'): - case _UT('d'): - case _UT('D'): - case _UT('e'): - case _UT('E'): - case _UT('f'): - case _UT('F'): - case _UT('g'): - case _UT('G'): - case _UT('h'): - case _UT('H'): - case _UT('i'): - case _UT('I'): - case _UT('j'): - case _UT('J'): - case _UT('k'): - case _UT('K'): - case _UT('l'): - case _UT('L'): - case _UT('m'): - case _UT('M'): - case _UT('n'): - case _UT('N'): - case _UT('o'): - case _UT('O'): - case _UT('p'): - case _UT('P'): - case _UT('q'): - case _UT('Q'): - case _UT('r'): - case _UT('R'): - case _UT('s'): - case _UT('S'): - case _UT('t'): - case _UT('T'): - case _UT('u'): - case _UT('U'): - case _UT('v'): - case _UT('V'): - case _UT('w'): - case _UT('W'): - case _UT('x'): - case _UT('X'): - case _UT('y'): - case _UT('Y'): - case _UT('z'): - case _UT('Z'): - case _UT('0'): /* DIGIT */ - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - case _UT('-'): /* "-" / "." / "_" / "~" */ - case _UT('.'): - case _UT('_'): - case _UT('~'): + case URI_SET_UNRESERVED(_UT): /* Copy unmodified */ write[0] = read[0]; write++; @@ -263,51 +199,9 @@ const URI_CHAR * URI_FUNC(UnescapeInPlaceEx)(URI_CHAR * inout, UriBool plusToSpa case _UT('%'): switch (read[1]) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - case _UT('a'): - case _UT('b'): - case _UT('c'): - case _UT('d'): - case _UT('e'): - case _UT('f'): - case _UT('A'): - case _UT('B'): - case _UT('C'): - case _UT('D'): - case _UT('E'): - case _UT('F'): + case URI_SET_HEXDIG(_UT): switch (read[2]) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): - case _UT('a'): - case _UT('b'): - case _UT('c'): - case _UT('d'): - case _UT('e'): - case _UT('f'): - case _UT('A'): - case _UT('B'): - case _UT('C'): - case _UT('D'): - case _UT('E'): - case _UT('F'): { + case URI_SET_HEXDIG(_UT): { /* Percent group found */ const unsigned char left = URI_FUNC(HexdigToInt)(read[1]); const unsigned char right = URI_FUNC(HexdigToInt)(read[2]); diff --git a/ext/uri/uriparser/src/UriIp4.c b/ext/uri/uriparser/src/UriIp4.c index 162a75a556d49..ae61141f7a3ad 100644 --- a/ext/uri/uriparser/src/UriIp4.c +++ b/ext/uri/uriparser/src/UriIp4.c @@ -68,6 +68,7 @@ # include # include "UriIp4Base.h" # include +# include "UriSets.h" # endif /* Prototypes */ @@ -194,16 +195,7 @@ URI_FUNC(ParseDecOctetOne)(UriIp4Parser * parser, const URI_CHAR * first, } switch (*first) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): + case URI_SET_DIGIT(_UT): uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); return (const URI_CHAR *)URI_FUNC(ParseDecOctetThree)(parser, first + 1, afterLast); @@ -272,16 +264,7 @@ URI_FUNC(ParseDecOctetThree)(UriIp4Parser * parser, const URI_CHAR * first, } switch (*first) { - case _UT('0'): - case _UT('1'): - case _UT('2'): - case _UT('3'): - case _UT('4'): - case _UT('5'): - case _UT('6'): - case _UT('7'): - case _UT('8'): - case _UT('9'): + case URI_SET_DIGIT(_UT): uriPushToStack(parser, (unsigned char)(9 + *first - _UT('9'))); return first + 1; diff --git a/ext/uri/uriparser/src/UriParse.c b/ext/uri/uriparser/src/UriParse.c index db48b380464b1..cada02301e00c 100644 --- a/ext/uri/uriparser/src/UriParse.c +++ b/ext/uri/uriparser/src/UriParse.c @@ -71,82 +71,9 @@ # include "UriCommon.h" # include "UriMemory.h" # include "UriParseBase.h" +# include "UriSets.h" # endif -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -# define URI_SET_HEX_LETTER_UPPER \ - _UT('A') : case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -# define URI_SET_HEX_LETTER_LOWER \ - _UT('a') : case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -# define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -# define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - static const URI_CHAR * URI_FUNC(ParseAuthority)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, @@ -154,8 +81,7 @@ static const URI_CHAR * URI_FUNC(ParseAuthority)(URI_TYPE(ParserState) * state, static const URI_CHAR * URI_FUNC(ParseAuthorityTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast); -static const URI_CHAR * URI_FUNC(ParseHexZero)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, +static const URI_CHAR * URI_FUNC(ParseHexZero)(const URI_CHAR * first, const URI_CHAR * afterLast); static const URI_CHAR * URI_FUNC(ParseHierPart)(URI_TYPE(ParserState) * state, const URI_CHAR * first, @@ -165,10 +91,6 @@ static const URI_CHAR * URI_FUNC(ParseIpFutLoop)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseIpFutStopGo)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, - const URI_CHAR * afterLast, - UriMemoryManager * memory); static const URI_CHAR * URI_FUNC(ParseIpLit2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, @@ -189,10 +111,6 @@ static const URI_CHAR * URI_FUNC(ParseOwnHost2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfo)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, - const URI_CHAR * afterLast, - UriMemoryManager * memory); static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfoNz)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, @@ -233,8 +151,7 @@ static const URI_CHAR * URI_FUNC(ParsePctSubUnres)(URI_TYPE(ParserState) * state const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory); -static const URI_CHAR * URI_FUNC(ParsePort)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, +static const URI_CHAR * URI_FUNC(ParsePort)(const URI_CHAR * first, const URI_CHAR * afterLast); static const URI_CHAR * URI_FUNC(ParseQueryFrag)(URI_TYPE(ParserState) * state, const URI_CHAR * first, @@ -340,26 +257,7 @@ static URI_INLINE const URI_CHAR * URI_FUNC(ParseAuthority)(URI_TYPE(ParserState return URI_FUNC(ParseAuthorityTwo)(state, afterIpLit2, afterLast); } - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: + case URI_SET_PCHAR(_UT): state->uri->userInfo.first = first; /* USERINFO BEGIN */ return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory); @@ -384,8 +282,7 @@ URI_FUNC(ParseAuthorityTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * firs switch (*first) { case _UT(':'): { - const URI_CHAR * const afterPort = - URI_FUNC(ParsePort)(state, first + 1, afterLast); + const URI_CHAR * const afterPort = URI_FUNC(ParsePort)(first + 1, afterLast); if (afterPort == NULL) { return NULL; } @@ -403,16 +300,17 @@ URI_FUNC(ParseAuthorityTwo)(URI_TYPE(ParserState) * state, const URI_CHAR * firs * [hexZero]->[HEXDIG][hexZero] * [hexZero]-> */ -static const URI_CHAR * URI_FUNC(ParseHexZero)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, +static const URI_CHAR * URI_FUNC(ParseHexZero)(const URI_CHAR * first, const URI_CHAR * afterLast) { +tail_call: if (first >= afterLast) { return afterLast; } switch (*first) { - case URI_SET_HEXDIG: - return URI_FUNC(ParseHexZero)(state, first + 1, afterLast); + case URI_SET_HEXDIG(_UT): + first += 1; + goto tail_call; default: return first; @@ -433,26 +331,7 @@ static URI_INLINE const URI_CHAR * URI_FUNC(ParseHierPart)(URI_TYPE(ParserState) } switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: + case URI_SET_PCHAR(_UT): return URI_FUNC(ParsePathRootless)(state, first, afterLast, memory); case _UT('/'): @@ -467,79 +346,37 @@ static URI_INLINE const URI_CHAR * URI_FUNC(ParseHierPart)(URI_TYPE(ParserState) * [ipFutLoop]->[subDelims][ipFutStopGo] * [ipFutLoop]->[unreserved][ipFutStopGo] * [ipFutLoop]-><:>[ipFutStopGo] + * + * [ipFutStopGo]->[ipFutLoop] + * [ipFutStopGo]-> */ static const URI_CHAR * URI_FUNC(ParseIpFutLoop)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } + const URI_CHAR * const originalFirst = first; - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseIpFutStopGo)(state, first + 1, afterLast, memory); + while (first < afterLast) { + switch (*first) { + case _UT(':'): + case URI_SET_SUB_DELIMS(_UT): + case URI_SET_UNRESERVED(_UT): + first += 1; + break; - default: - URI_FUNC(StopSyntax)(state, first, memory); - return NULL; + default: + goto done_looping; + break; + } } -} -/* - * [ipFutStopGo]->[ipFutLoop] - * [ipFutStopGo]-> - */ -static const URI_CHAR * URI_FUNC(ParseIpFutStopGo)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, - const URI_CHAR * afterLast, - UriMemoryManager * memory) { - if (first >= afterLast) { - return afterLast; +done_looping: + if (first == originalFirst) { + URI_FUNC(StopSyntax)(state, first, memory); + return NULL; } - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseIpFutLoop)(state, first, afterLast, memory); - - default: - return first; - } + return first; } /* @@ -568,10 +405,10 @@ static const URI_CHAR * URI_FUNC(ParseIpFuture)(URI_TYPE(ParserState) * state, } switch (first[1]) { - case URI_SET_HEXDIG: { + case URI_SET_HEXDIG(_UT): { const URI_CHAR * afterIpFutLoop; const URI_CHAR * const afterHexZero = - URI_FUNC(ParseHexZero)(state, first + 2, afterLast); + URI_FUNC(ParseHexZero)(first + 2, afterLast); if (afterHexZero == NULL) { return NULL; } @@ -643,7 +480,7 @@ static URI_INLINE const URI_CHAR * URI_FUNC(ParseIpLit2)(URI_TYPE(ParserState) * case _UT(':'): case _UT(']'): - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): state->uri->hostData.ip6 = memory->malloc( memory, 1 * sizeof(UriIp6)); /* Freed when stopping on parse error */ if (state->uri->hostData.ip6 == NULL) { @@ -685,7 +522,7 @@ static const URI_CHAR * URI_FUNC(ParseIPv6address2)(URI_TYPE(ParserState) * stat /* Eat rest of IPv4 address */ for (;;) { switch (*first) { - case URI_SET_DIGIT: + case URI_SET_DIGIT(_UT): if (digitCount == 4) { URI_FUNC(StopSyntax)(state, first, memory); return NULL; @@ -780,7 +617,7 @@ static const URI_CHAR * URI_FUNC(ParseIPv6address2)(URI_TYPE(ParserState) * stat int walking = 1; do { switch (*first) { - case URI_SET_HEX_LETTER_LOWER: + case URI_SET_HEX_LETTER_LOWER(_UT): letterAmong = 1; if (digitCount == 4) { URI_FUNC(StopSyntax)(state, first, memory); @@ -790,7 +627,7 @@ static const URI_CHAR * URI_FUNC(ParseIPv6address2)(URI_TYPE(ParserState) * stat digitCount++; break; - case URI_SET_HEX_LETTER_UPPER: + case URI_SET_HEX_LETTER_UPPER(_UT): letterAmong = 1; if (digitCount == 4) { URI_FUNC(StopSyntax)(state, first, memory); @@ -800,7 +637,7 @@ static const URI_CHAR * URI_FUNC(ParseIPv6address2)(URI_TYPE(ParserState) * stat digitCount++; break; - case URI_SET_DIGIT: + case URI_SET_DIGIT(_UT): if (digitCount == 4) { URI_FUNC(StopSyntax)(state, first, memory); return NULL; @@ -973,6 +810,7 @@ static const URI_CHAR * URI_FUNC(ParseMustBeSegmentNzNc)(URI_TYPE(ParserState) * const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { if (!URI_FUNC(PushPathSegment)(state, state->uri->scheme.first, first, memory)) { /* SEGMENT BOTH */ @@ -990,29 +828,15 @@ static const URI_CHAR * URI_FUNC(ParseMustBeSegmentNzNc)(URI_TYPE(ParserState) * if (afterPctEncoded == NULL) { return NULL; } - return URI_FUNC(ParseMustBeSegmentNzNc)(state, afterPctEncoded, afterLast, - memory); + first = afterPctEncoded; + goto tail_call; } case _UT('@'): - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): - case _UT('-'): - case _UT('.'): - case _UT('_'): - case _UT('~'): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseMustBeSegmentNzNc)(state, first + 1, afterLast, memory); + case URI_SET_SUB_DELIMS(_UT): + case URI_SET_UNRESERVED(_UT): + first += 1; + goto tail_call; case _UT('/'): { const URI_CHAR * afterZeroMoreSlashSegs; @@ -1109,6 +933,7 @@ static const URI_CHAR * URI_FUNC(ParseOwnHost2)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { if (!URI_FUNC(OnExitOwnHost2)(state, first, memory)) { URI_FUNC(StopMalloc)(state, memory); @@ -1118,30 +943,16 @@ static const URI_CHAR * URI_FUNC(ParseOwnHost2)(URI_TYPE(ParserState) * state, } switch (*first) { - case _UT('!'): - case _UT('$'): case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: { + case URI_SET_SUB_DELIMS(_UT): + case URI_SET_UNRESERVED(_UT): { const URI_CHAR * const afterPctSubUnres = URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory); if (afterPctSubUnres == NULL) { return NULL; } - return URI_FUNC(ParseOwnHost2)(state, afterPctSubUnres, afterLast, memory); + first = afterPctSubUnres; + goto tail_call; } default: @@ -1177,108 +988,69 @@ static URI_INLINE UriBool URI_FUNC(OnExitOwnHostUserInfo)(URI_TYPE(ParserState) return URI_TRUE; /* Success */ } -/* - * [ownHostUserInfo]->[ownHostUserInfoNz] - * [ownHostUserInfo]-> - */ -static URI_INLINE const URI_CHAR * -URI_FUNC(ParseOwnHostUserInfo)(URI_TYPE(ParserState) * state, const URI_CHAR * first, - const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return afterLast; - } - - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: - return URI_FUNC(ParseOwnHostUserInfoNz)(state, first, afterLast, memory); - - default: - if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) { - URI_FUNC(StopMalloc)(state, memory); - return NULL; - } - return first; - } -} - /* * [ownHostUserInfoNz]->[pctSubUnres][ownHostUserInfo] * [ownHostUserInfoNz]-><:>[ownPortUserInfo] * [ownHostUserInfoNz]-><@>[ownHost] + * + * [ownHostUserInfo]->[ownHostUserInfoNz] + * [ownHostUserInfo]-> */ static const URI_CHAR * URI_FUNC(ParseOwnHostUserInfoNz)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { - if (first >= afterLast) { - URI_FUNC(StopSyntax)(state, afterLast, memory); - return NULL; - } + const URI_CHAR * const originalFirst = first; + + while (first < afterLast) { + switch (*first) { + case _UT('%'): + case URI_SET_SUB_DELIMS(_UT): + case URI_SET_UNRESERVED(_UT): { + const URI_CHAR * const afterPctSubUnres = + URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory); + if (afterPctSubUnres == NULL) { + return NULL; + } + first = afterPctSubUnres; + break; + } - switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: { - const URI_CHAR * const afterPctSubUnres = - URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory); - if (afterPctSubUnres == NULL) { - return NULL; + default: + goto done_looping; + break; } - return URI_FUNC(ParseOwnHostUserInfo)(state, afterPctSubUnres, afterLast, memory); } - case _UT(':'): - state->uri->hostText.afterLast = first; /* HOST END */ - state->uri->portText.first = first + 1; /* PORT BEGIN */ - return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory); +done_looping: + if (first < afterLast) { + switch (*first) { + case _UT(':'): + state->uri->hostText.afterLast = first; /* HOST END */ + state->uri->portText.first = first + 1; /* PORT BEGIN */ + return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory); - case _UT('@'): - state->uri->userInfo.afterLast = first; /* USERINFO END */ - state->uri->hostText.first = first + 1; /* HOST BEGIN */ - return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory); + case _UT('@'): + state->uri->userInfo.afterLast = first; /* USERINFO END */ + state->uri->hostText.first = first + 1; /* HOST BEGIN */ + return URI_FUNC(ParseOwnHost)(state, first + 1, afterLast, memory); - default: - URI_FUNC(StopSyntax)(state, first, memory); + default: + break; + } + } + + if (first == originalFirst) { + URI_FUNC(StopSyntax)(state, afterLast, memory); + return NULL; + } + + if (!URI_FUNC(OnExitOwnHostUserInfo)(state, first, memory)) { + URI_FUNC(StopMalloc)(state, memory); return NULL; } + + return first; } static URI_INLINE UriBool URI_FUNC(OnExitOwnPortUserInfo)(URI_TYPE(ParserState) * state, @@ -1322,6 +1094,7 @@ static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)(URI_TYPE(ParserState) * s const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { if (!URI_FUNC(OnExitOwnPortUserInfo)(state, first, memory)) { URI_FUNC(StopMalloc)(state, memory); @@ -1331,19 +1104,7 @@ static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)(URI_TYPE(ParserState) * s } switch (*first) { - /* begin sub-delims */ - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('\''): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT('+'): - case _UT(','): - case _UT(';'): - case _UT('='): - /* end sub-delims */ + case URI_SET_SUB_DELIMS(_UT): /* begin unreserved (except alpha and digit) */ case _UT('-'): case _UT('.'): @@ -1351,13 +1112,14 @@ static const URI_CHAR * URI_FUNC(ParseOwnPortUserInfo)(URI_TYPE(ParserState) * s case _UT('~'): /* end unreserved (except alpha and digit) */ case _UT(':'): - case URI_SET_ALPHA: + case URI_SET_ALPHA(_UT): state->uri->hostText.afterLast = NULL; /* Not a host, reset */ state->uri->portText.first = NULL; /* Not a port, reset */ return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory); - case URI_SET_DIGIT: - return URI_FUNC(ParseOwnPortUserInfo)(state, first + 1, afterLast, memory); + case URI_SET_DIGIT(_UT): + first += 1; + goto tail_call; case _UT('%'): state->uri->portText.first = NULL; /* Not a port, reset */ @@ -1393,40 +1155,28 @@ static const URI_CHAR * URI_FUNC(ParseOwnUserInfo)(URI_TYPE(ParserState) * state const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { URI_FUNC(StopSyntax)(state, afterLast, memory); return NULL; } switch (*first) { - case _UT('!'): - case _UT('$'): case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(';'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: { + case URI_SET_SUB_DELIMS(_UT): + case URI_SET_UNRESERVED(_UT): { const URI_CHAR * const afterPctSubUnres = URI_FUNC(ParsePctSubUnres)(state, first, afterLast, memory); if (afterPctSubUnres == NULL) { return NULL; } - return URI_FUNC(ParseOwnUserInfo)(state, afterPctSubUnres, afterLast, memory); + first = afterPctSubUnres; + goto tail_call; } case _UT(':'): - return URI_FUNC(ParseOwnUserInfo)(state, first + 1, afterLast, memory); + first += 1; + goto tail_call; case _UT('@'): /* SURE */ @@ -1486,6 +1236,7 @@ static const URI_CHAR * URI_FUNC(ParsePathAbsEmpty)(URI_TYPE(ParserState) * stat const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { return afterLast; } @@ -1502,7 +1253,8 @@ static const URI_CHAR * URI_FUNC(ParsePathAbsEmpty)(URI_TYPE(ParserState) * stat URI_FUNC(StopMalloc)(state, memory); return NULL; } - return URI_FUNC(ParsePathAbsEmpty)(state, afterSegment, afterLast, memory); + first = afterSegment; + goto tail_call; } default: @@ -1522,26 +1274,7 @@ URI_FUNC(ParsePathAbsNoLeadSlash)(URI_TYPE(ParserState) * state, const URI_CHAR } switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: { + case URI_SET_PCHAR(_UT): { const URI_CHAR * const afterSegmentNz = URI_FUNC(ParseSegmentNz)(state, first, afterLast, memory); if (afterSegmentNz == NULL) { @@ -1600,25 +1333,7 @@ static const URI_CHAR * URI_FUNC(ParsePchar)(URI_TYPE(ParserState) * state, case _UT('%'): return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - case _UT(':'): - case _UT('@'): - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): - case _UT('-'): - case _UT('.'): - case _UT('_'): - case _UT('~'): - case URI_SET_DIGIT: - case URI_SET_ALPHA: + case URI_SET_PCHAR_WITHOUT_PERCENT(_UT): return first + 1; default: @@ -1652,14 +1367,14 @@ static const URI_CHAR * URI_FUNC(ParsePctEncoded)(URI_TYPE(ParserState) * state, } switch (first[1]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): if (afterLast - first < 3) { URI_FUNC(StopSyntax)(state, afterLast, memory); return NULL; } switch (first[2]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): return first + 3; default: @@ -1698,23 +1413,8 @@ static const URI_CHAR * URI_FUNC(ParsePctSubUnres)(URI_TYPE(ParserState) * state case _UT('%'): return URI_FUNC(ParsePctEncoded)(state, first, afterLast, memory); - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): - case _UT('-'): - case _UT('.'): - case _UT('_'): - case _UT('~'): - case URI_SET_DIGIT: - case URI_SET_ALPHA: + case URI_SET_SUB_DELIMS(_UT): + case URI_SET_UNRESERVED(_UT): return first + 1; default: @@ -1727,16 +1427,17 @@ static const URI_CHAR * URI_FUNC(ParsePctSubUnres)(URI_TYPE(ParserState) * state * [port]->[DIGIT][port] * [port]-> */ -static const URI_CHAR * URI_FUNC(ParsePort)(URI_TYPE(ParserState) * state, - const URI_CHAR * first, +static const URI_CHAR * URI_FUNC(ParsePort)(const URI_CHAR * first, const URI_CHAR * afterLast) { +tail_call: if (first >= afterLast) { return afterLast; } switch (*first) { - case URI_SET_DIGIT: - return URI_FUNC(ParsePort)(state, first + 1, afterLast); + case URI_SET_DIGIT(_UT): + first += 1; + goto tail_call; default: return first; @@ -1753,42 +1454,26 @@ static const URI_CHAR * URI_FUNC(ParseQueryFrag)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { return afterLast; } switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: { + case URI_SET_PCHAR(_UT): { const URI_CHAR * const afterPchar = URI_FUNC(ParsePchar)(state, first, afterLast, memory); if (afterPchar == NULL) { return NULL; } - return URI_FUNC(ParseQueryFrag)(state, afterPchar, afterLast, memory); + first = afterPchar; + goto tail_call; } case _UT('/'): case _UT('?'): - return URI_FUNC(ParseQueryFrag)(state, first + 1, afterLast, memory); + first += 1; + goto tail_call; default: return first; @@ -1803,37 +1488,20 @@ static const URI_CHAR * URI_FUNC(ParseSegment)(URI_TYPE(ParserState) * state, const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { return afterLast; } switch (*first) { - case _UT('!'): - case _UT('$'): - case _UT('%'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('-'): - case _UT('*'): - case _UT(','): - case _UT('.'): - case _UT(':'): - case _UT(';'): - case _UT('@'): - case _UT('\''): - case _UT('_'): - case _UT('~'): - case _UT('+'): - case _UT('='): - case URI_SET_DIGIT: - case URI_SET_ALPHA: { + case URI_SET_PCHAR(_UT): { const URI_CHAR * const afterPchar = URI_FUNC(ParsePchar)(state, first, afterLast, memory); if (afterPchar == NULL) { return NULL; } - return URI_FUNC(ParseSegment)(state, afterPchar, afterLast, memory); + first = afterPchar; + goto tail_call; } default: @@ -1894,6 +1562,7 @@ static const URI_CHAR * URI_FUNC(ParseSegmentNzNcOrScheme2)(URI_TYPE(ParserState const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { if (!URI_FUNC(OnExitSegmentNzNcOrScheme2)(state, first, memory)) { URI_FUNC(StopMalloc)(state, memory); @@ -1906,9 +1575,10 @@ static const URI_CHAR * URI_FUNC(ParseSegmentNzNcOrScheme2)(URI_TYPE(ParserState case _UT('.'): case _UT('+'): case _UT('-'): - case URI_SET_ALPHA: - case URI_SET_DIGIT: - return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory); + case URI_SET_ALPHA(_UT): + case URI_SET_DIGIT(_UT): + first += 1; + goto tail_call; case _UT('%'): { const URI_CHAR * const afterPctEncoded = @@ -2002,22 +1672,12 @@ static const URI_CHAR * URI_FUNC(ParseUriReference)(URI_TYPE(ParserState) * stat } switch (*first) { - case URI_SET_ALPHA: + case URI_SET_ALPHA(_UT): state->uri->scheme.first = first; /* SCHEME BEGIN */ return URI_FUNC(ParseSegmentNzNcOrScheme2)(state, first + 1, afterLast, memory); - case URI_SET_DIGIT: - case _UT('!'): - case _UT('$'): - case _UT('&'): - case _UT('('): - case _UT(')'): - case _UT('*'): - case _UT(','): - case _UT(';'): - case _UT('\''): - case _UT('+'): - case _UT('='): + case URI_SET_DIGIT(_UT): + case URI_SET_SUB_DELIMS(_UT): case _UT('.'): case _UT('_'): case _UT('~'): @@ -2128,6 +1788,7 @@ static const URI_CHAR * URI_FUNC(ParseZeroMoreSlashSegs)(URI_TYPE(ParserState) * const URI_CHAR * first, const URI_CHAR * afterLast, UriMemoryManager * memory) { +tail_call: if (first >= afterLast) { return afterLast; } @@ -2144,7 +1805,8 @@ static const URI_CHAR * URI_FUNC(ParseZeroMoreSlashSegs)(URI_TYPE(ParserState) * URI_FUNC(StopMalloc)(state, memory); return NULL; } - return URI_FUNC(ParseZeroMoreSlashSegs)(state, afterSegment, afterLast, memory); + first = afterSegment; + goto tail_call; } default: diff --git a/ext/uri/uriparser/src/UriSetFragment.c b/ext/uri/uriparser/src/UriSetFragment.c index b9c5c53b04202..4479391d859dc 100644 --- a/ext/uri/uriparser/src/UriSetFragment.c +++ b/ext/uri/uriparser/src/UriSetFragment.c @@ -62,104 +62,11 @@ # include # include "UriCommon.h" # include "UriMemory.h" +# include "UriSets.h" # endif # include -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -# define URI_SET_HEX_LETTER_UPPER \ - _UT('A') : case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -# define URI_SET_HEX_LETTER_LOWER \ - _UT('a') : case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -# define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -# define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - -# define URI_SET_SUB_DELIMS \ - _UT('!') : case _UT('$'): \ - case _UT('&'): \ - case _UT('\''): \ - case _UT('('): \ - case _UT(')'): \ - case _UT('*'): \ - case _UT('+'): \ - case _UT(','): \ - case _UT(';'): \ - case _UT('=') - -# define URI_SET_UNRESERVED \ - URI_SET_ALPHA: \ - case URI_SET_DIGIT: \ - case _UT('-'): \ - case _UT('.'): \ - case _UT('_'): \ - case _UT('~') - UriBool URI_FUNC(IsWellFormedFragment)(const URI_CHAR * first, const URI_CHAR * afterLast) { if ((first == NULL) || (afterLast == NULL)) { @@ -173,7 +80,7 @@ UriBool URI_FUNC(IsWellFormedFragment)(const URI_CHAR * first, */ while (first < afterLast) { switch (first[0]) { - case URI_SET_UNRESERVED: + case URI_SET_PCHAR_WITHOUT_PERCENT(_UT): break; /* pct-encoded */ @@ -182,13 +89,13 @@ UriBool URI_FUNC(IsWellFormedFragment)(const URI_CHAR * first, return URI_FALSE; } switch (first[1]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; } switch (first[2]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; @@ -196,12 +103,6 @@ UriBool URI_FUNC(IsWellFormedFragment)(const URI_CHAR * first, first += 2; break; - case URI_SET_SUB_DELIMS: - break; - - /* ":" / "@" and "/" / "?" */ - case _UT(':'): - case _UT('@'): case _UT('/'): case _UT('?'): break; diff --git a/ext/uri/uriparser/src/UriSetHostRegName.c b/ext/uri/uriparser/src/UriSetHostRegName.c index 61694b248adc6..01bc4e47f16ef 100644 --- a/ext/uri/uriparser/src/UriSetHostRegName.c +++ b/ext/uri/uriparser/src/UriSetHostRegName.c @@ -63,102 +63,9 @@ # include "UriMemory.h" # include "UriSetHostBase.h" # include "UriSetHostCommon.h" +# include "UriSets.h" # endif -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -# define URI_SET_HEX_LETTER_UPPER \ - _UT('A') : case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -# define URI_SET_HEX_LETTER_LOWER \ - _UT('a') : case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -# define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -# define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - -# define URI_SET_SUB_DELIMS \ - _UT('!') : case _UT('$'): \ - case _UT('&'): \ - case _UT('\''): \ - case _UT('('): \ - case _UT(')'): \ - case _UT('*'): \ - case _UT('+'): \ - case _UT(','): \ - case _UT(';'): \ - case _UT('=') - -# define URI_SET_UNRESERVED \ - URI_SET_ALPHA: \ - case URI_SET_DIGIT: \ - case _UT('-'): \ - case _UT('.'): \ - case _UT('_'): \ - case _UT('~') - UriBool URI_FUNC(IsWellFormedHostRegName)(const URI_CHAR * first, const URI_CHAR * afterLast) { if ((first == NULL) || (afterLast == NULL)) { @@ -168,7 +75,7 @@ UriBool URI_FUNC(IsWellFormedHostRegName)(const URI_CHAR * first, /* reg-name = *( unreserved / pct-encoded / sub-delims ) */ while (first < afterLast) { switch (first[0]) { - case URI_SET_UNRESERVED: + case URI_SET_UNRESERVED(_UT): break; /* pct-encoded */ @@ -177,13 +84,13 @@ UriBool URI_FUNC(IsWellFormedHostRegName)(const URI_CHAR * first, return URI_FALSE; } switch (first[1]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; } switch (first[2]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; @@ -191,7 +98,7 @@ UriBool URI_FUNC(IsWellFormedHostRegName)(const URI_CHAR * first, first += 2; break; - case URI_SET_SUB_DELIMS: + case URI_SET_SUB_DELIMS(_UT): break; default: diff --git a/ext/uri/uriparser/src/UriSetPath.c b/ext/uri/uriparser/src/UriSetPath.c index d9e8bec0aa802..17aef0fca42d4 100644 --- a/ext/uri/uriparser/src/UriSetPath.c +++ b/ext/uri/uriparser/src/UriSetPath.c @@ -62,104 +62,11 @@ # include # include "UriCommon.h" # include "UriMemory.h" +# include "UriSets.h" # endif # include -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -# define URI_SET_HEX_LETTER_UPPER \ - _UT('A') : case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -# define URI_SET_HEX_LETTER_LOWER \ - _UT('a') : case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -# define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -# define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - -# define URI_SET_SUB_DELIMS \ - _UT('!') : case _UT('$'): \ - case _UT('&'): \ - case _UT('\''): \ - case _UT('('): \ - case _UT(')'): \ - case _UT('*'): \ - case _UT('+'): \ - case _UT(','): \ - case _UT(';'): \ - case _UT('=') - -# define URI_SET_UNRESERVED \ - URI_SET_ALPHA: \ - case URI_SET_DIGIT: \ - case _UT('-'): \ - case _UT('.'): \ - case _UT('_'): \ - case _UT('~') - UriBool URI_FUNC(IsWellFormedPath)(const URI_CHAR * first, const URI_CHAR * afterLast, UriBool hasHost) { if ((first == NULL) || (afterLast == NULL)) { @@ -200,7 +107,7 @@ UriBool URI_FUNC(IsWellFormedPath)(const URI_CHAR * first, const URI_CHAR * afte */ while (first < afterLast) { switch (first[0]) { - case URI_SET_UNRESERVED: + case URI_SET_PCHAR_WITHOUT_PERCENT(_UT): break; /* pct-encoded */ @@ -209,13 +116,13 @@ UriBool URI_FUNC(IsWellFormedPath)(const URI_CHAR * first, const URI_CHAR * afte return URI_FALSE; } switch (first[1]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; } switch (first[2]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; @@ -223,12 +130,6 @@ UriBool URI_FUNC(IsWellFormedPath)(const URI_CHAR * first, const URI_CHAR * afte first += 2; break; - case URI_SET_SUB_DELIMS: - break; - - /* ":" / "@" and "/" */ - case _UT(':'): - case _UT('@'): case _UT('/'): break; diff --git a/ext/uri/uriparser/src/UriSetPort.c b/ext/uri/uriparser/src/UriSetPort.c index 1c373013f66d0..5e2160e309765 100644 --- a/ext/uri/uriparser/src/UriSetPort.c +++ b/ext/uri/uriparser/src/UriSetPort.c @@ -62,21 +62,11 @@ # include # include "UriCommon.h" # include "UriMemory.h" +# include "UriSets.h" # endif # include -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - UriBool URI_FUNC(IsWellFormedPort)(const URI_CHAR * first, const URI_CHAR * afterLast) { if ((first == NULL) || (afterLast == NULL)) { return URI_FALSE; @@ -85,7 +75,7 @@ UriBool URI_FUNC(IsWellFormedPort)(const URI_CHAR * first, const URI_CHAR * afte /* NOTE: Grammar reads "port = *DIGIT" which includes the empty string. */ while (first < afterLast) { switch (first[0]) { - case URI_SET_DIGIT: + case URI_SET_DIGIT(_UT): break; default: return URI_FALSE; diff --git a/ext/uri/uriparser/src/UriSetQuery.c b/ext/uri/uriparser/src/UriSetQuery.c index a189c14bb1ed9..4f58c8286ed70 100644 --- a/ext/uri/uriparser/src/UriSetQuery.c +++ b/ext/uri/uriparser/src/UriSetQuery.c @@ -62,104 +62,11 @@ # include # include "UriCommon.h" # include "UriMemory.h" +# include "UriSets.h" # endif # include -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -# define URI_SET_HEX_LETTER_UPPER \ - _UT('A') : case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -# define URI_SET_HEX_LETTER_LOWER \ - _UT('a') : case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -# define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -# define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - -# define URI_SET_SUB_DELIMS \ - _UT('!') : case _UT('$'): \ - case _UT('&'): \ - case _UT('\''): \ - case _UT('('): \ - case _UT(')'): \ - case _UT('*'): \ - case _UT('+'): \ - case _UT(','): \ - case _UT(';'): \ - case _UT('=') - -# define URI_SET_UNRESERVED \ - URI_SET_ALPHA: \ - case URI_SET_DIGIT: \ - case _UT('-'): \ - case _UT('.'): \ - case _UT('_'): \ - case _UT('~') - UriBool URI_FUNC(IsWellFormedQuery)(const URI_CHAR * first, const URI_CHAR * afterLast) { if ((first == NULL) || (afterLast == NULL)) { return URI_FALSE; @@ -172,7 +79,7 @@ UriBool URI_FUNC(IsWellFormedQuery)(const URI_CHAR * first, const URI_CHAR * aft */ while (first < afterLast) { switch (first[0]) { - case URI_SET_UNRESERVED: + case URI_SET_PCHAR_WITHOUT_PERCENT(_UT): break; /* pct-encoded */ @@ -181,13 +88,13 @@ UriBool URI_FUNC(IsWellFormedQuery)(const URI_CHAR * first, const URI_CHAR * aft return URI_FALSE; } switch (first[1]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; } switch (first[2]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; @@ -195,12 +102,6 @@ UriBool URI_FUNC(IsWellFormedQuery)(const URI_CHAR * first, const URI_CHAR * aft first += 2; break; - case URI_SET_SUB_DELIMS: - break; - - /* ":" / "@" and "/" / "?" */ - case _UT(':'): - case _UT('@'): case _UT('/'): case _UT('?'): break; diff --git a/ext/uri/uriparser/src/UriSetScheme.c b/ext/uri/uriparser/src/UriSetScheme.c index 9a21d45f26319..3dfaf1e9f151b 100644 --- a/ext/uri/uriparser/src/UriSetScheme.c +++ b/ext/uri/uriparser/src/UriSetScheme.c @@ -62,84 +62,11 @@ # include # include "UriCommon.h" # include "UriMemory.h" +# include "UriSets.h" # endif # include -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -# define URI_SET_HEX_LETTER_UPPER \ - _UT('A') : case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -# define URI_SET_HEX_LETTER_LOWER \ - _UT('a') : case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -# define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -# define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - UriBool URI_FUNC(IsWellFormedScheme)(const URI_CHAR * first, const URI_CHAR * afterLast) { if ((first == NULL) || (afterLast == NULL)) { return URI_FALSE; @@ -154,7 +81,7 @@ UriBool URI_FUNC(IsWellFormedScheme)(const URI_CHAR * first, const URI_CHAR * af } switch (first[0]) { - case URI_SET_ALPHA: + case URI_SET_ALPHA(_UT): break; default: @@ -165,8 +92,8 @@ UriBool URI_FUNC(IsWellFormedScheme)(const URI_CHAR * first, const URI_CHAR * af while (first < afterLast) { switch (first[0]) { - case URI_SET_ALPHA: - case URI_SET_DIGIT: + case URI_SET_ALPHA(_UT): + case URI_SET_DIGIT(_UT): case _UT('+'): case _UT('-'): case _UT('.'): diff --git a/ext/uri/uriparser/src/UriSetUserInfo.c b/ext/uri/uriparser/src/UriSetUserInfo.c index af1ec41a0763d..7865e837deb66 100644 --- a/ext/uri/uriparser/src/UriSetUserInfo.c +++ b/ext/uri/uriparser/src/UriSetUserInfo.c @@ -62,104 +62,11 @@ # include # include "UriCommon.h" # include "UriMemory.h" +# include "UriSets.h" # endif # include -# define URI_SET_DIGIT \ - _UT('0') : case _UT('1'): \ - case _UT('2'): \ - case _UT('3'): \ - case _UT('4'): \ - case _UT('5'): \ - case _UT('6'): \ - case _UT('7'): \ - case _UT('8'): \ - case _UT('9') - -# define URI_SET_HEX_LETTER_UPPER \ - _UT('A') : case _UT('B'): \ - case _UT('C'): \ - case _UT('D'): \ - case _UT('E'): \ - case _UT('F') - -# define URI_SET_HEX_LETTER_LOWER \ - _UT('a') : case _UT('b'): \ - case _UT('c'): \ - case _UT('d'): \ - case _UT('e'): \ - case _UT('f') - -# define URI_SET_HEXDIG \ - URI_SET_DIGIT: \ - case URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER - -# define URI_SET_ALPHA \ - URI_SET_HEX_LETTER_UPPER: \ - case URI_SET_HEX_LETTER_LOWER: \ - case _UT('g'): \ - case _UT('G'): \ - case _UT('h'): \ - case _UT('H'): \ - case _UT('i'): \ - case _UT('I'): \ - case _UT('j'): \ - case _UT('J'): \ - case _UT('k'): \ - case _UT('K'): \ - case _UT('l'): \ - case _UT('L'): \ - case _UT('m'): \ - case _UT('M'): \ - case _UT('n'): \ - case _UT('N'): \ - case _UT('o'): \ - case _UT('O'): \ - case _UT('p'): \ - case _UT('P'): \ - case _UT('q'): \ - case _UT('Q'): \ - case _UT('r'): \ - case _UT('R'): \ - case _UT('s'): \ - case _UT('S'): \ - case _UT('t'): \ - case _UT('T'): \ - case _UT('u'): \ - case _UT('U'): \ - case _UT('v'): \ - case _UT('V'): \ - case _UT('w'): \ - case _UT('W'): \ - case _UT('x'): \ - case _UT('X'): \ - case _UT('y'): \ - case _UT('Y'): \ - case _UT('z'): \ - case _UT('Z') - -# define URI_SET_SUB_DELIMS \ - _UT('!') : case _UT('$'): \ - case _UT('&'): \ - case _UT('\''): \ - case _UT('('): \ - case _UT(')'): \ - case _UT('*'): \ - case _UT('+'): \ - case _UT(','): \ - case _UT(';'): \ - case _UT('=') - -# define URI_SET_UNRESERVED \ - URI_SET_ALPHA: \ - case URI_SET_DIGIT: \ - case _UT('-'): \ - case _UT('.'): \ - case _UT('_'): \ - case _UT('~') - UriBool URI_FUNC(IsWellFormedUserInfo)(const URI_CHAR * first, const URI_CHAR * afterLast) { if ((first == NULL) || (afterLast == NULL)) { @@ -169,7 +76,7 @@ UriBool URI_FUNC(IsWellFormedUserInfo)(const URI_CHAR * first, /* userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) */ while (first < afterLast) { switch (first[0]) { - case URI_SET_UNRESERVED: + case URI_SET_UNRESERVED(_UT): break; /* pct-encoded */ @@ -178,13 +85,13 @@ UriBool URI_FUNC(IsWellFormedUserInfo)(const URI_CHAR * first, return URI_FALSE; } switch (first[1]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; } switch (first[2]) { - case URI_SET_HEXDIG: + case URI_SET_HEXDIG(_UT): break; default: return URI_FALSE; @@ -192,7 +99,7 @@ UriBool URI_FUNC(IsWellFormedUserInfo)(const URI_CHAR * first, first += 2; break; - case URI_SET_SUB_DELIMS: + case URI_SET_SUB_DELIMS(_UT): break; /* ":" */ diff --git a/ext/uri/uriparser/src/UriSets.h b/ext/uri/uriparser/src/UriSets.h new file mode 100644 index 0000000000000..a6a2c46a14d77 --- /dev/null +++ b/ext/uri/uriparser/src/UriSets.h @@ -0,0 +1,174 @@ +/* + * uriparser - RFC 3986 URI parsing library + * + * Copyright (C) 2025, Sebastian Pipping + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products + * derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @file UriSets.h + * Holds character set definitions. + */ + +// NOTE: We cannot use a regular include-once guard here because the +// file must support being included twice, e.g. from file UriParse.c. +#if !defined(URI_SET_DIGIT) + +// clang-format off +# define URI_SET_DIGIT(ut) \ + ut('0'): \ + case ut('1'): \ + /* clang-format on */ \ + case ut('2'): \ + case ut('3'): \ + case ut('4'): \ + case ut('5'): \ + case ut('6'): \ + case ut('7'): \ + case ut('8'): \ + case ut('9') + +// clang-format off +# define URI_SET_HEX_LETTER_LOWER(ut) \ + ut('a'): \ + case ut('b'): \ + /* clang-format on */ \ + case ut('c'): \ + case ut('d'): \ + case ut('e'): \ + case ut('f') + +// clang-format off +# define URI_SET_HEX_LETTER_UPPER(ut) \ + ut('A'): \ + case ut('B'): \ + /* clang-format on */ \ + case ut('C'): \ + case ut('D'): \ + case ut('E'): \ + case ut('F') + +// clang-format off +# define URI_SET_HEXDIG(ut) \ + URI_SET_DIGIT(ut): \ + case URI_SET_HEX_LETTER_LOWER(ut): \ + /* clang-format on */ \ + case URI_SET_HEX_LETTER_UPPER(ut) + +// clang-format off +# define URI_SET_ALPHA(ut) \ + URI_SET_HEX_LETTER_UPPER(ut): \ + case URI_SET_HEX_LETTER_LOWER(ut): \ + /* clang-format on */ \ + case ut('g'): \ + case ut('G'): \ + case ut('h'): \ + case ut('H'): \ + case ut('i'): \ + case ut('I'): \ + case ut('j'): \ + case ut('J'): \ + case ut('k'): \ + case ut('K'): \ + case ut('l'): \ + case ut('L'): \ + case ut('m'): \ + case ut('M'): \ + case ut('n'): \ + case ut('N'): \ + case ut('o'): \ + case ut('O'): \ + case ut('p'): \ + case ut('P'): \ + case ut('q'): \ + case ut('Q'): \ + case ut('r'): \ + case ut('R'): \ + case ut('s'): \ + case ut('S'): \ + case ut('t'): \ + case ut('T'): \ + case ut('u'): \ + case ut('U'): \ + case ut('v'): \ + case ut('V'): \ + case ut('w'): \ + case ut('W'): \ + case ut('x'): \ + case ut('X'): \ + case ut('y'): \ + case ut('Y'): \ + case ut('z'): \ + case ut('Z') + +// clang-format off +# define URI_SET_SUB_DELIMS(ut) \ + ut('!'): \ + case ut('$'): \ + /* clang-format on */ \ + case ut('&'): \ + case ut('\''): \ + case ut('('): \ + case ut(')'): \ + case ut('*'): \ + case ut('+'): \ + case ut(','): \ + case ut(';'): \ + case ut('=') + +// clang-format off +# define URI_SET_UNRESERVED(ut) \ + URI_SET_ALPHA(ut): \ + case URI_SET_DIGIT(ut): \ + /* clang-format on */ \ + case ut('-'): \ + case ut('.'): \ + case ut('_'): \ + case ut('~') + +// clang-format off +# define URI_SET_PCHAR_WITHOUT_PERCENT(ut) \ + URI_SET_UNRESERVED(ut): \ + case URI_SET_SUB_DELIMS(ut): \ + /* clang-format on */ \ + case ut(':'): \ + case ut('@') + +// clang-format off +# define URI_SET_PCHAR(ut) \ + URI_SET_PCHAR_WITHOUT_PERCENT(ut): \ + case ut('%') +/* clang-format on */ + +#endif // ! defined(URI_SET_DIGIT) diff --git a/ext/xml/compat.c b/ext/xml/compat.c index 19577ce17a893..7e37bf1e412c3 100644 --- a/ext/xml/compat.c +++ b/ext/xml/compat.c @@ -18,19 +18,22 @@ #if defined(HAVE_LIBXML) && (defined(HAVE_XML) || defined(HAVE_XMLRPC)) && !defined(HAVE_LIBEXPAT) #include "expat_compat.h" #include "ext/libxml/php_libxml.h" +#include "Zend/zend_smart_string.h" #ifdef LIBXML_EXPAT_COMPAT -static void -qualify_namespace(XML_Parser parser, const xmlChar *name, const xmlChar *URI, xmlChar **qualified) +static xmlChar * +qualify_namespace(XML_Parser parser, const xmlChar *name, const xmlChar *URI) { if (URI) { - /* Use libxml functions otherwise its memory deallocation is screwed up */ - *qualified = xmlStrdup(URI); - *qualified = xmlStrncat(*qualified, parser->_ns_separator, 1); - *qualified = xmlStrncat(*qualified, name, xmlStrlen(name)); + smart_string str = {0}; + smart_string_appends(&str, (const char *) URI); + smart_string_appends(&str, (const char *) parser->_ns_separator); + smart_string_appends(&str, (const char *) name); + smart_string_0(&str); + return BAD_CAST str.c; } else { - *qualified = xmlStrdup(name); + return BAD_CAST estrdup((const char *) name); } } @@ -91,7 +94,7 @@ start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, start_element_emit_default(parser); return; } - qualify_namespace(parser, name, URI, &qualified_name); + qualified_name = qualify_namespace(parser, name, URI); if (attributes != NULL) { xmlChar *qualified_name_attr = NULL; @@ -100,12 +103,12 @@ start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, for (i = 0; i < nb_attributes; i += 1) { if (attributes[y+1] != NULL) { - qualify_namespace(parser, attributes[y] , attributes[y + 2], &qualified_name_attr); + qualified_name_attr = qualify_namespace(parser, attributes[y] , attributes[y + 2]); } else { - qualified_name_attr = xmlStrdup(attributes[y]); + qualified_name_attr = BAD_CAST estrdup((const char *) attributes[y]); } attrs[z] = qualified_name_attr; - attrs[z + 1] = xmlStrndup(attributes[y + 3] , (int) (attributes[y + 4] - attributes[y + 3])); + attrs[z + 1] = BAD_CAST estrndup((const char *) attributes[y + 3], attributes[y + 4] - attributes[y + 3]); z += 2; y += 5; } @@ -115,11 +118,11 @@ start_element_handler_ns(void *user, const xmlChar *name, const xmlChar *prefix, parser->h_start_element(parser->user, (const XML_Char *) qualified_name, (const XML_Char **) attrs); if (attrs) { for (i = 0; i < z; i++) { - xmlFree(attrs[i]); + efree(attrs[i]); } efree(attrs); } - xmlFree(qualified_name); + efree(qualified_name); } static void @@ -163,11 +166,11 @@ end_element_handler_ns(void *user, const xmlChar *name, const xmlChar * prefix, return; } - qualify_namespace(parser, name, URI, &qualified_name); + qualified_name = qualify_namespace(parser, name, URI); parser->h_end_element(parser->user, (const XML_Char *) qualified_name); - xmlFree(qualified_name); + efree(qualified_name); } static void @@ -231,17 +234,19 @@ notation_decl_handler(void *user, const xmlChar *notation, const xmlChar *pub_id parser->h_notation_decl(parser->user, notation, NULL, sys_id, pub_id); } -static void -build_comment(const xmlChar *data, size_t data_len, xmlChar **comment, size_t *comment_len) +static xmlChar * +build_comment(const xmlChar *data, size_t data_len, size_t *comment_len) { *comment_len = data_len + 7; - *comment = xmlMalloc(*comment_len + 1); - memcpy(*comment, "", 3); + xmlChar *comment = emalloc(*comment_len + 1); + memcpy(comment, "", 3); + + comment[*comment_len] = '\0'; - (*comment)[*comment_len] = '\0'; + return comment; } static void @@ -250,24 +255,24 @@ comment_handler(void *user, const xmlChar *comment) XML_Parser parser = (XML_Parser) user; if (parser->h_default) { - xmlChar *d_comment; size_t d_comment_len; - build_comment(comment, (size_t) xmlStrlen(comment), &d_comment, &d_comment_len); + xmlChar *d_comment = build_comment(comment, (size_t) xmlStrlen(comment), &d_comment_len); parser->h_default(parser->user, d_comment, d_comment_len); - xmlFree(d_comment); + efree(d_comment); } } -static void -build_entity(const xmlChar *name, size_t len, xmlChar **entity, size_t *entity_len) +static xmlChar * +build_entity(const xmlChar *name, size_t len, size_t *entity_len) { *entity_len = len + 2; - *entity = xmlMalloc(*entity_len + 1); - (*entity)[0] = '&'; - memcpy(*entity+1, name, len); - (*entity)[len+1] = ';'; - (*entity)[*entity_len] = '\0'; + xmlChar *entity = emalloc(*entity_len + 1); + entity[0] = '&'; + memcpy(entity + 1, name, len); + entity[len + 1] = ';'; + entity[*entity_len] = '\0'; + return entity; } static void @@ -302,12 +307,11 @@ get_entity(void *user, const xmlChar *name) if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) { /* Predefined entities will expand unless no cdata handler is present */ if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) { - xmlChar *entity; size_t len; - build_entity(name, (size_t) xmlStrlen(name), &entity, &len); + xmlChar *entity = build_entity(name, (size_t) xmlStrlen(name), &len); parser->h_default(parser->user, (const xmlChar *) entity, len); - xmlFree(entity); + efree(entity); } else { /* expat will not expand internal entities if default handler is present otherwise it will expand and pass them to cdata handler */ @@ -393,15 +397,19 @@ XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *m return NULL; } +#if LIBXML_VERSION >= 21300 + xmlCtxtSetOptions(parser->parser, XML_PARSE_OLDSAX | XML_PARSE_NOENT); +#else php_libxml_sanitize_parse_ctxt_options(parser->parser); xmlCtxtUseOptions(parser->parser, XML_PARSE_OLDSAX | XML_PARSE_NOENT); +#endif parser->parser->wellFormed = 0; if (sep != NULL) { /* Note: sax2 flag will be set due to the magic number in `initialized` in php_xml_compat_handlers */ ZEND_ASSERT(parser->parser->sax->initialized == XML_SAX2_MAGIC); parser->use_namespace = 1; - parser->_ns_separator = xmlStrdup(sep); + parser->_ns_separator = BAD_CAST estrdup((const char *) sep); } else { /* Reset flag as XML_SAX2_MAGIC is needed for xmlCreatePushParserCtxt so must be set in the handlers */ @@ -636,25 +644,12 @@ XML_GetCurrentByteIndex(XML_Parser parser) (parser->parser->input->cur - parser->parser->input->base); } -PHP_XML_API int -XML_GetCurrentByteCount(XML_Parser parser) -{ - /* TODO: this is identical to ByteIndex; it should probably - * be different */ - return (int) XML_GetCurrentByteIndex(parser); -} - -PHP_XML_API const XML_Char *XML_ExpatVersion(void) -{ - return (const XML_Char *) "1.0"; -} - PHP_XML_API void XML_ParserFree(XML_Parser parser) { if (parser->use_namespace) { if (parser->_ns_separator) { - xmlFree(parser->_ns_separator); + efree(parser->_ns_separator); } } if (parser->parser->myDoc) { diff --git a/ext/xml/expat_compat.h b/ext/xml/expat_compat.h index 94ca8aeb4c351..a7faffbac504f 100644 --- a/ext/xml/expat_compat.h +++ b/ext/xml/expat_compat.h @@ -147,8 +147,6 @@ PHP_XML_API const XML_Char *XML_ErrorString(int); PHP_XML_API int XML_GetCurrentLineNumber(XML_Parser); PHP_XML_API int XML_GetCurrentColumnNumber(XML_Parser); PHP_XML_API long XML_GetCurrentByteIndex(XML_Parser); -PHP_XML_API int XML_GetCurrentByteCount(XML_Parser); -PHP_XML_API const XML_Char *XML_ExpatVersion(void); PHP_XML_API void XML_ParserFree(XML_Parser); #elif defined(HAVE_LIBEXPAT) diff --git a/ext/xml/xml.c b/ext/xml/xml.c index bf9f747599730..7a9329bcc8041 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -64,11 +64,7 @@ typedef struct { XML_Parser parser; XML_Char *target_encoding; - /* Reference to the object itself, for convenience. - * It is not owned, do not release it. */ - zval index; - - zend_object *object; + zend_object *object; /* object with handlers */ zend_fcall_info_cache startElementHandler; zend_fcall_info_cache endElementHandler; zend_fcall_info_cache characterDataHandler; @@ -135,7 +131,7 @@ inline static char xml_decode_iso_8859_1(unsigned short); inline static unsigned short xml_encode_us_ascii(unsigned char); inline static char xml_decode_us_ascii(unsigned short); static void xml_xmlchar_zval(const XML_Char *, int, const XML_Char *, zval *); -static int xml_xmlcharlen(const XML_Char *); +static size_t xml_xmlcharlen(const XML_Char *); static void xml_add_to_info(xml_parser *parser, zend_string *name); inline static zend_string *xml_decode_tag(xml_parser *parser, const XML_Char *tag); @@ -282,9 +278,9 @@ static int xml_parse_helper(xml_parser *parser, const char *data, size_t data_le ZEND_DIAGNOSTIC_IGNORED_END #endif - parser->isparsing = 1; + parser->isparsing = true; int ret = XML_Parse(parser->parser, (const XML_Char *) data, data_len, is_final); - parser->isparsing = 0; + parser->isparsing = false; return ret; } @@ -540,15 +536,9 @@ static zend_string *xml_utf8_decode(const XML_Char *s, size_t len, const XML_Cha /* }}} */ /* {{{ xml_xmlcharlen() */ -static int xml_xmlcharlen(const XML_Char *s) +static size_t xml_xmlcharlen(const XML_Char *s) { - int len = 0; - - while (*s) { - len++; - s++; - } - return len; + return strlen((const char *) s); } /* }}} */ @@ -641,7 +631,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha if (ZEND_FCC_INITIALIZED(parser->startElementHandler)) { zval args[3]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); ZVAL_STR(&args[1], xml_stripped_tag(tag_name, parser->toffset)); array_init(&args[2]); @@ -652,7 +642,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding); ZVAL_STR(&tmp, val); - zend_symtable_update(Z_ARRVAL(args[2]), att, &tmp); + zend_hash_update(Z_ARRVAL(args[2]), att, &tmp); attributes += 2; @@ -660,7 +650,6 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha } zend_call_known_fcc(&parser->startElementHandler, /* retval */ NULL, /* param_count */ 3, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); zval_ptr_dtor(&args[2]); } @@ -682,7 +671,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha /* Because toffset may change, we should use the original tag name */ parser->ltags[parser->level - 1] = zend_string_copy(tag_name); - parser->lastwasopen = 1; + parser->lastwasopen = true; attributes = (const XML_Char **) attrs; @@ -693,7 +682,7 @@ void xml_startElementHandler(void *userData, const XML_Char *name, const XML_Cha val = xml_utf8_decode(attributes[1], strlen((char *)attributes[1]), parser->target_encoding); ZVAL_STR(&tmp, val); - zend_symtable_update(Z_ARRVAL(atr), att, &tmp); + zend_hash_update(Z_ARRVAL(atr), att, &tmp); atcnt++; attributes += 2; @@ -742,11 +731,10 @@ void xml_endElementHandler(void *userData, const XML_Char *name) if (ZEND_FCC_INITIALIZED(parser->endElementHandler)) { zval args[2]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); ZVAL_STR(&args[1], xml_stripped_tag(tag_name, parser->toffset)); zend_call_known_fcc(&parser->endElementHandler, /* retval */ NULL, /* param_count */ 2, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); } @@ -775,7 +763,7 @@ void xml_endElementHandler(void *userData, const XML_Char *name) } } - parser->lastwasopen = 0; + parser->lastwasopen = false; } zend_string_release_ex(tag_name, 0); @@ -803,11 +791,10 @@ void xml_characterDataHandler(void *userData, const XML_Char *s, int len) if (ZEND_FCC_INITIALIZED(parser->characterDataHandler)) { zval args[2]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(s, len, parser->target_encoding, &args[1]); zend_call_known_fcc(&parser->characterDataHandler, /* retval */ NULL, /* param_count */ 2, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); } @@ -815,7 +802,7 @@ void xml_characterDataHandler(void *userData, const XML_Char *s, int len) return; } - bool doprint = 0; + bool doprint = false; zend_string *decoded_value; decoded_value = xml_utf8_decode(s, len, parser->target_encoding); if (parser->skipwhite) { @@ -826,7 +813,7 @@ void xml_characterDataHandler(void *userData, const XML_Char *s, int len) case '\n': continue; default: - doprint = 1; + doprint = true; break; } if (doprint) { @@ -911,12 +898,11 @@ void xml_processingInstructionHandler(void *userData, const XML_Char *target, co zval args[3]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(target, 0, parser->target_encoding, &args[1]); xml_xmlchar_zval(data, 0, parser->target_encoding, &args[2]); zend_call_known_fcc(&parser->processingInstructionHandler, /* retval */ NULL, /* param_count */ 3, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); zval_ptr_dtor_str(&args[2]); } @@ -933,11 +919,10 @@ void xml_defaultHandler(void *userData, const XML_Char *s, int len) zval args[2]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(s, len, parser->target_encoding, &args[1]); zend_call_known_fcc(&parser->defaultHandler, /* retval */ NULL, /* param_count */ 2, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); } /* }}} */ @@ -955,7 +940,7 @@ void xml_unparsedEntityDeclHandler(void *userData, zval args[6]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(entityName, 0, parser->target_encoding, &args[1]); xml_xmlchar_zval(base, 0, parser->target_encoding, &args[2]); xml_xmlchar_zval(systemId, 0, parser->target_encoding, &args[3]); @@ -963,7 +948,6 @@ void xml_unparsedEntityDeclHandler(void *userData, xml_xmlchar_zval(notationName, 0, parser->target_encoding, &args[5]); zend_call_known_fcc(&parser->unparsedEntityDeclHandler, /* retval */ NULL, /* param_count */ 6, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); zval_ptr_dtor_str(&args[2]); zval_ptr_dtor_str(&args[3]); @@ -984,14 +968,13 @@ void xml_notationDeclHandler(void *userData, const XML_Char *notationName, zval args[5]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(notationName, 0, parser->target_encoding, &args[1]); xml_xmlchar_zval(base, 0, parser->target_encoding, &args[2]); xml_xmlchar_zval(systemId, 0, parser->target_encoding, &args[3]); xml_xmlchar_zval(publicId, 0, parser->target_encoding, &args[4]); zend_call_known_fcc(&parser->notationDeclHandler, /* retval */ NULL, /* param_count */ 5, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); zval_ptr_dtor_str(&args[2]); zval_ptr_dtor_str(&args[3]); @@ -1013,14 +996,13 @@ int xml_externalEntityRefHandler(XML_Parser userData, const XML_Char *openEntity zval args[5]; zval retval; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(openEntityNames, 0, parser->target_encoding, &args[1]); xml_xmlchar_zval(base, 0, parser->target_encoding, &args[2]); xml_xmlchar_zval(systemId, 0, parser->target_encoding, &args[3]); xml_xmlchar_zval(publicId, 0, parser->target_encoding, &args[4]); zend_call_known_fcc(&parser->externalEntityRefHandler, /* retval */ &retval, /* param_count */ 5, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); zval_ptr_dtor_str(&args[2]); zval_ptr_dtor_str(&args[3]); @@ -1048,12 +1030,11 @@ void xml_startNamespaceDeclHandler(void *userData,const XML_Char *prefix, const zval args[3]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(prefix, 0, parser->target_encoding, &args[1]); xml_xmlchar_zval(uri, 0, parser->target_encoding, &args[2]); zend_call_known_fcc(&parser->startNamespaceDeclHandler, /* retval */ NULL, /* param_count */ 3, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); zval_ptr_dtor_str(&args[2]); } @@ -1070,11 +1051,10 @@ void xml_endNamespaceDeclHandler(void *userData, const XML_Char *prefix) zval args[2]; - ZVAL_COPY(&args[0], &parser->index); + ZVAL_OBJ(&args[0], &parser->std); xml_xmlchar_zval(prefix, 0, parser->target_encoding, &args[1]); zend_call_known_fcc(&parser->endNamespaceDeclHandler, /* retval */ NULL, /* param_count */ 2, args, /* named_params */ NULL); - zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&args[1]); } /* }}} */ @@ -1128,12 +1108,11 @@ static void php_xml_parser_create_impl(INTERNAL_FUNCTION_PARAMETERS, int ns_supp &php_xml_mem_hdlrs, (XML_Char*)ns_param); parser->target_encoding = encoding; - parser->case_folding = 1; - parser->isparsing = 0; + parser->case_folding = true; + parser->isparsing = false; parser->parsehuge = false; /* It's the default for BC & DoS protection */ XML_SetUserData(parser->parser, parser); - ZVAL_COPY_VALUE(&parser->index, return_value); } /* }}} */ @@ -1410,7 +1389,7 @@ PHP_FUNCTION(xml_parse) zval *pind; char *data; size_t data_len; - bool isFinal = 0; + bool isFinal = false; if (zend_parse_parameters(ZEND_NUM_ARGS(), "Os|b", &pind, xml_parser_ce, &data, &data_len, &isFinal) == FAILURE) { RETURN_THROWS(); diff --git a/ext/xmlreader/php_xmlreader_arginfo.h b/ext/xmlreader/php_xmlreader_arginfo.h index dd5ca550f606d..ef54bfa4c235f 100644 --- a/ext/xmlreader/php_xmlreader_arginfo.h +++ b/ext/xmlreader/php_xmlreader_arginfo.h @@ -180,183 +180,183 @@ static zend_class_entry *register_class_XMLReader(void) zval const_NONE_value; ZVAL_LONG(&const_NONE_value, XML_READER_TYPE_NONE); - zend_string *const_NONE_name = zend_string_init_interned("NONE", sizeof("NONE") - 1, 1); + zend_string *const_NONE_name = zend_string_init_interned("NONE", sizeof("NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_NONE_name, &const_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NONE_name); + zend_string_release_ex(const_NONE_name, true); zval const_ELEMENT_value; ZVAL_LONG(&const_ELEMENT_value, XML_READER_TYPE_ELEMENT); - zend_string *const_ELEMENT_name = zend_string_init_interned("ELEMENT", sizeof("ELEMENT") - 1, 1); + zend_string *const_ELEMENT_name = zend_string_init_interned("ELEMENT", sizeof("ELEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ELEMENT_name, &const_ELEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ELEMENT_name); + zend_string_release_ex(const_ELEMENT_name, true); zval const_ATTRIBUTE_value; ZVAL_LONG(&const_ATTRIBUTE_value, XML_READER_TYPE_ATTRIBUTE); - zend_string *const_ATTRIBUTE_name = zend_string_init_interned("ATTRIBUTE", sizeof("ATTRIBUTE") - 1, 1); + zend_string *const_ATTRIBUTE_name = zend_string_init_interned("ATTRIBUTE", sizeof("ATTRIBUTE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ATTRIBUTE_name, &const_ATTRIBUTE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ATTRIBUTE_name); + zend_string_release_ex(const_ATTRIBUTE_name, true); zval const_TEXT_value; ZVAL_LONG(&const_TEXT_value, XML_READER_TYPE_TEXT); - zend_string *const_TEXT_name = zend_string_init_interned("TEXT", sizeof("TEXT") - 1, 1); + zend_string *const_TEXT_name = zend_string_init_interned("TEXT", sizeof("TEXT") - 1, true); zend_declare_typed_class_constant(class_entry, const_TEXT_name, &const_TEXT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_TEXT_name); + zend_string_release_ex(const_TEXT_name, true); zval const_CDATA_value; ZVAL_LONG(&const_CDATA_value, XML_READER_TYPE_CDATA); - zend_string *const_CDATA_name = zend_string_init_interned("CDATA", sizeof("CDATA") - 1, 1); + zend_string *const_CDATA_name = zend_string_init_interned("CDATA", sizeof("CDATA") - 1, true); zend_declare_typed_class_constant(class_entry, const_CDATA_name, &const_CDATA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CDATA_name); + zend_string_release_ex(const_CDATA_name, true); zval const_ENTITY_REF_value; ZVAL_LONG(&const_ENTITY_REF_value, XML_READER_TYPE_ENTITY_REFERENCE); - zend_string *const_ENTITY_REF_name = zend_string_init_interned("ENTITY_REF", sizeof("ENTITY_REF") - 1, 1); + zend_string *const_ENTITY_REF_name = zend_string_init_interned("ENTITY_REF", sizeof("ENTITY_REF") - 1, true); zend_declare_typed_class_constant(class_entry, const_ENTITY_REF_name, &const_ENTITY_REF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ENTITY_REF_name); + zend_string_release_ex(const_ENTITY_REF_name, true); zval const_ENTITY_value; ZVAL_LONG(&const_ENTITY_value, XML_READER_TYPE_ENTITY); - zend_string *const_ENTITY_name = zend_string_init_interned("ENTITY", sizeof("ENTITY") - 1, 1); + zend_string *const_ENTITY_name = zend_string_init_interned("ENTITY", sizeof("ENTITY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ENTITY_name, &const_ENTITY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ENTITY_name); + zend_string_release_ex(const_ENTITY_name, true); zval const_PI_value; ZVAL_LONG(&const_PI_value, XML_READER_TYPE_PROCESSING_INSTRUCTION); - zend_string *const_PI_name = zend_string_init_interned("PI", sizeof("PI") - 1, 1); + zend_string *const_PI_name = zend_string_init_interned("PI", sizeof("PI") - 1, true); zend_declare_typed_class_constant(class_entry, const_PI_name, &const_PI_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_PI_name); + zend_string_release_ex(const_PI_name, true); zval const_COMMENT_value; ZVAL_LONG(&const_COMMENT_value, XML_READER_TYPE_COMMENT); - zend_string *const_COMMENT_name = zend_string_init_interned("COMMENT", sizeof("COMMENT") - 1, 1); + zend_string *const_COMMENT_name = zend_string_init_interned("COMMENT", sizeof("COMMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_COMMENT_name, &const_COMMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_COMMENT_name); + zend_string_release_ex(const_COMMENT_name, true); zval const_DOC_value; ZVAL_LONG(&const_DOC_value, XML_READER_TYPE_DOCUMENT); - zend_string *const_DOC_name = zend_string_init_interned("DOC", sizeof("DOC") - 1, 1); + zend_string *const_DOC_name = zend_string_init_interned("DOC", sizeof("DOC") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOC_name, &const_DOC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOC_name); + zend_string_release_ex(const_DOC_name, true); zval const_DOC_TYPE_value; ZVAL_LONG(&const_DOC_TYPE_value, XML_READER_TYPE_DOCUMENT_TYPE); - zend_string *const_DOC_TYPE_name = zend_string_init_interned("DOC_TYPE", sizeof("DOC_TYPE") - 1, 1); + zend_string *const_DOC_TYPE_name = zend_string_init_interned("DOC_TYPE", sizeof("DOC_TYPE") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOC_TYPE_name, &const_DOC_TYPE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOC_TYPE_name); + zend_string_release_ex(const_DOC_TYPE_name, true); zval const_DOC_FRAGMENT_value; ZVAL_LONG(&const_DOC_FRAGMENT_value, XML_READER_TYPE_DOCUMENT_FRAGMENT); - zend_string *const_DOC_FRAGMENT_name = zend_string_init_interned("DOC_FRAGMENT", sizeof("DOC_FRAGMENT") - 1, 1); + zend_string *const_DOC_FRAGMENT_name = zend_string_init_interned("DOC_FRAGMENT", sizeof("DOC_FRAGMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_DOC_FRAGMENT_name, &const_DOC_FRAGMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DOC_FRAGMENT_name); + zend_string_release_ex(const_DOC_FRAGMENT_name, true); zval const_NOTATION_value; ZVAL_LONG(&const_NOTATION_value, XML_READER_TYPE_NOTATION); - zend_string *const_NOTATION_name = zend_string_init_interned("NOTATION", sizeof("NOTATION") - 1, 1); + zend_string *const_NOTATION_name = zend_string_init_interned("NOTATION", sizeof("NOTATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_NOTATION_name, &const_NOTATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_NOTATION_name); + zend_string_release_ex(const_NOTATION_name, true); zval const_WHITESPACE_value; ZVAL_LONG(&const_WHITESPACE_value, XML_READER_TYPE_WHITESPACE); - zend_string *const_WHITESPACE_name = zend_string_init_interned("WHITESPACE", sizeof("WHITESPACE") - 1, 1); + zend_string *const_WHITESPACE_name = zend_string_init_interned("WHITESPACE", sizeof("WHITESPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_WHITESPACE_name, &const_WHITESPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_WHITESPACE_name); + zend_string_release_ex(const_WHITESPACE_name, true); zval const_SIGNIFICANT_WHITESPACE_value; ZVAL_LONG(&const_SIGNIFICANT_WHITESPACE_value, XML_READER_TYPE_SIGNIFICANT_WHITESPACE); - zend_string *const_SIGNIFICANT_WHITESPACE_name = zend_string_init_interned("SIGNIFICANT_WHITESPACE", sizeof("SIGNIFICANT_WHITESPACE") - 1, 1); + zend_string *const_SIGNIFICANT_WHITESPACE_name = zend_string_init_interned("SIGNIFICANT_WHITESPACE", sizeof("SIGNIFICANT_WHITESPACE") - 1, true); zend_declare_typed_class_constant(class_entry, const_SIGNIFICANT_WHITESPACE_name, &const_SIGNIFICANT_WHITESPACE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SIGNIFICANT_WHITESPACE_name); + zend_string_release_ex(const_SIGNIFICANT_WHITESPACE_name, true); zval const_END_ELEMENT_value; ZVAL_LONG(&const_END_ELEMENT_value, XML_READER_TYPE_END_ELEMENT); - zend_string *const_END_ELEMENT_name = zend_string_init_interned("END_ELEMENT", sizeof("END_ELEMENT") - 1, 1); + zend_string *const_END_ELEMENT_name = zend_string_init_interned("END_ELEMENT", sizeof("END_ELEMENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_END_ELEMENT_name, &const_END_ELEMENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_END_ELEMENT_name); + zend_string_release_ex(const_END_ELEMENT_name, true); zval const_END_ENTITY_value; ZVAL_LONG(&const_END_ENTITY_value, XML_READER_TYPE_END_ENTITY); - zend_string *const_END_ENTITY_name = zend_string_init_interned("END_ENTITY", sizeof("END_ENTITY") - 1, 1); + zend_string *const_END_ENTITY_name = zend_string_init_interned("END_ENTITY", sizeof("END_ENTITY") - 1, true); zend_declare_typed_class_constant(class_entry, const_END_ENTITY_name, &const_END_ENTITY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_END_ENTITY_name); + zend_string_release_ex(const_END_ENTITY_name, true); zval const_XML_DECLARATION_value; ZVAL_LONG(&const_XML_DECLARATION_value, XML_READER_TYPE_XML_DECLARATION); - zend_string *const_XML_DECLARATION_name = zend_string_init_interned("XML_DECLARATION", sizeof("XML_DECLARATION") - 1, 1); + zend_string *const_XML_DECLARATION_name = zend_string_init_interned("XML_DECLARATION", sizeof("XML_DECLARATION") - 1, true); zend_declare_typed_class_constant(class_entry, const_XML_DECLARATION_name, &const_XML_DECLARATION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_XML_DECLARATION_name); + zend_string_release_ex(const_XML_DECLARATION_name, true); zval const_LOADDTD_value; ZVAL_LONG(&const_LOADDTD_value, XML_PARSER_LOADDTD); - zend_string *const_LOADDTD_name = zend_string_init_interned("LOADDTD", sizeof("LOADDTD") - 1, 1); + zend_string *const_LOADDTD_name = zend_string_init_interned("LOADDTD", sizeof("LOADDTD") - 1, true); zend_declare_typed_class_constant(class_entry, const_LOADDTD_name, &const_LOADDTD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LOADDTD_name); + zend_string_release_ex(const_LOADDTD_name, true); zval const_DEFAULTATTRS_value; ZVAL_LONG(&const_DEFAULTATTRS_value, XML_PARSER_DEFAULTATTRS); - zend_string *const_DEFAULTATTRS_name = zend_string_init_interned("DEFAULTATTRS", sizeof("DEFAULTATTRS") - 1, 1); + zend_string *const_DEFAULTATTRS_name = zend_string_init_interned("DEFAULTATTRS", sizeof("DEFAULTATTRS") - 1, true); zend_declare_typed_class_constant(class_entry, const_DEFAULTATTRS_name, &const_DEFAULTATTRS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_DEFAULTATTRS_name); + zend_string_release_ex(const_DEFAULTATTRS_name, true); zval const_VALIDATE_value; ZVAL_LONG(&const_VALIDATE_value, XML_PARSER_VALIDATE); - zend_string *const_VALIDATE_name = zend_string_init_interned("VALIDATE", sizeof("VALIDATE") - 1, 1); + zend_string *const_VALIDATE_name = zend_string_init_interned("VALIDATE", sizeof("VALIDATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_VALIDATE_name, &const_VALIDATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_VALIDATE_name); + zend_string_release_ex(const_VALIDATE_name, true); zval const_SUBST_ENTITIES_value; ZVAL_LONG(&const_SUBST_ENTITIES_value, XML_PARSER_SUBST_ENTITIES); - zend_string *const_SUBST_ENTITIES_name = zend_string_init_interned("SUBST_ENTITIES", sizeof("SUBST_ENTITIES") - 1, 1); + zend_string *const_SUBST_ENTITIES_name = zend_string_init_interned("SUBST_ENTITIES", sizeof("SUBST_ENTITIES") - 1, true); zend_declare_typed_class_constant(class_entry, const_SUBST_ENTITIES_name, &const_SUBST_ENTITIES_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_SUBST_ENTITIES_name); + zend_string_release_ex(const_SUBST_ENTITIES_name, true); zval property_attributeCount_default_value; ZVAL_UNDEF(&property_attributeCount_default_value); - zend_string *property_attributeCount_name = zend_string_init("attributeCount", sizeof("attributeCount") - 1, 1); + zend_string *property_attributeCount_name = zend_string_init("attributeCount", sizeof("attributeCount") - 1, true); zend_declare_typed_property(class_entry, property_attributeCount_name, &property_attributeCount_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_attributeCount_name); + zend_string_release_ex(property_attributeCount_name, true); zval property_baseURI_default_value; ZVAL_UNDEF(&property_baseURI_default_value); - zend_string *property_baseURI_name = zend_string_init("baseURI", sizeof("baseURI") - 1, 1); + zend_string *property_baseURI_name = zend_string_init("baseURI", sizeof("baseURI") - 1, true); zend_declare_typed_property(class_entry, property_baseURI_name, &property_baseURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_baseURI_name); + zend_string_release_ex(property_baseURI_name, true); zval property_depth_default_value; ZVAL_UNDEF(&property_depth_default_value); - zend_string *property_depth_name = zend_string_init("depth", sizeof("depth") - 1, 1); + zend_string *property_depth_name = zend_string_init("depth", sizeof("depth") - 1, true); zend_declare_typed_property(class_entry, property_depth_name, &property_depth_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_depth_name); + zend_string_release_ex(property_depth_name, true); zval property_hasAttributes_default_value; ZVAL_UNDEF(&property_hasAttributes_default_value); - zend_string *property_hasAttributes_name = zend_string_init("hasAttributes", sizeof("hasAttributes") - 1, 1); + zend_string *property_hasAttributes_name = zend_string_init("hasAttributes", sizeof("hasAttributes") - 1, true); zend_declare_typed_property(class_entry, property_hasAttributes_name, &property_hasAttributes_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_hasAttributes_name); + zend_string_release_ex(property_hasAttributes_name, true); zval property_hasValue_default_value; ZVAL_UNDEF(&property_hasValue_default_value); - zend_string *property_hasValue_name = zend_string_init("hasValue", sizeof("hasValue") - 1, 1); + zend_string *property_hasValue_name = zend_string_init("hasValue", sizeof("hasValue") - 1, true); zend_declare_typed_property(class_entry, property_hasValue_name, &property_hasValue_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_hasValue_name); + zend_string_release_ex(property_hasValue_name, true); zval property_isDefault_default_value; ZVAL_UNDEF(&property_isDefault_default_value); - zend_string *property_isDefault_name = zend_string_init("isDefault", sizeof("isDefault") - 1, 1); + zend_string *property_isDefault_name = zend_string_init("isDefault", sizeof("isDefault") - 1, true); zend_declare_typed_property(class_entry, property_isDefault_name, &property_isDefault_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_isDefault_name); + zend_string_release_ex(property_isDefault_name, true); zval property_isEmptyElement_default_value; ZVAL_UNDEF(&property_isEmptyElement_default_value); - zend_string *property_isEmptyElement_name = zend_string_init("isEmptyElement", sizeof("isEmptyElement") - 1, 1); + zend_string *property_isEmptyElement_name = zend_string_init("isEmptyElement", sizeof("isEmptyElement") - 1, true); zend_declare_typed_property(class_entry, property_isEmptyElement_name, &property_isEmptyElement_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_isEmptyElement_name); + zend_string_release_ex(property_isEmptyElement_name, true); zval property_localName_default_value; ZVAL_UNDEF(&property_localName_default_value); - zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, 1); + zend_string *property_localName_name = zend_string_init("localName", sizeof("localName") - 1, true); zend_declare_typed_property(class_entry, property_localName_name, &property_localName_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_localName_name); + zend_string_release_ex(property_localName_name, true); zval property_name_default_value; ZVAL_UNDEF(&property_name_default_value); @@ -364,21 +364,21 @@ static zend_class_entry *register_class_XMLReader(void) zval property_namespaceURI_default_value; ZVAL_UNDEF(&property_namespaceURI_default_value); - zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, 1); + zend_string *property_namespaceURI_name = zend_string_init("namespaceURI", sizeof("namespaceURI") - 1, true); zend_declare_typed_property(class_entry, property_namespaceURI_name, &property_namespaceURI_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_namespaceURI_name); + zend_string_release_ex(property_namespaceURI_name, true); zval property_nodeType_default_value; ZVAL_UNDEF(&property_nodeType_default_value); - zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, 1); + zend_string *property_nodeType_name = zend_string_init("nodeType", sizeof("nodeType") - 1, true); zend_declare_typed_property(class_entry, property_nodeType_name, &property_nodeType_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_nodeType_name); + zend_string_release_ex(property_nodeType_name, true); zval property_prefix_default_value; ZVAL_UNDEF(&property_prefix_default_value); - zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, 1); + zend_string *property_prefix_name = zend_string_init("prefix", sizeof("prefix") - 1, true); zend_declare_typed_property(class_entry, property_prefix_name, &property_prefix_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_prefix_name); + zend_string_release_ex(property_prefix_name, true); zval property_value_default_value; ZVAL_UNDEF(&property_value_default_value); @@ -386,9 +386,9 @@ static zend_class_entry *register_class_XMLReader(void) zval property_xmlLang_default_value; ZVAL_UNDEF(&property_xmlLang_default_value); - zend_string *property_xmlLang_name = zend_string_init("xmlLang", sizeof("xmlLang") - 1, 1); + zend_string *property_xmlLang_name = zend_string_init("xmlLang", sizeof("xmlLang") - 1, true); zend_declare_typed_property(class_entry, property_xmlLang_name, &property_xmlLang_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_VIRTUAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_xmlLang_name); + zend_string_release_ex(property_xmlLang_name, true); return class_entry; } diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c index f9dd7f48c86fb..6d711e89b89d4 100644 --- a/ext/xmlwriter/php_xmlwriter.c +++ b/ext/xmlwriter/php_xmlwriter.c @@ -765,7 +765,7 @@ PHP_FUNCTION(xmlwriter_write_dtd_entity) int retval; /* Optional parameters */ char *pubid = NULL, *sysid = NULL, *ndataid = NULL; - bool pe = 0; + bool pe = false; size_t pubid_len, sysid_len, ndataid_len; zval *self; @@ -1006,7 +1006,7 @@ PHP_METHOD(XMLWriter, toStream) /* {{{ php_xmlwriter_flush */ static void php_xmlwriter_flush(INTERNAL_FUNCTION_PARAMETERS, int force_string) { xmlTextWriterPtr ptr; - bool empty = 1; + bool empty = true; int output_bytes; zval *self; diff --git a/ext/xsl/php_xsl_arginfo.h b/ext/xsl/php_xsl_arginfo.h index d640d1114a566..b1f4fd7601c58 100644 --- a/ext/xsl/php_xsl_arginfo.h +++ b/ext/xsl/php_xsl_arginfo.h @@ -119,27 +119,27 @@ static zend_class_entry *register_class_XSLTProcessor(void) zval property_doXInclude_default_value; ZVAL_FALSE(&property_doXInclude_default_value); - zend_string *property_doXInclude_name = zend_string_init("doXInclude", sizeof("doXInclude") - 1, 1); + zend_string *property_doXInclude_name = zend_string_init("doXInclude", sizeof("doXInclude") - 1, true); zend_declare_typed_property(class_entry, property_doXInclude_name, &property_doXInclude_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_doXInclude_name); + zend_string_release_ex(property_doXInclude_name, true); zval property_cloneDocument_default_value; ZVAL_FALSE(&property_cloneDocument_default_value); - zend_string *property_cloneDocument_name = zend_string_init("cloneDocument", sizeof("cloneDocument") - 1, 1); + zend_string *property_cloneDocument_name = zend_string_init("cloneDocument", sizeof("cloneDocument") - 1, true); zend_declare_typed_property(class_entry, property_cloneDocument_name, &property_cloneDocument_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_cloneDocument_name); + zend_string_release_ex(property_cloneDocument_name, true); zval property_maxTemplateDepth_default_value; ZVAL_UNDEF(&property_maxTemplateDepth_default_value); - zend_string *property_maxTemplateDepth_name = zend_string_init("maxTemplateDepth", sizeof("maxTemplateDepth") - 1, 1); + zend_string *property_maxTemplateDepth_name = zend_string_init("maxTemplateDepth", sizeof("maxTemplateDepth") - 1, true); zend_declare_typed_property(class_entry, property_maxTemplateDepth_name, &property_maxTemplateDepth_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_maxTemplateDepth_name); + zend_string_release_ex(property_maxTemplateDepth_name, true); zval property_maxTemplateVars_default_value; ZVAL_UNDEF(&property_maxTemplateVars_default_value); - zend_string *property_maxTemplateVars_name = zend_string_init("maxTemplateVars", sizeof("maxTemplateVars") - 1, 1); + zend_string *property_maxTemplateVars_name = zend_string_init("maxTemplateVars", sizeof("maxTemplateVars") - 1, true); zend_declare_typed_property(class_entry, property_maxTemplateVars_name, &property_maxTemplateVars_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_maxTemplateVars_name); + zend_string_release_ex(property_maxTemplateVars_name, true); return class_entry; } diff --git a/ext/zend_test/object_handlers_arginfo.h b/ext/zend_test/object_handlers_arginfo.h index 370ad13894aa8..0b8cff520c153 100644 --- a/ext/zend_test/object_handlers_arginfo.h +++ b/ext/zend_test/object_handlers_arginfo.h @@ -49,9 +49,9 @@ static zend_class_entry *register_class_DoOperationNoCast(void) zval property_val_default_value; ZVAL_UNDEF(&property_val_default_value); - zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, 1); + zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, true); zend_declare_typed_property(class_entry, property_val_name, &property_val_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_val_name); + zend_string_release_ex(property_val_name, true); return class_entry; } @@ -65,9 +65,9 @@ static zend_class_entry *register_class_LongCastableNoOperations(void) zval property_val_default_value; ZVAL_UNDEF(&property_val_default_value); - zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, 1); + zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, true); zend_declare_typed_property(class_entry, property_val_name, &property_val_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_val_name); + zend_string_release_ex(property_val_name, true); return class_entry; } @@ -81,9 +81,9 @@ static zend_class_entry *register_class_FloatCastableNoOperations(void) zval property_val_default_value; ZVAL_UNDEF(&property_val_default_value); - zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, 1); + zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, true); zend_declare_typed_property(class_entry, property_val_name, &property_val_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_DOUBLE)); - zend_string_release(property_val_name); + zend_string_release_ex(property_val_name, true); return class_entry; } @@ -97,9 +97,9 @@ static zend_class_entry *register_class_NumericCastableNoOperations(void) zval property_val_default_value; ZVAL_UNDEF(&property_val_default_value); - zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, 1); + zend_string *property_val_name = zend_string_init("val", sizeof("val") - 1, true); zend_declare_typed_property(class_entry, property_val_name, &property_val_default_value, ZEND_ACC_PRIVATE, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_DOUBLE)); - zend_string_release(property_val_name); + zend_string_release_ex(property_val_name, true); return class_entry; } @@ -113,51 +113,51 @@ static zend_class_entry *register_class_DimensionHandlersNoArrayAccess(void) zval property_read_default_value; ZVAL_FALSE(&property_read_default_value); - zend_string *property_read_name = zend_string_init("read", sizeof("read") - 1, 1); + zend_string *property_read_name = zend_string_init("read", sizeof("read") - 1, true); zend_declare_typed_property(class_entry, property_read_name, &property_read_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_read_name); + zend_string_release_ex(property_read_name, true); zval property_write_default_value; ZVAL_FALSE(&property_write_default_value); - zend_string *property_write_name = zend_string_init("write", sizeof("write") - 1, 1); + zend_string *property_write_name = zend_string_init("write", sizeof("write") - 1, true); zend_declare_typed_property(class_entry, property_write_name, &property_write_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_write_name); + zend_string_release_ex(property_write_name, true); zval property_has_default_value; ZVAL_FALSE(&property_has_default_value); - zend_string *property_has_name = zend_string_init("has", sizeof("has") - 1, 1); + zend_string *property_has_name = zend_string_init("has", sizeof("has") - 1, true); zend_declare_typed_property(class_entry, property_has_name, &property_has_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_has_name); + zend_string_release_ex(property_has_name, true); zval property_unset_default_value; ZVAL_FALSE(&property_unset_default_value); - zend_string *property_unset_name = zend_string_init("unset", sizeof("unset") - 1, 1); + zend_string *property_unset_name = zend_string_init("unset", sizeof("unset") - 1, true); zend_declare_typed_property(class_entry, property_unset_name, &property_unset_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_unset_name); + zend_string_release_ex(property_unset_name, true); zval property_readType_default_value; ZVAL_UNDEF(&property_readType_default_value); - zend_string *property_readType_name = zend_string_init("readType", sizeof("readType") - 1, 1); + zend_string *property_readType_name = zend_string_init("readType", sizeof("readType") - 1, true); zend_declare_typed_property(class_entry, property_readType_name, &property_readType_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_readType_name); + zend_string_release_ex(property_readType_name, true); zval property_hasOffset_default_value; ZVAL_FALSE(&property_hasOffset_default_value); - zend_string *property_hasOffset_name = zend_string_init("hasOffset", sizeof("hasOffset") - 1, 1); + zend_string *property_hasOffset_name = zend_string_init("hasOffset", sizeof("hasOffset") - 1, true); zend_declare_typed_property(class_entry, property_hasOffset_name, &property_hasOffset_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_BOOL)); - zend_string_release(property_hasOffset_name); + zend_string_release_ex(property_hasOffset_name, true); zval property_checkEmpty_default_value; ZVAL_UNDEF(&property_checkEmpty_default_value); - zend_string *property_checkEmpty_name = zend_string_init("checkEmpty", sizeof("checkEmpty") - 1, 1); + zend_string *property_checkEmpty_name = zend_string_init("checkEmpty", sizeof("checkEmpty") - 1, true); zend_declare_typed_property(class_entry, property_checkEmpty_name, &property_checkEmpty_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_checkEmpty_name); + zend_string_release_ex(property_checkEmpty_name, true); zval property_offset_default_value; ZVAL_UNDEF(&property_offset_default_value); - zend_string *property_offset_name = zend_string_init("offset", sizeof("offset") - 1, 1); + zend_string *property_offset_name = zend_string_init("offset", sizeof("offset") - 1, true); zend_declare_typed_property(class_entry, property_offset_name, &property_offset_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); - zend_string_release(property_offset_name); + zend_string_release_ex(property_offset_name, true); return class_entry; } diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index bdbd2f52f0f2d..fd1a51c5776c3 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -37,10 +37,12 @@ #include "Zend/Optimizer/zend_optimizer.h" #include "Zend/zend_alloc.h" #include "test_arginfo.h" +#include "tmp_methods_arginfo.h" #include "zend_call_stack.h" #include "zend_exceptions.h" #include "zend_mm_custom_handlers.h" #include "ext/uri/php_uri.h" +#include "zend_observer.h" #if defined(HAVE_LIBXML) && !defined(PHP_WIN32) # include @@ -594,6 +596,13 @@ static ZEND_FUNCTION(zend_test_zend_ini_str) RETURN_STR(ZT_G(str_test)); } +static ZEND_FUNCTION(zend_test_zstr_init_literal) +{ + ZEND_PARSE_PARAMETERS_NONE(); + + RETURN_STR(ZSTR_INIT_LITERAL("foo\0bar", false)); +} + static ZEND_FUNCTION(zend_test_is_string_marked_as_valid_utf8) { zend_string *str; @@ -1023,16 +1032,38 @@ static ZEND_FUNCTION(zend_test_log_err_debug) php_log_err_with_severity(ZSTR_VAL(str), LOG_DEBUG); } +typedef struct _zend_test_object { + zend_internal_function *tmp_method; + zend_object std; +} zend_test_object; + static zend_object *zend_test_class_new(zend_class_entry *class_type) { - zend_object *obj = zend_objects_new(class_type); - object_properties_init(obj, class_type); - obj->handlers = &zend_test_class_handlers; - return obj; + zend_test_object *intern = zend_object_alloc(sizeof(zend_test_object), class_type); + zend_object_std_init(&intern->std, class_type); + object_properties_init(&intern->std, class_type); + return &intern->std; +} + +static void zend_test_class_free_obj(zend_object *object) +{ + zend_test_object *intern = (zend_test_object*)((char*)object - XtOffsetOf(zend_test_object, std)); + + if (intern->tmp_method) { + zend_internal_function *func = intern->tmp_method; + intern->tmp_method = NULL; + zend_string_release_ex(func->function_name, 0); + zend_free_internal_arg_info(func, false); + efree(func); + } + + zend_object_std_dtor(object); } static zend_function *zend_test_class_method_get(zend_object **object, zend_string *name, const zval *key) { + zend_test_object *intern = (zend_test_object*)((char*)(*object) - XtOffsetOf(zend_test_object, std)); + if (zend_string_equals_literal_ci(name, "test")) { zend_internal_function *fptr; @@ -1046,10 +1077,46 @@ static zend_function *zend_test_class_method_get(zend_object **object, zend_stri fptr->num_args = 0; fptr->scope = (*object)->ce; fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER; + fptr->fn_flags2 = 0; fptr->function_name = zend_string_copy(name); fptr->handler = ZEND_FN(zend_test_func); fptr->doc_comment = NULL; + return (zend_function*)fptr; + } else if (zend_string_equals_literal_ci(name, "testTmpMethodWithArgInfo")) { + if (intern->tmp_method) { + return (zend_function*)intern->tmp_method; + } + + const zend_function_entry *entry = &class_ZendTestTmpMethods_methods[0]; + zend_internal_function *fptr = emalloc(sizeof(zend_internal_function)); + memset(fptr, 0, sizeof(zend_internal_function)); + fptr->type = ZEND_INTERNAL_FUNCTION; + fptr->handler = entry->handler; + fptr->function_name = zend_string_init(entry->fname, strlen(entry->fname), false); + fptr->scope = intern->std.ce; + fptr->prototype = NULL; + fptr->T = ZEND_OBSERVER_ENABLED; + fptr->fn_flags = ZEND_ACC_PUBLIC | ZEND_ACC_NEVER_CACHE; + + zend_internal_function_info *info = (zend_internal_function_info*)entry->arg_info; + + uint32_t num_arg_info = 1 + entry->num_args; + zend_arg_info *arg_info = safe_emalloc(num_arg_info, sizeof(zend_arg_info), 0); + for (uint32_t i = 0; i < num_arg_info; i++) { + zend_convert_internal_arg_info(&arg_info[i], &entry->arg_info[i], i == 0, false); + } + + fptr->arg_info = arg_info + 1; + fptr->num_args = entry->num_args; + if (info->required_num_args == (uint32_t)-1) { + fptr->required_num_args = entry->num_args; + } else { + fptr->required_num_args = info->required_num_args; + } + + intern->tmp_method = fptr; + return (zend_function*)fptr; } return zend_std_get_method(object, name, key); @@ -1070,6 +1137,7 @@ static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, ze fptr->num_args = 0; fptr->scope = ce; fptr->fn_flags = ZEND_ACC_CALL_VIA_HANDLER|ZEND_ACC_STATIC; + fptr->fn_flags2 = 0; fptr->function_name = zend_string_copy(name); fptr->handler = ZEND_FN(zend_test_func); fptr->doc_comment = NULL; @@ -1136,6 +1204,18 @@ static ZEND_METHOD(_ZendTestClass, variadicTest) { object_init_ex(return_value, zend_get_called_scope(execute_data)); } +ZEND_METHOD(ZendTestTmpMethods, testTmpMethodWithArgInfo) +{ + zend_object *obj; + zend_string *str; + + ZEND_PARSE_PARAMETERS_START(0, 2); + Z_PARAM_OPTIONAL; + Z_PARAM_OBJ_OR_NULL(obj); + Z_PARAM_STR(str); + ZEND_PARSE_PARAMETERS_END(); +} + static ZEND_METHOD(_ZendTestChildClass, returnsThrowable) { ZEND_PARSE_PARAMETERS_NONE(); @@ -1441,11 +1521,14 @@ PHP_MINIT_FUNCTION(zend_test) register_ZendTestClass_dnf_property(zend_test_class); zend_test_class->create_object = zend_test_class_new; zend_test_class->get_static_method = zend_test_class_static_method_get; + zend_test_class->default_object_handlers = &zend_test_class_handlers; zend_test_child_class = register_class__ZendTestChildClass(zend_test_class); memcpy(&zend_test_class_handlers, &std_object_handlers, sizeof(zend_object_handlers)); zend_test_class_handlers.get_method = zend_test_class_method_get; + zend_test_class_handlers.free_obj = zend_test_class_free_obj; + zend_test_class_handlers.offset = XtOffsetOf(zend_test_object, std); zend_test_gen_stub_flag_compatibility_test = register_class_ZendTestGenStubFlagCompatibilityTest(); diff --git a/ext/zend_test/test.stub.php b/ext/zend_test/test.stub.php index bf9a1c6b5bc8d..d0c0c64b8b1d0 100644 --- a/ext/zend_test/test.stub.php +++ b/ext/zend_test/test.stub.php @@ -301,6 +301,7 @@ function zend_test_zend_ini_parse_quantity(string $str): int {} function zend_test_zend_ini_parse_uquantity(string $str): int {} function zend_test_zend_ini_str(): string {} + function zend_test_zstr_init_literal(): string {} #ifdef ZEND_CHECK_STACK_LIMIT function zend_test_zend_call_stack_get(): ?array {} diff --git a/ext/zend_test/test_arginfo.h b/ext/zend_test/test_arginfo.h index bd2240cedd637..683b3b38648b6 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: 6bccdc2444e6a68ba615fc281235a4551d0b8819 */ + * Stub hash: a8dae89983ccbcd5dd36d1cdee736d40af4fd33c */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_trigger_bailout, 0, 0, IS_NEVER, 0) ZEND_END_ARG_INFO() @@ -130,6 +130,8 @@ ZEND_END_ARG_INFO() #define arginfo_zend_test_zend_ini_str arginfo_zend_get_current_func_name +#define arginfo_zend_test_zstr_init_literal arginfo_zend_get_current_func_name + #if defined(ZEND_CHECK_STACK_LIMIT) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_zend_test_zend_call_stack_get, 0, 0, IS_ARRAY, 1) ZEND_END_ARG_INFO() @@ -316,6 +318,7 @@ static ZEND_FUNCTION(zend_call_method_if_exists); static ZEND_FUNCTION(zend_test_zend_ini_parse_quantity); static ZEND_FUNCTION(zend_test_zend_ini_parse_uquantity); static ZEND_FUNCTION(zend_test_zend_ini_str); +static ZEND_FUNCTION(zend_test_zstr_init_literal); #if defined(ZEND_CHECK_STACK_LIMIT) static ZEND_FUNCTION(zend_test_zend_call_stack_get); static ZEND_FUNCTION(zend_test_zend_call_stack_use_all); @@ -447,6 +450,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(zend_test_zend_ini_parse_quantity, arginfo_zend_test_zend_ini_parse_quantity) ZEND_FE(zend_test_zend_ini_parse_uquantity, arginfo_zend_test_zend_ini_parse_uquantity) ZEND_FE(zend_test_zend_ini_str, arginfo_zend_test_zend_ini_str) + ZEND_FE(zend_test_zstr_init_literal, arginfo_zend_test_zstr_init_literal) #if defined(ZEND_CHECK_STACK_LIMIT) ZEND_FE(zend_test_zend_call_stack_get, arginfo_zend_test_zend_call_stack_get) ZEND_FE(zend_test_zend_call_stack_use_all, arginfo_zend_test_zend_call_stack_use_all) @@ -624,44 +628,44 @@ static void register_test_symbols(int module_number) REGISTER_STRING_CONSTANT("ZendTestNS2\\ZendSubNS\\ZEND_CONSTANT_A", "namespaced", CONST_PERSISTENT); - zend_string *attribute_name_Deprecated_func_zend_test_deprecated_attr_0 = zend_string_init_interned("Deprecated", sizeof("Deprecated") - 1, 1); + zend_string *attribute_name_Deprecated_func_zend_test_deprecated_attr_0 = zend_string_init_interned("Deprecated", sizeof("Deprecated") - 1, true); zend_attribute *attribute_Deprecated_func_zend_test_deprecated_attr_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "zend_test_deprecated_attr", sizeof("zend_test_deprecated_attr") - 1), attribute_name_Deprecated_func_zend_test_deprecated_attr_0, 1); - zend_string_release(attribute_name_Deprecated_func_zend_test_deprecated_attr_0); + zend_string_release_ex(attribute_name_Deprecated_func_zend_test_deprecated_attr_0, true); zend_string *attribute_Deprecated_func_zend_test_deprecated_attr_0_arg0_str = zend_string_init("custom message", strlen("custom message"), 1); ZVAL_STR(&attribute_Deprecated_func_zend_test_deprecated_attr_0->args[0].value, attribute_Deprecated_func_zend_test_deprecated_attr_0_arg0_str); attribute_Deprecated_func_zend_test_deprecated_attr_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_zend_test_nodiscard_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_zend_test_nodiscard_0 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_zend_test_nodiscard_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "zend_test_nodiscard", sizeof("zend_test_nodiscard") - 1), attribute_name_NoDiscard_func_zend_test_nodiscard_0, 1); - zend_string_release(attribute_name_NoDiscard_func_zend_test_nodiscard_0); + zend_string_release_ex(attribute_name_NoDiscard_func_zend_test_nodiscard_0, true); ZVAL_STR_COPY(&attribute_NoDiscard_func_zend_test_nodiscard_0->args[0].value, attribute_Deprecated_func_zend_test_deprecated_attr_0_arg0_str); attribute_NoDiscard_func_zend_test_nodiscard_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_Deprecated_func_zend_test_deprecated_nodiscard_0 = zend_string_init_interned("Deprecated", sizeof("Deprecated") - 1, 1); + zend_string *attribute_name_Deprecated_func_zend_test_deprecated_nodiscard_0 = zend_string_init_interned("Deprecated", sizeof("Deprecated") - 1, true); zend_attribute *attribute_Deprecated_func_zend_test_deprecated_nodiscard_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "zend_test_deprecated_nodiscard", sizeof("zend_test_deprecated_nodiscard") - 1), attribute_name_Deprecated_func_zend_test_deprecated_nodiscard_0, 1); - zend_string_release(attribute_name_Deprecated_func_zend_test_deprecated_nodiscard_0); + zend_string_release_ex(attribute_name_Deprecated_func_zend_test_deprecated_nodiscard_0, true); ZVAL_STR_COPY(&attribute_Deprecated_func_zend_test_deprecated_nodiscard_0->args[0].value, attribute_Deprecated_func_zend_test_deprecated_attr_0_arg0_str); attribute_Deprecated_func_zend_test_deprecated_nodiscard_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_NoDiscard_func_zend_test_deprecated_nodiscard_1 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, 1); + zend_string *attribute_name_NoDiscard_func_zend_test_deprecated_nodiscard_1 = zend_string_init_interned("NoDiscard", sizeof("NoDiscard") - 1, true); zend_attribute *attribute_NoDiscard_func_zend_test_deprecated_nodiscard_1 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "zend_test_deprecated_nodiscard", sizeof("zend_test_deprecated_nodiscard") - 1), attribute_name_NoDiscard_func_zend_test_deprecated_nodiscard_1, 1); - zend_string_release(attribute_name_NoDiscard_func_zend_test_deprecated_nodiscard_1); + zend_string_release_ex(attribute_name_NoDiscard_func_zend_test_deprecated_nodiscard_1, true); zend_string *attribute_NoDiscard_func_zend_test_deprecated_nodiscard_1_arg0_str = zend_string_init("custom message 2", strlen("custom message 2"), 1); ZVAL_STR(&attribute_NoDiscard_func_zend_test_deprecated_nodiscard_1->args[0].value, attribute_NoDiscard_func_zend_test_deprecated_nodiscard_1_arg0_str); attribute_NoDiscard_func_zend_test_deprecated_nodiscard_1->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); - zend_string *attribute_name_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, 1); + zend_string *attribute_name_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, true); zend_attribute *attribute_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0 = zend_add_parameter_attribute(zend_hash_str_find_ptr(CG(function_table), "zend_test_parameter_with_attribute", sizeof("zend_test_parameter_with_attribute") - 1), 0, attribute_name_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0, 1); - zend_string_release(attribute_name_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0); + zend_string_release_ex(attribute_name_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0, true); zend_string *attribute_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0_arg0_str = zend_string_init("value1", strlen("value1"), 1); ZVAL_STR(&attribute_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0->args[0].value, attribute_ZendTestParameterAttribute_func_zend_test_parameter_with_attribute_arg0_0_arg0_str); - zend_string *attribute_name_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0 = zend_string_init_interned("ZendTestAttributeWithArguments", sizeof("ZendTestAttributeWithArguments") - 1, 1); + zend_string *attribute_name_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0 = zend_string_init_interned("ZendTestAttributeWithArguments", sizeof("ZendTestAttributeWithArguments") - 1, true); zend_attribute *attribute_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "zend_test_attribute_with_named_argument", sizeof("zend_test_attribute_with_named_argument") - 1), attribute_name_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0, 1); - zend_string_release(attribute_name_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0); + zend_string_release_ex(attribute_name_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0, true); zend_string *attribute_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0_arg0_str = zend_string_init("foo", strlen("foo"), 1); ZVAL_STR(&attribute_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0->args[0].value, attribute_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0_arg0_str); - attribute_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0->args[0].name = zend_string_init_interned("arg", sizeof("arg") - 1, 1); + attribute_ZendTestAttributeWithArguments_func_zend_test_attribute_with_named_argument_0->args[0].name = zend_string_init_interned("arg", sizeof("arg") - 1, true); #if (PHP_VERSION_ID >= 80500) zend_constant *const_ZEND_TEST_ATTRIBUTED_CONSTANT = zend_hash_str_find_ptr(EG(zend_constants), "ZEND_TEST_ATTRIBUTED_CONSTANT", sizeof("ZEND_TEST_ATTRIBUTED_CONSTANT") - 1); @@ -685,10 +689,10 @@ static zend_class_entry *register_class__ZendTestInterface(void) zval const_DUMMY_value; ZVAL_LONG(&const_DUMMY_value, 0); - zend_string *const_DUMMY_name = zend_string_init_interned("DUMMY", sizeof("DUMMY") - 1, 1); + zend_string *const_DUMMY_name = zend_string_init_interned("DUMMY", sizeof("DUMMY") - 1, true); zend_string *const_DUMMY_comment = zend_string_init_interned("/**\n * \"Lorem ipsum\"\n * @see https://www.php.net\n * @since 8.2\n */", 98, 1); zend_declare_class_constant_ex(class_entry, const_DUMMY_name, &const_DUMMY_value, ZEND_ACC_PUBLIC, const_DUMMY_comment); - zend_string_release(const_DUMMY_name); + zend_string_release_ex(const_DUMMY_name, true); return class_entry; } @@ -708,82 +712,82 @@ static zend_class_entry *register_class__ZendTestClass(zend_class_entry *class_e zval const_TYPED_CLASS_CONST1_value; ZVAL_EMPTY_ARRAY(&const_TYPED_CLASS_CONST1_value); - zend_string *const_TYPED_CLASS_CONST1_name = zend_string_init_interned("TYPED_CLASS_CONST1", sizeof("TYPED_CLASS_CONST1") - 1, 1); + zend_string *const_TYPED_CLASS_CONST1_name = zend_string_init_interned("TYPED_CLASS_CONST1", sizeof("TYPED_CLASS_CONST1") - 1, true); #if (PHP_VERSION_ID >= 80300) zend_declare_typed_class_constant(class_entry, const_TYPED_CLASS_CONST1_name, &const_TYPED_CLASS_CONST1_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); #else zend_declare_class_constant_ex(class_entry, const_TYPED_CLASS_CONST1_name, &const_TYPED_CLASS_CONST1_value, ZEND_ACC_PUBLIC, NULL); #endif - zend_string_release(const_TYPED_CLASS_CONST1_name); + zend_string_release_ex(const_TYPED_CLASS_CONST1_name, true); zval const_TYPED_CLASS_CONST2_value; ZVAL_LONG(&const_TYPED_CLASS_CONST2_value, 42); - zend_string *const_TYPED_CLASS_CONST2_name = zend_string_init_interned("TYPED_CLASS_CONST2", sizeof("TYPED_CLASS_CONST2") - 1, 1); + zend_string *const_TYPED_CLASS_CONST2_name = zend_string_init_interned("TYPED_CLASS_CONST2", sizeof("TYPED_CLASS_CONST2") - 1, true); #if (PHP_VERSION_ID >= 80300) zend_declare_typed_class_constant(class_entry, const_TYPED_CLASS_CONST2_name, &const_TYPED_CLASS_CONST2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_ARRAY)); #else zend_declare_class_constant_ex(class_entry, const_TYPED_CLASS_CONST2_name, &const_TYPED_CLASS_CONST2_value, ZEND_ACC_PUBLIC, NULL); #endif - zend_string_release(const_TYPED_CLASS_CONST2_name); + zend_string_release_ex(const_TYPED_CLASS_CONST2_name, true); zval const_TYPED_CLASS_CONST3_value; ZVAL_LONG(&const_TYPED_CLASS_CONST3_value, 1); - zend_string *const_TYPED_CLASS_CONST3_name = zend_string_init_interned("TYPED_CLASS_CONST3", sizeof("TYPED_CLASS_CONST3") - 1, 1); + zend_string *const_TYPED_CLASS_CONST3_name = zend_string_init_interned("TYPED_CLASS_CONST3", sizeof("TYPED_CLASS_CONST3") - 1, true); #if (PHP_VERSION_ID >= 80300) zend_declare_typed_class_constant(class_entry, const_TYPED_CLASS_CONST3_name, &const_TYPED_CLASS_CONST3_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG|MAY_BE_STRING)); #else zend_declare_class_constant_ex(class_entry, const_TYPED_CLASS_CONST3_name, &const_TYPED_CLASS_CONST3_value, ZEND_ACC_PUBLIC, NULL); #endif - zend_string_release(const_TYPED_CLASS_CONST3_name); + zend_string_release_ex(const_TYPED_CLASS_CONST3_name, true); 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); + zend_string *const_ZEND_TEST_DEPRECATED_name = zend_string_init_interned("ZEND_TEST_DEPRECATED", sizeof("ZEND_TEST_DEPRECATED") - 1, true); #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); + zend_string_release_ex(const_ZEND_TEST_DEPRECATED_name, true); zval const_ZEND_TEST_DEPRECATED_ATTR_value; ZVAL_LONG(&const_ZEND_TEST_DEPRECATED_ATTR_value, 42); - zend_string *const_ZEND_TEST_DEPRECATED_ATTR_name = zend_string_init_interned("ZEND_TEST_DEPRECATED_ATTR", sizeof("ZEND_TEST_DEPRECATED_ATTR") - 1, 1); + zend_string *const_ZEND_TEST_DEPRECATED_ATTR_name = zend_string_init_interned("ZEND_TEST_DEPRECATED_ATTR", sizeof("ZEND_TEST_DEPRECATED_ATTR") - 1, true); #if (PHP_VERSION_ID >= 80300) zend_class_constant *const_ZEND_TEST_DEPRECATED_ATTR = zend_declare_typed_class_constant(class_entry, const_ZEND_TEST_DEPRECATED_ATTR_name, &const_ZEND_TEST_DEPRECATED_ATTR_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); #else zend_class_constant *const_ZEND_TEST_DEPRECATED_ATTR = zend_declare_class_constant_ex(class_entry, const_ZEND_TEST_DEPRECATED_ATTR_name, &const_ZEND_TEST_DEPRECATED_ATTR_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL); #endif - zend_string_release(const_ZEND_TEST_DEPRECATED_ATTR_name); + zend_string_release_ex(const_ZEND_TEST_DEPRECATED_ATTR_name, true); zval property__StaticProp_default_value; ZVAL_NULL(&property__StaticProp_default_value); - zend_string *property__StaticProp_name = zend_string_init("_StaticProp", sizeof("_StaticProp") - 1, 1); + zend_string *property__StaticProp_name = zend_string_init("_StaticProp", sizeof("_StaticProp") - 1, true); zend_declare_typed_property(class_entry, property__StaticProp_name, &property__StaticProp_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0)); - zend_string_release(property__StaticProp_name); + zend_string_release_ex(property__StaticProp_name, true); zval property_staticIntProp_default_value; ZVAL_LONG(&property_staticIntProp_default_value, 123); - zend_string *property_staticIntProp_name = zend_string_init("staticIntProp", sizeof("staticIntProp") - 1, 1); + zend_string *property_staticIntProp_name = zend_string_init("staticIntProp", sizeof("staticIntProp") - 1, true); zend_declare_typed_property(class_entry, property_staticIntProp_name, &property_staticIntProp_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_staticIntProp_name); + zend_string_release_ex(property_staticIntProp_name, true); zval property_intProp_default_value; ZVAL_LONG(&property_intProp_default_value, 123); - zend_string *property_intProp_name = zend_string_init("intProp", sizeof("intProp") - 1, 1); + zend_string *property_intProp_name = zend_string_init("intProp", sizeof("intProp") - 1, true); zend_declare_typed_property(class_entry, property_intProp_name, &property_intProp_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_intProp_name); + zend_string_release_ex(property_intProp_name, true); zval property_classProp_default_value; ZVAL_NULL(&property_classProp_default_value); - zend_string *property_classProp_name = zend_string_init("classProp", sizeof("classProp") - 1, 1); + zend_string *property_classProp_name = zend_string_init("classProp", sizeof("classProp") - 1, true); zend_string *property_classProp_class_stdClass = zend_string_init("stdClass", sizeof("stdClass")-1, 1); zend_declare_typed_property(class_entry, property_classProp_name, &property_classProp_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_classProp_class_stdClass, 0, MAY_BE_NULL)); - zend_string_release(property_classProp_name); + zend_string_release_ex(property_classProp_name, true); zval property_classUnionProp_default_value; ZVAL_NULL(&property_classUnionProp_default_value); - zend_string *property_classUnionProp_name = zend_string_init("classUnionProp", sizeof("classUnionProp") - 1, 1); + zend_string *property_classUnionProp_name = zend_string_init("classUnionProp", sizeof("classUnionProp") - 1, true); zend_string *property_classUnionProp_class_stdClass = zend_string_init("stdClass", sizeof("stdClass") - 1, 1); zend_string *property_classUnionProp_class_Iterator = zend_string_init("Iterator", sizeof("Iterator") - 1, 1); zend_type_list *property_classUnionProp_type_list = malloc(ZEND_TYPE_LIST_SIZE(2)); @@ -792,11 +796,11 @@ static zend_class_entry *register_class__ZendTestClass(zend_class_entry *class_e property_classUnionProp_type_list->types[1] = (zend_type) ZEND_TYPE_INIT_CLASS(property_classUnionProp_class_Iterator, 0, 0); zend_type property_classUnionProp_type = ZEND_TYPE_INIT_UNION(property_classUnionProp_type_list, MAY_BE_NULL); zend_declare_typed_property(class_entry, property_classUnionProp_name, &property_classUnionProp_default_value, ZEND_ACC_PUBLIC, NULL, property_classUnionProp_type); - zend_string_release(property_classUnionProp_name); + zend_string_release_ex(property_classUnionProp_name, true); zval property_classIntersectionProp_default_value; ZVAL_UNDEF(&property_classIntersectionProp_default_value); - zend_string *property_classIntersectionProp_name = zend_string_init("classIntersectionProp", sizeof("classIntersectionProp") - 1, 1); + zend_string *property_classIntersectionProp_name = zend_string_init("classIntersectionProp", sizeof("classIntersectionProp") - 1, true); zend_string *property_classIntersectionProp_class_Traversable = zend_string_init("Traversable", sizeof("Traversable") - 1, 1); zend_string *property_classIntersectionProp_class_Countable = zend_string_init("Countable", sizeof("Countable") - 1, 1); zend_type_list *property_classIntersectionProp_type_list = malloc(ZEND_TYPE_LIST_SIZE(2)); @@ -805,32 +809,32 @@ static zend_class_entry *register_class__ZendTestClass(zend_class_entry *class_e property_classIntersectionProp_type_list->types[1] = (zend_type) ZEND_TYPE_INIT_CLASS(property_classIntersectionProp_class_Countable, 0, 0); zend_type property_classIntersectionProp_type = ZEND_TYPE_INIT_INTERSECTION(property_classIntersectionProp_type_list, 0); zend_declare_typed_property(class_entry, property_classIntersectionProp_name, &property_classIntersectionProp_default_value, ZEND_ACC_PUBLIC, NULL, property_classIntersectionProp_type); - zend_string_release(property_classIntersectionProp_name); + zend_string_release_ex(property_classIntersectionProp_name, true); zval property_readonlyProp_default_value; ZVAL_UNDEF(&property_readonlyProp_default_value); - zend_string *property_readonlyProp_name = zend_string_init("readonlyProp", sizeof("readonlyProp") - 1, 1); + zend_string *property_readonlyProp_name = zend_string_init("readonlyProp", sizeof("readonlyProp") - 1, true); #if (PHP_VERSION_ID >= 80100) zend_declare_typed_property(class_entry, property_readonlyProp_name, &property_readonlyProp_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); #elif (PHP_VERSION_ID >= 80000) zend_declare_typed_property(class_entry, property_readonlyProp_name, &property_readonlyProp_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); #endif - zend_string_release(property_readonlyProp_name); + zend_string_release_ex(property_readonlyProp_name, true); zval property_finalProp_default_value; ZVAL_UNDEF(&property_finalProp_default_value); - zend_string *property_finalProp_name = zend_string_init("finalProp", sizeof("finalProp") - 1, 1); + zend_string *property_finalProp_name = zend_string_init("finalProp", sizeof("finalProp") - 1, true); #if (PHP_VERSION_ID >= 80400) zend_declare_typed_property(class_entry, property_finalProp_name, &property_finalProp_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); #elif (PHP_VERSION_ID >= 80000) zend_declare_typed_property(class_entry, property_finalProp_name, &property_finalProp_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); #endif - zend_string_release(property_finalProp_name); + zend_string_release_ex(property_finalProp_name, true); - zend_string *attribute_name_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0 = zend_string_init_interned("Deprecated", sizeof("Deprecated") - 1, 1); + zend_string *attribute_name_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0 = zend_string_init_interned("Deprecated", sizeof("Deprecated") - 1, true); zend_attribute *attribute_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0 = zend_add_class_constant_attribute(class_entry, const_ZEND_TEST_DEPRECATED_ATTR, attribute_name_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0, 1); - zend_string_release(attribute_name_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0); + zend_string_release_ex(attribute_name_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0, true); zend_string *attribute_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0_arg0_str = zend_string_init("custom message", strlen("custom message"), 1); ZVAL_STR(&attribute_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0->args[0].value, attribute_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0_arg0_str); attribute_Deprecated_const_ZEND_TEST_DEPRECATED_ATTR_0->args[0].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); @@ -912,40 +916,40 @@ static zend_class_entry *register_class_ZendAttributeTest(void) zval const_TEST_CONST_value; ZVAL_LONG(&const_TEST_CONST_value, 1); - zend_string *const_TEST_CONST_name = zend_string_init_interned("TEST_CONST", sizeof("TEST_CONST") - 1, 1); + zend_string *const_TEST_CONST_name = zend_string_init_interned("TEST_CONST", sizeof("TEST_CONST") - 1, true); zend_class_constant *const_TEST_CONST = zend_declare_class_constant_ex(class_entry, const_TEST_CONST_name, &const_TEST_CONST_value, ZEND_ACC_PUBLIC, NULL); - zend_string_release(const_TEST_CONST_name); + zend_string_release_ex(const_TEST_CONST_name, true); zval property_testProp_default_value; ZVAL_NULL(&property_testProp_default_value); - zend_string *property_testProp_name = zend_string_init("testProp", sizeof("testProp") - 1, 1); + zend_string *property_testProp_name = zend_string_init("testProp", sizeof("testProp") - 1, true); zend_property_info *property_testProp = zend_declare_typed_property(class_entry, property_testProp_name, &property_testProp_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0)); - zend_string_release(property_testProp_name); + zend_string_release_ex(property_testProp_name, true); - zend_string *attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_0 = zend_string_init_interned("ZendTestRepeatableAttribute", sizeof("ZendTestRepeatableAttribute") - 1, 1); + zend_string *attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_0 = zend_string_init_interned("ZendTestRepeatableAttribute", sizeof("ZendTestRepeatableAttribute") - 1, true); zend_add_class_constant_attribute(class_entry, const_TEST_CONST, attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_0, 0); - zend_string_release(attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_0); + zend_string_release_ex(attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_0, true); - zend_string *attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_1 = zend_string_init_interned("ZendTestRepeatableAttribute", sizeof("ZendTestRepeatableAttribute") - 1, 1); + zend_string *attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_1 = zend_string_init_interned("ZendTestRepeatableAttribute", sizeof("ZendTestRepeatableAttribute") - 1, true); zend_add_class_constant_attribute(class_entry, const_TEST_CONST, attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_1, 0); - zend_string_release(attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_1); + zend_string_release_ex(attribute_name_ZendTestRepeatableAttribute_const_TEST_CONST_1, true); - zend_string *attribute_name_ZendTestRepeatableAttribute_property_testProp_0 = zend_string_init_interned("ZendTestRepeatableAttribute", sizeof("ZendTestRepeatableAttribute") - 1, 1); + zend_string *attribute_name_ZendTestRepeatableAttribute_property_testProp_0 = zend_string_init_interned("ZendTestRepeatableAttribute", sizeof("ZendTestRepeatableAttribute") - 1, true); zend_add_property_attribute(class_entry, property_testProp, attribute_name_ZendTestRepeatableAttribute_property_testProp_0, 0); - zend_string_release(attribute_name_ZendTestRepeatableAttribute_property_testProp_0); + zend_string_release_ex(attribute_name_ZendTestRepeatableAttribute_property_testProp_0, true); - zend_string *attribute_name_ZendTestPropertyAttribute_property_testProp_1 = zend_string_init_interned("ZendTestPropertyAttribute", sizeof("ZendTestPropertyAttribute") - 1, 1); + zend_string *attribute_name_ZendTestPropertyAttribute_property_testProp_1 = zend_string_init_interned("ZendTestPropertyAttribute", sizeof("ZendTestPropertyAttribute") - 1, true); zend_attribute *attribute_ZendTestPropertyAttribute_property_testProp_1 = zend_add_property_attribute(class_entry, property_testProp, attribute_name_ZendTestPropertyAttribute_property_testProp_1, 1); - zend_string_release(attribute_name_ZendTestPropertyAttribute_property_testProp_1); + zend_string_release_ex(attribute_name_ZendTestPropertyAttribute_property_testProp_1, true); zend_string *attribute_ZendTestPropertyAttribute_property_testProp_1_arg0_str = zend_string_init("testProp", strlen("testProp"), 1); ZVAL_STR(&attribute_ZendTestPropertyAttribute_property_testProp_1->args[0].value, attribute_ZendTestPropertyAttribute_property_testProp_1_arg0_str); - zend_string *attribute_name_ZendTestAttribute_func_testmethod_0 = zend_string_init_interned("ZendTestAttribute", sizeof("ZendTestAttribute") - 1, 1); + zend_string *attribute_name_ZendTestAttribute_func_testmethod_0 = zend_string_init_interned("ZendTestAttribute", sizeof("ZendTestAttribute") - 1, true); zend_add_function_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "testmethod", sizeof("testmethod") - 1), attribute_name_ZendTestAttribute_func_testmethod_0, 0); - zend_string_release(attribute_name_ZendTestAttribute_func_testmethod_0); + zend_string_release_ex(attribute_name_ZendTestAttribute_func_testmethod_0, true); return class_entry; } @@ -964,13 +968,13 @@ static zend_class_entry *register_class__ZendTestTrait(void) zval property_testProp_default_value; ZVAL_NULL(&property_testProp_default_value); - zend_string *property_testProp_name = zend_string_init("testProp", sizeof("testProp") - 1, 1); + zend_string *property_testProp_name = zend_string_init("testProp", sizeof("testProp") - 1, true); zend_declare_typed_property(class_entry, property_testProp_name, &property_testProp_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_NONE(0)); - zend_string_release(property_testProp_name); + zend_string_release_ex(property_testProp_name, true); zval property_classUnionProp_default_value; ZVAL_UNDEF(&property_classUnionProp_default_value); - zend_string *property_classUnionProp_name = zend_string_init("classUnionProp", sizeof("classUnionProp") - 1, 1); + zend_string *property_classUnionProp_name = zend_string_init("classUnionProp", sizeof("classUnionProp") - 1, true); zend_string *property_classUnionProp_class_Traversable = zend_string_init("Traversable", sizeof("Traversable") - 1, 1); zend_string *property_classUnionProp_class_Countable = zend_string_init("Countable", sizeof("Countable") - 1, 1); zend_type_list *property_classUnionProp_type_list = malloc(ZEND_TYPE_LIST_SIZE(2)); @@ -979,7 +983,7 @@ static zend_class_entry *register_class__ZendTestTrait(void) property_classUnionProp_type_list->types[1] = (zend_type) ZEND_TYPE_INIT_CLASS(property_classUnionProp_class_Countable, 0, 0); zend_type property_classUnionProp_type = ZEND_TYPE_INIT_UNION(property_classUnionProp_type_list, 0); zend_declare_typed_property(class_entry, property_classUnionProp_name, &property_classUnionProp_default_value, ZEND_ACC_PUBLIC, NULL, property_classUnionProp_type); - zend_string_release(property_classUnionProp_name); + zend_string_release_ex(property_classUnionProp_name, true); return class_entry; } @@ -996,9 +1000,9 @@ static zend_class_entry *register_class_ZendTestAttribute(void) class_entry->ce_flags |= ZEND_ACC_FINAL; #endif - zend_string *attribute_name_Attribute_class_ZendTestAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_ZendTestAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_ZendTestAttribute_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_ZendTestAttribute_0, 1); - zend_string_release(attribute_name_Attribute_class_ZendTestAttribute_0); + zend_string_release_ex(attribute_name_Attribute_class_ZendTestAttribute_0, true); ZVAL_LONG(&attribute_Attribute_class_ZendTestAttribute_0->args[0].value, ZEND_ATTRIBUTE_TARGET_ALL); return class_entry; @@ -1018,17 +1022,17 @@ static zend_class_entry *register_class_ZendTestAttributeWithArguments(void) zval property_arg_default_value; ZVAL_UNDEF(&property_arg_default_value); - zend_string *property_arg_name = zend_string_init("arg", sizeof("arg") - 1, 1); + zend_string *property_arg_name = zend_string_init("arg", sizeof("arg") - 1, true); #if (PHP_VERSION_ID >= 80100) zend_declare_typed_property(class_entry, property_arg_name, &property_arg_default_value, ZEND_ACC_PUBLIC|ZEND_ACC_READONLY, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); #elif (PHP_VERSION_ID >= 80000) zend_declare_typed_property(class_entry, property_arg_name, &property_arg_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ANY)); #endif - zend_string_release(property_arg_name); + zend_string_release_ex(property_arg_name, true); - zend_string *attribute_name_Attribute_class_ZendTestAttributeWithArguments_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_ZendTestAttributeWithArguments_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_ZendTestAttributeWithArguments_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_ZendTestAttributeWithArguments_0, 1); - zend_string_release(attribute_name_Attribute_class_ZendTestAttributeWithArguments_0); + zend_string_release_ex(attribute_name_Attribute_class_ZendTestAttributeWithArguments_0, true); ZVAL_LONG(&attribute_Attribute_class_ZendTestAttributeWithArguments_0->args[0].value, ZEND_ATTRIBUTE_TARGET_ALL); return class_entry; @@ -1046,9 +1050,9 @@ static zend_class_entry *register_class_ZendTestRepeatableAttribute(void) class_entry->ce_flags |= ZEND_ACC_FINAL; #endif - zend_string *attribute_name_Attribute_class_ZendTestRepeatableAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_ZendTestRepeatableAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_ZendTestRepeatableAttribute_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_ZendTestRepeatableAttribute_0, 1); - zend_string_release(attribute_name_Attribute_class_ZendTestRepeatableAttribute_0); + zend_string_release_ex(attribute_name_Attribute_class_ZendTestRepeatableAttribute_0, true); ZVAL_LONG(&attribute_Attribute_class_ZendTestRepeatableAttribute_0->args[0].value, ZEND_ATTRIBUTE_TARGET_ALL | ZEND_ATTRIBUTE_IS_REPEATABLE); return class_entry; @@ -1068,13 +1072,13 @@ static zend_class_entry *register_class_ZendTestParameterAttribute(void) zval property_parameter_default_value; ZVAL_UNDEF(&property_parameter_default_value); - zend_string *property_parameter_name = zend_string_init("parameter", sizeof("parameter") - 1, 1); + zend_string *property_parameter_name = zend_string_init("parameter", sizeof("parameter") - 1, true); zend_declare_typed_property(class_entry, property_parameter_name, &property_parameter_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_parameter_name); + zend_string_release_ex(property_parameter_name, true); - zend_string *attribute_name_Attribute_class_ZendTestParameterAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_ZendTestParameterAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_ZendTestParameterAttribute_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_ZendTestParameterAttribute_0, 1); - zend_string_release(attribute_name_Attribute_class_ZendTestParameterAttribute_0); + zend_string_release_ex(attribute_name_Attribute_class_ZendTestParameterAttribute_0, true); ZVAL_LONG(&attribute_Attribute_class_ZendTestParameterAttribute_0->args[0].value, ZEND_ATTRIBUTE_TARGET_PARAMETER); return class_entry; @@ -1097,14 +1101,14 @@ static zend_class_entry *register_class_ZendTestPropertyAttribute(void) zval property_parameter_default_value; ZVAL_UNDEF(&property_parameter_default_value); - zend_string *property_parameter_name = zend_string_init("parameter", sizeof("parameter") - 1, 1); + zend_string *property_parameter_name = zend_string_init("parameter", sizeof("parameter") - 1, true); zend_string *property_parameter_comment = zend_string_init_interned("/**\n * \"Lorem ipsum\"\n * @see https://www.php.net\n * @since 8.4\n */", 98, 1); zend_declare_typed_property(class_entry, property_parameter_name, &property_parameter_default_value, ZEND_ACC_PUBLIC, property_parameter_comment, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_parameter_name); + zend_string_release_ex(property_parameter_name, true); - zend_string *attribute_name_Attribute_class_ZendTestPropertyAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, 1); + zend_string *attribute_name_Attribute_class_ZendTestPropertyAttribute_0 = zend_string_init_interned("Attribute", sizeof("Attribute") - 1, true); zend_attribute *attribute_Attribute_class_ZendTestPropertyAttribute_0 = zend_add_class_attribute(class_entry, attribute_name_Attribute_class_ZendTestPropertyAttribute_0, 1); - zend_string_release(attribute_name_Attribute_class_ZendTestPropertyAttribute_0); + zend_string_release_ex(attribute_name_Attribute_class_ZendTestPropertyAttribute_0, true); ZVAL_LONG(&attribute_Attribute_class_ZendTestPropertyAttribute_0->args[0].value, ZEND_ATTRIBUTE_TARGET_PROPERTY); return class_entry; @@ -1122,15 +1126,15 @@ static zend_class_entry *register_class_ZendTestClassWithMethodWithParameterAttr #endif - zend_string *attribute_name_ZendTestParameterAttribute_func_no_override_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, 1); + zend_string *attribute_name_ZendTestParameterAttribute_func_no_override_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, true); zend_attribute *attribute_ZendTestParameterAttribute_func_no_override_arg0_0 = zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "no_override", sizeof("no_override") - 1), 0, attribute_name_ZendTestParameterAttribute_func_no_override_arg0_0, 1); - zend_string_release(attribute_name_ZendTestParameterAttribute_func_no_override_arg0_0); + zend_string_release_ex(attribute_name_ZendTestParameterAttribute_func_no_override_arg0_0, true); zend_string *attribute_ZendTestParameterAttribute_func_no_override_arg0_0_arg0_str = zend_string_init("value2", strlen("value2"), 1); ZVAL_STR(&attribute_ZendTestParameterAttribute_func_no_override_arg0_0->args[0].value, attribute_ZendTestParameterAttribute_func_no_override_arg0_0_arg0_str); - zend_string *attribute_name_ZendTestParameterAttribute_func_override_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, 1); + zend_string *attribute_name_ZendTestParameterAttribute_func_override_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, true); zend_attribute *attribute_ZendTestParameterAttribute_func_override_arg0_0 = zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "override", sizeof("override") - 1), 0, attribute_name_ZendTestParameterAttribute_func_override_arg0_0, 1); - zend_string_release(attribute_name_ZendTestParameterAttribute_func_override_arg0_0); + zend_string_release_ex(attribute_name_ZendTestParameterAttribute_func_override_arg0_0, true); zend_string *attribute_ZendTestParameterAttribute_func_override_arg0_0_arg0_str = zend_string_init("value3", strlen("value3"), 1); ZVAL_STR(&attribute_ZendTestParameterAttribute_func_override_arg0_0->args[0].value, attribute_ZendTestParameterAttribute_func_override_arg0_0_arg0_str); @@ -1149,9 +1153,9 @@ static zend_class_entry *register_class_ZendTestChildClassWithMethodWithParamete #endif - zend_string *attribute_name_ZendTestParameterAttribute_func_override_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, 1); + zend_string *attribute_name_ZendTestParameterAttribute_func_override_arg0_0 = zend_string_init_interned("ZendTestParameterAttribute", sizeof("ZendTestParameterAttribute") - 1, true); zend_attribute *attribute_ZendTestParameterAttribute_func_override_arg0_0 = zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "override", sizeof("override") - 1), 0, attribute_name_ZendTestParameterAttribute_func_override_arg0_0, 1); - zend_string_release(attribute_name_ZendTestParameterAttribute_func_override_arg0_0); + zend_string_release_ex(attribute_name_ZendTestParameterAttribute_func_override_arg0_0, true); zend_string *attribute_ZendTestParameterAttribute_func_override_arg0_0_arg0_str = zend_string_init("value4", strlen("value4"), 1); ZVAL_STR(&attribute_ZendTestParameterAttribute_func_override_arg0_0->args[0].value, attribute_ZendTestParameterAttribute_func_override_arg0_0_arg0_str); @@ -1171,14 +1175,14 @@ static zend_class_entry *register_class_ZendTestClassWithPropertyAttribute(void) zval property_attributed_default_value; ZVAL_UNDEF(&property_attributed_default_value); - zend_string *property_attributed_name = zend_string_init("attributed", sizeof("attributed") - 1, 1); + zend_string *property_attributed_name = zend_string_init("attributed", sizeof("attributed") - 1, true); zend_property_info *property_attributed = zend_declare_typed_property(class_entry, property_attributed_name, &property_attributed_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_attributed_name); + zend_string_release_ex(property_attributed_name, true); - zend_string *attribute_name_ZendTestAttribute_property_attributed_0 = zend_string_init_interned("ZendTestAttribute", sizeof("ZendTestAttribute") - 1, 1); + zend_string *attribute_name_ZendTestAttribute_property_attributed_0 = zend_string_init_interned("ZendTestAttribute", sizeof("ZendTestAttribute") - 1, true); zend_add_property_attribute(class_entry, property_attributed, attribute_name_ZendTestAttribute_property_attributed_0, 0); - zend_string_release(attribute_name_ZendTestAttribute_property_attributed_0); + zend_string_release_ex(attribute_name_ZendTestAttribute_property_attributed_0, true); return class_entry; } @@ -1316,10 +1320,10 @@ static zend_class_entry *register_class_ZendTestNS2_Foo(void) zval property_foo_default_value; ZVAL_UNDEF(&property_foo_default_value); - zend_string *property_foo_name = zend_string_init("foo", sizeof("foo") - 1, 1); + zend_string *property_foo_name = zend_string_init("foo", sizeof("foo") - 1, true); zend_string *property_foo_class_ZendTestNS2_ZendSubNS_Foo = zend_string_init("ZendTestNS2\\ZendSubNS\\Foo", sizeof("ZendTestNS2\\ZendSubNS\\Foo")-1, 1); zend_declare_typed_property(class_entry, property_foo_name, &property_foo_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_CLASS(property_foo_class_ZendTestNS2_ZendSubNS_Foo, 0, 0)); - zend_string_release(property_foo_name); + zend_string_release_ex(property_foo_name, true); return class_entry; } diff --git a/ext/zend_test/tests/zstr_init_literal.phpt b/ext/zend_test/tests/zstr_init_literal.phpt new file mode 100644 index 0000000000000..b7f382da8d6e1 --- /dev/null +++ b/ext/zend_test/tests/zstr_init_literal.phpt @@ -0,0 +1,13 @@ +--TEST-- +zstr_init_literal +--EXTENSIONS-- +zend_test +--FILE-- + +--EXPECT-- +int(7) +string(14) "666f6f00626172" diff --git a/ext/zend_test/tmp_methods.stub.php b/ext/zend_test/tmp_methods.stub.php new file mode 100644 index 0000000000000..af479c7d5422f --- /dev/null +++ b/ext/zend_test/tmp_methods.stub.php @@ -0,0 +1,11 @@ += 0.11 libzip != 1.3.1 libzip != 1.7.0]) + PKG_CHECK_MODULES([LIBZIP], [libzip >= 1.0.0 libzip != 1.3.1 libzip != 1.7.0]) PHP_EVAL_INCLINE([$LIBZIP_CFLAGS]) PHP_EVAL_LIBLINE([$LIBZIP_LIBS], [ZIP_SHARED_LIBADD]) - PHP_CHECK_LIBRARY([zip], [zip_file_set_mtime], - [AC_DEFINE([HAVE_SET_MTIME], [1], - [Define to 1 if libzip library has the 'zip_file_set_mtime' function - (available since 1.0.0).])], - [AC_MSG_WARN([Libzip >= 1.0.0 needed for setting mtime])], - [$LIBZIP_LIBS]) - PHP_CHECK_LIBRARY([zip], [zip_file_set_encryption], [AC_DEFINE([HAVE_ENCRYPTION], [1], [Define to 1 if libzip library has encryption support (available since diff --git a/ext/zip/config.w32 b/ext/zip/config.w32 index c0226f8976460..9b80aefaaad0b 100644 --- a/ext/zip/config.w32 +++ b/ext/zip/config.w32 @@ -17,7 +17,7 @@ if (PHP_ZIP != "no") { } AC_DEFINE('HAVE_ZIP', 1, "Define to 1 if the PHP extension 'zip' is available."); - ADD_FLAG("CFLAGS_ZIP", "/D HAVE_SET_MTIME /D HAVE_ENCRYPTION /D HAVE_LIBZIP_VERSION /D HAVE_PROGRESS_CALLBACK /D HAVE_CANCEL_CALLBACK /D HAVE_METHOD_SUPPORTED /D LZMA_API_STATIC"); + ADD_FLAG("CFLAGS_ZIP", "/D HAVE_ENCRYPTION /D HAVE_LIBZIP_VERSION /D HAVE_PROGRESS_CALLBACK /D HAVE_CANCEL_CALLBACK /D HAVE_METHOD_SUPPORTED /D LZMA_API_STATIC"); } else { WARNING("zip not enabled; libraries and headers not found"); } diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 3417f045ee0f7..4ff362bab15d2 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -74,6 +74,17 @@ static int le_zip_entry; # define add_ascii_assoc_string add_assoc_string # define add_ascii_assoc_long add_assoc_long +static bool php_zip_file_set_encryption(struct zip *intern, zend_long index, zend_long method, char *password) { + // FIXME: is a workaround to reset/free the password in case of consecutive calls. + // when libzip 1.11.5 is available, we can save this call in this case. + if (UNEXPECTED(zip_file_set_encryption(intern, (zip_uint64_t)index, ZIP_EM_NONE, NULL) < 0)) { + php_error_docref(NULL, E_WARNING, "password reset failed"); + return false; + } + + return (zip_file_set_encryption(intern, (zip_uint64_t)index, (zip_uint16_t)method, password) == 0); +} + /* Flatten a path by making a relative path (to .)*/ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */ { @@ -111,11 +122,8 @@ static char * php_zip_make_relative_path(char *path, size_t path_len) /* {{{ */ } /* }}} */ -# define CWD_STATE_ALLOC(l) emalloc(l) -# define CWD_STATE_FREE(s) efree(s) - /* {{{ php_zip_extract_file */ -static int php_zip_extract_file(struct zip * za, char *dest, const char *file, size_t file_len, zip_int64_t idx) +static bool php_zip_extract_file(struct zip * za, char *dest, const char *file, size_t file_len, zip_int64_t idx) { php_stream_statbuf ssb; struct zip_file *zf; @@ -136,10 +144,10 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s if (idx < 0) { idx = zip_name_locate(za, file, 0); if (idx < 0) { - return 0; + return false; } } - new_state.cwd = CWD_STATE_ALLOC(1); + new_state.cwd = emalloc(1); new_state.cwd[0] = '\0'; new_state.cwd_length = 0; @@ -149,14 +157,14 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s virtual_file_ex(&new_state, file, NULL, CWD_EXPAND); path_cleaned = php_zip_make_relative_path(new_state.cwd, new_state.cwd_length); if(!path_cleaned) { - CWD_STATE_FREE(new_state.cwd); - return 0; + efree(new_state.cwd); + return false; } path_cleaned_len = strlen(path_cleaned); if (path_cleaned_len >= MAXPATHLEN || zip_stat_index(za, idx, 0, &sb) != 0) { - CWD_STATE_FREE(new_state.cwd); - return 0; + efree(new_state.cwd); + return false; } /* it is a directory only, see #40228 */ @@ -177,9 +185,9 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname_fullpath)) { efree(file_dirname_fullpath); - zend_string_release_ex(file_basename, 0); - CWD_STATE_FREE(new_state.cwd); - return 0; + zend_string_release_ex(file_basename, false); + efree(new_state.cwd); + return false; } } @@ -189,33 +197,33 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s if (!ret) { efree(file_dirname_fullpath); if (!is_dir_only) { - zend_string_release_ex(file_basename, 0); + zend_string_release_ex(file_basename, false); } - CWD_STATE_FREE(new_state.cwd); - return 0; + efree(new_state.cwd); + return false; } } /* it is a standalone directory, job done */ if (is_dir_only) { efree(file_dirname_fullpath); - CWD_STATE_FREE(new_state.cwd); - return 1; + efree(new_state.cwd); + return true; } len = spprintf(&fullpath, 0, "%s/%s", file_dirname_fullpath, ZSTR_VAL(file_basename)); if (!len) { efree(file_dirname_fullpath); - zend_string_release_ex(file_basename, 0); - CWD_STATE_FREE(new_state.cwd); - return 0; + zend_string_release_ex(file_basename, false); + efree(new_state.cwd); + return false; } else if (len > MAXPATHLEN) { php_error_docref(NULL, E_WARNING, "Full extraction path exceed MAXPATHLEN (%i)", MAXPATHLEN); efree(fullpath); efree(file_dirname_fullpath); - zend_string_release_ex(file_basename, 0); - CWD_STATE_FREE(new_state.cwd); - return 0; + zend_string_release_ex(file_basename, false); + efree(new_state.cwd); + return false; } /* check again the full path, not sure if it @@ -225,9 +233,9 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s if (ZIP_OPENBASEDIR_CHECKPATH(fullpath)) { efree(fullpath); efree(file_dirname_fullpath); - zend_string_release_ex(file_basename, 0); - CWD_STATE_FREE(new_state.cwd); - return 0; + zend_string_release_ex(file_basename, false); + efree(new_state.cwd); + return false; } zf = zip_fopen_index(za, idx, 0); @@ -262,19 +270,15 @@ static int php_zip_extract_file(struct zip * za, char *dest, const char *file, s done: efree(fullpath); - zend_string_release_ex(file_basename, 0); + zend_string_release_ex(file_basename, false); efree(file_dirname_fullpath); - CWD_STATE_FREE(new_state.cwd); + efree(new_state.cwd); - if (n<0) { - return 0; - } else { - return 1; - } + return !(n < 0); } /* }}} */ -static int php_zip_add_file(ze_zip_object *obj, const char *filename, size_t filename_len, +static zend_result php_zip_add_file(ze_zip_object *obj, const char *filename, size_t filename_len, char *entry_name, size_t entry_name_len, /* unused if replace >= 0 */ zip_uint64_t offset_start, zip_uint64_t offset_len, zend_long replace, /* index to replace, add new file if < 0 */ @@ -286,24 +290,24 @@ static int php_zip_add_file(ze_zip_object *obj, const char *filename, size_t fil php_stream_statbuf ssb; if (ZIP_OPENBASEDIR_CHECKPATH(filename)) { - return -1; + return FAILURE; } if (!expand_filepath(filename, resolved_path)) { php_error_docref(NULL, E_WARNING, "No such file or directory"); - return -1; + return FAILURE; } if (php_stream_stat_path_ex(resolved_path, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL)) { php_error_docref(NULL, E_WARNING, "No such file or directory"); - return -1; + return FAILURE; } if (flags & ZIP_FL_OPEN_FILE_NOW) { FILE *fd; fd = fopen(resolved_path, "rb"); if (!fd) { - return -1; + return FAILURE; } flags ^= ZIP_FL_OPEN_FILE_NOW; zs = zip_source_filep(obj->za, fd, offset_start, offset_len); @@ -311,25 +315,25 @@ static int php_zip_add_file(ze_zip_object *obj, const char *filename, size_t fil zs = zip_source_file(obj->za, resolved_path, offset_start, offset_len); } if (!zs) { - return -1; + return FAILURE; } /* Replace */ if (replace >= 0) { if (zip_file_replace(obj->za, replace, zs, flags) < 0) { zip_source_free(zs); - return -1; + return FAILURE; } zip_error_clear(obj->za); - return 1; + return SUCCESS; } /* Add */ obj->last_id = zip_file_add(obj->za, entry_name, zs, flags); if (obj->last_id < 0) { zip_source_free(zs); - return -1; + return FAILURE; } zip_error_clear(obj->za); - return 1; + return SUCCESS; } /* }}} */ @@ -349,7 +353,7 @@ typedef struct { } zip_options; /* Expects opts to be zero-initialized. */ -static int php_zip_parse_options(HashTable *options, zip_options *opts) +static zend_result php_zip_parse_options(HashTable *options, zip_options *opts) /* {{{ */ { zval *option; @@ -374,14 +378,22 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) php_error_docref(NULL, E_WARNING, "Option \"comp_method\" must be of type int, %s given", zend_zval_value_name(option)); } - opts->comp_method = zval_get_long(option); + zend_long comp_method = zval_get_long(option); + if (comp_method < 0 || comp_method > INT_MAX) { + php_error_docref(NULL, E_WARNING, "Option \"comp_method\" must be between 0 and %d", INT_MAX); + } + opts->comp_method = (zip_int32_t)comp_method; if ((option = zend_hash_str_find(options, "comp_flags", sizeof("comp_flags") - 1)) != NULL) { if (Z_TYPE_P(option) != IS_LONG) { php_error_docref(NULL, E_WARNING, "Option \"comp_flags\" must be of type int, %s given", zend_zval_value_name(option)); } - opts->comp_flags = zval_get_long(option); + zend_long comp_flags = zval_get_long(option); + if (comp_flags < 0 || comp_flags > USHRT_MAX) { + php_error_docref(NULL, E_WARNING, "Option \"comp_flags\" must be between 0 and %u", USHRT_MAX); + } + opts->comp_flags = (zip_uint32_t)comp_flags; } } @@ -397,7 +409,7 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if (Z_TYPE_P(option) != IS_STRING) { zend_type_error("Option \"enc_password\" must be of type string, %s given", zend_zval_value_name(option)); - return -1; + return FAILURE; } opts->enc_password = Z_STRVAL_P(option); } @@ -408,17 +420,17 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if (Z_TYPE_P(option) != IS_STRING) { zend_type_error("Option \"remove_path\" must be of type string, %s given", zend_zval_value_name(option)); - return -1; + return FAILURE; } if (Z_STRLEN_P(option) == 0) { zend_value_error("Option \"remove_path\" must not be empty"); - return -1; + return FAILURE; } if (Z_STRLEN_P(option) >= MAXPATHLEN) { zend_value_error("Option \"remove_path\" must be less than %d bytes", MAXPATHLEN - 1); - return -1; + return FAILURE; } opts->remove_path_len = Z_STRLEN_P(option); opts->remove_path = Z_STRVAL_P(option); @@ -428,17 +440,17 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if (Z_TYPE_P(option) != IS_STRING) { zend_type_error("Option \"add_path\" must be of type string, %s given", zend_zval_value_name(option)); - return -1; + return FAILURE; } if (Z_STRLEN_P(option) == 0) { zend_value_error("Option \"add_path\" must not be empty"); - return -1; + return FAILURE; } if (Z_STRLEN_P(option) >= MAXPATHLEN) { zend_value_error("Option \"add_path\" must be less than %d bytes", MAXPATHLEN - 1); - return -1; + return FAILURE; } opts->add_path_len = Z_STRLEN_P(option); opts->add_path = Z_STRVAL_P(option); @@ -448,12 +460,12 @@ static int php_zip_parse_options(HashTable *options, zip_options *opts) if (Z_TYPE_P(option) != IS_LONG) { zend_type_error("Option \"flags\" must be of type int, %s given", zend_zval_value_name(option)); - return -1; + return FAILURE; } opts->flags = Z_LVAL_P(option); } - return 1; + return SUCCESS; } /* }}} */ @@ -503,17 +515,11 @@ static zend_long php_zip_status(ze_zip_object *obj) /* {{{ */ int zep = obj->err_zip; /* saved err if closed */ if (obj->za) { -#if LIBZIP_VERSION_MAJOR < 1 - int syp; - - zip_error_get(obj->za, &zep, &syp); -#else zip_error_t *err; err = zip_get_error(obj->za); zep = zip_error_code_zip(err); zip_error_fini(err); -#endif } return zep; } @@ -530,17 +536,11 @@ static zend_long php_zip_status_sys(ze_zip_object *obj) /* {{{ */ int syp = obj->err_sys; /* saved err if closed */ if (obj->za) { -#if LIBZIP_VERSION_MAJOR < 1 - int zep; - - zip_error_get(obj->za, &zep, &syp); -#else zip_error_t *err; err = zip_get_error(obj->za); syp = zip_error_code_system(err); zip_error_fini(err); -#endif } return syp; } @@ -575,7 +575,7 @@ static char * php_zipobj_get_zip_comment(ze_zip_object *obj, int *len) /* {{{ */ } /* }}} */ -int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_value) /* {{{ */ +int php_zip_glob(zend_string *spattern, zend_long flags, zval *return_value) /* {{{ */ { int cwd_skip = 0; #ifdef ZTS @@ -584,9 +584,11 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v char *result; #endif php_glob_t globbuf; - size_t n; int ret; + const char *pattern = ZSTR_VAL(spattern); + size_t pattern_len = ZSTR_LEN(spattern); + if (pattern_len >= MAXPATHLEN) { php_error_docref(NULL, E_WARNING, "Pattern exceeds the maximum allowed length of %d characters", MAXPATHLEN); return -1; @@ -646,7 +648,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v } array_init(return_value); - for (n = 0; n < globbuf.gl_pathc; n++) { + for (size_t n = 0; n < globbuf.gl_pathc; n++) { /* we need to do this every time since PHP_GLOB_ONLYDIR does not guarantee that * all directories will be filtered. GNU libc documentation states the * following: @@ -717,7 +719,7 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val re = pcre_get_compiled_regex(regexp, &capture_count); if (!re) { for (i = 0; i < files_cnt; i++) { - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); } efree(namelist); php_error_docref(NULL, E_WARNING, "Invalid expression"); @@ -734,28 +736,28 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val if ((namelist_len == 1 && ZSTR_VAL(namelist[i])[0] == '.') || (namelist_len == 2 && ZSTR_VAL(namelist[i])[0] == '.' && ZSTR_VAL(namelist[i])[1] == '.')) { - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); continue; } if ((path_len + namelist_len + 1) >= MAXPATHLEN) { php_error_docref(NULL, E_WARNING, "add_path string too long (max: %u, %zu given)", MAXPATHLEN - 1, (path_len + namelist_len + 1)); - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); break; } match_data = php_pcre_create_match_data(capture_count, re); if (!match_data) { /* Allocation failed, but can proceed to the next pattern. */ - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); continue; } rc = pcre2_match(re, (PCRE2_SPTR)ZSTR_VAL(namelist[i]), ZSTR_LEN(namelist[i]), 0, 0, match_data, mctx); php_pcre_free_match_data(match_data); /* 0 means that the vector is too small to hold all the captured substring offsets */ if (rc < 0) { - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); continue; } @@ -763,17 +765,17 @@ int php_zip_pcre(zend_string *regexp, char *path, int path_len, zval *return_val if (0 != VCWD_STAT(fullpath, &s)) { php_error_docref(NULL, E_WARNING, "Cannot read <%s>", fullpath); - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); continue; } if (S_IFDIR == (s.st_mode & S_IFMT)) { - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); continue; } add_next_index_string(return_value, fullpath); - zend_string_release_ex(namelist[i], 0); + zend_string_release_ex(namelist[i], false); } efree(namelist); } @@ -806,9 +808,9 @@ static void php_zip_register_prop_handler(HashTable *prop_handler, char *name, z hnd.read_const_char_func = read_char_func; hnd.read_int_func = read_int_func; hnd.type = rettype; - str = zend_string_init_interned(name, strlen(name), 1); + str = zend_string_init_interned(name, strlen(name), true); zend_hash_add_mem(prop_handler, str, &hnd, sizeof(zip_prop_handler)); - zend_string_release_ex(str, 1); + zend_string_release_ex(str, true); } /* }}} */ @@ -926,12 +928,12 @@ static int php_zip_has_property(zend_object *object, zend_string *name, int type if (hnd != NULL) { zval tmp, *prop; - if (type == 2) { + if (type == ZEND_PROPERTY_EXISTS) { retval = true; } else if ((prop = php_zip_property_reader(obj, hnd, &tmp)) != NULL) { - if (type == 1) { + if (type == ZEND_PROPERTY_NOT_EMPTY) { retval = zend_is_true(&tmp); - } else if (type == 0) { + } else if (type == ZEND_PROPERTY_ISSET) { retval = (Z_TYPE(tmp) != IS_NULL); } zval_ptr_dtor(&tmp); @@ -960,12 +962,12 @@ static HashTable *php_zip_get_properties(zend_object *object)/* {{{ */ zend_string *key; obj = php_zip_fetch_object(object); - props = zend_std_get_properties(object); if (obj->prop_handler == NULL) { return NULL; } + props = zend_std_get_properties(object); ZEND_HASH_MAP_FOREACH_STR_KEY_PTR(obj->prop_handler, key, hnd) { zval *ret, val; ret = php_zip_property_reader(obj, hnd, &val); @@ -1001,6 +1003,21 @@ static void php_zip_cancel_callback_free(void *ptr) } #endif +static void php_zip_object_dtor(zend_object *object) +{ + zend_objects_destroy_object(object); + + ze_zip_object *intern = php_zip_fetch_object(object); + + if (intern->za) { + if (zip_close(intern->za) != 0) { + php_error_docref(NULL, E_WARNING, "Cannot destroy the zip context: %s", zip_strerror(intern->za)); + zip_discard(intern->za); + } + intern->za = NULL; + } +} + static void php_zip_object_free_storage(zend_object *object) /* {{{ */ { ze_zip_object * intern = php_zip_fetch_object(object); @@ -1015,7 +1032,7 @@ static void php_zip_object_free_storage(zend_object *object) /* {{{ */ if (intern->buffers_cnt>0) { for (i=0; ibuffers_cnt; i++) { - efree(intern->buffers[i]); + zend_string_release(intern->buffers[i]); } efree(intern->buffers); } @@ -1203,7 +1220,7 @@ PHP_FUNCTION(zip_read) RETURN_THROWS(); } - if (rsrc_int && rsrc_int->za) { + if (rsrc_int->za) { if (rsrc_int->index_current >= rsrc_int->num_files) { RETURN_FALSE; } @@ -1256,11 +1273,7 @@ PHP_FUNCTION(zip_entry_open) RETURN_THROWS(); } - if (zr_rsrc->zf != NULL) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(zr_rsrc->zf != NULL); } /* }}} */ @@ -1304,7 +1317,7 @@ PHP_FUNCTION(zip_entry_read) } if (zr_rsrc->zf) { - buffer = zend_string_safe_alloc(1, len, 0, 0); + buffer = zend_string_safe_alloc(1, len, 0, false); zip_int64_t n = zip_fread(zr_rsrc->zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer)); if (n > 0) { ZSTR_VAL(buffer)[n] = '\0'; @@ -1497,12 +1510,7 @@ PHP_METHOD(ZipArchive, setPassword) RETURN_FALSE; } - int res = zip_set_default_password(intern, (const char *)password); - if (res == 0) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(zip_set_default_password(intern, (const char *)password) == 0); } /* }}} */ @@ -1526,18 +1534,12 @@ PHP_METHOD(ZipArchive, close) if (err) { php_error_docref(NULL, E_WARNING, "%s", zip_strerror(intern)); /* Save error for property reader */ - #if LIBZIP_VERSION_MAJOR < 1 - zip_error_get(intern, &ze_obj->err_zip, &ze_obj->err_sys); - #else - { - zip_error_t *ziperr; - - ziperr = zip_get_error(intern); - ze_obj->err_zip = zip_error_code_zip(ziperr); - ze_obj->err_sys = zip_error_code_system(ziperr); - zip_error_fini(ziperr); - } - #endif + zip_error_t *ziperr; + + ziperr = zip_get_error(intern); + ze_obj->err_zip = zip_error_code_zip(ziperr); + ze_obj->err_sys = zip_error_code_system(ziperr); + zip_error_fini(ziperr); zip_discard(intern); } else { ze_obj->err_zip = 0; @@ -1552,11 +1554,7 @@ PHP_METHOD(ZipArchive, close) ze_obj->filename_len = 0; ze_obj->za = NULL; - if (!err) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } + RETURN_BOOL(!err); } /* }}} */ @@ -1602,10 +1600,6 @@ PHP_METHOD(ZipArchive, clearError) PHP_METHOD(ZipArchive, getStatusString) { zval *self = ZEND_THIS; -#if LIBZIP_VERSION_MAJOR < 1 - int zep, syp, len; - char error_string[128]; -#endif ze_zip_object *ze_obj; if (zend_parse_parameters_none() == FAILURE) { @@ -1614,15 +1608,6 @@ PHP_METHOD(ZipArchive, getStatusString) ze_obj = Z_ZIP_P(self); /* not ZIP_FROM_OBJECT as we can use saved error after close */ -#if LIBZIP_VERSION_MAJOR < 1 - if (ze_obj->za) { - zip_error_get(ze_obj->za, &zep, &syp); - len = zip_error_to_str(error_string, 128, zep, syp); - } else { - len = zip_error_to_str(error_string, 128, ze_obj->err_zip, ze_obj->err_sys); - } - RETVAL_STRINGL(error_string, len); -#else if (ze_obj->za) { zip_error_t *err; @@ -1637,7 +1622,6 @@ PHP_METHOD(ZipArchive, getStatusString) RETVAL_STRING(zip_error_strerror(&err)); zip_error_fini(&err); } -#endif } /* }}} */ @@ -1712,24 +1696,21 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* zend_argument_must_not_be_empty_error(1); RETURN_THROWS(); } - if (options && zend_hash_num_elements(options) > 0 && (php_zip_parse_options(options, &opts) < 0)) { + if (options && zend_hash_num_elements(options) > 0 && (php_zip_parse_options(options, &opts) == FAILURE)) { RETURN_THROWS(); } if (type == 1) { - found = php_zip_glob(ZSTR_VAL(pattern), ZSTR_LEN(pattern), glob_flags, return_value); + found = php_zip_glob(pattern, glob_flags, return_value); } else { found = php_zip_pcre(pattern, path, path_len, return_value); } if (found > 0) { - int i; zval *zval_file; - ze_zip_object *ze_obj; + ze_zip_object *ze_obj = Z_ZIP_P(self); - ze_obj = Z_ZIP_P(self); - - for (i = 0; i < found; i++) { + for (int i = 0; i < found; i++) { char *file_stripped, *entry_name; size_t entry_name_len, file_stripped_len; char entry_name_buf[MAXPATHLEN]; @@ -1756,7 +1737,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* if (opts.add_path) { if ((opts.add_path_len + file_stripped_len) > MAXPATHLEN) { if (basename) { - zend_string_release_ex(basename, 0); + zend_string_release_ex(basename, false); } php_error_docref(NULL, E_WARNING, "Entry name too long (max: %d, %zd given)", MAXPATHLEN - 1, (opts.add_path_len + file_stripped_len)); @@ -1771,12 +1752,12 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* entry_name = entry_name_buf; entry_name_len = strlen(entry_name); if (basename) { - zend_string_release_ex(basename, 0); + zend_string_release_ex(basename, false); basename = NULL; } if (php_zip_add_file(ze_obj, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), - entry_name, entry_name_len, 0, 0, -1, opts.flags) < 0) { + entry_name, entry_name_len, 0, 0, -1, opts.flags) == FAILURE) { zend_array_destroy(Z_ARR_P(return_value)); RETURN_FALSE; } @@ -1788,12 +1769,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* } #ifdef HAVE_ENCRYPTION if (opts.enc_method >= 0) { - if (UNEXPECTED(zip_file_set_encryption(ze_obj->za, ze_obj->last_id, ZIP_EM_NONE, NULL) < 0)) { - zend_array_destroy(Z_ARR_P(return_value)); - php_error_docref(NULL, E_WARNING, "password reset failed"); - RETURN_FALSE; - } - if (zip_file_set_encryption(ze_obj->za, ze_obj->last_id, opts.enc_method, opts.enc_password)) { + if (!php_zip_file_set_encryption(ze_obj->za, ze_obj->last_id, opts.enc_method, opts.enc_password)) { zend_array_destroy(Z_ARR_P(return_value)); RETURN_FALSE; } @@ -1848,12 +1824,8 @@ PHP_METHOD(ZipArchive, addFile) entry_name_len = ZSTR_LEN(filename); } - if (php_zip_add_file(Z_ZIP_P(self), ZSTR_VAL(filename), ZSTR_LEN(filename), - entry_name, entry_name_len, offset_start, offset_len, -1, flags) < 0) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + RETURN_BOOL(php_zip_add_file(Z_ZIP_P(self), ZSTR_VAL(filename), ZSTR_LEN(filename), + entry_name, entry_name_len, offset_start, offset_len, -1, flags) == SUCCESS); } /* }}} */ @@ -1881,12 +1853,8 @@ PHP_METHOD(ZipArchive, replaceFile) RETURN_THROWS(); } - if (php_zip_add_file(Z_ZIP_P(self), ZSTR_VAL(filename), ZSTR_LEN(filename), - NULL, 0, offset_start, offset_len, index, flags) < 0) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + RETURN_BOOL(php_zip_add_file(Z_ZIP_P(self), ZSTR_VAL(filename), ZSTR_LEN(filename), + NULL, 0, offset_start, offset_len, index, flags) == SUCCESS); } /* }}} */ @@ -1912,17 +1880,16 @@ PHP_METHOD(ZipArchive, addFromString) ze_obj = Z_ZIP_P(self); if (ze_obj->buffers_cnt) { - ze_obj->buffers = (char **)safe_erealloc(ze_obj->buffers, sizeof(char *), (ze_obj->buffers_cnt+1), 0); + ze_obj->buffers = safe_erealloc(ze_obj->buffers, sizeof(*ze_obj->buffers), (ze_obj->buffers_cnt + 1), 0); pos = ze_obj->buffers_cnt++; } else { - ze_obj->buffers = (char **)emalloc(sizeof(char *)); + ze_obj->buffers = emalloc(sizeof(*ze_obj->buffers)); ze_obj->buffers_cnt++; pos = 0; } - ze_obj->buffers[pos] = (char *)safe_emalloc(ZSTR_LEN(buffer), 1, 1); - memcpy(ze_obj->buffers[pos], ZSTR_VAL(buffer), ZSTR_LEN(buffer) + 1); + ze_obj->buffers[pos] = zend_string_copy(buffer); - zs = zip_source_buffer(intern, ze_obj->buffers[pos], ZSTR_LEN(buffer), 0); + zs = zip_source_buffer(intern, ZSTR_VAL(buffer), ZSTR_LEN(buffer), 0); if (zs == NULL) { RETURN_FALSE; @@ -2056,11 +2023,7 @@ PHP_METHOD(ZipArchive, setArchiveComment) RETURN_THROWS(); } - if (zip_set_archive_comment(intern, (const char *)comment, comment_len)) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + RETURN_BOOL(zip_set_archive_comment(intern, (const char *)comment, comment_len) == 0); } /* }}} */ @@ -2099,11 +2062,7 @@ PHP_METHOD(ZipArchive, setArchiveFlag) ZIP_FROM_OBJECT(intern, self); - if (zip_set_archive_flag(intern, flag, (int)value)) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + RETURN_BOOL(zip_set_archive_flag(intern, flag, (int)value) == 0); } PHP_METHOD(ZipArchive, getArchiveFlag) @@ -2209,10 +2168,7 @@ PHP_METHOD(ZipArchive, setExternalAttributesName) idx = zip_name_locate(intern, name, 0); - if (idx < 0) { - RETURN_FALSE; - } - if (zip_file_set_external_attributes(intern, idx, (zip_flags_t)flags, + if (idx < 0 || zip_file_set_external_attributes(intern, idx, (zip_flags_t)flags, (zip_uint8_t)(opsys&0xff), (zip_uint32_t)attr) < 0) { RETURN_FALSE; } @@ -2236,11 +2192,8 @@ PHP_METHOD(ZipArchive, setExternalAttributesIndex) ZIP_FROM_OBJECT(intern, self); PHP_ZIP_STAT_INDEX(intern, index, 0, sb); - if (zip_file_set_external_attributes(intern, (zip_uint64_t)index, - (zip_flags_t)flags, (zip_uint8_t)(opsys&0xff), (zip_uint32_t)attr) < 0) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(zip_file_set_external_attributes(intern, (zip_uint64_t)index, + (zip_flags_t)flags, (zip_uint8_t)(opsys&0xff), (zip_uint32_t)attr) == 0); } /* }}} */ @@ -2270,10 +2223,7 @@ PHP_METHOD(ZipArchive, getExternalAttributesName) idx = zip_name_locate(intern, name, 0); - if (idx < 0) { - RETURN_FALSE; - } - if (zip_file_get_external_attributes(intern, idx, + if (idx < 0 || zip_file_get_external_attributes(intern, idx, (zip_flags_t)flags, &opsys, &attr) < 0) { RETURN_FALSE; } @@ -2341,15 +2291,7 @@ PHP_METHOD(ZipArchive, setEncryptionName) RETURN_FALSE; } - if (UNEXPECTED(zip_file_set_encryption(intern, idx, ZIP_EM_NONE, NULL) < 0)) { - php_error_docref(NULL, E_WARNING, "password reset failed"); - RETURN_FALSE; - } - - if (zip_file_set_encryption(intern, idx, (zip_uint16_t)method, password)) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(php_zip_file_set_encryption(intern, idx, method, password)); } /* }}} */ @@ -2369,15 +2311,7 @@ PHP_METHOD(ZipArchive, setEncryptionIndex) ZIP_FROM_OBJECT(intern, self); - if (UNEXPECTED(zip_file_set_encryption(intern, index, ZIP_EM_NONE, NULL) < 0)) { - php_error_docref(NULL, E_WARNING, "password reset failed"); - RETURN_FALSE; - } - - if (zip_file_set_encryption(intern, index, (zip_uint16_t)method, password)) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(php_zip_file_set_encryption(intern, index, method, password)); } /* }}} */ #endif @@ -2455,24 +2389,31 @@ PHP_METHOD(ZipArchive, setCompressionName) RETURN_THROWS(); } - ZIP_FROM_OBJECT(intern, this); - if (name_len == 0) { zend_argument_must_not_be_empty_error(1); RETURN_THROWS(); } + if (comp_method < -1 || comp_method > INT_MAX) { + zend_argument_value_error(2, "must be between -1 and %d", INT_MAX); + RETURN_THROWS(); + } + + if (comp_flags < 0 || comp_flags > USHRT_MAX) { + // comp_flags is cast down accordingly in libzip, zip_entry_t compression_level is of zip_uint16_t + zend_argument_value_error(3, "must be between 0 and %u", USHRT_MAX); + RETURN_THROWS(); + } + + ZIP_FROM_OBJECT(intern, this); idx = zip_name_locate(intern, name, 0); if (idx < 0) { RETURN_FALSE; } - if (zip_set_file_compression(intern, (zip_uint64_t)idx, - (zip_int32_t)comp_method, (zip_uint32_t)comp_flags) != 0) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(zip_set_file_compression(intern, (zip_uint64_t)idx, + (zip_int32_t)comp_method, (zip_uint32_t)comp_flags) == 0); } /* }}} */ @@ -2489,17 +2430,28 @@ PHP_METHOD(ZipArchive, setCompressionIndex) RETURN_THROWS(); } - ZIP_FROM_OBJECT(intern, this); - - if (zip_set_file_compression(intern, (zip_uint64_t)index, - (zip_int32_t)comp_method, (zip_uint32_t)comp_flags) != 0) { + if (index < 0) { RETURN_FALSE; } - RETURN_TRUE; + + if (comp_method < -1 || comp_method > INT_MAX) { + zend_argument_value_error(2, "must be between -1 and %d", INT_MAX); + RETURN_THROWS(); + } + + if (comp_flags < 0 || comp_flags > USHRT_MAX) { + // comp_flags is cast down accordingly in libzip, zip_entry_t compression_level is of zip_uint16_t + zend_argument_value_error(3, "must be between 0 and %u", USHRT_MAX); + RETURN_THROWS(); + } + + ZIP_FROM_OBJECT(intern, this); + + RETURN_BOOL(zip_set_file_compression(intern, (zip_uint64_t)index, + (zip_int32_t)comp_method, (zip_uint32_t)comp_flags) == 0); } /* }}} */ -#ifdef HAVE_SET_MTIME /* {{{ Set the modification time of a file in zip, using its name */ PHP_METHOD(ZipArchive, setMtimeName) { @@ -2515,24 +2467,21 @@ PHP_METHOD(ZipArchive, setMtimeName) RETURN_THROWS(); } - ZIP_FROM_OBJECT(intern, this); - if (name_len == 0) { zend_argument_must_not_be_empty_error(1); RETURN_THROWS(); } + ZIP_FROM_OBJECT(intern, this); + idx = zip_name_locate(intern, name, 0); if (idx < 0) { RETURN_FALSE; } - if (zip_file_set_mtime(intern, (zip_uint64_t)idx, - (time_t)mtime, (zip_uint32_t)flags) != 0) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(zip_file_set_mtime(intern, (zip_uint64_t)idx, + (time_t)mtime, (zip_uint32_t)flags) == 0); } /* }}} */ @@ -2551,14 +2500,10 @@ PHP_METHOD(ZipArchive, setMtimeIndex) ZIP_FROM_OBJECT(intern, this); - if (zip_file_set_mtime(intern, (zip_uint64_t)index, - (time_t)mtime, (zip_uint32_t)flags) != 0) { - RETURN_FALSE; - } - RETURN_TRUE; + RETURN_BOOL(zip_file_set_mtime(intern, (zip_uint64_t)index, + (time_t)mtime, (zip_uint32_t)flags) == 0); } /* }}} */ -#endif /* {{{ Delete a file using its index */ PHP_METHOD(ZipArchive, deleteIndex) @@ -2577,11 +2522,7 @@ PHP_METHOD(ZipArchive, deleteIndex) RETURN_FALSE; } - if (zip_delete(intern, index) < 0) { - RETURN_FALSE; - } - - RETURN_TRUE; + RETURN_BOOL(zip_delete(intern, index) == 0); } /* }}} */ @@ -2598,17 +2539,15 @@ PHP_METHOD(ZipArchive, deleteName) RETURN_THROWS(); } - ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { RETURN_FALSE; } + ZIP_FROM_OBJECT(intern, self); + PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); - if (zip_delete(intern, sb.index)) { - RETURN_FALSE; - } - RETURN_TRUE; + + RETURN_BOOL(zip_delete(intern, sb.index) == 0); } /* }}} */ @@ -2629,18 +2568,14 @@ PHP_METHOD(ZipArchive, renameIndex) RETURN_FALSE; } - ZIP_FROM_OBJECT(intern, self); - if (new_name_len == 0) { zend_argument_must_not_be_empty_error(2); RETURN_THROWS(); } - if (zip_file_rename(intern, index, (const char *)new_name, 0) != 0) { - RETURN_FALSE; - } + ZIP_FROM_OBJECT(intern, self); - RETURN_TRUE; + RETURN_BOOL(zip_file_rename(intern, index, (const char *)new_name, 0) == 0); } /* }}} */ @@ -2666,11 +2601,7 @@ PHP_METHOD(ZipArchive, renameName) PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); - if (zip_file_rename(intern, sb.index, (const char *)new_name, 0)) { - RETURN_FALSE; - } - - RETURN_TRUE; + RETURN_BOOL(zip_file_rename(intern, sb.index, (const char *)new_name, 0) == 0); } /* }}} */ @@ -2685,17 +2616,13 @@ PHP_METHOD(ZipArchive, unchangeIndex) RETURN_THROWS(); } - ZIP_FROM_OBJECT(intern, self); - if (index < 0) { RETURN_FALSE; } - if (zip_unchange(intern, index) != 0) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + ZIP_FROM_OBJECT(intern, self); + + RETURN_BOOL(zip_unchange(intern, index) == 0); } /* }}} */ @@ -2712,19 +2639,15 @@ PHP_METHOD(ZipArchive, unchangeName) RETURN_THROWS(); } - ZIP_FROM_OBJECT(intern, self); - if (name_len < 1) { RETURN_FALSE; } + ZIP_FROM_OBJECT(intern, self); + PHP_ZIP_STAT_PATH(intern, name, name_len, 0, sb); - if (zip_unchange(intern, sb.index) != 0) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + RETURN_BOOL(zip_unchange(intern, sb.index) == 0); } /* }}} */ @@ -2740,11 +2663,7 @@ PHP_METHOD(ZipArchive, unchangeAll) ZIP_FROM_OBJECT(intern, self); - if (zip_unchange_all(intern) != 0) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + RETURN_BOOL(zip_unchange_all(intern) == 0); } /* }}} */ @@ -2760,11 +2679,7 @@ PHP_METHOD(ZipArchive, unchangeArchive) ZIP_FROM_OBJECT(intern, self); - if (zip_unchange_archive(intern) != 0) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } + RETURN_BOOL(zip_unchange_archive(intern) == 0); } /* }}} */ @@ -2793,8 +2708,6 @@ PHP_METHOD(ZipArchive, extractTo) Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(files_ht, files_str) ZEND_PARSE_PARAMETERS_END(); - ZIP_FROM_OBJECT(intern, self); - if (pathto_len < 1) { RETURN_FALSE; } @@ -2807,6 +2720,7 @@ PHP_METHOD(ZipArchive, extractTo) } uint32_t nelems, i; + ZIP_FROM_OBJECT(intern, self); if (files_str) { if (!php_zip_extract_file(intern, pathto, ZSTR_VAL(files_str), ZSTR_LEN(files_str), -1)) { @@ -2820,14 +2734,13 @@ PHP_METHOD(ZipArchive, extractTo) for (i = 0; i < nelems; i++) { zval *zval_file; if ((zval_file = zend_hash_index_find_deref(files_ht, i)) != NULL) { - switch (Z_TYPE_P(zval_file)) { - case IS_LONG: - break; - case IS_STRING: + if (Z_TYPE_P(zval_file) == IS_STRING) { if (!php_zip_extract_file(intern, pathto, Z_STRVAL_P(zval_file), Z_STRLEN_P(zval_file), -1)) { RETURN_FALSE; } - break; + } else { + zend_argument_type_error(2, "must only have elements of type string, %s given", zend_zval_value_name(zval_file)); + RETURN_THROWS(); } } } @@ -2902,7 +2815,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */ RETURN_FALSE; } - buffer = zend_string_safe_alloc(1, len, 0, 0); + buffer = zend_string_safe_alloc(1, len, 0, false); zip_int64_t n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer)); if (n < 1) { zend_string_efree(buffer); @@ -2996,6 +2909,10 @@ PHP_METHOD(ZipArchive, getStream) #ifdef HAVE_PROGRESS_CALLBACK static void php_zip_progress_callback(zip_t *arch, double state, void *ptr) { + if (!EG(active)) { + return; + } + zval cb_args[1]; ze_zip_object *obj = ptr; @@ -3043,6 +2960,10 @@ static int php_zip_cancel_callback(zip_t *arch, void *ptr) zval cb_retval; ze_zip_object *obj = ptr; + if (!EG(active)) { + return 0; + } + zend_call_known_fcc(&obj->cancel_callback, &cb_retval, 0, NULL, NULL); if (Z_ISUNDEF(cb_retval)) { /* Cancel if an exception has been thrown */ @@ -3098,11 +3019,15 @@ PHP_METHOD(ZipArchive, registerCancelCallback) PHP_METHOD(ZipArchive, isCompressionMethodSupported) { zend_long method; - bool enc = 1; + bool enc = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|b", &method, &enc) == FAILURE) { return; } + if (method < -1 || method > INT_MAX) { + zend_argument_value_error(1, "must be between -1 and %d", INT_MAX); + RETURN_THROWS(); + } RETVAL_BOOL(zip_compression_method_supported((zip_int32_t)method, enc)); } /* }}} */ @@ -3111,12 +3036,16 @@ PHP_METHOD(ZipArchive, isCompressionMethodSupported) PHP_METHOD(ZipArchive, isEncryptionMethodSupported) { zend_long method; - bool enc = 1; + bool enc = true; if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|b", &method, &enc) == FAILURE) { return; } - RETVAL_BOOL(zip_encryption_method_supported((zip_uint16_t)method, enc)); + if (method < 0 || method > USHRT_MAX) { + zend_argument_value_error(1, "must be between 0 and %u", USHRT_MAX); + RETURN_THROWS(); + } + RETURN_BOOL(zip_encryption_method_supported((zip_uint16_t)method, enc)); } /* }}} */ #endif @@ -3131,6 +3060,7 @@ static PHP_MINIT_FUNCTION(zip) memcpy(&zip_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); zip_object_handlers.offset = XtOffsetOf(ze_zip_object, zo); zip_object_handlers.free_obj = php_zip_object_free_storage; + zip_object_handlers.dtor_obj = php_zip_object_dtor; zip_object_handlers.clone_obj = NULL; zip_object_handlers.get_property_ptr_ptr = php_zip_get_property_ptr_ptr; diff --git a/ext/zip/php_zip.h b/ext/zip/php_zip.h index 61e7fb8dad1ea..5dc7bab250042 100644 --- a/ext/zip/php_zip.h +++ b/ext/zip/php_zip.h @@ -68,7 +68,7 @@ typedef struct _ze_zip_read_rsrc { /* Extends zend object */ typedef struct _ze_zip_object { struct zip *za; - char **buffers; + zend_string **buffers; HashTable *prop_handler; char *filename; int filename_len; diff --git a/ext/zip/php_zip.stub.php b/ext/zip/php_zip.stub.php index 3473d27bf2050..8a37b2508da18 100644 --- a/ext/zip/php_zip.stub.php +++ b/ext/zip/php_zip.stub.php @@ -704,13 +704,11 @@ public function setCommentIndex(int $index, string $comment): bool {} /** @tentative-return-type */ public function setCommentName(string $name, string $comment): bool {} -#ifdef HAVE_SET_MTIME /** @tentative-return-type */ public function setMtimeIndex(int $index, int $timestamp, int $flags = 0): bool {} /** @tentative-return-type */ public function setMtimeName(string $name, int $timestamp, int $flags = 0): bool {} -#endif /** @tentative-return-type */ public function getCommentIndex(int $index, int $flags = 0): string|false {} diff --git a/ext/zip/php_zip_arginfo.h b/ext/zip/php_zip_arginfo.h index 2a24750142c95..ba4f867e8af73 100644 --- a/ext/zip/php_zip_arginfo.h +++ b/ext/zip/php_zip_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 53e04d9b2c25cc8a0c9fe51914b5a47280834fb8 */ + * Stub hash: 1f77735273373672b9c8c5b92c46e23ea99faeaf */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -138,7 +138,6 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_setCo ZEND_ARG_TYPE_INFO(0, comment, IS_STRING, 0) ZEND_END_ARG_INFO() -#if defined(HAVE_SET_MTIME) ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_setMtimeIndex, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0) @@ -150,7 +149,6 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ZipArchive_setMt ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_ZipArchive_getCommentIndex, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) @@ -334,10 +332,8 @@ ZEND_METHOD(ZipArchive, setArchiveFlag); ZEND_METHOD(ZipArchive, getArchiveFlag); ZEND_METHOD(ZipArchive, setCommentIndex); ZEND_METHOD(ZipArchive, setCommentName); -#if defined(HAVE_SET_MTIME) ZEND_METHOD(ZipArchive, setMtimeIndex); ZEND_METHOD(ZipArchive, setMtimeName); -#endif ZEND_METHOD(ZipArchive, getCommentIndex); ZEND_METHOD(ZipArchive, getCommentName); ZEND_METHOD(ZipArchive, deleteIndex); @@ -414,10 +410,8 @@ static const zend_function_entry class_ZipArchive_methods[] = { ZEND_ME(ZipArchive, getArchiveFlag, arginfo_class_ZipArchive_getArchiveFlag, ZEND_ACC_PUBLIC) ZEND_ME(ZipArchive, setCommentIndex, arginfo_class_ZipArchive_setCommentIndex, ZEND_ACC_PUBLIC) ZEND_ME(ZipArchive, setCommentName, arginfo_class_ZipArchive_setCommentName, ZEND_ACC_PUBLIC) -#if defined(HAVE_SET_MTIME) ZEND_ME(ZipArchive, setMtimeIndex, arginfo_class_ZipArchive_setMtimeIndex, ZEND_ACC_PUBLIC) ZEND_ME(ZipArchive, setMtimeName, arginfo_class_ZipArchive_setMtimeName, ZEND_ACC_PUBLIC) -#endif ZEND_ME(ZipArchive, getCommentIndex, arginfo_class_ZipArchive_getCommentIndex, ZEND_ACC_PUBLIC) ZEND_ME(ZipArchive, getCommentName, arginfo_class_ZipArchive_getCommentName, ZEND_ACC_PUBLIC) ZEND_ME(ZipArchive, deleteIndex, arginfo_class_ZipArchive_deleteIndex, ZEND_ACC_PUBLIC) @@ -535,740 +529,740 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry zval const_CREATE_value; ZVAL_LONG(&const_CREATE_value, ZIP_CREATE); - zend_string *const_CREATE_name = zend_string_init_interned("CREATE", sizeof("CREATE") - 1, 1); + zend_string *const_CREATE_name = zend_string_init_interned("CREATE", sizeof("CREATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CREATE_name, &const_CREATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CREATE_name); + zend_string_release_ex(const_CREATE_name, true); zval const_EXCL_value; ZVAL_LONG(&const_EXCL_value, ZIP_EXCL); - zend_string *const_EXCL_name = zend_string_init_interned("EXCL", sizeof("EXCL") - 1, 1); + zend_string *const_EXCL_name = zend_string_init_interned("EXCL", sizeof("EXCL") - 1, true); zend_declare_typed_class_constant(class_entry, const_EXCL_name, &const_EXCL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EXCL_name); + zend_string_release_ex(const_EXCL_name, true); zval const_CHECKCONS_value; ZVAL_LONG(&const_CHECKCONS_value, ZIP_CHECKCONS); - zend_string *const_CHECKCONS_name = zend_string_init_interned("CHECKCONS", sizeof("CHECKCONS") - 1, 1); + zend_string *const_CHECKCONS_name = zend_string_init_interned("CHECKCONS", sizeof("CHECKCONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_CHECKCONS_name, &const_CHECKCONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CHECKCONS_name); + zend_string_release_ex(const_CHECKCONS_name, true); zval const_OVERWRITE_value; ZVAL_LONG(&const_OVERWRITE_value, ZIP_OVERWRITE); - zend_string *const_OVERWRITE_name = zend_string_init_interned("OVERWRITE", sizeof("OVERWRITE") - 1, 1); + zend_string *const_OVERWRITE_name = zend_string_init_interned("OVERWRITE", sizeof("OVERWRITE") - 1, true); zend_declare_typed_class_constant(class_entry, const_OVERWRITE_name, &const_OVERWRITE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OVERWRITE_name); + zend_string_release_ex(const_OVERWRITE_name, true); #if defined(ZIP_RDONLY) zval const_RDONLY_value; ZVAL_LONG(&const_RDONLY_value, ZIP_RDONLY); - zend_string *const_RDONLY_name = zend_string_init_interned("RDONLY", sizeof("RDONLY") - 1, 1); + zend_string *const_RDONLY_name = zend_string_init_interned("RDONLY", sizeof("RDONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_RDONLY_name, &const_RDONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_RDONLY_name); + zend_string_release_ex(const_RDONLY_name, true); #endif zval const_FL_NOCASE_value; ZVAL_LONG(&const_FL_NOCASE_value, ZIP_FL_NOCASE); - zend_string *const_FL_NOCASE_name = zend_string_init_interned("FL_NOCASE", sizeof("FL_NOCASE") - 1, 1); + zend_string *const_FL_NOCASE_name = zend_string_init_interned("FL_NOCASE", sizeof("FL_NOCASE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_NOCASE_name, &const_FL_NOCASE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_NOCASE_name); + zend_string_release_ex(const_FL_NOCASE_name, true); zval const_FL_NODIR_value; ZVAL_LONG(&const_FL_NODIR_value, ZIP_FL_NODIR); - zend_string *const_FL_NODIR_name = zend_string_init_interned("FL_NODIR", sizeof("FL_NODIR") - 1, 1); + zend_string *const_FL_NODIR_name = zend_string_init_interned("FL_NODIR", sizeof("FL_NODIR") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_NODIR_name, &const_FL_NODIR_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_NODIR_name); + zend_string_release_ex(const_FL_NODIR_name, true); zval const_FL_COMPRESSED_value; ZVAL_LONG(&const_FL_COMPRESSED_value, ZIP_FL_COMPRESSED); - zend_string *const_FL_COMPRESSED_name = zend_string_init_interned("FL_COMPRESSED", sizeof("FL_COMPRESSED") - 1, 1); + zend_string *const_FL_COMPRESSED_name = zend_string_init_interned("FL_COMPRESSED", sizeof("FL_COMPRESSED") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_COMPRESSED_name, &const_FL_COMPRESSED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_COMPRESSED_name); + zend_string_release_ex(const_FL_COMPRESSED_name, true); zval const_FL_UNCHANGED_value; ZVAL_LONG(&const_FL_UNCHANGED_value, ZIP_FL_UNCHANGED); - zend_string *const_FL_UNCHANGED_name = zend_string_init_interned("FL_UNCHANGED", sizeof("FL_UNCHANGED") - 1, 1); + zend_string *const_FL_UNCHANGED_name = zend_string_init_interned("FL_UNCHANGED", sizeof("FL_UNCHANGED") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_UNCHANGED_name, &const_FL_UNCHANGED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_UNCHANGED_name); + zend_string_release_ex(const_FL_UNCHANGED_name, true); #if defined(ZIP_FL_RECOMPRESS) zval const_FL_RECOMPRESS_value; ZVAL_LONG(&const_FL_RECOMPRESS_value, ZIP_FL_RECOMPRESS); - zend_string *const_FL_RECOMPRESS_name = zend_string_init_interned("FL_RECOMPRESS", sizeof("FL_RECOMPRESS") - 1, 1); + zend_string *const_FL_RECOMPRESS_name = zend_string_init_interned("FL_RECOMPRESS", sizeof("FL_RECOMPRESS") - 1, true); zend_class_constant *const_FL_RECOMPRESS = zend_declare_typed_class_constant(class_entry, const_FL_RECOMPRESS_name, &const_FL_RECOMPRESS_value, ZEND_ACC_PUBLIC|ZEND_ACC_DEPRECATED, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_RECOMPRESS_name); + zend_string_release_ex(const_FL_RECOMPRESS_name, true); #endif zval const_FL_ENCRYPTED_value; ZVAL_LONG(&const_FL_ENCRYPTED_value, ZIP_FL_ENCRYPTED); - zend_string *const_FL_ENCRYPTED_name = zend_string_init_interned("FL_ENCRYPTED", sizeof("FL_ENCRYPTED") - 1, 1); + zend_string *const_FL_ENCRYPTED_name = zend_string_init_interned("FL_ENCRYPTED", sizeof("FL_ENCRYPTED") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_ENCRYPTED_name, &const_FL_ENCRYPTED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_ENCRYPTED_name); + zend_string_release_ex(const_FL_ENCRYPTED_name, true); zval const_FL_OVERWRITE_value; ZVAL_LONG(&const_FL_OVERWRITE_value, ZIP_FL_OVERWRITE); - zend_string *const_FL_OVERWRITE_name = zend_string_init_interned("FL_OVERWRITE", sizeof("FL_OVERWRITE") - 1, 1); + zend_string *const_FL_OVERWRITE_name = zend_string_init_interned("FL_OVERWRITE", sizeof("FL_OVERWRITE") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_OVERWRITE_name, &const_FL_OVERWRITE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_OVERWRITE_name); + zend_string_release_ex(const_FL_OVERWRITE_name, true); zval const_FL_LOCAL_value; ZVAL_LONG(&const_FL_LOCAL_value, ZIP_FL_LOCAL); - zend_string *const_FL_LOCAL_name = zend_string_init_interned("FL_LOCAL", sizeof("FL_LOCAL") - 1, 1); + zend_string *const_FL_LOCAL_name = zend_string_init_interned("FL_LOCAL", sizeof("FL_LOCAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_LOCAL_name, &const_FL_LOCAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_LOCAL_name); + zend_string_release_ex(const_FL_LOCAL_name, true); zval const_FL_CENTRAL_value; ZVAL_LONG(&const_FL_CENTRAL_value, ZIP_FL_CENTRAL); - zend_string *const_FL_CENTRAL_name = zend_string_init_interned("FL_CENTRAL", sizeof("FL_CENTRAL") - 1, 1); + zend_string *const_FL_CENTRAL_name = zend_string_init_interned("FL_CENTRAL", sizeof("FL_CENTRAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_CENTRAL_name, &const_FL_CENTRAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_CENTRAL_name); + zend_string_release_ex(const_FL_CENTRAL_name, true); zval const_FL_ENC_GUESS_value; ZVAL_LONG(&const_FL_ENC_GUESS_value, ZIP_FL_ENC_GUESS); - zend_string *const_FL_ENC_GUESS_name = zend_string_init_interned("FL_ENC_GUESS", sizeof("FL_ENC_GUESS") - 1, 1); + zend_string *const_FL_ENC_GUESS_name = zend_string_init_interned("FL_ENC_GUESS", sizeof("FL_ENC_GUESS") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_ENC_GUESS_name, &const_FL_ENC_GUESS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_ENC_GUESS_name); + zend_string_release_ex(const_FL_ENC_GUESS_name, true); zval const_FL_ENC_RAW_value; ZVAL_LONG(&const_FL_ENC_RAW_value, ZIP_FL_ENC_RAW); - zend_string *const_FL_ENC_RAW_name = zend_string_init_interned("FL_ENC_RAW", sizeof("FL_ENC_RAW") - 1, 1); + zend_string *const_FL_ENC_RAW_name = zend_string_init_interned("FL_ENC_RAW", sizeof("FL_ENC_RAW") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_ENC_RAW_name, &const_FL_ENC_RAW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_ENC_RAW_name); + zend_string_release_ex(const_FL_ENC_RAW_name, true); zval const_FL_ENC_STRICT_value; ZVAL_LONG(&const_FL_ENC_STRICT_value, ZIP_FL_ENC_STRICT); - zend_string *const_FL_ENC_STRICT_name = zend_string_init_interned("FL_ENC_STRICT", sizeof("FL_ENC_STRICT") - 1, 1); + zend_string *const_FL_ENC_STRICT_name = zend_string_init_interned("FL_ENC_STRICT", sizeof("FL_ENC_STRICT") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_ENC_STRICT_name, &const_FL_ENC_STRICT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_ENC_STRICT_name); + zend_string_release_ex(const_FL_ENC_STRICT_name, true); zval const_FL_ENC_UTF_8_value; ZVAL_LONG(&const_FL_ENC_UTF_8_value, ZIP_FL_ENC_UTF_8); - zend_string *const_FL_ENC_UTF_8_name = zend_string_init_interned("FL_ENC_UTF_8", sizeof("FL_ENC_UTF_8") - 1, 1); + zend_string *const_FL_ENC_UTF_8_name = zend_string_init_interned("FL_ENC_UTF_8", sizeof("FL_ENC_UTF_8") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_ENC_UTF_8_name, &const_FL_ENC_UTF_8_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_ENC_UTF_8_name); + zend_string_release_ex(const_FL_ENC_UTF_8_name, true); zval const_FL_ENC_CP437_value; ZVAL_LONG(&const_FL_ENC_CP437_value, ZIP_FL_ENC_CP437); - zend_string *const_FL_ENC_CP437_name = zend_string_init_interned("FL_ENC_CP437", sizeof("FL_ENC_CP437") - 1, 1); + zend_string *const_FL_ENC_CP437_name = zend_string_init_interned("FL_ENC_CP437", sizeof("FL_ENC_CP437") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_ENC_CP437_name, &const_FL_ENC_CP437_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_ENC_CP437_name); + zend_string_release_ex(const_FL_ENC_CP437_name, true); zval const_FL_OPEN_FILE_NOW_value; ZVAL_LONG(&const_FL_OPEN_FILE_NOW_value, ZIP_FL_OPEN_FILE_NOW); - zend_string *const_FL_OPEN_FILE_NOW_name = zend_string_init_interned("FL_OPEN_FILE_NOW", sizeof("FL_OPEN_FILE_NOW") - 1, 1); + zend_string *const_FL_OPEN_FILE_NOW_name = zend_string_init_interned("FL_OPEN_FILE_NOW", sizeof("FL_OPEN_FILE_NOW") - 1, true); zend_declare_typed_class_constant(class_entry, const_FL_OPEN_FILE_NOW_name, &const_FL_OPEN_FILE_NOW_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_FL_OPEN_FILE_NOW_name); + zend_string_release_ex(const_FL_OPEN_FILE_NOW_name, true); zval const_CM_DEFAULT_value; ZVAL_LONG(&const_CM_DEFAULT_value, ZIP_CM_DEFAULT); - zend_string *const_CM_DEFAULT_name = zend_string_init_interned("CM_DEFAULT", sizeof("CM_DEFAULT") - 1, 1); + zend_string *const_CM_DEFAULT_name = zend_string_init_interned("CM_DEFAULT", sizeof("CM_DEFAULT") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_DEFAULT_name, &const_CM_DEFAULT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_DEFAULT_name); + zend_string_release_ex(const_CM_DEFAULT_name, true); zval const_CM_STORE_value; ZVAL_LONG(&const_CM_STORE_value, ZIP_CM_STORE); - zend_string *const_CM_STORE_name = zend_string_init_interned("CM_STORE", sizeof("CM_STORE") - 1, 1); + zend_string *const_CM_STORE_name = zend_string_init_interned("CM_STORE", sizeof("CM_STORE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_STORE_name, &const_CM_STORE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_STORE_name); + zend_string_release_ex(const_CM_STORE_name, true); zval const_CM_SHRINK_value; ZVAL_LONG(&const_CM_SHRINK_value, ZIP_CM_SHRINK); - zend_string *const_CM_SHRINK_name = zend_string_init_interned("CM_SHRINK", sizeof("CM_SHRINK") - 1, 1); + zend_string *const_CM_SHRINK_name = zend_string_init_interned("CM_SHRINK", sizeof("CM_SHRINK") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_SHRINK_name, &const_CM_SHRINK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_SHRINK_name); + zend_string_release_ex(const_CM_SHRINK_name, true); zval const_CM_REDUCE_1_value; ZVAL_LONG(&const_CM_REDUCE_1_value, ZIP_CM_REDUCE_1); - zend_string *const_CM_REDUCE_1_name = zend_string_init_interned("CM_REDUCE_1", sizeof("CM_REDUCE_1") - 1, 1); + zend_string *const_CM_REDUCE_1_name = zend_string_init_interned("CM_REDUCE_1", sizeof("CM_REDUCE_1") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_REDUCE_1_name, &const_CM_REDUCE_1_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_REDUCE_1_name); + zend_string_release_ex(const_CM_REDUCE_1_name, true); zval const_CM_REDUCE_2_value; ZVAL_LONG(&const_CM_REDUCE_2_value, ZIP_CM_REDUCE_2); - zend_string *const_CM_REDUCE_2_name = zend_string_init_interned("CM_REDUCE_2", sizeof("CM_REDUCE_2") - 1, 1); + zend_string *const_CM_REDUCE_2_name = zend_string_init_interned("CM_REDUCE_2", sizeof("CM_REDUCE_2") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_REDUCE_2_name, &const_CM_REDUCE_2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_REDUCE_2_name); + zend_string_release_ex(const_CM_REDUCE_2_name, true); zval const_CM_REDUCE_3_value; ZVAL_LONG(&const_CM_REDUCE_3_value, ZIP_CM_REDUCE_3); - zend_string *const_CM_REDUCE_3_name = zend_string_init_interned("CM_REDUCE_3", sizeof("CM_REDUCE_3") - 1, 1); + zend_string *const_CM_REDUCE_3_name = zend_string_init_interned("CM_REDUCE_3", sizeof("CM_REDUCE_3") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_REDUCE_3_name, &const_CM_REDUCE_3_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_REDUCE_3_name); + zend_string_release_ex(const_CM_REDUCE_3_name, true); zval const_CM_REDUCE_4_value; ZVAL_LONG(&const_CM_REDUCE_4_value, ZIP_CM_REDUCE_4); - zend_string *const_CM_REDUCE_4_name = zend_string_init_interned("CM_REDUCE_4", sizeof("CM_REDUCE_4") - 1, 1); + zend_string *const_CM_REDUCE_4_name = zend_string_init_interned("CM_REDUCE_4", sizeof("CM_REDUCE_4") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_REDUCE_4_name, &const_CM_REDUCE_4_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_REDUCE_4_name); + zend_string_release_ex(const_CM_REDUCE_4_name, true); zval const_CM_IMPLODE_value; ZVAL_LONG(&const_CM_IMPLODE_value, ZIP_CM_IMPLODE); - zend_string *const_CM_IMPLODE_name = zend_string_init_interned("CM_IMPLODE", sizeof("CM_IMPLODE") - 1, 1); + zend_string *const_CM_IMPLODE_name = zend_string_init_interned("CM_IMPLODE", sizeof("CM_IMPLODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_IMPLODE_name, &const_CM_IMPLODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_IMPLODE_name); + zend_string_release_ex(const_CM_IMPLODE_name, true); zval const_CM_DEFLATE_value; ZVAL_LONG(&const_CM_DEFLATE_value, ZIP_CM_DEFLATE); - zend_string *const_CM_DEFLATE_name = zend_string_init_interned("CM_DEFLATE", sizeof("CM_DEFLATE") - 1, 1); + zend_string *const_CM_DEFLATE_name = zend_string_init_interned("CM_DEFLATE", sizeof("CM_DEFLATE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_DEFLATE_name, &const_CM_DEFLATE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_DEFLATE_name); + zend_string_release_ex(const_CM_DEFLATE_name, true); zval const_CM_DEFLATE64_value; ZVAL_LONG(&const_CM_DEFLATE64_value, ZIP_CM_DEFLATE64); - zend_string *const_CM_DEFLATE64_name = zend_string_init_interned("CM_DEFLATE64", sizeof("CM_DEFLATE64") - 1, 1); + zend_string *const_CM_DEFLATE64_name = zend_string_init_interned("CM_DEFLATE64", sizeof("CM_DEFLATE64") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_DEFLATE64_name, &const_CM_DEFLATE64_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_DEFLATE64_name); + zend_string_release_ex(const_CM_DEFLATE64_name, true); zval const_CM_PKWARE_IMPLODE_value; ZVAL_LONG(&const_CM_PKWARE_IMPLODE_value, ZIP_CM_PKWARE_IMPLODE); - zend_string *const_CM_PKWARE_IMPLODE_name = zend_string_init_interned("CM_PKWARE_IMPLODE", sizeof("CM_PKWARE_IMPLODE") - 1, 1); + zend_string *const_CM_PKWARE_IMPLODE_name = zend_string_init_interned("CM_PKWARE_IMPLODE", sizeof("CM_PKWARE_IMPLODE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_PKWARE_IMPLODE_name, &const_CM_PKWARE_IMPLODE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_PKWARE_IMPLODE_name); + zend_string_release_ex(const_CM_PKWARE_IMPLODE_name, true); zval const_CM_BZIP2_value; ZVAL_LONG(&const_CM_BZIP2_value, ZIP_CM_BZIP2); - zend_string *const_CM_BZIP2_name = zend_string_init_interned("CM_BZIP2", sizeof("CM_BZIP2") - 1, 1); + zend_string *const_CM_BZIP2_name = zend_string_init_interned("CM_BZIP2", sizeof("CM_BZIP2") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_BZIP2_name, &const_CM_BZIP2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_BZIP2_name); + zend_string_release_ex(const_CM_BZIP2_name, true); zval const_CM_LZMA_value; ZVAL_LONG(&const_CM_LZMA_value, ZIP_CM_LZMA); - zend_string *const_CM_LZMA_name = zend_string_init_interned("CM_LZMA", sizeof("CM_LZMA") - 1, 1); + zend_string *const_CM_LZMA_name = zend_string_init_interned("CM_LZMA", sizeof("CM_LZMA") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_LZMA_name, &const_CM_LZMA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_LZMA_name); + zend_string_release_ex(const_CM_LZMA_name, true); #if defined(ZIP_CM_LZMA2) zval const_CM_LZMA2_value; ZVAL_LONG(&const_CM_LZMA2_value, ZIP_CM_LZMA2); - zend_string *const_CM_LZMA2_name = zend_string_init_interned("CM_LZMA2", sizeof("CM_LZMA2") - 1, 1); + zend_string *const_CM_LZMA2_name = zend_string_init_interned("CM_LZMA2", sizeof("CM_LZMA2") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_LZMA2_name, &const_CM_LZMA2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_LZMA2_name); + zend_string_release_ex(const_CM_LZMA2_name, true); #endif #if defined(ZIP_CM_ZSTD) zval const_CM_ZSTD_value; ZVAL_LONG(&const_CM_ZSTD_value, ZIP_CM_ZSTD); - zend_string *const_CM_ZSTD_name = zend_string_init_interned("CM_ZSTD", sizeof("CM_ZSTD") - 1, 1); + zend_string *const_CM_ZSTD_name = zend_string_init_interned("CM_ZSTD", sizeof("CM_ZSTD") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_ZSTD_name, &const_CM_ZSTD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_ZSTD_name); + zend_string_release_ex(const_CM_ZSTD_name, true); #endif #if defined(ZIP_CM_XZ) zval const_CM_XZ_value; ZVAL_LONG(&const_CM_XZ_value, ZIP_CM_XZ); - zend_string *const_CM_XZ_name = zend_string_init_interned("CM_XZ", sizeof("CM_XZ") - 1, 1); + zend_string *const_CM_XZ_name = zend_string_init_interned("CM_XZ", sizeof("CM_XZ") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_XZ_name, &const_CM_XZ_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_XZ_name); + zend_string_release_ex(const_CM_XZ_name, true); #endif zval const_CM_TERSE_value; ZVAL_LONG(&const_CM_TERSE_value, ZIP_CM_TERSE); - zend_string *const_CM_TERSE_name = zend_string_init_interned("CM_TERSE", sizeof("CM_TERSE") - 1, 1); + zend_string *const_CM_TERSE_name = zend_string_init_interned("CM_TERSE", sizeof("CM_TERSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_TERSE_name, &const_CM_TERSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_TERSE_name); + zend_string_release_ex(const_CM_TERSE_name, true); zval const_CM_LZ77_value; ZVAL_LONG(&const_CM_LZ77_value, ZIP_CM_LZ77); - zend_string *const_CM_LZ77_name = zend_string_init_interned("CM_LZ77", sizeof("CM_LZ77") - 1, 1); + zend_string *const_CM_LZ77_name = zend_string_init_interned("CM_LZ77", sizeof("CM_LZ77") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_LZ77_name, &const_CM_LZ77_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_LZ77_name); + zend_string_release_ex(const_CM_LZ77_name, true); zval const_CM_WAVPACK_value; ZVAL_LONG(&const_CM_WAVPACK_value, ZIP_CM_WAVPACK); - zend_string *const_CM_WAVPACK_name = zend_string_init_interned("CM_WAVPACK", sizeof("CM_WAVPACK") - 1, 1); + zend_string *const_CM_WAVPACK_name = zend_string_init_interned("CM_WAVPACK", sizeof("CM_WAVPACK") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_WAVPACK_name, &const_CM_WAVPACK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_WAVPACK_name); + zend_string_release_ex(const_CM_WAVPACK_name, true); zval const_CM_PPMD_value; ZVAL_LONG(&const_CM_PPMD_value, ZIP_CM_PPMD); - zend_string *const_CM_PPMD_name = zend_string_init_interned("CM_PPMD", sizeof("CM_PPMD") - 1, 1); + zend_string *const_CM_PPMD_name = zend_string_init_interned("CM_PPMD", sizeof("CM_PPMD") - 1, true); zend_declare_typed_class_constant(class_entry, const_CM_PPMD_name, &const_CM_PPMD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_CM_PPMD_name); + zend_string_release_ex(const_CM_PPMD_name, true); zval const_ER_OK_value; ZVAL_LONG(&const_ER_OK_value, ZIP_ER_OK); - zend_string *const_ER_OK_name = zend_string_init_interned("ER_OK", sizeof("ER_OK") - 1, 1); + zend_string *const_ER_OK_name = zend_string_init_interned("ER_OK", sizeof("ER_OK") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_OK_name, &const_ER_OK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_OK_name); + zend_string_release_ex(const_ER_OK_name, true); zval const_ER_MULTIDISK_value; ZVAL_LONG(&const_ER_MULTIDISK_value, ZIP_ER_MULTIDISK); - zend_string *const_ER_MULTIDISK_name = zend_string_init_interned("ER_MULTIDISK", sizeof("ER_MULTIDISK") - 1, 1); + zend_string *const_ER_MULTIDISK_name = zend_string_init_interned("ER_MULTIDISK", sizeof("ER_MULTIDISK") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_MULTIDISK_name, &const_ER_MULTIDISK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_MULTIDISK_name); + zend_string_release_ex(const_ER_MULTIDISK_name, true); zval const_ER_RENAME_value; ZVAL_LONG(&const_ER_RENAME_value, ZIP_ER_RENAME); - zend_string *const_ER_RENAME_name = zend_string_init_interned("ER_RENAME", sizeof("ER_RENAME") - 1, 1); + zend_string *const_ER_RENAME_name = zend_string_init_interned("ER_RENAME", sizeof("ER_RENAME") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_RENAME_name, &const_ER_RENAME_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_RENAME_name); + zend_string_release_ex(const_ER_RENAME_name, true); zval const_ER_CLOSE_value; ZVAL_LONG(&const_ER_CLOSE_value, ZIP_ER_CLOSE); - zend_string *const_ER_CLOSE_name = zend_string_init_interned("ER_CLOSE", sizeof("ER_CLOSE") - 1, 1); + zend_string *const_ER_CLOSE_name = zend_string_init_interned("ER_CLOSE", sizeof("ER_CLOSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_CLOSE_name, &const_ER_CLOSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_CLOSE_name); + zend_string_release_ex(const_ER_CLOSE_name, true); zval const_ER_SEEK_value; ZVAL_LONG(&const_ER_SEEK_value, ZIP_ER_SEEK); - zend_string *const_ER_SEEK_name = zend_string_init_interned("ER_SEEK", sizeof("ER_SEEK") - 1, 1); + zend_string *const_ER_SEEK_name = zend_string_init_interned("ER_SEEK", sizeof("ER_SEEK") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_SEEK_name, &const_ER_SEEK_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_SEEK_name); + zend_string_release_ex(const_ER_SEEK_name, true); zval const_ER_READ_value; ZVAL_LONG(&const_ER_READ_value, ZIP_ER_READ); - zend_string *const_ER_READ_name = zend_string_init_interned("ER_READ", sizeof("ER_READ") - 1, 1); + zend_string *const_ER_READ_name = zend_string_init_interned("ER_READ", sizeof("ER_READ") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_READ_name, &const_ER_READ_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_READ_name); + zend_string_release_ex(const_ER_READ_name, true); zval const_ER_WRITE_value; ZVAL_LONG(&const_ER_WRITE_value, ZIP_ER_WRITE); - zend_string *const_ER_WRITE_name = zend_string_init_interned("ER_WRITE", sizeof("ER_WRITE") - 1, 1); + zend_string *const_ER_WRITE_name = zend_string_init_interned("ER_WRITE", sizeof("ER_WRITE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_WRITE_name, &const_ER_WRITE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_WRITE_name); + zend_string_release_ex(const_ER_WRITE_name, true); zval const_ER_CRC_value; ZVAL_LONG(&const_ER_CRC_value, ZIP_ER_CRC); - zend_string *const_ER_CRC_name = zend_string_init_interned("ER_CRC", sizeof("ER_CRC") - 1, 1); + zend_string *const_ER_CRC_name = zend_string_init_interned("ER_CRC", sizeof("ER_CRC") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_CRC_name, &const_ER_CRC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_CRC_name); + zend_string_release_ex(const_ER_CRC_name, true); zval const_ER_ZIPCLOSED_value; ZVAL_LONG(&const_ER_ZIPCLOSED_value, ZIP_ER_ZIPCLOSED); - zend_string *const_ER_ZIPCLOSED_name = zend_string_init_interned("ER_ZIPCLOSED", sizeof("ER_ZIPCLOSED") - 1, 1); + zend_string *const_ER_ZIPCLOSED_name = zend_string_init_interned("ER_ZIPCLOSED", sizeof("ER_ZIPCLOSED") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_ZIPCLOSED_name, &const_ER_ZIPCLOSED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_ZIPCLOSED_name); + zend_string_release_ex(const_ER_ZIPCLOSED_name, true); zval const_ER_NOENT_value; ZVAL_LONG(&const_ER_NOENT_value, ZIP_ER_NOENT); - zend_string *const_ER_NOENT_name = zend_string_init_interned("ER_NOENT", sizeof("ER_NOENT") - 1, 1); + zend_string *const_ER_NOENT_name = zend_string_init_interned("ER_NOENT", sizeof("ER_NOENT") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_NOENT_name, &const_ER_NOENT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_NOENT_name); + zend_string_release_ex(const_ER_NOENT_name, true); zval const_ER_EXISTS_value; ZVAL_LONG(&const_ER_EXISTS_value, ZIP_ER_EXISTS); - zend_string *const_ER_EXISTS_name = zend_string_init_interned("ER_EXISTS", sizeof("ER_EXISTS") - 1, 1); + zend_string *const_ER_EXISTS_name = zend_string_init_interned("ER_EXISTS", sizeof("ER_EXISTS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_EXISTS_name, &const_ER_EXISTS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_EXISTS_name); + zend_string_release_ex(const_ER_EXISTS_name, true); zval const_ER_OPEN_value; ZVAL_LONG(&const_ER_OPEN_value, ZIP_ER_OPEN); - zend_string *const_ER_OPEN_name = zend_string_init_interned("ER_OPEN", sizeof("ER_OPEN") - 1, 1); + zend_string *const_ER_OPEN_name = zend_string_init_interned("ER_OPEN", sizeof("ER_OPEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_OPEN_name, &const_ER_OPEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_OPEN_name); + zend_string_release_ex(const_ER_OPEN_name, true); zval const_ER_TMPOPEN_value; ZVAL_LONG(&const_ER_TMPOPEN_value, ZIP_ER_TMPOPEN); - zend_string *const_ER_TMPOPEN_name = zend_string_init_interned("ER_TMPOPEN", sizeof("ER_TMPOPEN") - 1, 1); + zend_string *const_ER_TMPOPEN_name = zend_string_init_interned("ER_TMPOPEN", sizeof("ER_TMPOPEN") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_TMPOPEN_name, &const_ER_TMPOPEN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_TMPOPEN_name); + zend_string_release_ex(const_ER_TMPOPEN_name, true); zval const_ER_ZLIB_value; ZVAL_LONG(&const_ER_ZLIB_value, ZIP_ER_ZLIB); - zend_string *const_ER_ZLIB_name = zend_string_init_interned("ER_ZLIB", sizeof("ER_ZLIB") - 1, 1); + zend_string *const_ER_ZLIB_name = zend_string_init_interned("ER_ZLIB", sizeof("ER_ZLIB") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_ZLIB_name, &const_ER_ZLIB_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_ZLIB_name); + zend_string_release_ex(const_ER_ZLIB_name, true); zval const_ER_MEMORY_value; ZVAL_LONG(&const_ER_MEMORY_value, ZIP_ER_MEMORY); - zend_string *const_ER_MEMORY_name = zend_string_init_interned("ER_MEMORY", sizeof("ER_MEMORY") - 1, 1); + zend_string *const_ER_MEMORY_name = zend_string_init_interned("ER_MEMORY", sizeof("ER_MEMORY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_MEMORY_name, &const_ER_MEMORY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_MEMORY_name); + zend_string_release_ex(const_ER_MEMORY_name, true); zval const_ER_CHANGED_value; ZVAL_LONG(&const_ER_CHANGED_value, ZIP_ER_CHANGED); - zend_string *const_ER_CHANGED_name = zend_string_init_interned("ER_CHANGED", sizeof("ER_CHANGED") - 1, 1); + zend_string *const_ER_CHANGED_name = zend_string_init_interned("ER_CHANGED", sizeof("ER_CHANGED") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_CHANGED_name, &const_ER_CHANGED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_CHANGED_name); + zend_string_release_ex(const_ER_CHANGED_name, true); zval const_ER_COMPNOTSUPP_value; ZVAL_LONG(&const_ER_COMPNOTSUPP_value, ZIP_ER_COMPNOTSUPP); - zend_string *const_ER_COMPNOTSUPP_name = zend_string_init_interned("ER_COMPNOTSUPP", sizeof("ER_COMPNOTSUPP") - 1, 1); + zend_string *const_ER_COMPNOTSUPP_name = zend_string_init_interned("ER_COMPNOTSUPP", sizeof("ER_COMPNOTSUPP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_COMPNOTSUPP_name, &const_ER_COMPNOTSUPP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_COMPNOTSUPP_name); + zend_string_release_ex(const_ER_COMPNOTSUPP_name, true); zval const_ER_EOF_value; ZVAL_LONG(&const_ER_EOF_value, ZIP_ER_EOF); - zend_string *const_ER_EOF_name = zend_string_init_interned("ER_EOF", sizeof("ER_EOF") - 1, 1); + zend_string *const_ER_EOF_name = zend_string_init_interned("ER_EOF", sizeof("ER_EOF") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_EOF_name, &const_ER_EOF_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_EOF_name); + zend_string_release_ex(const_ER_EOF_name, true); zval const_ER_INVAL_value; ZVAL_LONG(&const_ER_INVAL_value, ZIP_ER_INVAL); - zend_string *const_ER_INVAL_name = zend_string_init_interned("ER_INVAL", sizeof("ER_INVAL") - 1, 1); + zend_string *const_ER_INVAL_name = zend_string_init_interned("ER_INVAL", sizeof("ER_INVAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_INVAL_name, &const_ER_INVAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_INVAL_name); + zend_string_release_ex(const_ER_INVAL_name, true); zval const_ER_NOZIP_value; ZVAL_LONG(&const_ER_NOZIP_value, ZIP_ER_NOZIP); - zend_string *const_ER_NOZIP_name = zend_string_init_interned("ER_NOZIP", sizeof("ER_NOZIP") - 1, 1); + zend_string *const_ER_NOZIP_name = zend_string_init_interned("ER_NOZIP", sizeof("ER_NOZIP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_NOZIP_name, &const_ER_NOZIP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_NOZIP_name); + zend_string_release_ex(const_ER_NOZIP_name, true); zval const_ER_INTERNAL_value; ZVAL_LONG(&const_ER_INTERNAL_value, ZIP_ER_INTERNAL); - zend_string *const_ER_INTERNAL_name = zend_string_init_interned("ER_INTERNAL", sizeof("ER_INTERNAL") - 1, 1); + zend_string *const_ER_INTERNAL_name = zend_string_init_interned("ER_INTERNAL", sizeof("ER_INTERNAL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_INTERNAL_name, &const_ER_INTERNAL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_INTERNAL_name); + zend_string_release_ex(const_ER_INTERNAL_name, true); zval const_ER_INCONS_value; ZVAL_LONG(&const_ER_INCONS_value, ZIP_ER_INCONS); - zend_string *const_ER_INCONS_name = zend_string_init_interned("ER_INCONS", sizeof("ER_INCONS") - 1, 1); + zend_string *const_ER_INCONS_name = zend_string_init_interned("ER_INCONS", sizeof("ER_INCONS") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_INCONS_name, &const_ER_INCONS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_INCONS_name); + zend_string_release_ex(const_ER_INCONS_name, true); zval const_ER_REMOVE_value; ZVAL_LONG(&const_ER_REMOVE_value, ZIP_ER_REMOVE); - zend_string *const_ER_REMOVE_name = zend_string_init_interned("ER_REMOVE", sizeof("ER_REMOVE") - 1, 1); + zend_string *const_ER_REMOVE_name = zend_string_init_interned("ER_REMOVE", sizeof("ER_REMOVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_REMOVE_name, &const_ER_REMOVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_REMOVE_name); + zend_string_release_ex(const_ER_REMOVE_name, true); zval const_ER_DELETED_value; ZVAL_LONG(&const_ER_DELETED_value, ZIP_ER_DELETED); - zend_string *const_ER_DELETED_name = zend_string_init_interned("ER_DELETED", sizeof("ER_DELETED") - 1, 1); + zend_string *const_ER_DELETED_name = zend_string_init_interned("ER_DELETED", sizeof("ER_DELETED") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_DELETED_name, &const_ER_DELETED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_DELETED_name); + zend_string_release_ex(const_ER_DELETED_name, true); zval const_ER_ENCRNOTSUPP_value; ZVAL_LONG(&const_ER_ENCRNOTSUPP_value, ZIP_ER_ENCRNOTSUPP); - zend_string *const_ER_ENCRNOTSUPP_name = zend_string_init_interned("ER_ENCRNOTSUPP", sizeof("ER_ENCRNOTSUPP") - 1, 1); + zend_string *const_ER_ENCRNOTSUPP_name = zend_string_init_interned("ER_ENCRNOTSUPP", sizeof("ER_ENCRNOTSUPP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_ENCRNOTSUPP_name, &const_ER_ENCRNOTSUPP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_ENCRNOTSUPP_name); + zend_string_release_ex(const_ER_ENCRNOTSUPP_name, true); zval const_ER_RDONLY_value; ZVAL_LONG(&const_ER_RDONLY_value, ZIP_ER_RDONLY); - zend_string *const_ER_RDONLY_name = zend_string_init_interned("ER_RDONLY", sizeof("ER_RDONLY") - 1, 1); + zend_string *const_ER_RDONLY_name = zend_string_init_interned("ER_RDONLY", sizeof("ER_RDONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_RDONLY_name, &const_ER_RDONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_RDONLY_name); + zend_string_release_ex(const_ER_RDONLY_name, true); zval const_ER_NOPASSWD_value; ZVAL_LONG(&const_ER_NOPASSWD_value, ZIP_ER_NOPASSWD); - zend_string *const_ER_NOPASSWD_name = zend_string_init_interned("ER_NOPASSWD", sizeof("ER_NOPASSWD") - 1, 1); + zend_string *const_ER_NOPASSWD_name = zend_string_init_interned("ER_NOPASSWD", sizeof("ER_NOPASSWD") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_NOPASSWD_name, &const_ER_NOPASSWD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_NOPASSWD_name); + zend_string_release_ex(const_ER_NOPASSWD_name, true); zval const_ER_WRONGPASSWD_value; ZVAL_LONG(&const_ER_WRONGPASSWD_value, ZIP_ER_WRONGPASSWD); - zend_string *const_ER_WRONGPASSWD_name = zend_string_init_interned("ER_WRONGPASSWD", sizeof("ER_WRONGPASSWD") - 1, 1); + zend_string *const_ER_WRONGPASSWD_name = zend_string_init_interned("ER_WRONGPASSWD", sizeof("ER_WRONGPASSWD") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_WRONGPASSWD_name, &const_ER_WRONGPASSWD_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_WRONGPASSWD_name); + zend_string_release_ex(const_ER_WRONGPASSWD_name, true); #if defined(ZIP_ER_OPNOTSUPP) zval const_ER_OPNOTSUPP_value; ZVAL_LONG(&const_ER_OPNOTSUPP_value, ZIP_ER_OPNOTSUPP); - zend_string *const_ER_OPNOTSUPP_name = zend_string_init_interned("ER_OPNOTSUPP", sizeof("ER_OPNOTSUPP") - 1, 1); + zend_string *const_ER_OPNOTSUPP_name = zend_string_init_interned("ER_OPNOTSUPP", sizeof("ER_OPNOTSUPP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_OPNOTSUPP_name, &const_ER_OPNOTSUPP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_OPNOTSUPP_name); + zend_string_release_ex(const_ER_OPNOTSUPP_name, true); #endif #if defined(ZIP_ER_INUSE) zval const_ER_INUSE_value; ZVAL_LONG(&const_ER_INUSE_value, ZIP_ER_INUSE); - zend_string *const_ER_INUSE_name = zend_string_init_interned("ER_INUSE", sizeof("ER_INUSE") - 1, 1); + zend_string *const_ER_INUSE_name = zend_string_init_interned("ER_INUSE", sizeof("ER_INUSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_INUSE_name, &const_ER_INUSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_INUSE_name); + zend_string_release_ex(const_ER_INUSE_name, true); #endif #if defined(ZIP_ER_TELL) zval const_ER_TELL_value; ZVAL_LONG(&const_ER_TELL_value, ZIP_ER_TELL); - zend_string *const_ER_TELL_name = zend_string_init_interned("ER_TELL", sizeof("ER_TELL") - 1, 1); + zend_string *const_ER_TELL_name = zend_string_init_interned("ER_TELL", sizeof("ER_TELL") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_TELL_name, &const_ER_TELL_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_TELL_name); + zend_string_release_ex(const_ER_TELL_name, true); #endif #if defined(ZIP_ER_COMPRESSED_DATA) zval const_ER_COMPRESSED_DATA_value; ZVAL_LONG(&const_ER_COMPRESSED_DATA_value, ZIP_ER_COMPRESSED_DATA); - zend_string *const_ER_COMPRESSED_DATA_name = zend_string_init_interned("ER_COMPRESSED_DATA", sizeof("ER_COMPRESSED_DATA") - 1, 1); + zend_string *const_ER_COMPRESSED_DATA_name = zend_string_init_interned("ER_COMPRESSED_DATA", sizeof("ER_COMPRESSED_DATA") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_COMPRESSED_DATA_name, &const_ER_COMPRESSED_DATA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_COMPRESSED_DATA_name); + zend_string_release_ex(const_ER_COMPRESSED_DATA_name, true); #endif #if defined(ZIP_ER_CANCELLED) zval const_ER_CANCELLED_value; ZVAL_LONG(&const_ER_CANCELLED_value, ZIP_ER_CANCELLED); - zend_string *const_ER_CANCELLED_name = zend_string_init_interned("ER_CANCELLED", sizeof("ER_CANCELLED") - 1, 1); + zend_string *const_ER_CANCELLED_name = zend_string_init_interned("ER_CANCELLED", sizeof("ER_CANCELLED") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_CANCELLED_name, &const_ER_CANCELLED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_CANCELLED_name); + zend_string_release_ex(const_ER_CANCELLED_name, true); #endif #if defined(ZIP_ER_DATA_LENGTH) zval const_ER_DATA_LENGTH_value; ZVAL_LONG(&const_ER_DATA_LENGTH_value, ZIP_ER_DATA_LENGTH); - zend_string *const_ER_DATA_LENGTH_name = zend_string_init_interned("ER_DATA_LENGTH", sizeof("ER_DATA_LENGTH") - 1, 1); + zend_string *const_ER_DATA_LENGTH_name = zend_string_init_interned("ER_DATA_LENGTH", sizeof("ER_DATA_LENGTH") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_DATA_LENGTH_name, &const_ER_DATA_LENGTH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_DATA_LENGTH_name); + zend_string_release_ex(const_ER_DATA_LENGTH_name, true); #endif #if defined(ZIP_ER_NOT_ALLOWED) zval const_ER_NOT_ALLOWED_value; ZVAL_LONG(&const_ER_NOT_ALLOWED_value, ZIP_ER_NOT_ALLOWED); - zend_string *const_ER_NOT_ALLOWED_name = zend_string_init_interned("ER_NOT_ALLOWED", sizeof("ER_NOT_ALLOWED") - 1, 1); + zend_string *const_ER_NOT_ALLOWED_name = zend_string_init_interned("ER_NOT_ALLOWED", sizeof("ER_NOT_ALLOWED") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_NOT_ALLOWED_name, &const_ER_NOT_ALLOWED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_NOT_ALLOWED_name); + zend_string_release_ex(const_ER_NOT_ALLOWED_name, true); #endif #if defined(ZIP_ER_TRUNCATED_ZIP) zval const_ER_TRUNCATED_ZIP_value; ZVAL_LONG(&const_ER_TRUNCATED_ZIP_value, ZIP_ER_TRUNCATED_ZIP); - zend_string *const_ER_TRUNCATED_ZIP_name = zend_string_init_interned("ER_TRUNCATED_ZIP", sizeof("ER_TRUNCATED_ZIP") - 1, 1); + zend_string *const_ER_TRUNCATED_ZIP_name = zend_string_init_interned("ER_TRUNCATED_ZIP", sizeof("ER_TRUNCATED_ZIP") - 1, true); zend_declare_typed_class_constant(class_entry, const_ER_TRUNCATED_ZIP_name, &const_ER_TRUNCATED_ZIP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_ER_TRUNCATED_ZIP_name); + zend_string_release_ex(const_ER_TRUNCATED_ZIP_name, true); #endif #if defined(ZIP_AFL_RDONLY) zval const_AFL_RDONLY_value; ZVAL_LONG(&const_AFL_RDONLY_value, ZIP_AFL_RDONLY); - zend_string *const_AFL_RDONLY_name = zend_string_init_interned("AFL_RDONLY", sizeof("AFL_RDONLY") - 1, 1); + zend_string *const_AFL_RDONLY_name = zend_string_init_interned("AFL_RDONLY", sizeof("AFL_RDONLY") - 1, true); zend_declare_typed_class_constant(class_entry, const_AFL_RDONLY_name, &const_AFL_RDONLY_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_AFL_RDONLY_name); + zend_string_release_ex(const_AFL_RDONLY_name, true); #endif #if defined(ZIP_AFL_IS_TORRENTZIP) zval const_AFL_IS_TORRENTZIP_value; ZVAL_LONG(&const_AFL_IS_TORRENTZIP_value, ZIP_AFL_IS_TORRENTZIP); - zend_string *const_AFL_IS_TORRENTZIP_name = zend_string_init_interned("AFL_IS_TORRENTZIP", sizeof("AFL_IS_TORRENTZIP") - 1, 1); + zend_string *const_AFL_IS_TORRENTZIP_name = zend_string_init_interned("AFL_IS_TORRENTZIP", sizeof("AFL_IS_TORRENTZIP") - 1, true); zend_declare_typed_class_constant(class_entry, const_AFL_IS_TORRENTZIP_name, &const_AFL_IS_TORRENTZIP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_AFL_IS_TORRENTZIP_name); + zend_string_release_ex(const_AFL_IS_TORRENTZIP_name, true); #endif #if defined(ZIP_AFL_WANT_TORRENTZIP) zval const_AFL_WANT_TORRENTZIP_value; ZVAL_LONG(&const_AFL_WANT_TORRENTZIP_value, ZIP_AFL_WANT_TORRENTZIP); - zend_string *const_AFL_WANT_TORRENTZIP_name = zend_string_init_interned("AFL_WANT_TORRENTZIP", sizeof("AFL_WANT_TORRENTZIP") - 1, 1); + zend_string *const_AFL_WANT_TORRENTZIP_name = zend_string_init_interned("AFL_WANT_TORRENTZIP", sizeof("AFL_WANT_TORRENTZIP") - 1, true); zend_declare_typed_class_constant(class_entry, const_AFL_WANT_TORRENTZIP_name, &const_AFL_WANT_TORRENTZIP_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_AFL_WANT_TORRENTZIP_name); + zend_string_release_ex(const_AFL_WANT_TORRENTZIP_name, true); #endif #if defined(ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE) zval const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_value; ZVAL_LONG(&const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_value, ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE); - zend_string *const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_name = zend_string_init_interned("AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE", sizeof("AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE") - 1, 1); + zend_string *const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_name = zend_string_init_interned("AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE", sizeof("AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE") - 1, true); zend_declare_typed_class_constant(class_entry, const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_name, &const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_name); + zend_string_release_ex(const_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE_name, true); #endif #if defined(ZIP_OPSYS_DEFAULT) zval const_OPSYS_DOS_value; ZVAL_LONG(&const_OPSYS_DOS_value, ZIP_OPSYS_DOS); - zend_string *const_OPSYS_DOS_name = zend_string_init_interned("OPSYS_DOS", sizeof("OPSYS_DOS") - 1, 1); + zend_string *const_OPSYS_DOS_name = zend_string_init_interned("OPSYS_DOS", sizeof("OPSYS_DOS") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_DOS_name, &const_OPSYS_DOS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_DOS_name); + zend_string_release_ex(const_OPSYS_DOS_name, true); zval const_OPSYS_AMIGA_value; ZVAL_LONG(&const_OPSYS_AMIGA_value, ZIP_OPSYS_AMIGA); - zend_string *const_OPSYS_AMIGA_name = zend_string_init_interned("OPSYS_AMIGA", sizeof("OPSYS_AMIGA") - 1, 1); + zend_string *const_OPSYS_AMIGA_name = zend_string_init_interned("OPSYS_AMIGA", sizeof("OPSYS_AMIGA") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_AMIGA_name, &const_OPSYS_AMIGA_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_AMIGA_name); + zend_string_release_ex(const_OPSYS_AMIGA_name, true); zval const_OPSYS_OPENVMS_value; ZVAL_LONG(&const_OPSYS_OPENVMS_value, ZIP_OPSYS_OPENVMS); - zend_string *const_OPSYS_OPENVMS_name = zend_string_init_interned("OPSYS_OPENVMS", sizeof("OPSYS_OPENVMS") - 1, 1); + zend_string *const_OPSYS_OPENVMS_name = zend_string_init_interned("OPSYS_OPENVMS", sizeof("OPSYS_OPENVMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_OPENVMS_name, &const_OPSYS_OPENVMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_OPENVMS_name); + zend_string_release_ex(const_OPSYS_OPENVMS_name, true); zval const_OPSYS_UNIX_value; ZVAL_LONG(&const_OPSYS_UNIX_value, ZIP_OPSYS_UNIX); - zend_string *const_OPSYS_UNIX_name = zend_string_init_interned("OPSYS_UNIX", sizeof("OPSYS_UNIX") - 1, 1); + zend_string *const_OPSYS_UNIX_name = zend_string_init_interned("OPSYS_UNIX", sizeof("OPSYS_UNIX") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_UNIX_name, &const_OPSYS_UNIX_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_UNIX_name); + zend_string_release_ex(const_OPSYS_UNIX_name, true); zval const_OPSYS_VM_CMS_value; ZVAL_LONG(&const_OPSYS_VM_CMS_value, ZIP_OPSYS_VM_CMS); - zend_string *const_OPSYS_VM_CMS_name = zend_string_init_interned("OPSYS_VM_CMS", sizeof("OPSYS_VM_CMS") - 1, 1); + zend_string *const_OPSYS_VM_CMS_name = zend_string_init_interned("OPSYS_VM_CMS", sizeof("OPSYS_VM_CMS") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_VM_CMS_name, &const_OPSYS_VM_CMS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_VM_CMS_name); + zend_string_release_ex(const_OPSYS_VM_CMS_name, true); zval const_OPSYS_ATARI_ST_value; ZVAL_LONG(&const_OPSYS_ATARI_ST_value, ZIP_OPSYS_ATARI_ST); - zend_string *const_OPSYS_ATARI_ST_name = zend_string_init_interned("OPSYS_ATARI_ST", sizeof("OPSYS_ATARI_ST") - 1, 1); + zend_string *const_OPSYS_ATARI_ST_name = zend_string_init_interned("OPSYS_ATARI_ST", sizeof("OPSYS_ATARI_ST") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_ATARI_ST_name, &const_OPSYS_ATARI_ST_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_ATARI_ST_name); + zend_string_release_ex(const_OPSYS_ATARI_ST_name, true); zval const_OPSYS_OS_2_value; ZVAL_LONG(&const_OPSYS_OS_2_value, ZIP_OPSYS_OS_2); - zend_string *const_OPSYS_OS_2_name = zend_string_init_interned("OPSYS_OS_2", sizeof("OPSYS_OS_2") - 1, 1); + zend_string *const_OPSYS_OS_2_name = zend_string_init_interned("OPSYS_OS_2", sizeof("OPSYS_OS_2") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_OS_2_name, &const_OPSYS_OS_2_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_OS_2_name); + zend_string_release_ex(const_OPSYS_OS_2_name, true); zval const_OPSYS_MACINTOSH_value; ZVAL_LONG(&const_OPSYS_MACINTOSH_value, ZIP_OPSYS_MACINTOSH); - zend_string *const_OPSYS_MACINTOSH_name = zend_string_init_interned("OPSYS_MACINTOSH", sizeof("OPSYS_MACINTOSH") - 1, 1); + zend_string *const_OPSYS_MACINTOSH_name = zend_string_init_interned("OPSYS_MACINTOSH", sizeof("OPSYS_MACINTOSH") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_MACINTOSH_name, &const_OPSYS_MACINTOSH_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_MACINTOSH_name); + zend_string_release_ex(const_OPSYS_MACINTOSH_name, true); zval const_OPSYS_Z_SYSTEM_value; ZVAL_LONG(&const_OPSYS_Z_SYSTEM_value, ZIP_OPSYS_Z_SYSTEM); - zend_string *const_OPSYS_Z_SYSTEM_name = zend_string_init_interned("OPSYS_Z_SYSTEM", sizeof("OPSYS_Z_SYSTEM") - 1, 1); + zend_string *const_OPSYS_Z_SYSTEM_name = zend_string_init_interned("OPSYS_Z_SYSTEM", sizeof("OPSYS_Z_SYSTEM") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_Z_SYSTEM_name, &const_OPSYS_Z_SYSTEM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_Z_SYSTEM_name); + zend_string_release_ex(const_OPSYS_Z_SYSTEM_name, true); zval const_OPSYS_CPM_value; ZVAL_LONG(&const_OPSYS_CPM_value, ZIP_OPSYS_CPM); - zend_string *const_OPSYS_CPM_name = zend_string_init_interned("OPSYS_CPM", sizeof("OPSYS_CPM") - 1, 1); + zend_string *const_OPSYS_CPM_name = zend_string_init_interned("OPSYS_CPM", sizeof("OPSYS_CPM") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_CPM_name, &const_OPSYS_CPM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_CPM_name); + zend_string_release_ex(const_OPSYS_CPM_name, true); zval const_OPSYS_WINDOWS_NTFS_value; ZVAL_LONG(&const_OPSYS_WINDOWS_NTFS_value, ZIP_OPSYS_WINDOWS_NTFS); - zend_string *const_OPSYS_WINDOWS_NTFS_name = zend_string_init_interned("OPSYS_WINDOWS_NTFS", sizeof("OPSYS_WINDOWS_NTFS") - 1, 1); + zend_string *const_OPSYS_WINDOWS_NTFS_name = zend_string_init_interned("OPSYS_WINDOWS_NTFS", sizeof("OPSYS_WINDOWS_NTFS") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_WINDOWS_NTFS_name, &const_OPSYS_WINDOWS_NTFS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_WINDOWS_NTFS_name); + zend_string_release_ex(const_OPSYS_WINDOWS_NTFS_name, true); zval const_OPSYS_MVS_value; ZVAL_LONG(&const_OPSYS_MVS_value, ZIP_OPSYS_MVS); - zend_string *const_OPSYS_MVS_name = zend_string_init_interned("OPSYS_MVS", sizeof("OPSYS_MVS") - 1, 1); + zend_string *const_OPSYS_MVS_name = zend_string_init_interned("OPSYS_MVS", sizeof("OPSYS_MVS") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_MVS_name, &const_OPSYS_MVS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_MVS_name); + zend_string_release_ex(const_OPSYS_MVS_name, true); zval const_OPSYS_VSE_value; ZVAL_LONG(&const_OPSYS_VSE_value, ZIP_OPSYS_VSE); - zend_string *const_OPSYS_VSE_name = zend_string_init_interned("OPSYS_VSE", sizeof("OPSYS_VSE") - 1, 1); + zend_string *const_OPSYS_VSE_name = zend_string_init_interned("OPSYS_VSE", sizeof("OPSYS_VSE") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_VSE_name, &const_OPSYS_VSE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_VSE_name); + zend_string_release_ex(const_OPSYS_VSE_name, true); zval const_OPSYS_ACORN_RISC_value; ZVAL_LONG(&const_OPSYS_ACORN_RISC_value, ZIP_OPSYS_ACORN_RISC); - zend_string *const_OPSYS_ACORN_RISC_name = zend_string_init_interned("OPSYS_ACORN_RISC", sizeof("OPSYS_ACORN_RISC") - 1, 1); + zend_string *const_OPSYS_ACORN_RISC_name = zend_string_init_interned("OPSYS_ACORN_RISC", sizeof("OPSYS_ACORN_RISC") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_ACORN_RISC_name, &const_OPSYS_ACORN_RISC_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_ACORN_RISC_name); + zend_string_release_ex(const_OPSYS_ACORN_RISC_name, true); zval const_OPSYS_VFAT_value; ZVAL_LONG(&const_OPSYS_VFAT_value, ZIP_OPSYS_VFAT); - zend_string *const_OPSYS_VFAT_name = zend_string_init_interned("OPSYS_VFAT", sizeof("OPSYS_VFAT") - 1, 1); + zend_string *const_OPSYS_VFAT_name = zend_string_init_interned("OPSYS_VFAT", sizeof("OPSYS_VFAT") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_VFAT_name, &const_OPSYS_VFAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_VFAT_name); + zend_string_release_ex(const_OPSYS_VFAT_name, true); zval const_OPSYS_ALTERNATE_MVS_value; ZVAL_LONG(&const_OPSYS_ALTERNATE_MVS_value, ZIP_OPSYS_ALTERNATE_MVS); - zend_string *const_OPSYS_ALTERNATE_MVS_name = zend_string_init_interned("OPSYS_ALTERNATE_MVS", sizeof("OPSYS_ALTERNATE_MVS") - 1, 1); + zend_string *const_OPSYS_ALTERNATE_MVS_name = zend_string_init_interned("OPSYS_ALTERNATE_MVS", sizeof("OPSYS_ALTERNATE_MVS") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_ALTERNATE_MVS_name, &const_OPSYS_ALTERNATE_MVS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_ALTERNATE_MVS_name); + zend_string_release_ex(const_OPSYS_ALTERNATE_MVS_name, true); zval const_OPSYS_BEOS_value; ZVAL_LONG(&const_OPSYS_BEOS_value, ZIP_OPSYS_BEOS); - zend_string *const_OPSYS_BEOS_name = zend_string_init_interned("OPSYS_BEOS", sizeof("OPSYS_BEOS") - 1, 1); + zend_string *const_OPSYS_BEOS_name = zend_string_init_interned("OPSYS_BEOS", sizeof("OPSYS_BEOS") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_BEOS_name, &const_OPSYS_BEOS_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_BEOS_name); + zend_string_release_ex(const_OPSYS_BEOS_name, true); zval const_OPSYS_TANDEM_value; ZVAL_LONG(&const_OPSYS_TANDEM_value, ZIP_OPSYS_TANDEM); - zend_string *const_OPSYS_TANDEM_name = zend_string_init_interned("OPSYS_TANDEM", sizeof("OPSYS_TANDEM") - 1, 1); + zend_string *const_OPSYS_TANDEM_name = zend_string_init_interned("OPSYS_TANDEM", sizeof("OPSYS_TANDEM") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_TANDEM_name, &const_OPSYS_TANDEM_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_TANDEM_name); + zend_string_release_ex(const_OPSYS_TANDEM_name, true); zval const_OPSYS_OS_400_value; ZVAL_LONG(&const_OPSYS_OS_400_value, ZIP_OPSYS_OS_400); - zend_string *const_OPSYS_OS_400_name = zend_string_init_interned("OPSYS_OS_400", sizeof("OPSYS_OS_400") - 1, 1); + zend_string *const_OPSYS_OS_400_name = zend_string_init_interned("OPSYS_OS_400", sizeof("OPSYS_OS_400") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_OS_400_name, &const_OPSYS_OS_400_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_OS_400_name); + zend_string_release_ex(const_OPSYS_OS_400_name, true); zval const_OPSYS_OS_X_value; ZVAL_LONG(&const_OPSYS_OS_X_value, ZIP_OPSYS_OS_X); - zend_string *const_OPSYS_OS_X_name = zend_string_init_interned("OPSYS_OS_X", sizeof("OPSYS_OS_X") - 1, 1); + zend_string *const_OPSYS_OS_X_name = zend_string_init_interned("OPSYS_OS_X", sizeof("OPSYS_OS_X") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_OS_X_name, &const_OPSYS_OS_X_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_OS_X_name); + zend_string_release_ex(const_OPSYS_OS_X_name, true); zval const_OPSYS_DEFAULT_value; ZVAL_LONG(&const_OPSYS_DEFAULT_value, ZIP_OPSYS_DEFAULT); - zend_string *const_OPSYS_DEFAULT_name = zend_string_init_interned("OPSYS_DEFAULT", sizeof("OPSYS_DEFAULT") - 1, 1); + zend_string *const_OPSYS_DEFAULT_name = zend_string_init_interned("OPSYS_DEFAULT", sizeof("OPSYS_DEFAULT") - 1, true); zend_declare_typed_class_constant(class_entry, const_OPSYS_DEFAULT_name, &const_OPSYS_DEFAULT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_OPSYS_DEFAULT_name); + zend_string_release_ex(const_OPSYS_DEFAULT_name, true); #endif zval const_EM_NONE_value; ZVAL_LONG(&const_EM_NONE_value, ZIP_EM_NONE); - zend_string *const_EM_NONE_name = zend_string_init_interned("EM_NONE", sizeof("EM_NONE") - 1, 1); + zend_string *const_EM_NONE_name = zend_string_init_interned("EM_NONE", sizeof("EM_NONE") - 1, true); zend_declare_typed_class_constant(class_entry, const_EM_NONE_name, &const_EM_NONE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EM_NONE_name); + zend_string_release_ex(const_EM_NONE_name, true); zval const_EM_TRAD_PKWARE_value; ZVAL_LONG(&const_EM_TRAD_PKWARE_value, ZIP_EM_TRAD_PKWARE); - zend_string *const_EM_TRAD_PKWARE_name = zend_string_init_interned("EM_TRAD_PKWARE", sizeof("EM_TRAD_PKWARE") - 1, 1); + zend_string *const_EM_TRAD_PKWARE_name = zend_string_init_interned("EM_TRAD_PKWARE", sizeof("EM_TRAD_PKWARE") - 1, true); zend_declare_typed_class_constant(class_entry, const_EM_TRAD_PKWARE_name, &const_EM_TRAD_PKWARE_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EM_TRAD_PKWARE_name); + zend_string_release_ex(const_EM_TRAD_PKWARE_name, true); #if defined(HAVE_ENCRYPTION) zval const_EM_AES_128_value; ZVAL_LONG(&const_EM_AES_128_value, ZIP_EM_AES_128); - zend_string *const_EM_AES_128_name = zend_string_init_interned("EM_AES_128", sizeof("EM_AES_128") - 1, 1); + zend_string *const_EM_AES_128_name = zend_string_init_interned("EM_AES_128", sizeof("EM_AES_128") - 1, true); zend_declare_typed_class_constant(class_entry, const_EM_AES_128_name, &const_EM_AES_128_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EM_AES_128_name); + zend_string_release_ex(const_EM_AES_128_name, true); zval const_EM_AES_192_value; ZVAL_LONG(&const_EM_AES_192_value, ZIP_EM_AES_192); - zend_string *const_EM_AES_192_name = zend_string_init_interned("EM_AES_192", sizeof("EM_AES_192") - 1, 1); + zend_string *const_EM_AES_192_name = zend_string_init_interned("EM_AES_192", sizeof("EM_AES_192") - 1, true); zend_declare_typed_class_constant(class_entry, const_EM_AES_192_name, &const_EM_AES_192_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EM_AES_192_name); + zend_string_release_ex(const_EM_AES_192_name, true); zval const_EM_AES_256_value; ZVAL_LONG(&const_EM_AES_256_value, ZIP_EM_AES_256); - zend_string *const_EM_AES_256_name = zend_string_init_interned("EM_AES_256", sizeof("EM_AES_256") - 1, 1); + zend_string *const_EM_AES_256_name = zend_string_init_interned("EM_AES_256", sizeof("EM_AES_256") - 1, true); zend_declare_typed_class_constant(class_entry, const_EM_AES_256_name, &const_EM_AES_256_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EM_AES_256_name); + zend_string_release_ex(const_EM_AES_256_name, true); #endif zval const_EM_UNKNOWN_value; ZVAL_LONG(&const_EM_UNKNOWN_value, ZIP_EM_UNKNOWN); - zend_string *const_EM_UNKNOWN_name = zend_string_init_interned("EM_UNKNOWN", sizeof("EM_UNKNOWN") - 1, 1); + zend_string *const_EM_UNKNOWN_name = zend_string_init_interned("EM_UNKNOWN", sizeof("EM_UNKNOWN") - 1, true); zend_declare_typed_class_constant(class_entry, const_EM_UNKNOWN_name, &const_EM_UNKNOWN_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_EM_UNKNOWN_name); + zend_string_release_ex(const_EM_UNKNOWN_name, true); zval const_LIBZIP_VERSION_value; zend_string *const_LIBZIP_VERSION_value_str = zend_string_init(LIBZIP_VERSION_STR, strlen(LIBZIP_VERSION_STR), 1); ZVAL_STR(&const_LIBZIP_VERSION_value, const_LIBZIP_VERSION_value_str); - zend_string *const_LIBZIP_VERSION_name = zend_string_init_interned("LIBZIP_VERSION", sizeof("LIBZIP_VERSION") - 1, 1); + zend_string *const_LIBZIP_VERSION_name = zend_string_init_interned("LIBZIP_VERSION", sizeof("LIBZIP_VERSION") - 1, true); zend_declare_typed_class_constant(class_entry, const_LIBZIP_VERSION_name, &const_LIBZIP_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(const_LIBZIP_VERSION_name); + zend_string_release_ex(const_LIBZIP_VERSION_name, true); zval const_LENGTH_TO_END_value; ZVAL_LONG(&const_LENGTH_TO_END_value, ZIP_LENGTH_TO_END); - zend_string *const_LENGTH_TO_END_name = zend_string_init_interned("LENGTH_TO_END", sizeof("LENGTH_TO_END") - 1, 1); + zend_string *const_LENGTH_TO_END_name = zend_string_init_interned("LENGTH_TO_END", sizeof("LENGTH_TO_END") - 1, true); zend_declare_typed_class_constant(class_entry, const_LENGTH_TO_END_name, &const_LENGTH_TO_END_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LENGTH_TO_END_name); + zend_string_release_ex(const_LENGTH_TO_END_name, true); #if defined(ZIP_LENGTH_UNCHECKED) zval const_LENGTH_UNCHECKED_value; ZVAL_LONG(&const_LENGTH_UNCHECKED_value, ZIP_LENGTH_UNCHECKED); - zend_string *const_LENGTH_UNCHECKED_name = zend_string_init_interned("LENGTH_UNCHECKED", sizeof("LENGTH_UNCHECKED") - 1, 1); + zend_string *const_LENGTH_UNCHECKED_name = zend_string_init_interned("LENGTH_UNCHECKED", sizeof("LENGTH_UNCHECKED") - 1, true); zend_declare_typed_class_constant(class_entry, const_LENGTH_UNCHECKED_name, &const_LENGTH_UNCHECKED_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(const_LENGTH_UNCHECKED_name); + zend_string_release_ex(const_LENGTH_UNCHECKED_name, true); #endif zval property_lastId_default_value; ZVAL_UNDEF(&property_lastId_default_value); - zend_string *property_lastId_name = zend_string_init("lastId", sizeof("lastId") - 1, 1); + zend_string *property_lastId_name = zend_string_init("lastId", sizeof("lastId") - 1, true); zend_declare_typed_property(class_entry, property_lastId_name, &property_lastId_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_lastId_name); + zend_string_release_ex(property_lastId_name, true); zval property_status_default_value; ZVAL_UNDEF(&property_status_default_value); - zend_string *property_status_name = zend_string_init("status", sizeof("status") - 1, 1); + zend_string *property_status_name = zend_string_init("status", sizeof("status") - 1, true); zend_declare_typed_property(class_entry, property_status_name, &property_status_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_status_name); + zend_string_release_ex(property_status_name, true); zval property_statusSys_default_value; ZVAL_UNDEF(&property_statusSys_default_value); - zend_string *property_statusSys_name = zend_string_init("statusSys", sizeof("statusSys") - 1, 1); + zend_string *property_statusSys_name = zend_string_init("statusSys", sizeof("statusSys") - 1, true); zend_declare_typed_property(class_entry, property_statusSys_name, &property_statusSys_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_statusSys_name); + zend_string_release_ex(property_statusSys_name, true); zval property_numFiles_default_value; ZVAL_UNDEF(&property_numFiles_default_value); - zend_string *property_numFiles_name = zend_string_init("numFiles", sizeof("numFiles") - 1, 1); + zend_string *property_numFiles_name = zend_string_init("numFiles", sizeof("numFiles") - 1, true); zend_declare_typed_property(class_entry, property_numFiles_name, &property_numFiles_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); - zend_string_release(property_numFiles_name); + zend_string_release_ex(property_numFiles_name, true); zval property_filename_default_value; ZVAL_UNDEF(&property_filename_default_value); - zend_string *property_filename_name = zend_string_init("filename", sizeof("filename") - 1, 1); + zend_string *property_filename_name = zend_string_init("filename", sizeof("filename") - 1, true); zend_declare_typed_property(class_entry, property_filename_name, &property_filename_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_filename_name); + zend_string_release_ex(property_filename_name, true); zval property_comment_default_value; ZVAL_UNDEF(&property_comment_default_value); - zend_string *property_comment_name = zend_string_init("comment", sizeof("comment") - 1, 1); + zend_string *property_comment_name = zend_string_init("comment", sizeof("comment") - 1, true); zend_declare_typed_property(class_entry, property_comment_name, &property_comment_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); - zend_string_release(property_comment_name); + zend_string_release_ex(property_comment_name, true); #if defined(ZIP_FL_RECOMPRESS) diff --git a/ext/zip/tests/ZipArchive_bailout.phpt b/ext/zip/tests/ZipArchive_bailout.phpt new file mode 100644 index 0000000000000..c7e4ede8446df --- /dev/null +++ b/ext/zip/tests/ZipArchive_bailout.phpt @@ -0,0 +1,28 @@ +--TEST-- +ZipArchive destructor should be called on bailout +--EXTENSIONS-- +zip +--FILE-- +open($file, ZIPARCHIVE::CREATE); +$zip->registerCancelCallback(cb(...)); +$zip->addFromString('test', 'test'); +$fusion = $zip; + +?> +--CLEAN-- + +--EXPECTF-- +Notice: Only variable references should be returned by reference in %s on line %d + +Notice: Only variable references should be returned by reference in %s on line %d + +Notice: Only variable references should be returned by reference in %s on line %d diff --git a/ext/zip/tests/ZipArchive_destruct.phpt b/ext/zip/tests/ZipArchive_destruct.phpt new file mode 100644 index 0000000000000..7e3ef6c5dae42 --- /dev/null +++ b/ext/zip/tests/ZipArchive_destruct.phpt @@ -0,0 +1,28 @@ +--TEST-- +Leaking ZipArchive destructor +--EXTENSIONS-- +zip +--FILE-- +open($file, ZIPARCHIVE::CREATE); +$leak->addFromString('test', 'test'); + +?> +===DONE=== +--CLEAN-- + +--EXPECT-- +===DONE=== diff --git a/ext/zip/tests/oo_addglob2.phpt b/ext/zip/tests/oo_addglob2.phpt index 517c0b7fd7fda..a98a222712052 100644 --- a/ext/zip/tests/oo_addglob2.phpt +++ b/ext/zip/tests/oo_addglob2.phpt @@ -33,10 +33,26 @@ if (!$zip->addGlob($dirname . 'foo.*', GLOB_BRACE, $options)) { $options = [ 'remove_all_path' => true, 'comp_method' => ZipArchive::CM_STORE, - 'comp_flags' => 5, + 'comp_flags' => PHP_INT_MIN, 'enc_method' => ZipArchive::EM_AES_256, 'enc_password' => 'secret', ]; + +try { + $zip->addGlob($dirname. 'bar.*', GLOB_BRACE, $options); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +$options['comp_flags'] = 65536; + +try { + $zip->addGlob($dirname. 'bar.*', GLOB_BRACE, $options); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +$options['comp_flags'] = 5; if (!$zip->addGlob($dirname . 'bar.*', GLOB_BRACE, $options)) { echo "failed 2\n"; } @@ -61,6 +77,10 @@ $dirname = __DIR__ . '/'; include $dirname . 'utils.inc'; rmdir_rf(__DIR__ . '/__tmp_oo_addglob2/'); ?> ---EXPECT-- +--EXPECTF-- + +Warning: ZipArchive::addGlob(): Option "comp_flags" must be between 0 and 65535 in %s on line %d + +Warning: ZipArchive::addGlob(): Option "comp_flags" must be between 0 and 65535 in %s on line %d 0: foo.txt, comp=8, enc=0 1: bar.txt, comp=0, enc=259 diff --git a/ext/zip/tests/oo_setcompression.phpt b/ext/zip/tests/oo_setcompression.phpt index 6b3291463659b..1b7e817688dde 100644 --- a/ext/zip/tests/oo_setcompression.phpt +++ b/ext/zip/tests/oo_setcompression.phpt @@ -28,6 +28,18 @@ var_dump($zip->setCompressionName('entry2.txt', ZipArchive::CM_DEFAULT)); var_dump($zip->setCompressionName('dir/entry3.txt', ZipArchive::CM_STORE)); var_dump($zip->setCompressionName('entry4.txt', ZipArchive::CM_DEFLATE)); +try { + $zip->setCompressionName('entry5.txt', PHP_INT_MIN); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +try { + $zip->setCompressionIndex(4, PHP_INT_MIN); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + var_dump($zip->setCompressionIndex(4, ZipArchive::CM_STORE)); var_dump($zip->setCompressionIndex(5, ZipArchive::CM_DEFLATE)); var_dump($zip->setCompressionIndex(6, ZipArchive::CM_DEFAULT)); @@ -57,6 +69,8 @@ unlink($tmpfile); bool(true) bool(true) bool(true) +ZipArchive::setCompressionName(): Argument #2 ($method) must be between -1 and %d +ZipArchive::setCompressionIndex(): Argument #2 ($method) must be between -1 and %d bool(true) bool(true) bool(true) diff --git a/ext/zip/tests/oo_setcompression_64bit.phpt b/ext/zip/tests/oo_setcompression_64bit.phpt new file mode 100644 index 0000000000000..cb093e8ccfc9d --- /dev/null +++ b/ext/zip/tests/oo_setcompression_64bit.phpt @@ -0,0 +1,29 @@ +--TEST-- +setCompressionName and setCompressionIndex methods +--EXTENSIONS-- +zip +--SKIPIF-- + +--FILE-- +setCompressionName('entry5.txt', PHP_INT_MAX); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +try { + $zip->setCompressionIndex(4, PHP_INT_MAX); +} catch (\ValueError $e) { + echo $e->getMessage(), PHP_EOL; +} + +?> +--EXPECTF-- +ZipArchive::setCompressionName(): Argument #2 ($method) must be between -1 and %d +ZipArchive::setCompressionIndex(): Argument #2 ($method) must be between -1 and %d diff --git a/ext/zip/tests/oo_setmtime.phpt b/ext/zip/tests/oo_setmtime.phpt index 8c3c4eb7cca32..bf34dd722b519 100644 --- a/ext/zip/tests/oo_setmtime.phpt +++ b/ext/zip/tests/oo_setmtime.phpt @@ -2,11 +2,6 @@ setMtime --EXTENSIONS-- zip ---SKIPIF-- - --INI-- date.timezone=UTC --FILE-- diff --git a/ext/zip/zip_stream.c b/ext/zip/zip_stream.c index a32324347d674..50f097de3c876 100644 --- a/ext/zip/zip_stream.c +++ b/ext/zip/zip_stream.c @@ -49,18 +49,11 @@ static ssize_t php_zip_ops_read(php_stream *stream, char *buf, size_t count) if (self->zf) { n = zip_fread(self->zf, buf, count); if (n < 0) { -#if LIBZIP_VERSION_MAJOR < 1 - int ze, se; - zip_file_error_get(self->zf, &ze, &se); - stream->eof = 1; - php_error_docref(NULL, E_WARNING, "Zip stream error: %s", zip_file_strerror(self->zf)); -#else zip_error_t *err; err = zip_file_get_error(self->zf); stream->eof = 1; php_error_docref(NULL, E_WARNING, "Zip stream error: %s", zip_error_strerror(err)); zip_error_fini(err); -#endif return -1; } /* cast count to signed value to avoid possibly negative n @@ -82,7 +75,7 @@ static ssize_t php_zip_ops_write(php_stream *stream, const char *buf, size_t cou return -1; } - return count; + return (ssize_t)count; } /* }}} */ @@ -157,7 +150,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ fragment++; if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) { - zend_string_release_ex(file_basename, 0); + zend_string_release_ex(file_basename, false); return -1; } @@ -166,7 +159,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ memset(ssb, 0, sizeof(php_stream_statbuf)); if (zip_stat(za, fragment, ZIP_FL_NOCASE, &sb) != 0) { zip_close(za); - zend_string_release_ex(file_basename, 0); + zend_string_release_ex(file_basename, false); return -1; } zip_close(za); @@ -190,7 +183,7 @@ static int php_zip_ops_stat(php_stream *stream, php_stream_statbuf *ssb) /* {{{ #endif ssb->sb.st_ino = -1; } - zend_string_release_ex(file_basename, 0); + zend_string_release_ex(file_basename, false); return 0; } /* }}} */ @@ -319,7 +312,7 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, fragment++; if (ZIP_OPENBASEDIR_CHECKPATH(file_dirname)) { - zend_string_release_ex(file_basename, 0); + zend_string_release_ex(file_basename, false); return NULL; } @@ -351,14 +344,14 @@ php_stream *php_stream_zip_opener(php_stream_wrapper *wrapper, } if (opened_path) { - *opened_path = zend_string_init(path, strlen(path), 0); + *opened_path = zend_string_init(path, path_len, false); } } else { zip_close(za); } } - zend_string_release_ex(file_basename, 0); + zend_string_release_ex(file_basename, false); if (!stream) { return NULL; diff --git a/ext/zlib/config.w32 b/ext/zlib/config.w32 index 3bc24d88e1735..63ca949813ce1 100644 --- a/ext/zlib/config.w32 +++ b/ext/zlib/config.w32 @@ -6,7 +6,7 @@ if (PHP_ZLIB == "yes") { if (CHECK_LIB("zlib_a.lib;zlib.lib", "zlib", PHP_ZLIB) && CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)) { - EXTENSION("zlib", "zlib.c zlib_fopen_wrapper.c zlib_filter.c", PHP_ZLIB_SHARED, "/D ZLIB_EXPORTS /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); + EXTENSION("zlib", "zlib.c zlib_fopen_wrapper.c zlib_filter.c", PHP_ZLIB_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("HAVE_ZLIB", 1, "Define to 1 if the PHP extension 'zlib' is available."); if (!PHP_ZLIB_SHARED) { diff --git a/ext/zlib/tests/inflate_init_error.phpt b/ext/zlib/tests/inflate_init_error.phpt index 8faed763be4e5..9854f7453909b 100644 --- a/ext/zlib/tests/inflate_init_error.phpt +++ b/ext/zlib/tests/inflate_init_error.phpt @@ -13,4 +13,4 @@ try { ?> --EXPECT-- -Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE +inflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE diff --git a/ext/zlib/tests/leak_invalid_encoding_with_dict.phpt b/ext/zlib/tests/leak_invalid_encoding_with_dict.phpt index da2a11849c0c2..507e6842cb587 100644 --- a/ext/zlib/tests/leak_invalid_encoding_with_dict.phpt +++ b/ext/zlib/tests/leak_invalid_encoding_with_dict.phpt @@ -16,5 +16,5 @@ try { } ?> --EXPECT-- -Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE +inflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE deflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index e73e168708ad7..68c5572931b66 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -800,12 +800,12 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_ memcpy(*dict, ZSTR_VAL(str), ZSTR_LEN(str)); *dictlen = ZSTR_LEN(str); - return 1; + return true; } case IS_ARRAY: { HashTable *dictionary = Z_ARR_P(option_buffer); - bool result = 1; + bool result = true; if (zend_hash_num_elements(dictionary) > 0) { zend_string **strings = safe_emalloc(zend_hash_num_elements(dictionary), sizeof(zend_string *), 0); @@ -815,18 +815,18 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_ ZEND_HASH_FOREACH_VAL(dictionary, cur) { zend_string *string = zval_try_get_string(cur); if (string == NULL) { - result = 0; + result = false; break; } *dictlen += ZSTR_LEN(string) + 1; strings[total++] = string; if (ZSTR_LEN(string) == 0) { - result = 0; + result = false; zend_argument_value_error(2, "must not contain empty strings"); break; } if (zend_str_has_nul_byte(string)) { - result = 0; + result = false; zend_argument_value_error(2, "must not contain strings with null bytes"); break; } @@ -852,10 +852,10 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_ default: zend_argument_type_error(2, "must be of type zero-terminated string or array, %s given", zend_zval_value_name(option_buffer)); - return 0; + return false; } } - return 1; + return true; } /* {{{ Initialize an incremental inflate context with the specified encoding */ @@ -887,7 +887,7 @@ PHP_FUNCTION(inflate_init) case PHP_ZLIB_ENCODING_DEFLATE: break; default: - zend_value_error("Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE"); + zend_argument_value_error(1, "must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE"); RETURN_THROWS(); } diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index e5491afec3919..e42132fd0008c 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -238,7 +238,7 @@ static php_stream_filter_status_t php_zlib_deflate_filter( status = Z_OK; while (status == Z_OK) { status = deflate(&(data->strm), (flags & PSFS_FLAG_FLUSH_CLOSE ? Z_FINISH : Z_SYNC_FLUSH)); - data->finished = 1; + data->finished = true; if (data->strm.avail_out < data->outbuf_len) { size_t bucketlen = data->outbuf_len - data->strm.avail_out; @@ -335,7 +335,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f } /* RFC 1951 Inflate */ - data->finished = '\0'; + data->finished = false; status = inflateInit2(&(data->strm), windowBits); fops = &php_zlib_inflate_ops; } else if (strcasecmp(filtername, "zlib.deflate") == 0) { @@ -402,7 +402,7 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f } } status = deflateInit2(&(data->strm), level, Z_DEFLATED, windowBits, memLevel, 0); - data->finished = 1; + data->finished = true; fops = &php_zlib_deflate_ops; } else { status = Z_DATA_ERROR; diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index fc0dbb9a984ea..63564cc73bdfc 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -506,7 +506,7 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt php_stream_wrapper *wrapper; zend_string *exec_filename; - if (!filename || CHECK_NULL_PATH(filename, filename_length)) { + if (!filename || zend_char_has_nul_byte(filename, filename_length)) { return NULL; } diff --git a/main/main.c b/main/main.c index 25cfc4de1e7d9..f190eab3d094f 100644 --- a/main/main.c +++ b/main/main.c @@ -127,8 +127,8 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module) { smart_string version_info = {0}; smart_string_append_printf(&version_info, - "PHP %s (%s) (built: %s) (%s)\n", - PHP_VERSION, sapi_module->name, php_build_date, + "PHP " PHP_VERSION " (%s) (built: %s) (%s)\n", + sapi_module->name, php_build_date, #ifdef ZTS "ZTS" #else @@ -148,8 +148,12 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module) #endif ); smart_string_appends(&version_info, "Copyright (c) The PHP Group\n"); - if (php_build_provider()) { - smart_string_append_printf(&version_info, "Built by %s\n", php_build_provider()); + + const char *build_provider = php_build_provider(); + if (build_provider) { + smart_string_appends(&version_info, "Built by "); + smart_string_appends(&version_info, build_provider); + smart_string_appendc(&version_info, '\n'); } smart_string_appends(&version_info, get_zend_version()); smart_string_0(&version_info); @@ -160,7 +164,7 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module) PHPAPI void php_print_version(sapi_module_struct *sapi_module) { char *version_info = php_get_version(sapi_module); - php_printf("%s", version_info); + PHPWRITE(version_info, strlen(version_info)); efree(version_info); } diff --git a/main/network.c b/main/network.c index f613a73f390f1..96953531c3761 100644 --- a/main/network.c +++ b/main/network.c @@ -498,8 +498,13 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po /* attempt to bind */ -#ifdef SO_REUSEADDR - setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&sockoptval, sizeof(sockoptval)); + if (sockopts & STREAM_SOCKOP_SO_REUSEADDR) { + setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&sockoptval, sizeof(sockoptval)); + } +#ifdef PHP_WIN32 + else { + setsockopt(sock, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&sockoptval, sizeof(sockoptval)); + } #endif #ifdef IPV6_V6ONLY if (sockopts & STREAM_SOCKOP_IPV6_V6ONLY) { @@ -509,7 +514,13 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po #endif #ifdef SO_REUSEPORT if (sockopts & STREAM_SOCKOP_SO_REUSEPORT) { +# ifdef SO_REUSEPORT_LB + /* Historically, SO_REUSEPORT on FreeBSD predates Linux version, however does not + * involve load balancing grouping thus SO_REUSEPORT_LB is the genuine equivalent.*/ + setsockopt(sock, SOL_SOCKET, SO_REUSEPORT_LB, (char*)&sockoptval, sizeof(sockoptval)); +# else setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (char*)&sockoptval, sizeof(sockoptval)); +# endif } #endif #ifdef SO_BROADCAST diff --git a/main/output.c b/main/output.c index 653b457e9b641..c90e4426d6cde 100644 --- a/main/output.c +++ b/main/output.c @@ -187,8 +187,12 @@ PHPAPI void php_output_deactivate(void) /* release all output handlers */ if (OG(handlers).elements) { while ((handler = zend_stack_top(&OG(handlers)))) { - php_output_handler_free(handler); zend_stack_del_top(&OG(handlers)); + /* It's possible to start a new output handler and mark it as active, + * however this loop will destroy all active handlers. */ + OG(active) = NULL; + ZEND_ASSERT(OG(running) == NULL && "output is deactivated therefore running should stay NULL"); + php_output_handler_free(handler); } } zend_stack_destroy(&OG(handlers)); @@ -718,10 +722,11 @@ PHPAPI void php_output_handler_dtor(php_output_handler *handler) * Destroy and free an output handler */ PHPAPI void php_output_handler_free(php_output_handler **h) { - if (*h) { - php_output_handler_dtor(*h); - efree(*h); + php_output_handler *handler = *h; + if (handler) { *h = NULL; + php_output_handler_dtor(handler); + efree(handler); } } /* }}} */ diff --git a/main/php.h b/main/php.h index b298aa299e7b3..32222cfca94e0 100644 --- a/main/php.h +++ b/main/php.h @@ -22,8 +22,7 @@ #include #endif -#define PHP_API_VERSION 20250925 -#define PHP_HAVE_STREAMS +#define PHP_API_VERSION 20250926 #define YYDEBUG 0 #define PHP_DEFAULT_CHARSET "UTF-8" diff --git a/main/php_network.h b/main/php_network.h index 6df73cf7af0d0..45e1e1902631d 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -123,7 +123,7 @@ typedef int php_socket_t; #define STREAM_SOCKOP_IPV6_V6ONLY (1 << 3) #define STREAM_SOCKOP_IPV6_V6ONLY_ENABLED (1 << 4) #define STREAM_SOCKOP_TCP_NODELAY (1 << 5) - +#define STREAM_SOCKOP_SO_REUSEADDR (1 << 6) /* uncomment this to debug poll(2) emulation on systems that have poll(2) */ /* #define PHP_USE_POLL_2_EMULATION 1 */ diff --git a/main/php_version.h b/main/php_version.h index 87cf375f2e0f9..fa9484cbe1502 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -1,8 +1,8 @@ /* automatically generated by configure */ /* edit configure.ac to change version number */ #define PHP_MAJOR_VERSION 8 -#define PHP_MINOR_VERSION 5 -#define PHP_RELEASE_VERSION 1 +#define PHP_MINOR_VERSION 6 +#define PHP_RELEASE_VERSION 0 #define PHP_EXTRA_VERSION "-dev" -#define PHP_VERSION "8.5.1-dev" -#define PHP_VERSION_ID 80501 +#define PHP_VERSION "8.6.0-dev" +#define PHP_VERSION_ID 80600 diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 888e4c90bbaf9..f5e25aa96c772 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -37,7 +37,6 @@ static int le_protocols; struct php_user_stream_wrapper { php_stream_wrapper wrapper; - char * protoname; zend_class_entry *ce; zend_resource *resource; }; @@ -72,7 +71,6 @@ static void stream_wrapper_dtor(zend_resource *rsrc) { struct php_user_stream_wrapper * uwrap = (struct php_user_stream_wrapper*)rsrc->ptr; - efree(uwrap->protoname); efree(uwrap); } @@ -346,7 +344,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char * zval_ptr_dtor(&args[3]); goto end; } - if (zval_is_true(&zretval)) { + if (zend_is_true(&zretval)) { /* the stream is now open! */ stream = php_stream_alloc_rel(&php_stream_userspace_ops, us, 0, mode); @@ -430,7 +428,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char goto end; } - if (zval_is_true(&zretval)) { + if (zend_is_true(&zretval)) { /* the stream is now open! */ stream = php_stream_alloc_rel(&php_stream_userspace_dir_ops, us, 0, mode); @@ -468,7 +466,6 @@ PHP_FUNCTION(stream_wrapper_register) uwrap = (struct php_user_stream_wrapper *)ecalloc(1, sizeof(*uwrap)); uwrap->ce = ce; - uwrap->protoname = estrndup(ZSTR_VAL(protocol), ZSTR_LEN(protocol)); uwrap->wrapper.wops = &user_stream_wops; uwrap->wrapper.abstract = uwrap; uwrap->wrapper.is_url = ((flags & PHP_STREAM_IS_URL) != 0); @@ -602,8 +599,6 @@ static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_ didwrite = count; } - zval_ptr_dtor(&retval); - return didwrite; } @@ -674,7 +669,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count goto err; } - if (zval_is_true(&retval)) { + if (zend_is_true(&retval)) { stream->eof = 1; } zval_ptr_dtor(&retval); @@ -722,7 +717,7 @@ static int php_userstreamop_flush(php_stream *stream) zend_result call_result = zend_call_method_if_exists(Z_OBJ(us->object), func_name, &retval, 0, NULL); zend_string_release_ex(func_name, false); - int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval) ? 0 : -1; + int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval) ? 0 : -1; zval_ptr_dtor(&retval); @@ -757,7 +752,7 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when ret = -1; goto out; - } else if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) { + } else if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval)) { ret = 0; } else { ret = -1; @@ -1092,7 +1087,7 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1130,7 +1125,7 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1168,7 +1163,7 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1205,7 +1200,7 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url, } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); @@ -1267,7 +1262,7 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i } else if (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE) { ret = Z_TYPE(zretval) == IS_TRUE; } - // TODO: Warn on invalid return type, or use zval_is_true()? + // TODO: Warn on invalid return type, or use zend_is_true()? zval_ptr_dtor(&zretval); diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index e3e81323c3fc7..db35a9b7952c8 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -718,6 +718,16 @@ static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t * } #endif +#ifdef SO_REUSEADDR + /* SO_REUSEADDR is enabled by default so this option is just to disable it if set to false. */ + if (!PHP_STREAM_CONTEXT(stream) + || (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "so_reuseaddr")) == NULL + || zend_is_true(tmpzval) + ) { + sockopts |= STREAM_SOCKOP_SO_REUSEADDR; + } +#endif + #ifdef SO_BROADCAST if (stream->ops == &php_stream_udp_socket_ops /* SO_BROADCAST is only applicable for UDP */ && PHP_STREAM_CONTEXT(stream) diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index ae56d143c90c8..046e2174dc1d8 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -395,13 +395,7 @@ static void append_essential_headers(smart_str* buffer, php_cli_server_client *c static const char *get_mime_type(const php_cli_server *server, const char *ext, size_t ext_len) /* {{{ */ { - char *ret; - ALLOCA_FLAG(use_heap) - char *ext_lower = do_alloca(ext_len + 1, use_heap); - zend_str_tolower_copy(ext_lower, ext, ext_len); - ret = zend_hash_str_find_ptr(&server->extension_mime_types, ext_lower, ext_len); - free_alloca(ext_lower, use_heap); - return (const char*)ret; + return zend_hash_str_find_ptr_lc(&server->extension_mime_types, ext, ext_len); } /* }}} */ PHP_FUNCTION(apache_request_headers) /* {{{ */ diff --git a/sapi/fpm/www.conf.in b/sapi/fpm/www.conf.in index 69df3e6630047..f39e371ea70fe 100644 --- a/sapi/fpm/www.conf.in +++ b/sapi/fpm/www.conf.in @@ -329,7 +329,7 @@ pm.max_spare_servers = 3 ; it must be associated with embraces to specify the name of the header: ; - %{Content-Type}o ; - %{X-Powered-By}o -; - %{Transfert-Encoding}o +; - %{Transfer-Encoding}o ; - .... ; %p: PID of the child that serviced the request ; %P: PID of the parent of the child that serviced the request diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index a8f1bf01433b7..01b19de80a995 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -34,11 +34,7 @@ static inline void phpdbg_append_individual_arg(smart_str *s, uint32_t i, zend_f } if (i < func->common.num_args) { if (arginfo) { - if (func->type == ZEND_INTERNAL_FUNCTION) { - arg_name = (char *) ((zend_internal_arg_info *) &arginfo[i])->name; - } else { - arg_name = ZSTR_VAL(arginfo[i].name); - } + arg_name = ZSTR_VAL(arginfo[i].name); } smart_str_appends(s, arg_name ? arg_name : "?"); smart_str_appendc(s, '='); @@ -213,11 +209,7 @@ static void phpdbg_dump_prototype(zval *tmp) /* {{{ */ char *arg_name = NULL; if (arginfo) { - if (func->type == ZEND_INTERNAL_FUNCTION) { - arg_name = (char *)((zend_internal_arg_info *)&arginfo[j])->name; - } else { - arg_name = ZSTR_VAL(arginfo[j].name); - } + arg_name = ZSTR_VAL(arginfo[j].name); } if (!is_variadic) { diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c index b329bdac728bb..9c93cd2b88efb 100644 --- a/sapi/phpdbg/phpdbg_info.c +++ b/sapi/phpdbg/phpdbg_info.c @@ -307,7 +307,7 @@ PHPDBG_INFO(literal) /* {{{ */ bool in_executor = PHPDBG_G(in_execution) && EG(current_execute_data) && EG(current_execute_data)->func; if (in_executor || PHPDBG_G(ops)) { zend_op_array *ops = in_executor ? &EG(current_execute_data)->func->op_array : PHPDBG_G(ops); - int literal = 0, count = ops->last_literal - 1; + uint32_t literal = 0, count = ops->last_literal - 1; if (ops->function_name) { if (ops->scope) { diff --git a/sapi/phpdbg/phpdbg_utils.c b/sapi/phpdbg/phpdbg_utils.c index 329ee9a8830e3..55d97acc38759 100644 --- a/sapi/phpdbg/phpdbg_utils.c +++ b/sapi/phpdbg/phpdbg_utils.c @@ -612,7 +612,7 @@ int phpdbg_is_auto_global(char *name, int len) { PHPDBG_API bool phpdbg_check_caught_ex(zend_execute_data *execute_data, zend_object *exception) { const zend_op *op; zend_op *cur; - uint32_t op_num, i; + uint32_t op_num; zend_op_array *op_array = &execute_data->func->op_array; if (execute_data->opline >= EG(exception_op) && execute_data->opline < EG(exception_op) + 3 && EG(opline_before_exception)) { @@ -623,7 +623,7 @@ PHPDBG_API bool phpdbg_check_caught_ex(zend_execute_data *execute_data, zend_obj op_num = op - op_array->opcodes; - for (i = 0; i < op_array->last_try_catch && op_array->try_catch_array[i].try_op <= op_num; i++) { + for (uint32_t i = 0; i < op_array->last_try_catch && op_array->try_catch_array[i].try_op <= op_num; i++) { uint32_t catch = op_array->try_catch_array[i].catch_op, finally = op_array->try_catch_array[i].finally_op; if (op_num <= catch || op_num <= finally) { if (finally) { diff --git a/tests/output/gh20352.phpt b/tests/output/gh20352.phpt new file mode 100644 index 0000000000000..16be0b920e80f --- /dev/null +++ b/tests/output/gh20352.phpt @@ -0,0 +1,24 @@ +--TEST-- +GH-20352 (UAF in php_output_handler_free via re-entrant ob_start() during error deactivation) +--FILE-- + +--EXPECTF-- +Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in %s on line %d diff --git a/tests/unit/Makefile b/tests/unit/Makefile new file mode 100644 index 0000000000000..ae8eeb8ab3ed9 --- /dev/null +++ b/tests/unit/Makefile @@ -0,0 +1,32 @@ +CC = gcc +CFLAGS = -g -Wall -I../../ -I../../Zend -I../../main -I../../TSRM -I. -I.. +COMMON_LDFLAGS = ../../.libs/libphp.a -lcmocka -lpthread -lm -ldl -lresolv -lutil + +# Update paths in .github/workflows/unit-tests.yml when adding new test to make it run in PR when such file changes +TESTS = main/test_network +main/test_network_SRC = main/test_network.c +main/test_network_LDFLAGS = $(COMMON_LDFLAGS) -Wl,--wrap=connect,--wrap=poll,--wrap=getsockopt,--wrap=gettimeofday + + +# Build all tests +all: $(TESTS) + +# Build rule for each test +$(TESTS): + $(CC) $(CFLAGS) -o $@.out $($(basename $@)_SRC) $($(basename $@)_LDFLAGS) + +# Run all tests +.PHONY: test +test: $(TESTS) + @echo "Running all tests..." + @for test in $(TESTS); do \ + echo "Running $$test..."; \ + $$test.out || exit 1; \ + done + +# Clean tests +.PHONY: clean +clean: + @for test in $(TESTS); do \ + rm -f $$test.out; \ + done diff --git a/tests/unit/main/test_network.c b/tests/unit/main/test_network.c new file mode 100644 index 0000000000000..3e0e6e37ed989 --- /dev/null +++ b/tests/unit/main/test_network.c @@ -0,0 +1,254 @@ +#include "php.h" +#include "php_network.h" +#include + +// Mocked poll +int __wrap_poll(struct pollfd *ufds, nfds_t nfds, int timeout) +{ + function_called(); + check_expected(timeout); + + int n = mock_type(int); + if (n > 0) { + ufds->revents = 1; + } else if (n < 0) { + errno = -n; + n = -1; + } + + return n; +} + +// Mocked connect +int __wrap_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen) +{ + function_called(); + errno = mock_type(int); + return errno != 0 ? -1 : 0; +} + +// Mocked getsockopt +int __wrap_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen) +{ + function_called(); + int *error = (int *) optval; + *error = mock_type(int); + return mock_type(int); +} + +// Mocked gettimeofday +int __wrap_gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info) +{ + function_called(); + struct timeval *now = mock_ptr_type(struct timeval *); + if (now) { + time_Info->tv_sec = now->tv_sec; + time_Info->tv_usec = now->tv_usec; + } + return mock_type(int); +} + +// Test successful connection +static void test_php_network_connect_socket_immediate_success(void **state) { + struct timeval timeout = { .tv_sec = 2, .tv_usec = 500000 }; + php_socket_t sockfd = 12; + int error_code = 0; + + expect_function_call(__wrap_connect); + will_return(__wrap_connect, 0); + + int result = php_network_connect_socket(sockfd, NULL, 0, 0, &timeout, NULL, &error_code); + + assert_int_equal(result, 0); + assert_int_equal(error_code, 0); +} + +// Test successful connection in progress followed by poll +static void test_php_network_connect_socket_progress_success(void **state) { + struct timeval timeout_tv = { .tv_sec = 2, .tv_usec = 500000 }; + php_socket_t sockfd = 12; + int error_code = 0; + + // Mock connect setting EINPROGRESS errno + expect_function_call(__wrap_connect); + will_return(__wrap_connect, EINPROGRESS); + + // Mock time setting - ignored + expect_function_call(__wrap_gettimeofday); + will_return(__wrap_gettimeofday, NULL); + will_return(__wrap_gettimeofday, 0); + + // Mock poll to return success + expect_function_call(__wrap_poll); + expect_value(__wrap_poll, timeout, 2500); + will_return(__wrap_poll, 1); + + // Mock no socket error + expect_function_call(__wrap_getsockopt); + will_return(__wrap_getsockopt, 0); // optval saved result + will_return(__wrap_getsockopt, 0); // actual return value + + int result = php_network_connect_socket(sockfd, NULL, 0, 0, &timeout_tv, NULL, &error_code); + + assert_int_equal(result, 0); + assert_int_equal(error_code, 0); +} + +static void test_php_network_connect_socket_eintr_t1(void **state) { + struct timeval timeout_tv = { .tv_sec = 2, .tv_usec = 500000 }; + struct timeval start_time = { .tv_sec = 1000, .tv_usec = 0 }; // Initial time + struct timeval retry_time = { .tv_sec = 1001, .tv_usec = 200000 }; // Time after EINTR + php_socket_t sockfd = 12; + int error_code = 0; + + // Mock connect to set EINPROGRESS + expect_function_call(__wrap_connect); + will_return(__wrap_connect, EINPROGRESS); + + // Mock gettimeofday for initial call + expect_function_call(__wrap_gettimeofday); + will_return(__wrap_gettimeofday, &start_time); + will_return(__wrap_gettimeofday, 0); + + // Mock poll to return EINTR first + expect_function_call(__wrap_poll); + expect_value(__wrap_poll, timeout, 2500); + will_return(__wrap_poll, -EINTR); + + // Mock gettimeofday after EINTR + expect_function_call(__wrap_gettimeofday); + will_return(__wrap_gettimeofday, &retry_time); + will_return(__wrap_gettimeofday, 0); + + // Mock poll to succeed on retry + expect_function_call(__wrap_poll); + expect_value(__wrap_poll, timeout, 1300); + will_return(__wrap_poll, 1); + + // Mock no socket error + expect_function_call(__wrap_getsockopt); + will_return(__wrap_getsockopt, 0); + will_return(__wrap_getsockopt, 0); + + int result = php_network_connect_socket(sockfd, NULL, 0, 0, &timeout_tv, NULL, &error_code); + + // Ensure the function succeeds + assert_int_equal(result, 0); + assert_int_equal(error_code, 0); +} + +static void test_php_network_connect_socket_eintr_t2(void **state) { + struct timeval timeout_tv = { .tv_sec = 2, .tv_usec = 1500000 }; + struct timeval start_time = { .tv_sec = 1000, .tv_usec = 300000 }; // Initial time + struct timeval retry_time = { .tv_sec = 1001, .tv_usec = 200000 }; // Time after EINTR + php_socket_t sockfd = 12; + int error_code = 0; + + // Mock connect to set EINPROGRESS + expect_function_call(__wrap_connect); + will_return(__wrap_connect, EINPROGRESS); + + // Mock gettimeofday for initial call + expect_function_call(__wrap_gettimeofday); + will_return(__wrap_gettimeofday, &start_time); + will_return(__wrap_gettimeofday, 0); + + // Mock poll to return EINTR first + expect_function_call(__wrap_poll); + expect_value(__wrap_poll, timeout, 3500); + will_return(__wrap_poll, -EINTR); + + // Mock gettimeofday after EINTR + expect_function_call(__wrap_gettimeofday); + will_return(__wrap_gettimeofday, &retry_time); + will_return(__wrap_gettimeofday, 0); + + // Mock poll to succeed on retry + expect_function_call(__wrap_poll); + expect_value(__wrap_poll, timeout, 2600); + will_return(__wrap_poll, 1); + + // Mock no socket error + expect_function_call(__wrap_getsockopt); + will_return(__wrap_getsockopt, 0); // optval saved result + will_return(__wrap_getsockopt, 0); // actual return value + + int result = php_network_connect_socket(sockfd, NULL, 0, 0, &timeout_tv, NULL, &error_code); + + // Ensure the function succeeds + assert_int_equal(result, 0); + assert_int_equal(error_code, 0); +} + +static void test_php_network_connect_socket_eintr_t3(void **state) { + struct timeval timeout_tv = { .tv_sec = 2, .tv_usec = 500000 }; + struct timeval start_time = { .tv_sec = 1002, .tv_usec = 300000 }; // Initial time + struct timeval retry_time = { .tv_sec = 1001, .tv_usec = 2200000 }; // Time after EINTR + php_socket_t sockfd = 12; + int error_code = 0; + + // Mock connect to set EINPROGRESS + expect_function_call(__wrap_connect); + will_return(__wrap_connect, EINPROGRESS); + + // Mock gettimeofday for initial call + expect_function_call(__wrap_gettimeofday); + will_return(__wrap_gettimeofday, &start_time); + will_return(__wrap_gettimeofday, 0); + + // Mock poll to return EINTR first + expect_function_call(__wrap_poll); + expect_value(__wrap_poll, timeout, 2500); + will_return(__wrap_poll, -EINTR); + + // Mock gettimeofday after EINTR + expect_function_call(__wrap_gettimeofday); + will_return(__wrap_gettimeofday, &retry_time); + will_return(__wrap_gettimeofday, 0); + + // Mock poll to succeed on retry + expect_function_call(__wrap_poll); + expect_value(__wrap_poll, timeout, 1600); + will_return(__wrap_poll, 1); + + // Mock no socket error + expect_function_call(__wrap_getsockopt); + will_return(__wrap_getsockopt, 0); // optval saved result + will_return(__wrap_getsockopt, 0); // actual return value + + int result = php_network_connect_socket(sockfd, NULL, 0, 0, &timeout_tv, NULL, &error_code); + + // Ensure the function succeeds + assert_int_equal(result, 0); + assert_int_equal(error_code, 0); +} + +// Test connection error (ECONNREFUSED) +static void test_php_network_connect_socket_connect_error(void **state) { + struct timeval timeout = { .tv_sec = 2, .tv_usec = 500000 }; + php_socket_t sockfd = 12; + int error_code = 0; + + // Mock connect to set ECONNREFUSED + expect_function_call(__wrap_connect); + will_return(__wrap_connect, ECONNREFUSED); + + int result = php_network_connect_socket(sockfd, NULL, 0, 0, &timeout, NULL, &error_code); + + // Ensure the function returns an error + assert_int_equal(result, -1); + assert_int_equal(error_code, ECONNREFUSED); +} + + +int main(void) { + const struct CMUnitTest tests[] = { + cmocka_unit_test(test_php_network_connect_socket_immediate_success), + cmocka_unit_test(test_php_network_connect_socket_progress_success), + cmocka_unit_test(test_php_network_connect_socket_eintr_t1), + cmocka_unit_test(test_php_network_connect_socket_eintr_t2), + cmocka_unit_test(test_php_network_connect_socket_eintr_t3), + cmocka_unit_test(test_php_network_connect_socket_connect_error), + }; + return cmocka_run_group_tests(tests, NULL, NULL); +} diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 0930a86b741ca..b6693df2a5c3d 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -95,10 +95,10 @@ if (typeof(CWD) == "undefined") { if (!MODE_PHPIZE) { /* defaults; we pick up the precise versions from configure.ac */ var PHP_VERSION = 8; - var PHP_MINOR_VERSION = 5; + var PHP_MINOR_VERSION = 6; var PHP_RELEASE_VERSION = 0; var PHP_EXTRA_VERSION = ""; - var PHP_VERSION_STRING = "8.5.0"; + var PHP_VERSION_STRING = "8.6.0"; } /* Get version numbers and DEFINE as a string */