diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8fb09206d3a6e..bca6af8471fcd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -45,6 +45,7 @@ /ext/random @TimWolla @zeriyoshi /ext/session @Girgias /ext/simplexml @nielsdos +/ext/soap @nielsdos /ext/sockets @devnexen /ext/spl @Girgias /ext/standard @bukka diff --git a/.github/actions/apt-x32/action.yml b/.github/actions/apt-x32/action.yml index 0638881d1e4c2..af1d7918bb28d 100644 --- a/.github/actions/apt-x32/action.yml +++ b/.github/actions/apt-x32/action.yml @@ -33,13 +33,11 @@ runs: libsodium-dev:i386 \ libsqlite3-dev:i386 \ libssl-dev:i386 \ - libtidy-dev:i386 \ libwebp-dev:i386 \ libxml2-dev:i386 \ libxml2-dev:i386 \ libxpm-dev:i386 \ libxslt1-dev:i386 \ - libzip-dev:i386 \ locales \ make \ pkg-config:i386 \ diff --git a/.github/actions/brew/action.yml b/.github/actions/brew/action.yml index 287062e6f9f9c..07595a5ada931 100644 --- a/.github/actions/brew/action.yml +++ b/.github/actions/brew/action.yml @@ -13,7 +13,7 @@ runs: # Some packages exist on x86 but not arm, or vice versa. # Install them with reinstall to avoid warnings. - brew reinstall autoconf webp tidy-html5 libzip libsodium icu4c + brew reinstall autoconf webp tidy-html5 libzip libsodium icu4c curl brew install \ bison \ re2c diff --git a/.github/actions/configure-macos/action.yml b/.github/actions/configure-macos/action.yml index ab92dfb2d782f..b318f22725150 100644 --- a/.github/actions/configure-macos/action.yml +++ b/.github/actions/configure-macos/action.yml @@ -18,6 +18,7 @@ runs: export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/libxslt/lib/pkgconfig" export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/zlib/lib/pkgconfig" export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$BREW_OPT/icu4c/lib/pkgconfig" + sed -i -e 's/Requires.private:.*//g' "$BREW_OPT/curl/lib/pkgconfig/libcurl.pc" ./buildconf --force ./configure \ --enable-option-checking=fatal \ diff --git a/.github/actions/configure-x32/action.yml b/.github/actions/configure-x32/action.yml index c07c49bb2c4f1..de500e02d4991 100644 --- a/.github/actions/configure-x32/action.yml +++ b/.github/actions/configure-x32/action.yml @@ -10,6 +10,7 @@ runs: run: | set -x + export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/i386-linux-gnu/pkgconfig" ./buildconf --force export CFLAGS="-m32 -msse2" export CXXFLAGS="-m32 -msse2" @@ -33,12 +34,10 @@ runs: --with-freetype \ --with-xpm \ --enable-exif \ - --with-zip \ --with-zlib \ --enable-soap \ --enable-xmlreader \ --with-xsl \ - --with-tidy \ --enable-sysvsem \ --enable-sysvshm \ --enable-shmop \ diff --git a/.github/nightly_matrix.php b/.github/nightly_matrix.php index 7c2797f249e59..311176ef5e53e 100644 --- a/.github/nightly_matrix.php +++ b/.github/nightly_matrix.php @@ -1,11 +1,11 @@ 'master', 'ref' => 'master', 'version' => ['major' => 8, 'minor' => 5]], - ['name' => 'PHP-8.4', 'ref' => 'PHP-8.4', 'version' => ['major' => 8, 'minor' => 4]], - ['name' => 'PHP-8.3', 'ref' => 'PHP-8.3', 'version' => ['major' => 8, 'minor' => 3]], - ['name' => 'PHP-8.2', 'ref' => 'PHP-8.2', 'version' => ['major' => 8, 'minor' => 2]], - ['name' => 'PHP-8.1', 'ref' => 'PHP-8.1', 'version' => ['major' => 8, 'minor' => 1]], + ['ref' => 'master', 'version' => [8, 5]], + ['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 { @@ -36,142 +36,30 @@ function get_branches() { return $changed_branches; } -function get_matrix_include(array $branches) { - $jobs = []; - foreach ($branches as $branch) { - $jobs[] = [ - 'name' => '_ASAN_UBSAN', - 'branch' => $branch, - 'debug' => true, - 'zts' => true, - 'configuration_parameters' => "CFLAGS='-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address'", - 'run_tests_parameters' => '--asan', - 'test_function_jit' => false, - 'asan' => true, - ]; - $jobs[] = [ - 'name' => '_REPEAT', - 'branch' => $branch, - 'debug' => true, - 'zts' => false, - 'run_tests_parameters' => '--repeat 2', - 'timeout_minutes' => 360, - 'test_function_jit' => true, - 'asan' => false, - ]; - $jobs[] = [ - 'name' => '_VARIATION', - 'branch' => $branch, - 'debug' => true, - 'zts' => true, - 'configuration_parameters' => "CFLAGS='-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_VERIFY_TYPE_INFERENCE'", - 'run_tests_parameters' => '-d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0', - 'timeout_minutes' => 360, - 'test_function_jit' => true, - 'asan' => false, - ]; - } - return $jobs; -} - -function get_windows_matrix_include(array $branches) { - $jobs = []; - foreach ($branches as $branch) { - $jobs[] = [ - 'branch' => $branch, - 'x64' => true, - 'zts' => true, - 'opcache' => true, - ]; - $jobs[] = [ - 'branch' => $branch, - 'x64' => false, - 'zts' => false, - 'opcache' => false, - ]; - } - return $jobs; -} - -function get_macos_matrix_include(array $branches) { - $jobs = []; - foreach ($branches as $branch) { - foreach([true, false] as $debug) { - foreach([true, false] as $zts) { - $jobs[] = [ - 'branch' => $branch, - 'debug' => $debug, - 'zts' => $zts, - 'os' => in_array($branch['name'], ['master', 'PHP-8.4'], true) ? '13' : '12', - 'arch' => 'X64', - 'test_jit' => true, - ]; - if ($branch['version']['minor'] >= 4 || $branch['version']['major'] >= 9) { - $jobs[] = [ - 'branch' => $branch, - 'debug' => $debug, - 'zts' => $zts, - 'os' => '14', - 'arch' => 'ARM64', - 'test_jit' => !$zts, - ]; - } - } - } - } - return $jobs; -} - -function get_alpine_matrix_include(array $branches) { - $jobs = []; - foreach ($branches as $branch) { - if ([$branch['version']['major'], $branch['version']['minor']] < [8, 4]) { - continue; - } - $jobs[] = [ - 'name' => '_ASAN_UBSAN', - 'branch' => $branch, - 'debug' => true, - 'zts' => true, - 'asan' => true, - 'test_jit' => true, - 'configuration_parameters' => "CFLAGS='-fsanitize=undefined,address -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC' LDFLAGS='-fsanitize=undefined,address -fno-sanitize=function' CC=clang-17 CXX=clang++-17", - 'run_tests_parameters' => '--asan -x', - ]; - } - return $jobs; -} - function get_current_version(): array { $file = dirname(__DIR__) . '/main/php_version.h'; $content = file_get_contents($file); preg_match('(^#define PHP_MAJOR_VERSION (?\d+)$)m', $content, $matches); - $major = $matches['num']; + $major = (int) $matches['num']; preg_match('(^#define PHP_MINOR_VERSION (?\d+)$)m', $content, $matches); - $minor = $matches['num']; - return ['major' => $major, 'minor' => $minor]; + $minor = (int) $matches['num']; + return [$major, $minor]; } $trigger = $argv[1] ?? 'schedule'; $attempt = (int) ($argv[2] ?? 1); -$discard_cache = ($trigger === 'schedule' && $attempt !== 1) || $trigger === 'workflow_dispatch'; +$monday = date('w', time()) === '1'; +$discard_cache = $monday + || ($trigger === 'schedule' && $attempt !== 1) + || $trigger === 'workflow_dispatch'; if ($discard_cache) { @unlink(get_branch_commit_cache_file_path()); } $branch = $argv[3] ?? 'master'; - $branches = $branch === 'master' ? get_branches() - : [['name' => strtoupper($branch), 'ref' => $branch, 'version' => get_current_version()]]; -$matrix_include = get_matrix_include($branches); -$windows_matrix_include = get_windows_matrix_include($branches); -$macos_matrix_include = get_macos_matrix_include($branches); -$alpine_matrix_include = get_alpine_matrix_include($branches); + : [['ref' => $branch, 'version' => get_current_version()]]; $f = fopen(getenv('GITHUB_OUTPUT'), 'a'); fwrite($f, 'branches=' . json_encode($branches, JSON_UNESCAPED_SLASHES) . "\n"); -fwrite($f, 'matrix-include=' . json_encode($matrix_include, JSON_UNESCAPED_SLASHES) . "\n"); -fwrite($f, 'windows-matrix-include=' . json_encode($windows_matrix_include, JSON_UNESCAPED_SLASHES) . "\n"); -fwrite($f, 'macos-matrix-include=' . json_encode($macos_matrix_include, JSON_UNESCAPED_SLASHES) . "\n"); -fwrite($f, 'alpine-matrix-include=' . json_encode($alpine_matrix_include, JSON_UNESCAPED_SLASHES) . "\n"); fclose($f); diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index bb1755769e9ca..b87b7389ef02d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,53 +1,37 @@ -name: Nightly +name: Test suite on: - schedule: - - cron: "0 1 * * *" - workflow_dispatch: ~ + workflow_call: + inputs: + asan_ubuntu_version: + required: true + type: string + branch: + required: true + type: string + community_verify_type_inference: + required: true + type: boolean + libmysqlclient_with_mysqli: + required: true + type: boolean + run_alpine: + required: true + type: boolean + run_macos_arm64: + required: true + type: boolean + ubuntu_version: + required: true + type: string + windows_version: + required: true + type: string permissions: contents: read jobs: - GENERATE_MATRIX: - name: Generate Matrix - if: github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch' - runs-on: ubuntu-latest - outputs: - branches: ${{ steps.set-matrix.outputs.branches }} - matrix-include: ${{ steps.set-matrix.outputs.matrix-include }} - windows-matrix-include: ${{ steps.set-matrix.outputs.windows-matrix-include }} - macos-matrix-include: ${{ steps.set-matrix.outputs.macos-matrix-include }} - alpine-matrix-include: ${{ steps.set-matrix.outputs.alpine-matrix-include }} - steps: - - uses: actions/checkout@v4 - 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 - with: - path: branch-commit-cache.json - # The cache key needs to change every time for the - # cache to be updated after this job finishes. - key: nightly-${{ github.run_id }}-${{ github.run_attempt }} - restore-keys: | - nightly- - - name: Generate Matrix - id: set-matrix - run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.head_ref || github.ref_name }}" - - name: Notify Slack - if: failure() - uses: ./.github/actions/notify-slack - with: - token: ${{ secrets.ACTION_MONITORING_SLACK }} ALPINE: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} - strategy: - fail-fast: false - matrix: - include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.alpine-matrix-include) }} - name: "${{ matrix.branch.name }}_ALPINE_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" + if: inputs.run_alpine + name: ALPINE_X64_ASAN_UBSAN_DEBUG_ZTS runs-on: ubuntu-22.04 container: image: 'alpine:3.20.1' @@ -55,11 +39,10 @@ jobs: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: apk uses: ./.github/actions/apk - name: LLVM 17 (ASAN-only) - if: ${{ matrix.asan }} # libclang_rt.asan-x86_64.a is provided by compiler-rt, and only for clang17: # https://pkgs.alpinelinux.org/contents?file=libclang_rt.asan-x86_64.a&path=&name=&branch=v3.20 run: | @@ -76,21 +59,23 @@ jobs: uses: ./.github/actions/configure-alpine with: configurationParameters: >- - ${{ matrix.configuration_parameters }} - --${{ matrix.debug && 'enable' || 'disable' }}-debug - --${{ matrix.zts && 'enable' || 'disable' }}-zts - skipSlow: ${{ matrix.asan }} + CFLAGS="-fsanitize=undefined,address -fno-sanitize=function -DZEND_TRACK_ARENA_ALLOC" + LDFLAGS="-fsanitize=undefined,address -fno-sanitize=function" + CC=clang-17 + CXX=clang++-17 + --enable-debug + --enable-zts + skipSlow: true # FIXME: This should likely include slow extensions - name: make run: make -j$(/usr/bin/nproc) >/dev/null - name: make install uses: ./.github/actions/install-alpine - name: Test Tracing JIT - if: matrix.test_jit uses: ./.github/actions/test-alpine with: jitType: tracing runTestsParameters: >- - ${{ matrix.run_tests_parameters }} + --asan -x -d zend_extension=opcache.so -d opcache.enable_cli=1 - name: Notify Slack @@ -100,8 +85,6 @@ jobs: token: ${{ secrets.ACTION_MONITORING_SLACK }} LINUX_X64: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} services: mysql: image: mysql:8.3 @@ -128,21 +111,45 @@ jobs: strategy: fail-fast: false matrix: - branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} configuration_parameters: [''] debug: [true, false] name: [''] run_tests_parameters: [''] test_function_jit: [true] zts: [true, false] - include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.matrix-include) }} - name: "${{ matrix.branch.name }}_LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" - runs-on: ubuntu-${{ (matrix.branch.version.minor >= 3 && !matrix.asan) && '22.04' || '20.04' }} + include: + - name: _ASAN_UBSAN + debug: true + zts: true + configuration_parameters: >- + CFLAGS="-fsanitize=undefined,address -DZEND_TRACK_ARENA_ALLOC" + LDFLAGS="-fsanitize=undefined,address" + run_tests_parameters: '--asan' + test_function_jit: false + asan: true + - name: _REPEAT + debug: true + zts: false + run_tests_parameters: --repeat 2 + timeout_minutes: 360 + test_function_jit: true + asan: false + - name: _VARIATION + debug: true + zts: true + configuration_parameters: >- + CFLAGS="-DZEND_RC_DEBUG=1 -DPROFITABILITY_CHECKS=0 -DZEND_VERIFY_FUNC_INFO=1 -DZEND_VERIFY_TYPE_INFERENCE" + run_tests_parameters: -d zend_test.observer.enabled=1 -d zend_test.observer.show_output=0 + timeout_minutes: 360 + test_function_jit: true + asan: false + name: "LINUX_X64${{ matrix.name }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" + runs-on: ubuntu-${{ matrix.asan && inputs.asan_ubuntu_version || inputs.ubuntu_version }} steps: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: Create MSSQL container uses: ./.github/actions/setup-mssql - name: apt @@ -211,18 +218,15 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} LINUX_X32: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} strategy: fail-fast: false matrix: - branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} debug: [true, false] zts: [true, false] - name: "${{ matrix.branch.name }}_LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" + name: "LINUX_X32_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" runs-on: ubuntu-latest container: - image: ubuntu:${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }} + image: ubuntu:${{ inputs.ubuntu_version }} services: mysql: image: mysql:8.3 @@ -235,7 +239,7 @@ jobs: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: apt uses: ./.github/actions/apt-x32 - name: System info @@ -290,19 +294,21 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} MACOS: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} strategy: fail-fast: false matrix: - include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.macos-matrix-include) }} - name: "${{ matrix.branch.name }}_MACOS_${{ matrix.arch }}_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" + debug: [true, false] + zts: [true, false] + os: ['13', '14'] + 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 }} steps: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: brew uses: ./.github/actions/brew - name: ./configure @@ -320,7 +326,7 @@ jobs: - name: Test uses: ./.github/actions/test-macos - name: Test Tracing JIT - if: matrix.test_jit + if: matrix.os != '14' || !matrix.zts uses: ./.github/actions/test-macos with: jitType: tracing @@ -334,7 +340,7 @@ jobs: -d zend_extension=opcache.so -d opcache.enable_cli=1 - name: Test Function JIT - if: matrix.test_jit + if: matrix.os != '14' || !matrix.zts uses: ./.github/actions/test-macos with: jitType: function @@ -349,7 +355,7 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} COVERAGE_DEBUG_NTS: - if: github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch' + if: inputs.branch == 'master' services: mysql: image: mysql:8.3 @@ -377,6 +383,8 @@ jobs: steps: - name: git checkout uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} - name: Create MSSQL container uses: ./.github/actions/setup-mssql - name: apt @@ -413,20 +421,14 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} COMMUNITY: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} strategy: fail-fast: false matrix: - branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} type: ['asan', 'verify_type_inference'] - # These branches don't include type verification exclude: - - { branch: { name: 'PHP-8.1', ref: 'PHP-8.1', major: 8, minor: 1 }, type: 'verify_type_inference' } - - { branch: { name: 'PHP-8.2', ref: 'PHP-8.2', major: 8, minor: 2 }, type: 'verify_type_inference' } - - { branch: { name: 'PHP-8.3', ref: 'PHP-8.3', major: 8, minor: 3 }, type: 'verify_type_inference' } - name: "${{ matrix.branch.name }}_COMMUNITY_${{ matrix.type }}" - runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }} + - type: ${{ !inputs.community_verify_type_inference && 'verify_type_inference' || '*never*' }} + name: "COMMUNITY_${{ matrix.type }}" + runs-on: ubuntu-${{ inputs.ubuntu_version }} env: ASAN_OPTIONS: exitcode=139 UBSAN_OPTIONS: print_stacktrace=1 @@ -436,7 +438,7 @@ jobs: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: apt uses: ./.github/actions/apt-x64 - name: ./configure @@ -601,8 +603,6 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} OPCACHE_VARIATION: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} services: mysql: image: mysql:8.3 @@ -626,17 +626,13 @@ jobs: FIREBIRD_DATABASE: test.fdb FIREBIRD_USER: test FIREBIRD_PASSWORD: test - strategy: - fail-fast: false - matrix: - branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} - name: "${{ matrix.branch.name }}_OPCACHE_VARIATION" - runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }} + name: OPCACHE_VARIATION + runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: Create MSSQL container uses: ./.github/actions/setup-mssql - name: apt @@ -698,19 +694,13 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} MSAN: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} - strategy: - fail-fast: false - matrix: - branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} - name: "${{ matrix.branch.name }}_MSAN" - runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }} + name: MSAN + runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: apt uses: ./.github/actions/apt-x64 - name: ./configure @@ -796,19 +786,13 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} LIBMYSQLCLIENT: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} - strategy: - fail-fast: false - matrix: - branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} - name: "${{ matrix.branch.name }}_LIBMYSQLCLIENT" - runs-on: ubuntu-${{ matrix.branch.version.minor >= 3 && '22.04' || '20.04' }} + name: LIBMYSQLCLIENT + runs-on: ubuntu-${{ inputs.ubuntu_version }} steps: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: apt run: | sudo apt-get update -y | true @@ -822,23 +806,23 @@ jobs: - name: Build mysql-8.0 uses: ./.github/actions/build-libmysqlclient with: - configurationParameters: --enable-werror + configurationParameters: ${{ !inputs.libmysqlclient_with_mysqli && '--enable-werror' || '' }} libmysql: mysql-8.0.37-linux-glibc2.28-x86_64.tar.xz - withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }} + withMysqli: ${{ inputs.libmysqlclient_with_mysqli }} - name: Test mysql-8.0 uses: ./.github/actions/test-libmysqlclient with: - withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }} + withMysqli: ${{ inputs.libmysqlclient_with_mysqli }} - name: Build mysql-8.4 uses: ./.github/actions/build-libmysqlclient with: - configurationParameters: --enable-werror + configurationParameters: ${{ !inputs.libmysqlclient_with_mysqli && '--enable-werror' || '' }} libmysql: mysql-8.4.0-linux-glibc2.28-x86_64.tar.xz - withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }} + withMysqli: ${{ inputs.libmysqlclient_with_mysqli }} - name: Test mysql-8.4 uses: ./.github/actions/test-libmysqlclient with: - withMysqli: ${{ matrix.branch.ref == 'PHP-8.1' }} + withMysqli: ${{ inputs.libmysqlclient_with_mysqli }} - name: Verify generated files are up to date uses: ./.github/actions/verify-generated-files - name: Notify Slack @@ -847,7 +831,7 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} PECL: - if: github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch' + if: inputs.branch == 'master' runs-on: ubuntu-22.04 env: CC: ccache gcc @@ -857,6 +841,7 @@ jobs: uses: actions/checkout@v4 with: path: php + ref: ${{ inputs.branch }} - name: git checkout apcu uses: actions/checkout@v4 with: @@ -958,20 +943,24 @@ jobs: with: token: ${{ secrets.ACTION_MONITORING_SLACK }} WINDOWS: - needs: GENERATE_MATRIX - if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} strategy: fail-fast: false matrix: - include: ${{ fromJson(needs.GENERATE_MATRIX.outputs.windows-matrix-include) }} - name: "${{ matrix.branch.name }}_WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" - runs-on: ${{ (matrix.branch.version.minor >= 4) && 'windows-2022' || 'windows-2019' }} + include: + - x64: true + zts: true + opcache: true + - x64: false + zts: false + opcache: false + name: "WINDOWS_${{ matrix.x64 && 'X64' || 'X86' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}" + runs-on: windows-${{ inputs.windows_version }} env: 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_CRT: ${{ (matrix.branch.version.minor >= 4) && 'vs17' || 'vs16' }} + PHP_BUILD_CRT: ${{ inputs.windows_version == '2022' && 'vs17' || 'vs16' }} PLATFORM: ${{ matrix.x64 && 'x64' || 'x86' }} THREAD_SAFE: "${{ matrix.zts && '1' || '0' }}" INTRINSICS: "${{ matrix.zts && 'AVX2' || '' }}" @@ -983,7 +972,7 @@ jobs: - name: git checkout uses: actions/checkout@v4 with: - ref: ${{ matrix.branch.ref }} + ref: ${{ inputs.branch }} - name: Setup uses: ./.github/actions/setup-windows - name: Build diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 684934c7073ee..6baf80d5f84b0 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -78,7 +78,7 @@ jobs: zts: true asan: true name: "LINUX_X64_${{ matrix.debug && 'DEBUG' || 'RELEASE' }}_${{ matrix.zts && 'ZTS' || 'NTS' }}${{ matrix.asan && '_ASAN' || '' }}" - runs-on: ubuntu-${{ !matrix.asan && '22' || '24' }}.04 + runs-on: ubuntu-24.04 timeout-minutes: 50 steps: - name: git checkout @@ -142,7 +142,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 50 container: - image: ubuntu:20.04 + image: ubuntu:24.04 env: MYSQL_TEST_HOST: mysql PDO_MYSQL_TEST_DSN: mysql:host=mysql;dbname=test @@ -255,7 +255,7 @@ jobs: BENCHMARKING: name: BENCHMARKING if: github.repository == 'php/php-src' || github.event_name == 'pull_request' - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 timeout-minutes: 50 steps: - name: git checkout diff --git a/.github/workflows/root.yml b/.github/workflows/root.yml new file mode 100644 index 0000000000000..cefabd0394a46 --- /dev/null +++ b/.github/workflows/root.yml @@ -0,0 +1,62 @@ +name: Nightly +on: + schedule: + - cron: "0 1 * * *" + workflow_dispatch: ~ +permissions: + contents: read +jobs: + GENERATE_MATRIX: + name: Generate Matrix + if: github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + outputs: + branches: ${{ steps.set-matrix.outputs.branches }} + steps: + - uses: actions/checkout@v4 + 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 + with: + path: branch-commit-cache.json + # The cache key needs to change every time for the + # cache to be updated after this job finishes. + key: nightly-${{ github.run_id }}-${{ github.run_attempt }} + restore-keys: | + nightly- + - name: Generate Matrix + id: set-matrix + run: php .github/nightly_matrix.php "${{ github.event_name }}" "${{ github.run_attempt }}" "${{ github.head_ref || github.ref_name }}" + - name: Notify Slack + if: failure() + uses: ./.github/actions/notify-slack + with: + token: ${{ secrets.ACTION_MONITORING_SLACK }} + NIGHTLY: + needs: GENERATE_MATRIX + name: ${{ matrix.branch.ref }} + if: ${{ needs.GENERATE_MATRIX.outputs.branches != '[]' }} + uses: ./.github/workflows/nightly.yml + strategy: + fail-fast: false + matrix: + branch: ${{ fromJson(needs.GENERATE_MATRIX.outputs.branches) }} + with: + asan_ubuntu_version: ${{ + (((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 5) || matrix.branch.version[0] >= 9) && '24.04') + || '20.04' }} + 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) }} + run_alpine: ${{ (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 }} + ubuntu_version: ${{ + (((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 5) || matrix.branch.version[0] >= 9) && '24.04') + || ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 3) && '22.04') + || '20.04' }} + windows_version: ${{ ((matrix.branch.version[0] == 8 && matrix.branch.version[1] >= 4) || matrix.branch.version[0] >= 9) && '2022' || '2019' }} + secrets: inherit diff --git a/EXTENSIONS b/EXTENSIONS index 4081f85adf64f..6c3a83b8d9124 100644 --- a/EXTENSIONS +++ b/EXTENSIONS @@ -184,7 +184,8 @@ SINCE: 5.0 ------------------------------------------------------------------------------- EXTENSION: soap PRIMARY MAINTAINER: Dmitry Stogov (2004 - 2018) -MAINTENANCE: Maintained + Niels Dossche (2024 - 2024) +MAINTENANCE: Odd fixes STATUS: Working ------------------------------------------------------------------------------- EXTENSION: xml diff --git a/NEWS b/NEWS index 01bc51d2a757f..bce8cb9ea040b 100644 --- a/NEWS +++ b/NEWS @@ -5,11 +5,19 @@ PHP NEWS - COM: . Fix property access of PHP objects wrapped in variant. (cmb) +- Core: + . Fixed bug GH-16665 (\array and \callable should not be usable in + class_alias). (nielsdos) + - Curl: . Added curl_multi_get_handles(). (timwolla) - DOM: . Added Dom\Element::$outerHTML. (nielsdos) + . Added Dom\Element::insertAdjacentHTML(). (nielsdos) + +- Intl: + . Bumped ICU requirement to ICU >= 57.1. (cmb) - Output: . Fixed calculation of aligned buffer size. (cmb) @@ -25,13 +33,33 @@ PHP NEWS its name to be reused. (David Carlier) . Added Iterable support for pgsql_copy_from. (David Carlier) +- POSIX: + . Added POSIX_SC_OPEN_MAX constant to get the number of file descriptors + a process can handle. (David Carlier) + - Random: . Moves from /dev/urandom usage to arc4random_buf on Haiku. (David Carlier) +- Reflection: + . Added ReflectionConstant::getExtension() and ::getExtensionName(). + (DanielEScherzer) + - SOAP: . Fixed bug #49169 (SoapServer calls wrong function, although "SOAP action" header is correct). (nielsdos) +- Sockets: + . Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage. + (David Carlier) + +- Standard: + . Fixed crypt() tests on musl when using --with-external-libcrypt + (Michael Orlitzky). + +- Windows: + . Fixed bug GH-10992 (Improper long path support for relative paths). (cmb, + nielsdos) + - XMLWriter: . Improved performance and reduce memory consumption. (nielsdos) diff --git a/UPGRADING b/UPGRADING index 110080e2ee425..0a2eb2867489c 100644 --- a/UPGRADING +++ b/UPGRADING @@ -25,6 +25,13 @@ PHP 8.5 UPGRADE NOTES . bzcompress() now throws a ValueError when $work_factor is not between 0 and 250. +- Core: + . It is no longer possible to use "array" and "callable" as class alias names + in class_alias(). + +- Intl: + . The extension now requires at least ICU 57.1. + - LDAP: . ldap_get_option() and ldap_set_option() now throw a ValueError when passing an invalid option. @@ -56,6 +63,11 @@ PHP 8.5 UPGRADE NOTES 4. Deprecated Functionality ======================================== +- 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 + ======================================== 5. Changed Functions ======================================== @@ -83,11 +95,19 @@ PHP 8.5 UPGRADE NOTES attached to a CurlMultiHandle. This includes both handles added using curl_multi_add_handle() and handles accepted by CURLMOPT_PUSHFUNCTION. +- DOM: + . Added Dom\Element::insertAdjacentHTML(). + - 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. +- Reflection: + . ReflectionConstant::getFileName() was introduced. + . ReflectionConstant::getExtension() and + ReflectionConstant::getExtensionName() were introduced. + ======================================== 7. New Classes and Interfaces ======================================== @@ -100,10 +120,21 @@ PHP 8.5 UPGRADE NOTES 9. Other Changes to Extensions ======================================== +- Readline: + . The return types of readline_add_history(), readline_clear_history(), and + readline_callback_handler_install() have been changed to true, rather + than bool. + ======================================== 10. New Global Constants ======================================== +- POSIX: + . POSIX_SC_OPEN_MAX. + +- Sockets: + . IPPROTO_ICMP/IPPROTO_ICMPV6. + ======================================== 11. Changes to INI File Handling ======================================== @@ -116,6 +147,11 @@ PHP 8.5 UPGRADE NOTES PHP_RELEASE_VERSION are now always numbers. Previously, they have been strings for buildconf builds. +* 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. + ======================================== 13. Other Changes ======================================== diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index 5f1647f8e45f6..6c0256f7ae88a 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -22,6 +22,9 @@ PHP 8.5 INTERNALS UPGRADE NOTES 3. Module changes ======================== +- ext/libxml + . The refcount APIs now return an `unsigned int` instead of an `int`. + ======================== 4. OpCode changes ======================== diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index e457c24b18aa2..7169238893159 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -3959,6 +3959,9 @@ static zend_always_inline zend_result _zend_update_type_info( } else { zend_arg_info *ret_info = op_array->arg_info - 1; tmp = zend_fetch_arg_info_type(script, ret_info, &ce); + if ((tmp & MAY_BE_NULL) && opline->op1_type == IS_CV) { + tmp |= MAY_BE_UNDEF; + } tmp |= (t1 & MAY_BE_INDIRECT); // TODO: We could model more precisely how illegal types are converted. diff --git a/Zend/tests/abstract_implicit.phpt b/Zend/tests/abstract_implicit.phpt new file mode 100644 index 0000000000000..1ccd4d3653fcb --- /dev/null +++ b/Zend/tests/abstract_implicit.phpt @@ -0,0 +1,19 @@ +--TEST-- +Abstract methods not allowed in classes that are not abstract (GH-16067) +--FILE-- + +--EXPECTF-- +Fatal error: Class NotAbstract declares abstract method bar() and must therefore be declared abstract in %s on line %d diff --git a/Zend/tests/anon/gh16067.phpt b/Zend/tests/anon/gh16067.phpt new file mode 100644 index 0000000000000..dc09d14964a5a --- /dev/null +++ b/Zend/tests/anon/gh16067.phpt @@ -0,0 +1,11 @@ +--TEST-- +Compiler prevents explicit `abstract` methods on anonymous classes +--FILE-- + +--EXPECTF-- +Fatal error: Anonymous class method f() must not be abstract in %s on line 4 diff --git a/Zend/tests/enum/no-abstract.phpt b/Zend/tests/enum/no-abstract.phpt new file mode 100644 index 0000000000000..2593d67e44de5 --- /dev/null +++ b/Zend/tests/enum/no-abstract.phpt @@ -0,0 +1,12 @@ +--TEST-- +Compiler prevents `abstract` methods on enums classes (GH-16067) +--FILE-- + +--EXPECTF-- +Fatal error: Enum method Example::foo() must not be abstract in %s on line 4 diff --git a/Zend/tests/errmsg/errmsg_018.phpt b/Zend/tests/errmsg/errmsg_018.phpt index 070247e4d419c..e94f99446ce10 100644 --- a/Zend/tests/errmsg/errmsg_018.phpt +++ b/Zend/tests/errmsg/errmsg_018.phpt @@ -10,4 +10,4 @@ class test { echo "Done\n"; ?> --EXPECTF-- -Fatal error: Class test contains 1 abstract method and must therefore be declared abstract or implement the remaining method (test::foo) in %s on line %d +Fatal error: Class test declares abstract method foo() and must therefore be declared abstract in %s on line %d diff --git a/Zend/tests/gh16508.phpt b/Zend/tests/gh16508.phpt new file mode 100644 index 0000000000000..2330cf083ce77 --- /dev/null +++ b/Zend/tests/gh16508.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-16508: Missing lineno in inheritance errors of delayed early bound classes +--EXTENSIONS-- +opcache +--INI-- +opcache.enable_cli=1 +--FILE-- + +--EXPECTF-- +Fatal error: Class Test2 contains 1 abstract method and must therefore be declared abstract or implement the remaining method (Test::foo) in %s on line 5 diff --git a/Zend/tests/gh16509.inc b/Zend/tests/gh16509.inc new file mode 100644 index 0000000000000..297699fb671ea --- /dev/null +++ b/Zend/tests/gh16509.inc @@ -0,0 +1,7 @@ + +--FILE-- + +--EXPECTF-- +Fatal error: Cannot redeclare function test() (previously declared in %sgh16509.inc:3) in %sgh16509.inc on line 3 diff --git a/Zend/tests/gh16515.phpt b/Zend/tests/gh16515.phpt new file mode 100644 index 0000000000000..63bb447e7ba2e --- /dev/null +++ b/Zend/tests/gh16515.phpt @@ -0,0 +1,16 @@ +--TEST-- +GH-16515: Incorrect propagation of ZEND_ACC_RETURN_REFERENCE for call trampoline +--FILE-- +bar(...)); + +?> +--EXPECTF-- +Notice: Only variable references should be returned by reference in %s on line %d diff --git a/Zend/tests/gh16615_001.phpt b/Zend/tests/gh16615_001.phpt new file mode 100644 index 0000000000000..a6bb2c743d473 --- /dev/null +++ b/Zend/tests/gh16615_001.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-16615 001 (Assertion failure in zend_std_read_property) +--FILE-- + $value; + } +} + +$reflector = new ReflectionClass(Foo::class); + +// Adds IS_PROP_LAZY to prop flags +$foo = $reflector->newLazyGhost(function ($ghost) { + $ghost->bar = 'bar'; +}); + +echo $foo->bar; + +?> +--EXPECT-- +bar diff --git a/Zend/tests/gh16615_002.phpt b/Zend/tests/gh16615_002.phpt new file mode 100644 index 0000000000000..eff3398f27753 --- /dev/null +++ b/Zend/tests/gh16615_002.phpt @@ -0,0 +1,24 @@ +--TEST-- +GH-16615 002 (Assertion failure in zend_std_read_property) +--FILE-- + $value; + } + public function __clone() { + try { + echo $this->bar; + } catch (Error $e) { + printf("%s: %s\n", $e::class, $e->getMessage()); + } + } +} + +// Adds IS_PROP_REINITABLE to prop flags +clone new Foo(); + +?> +--EXPECT-- +Error: Typed property Foo::$bar must not be accessed before initialization diff --git a/Zend/tests/gh16648.phpt b/Zend/tests/gh16648.phpt new file mode 100644 index 0000000000000..9fdceba959456 --- /dev/null +++ b/Zend/tests/gh16648.phpt @@ -0,0 +1,49 @@ +--TEST-- +GH-16648: Use-after-free during array sorting +--FILE-- + '1', '3' => new C, '2' => '2']; +asort($arr); +var_dump($arr); + +?> +--EXPECT-- +array(11) { + ["a"]=> + string(1) "1" + [3]=> + int(3) + [2]=> + int(2) + [0]=> + int(0) + [1]=> + int(1) + [4]=> + int(4) + [5]=> + int(5) + [6]=> + int(6) + [7]=> + int(7) + [8]=> + int(8) + [9]=> + int(9) +} diff --git a/Zend/tests/gh16665_1.phpt b/Zend/tests/gh16665_1.phpt new file mode 100644 index 0000000000000..5baa46a039121 --- /dev/null +++ b/Zend/tests/gh16665_1.phpt @@ -0,0 +1,8 @@ +--TEST-- +GH-16665 (\array should not be usable) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use "array" as a class alias as it is reserved in %s on line %d diff --git a/Zend/tests/gh16665_2.phpt b/Zend/tests/gh16665_2.phpt new file mode 100644 index 0000000000000..3b8ffd4c1e6b0 --- /dev/null +++ b/Zend/tests/gh16665_2.phpt @@ -0,0 +1,8 @@ +--TEST-- +GH-16665 (\callable should not be usable) +--FILE-- + +--EXPECTF-- +Fatal error: Cannot use "callable" as a class alias as it is reserved in %s on line %d diff --git a/Zend/tests/gh16799.phpt b/Zend/tests/gh16799.phpt new file mode 100644 index 0000000000000..ce1dbd5b16558 --- /dev/null +++ b/Zend/tests/gh16799.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-16799 (Assertion failure at Zend/zend_vm_execute.h) +--FILE-- + +--EXPECTF-- +Fatal error: Uncaught Exception: Use of "static" in callables is deprecated in %s:%d +Stack trace: +#0 %s(%d): {closure:%s:%d}(8192, 'Use of "static"...', %s, %d) +#1 %s(%d): Test::test() +#2 {main} + thrown in %s on line %d diff --git a/Zend/tests/lazy_objects/init_ast_const.phpt b/Zend/tests/lazy_objects/init_ast_const.phpt deleted file mode 100644 index 018c46e4915e5..0000000000000 --- a/Zend/tests/lazy_objects/init_ast_const.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Lazy objects: Class constants are updated before initialization ---FILE-- -newLazyGhost(function () { }); - -function f() { - define('FOO', new stdClass); -} - -f(); - -try { - var_dump($c->a); -} catch (\Error $e) { - printf("%s: %s\n", $e::class, $e->getMessage()); -} - ---EXPECTF-- -object(stdClass)#%d (0) { -} diff --git a/Zend/tests/lazy_objects/init_ast_const_failure.phpt b/Zend/tests/lazy_objects/init_ast_const_failure.phpt deleted file mode 100644 index d3f1ca0f35f5c..0000000000000 --- a/Zend/tests/lazy_objects/init_ast_const_failure.phpt +++ /dev/null @@ -1,26 +0,0 @@ ---TEST-- -Lazy objects: Class constants are updated before initialization: update constant failure ---FILE-- -newLazyGhost(function () { }); - -function f() { - define('FOO', new stdClass); -} - -f(); - -try { - var_dump($c->a); -} catch (\Error $e) { - printf("%s: %s\n", $e::class, $e->getMessage()); -} - ---EXPECT-- -TypeError: Cannot assign stdClass to property C::$a of type C diff --git a/Zend/tests/lazy_objects/isLazy.phpt b/Zend/tests/lazy_objects/isLazy.phpt new file mode 100644 index 0000000000000..691b42b708dbc --- /dev/null +++ b/Zend/tests/lazy_objects/isLazy.phpt @@ -0,0 +1,140 @@ +--TEST-- +Lazy Objects: ReflectionProperty::isLazy() +--FILE-- +dynamic = 1; + $pr = new ReflectionProperty($tmp, $name); + } else { + $pr = $reflector->getProperty($name); + } + printf("%s: %d\n", $name, $pr->isLazy($obj)); + } +} + +$reflector = new ReflectionClass(C::class); + +print "# Ghost\n"; + +$obj = $reflector->newLazyGhost(function () { }); + +testProps($reflector, $obj); + +$pr = $reflector->getProperty('typed'); +$pr->skipLazyInitialization($obj); +printf("typed (skipped): %d\n", $pr->isLazy($obj)); + +print "# Initialized Ghost\n"; + +$reflector->initializeLazyObject($obj); + +testProps($reflector, $obj); + +print "# Proxy\n"; + +$obj = $reflector->newLazyProxy(function () { + return new C(); +}); + +testProps($reflector, $obj); + +$pr = $reflector->getProperty('typed'); +$pr->skipLazyInitialization($obj); +printf("typed (skipped prop): %d\n", $pr->isLazy($obj)); + +print "# Initialized Proxy\n"; + +$reflector->initializeLazyObject($obj); + +testProps($reflector, $obj); + +print "# Nested Proxy\n"; + +$nested = new C(); +$obj = $reflector->newLazyProxy(function () use ($nested) { + return $nested; +}); +$reflector->initializeLazyObject($obj); +$reflector->resetAsLazyProxy($nested, function () { + return new C(); +}); + +testProps($reflector, $obj); + +print "# Nested Proxy (nested initialized)\n"; + +$nested = new C(); +$obj = $reflector->newLazyProxy(function () use ($nested) { + return $nested; +}); +$reflector->initializeLazyObject($obj); +$reflector->resetAsLazyProxy($nested, function () { + return new C(); +}); +$reflector->initializeLazyObject($nested); + +testProps($reflector, $obj); + +print "# Internal\n"; + +$obj = (new DateTime())->diff(new DateTime()); +$reflector = new ReflectionClass(DateInterval::class); +$pr = new ReflectionProperty($obj, 'y'); +printf("y: %d\n", $pr->isLazy($obj)); + +?> +--EXPECT-- +# Ghost +staticProp: 0 +typed: 1 +untyped: 1 +virtual: 0 +dynamic: 0 +typed (skipped): 0 +# Initialized Ghost +staticProp: 0 +typed: 0 +untyped: 0 +virtual: 0 +dynamic: 0 +# Proxy +staticProp: 0 +typed: 1 +untyped: 1 +virtual: 0 +dynamic: 0 +typed (skipped prop): 0 +# Initialized Proxy +staticProp: 0 +typed: 0 +untyped: 0 +virtual: 0 +dynamic: 0 +# Nested Proxy +staticProp: 0 +typed: 1 +untyped: 1 +virtual: 0 +dynamic: 0 +# Nested Proxy (nested initialized) +staticProp: 0 +typed: 0 +untyped: 0 +virtual: 0 +dynamic: 0 +# Internal +y: 0 diff --git a/Zend/tests/lazy_objects/oss_fuzz_71407.phpt b/Zend/tests/lazy_objects/oss_fuzz_71407.phpt new file mode 100644 index 0000000000000..09b4febcde2c2 --- /dev/null +++ b/Zend/tests/lazy_objects/oss_fuzz_71407.phpt @@ -0,0 +1,22 @@ +--TEST-- +oss-fuzz #71407 +--FILE-- +newLazyGhost(function() {}); + clone $obj; +} catch (Error $e) { + printf("%s: %s\n", $e::class, $e->getMessage()); +} + + +?> +--EXPECT-- +Error: Undefined constant "x" diff --git a/Zend/zend.c b/Zend/zend.c index b4fd4fd269c8a..b4a084b1f95c7 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -832,6 +832,8 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{ executor_globals->record_errors = false; executor_globals->num_errors = 0; executor_globals->errors = NULL; + executor_globals->filename_override = NULL; + executor_globals->lineno_override = -1; #ifdef ZEND_CHECK_STACK_LIMIT executor_globals->stack_limit = (void*)0; executor_globals->stack_base = (void*)0; @@ -1210,6 +1212,10 @@ void zend_shutdown(void) /* {{{ */ CG(script_encoding_list) = NULL; CG(script_encoding_list_size) = 0; } + if (CG(internal_run_time_cache)) { + pefree(CG(internal_run_time_cache), 1); + CG(internal_run_time_cache) = NULL; + } #endif zend_map_ptr_static_last = 0; zend_map_ptr_static_size = 0; diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 997733b6a5e44..629aa7d51a840 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -871,7 +871,7 @@ void zend_closure_from_frame(zval *return_value, zend_execute_data *call) { /* { memset(&trampoline, 0, sizeof(zend_internal_function)); trampoline.type = ZEND_INTERNAL_FUNCTION; - trampoline.fn_flags = mptr->common.fn_flags & (ZEND_ACC_STATIC | ZEND_ACC_VARIADIC); + trampoline.fn_flags = mptr->common.fn_flags & (ZEND_ACC_STATIC | ZEND_ACC_VARIADIC | ZEND_ACC_RETURN_REFERENCE); trampoline.handler = zend_closure_call_magic; trampoline.function_name = mptr->common.function_name; trampoline.scope = mptr->common.scope; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ae50c29dffad6..fb436bdc20eab 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -214,6 +214,10 @@ static const struct reserved_class_name reserved_class_names[] = { {ZEND_STRL("iterable")}, {ZEND_STRL("object")}, {ZEND_STRL("mixed")}, + /* These are not usable as class names because they're proper tokens, + * but they are here for class aliases. */ + {ZEND_STRL("array")}, + {ZEND_STRL("callable")}, {NULL, 0} }; @@ -1278,7 +1282,7 @@ static zend_never_inline ZEND_COLD ZEND_NORETURN void do_bind_function_error(zen zend_error_noreturn(error_level, "Cannot redeclare function %s() (previously declared in %s:%d)", op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name), ZSTR_VAL(old_function->op_array.filename), - old_function->op_array.opcodes[0].lineno); + old_function->op_array.line_start); } else { zend_error_noreturn(error_level, "Cannot redeclare function %s()", op_array ? ZSTR_VAL(op_array->function_name) : ZSTR_VAL(old_function->common.function_name)); @@ -3709,6 +3713,7 @@ static uint32_t zend_get_arg_num(zend_function *fn, zend_string *arg_name) { } } } 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); @@ -8067,6 +8072,22 @@ static zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string zend_error(E_COMPILE_WARNING, "Private methods cannot be final as they are never overridden by other classes"); } + if ((fn_flags & ZEND_ACC_ABSTRACT) + && !(ce->ce_flags & (ZEND_ACC_EXPLICIT_ABSTRACT_CLASS|ZEND_ACC_TRAIT))) { + // Don't say that the class should be declared abstract if it is + // anonymous or an enum and can't be abstract + if (ce->ce_flags & ZEND_ACC_ANON_CLASS) { + zend_error_noreturn(E_COMPILE_ERROR, "Anonymous class method %s() must not be abstract", + ZSTR_VAL(name)); + } else if (ce->ce_flags & (ZEND_ACC_ENUM|ZEND_ACC_INTERFACE)) { + zend_error_noreturn(E_COMPILE_ERROR, "%s method %s::%s() must not be abstract", + zend_get_object_type_case(ce, true), ZSTR_VAL(ce->name), ZSTR_VAL(name)); + } else { + zend_error_noreturn(E_COMPILE_ERROR, "Class %s declares abstract method %s() and must therefore be declared abstract", + ZSTR_VAL(ce->name), ZSTR_VAL(name)); + } + } + if (in_interface) { if (!(fn_flags & ZEND_ACC_PUBLIC)) { zend_error_noreturn(E_COMPILE_ERROR, "Access type for interface method " @@ -8076,10 +8097,6 @@ static zend_string *zend_begin_method_decl(zend_op_array *op_array, zend_string zend_error_noreturn(E_COMPILE_ERROR, "Interface method " "%s::%s() must not be final", ZSTR_VAL(ce->name), ZSTR_VAL(name)); } - if (fn_flags & ZEND_ACC_ABSTRACT) { - zend_error_noreturn(E_COMPILE_ERROR, "Interface method " - "%s::%s() must not be abstract", ZSTR_VAL(ce->name), ZSTR_VAL(name)); - } op_array->fn_flags |= ZEND_ACC_ABSTRACT; } @@ -8362,6 +8379,7 @@ static zend_op_array *zend_compile_func_decl_ex( } else if (toplevel) { /* Only register the function after a successful compile */ if (UNEXPECTED(zend_hash_add_ptr(CG(function_table), lcname, op_array) == NULL)) { + CG(zend_lineno) = decl->start_lineno; do_bind_function_error(lcname, op_array, true); } } @@ -9145,7 +9163,13 @@ static void zend_compile_class_decl(znode *result, zend_ast *ast, bool toplevel) } opline->op1_type = IS_CONST; - LITERAL_STR(opline->op1, lcname); + /* It's possible that `lcname` is not an interned string because it was not yet in the interned string table. + * However, by this point another thread may have caused `lcname` to be added in the interned string table. + * This will cause `lcname` to get freed once it is found in the interned string table. If we were to use + * LITERAL_STR() here we would not change the `lcname` pointer to the new value, and it would point to the + * now-freed string. This will cause issues when we use `lcname` in the code below. We solve this by using + * zend_add_literal_string() which gives us the new value. */ + opline->op1.constant = zend_add_literal_string(&lcname); if (decl->flags & ZEND_ACC_ANON_CLASS) { opline->opcode = ZEND_DECLARE_ANON_CLASS; diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index d453b8bb73717..4d9a769f1de3a 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -46,12 +46,18 @@ void free_zend_constant(zval *zv) if (c->name) { zend_string_release_ex(c->name, 0); } + if (c->filename) { + zend_string_release_ex(c->filename, 0); + } efree(c); } else { zval_internal_ptr_dtor(&c->value); if (c->name) { zend_string_release_ex(c->name, 1); } + if (c->filename) { + zend_string_release_ex(c->filename, 1); + } free(c); } } @@ -68,6 +74,9 @@ static void copy_zend_constant(zval *zv) c = Z_PTR_P(zv); c->name = zend_string_copy(c->name); + if (c->filename != NULL) { + c->filename = zend_string_copy(c->filename); + } if (Z_TYPE(c->value) == IS_STRING) { Z_STR(c->value) = zend_string_dup(Z_STR(c->value), 1); } @@ -495,6 +504,14 @@ ZEND_API zend_result zend_register_constant(zend_constant *c) name = c->name; } + c->filename = NULL; + if (ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT) { + zend_string *filename = zend_get_executed_filename_ex(); + if (filename) { + c->filename = zend_string_copy(filename); + } + } + /* Check if the user is trying to define any special constant */ if (zend_string_equals_literal(name, "__COMPILER_HALT_OFFSET__") || (!persistent && zend_get_special_const(ZSTR_VAL(name), ZSTR_LEN(name))) @@ -502,6 +519,10 @@ ZEND_API zend_result zend_register_constant(zend_constant *c) ) { zend_error(E_WARNING, "Constant %s already defined", ZSTR_VAL(name)); zend_string_release(c->name); + if (c->filename) { + zend_string_release(c->filename); + c->filename = NULL; + } if (!persistent) { zval_ptr_dtor_nogc(&c->value); } diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h index 6f0710c0ce63e..fbefe0011ae1e 100644 --- a/Zend/zend_constants.h +++ b/Zend/zend_constants.h @@ -33,6 +33,7 @@ typedef struct _zend_constant { zval value; zend_string *name; + zend_string *filename; } zend_constant; #define ZEND_CONSTANT_FLAGS(c) \ diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c index f532c07e4e679..c66509c50eaed 100644 --- a/Zend/zend_exceptions.c +++ b/Zend/zend_exceptions.c @@ -529,7 +529,7 @@ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */ } /* }}} */ -static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /* {{{ */ +static void _build_trace_string(smart_str *str, const HashTable *ht, uint32_t num) /* {{{ */ { zval *file, *tmp; @@ -539,14 +539,14 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /* file = zend_hash_find_known_hash(ht, ZSTR_KNOWN(ZEND_STR_FILE)); if (file) { - if (Z_TYPE_P(file) != IS_STRING) { + if (UNEXPECTED(Z_TYPE_P(file) != IS_STRING)) { zend_error(E_WARNING, "File name is not a string"); smart_str_appends(str, "[unknown file]: "); } else{ zend_long line = 0; tmp = zend_hash_find_known_hash(ht, ZSTR_KNOWN(ZEND_STR_LINE)); if (tmp) { - if (Z_TYPE_P(tmp) == IS_LONG) { + if (EXPECTED(Z_TYPE_P(tmp) == IS_LONG)) { line = Z_LVAL_P(tmp); } else { zend_error(E_WARNING, "Line is not an int"); @@ -566,7 +566,7 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /* smart_str_appendc(str, '('); tmp = zend_hash_find_known_hash(ht, ZSTR_KNOWN(ZEND_STR_ARGS)); if (tmp) { - if (Z_TYPE_P(tmp) == IS_ARRAY) { + if (EXPECTED(Z_TYPE_P(tmp) == IS_ARRAY)) { size_t last_len = ZSTR_LEN(str->s); zend_string *name; zval *arg; @@ -590,14 +590,14 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /* } /* }}} */ -ZEND_API zend_string *zend_trace_to_string(HashTable *trace, bool include_main) { +ZEND_API zend_string *zend_trace_to_string(const HashTable *trace, bool include_main) { zend_ulong index; zval *frame; uint32_t num = 0; smart_str str = {0}; ZEND_HASH_FOREACH_NUM_KEY_VAL(trace, index, frame) { - if (Z_TYPE_P(frame) != IS_ARRAY) { + if (UNEXPECTED(Z_TYPE_P(frame) != IS_ARRAY)) { zend_error(E_WARNING, "Expected array for frame " ZEND_ULONG_FMT, index); continue; } @@ -624,7 +624,7 @@ ZEND_METHOD(Exception, getTraceAsString) zval *object = ZEND_THIS; zend_class_entry *base_ce = i_get_exception_base(Z_OBJ_P(object)); zval rv; - zval *trace = zend_read_property_ex(base_ce, Z_OBJ_P(object), ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv); + const zval *trace = zend_read_property_ex(base_ce, Z_OBJ_P(object), ZSTR_KNOWN(ZEND_STR_TRACE), 1, &rv); if (EG(exception)) { RETURN_THROWS(); } @@ -859,14 +859,13 @@ ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception ZEND_API ZEND_COLD zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format, ...) /* {{{ */ { va_list arg; - char *message; zend_object *obj; va_start(arg, format); - zend_vspprintf(&message, 0, format, arg); + zend_string *msg_str = zend_vstrpprintf(0, format, arg); va_end(arg); - obj = zend_throw_exception(exception_ce, message, code); - efree(message); + obj = zend_throw_exception_zstr(exception_ce, msg_str, code); + zend_string_release(msg_str); return obj; } /* }}} */ diff --git a/Zend/zend_exceptions.h b/Zend/zend_exceptions.h index b80c17d8f38f2..d0138021d1ea3 100644 --- a/Zend/zend_exceptions.h +++ b/Zend/zend_exceptions.h @@ -72,7 +72,7 @@ extern ZEND_API void (*zend_throw_exception_hook)(zend_object *ex); /* show an exception using zend_error(severity,...), severity should be E_ERROR */ ZEND_API ZEND_COLD zend_result zend_exception_error(zend_object *exception, int severity); ZEND_NORETURN void zend_exception_uncaught_error(const char *prefix, ...) ZEND_ATTRIBUTE_FORMAT(printf, 1, 2); -ZEND_API zend_string *zend_trace_to_string(HashTable *trace, bool include_main); +ZEND_API zend_string *zend_trace_to_string(const HashTable *trace, bool include_main); ZEND_API ZEND_COLD zend_object *zend_create_unwind_exit(void); ZEND_API ZEND_COLD zend_object *zend_create_graceful_exit(void); diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index ba398e18ae078..44021b785ba95 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -5304,6 +5304,7 @@ static zend_always_inline uint32_t zend_get_arg_offset_by_name( } } } 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); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 6a8ae805fc256..a1fbe049f3f99 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -505,8 +505,8 @@ ZEND_API zend_result ZEND_FASTCALL zend_handle_undef_args(zend_execute_data *cal } \ } while (0) -#define ZEND_CLASS_HAS_TYPE_HINTS(ce) ((ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS) == ZEND_ACC_HAS_TYPE_HINTS) -#define ZEND_CLASS_HAS_READONLY_PROPS(ce) ((ce->ce_flags & ZEND_ACC_HAS_READONLY_PROPS) == ZEND_ACC_HAS_READONLY_PROPS) +#define ZEND_CLASS_HAS_TYPE_HINTS(ce) ((bool)(ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS)) +#define ZEND_CLASS_HAS_READONLY_PROPS(ce) ((bool)(ce->ce_flags & ZEND_ACC_HAS_READONLY_PROPS)) ZEND_API bool zend_verify_class_constant_type(zend_class_constant *c, const zend_string *name, zval *constant); diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index f42479cf745d2..9ebc15f3a43fb 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -299,6 +299,9 @@ ZEND_API void zend_shutdown_executor_values(bool fast_shutdown) if (c->name) { zend_string_release_ex(c->name, 0); } + if (c->filename) { + zend_string_release_ex(c->filename, 0); + } efree(c); zend_string_release_ex(key, 0); } ZEND_HASH_MAP_FOREACH_END_DEL(); diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 46dff9bfd29e0..8bddb0c208835 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -2973,13 +2973,12 @@ ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q) q->h = h; } -ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, bucket_compare_func_t compar, bool renumber) +static void zend_hash_sort_internal(HashTable *ht, sort_func_t sort, bucket_compare_func_t compar, bool renumber) { Bucket *p; uint32_t i, j; IS_CONSISTENT(ht); - HT_ASSERT_RC1(ht); if (!(ht->nNumOfElements>1) && !(renumber && ht->nNumOfElements>0)) { /* Doesn't require sorting */ @@ -3066,6 +3065,33 @@ ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, b } } +ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort, bucket_compare_func_t compar, bool renumber) +{ + HT_ASSERT_RC1(ht); + zend_hash_sort_internal(ht, sort, compar, renumber); +} + +ZEND_API void ZEND_FASTCALL zend_array_sort_ex(HashTable *ht, sort_func_t sort, bucket_compare_func_t compar, bool renumber) +{ + HT_ASSERT_RC1(ht); + + /* Unpack the array early to avoid RCn assertion failures. */ + if (HT_IS_PACKED(ht)) { + zend_hash_packed_to_hash(ht); + } + + /* Adding a refcount prevents the array from going away. */ + GC_ADDREF(ht); + + zend_hash_sort_internal(ht, sort, compar, renumber); + + if (UNEXPECTED(GC_DELREF(ht) == 0)) { + zend_array_destroy(ht); + } else { + gc_check_possible_root((zend_refcounted *)ht); + } +} + static zend_always_inline int zend_hash_compare_impl(const HashTable *ht1, const HashTable *ht2, compare_func_t compar, bool ordered) { uint32_t idx1, idx2; zend_string *key1, *key2; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index 58a2537ff845c..5865c735eec48 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -299,12 +299,20 @@ ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q); typedef int (*bucket_compare_func_t)(Bucket *a, Bucket *b); ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered); ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber); +ZEND_API void ZEND_FASTCALL zend_array_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber); ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag); static zend_always_inline void ZEND_FASTCALL zend_hash_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) { zend_hash_sort_ex(ht, zend_sort, compare_func, renumber); } +/* Use this variant over zend_hash_sort() when sorting user arrays that may + * trigger user code. It will ensure the user code cannot free the array during + * sorting. */ +static zend_always_inline void zend_array_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) { + zend_array_sort_ex(ht, zend_sort, compare_func, renumber); +} + static zend_always_inline uint32_t zend_hash_num_elements(const HashTable *ht) { return ht->nNumOfElements; } diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 16af5f0ac61a9..3e09206b31566 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -2281,7 +2281,7 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_ * of where it is coming from there is no conflict and we do not need to add it again */ if (existing_fn->op_array.opcodes == fn->op_array.opcodes && (existing_fn->common.fn_flags & ZEND_ACC_PPP_MASK) == (fn->common.fn_flags & ZEND_ACC_PPP_MASK) && - (existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { + (existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT)) { return; } @@ -2347,7 +2347,7 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_ static void zend_fixup_trait_method(zend_function *fn, zend_class_entry *ce) /* {{{ */ { - if ((fn->common.scope->ce_flags & ZEND_ACC_TRAIT) == ZEND_ACC_TRAIT) { + if (fn->common.scope->ce_flags & ZEND_ACC_TRAIT) { fn->common.scope = ce; @@ -3849,6 +3849,8 @@ ZEND_API zend_class_entry *zend_try_early_bind(zend_class_entry *ce, zend_class_ CG(current_linking_class) = is_cacheable ? ce : NULL; zend_try{ + CG(zend_lineno) = ce->info.user.line_start; + if (is_cacheable) { zend_begin_record_errors(); } diff --git a/Zend/zend_lazy_objects.c b/Zend/zend_lazy_objects.c index 94be396f580f8..e6dd6144d4b5c 100644 --- a/Zend/zend_lazy_objects.c +++ b/Zend/zend_lazy_objects.c @@ -259,6 +259,13 @@ ZEND_API zend_object *zend_object_make_lazy(zend_object *obj, return NULL; } + if (UNEXPECTED(!(reflection_ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) { + if (UNEXPECTED(zend_update_class_constants(reflection_ce) != SUCCESS)) { + ZEND_ASSERT(EG(exception)); + return NULL; + } + } + obj = zend_objects_new(reflection_ce); for (int i = 0; i < obj->ce->default_properties_count; i++) { @@ -373,12 +380,7 @@ ZEND_API zend_object *zend_lazy_object_mark_as_initialized(zend_object *obj) zend_class_entry *ce = obj->ce; - if (UNEXPECTED(!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) { - if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) { - ZEND_ASSERT(EG(exception)); - return NULL; - } - } + ZEND_ASSERT(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED); zval *default_properties_table = CE_DEFAULT_PROPERTIES_TABLE(ce); zval *properties_table = obj->properties_table; @@ -568,12 +570,7 @@ ZEND_API zend_object *zend_lazy_object_init(zend_object *obj) zend_class_entry *ce = obj->ce; - if (UNEXPECTED(!(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED))) { - if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) { - ZEND_ASSERT(EG(exception)); - return NULL; - } - } + ZEND_ASSERT(ce->ce_flags & ZEND_ACC_CONSTANTS_UPDATED); if (zend_object_is_lazy_proxy(obj)) { return zend_lazy_object_init_proxy(obj); diff --git a/Zend/zend_max_execution_timer.h b/Zend/zend_max_execution_timer.h index 789f50e6b7dcd..6557d6c918455 100644 --- a/Zend/zend_max_execution_timer.h +++ b/Zend/zend_max_execution_timer.h @@ -21,8 +21,10 @@ #include "zend_long.h" +BEGIN_EXTERN_C() /* Must be called after calls to fork() */ ZEND_API void zend_max_execution_timer_init(void); +END_EXTERN_C() void zend_max_execution_timer_settime(zend_long seconds); void zend_max_execution_timer_shutdown(void); diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 6f5cc8b45214c..f08685092745a 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -791,7 +791,7 @@ ZEND_API zval *zend_std_read_property(zend_object *zobj, zend_string *name, int if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) { /* As hooked properties can't be unset, the only way to end up with an undef * value is via an uninitialized property. */ - ZEND_ASSERT(Z_PROP_FLAG_P(retval) == IS_PROP_UNINIT); + ZEND_ASSERT(Z_PROP_FLAG_P(retval) & IS_PROP_UNINIT); goto uninit_error; } @@ -1614,7 +1614,10 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce func->arg_flags[0] = 0; func->arg_flags[1] = 0; func->arg_flags[2] = 0; - func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE | ZEND_ACC_PUBLIC | ZEND_ACC_VARIADIC; + func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE + | ZEND_ACC_PUBLIC + | ZEND_ACC_VARIADIC + | (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE); if (is_static) { func->fn_flags |= ZEND_ACC_STATIC; } diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index f4609428326c7..9ab46f9b32cfe 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -47,6 +47,9 @@ #include "../TSRM/TSRM.h" #include +#if ZEND_DEBUG && defined(NDEBUG) +# error "NDEBUG must not be defined when ZEND_DEBUG is enabled" +#endif #include #include @@ -512,6 +515,13 @@ extern "C++" { # undef HAVE_FUNC_ATTRIBUTE_IFUNC #endif +#if __has_feature(memory_sanitizer) +# include +# define MSAN_UNPOISON(value) __msan_unpoison(&(value), sizeof(value)) +#else +# define MSAN_UNPOISON(value) +#endif + /* Only use ifunc resolvers if we have __builtin_cpu_supports() and __builtin_cpu_init(), * otherwise the use of zend_cpu_supports() may not be safe inside ifunc resolvers. */ #if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) && \ diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index 8115e041c0c3e..88b905ffeab40 100644 --- a/Zend/zend_strtod.c +++ b/Zend/zend_strtod.c @@ -3605,13 +3605,20 @@ rv_alloc(i) int i; rv_alloc(int i) #endif { - int k, *r; - size_t j = sizeof(ULong); + int j, k, *r; + size_t rem; + + rem = sizeof(Bigint) - sizeof(ULong) - sizeof(int); + + + j = sizeof(ULong); + if (i > ((INT_MAX >> 2) + rem)) + i = (INT_MAX >> 2) + rem; for(k = 0; - sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (size_t)i; - j <<= 1) + rem + j <= (size_t)i; j <<= 1) k++; + r = (int*)Balloc(k); *r = k; return diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index e19c503379319..7e471b5acd8b6 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3634,7 +3634,7 @@ ZEND_VM_HOT_OBJ_HANDLER(112, ZEND_INIT_METHOD_CALL, CONST|TMPVAR|UNUSED|THIS|CV, fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((OP2_TYPE == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } FREE_OP2(); if ((OP1_TYPE & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -3918,6 +3918,16 @@ ZEND_VM_HANDLER(118, ZEND_INIT_USER_CALL, CONST, CONST|TMPVAR|CV, NUM) function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) { ZEND_ASSERT(!error); + + /* Deprecation can be emitted from zend_is_callable_ex(), which can + * invoke a user error handler and throw an exception. + * For the CONST and CV case we reuse the same exception block below + * to make sure we don't increase VM size too much. */ + if (!(OP2_TYPE & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) { + FREE_OP2(); + HANDLE_EXCEPTION(); + } + func = fcc.function_handler; object_or_called_scope = fcc.called_scope; if (func->common.fn_flags & ZEND_ACC_CLOSURE) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index af9ea669b6b4f..9209399a5cdbf 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -7220,7 +7220,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -7423,6 +7423,16 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CONS function_name = RT_CONSTANT(opline, opline->op2); if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) { ZEND_ASSERT(!error); + + /* Deprecation can be emitted from zend_is_callable_ex(), which can + * invoke a user error handler and throw an exception. + * For the CONST and CV case we reuse the same exception block below + * to make sure we don't increase VM size too much. */ + if (!(IS_CONST & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) { + + HANDLE_EXCEPTION(); + } + func = fcc.function_handler; object_or_called_scope = fcc.called_scope; if (func->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -9784,7 +9794,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -9987,6 +9997,16 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_TMPV function_name = _get_zval_ptr_var(opline->op2.var EXECUTE_DATA_CC); if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) { ZEND_ASSERT(!error); + + /* Deprecation can be emitted from zend_is_callable_ex(), which can + * invoke a user error handler and throw an exception. + * For the CONST and CV case we reuse the same exception block below + * to make sure we don't increase VM size too much. */ + if (!((IS_TMP_VAR|IS_VAR) & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) { + zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); + HANDLE_EXCEPTION(); + } + func = fcc.function_handler; object_or_called_scope = fcc.called_scope; if (func->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -12266,7 +12286,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_ fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if ((IS_CONST & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -12469,6 +12489,16 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_USER_CALL_SPEC_CONST_CV_H function_name = _get_zval_ptr_cv_BP_VAR_R(opline->op2.var EXECUTE_DATA_CC); if (zend_is_callable_ex(function_name, NULL, 0, NULL, &fcc, &error)) { ZEND_ASSERT(!error); + + /* Deprecation can be emitted from zend_is_callable_ex(), which can + * invoke a user error handler and throw an exception. + * For the CONST and CV case we reuse the same exception block below + * to make sure we don't increase VM size too much. */ + if (!(IS_CV & (IS_TMP_VAR|IS_VAR)) && UNEXPECTED(EG(exception))) { + + HANDLE_EXCEPTION(); + } + func = fcc.function_handler; object_or_called_scope = fcc.called_scope; if (func->common.fn_flags & ZEND_ACC_CLOSURE) { @@ -16659,7 +16689,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -18152,7 +18182,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_T fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -19559,7 +19589,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_TMPVAR_C fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if (((IS_TMP_VAR|IS_VAR) & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -34945,7 +34975,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -37114,7 +37144,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_T fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -39759,7 +39789,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_UNUSED_C fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if ((IS_UNUSED & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -44875,7 +44905,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_S fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CONST == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -48769,7 +48799,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_TMPVA fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), (((IS_TMP_VAR|IS_VAR) == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } zval_ptr_dtor_nogc(EX_VAR(opline->op2.var)); if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { @@ -54364,7 +54394,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_INIT_METHOD_CALL_SPEC_CV_CV_HA fbc = obj->handlers->get_method(&obj, Z_STR_P(function_name), ((IS_CV == IS_CONST) ? (RT_CONSTANT(opline, opline->op2) + 1) : NULL)); if (UNEXPECTED(fbc == NULL)) { if (EXPECTED(!EG(exception))) { - zend_undefined_method(obj->ce, Z_STR_P(function_name)); + zend_undefined_method(orig_obj->ce, Z_STR_P(function_name)); } if ((IS_CV & (IS_VAR|IS_TMP_VAR)) && GC_DELREF(orig_obj) == 0) { diff --git a/build/gen_stub.php b/build/gen_stub.php index c3f6330ae3637..c32f53678d1e2 100755 --- a/build/gen_stub.php +++ b/build/gen_stub.php @@ -1686,7 +1686,7 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str $undocumentedEntity = $doc->createEntityReference('warn.undocumented.func'); $descriptionRefSec->appendChild($undocumentedEntity); $descriptionRefSec->appendChild(new DOMText("\n ")); - $returnDescriptionPara = $doc->createElement('para'); + $returnDescriptionPara = $doc->createElement('simpara'); $returnDescriptionPara->appendChild(new DOMText("\n Description.\n ")); $descriptionRefSec->appendChild($returnDescriptionPara); @@ -1709,7 +1709,7 @@ public function getMethodSynopsisDocument(array $funcMap, array $aliasMap): ?str $errorsDescriptionParaConstantTag->append('E_*'); $errorsDescriptionParaExceptionTag = $doc->createElement('exceptionname'); $errorsDescriptionParaExceptionTag->append('Exception'); - $errorsDescriptionPara = $doc->createElement('para'); + $errorsDescriptionPara = $doc->createElement('simpara'); $errorsDescriptionPara->append( "\n When does this function issue ", $errorsDescriptionParaConstantTag, @@ -1813,20 +1813,19 @@ private function getParameterSection(DOMDocument $doc): DOMElement { $parametersRefSec->appendChild($noParamEntity); return $parametersRefSec; } else { - $parametersPara = $doc->createElement('para'); - $parametersRefSec->appendChild($parametersPara); + $parametersContainer = $doc->createDocumentFragment(); - $parametersPara->appendChild(new DOMText("\n ")); + $parametersContainer->appendChild(new DOMText("\n ")); $parametersList = $doc->createElement('variablelist'); - $parametersPara->appendChild($parametersList); + $parametersContainer->appendChild($parametersList); /* name - + Description. - + */ @@ -1835,35 +1834,36 @@ private function getParameterSection(DOMDocument $doc): DOMElement { $parameterTerm = $doc->createElement('term'); $parameterTerm->appendChild($parameter); - $listItemPara = $doc->createElement('para'); + $listItemPara = $doc->createElement('simpara'); $listItemPara->append( - "\n ", - "Description.", "\n ", + "Description.", + "\n ", ); $parameterEntryListItem = $doc->createElement('listitem'); $parameterEntryListItem->append( - "\n ", - $listItemPara, "\n ", + $listItemPara, + "\n ", ); $parameterEntry = $doc->createElement('varlistentry'); $parameterEntry->append( - "\n ", + "\n ", $parameterTerm, - "\n ", - $parameterEntryListItem, "\n ", + $parameterEntryListItem, + "\n ", ); - $parametersList->appendChild(new DOMText("\n ")); + $parametersList->appendChild(new DOMText("\n ")); $parametersList->appendChild($parameterEntry); } - $parametersList->appendChild(new DOMText("\n ")); + $parametersList->appendChild(new DOMText("\n ")); } - $parametersPara->appendChild(new DOMText("\n ")); + $parametersContainer->appendChild(new DOMText("\n ")); + $parametersRefSec->appendChild($parametersContainer); $parametersRefSec->appendChild(new DOMText("\n ")); return $parametersRefSec; } @@ -1871,7 +1871,7 @@ private function getParameterSection(DOMDocument $doc): DOMElement { private function getReturnValueSection(DOMDocument $doc): DOMElement { $returnRefSec = $this->generateRefSect1($doc, 'returnvalues'); - $returnDescriptionPara = $doc->createElement('para'); + $returnDescriptionPara = $doc->createElement('simpara'); $returnDescriptionPara->appendChild(new DOMText("\n ")); $returnType = $this->return->getMethodSynopsisType(); @@ -2010,7 +2010,7 @@ private function getExampleSection(DOMDocument $doc, string $id): DOMElement { $example->append("\n ", $title); - $para = $doc->createElement('para'); + $para = $doc->createElement('simpara'); $para->append("\n ", "Description.", "\n "); $example->append("\n ", $para); diff --git a/build/genif.sh b/build/genif.sh index 697bef95912e4..f6d6fff953476 100755 --- a/build/genif.sh +++ b/build/genif.sh @@ -32,7 +32,7 @@ header_list= olddir=$(pwd) # Go to project root. -cd $(CDPATH= cd -- "$(dirname -- "$0")/../" && pwd -P) +cd "$(CDPATH='' cd -- "$(dirname -- "$0")/../" && pwd -P)" || exit module_ptrs="$(echo $extensions | $AWK -f ./build/order_by_dep.awk)" diff --git a/build/php.m4 b/build/php.m4 index e45b22b7665fc..53684cf011d9a 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1779,7 +1779,7 @@ dnl dnl Common setup macro for ICU. dnl AC_DEFUN([PHP_SETUP_ICU],[ - PKG_CHECK_MODULES([ICU], [icu-uc >= 50.1 icu-io icu-i18n]) + PKG_CHECK_MODULES([ICU], [icu-uc >= 57.1 icu-io icu-i18n]) PHP_EVAL_INCLINE([$ICU_CFLAGS]) PHP_EVAL_LIBLINE([$ICU_LIBS], [$1]) diff --git a/buildconf b/buildconf index 51ef423abcf2d..0586cbf0cd274 100755 --- a/buildconf +++ b/buildconf @@ -8,9 +8,9 @@ force=0 debug=0 # Go to project root. -cd $(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) +cd "$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)" || exit -php_extra_version=$(grep '^AC_INIT(' configure.ac) +php_extra_version=$(grep '^AC_INIT(' configure.ac) || exit case "$php_extra_version" in *-dev*) dev=1 diff --git a/configure.ac b/configure.ac index 56c22f1a80f5d..01d9ded69b920 100644 --- a/configure.ac +++ b/configure.ac @@ -799,6 +799,8 @@ PHP_ARG_ENABLE([debug], AS_VAR_IF([PHP_DEBUG], [yes], [ PHP_DEBUG=1 ZEND_DEBUG=yes + CFLAGS="$CFLAGS -UNDEBUG" + CXXFLAGS="$CXXFLAGS -UNDEBUG" PHP_REMOVE_OPTIMIZATION_FLAGS dnl Add -O0 only if GCC or ICC is used. if test "$GCC" = "yes" || test "$ICC" = "yes"; then @@ -817,6 +819,8 @@ AS_VAR_IF([PHP_DEBUG], [yes], [ ], [ PHP_DEBUG=0 ZEND_DEBUG=no + CFLAGS="$CFLAGS -DNDEBUG" + CXXFLAGS="$CXXFLAGS -DNDEBUG" ]) PHP_ARG_ENABLE([debug-assertions], @@ -829,6 +833,8 @@ PHP_ARG_ENABLE([debug-assertions], AS_VAR_IF([PHP_DEBUG_ASSERTIONS], [yes], [ PHP_DEBUG=1 ZEND_DEBUG=yes + CFLAGS="$CFLAGS -UNDEBUG" + CXXFLAGS="$CXXFLAGS -UNDEBUG" ]) AC_ARG_ENABLE([zts], diff --git a/ext/bcmath/libbcmath/src/div.c b/ext/bcmath/libbcmath/src/div.c index 35ca450ceb78c..9c8344fe771a8 100644 --- a/ext/bcmath/libbcmath/src/div.c +++ b/ext/bcmath/libbcmath/src/div.c @@ -434,7 +434,7 @@ bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale) numerator_bottom_extension -= scale_diff; } else { numerator_bottom_extension = 0; - numeratorend -= scale_diff - numerator_bottom_extension; + numeratorend -= scale_diff > numerator_top_extension ? scale_diff - numerator_top_extension : 0; } } else { numerator_bottom_extension += scale - numerator_scale; @@ -444,6 +444,11 @@ bool bc_divide(bc_num numerator, bc_num divisor, bc_num *quot, size_t scale) /* Length of numerator data that can be read */ size_t numerator_readable_len = numeratorend - numeratorptr + 1; + if (divisor_len > numerator_readable_len + numerator_bottom_extension) { + *quot = bc_copy_num(BCG(_zero_)); + return true; + } + /* If divisor is 1 here, return the result of adjusting the decimal point position of numerator. */ if (divisor_len == 1 && *divisorptr == 1) { if (numerator_len == 0) { diff --git a/ext/bcmath/tests/gh16262.phpt b/ext/bcmath/tests/gh16262.phpt new file mode 100644 index 0000000000000..e932bae2301ab --- /dev/null +++ b/ext/bcmath/tests/gh16262.phpt @@ -0,0 +1,158 @@ +--TEST-- +GH-16262 Stack buffer overflow in ext/bcmath/libbcmath/src/div.c:459 +--EXTENSIONS-- +bcmath +--INI-- +bcmath.scale=0 +--FILE-- +div('1000', $scale), + ); + echo "1 / 2000:\n"; + var_dump( + bcdiv('1', '2000', $scale), + (new BcMath\Number('1'))->div('2000', $scale), + ); + echo "\n"; +} +?> +--EXPECT-- +========== scale: null ========== +1 / 1000: +string(1) "0" +object(BcMath\Number)#2 (2) { + ["value"]=> + string(5) "0.001" + ["scale"]=> + int(3) +} +1 / 2000: +string(1) "0" +object(BcMath\Number)#1 (2) { + ["value"]=> + string(6) "0.0005" + ["scale"]=> + int(4) +} + +========== scale: 0 ========== +1 / 1000: +string(1) "0" +object(BcMath\Number)#2 (2) { + ["value"]=> + string(1) "0" + ["scale"]=> + int(0) +} +1 / 2000: +string(1) "0" +object(BcMath\Number)#1 (2) { + ["value"]=> + string(1) "0" + ["scale"]=> + int(0) +} + +========== scale: 1 ========== +1 / 1000: +string(3) "0.0" +object(BcMath\Number)#2 (2) { + ["value"]=> + string(3) "0.0" + ["scale"]=> + int(1) +} +1 / 2000: +string(3) "0.0" +object(BcMath\Number)#1 (2) { + ["value"]=> + string(3) "0.0" + ["scale"]=> + int(1) +} + +========== scale: 2 ========== +1 / 1000: +string(4) "0.00" +object(BcMath\Number)#2 (2) { + ["value"]=> + string(4) "0.00" + ["scale"]=> + int(2) +} +1 / 2000: +string(4) "0.00" +object(BcMath\Number)#1 (2) { + ["value"]=> + string(4) "0.00" + ["scale"]=> + int(2) +} + +========== scale: 3 ========== +1 / 1000: +string(5) "0.001" +object(BcMath\Number)#2 (2) { + ["value"]=> + string(5) "0.001" + ["scale"]=> + int(3) +} +1 / 2000: +string(5) "0.000" +object(BcMath\Number)#1 (2) { + ["value"]=> + string(5) "0.000" + ["scale"]=> + int(3) +} + +========== scale: 4 ========== +1 / 1000: +string(6) "0.0010" +object(BcMath\Number)#2 (2) { + ["value"]=> + string(6) "0.0010" + ["scale"]=> + int(4) +} +1 / 2000: +string(6) "0.0005" +object(BcMath\Number)#1 (2) { + ["value"]=> + string(6) "0.0005" + ["scale"]=> + int(4) +} + +========== scale: 5 ========== +1 / 1000: +string(7) "0.00100" +object(BcMath\Number)#2 (2) { + ["value"]=> + string(7) "0.00100" + ["scale"]=> + int(5) +} +1 / 2000: +string(7) "0.00050" +object(BcMath\Number)#1 (2) { + ["value"]=> + string(7) "0.00050" + ["scale"]=> + int(5) +} diff --git a/ext/bcmath/tests/gh16265.phpt b/ext/bcmath/tests/gh16265.phpt new file mode 100644 index 0000000000000..bc562d81df1ad --- /dev/null +++ b/ext/bcmath/tests/gh16265.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-16265 Segmentation fault (index oob) in ext/bcmath/libbcmath/src/convert.c:155 +--EXTENSIONS-- +bcmath +--INI-- +bcmath.scale=0 +--FILE-- + +--EXPECT-- +0.000000000 diff --git a/ext/calendar/gregor.c b/ext/calendar/gregor.c index dab12e5187df5..3aef7ae6ac505 100644 --- a/ext/calendar/gregor.c +++ b/ext/calendar/gregor.c @@ -148,16 +148,25 @@ void SdnToGregorian( int dayOfYear; if (sdn <= 0 || - sdn > (LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) { + sdn > (ZEND_LONG_MAX - 4 * GREGOR_SDN_OFFSET) / 4) { goto fail; } temp = (sdn + GREGOR_SDN_OFFSET) * 4 - 1; + if (temp < 0 || (temp / DAYS_PER_400_YEARS) > INT_MAX) { + goto fail; + } + /* Calculate the century (year/100). */ century = temp / DAYS_PER_400_YEARS; /* Calculate the year and day of year (1 <= dayOfYear <= 366). */ temp = ((temp % DAYS_PER_400_YEARS) / 4) * 4 + 3; + + if (century > ((INT_MAX / 100) - (temp / DAYS_PER_4_YEARS))) { + goto fail; + } + year = (century * 100) + (temp / DAYS_PER_4_YEARS); dayOfYear = (temp % DAYS_PER_4_YEARS) / 4 + 1; diff --git a/ext/calendar/tests/gh16235.phpt b/ext/calendar/tests/gh16235.phpt new file mode 100644 index 0000000000000..6b8856209828c --- /dev/null +++ b/ext/calendar/tests/gh16235.phpt @@ -0,0 +1,11 @@ +--TEST-- +GH-16235 (jdtogregorian overflow on argument) +--EXTENSIONS-- +calendar +--FILE-- + +--EXPECT-- +DONE diff --git a/ext/calendar/tests/gh16834.phpt b/ext/calendar/tests/gh16834.phpt new file mode 100644 index 0000000000000..ea9b8d0079a81 --- /dev/null +++ b/ext/calendar/tests/gh16834.phpt @@ -0,0 +1,31 @@ +--TEST-- +GH-16834 (cal_from_jd from julian_day argument) +--EXTENSIONS-- +calendar +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(9) { + ["date"]=> + string(5) "0/0/0" + ["month"]=> + int(0) + ["day"]=> + int(0) + ["year"]=> + int(0) + ["dow"]=> + int(%d) + ["abbrevdayname"]=> + string(3) "%s" + ["dayname"]=> + string(9) "%s" + ["abbrevmonth"]=> + string(0) "" + ["monthname"]=> + string(0) "" +} diff --git a/ext/com_dotnet/tests/bug77578.phpt b/ext/com_dotnet/tests/bug77578.phpt index a820935d5d775..e25230f76f497 100644 --- a/ext/com_dotnet/tests/bug77578.phpt +++ b/ext/com_dotnet/tests/bug77578.phpt @@ -6,18 +6,33 @@ com_dotnet --EXPECT-- +bool(true) array(0) { } int(0) diff --git a/ext/curl/config.w32 b/ext/curl/config.w32 index 82be5212e56b3..253c3e3cb6356 100644 --- a/ext/curl/config.w32 +++ b/ext/curl/config.w32 @@ -3,16 +3,6 @@ ARG_WITH("curl", "cURL support", "no"); if (PHP_CURL != "no") { - var ver_num = NaN; - var f = PHP_PHP_BUILD + "/include/curl/curlver.h"; - if (FSO.FileExists(f)) { - var reg = /LIBCURL_VERSION_NUM\s+(0x[a-z0-9]+)/gi; - var m = reg.exec(file_get_contents(PHP_PHP_BUILD + "/include/curl/curlver.h")); - if (!!m && m.length >= 2) { - ver_num = parseInt(m[1]); - } - } - if (CHECK_LIB("libcurl_a.lib;libcurl.lib", "curl", PHP_CURL) && CHECK_HEADER_ADD_INCLUDE("curl/easy.h", "CFLAGS_CURL") && SETUP_OPENSSL("curl", PHP_CURL) >= 2 && @@ -20,7 +10,6 @@ if (PHP_CURL != "no") { CHECK_LIB("wldap32.lib", "curl", PHP_CURL) && (((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "curl", PHP_CURL))) || (PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "curl", PHP_CURL)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED))) && - !isNaN(ver_num) && (CHECK_LIB("normaliz.lib", "curl", PHP_CURL) && CHECK_LIB("libssh2.lib", "curl", PHP_CURL) && CHECK_LIB("nghttp2.lib", "curl", PHP_CURL)) diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 677eaa8703af0..16b7c6618bc6e 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1283,13 +1283,13 @@ void _php_setup_easy_copy_handlers(php_curl *ch, php_curl *source) ch->handlers.read->res = source->handlers.read->res; if (ZEND_FCC_INITIALIZED(source->handlers.read->fcc)) { - zend_fcc_dup(&source->handlers.read->fcc, &source->handlers.read->fcc); + zend_fcc_dup(&ch->handlers.read->fcc, &source->handlers.read->fcc); } if (ZEND_FCC_INITIALIZED(source->handlers.write->fcc)) { - zend_fcc_dup(&source->handlers.write->fcc, &source->handlers.write->fcc); + zend_fcc_dup(&ch->handlers.write->fcc, &source->handlers.write->fcc); } if (ZEND_FCC_INITIALIZED(source->handlers.write_header->fcc)) { - zend_fcc_dup(&source->handlers.write_header->fcc, &source->handlers.write_header->fcc); + zend_fcc_dup(&ch->handlers.write_header->fcc, &source->handlers.write_header->fcc); } curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str); @@ -1540,7 +1540,7 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo if (Z_TYPE_P(current) == IS_ARRAY) { zval *current_element; - ZEND_HASH_FOREACH_VAL(HASH_OF(current), current_element) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(current), current_element) { add_simple_field(mime, string_key, current_element); } ZEND_HASH_FOREACH_END(); @@ -1936,7 +1936,10 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); #if LIBCURL_VERSION_NUM >= 0x075500 /* Available since 7.85.0 */ if ((option == CURLOPT_PROTOCOLS_STR || option == CURLOPT_REDIR_PROTOCOLS_STR) && - (PG(open_basedir) && *PG(open_basedir)) && php_memnistr(ZSTR_VAL(str), "file", sizeof("file") - 1, ZSTR_VAL(str) + ZSTR_LEN(str)) != NULL) { + (PG(open_basedir) && *PG(open_basedir)) + && (php_memnistr(ZSTR_VAL(str), "file", sizeof("file") - 1, ZSTR_VAL(str) + ZSTR_LEN(str)) != NULL + || php_memnistr(ZSTR_VAL(str), "all", sizeof("all") - 1, ZSTR_VAL(str) + ZSTR_LEN(str)) != NULL)) { + zend_tmp_string_release(tmp_str); php_error_docref(NULL, E_WARNING, "The FILE protocol cannot be activated when an open_basedir is set"); return FAILURE; } @@ -2186,7 +2189,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue case CURLOPT_POSTFIELDS: if (Z_TYPE_P(zvalue) == IS_ARRAY) { - if (zend_hash_num_elements(HASH_OF(zvalue)) == 0) { + if (zend_hash_num_elements(Z_ARRVAL_P(zvalue)) == 0) { /* no need to build the mime structure for empty hashtables; also works around https://github.com/curl/curl/issues/6455 */ curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, ""); diff --git a/ext/curl/tests/bug77535.phpt b/ext/curl/tests/bug77535.phpt index 522818516ae69..600bfef62b9aa 100644 --- a/ext/curl/tests/bug77535.phpt +++ b/ext/curl/tests/bug77535.phpt @@ -2,7 +2,7 @@ Bug #77535 (Invalid callback, h2 server push) --EXTENSIONS-- curl ---XLEAK-- +--XFAIL-- --SKIPIF-- --EXPECT-- +Trampoline for trampoline Array ( [0] => main response diff --git a/ext/curl/tests/curl_version_features-array.phpt b/ext/curl/tests/curl_version_features-array.phpt index b58443a92d834..3bf47cea4f3bb 100644 --- a/ext/curl/tests/curl_version_features-array.phpt +++ b/ext/curl/tests/curl_version_features-array.phpt @@ -49,6 +49,5 @@ Array [HTTPS_PROXY] => bool [MULTI_SSL] => bool [BROTLI] => bool -%A -) +%A) Complete diff --git a/ext/curl/tests/curl_writeheader_tranpoline.phpt b/ext/curl/tests/curl_writeheader_trampoline.phpt similarity index 100% rename from ext/curl/tests/curl_writeheader_tranpoline.phpt rename to ext/curl/tests/curl_writeheader_trampoline.phpt diff --git a/ext/curl/tests/gh16802.phpt b/ext/curl/tests/gh16802.phpt new file mode 100644 index 0000000000000..0fb3d4dedb170 --- /dev/null +++ b/ext/curl/tests/gh16802.phpt @@ -0,0 +1,31 @@ +--TEST-- +GH-16802 (open_basedir bypass using curl extension) +--EXTENSIONS-- +curl +--SKIPIF-- + +--INI-- +open_basedir=/nowhere +--FILE-- + +--EXPECTF-- +Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d + +Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d + +Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d + +Warning: curl_setopt(): The FILE protocol cannot be activated when an open_basedir is set in %s on line %d +bool(false) diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 95a5e5ae7364b..f1bfbfbf3f1f5 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -5487,6 +5487,10 @@ static void php_do_date_sunrise_sunset(INTERNAL_FUNCTION_PARAMETERS, bool calc_s } altitude = 90 - zenith; + if (!zend_finite(latitude) || !zend_finite(longitude)) { + RETURN_FALSE; + } + /* Initialize time struct */ tzi = get_timezone_info(); if (!tzi) { @@ -5564,6 +5568,15 @@ PHP_FUNCTION(date_sun_info) Z_PARAM_DOUBLE(longitude) ZEND_PARSE_PARAMETERS_END(); + if (!zend_finite(latitude)) { + zend_argument_value_error(2, "must be finite"); + RETURN_THROWS(); + } + if (!zend_finite(longitude)) { + zend_argument_value_error(3, "must be finite"); + RETURN_THROWS(); + } + /* Initialize time struct */ tzi = get_timezone_info(); if (!tzi) { diff --git a/ext/date/tests/gh14732.phpt b/ext/date/tests/gh14732.phpt new file mode 100644 index 0000000000000..63c626963a9d5 --- /dev/null +++ b/ext/date/tests/gh14732.phpt @@ -0,0 +1,42 @@ +--TEST-- +GH-14732 (date_sun_info() fails for non-finite values) +--FILE-- +getMessage(), "\n"; +} +try { + date_sun_info(1, -INF, 1); +} catch (ValueError $ex) { + echo $ex->getMessage(), "\n"; +} +try { + date_sun_info(1, 1, NAN); +} catch (ValueError $ex) { + echo $ex->getMessage(), "\n"; +} +try { + date_sun_info(1, 1, INF); +} catch (ValueError $ex) { + echo $ex->getMessage(), "\n"; +} +var_dump(date_sunset(1, SUNFUNCS_RET_STRING, NAN, 1)); +var_dump(date_sunrise(1, SUNFUNCS_RET_STRING, 1, NAN)); +?> +--EXPECTF-- +date_sun_info(): Argument #2 ($latitude) must be finite +date_sun_info(): Argument #2 ($latitude) must be finite +date_sun_info(): Argument #3 ($longitude) must be finite +date_sun_info(): Argument #3 ($longitude) must be finite + +Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d + +Deprecated: Function date_sunset() is deprecated since 8.1, use date_sun_info() instead in %s on line %d +bool(false) + +Deprecated: Constant SUNFUNCS_RET_STRING is deprecated in %s on line %d + +Deprecated: Function date_sunrise() is deprecated since 8.1, use date_sun_info() instead in %s on line %d +bool(false) diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 04cee6f385d48..67928864ad841 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -823,14 +823,10 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) } else { spprintf(&lock_name, 0, "%s.lck", ZSTR_VAL(connection->info->path)); if (!strcmp(file_mode, "r")) { - zend_string *opened_path = NULL; /* when in read only mode try to use existing .lck file first */ /* do not log errors for .lck file while in read only mode on .lck file */ lock_file_mode = "rb"; - connection->info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|persistent_flag, &opened_path); - if (opened_path) { - zend_string_release_ex(opened_path, 0); - } + connection->info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|persistent_flag, NULL); } if (!connection->info->lock.fp) { /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */ @@ -842,10 +838,13 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) connection->info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, &opened_path); if (connection->info->lock.fp) { if (is_db_lock) { - ZEND_ASSERT(opened_path); - /* replace the path info with the real path of the opened file */ - zend_string_release_ex(connection->info->path, persistent); - connection->info->path = php_dba_zend_string_dup_safe(opened_path, persistent); + if (opened_path) { + /* replace the path info with the real path of the opened file */ + zend_string_release_ex(connection->info->path, persistent); + connection->info->path = php_dba_zend_string_dup_safe(opened_path, persistent); + } else { + error = "Unable to determine path for locking"; + } } } if (opened_path) { @@ -862,10 +861,10 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent) zval_ptr_dtor(return_value); RETURN_FALSE; } - if (!php_stream_supports_lock(connection->info->lock.fp)) { + if (!error && !php_stream_supports_lock(connection->info->lock.fp)) { error = "Stream does not support locking"; } - if (php_stream_lock(connection->info->lock.fp, lock_mode)) { + if (!error && php_stream_lock(connection->info->lock.fp, lock_mode)) { error = "Unable to establish lock"; /* force failure exit */ } } diff --git a/ext/dba/tests/gh16390.phpt b/ext/dba/tests/gh16390.phpt new file mode 100644 index 0000000000000..0b66e742a40ab --- /dev/null +++ b/ext/dba/tests/gh16390.phpt @@ -0,0 +1,11 @@ +--TEST-- +GH-16390 (dba_open() can segfault for "pathless" streams) +--EXTENSIONS-- +dba +--FILE-- + +--EXPECTF-- +Warning: dba_open(): Driver initialization failed for handler: inifile: Unable to determine path for locking in %s on line %d diff --git a/ext/dl_test/dl_test.c b/ext/dl_test/dl_test.c index 33008a2b57205..04f013f64709f 100644 --- a/ext/dl_test/dl_test.c +++ b/ext/dl_test/dl_test.c @@ -94,6 +94,8 @@ PHP_MINIT_FUNCTION(dl_test) fprintf(stderr, "DL TEST MINIT\n"); } + register_dl_test_symbols(module_number); + return SUCCESS; } /* }}} */ diff --git a/ext/dl_test/dl_test.stub.php b/ext/dl_test/dl_test.stub.php index 524c8206365b8..2b1545175046c 100644 --- a/ext/dl_test/dl_test.stub.php +++ b/ext/dl_test/dl_test.stub.php @@ -8,3 +8,6 @@ function dl_test_test1(): void {} function dl_test_test2(string $str = ""): string {} + +/** @var int */ +const DL_TEST_CONST = 42; diff --git a/ext/dl_test/dl_test_arginfo.h b/ext/dl_test/dl_test_arginfo.h index 0b6627b19b009..276eae4ac7dce 100644 --- a/ext/dl_test/dl_test_arginfo.h +++ b/ext/dl_test/dl_test_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 547ddbc21e9aa853b491cb17e902bbbb9cc2df00 */ + * Stub hash: e1154d736a190512ecf51e30719d53e685ca5513 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl_test_test1, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() @@ -16,3 +16,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(dl_test_test2, arginfo_dl_test_test2) ZEND_FE_END }; + +static void register_dl_test_symbols(int module_number) +{ + REGISTER_LONG_CONSTANT("DL_TEST_CONST", 42, CONST_PERSISTENT); +} diff --git a/ext/dom/document.c b/ext/dom/document.c index ba5e7dab3d844..9a3975e9f0fcf 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1283,10 +1283,7 @@ PHP_METHOD(DOMDocument, __construct) } } intern->document = NULL; - if (php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp) == -1) { - /* docp is always non-null so php_libxml_increment_doc_ref() never returns -1 */ - ZEND_UNREACHABLE(); - } + php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp); php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)docp, (void *)intern); } /* }}} end DOMDocument::__construct */ @@ -1495,9 +1492,7 @@ static void php_dom_finish_loading_document(zval *this, zval *return_value, xmlD } } intern->document = NULL; - if (php_libxml_increment_doc_ref((php_libxml_node_object *)intern, newdoc) == -1) { - RETURN_FALSE; - } + php_libxml_increment_doc_ref((php_libxml_node_object *)intern, newdoc); intern->document->doc_props = doc_prop; intern->document->class_type = class_type; } diff --git a/ext/dom/documentfragment.c b/ext/dom/documentfragment.c index 74b7f073741e1..76870faedfa4c 100644 --- a/ext/dom/documentfragment.c +++ b/ext/dom/documentfragment.c @@ -73,7 +73,7 @@ PHP_METHOD(DOMDocumentFragment, appendXML) { DOM_GET_OBJ(nodep, id, xmlNodePtr, intern); - if (dom_node_is_read_only(nodep) == SUCCESS) { + if (dom_node_is_read_only(nodep)) { php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(intern->document)); RETURN_FALSE; } diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index ad7dae5b3f129..caf59137e1487 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -177,7 +177,7 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */ if (objmap->nodetype != XML_ENTITY_NODE && objmap->nodetype != XML_NOTATION_NODE) { if (objmap->nodetype == DOM_NODESET) { - HashTable *nodeht = HASH_OF(&objmap->baseobj_zv); + HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); zval *entry; zend_hash_move_forward_ex(nodeht, &iterator->pos); if ((entry = zend_hash_get_current_data_ex(nodeht, &iterator->pos))) { @@ -275,7 +275,7 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, i if (objmap->nodetype != XML_ENTITY_NODE && objmap->nodetype != XML_NOTATION_NODE) { if (objmap->nodetype == DOM_NODESET) { - nodeht = HASH_OF(&objmap->baseobj_zv); + nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); zend_hash_internal_pointer_reset_ex(nodeht, &iterator->pos); if ((entry = zend_hash_get_current_data_ex(nodeht, &iterator->pos))) { ZVAL_COPY(&iterator->curobj, entry); diff --git a/ext/dom/element.c b/ext/dom/element.c index 418096312c456..e96f4547d8f3f 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -1715,6 +1715,98 @@ PHP_METHOD(Dom_Element, insertAdjacentText) } /* }}} end DOMElement::insertAdjacentText */ +/* https://html.spec.whatwg.org/#dom-element-insertadjacenthtml */ +PHP_METHOD(Dom_Element, insertAdjacentHTML) +{ + zval *where_zv; + zend_string *string; + + dom_object *this_intern; + zval *id; + xmlNodePtr thisp; + + bool created_context = false; + + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(where_zv, dom_adjacent_position_class_entry) + Z_PARAM_STR(string) + ZEND_PARSE_PARAMETERS_END(); + + DOM_GET_THIS_OBJ(thisp, id, xmlNodePtr, this_intern); + + const zend_string *where = Z_STR_P(zend_enum_fetch_case_name(Z_OBJ_P(where_zv))); + + /* 1. We don't do injection sinks. */ + + /* 2. Let context be NULL */ + xmlNodePtr context = NULL; + + /* 3. Use the first matching item from this list: (...) */ + switch (ZSTR_LEN(where) + ZSTR_VAL(where)[2]) { + case sizeof("BeforeBegin") - 1 + 'f': + case sizeof("AfterEnd") - 1 + 't': + /* 1. Set context to this's parent. */ + context = thisp->parent; + + /* 2. If context is null or a Document, throw a "NoModificationAllowedError" DOMException. */ + if (context == NULL || context->type == XML_DOCUMENT_NODE || context->type == XML_HTML_DOCUMENT_NODE) { + php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, true); + RETURN_THROWS(); + } + break; + case sizeof("AfterBegin") - 1 + 't': + case sizeof("BeforeEnd") - 1 + 'f': + /* Set context to this. */ + context = thisp; + break; + EMPTY_SWITCH_DEFAULT_CASE(); + } + + /* 4. If context is not an Element or all of the following are true: (...) */ + if (context->type != XML_ELEMENT_NODE + || (php_dom_ns_is_html_and_document_is_html(context) && xmlStrEqual(context->name, BAD_CAST "html"))) { + /* set context to the result of creating an element given this's node document, body, and the HTML namespace. */ + xmlNsPtr html_ns = php_dom_libxml_ns_mapper_ensure_html_ns(php_dom_get_ns_mapper(this_intern)); + + context = xmlNewDocNode(thisp->doc, html_ns, BAD_CAST "body", NULL); + created_context = true; + if (UNEXPECTED(context == NULL)) { + php_dom_throw_error(INVALID_STATE_ERR, true); + goto err; + } + } + + /* 5. Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString. */ + xmlNodePtr fragment = dom_parse_fragment(this_intern, context, string); + if (fragment == NULL) { + goto err; + } + + php_libxml_invalidate_node_list_cache(this_intern->document); + + /* 6. Use the first matching item from this list: (...) */ + switch (ZSTR_LEN(where) + ZSTR_VAL(where)[2]) { + case sizeof("BeforeBegin") - 1 + 'f': + php_dom_pre_insert(this_intern->document, fragment, thisp->parent, thisp); + break; + case sizeof("AfterEnd") - 1 + 't': + php_dom_pre_insert(this_intern->document, fragment, thisp->parent, thisp->next); + break; + case sizeof("AfterBegin") - 1 + 't': + php_dom_pre_insert(this_intern->document, fragment, thisp, thisp->children); + break; + case sizeof("BeforeEnd") - 1 + 'f': + php_dom_node_append(this_intern->document, fragment, thisp); + break; + EMPTY_SWITCH_DEFAULT_CASE(); + } + +err: + if (created_context) { + xmlFreeNode(context); + } +} + /* {{{ URL: https://dom.spec.whatwg.org/#dom-element-toggleattribute Since: */ diff --git a/ext/dom/html_document.c b/ext/dom/html_document.c index 3ca812bde50b6..3e4ceeb14f2b6 100644 --- a/ext/dom/html_document.c +++ b/ext/dom/html_document.c @@ -570,12 +570,11 @@ static bool dom_decode_encode_fast_path( const lxb_char_t *buf_ref_backup = buf_ref; lxb_codepoint_t codepoint = lxb_encoding_decode_utf_8_single(&decoding_encoding_ctx->decode, &buf_ref, buf_end); if (UNEXPECTED(codepoint > LXB_ENCODING_MAX_CODEPOINT)) { - size_t skip = buf_ref - buf_ref_backup; /* Skip invalid data, it's replaced by the UTF-8 replacement bytes */ if (!dom_process_parse_chunk( ctx, document, parser, - buf_ref - last_output - skip, + buf_ref_backup - last_output, last_output, buf_ref - last_output, tokenizer_error_offset, @@ -1208,6 +1207,68 @@ static zend_result dom_write_output_stream(void *application_data, const char *b return SUCCESS; } +/* Fast path when the output encoding is UTF-8 */ +static zend_result dom_saveHTML_write_string_len_utf8_output(void *application_data, const char *buf, size_t len) +{ + dom_output_ctx *output = (dom_output_ctx *) application_data; + + output->decode->status = LXB_STATUS_OK; + + const lxb_char_t *buf_ref = (const lxb_char_t *) buf; + const lxb_char_t *last_output = buf_ref; + const lxb_char_t *buf_end = buf_ref + len; + + while (buf_ref != buf_end) { + const lxb_char_t *buf_ref_backup = buf_ref; + lxb_codepoint_t codepoint = lxb_encoding_decode_utf_8_single(output->decode, &buf_ref, buf_end); + if (UNEXPECTED(codepoint > LXB_ENCODING_MAX_CODEPOINT)) { + if (UNEXPECTED(output->write_output( + output->output_data, + (const char *) last_output, + buf_ref_backup - last_output + ) != SUCCESS)) { + return FAILURE; + } + + if (codepoint == LXB_ENCODING_DECODE_CONTINUE) { + ZEND_ASSERT(buf_ref == buf_end); + /* The decoder needs more data but the entire buffer is consumed. + * All valid data is outputted, and if the remaining data for the code point + * is invalid, the next call will output the replacement bytes. */ + output->decode->status = LXB_STATUS_CONTINUE; + return SUCCESS; + } + + if (UNEXPECTED(output->write_output( + output->output_data, + (const char *) LXB_ENCODING_REPLACEMENT_BYTES, + LXB_ENCODING_REPLACEMENT_SIZE + ) != SUCCESS)) { + return FAILURE; + } + + last_output = buf_ref; + } + } + + if (buf_ref != last_output) { + if (UNEXPECTED(output->write_output( + output->output_data, + (const char *) last_output, + buf_ref - last_output + ) != SUCCESS)) { + return FAILURE; + } + } + + return SUCCESS; +} + +static zend_result dom_saveHTML_write_string_utf8_output(void *application_data, const char *buf) +{ + return dom_saveHTML_write_string_len_utf8_output(application_data, buf, strlen(buf)); +} + static zend_result dom_saveHTML_write_string_len(void *application_data, const char *buf, size_t len) { dom_output_ctx *output = (dom_output_ctx *) application_data; @@ -1216,7 +1277,7 @@ static zend_result dom_saveHTML_write_string_len(void *application_data, const c const lxb_char_t *buf_end = buf_ref + len; do { - decode_status = output->decoding_data->decode(output->decode, &buf_ref, buf_end); + decode_status = lxb_encoding_decode_utf_8(output->decode, &buf_ref, buf_end); const lxb_codepoint_t *codepoints_ref = output->codepoints; const lxb_codepoint_t *codepoints_end = codepoints_ref + lxb_encoding_decode_buf_used(output->decode); @@ -1272,8 +1333,15 @@ static zend_result dom_common_save(dom_output_ctx *output_ctx, dom_object *inter output_ctx->encoding_output = encoding_output; dom_html5_serialize_context ctx; - ctx.write_string_len = dom_saveHTML_write_string_len; - ctx.write_string = dom_saveHTML_write_string; + if (encoding_data->encoding == LXB_ENCODING_UTF_8) { + /* Fast path */ + ctx.write_string_len = dom_saveHTML_write_string_len_utf8_output; + ctx.write_string = dom_saveHTML_write_string_utf8_output; + } else { + /* Slow path */ + ctx.write_string_len = dom_saveHTML_write_string_len; + ctx.write_string = dom_saveHTML_write_string; + } ctx.application_data = output_ctx; ctx.private_data = php_dom_get_private_data(intern); if (UNEXPECTED(dom_html5_serialize_outer(&ctx, node) != SUCCESS)) { diff --git a/ext/dom/inner_outer_html_mixin.c b/ext/dom/inner_outer_html_mixin.c index 7dc1199fdebb9..b14c3ba708ffb 100644 --- a/ext/dom/inner_outer_html_mixin.c +++ b/ext/dom/inner_outer_html_mixin.c @@ -342,7 +342,7 @@ static xmlNodePtr dom_xml_fragment_parsing_algorithm(dom_object *obj, const xmlN } /* https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm */ -static xmlNodePtr dom_parse_fragment(dom_object *obj, xmlNodePtr context_node, const zend_string *input) +xmlNodePtr dom_parse_fragment(dom_object *obj, xmlNodePtr context_node, const zend_string *input) { if (context_node->doc->type == XML_DOCUMENT_NODE) { return dom_xml_fragment_parsing_algorithm(obj, context_node, input); @@ -374,6 +374,9 @@ zend_result dom_element_inner_html_write(dom_object *obj, zval *newval) } } + ZEND_ASSERT(obj->document != NULL); + php_libxml_invalidate_node_list_cache(obj->document); + /* 5. Replace all with fragment within context. */ dom_remove_all_children(context_node); return php_dom_pre_insert(obj->document, fragment, context_node, NULL) ? SUCCESS : FAILURE; @@ -451,6 +454,9 @@ zend_result dom_element_outer_html_write(dom_object *obj, zval *newval) return FAILURE; } + ZEND_ASSERT(obj->document != NULL); + php_libxml_invalidate_node_list_cache(obj->document); + /* 7. Replace this with fragment within this's parent. */ if (!php_dom_pre_insert(obj->document, fragment, this->parent, this)) { xmlFreeNode(fragment); diff --git a/ext/dom/node.c b/ext/dom/node.c index 1a433468ede35..fc8f0a58868c0 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -837,8 +837,8 @@ static xmlNodePtr dom_insert_fragment(xmlNodePtr nodep, xmlNodePtr prevsib, xmlN static bool dom_node_check_legacy_insertion_validity(xmlNodePtr parentp, xmlNodePtr child, bool stricterror, bool warn_empty_fragment) { - if (dom_node_is_read_only(parentp) == SUCCESS || - (child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) { + if (dom_node_is_read_only(parentp) || + (child->parent != NULL && dom_node_is_read_only(child->parent))) { php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror); return false; } @@ -864,6 +864,17 @@ static bool dom_node_check_legacy_insertion_validity(xmlNodePtr parentp, xmlNode php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror); return false; } + /* Attributes must be in elements. */ + if (child->type == XML_ATTRIBUTE_NODE && parentp->type != XML_ELEMENT_NODE) { + php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror); + return false; + } + + /* Documents can never be a child. */ + if (child->type == XML_DOCUMENT_NODE || child->type == XML_HTML_DOCUMENT_NODE) { + php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror); + return false; + } return true; } @@ -884,21 +895,24 @@ static void dom_node_insert_before_legacy(zval *return_value, zval *ref, dom_obj RETURN_FALSE; } - if (child->doc == NULL && parentp->doc != NULL) { - dom_set_document_ref_pointers(child, intern->document); - } - - php_libxml_invalidate_node_list_cache(intern->document); - + xmlNodePtr refp = NULL; if (ref != NULL) { - xmlNodePtr refp; dom_object *refpobj; DOM_GET_OBJ(refp, ref, xmlNodePtr, refpobj); if (refp->parent != parentp) { php_dom_throw_error(NOT_FOUND_ERR, stricterror); RETURN_FALSE; } + } + + if (child->doc == NULL && parentp->doc != NULL) { + xmlSetTreeDoc(child, parentp->doc); + dom_set_document_ref_pointers(child, intern->document); + } + php_libxml_invalidate_node_list_cache(intern->document); + + if (ref != NULL) { if (child->parent != NULL) { xmlUnlinkNode(child); } @@ -1185,6 +1199,13 @@ static void dom_node_replace_child(INTERNAL_FUNCTION_PARAMETERS, bool modern) RETURN_FALSE; } + /* This is already disallowed by libxml, but we should check it here to avoid + * breaking assumptions and assertions. */ + if ((oldchild->type == XML_ATTRIBUTE_NODE) != (newchild->type == XML_ATTRIBUTE_NODE)) { + php_dom_throw_error(HIERARCHY_REQUEST_ERR, stricterror); + RETURN_FALSE; + } + if (oldchild->parent != nodep) { php_dom_throw_error(NOT_FOUND_ERR, stricterror); RETURN_FALSE; @@ -1192,6 +1213,7 @@ static void dom_node_replace_child(INTERNAL_FUNCTION_PARAMETERS, bool modern) } if (newchild->doc == NULL && nodep->doc != NULL) { + xmlSetTreeDoc(newchild, nodep->doc); dom_set_document_ref_pointers(newchild, intern->document); } @@ -1259,8 +1281,8 @@ static void dom_node_remove_child(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry RETURN_FALSE; } - if (dom_node_is_read_only(nodep) == SUCCESS || - (child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) { + if (dom_node_is_read_only(nodep) || + (child->parent != NULL && dom_node_is_read_only(child->parent))) { php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, stricterror); RETURN_FALSE; } @@ -1300,6 +1322,7 @@ static void dom_node_append_child_legacy(zval *return_value, dom_object *intern, } if (child->doc == NULL && nodep->doc != NULL) { + xmlSetTreeDoc(child, nodep->doc); dom_set_document_ref_pointers(child, intern->document); } @@ -2392,7 +2415,7 @@ PHP_METHOD(DOMNode, getRootNode) } /* }}} */ -/* {{{ URL: https://dom.spec.whatwg.org/#dom-node-comparedocumentposition (last check date 2023-07-24) +/* {{{ URL: https://dom.spec.whatwg.org/#dom-node-comparedocumentposition (last check date 2024-11-17) Since: */ diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index d2e05a7b736b0..819b7396b69c7 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -72,7 +72,7 @@ zend_long php_dom_get_nodelist_length(dom_object *obj) } if (objmap->nodetype == DOM_NODESET) { - HashTable *nodeht = HASH_OF(&objmap->baseobj_zv); + HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); return zend_hash_num_elements(nodeht); } @@ -145,7 +145,7 @@ void php_dom_nodelist_get_item_into_zval(dom_nnodemap_object *objmap, zend_long itemnode = php_dom_libxml_hash_iter(objmap, index); } else { if (objmap->nodetype == DOM_NODESET) { - HashTable *nodeht = HASH_OF(&objmap->baseobj_zv); + HashTable *nodeht = Z_ARRVAL_P(&objmap->baseobj_zv); zval *entry = zend_hash_index_find(nodeht, index); if (entry) { ZVAL_COPY(return_value, entry); diff --git a/ext/dom/parentnode/tree.c b/ext/dom/parentnode/tree.c index ef1ad42b68c86..f57fd1cc7335b 100644 --- a/ext/dom/parentnode/tree.c +++ b/ext/dom/parentnode/tree.c @@ -239,8 +239,11 @@ static bool dom_is_pre_insert_valid_without_step_1(php_libxml_ref_obj *document, ZEND_ASSERT(parentNode != NULL); /* 1. If parent is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException. - * => Impossible */ - ZEND_ASSERT(!php_dom_pre_insert_is_parent_invalid(parentNode)); + * => This is possible because we can grab children of attributes etc... (see e.g. GH-16594) */ + if (php_dom_pre_insert_is_parent_invalid(parentNode)) { + php_dom_throw_error(HIERARCHY_REQUEST_ERR, dom_get_strict_error(document)); + return false; + } if (node->doc != documentNode) { php_dom_throw_error(WRONG_DOCUMENT_ERR, dom_get_strict_error(document)); @@ -497,7 +500,7 @@ static void dom_insert_node_list_cleanup(xmlNodePtr node) xmlFreeNode(node); } else { /* Must have been a directly-passed node. */ - ZEND_ASSERT(node->_private != NULL); + ZEND_UNREACHABLE(); } } @@ -696,8 +699,8 @@ void dom_parent_node_before(dom_object *context, zval *nodes, uint32_t nodesc) static zend_result dom_child_removal_preconditions(const xmlNode *child, const dom_object *context) { - if (dom_node_is_read_only(child) == SUCCESS || - (child->parent != NULL && dom_node_is_read_only(child->parent) == SUCCESS)) { + if (dom_node_is_read_only(child) || + (child->parent != NULL && dom_node_is_read_only(child->parent))) { php_dom_throw_error(NO_MODIFICATION_ALLOWED_ERR, dom_get_strict_error(context->document)); return FAILURE; } diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 0593700d32016..1327cfad6604b 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -155,7 +155,7 @@ typedef struct dom_prop_handler { dom_write_t write_func; } dom_prop_handler; -int dom_node_is_read_only(const xmlNode *node) { +bool dom_node_is_read_only(const xmlNode *node) { switch (node->type) { case XML_ENTITY_REF_NODE: case XML_ENTITY_NODE: @@ -166,14 +166,9 @@ int dom_node_is_read_only(const xmlNode *node) { case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_NAMESPACE_DECL: - return SUCCESS; - break; + return true; default: - if (node->doc == NULL) { - return SUCCESS; - } else { - return FAILURE; - } + return node->doc == NULL; } } diff --git a/ext/dom/php_dom.h b/ext/dom/php_dom.h index 851bc14d12574..7dd8cc896b48a 100644 --- a/ext/dom/php_dom.h +++ b/ext/dom/php_dom.h @@ -147,7 +147,7 @@ xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr basep, xmlNodePtr nodep, void php_dom_create_implementation(zval *retval, bool modern); int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child); bool dom_has_feature(zend_string *feature, zend_string *version); -int dom_node_is_read_only(const xmlNode *node); +bool dom_node_is_read_only(const xmlNode *node); bool dom_node_children_valid(const xmlNode *node); void php_dom_create_iterator(zval *return_value, dom_iterator_type iterator_type, bool modern); void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, const char *local, size_t local_len, const char *ns, size_t ns_len); @@ -211,6 +211,7 @@ void dom_parent_node_query_selector(xmlNodePtr thisp, dom_object *intern, zval * void dom_parent_node_query_selector_all(xmlNodePtr thisp, dom_object *intern, zval *return_value, const zend_string *selectors_str); void dom_element_matches(xmlNodePtr thisp, dom_object *intern, zval *return_value, const zend_string *selectors_str); void dom_element_closest(xmlNodePtr thisp, dom_object *intern, zval *return_value, const zend_string *selectors_str); +xmlNodePtr dom_parse_fragment(dom_object *obj, xmlNodePtr context_node, const zend_string *input); /* nodemap and nodelist APIs */ xmlNodePtr php_dom_named_node_map_get_named_item(dom_nnodemap_object *objmap, const zend_string *named, bool may_transform); diff --git a/ext/dom/php_dom.stub.php b/ext/dom/php_dom.stub.php index 587694f5dfa70..ac11623471f19 100644 --- a/ext/dom/php_dom.stub.php +++ b/ext/dom/php_dom.stub.php @@ -1632,6 +1632,7 @@ public function getElementsByTagNameNS(?string $namespace, string $localName): H public function insertAdjacentElement(AdjacentPosition $where, Element $element): ?Element {} public function insertAdjacentText(AdjacentPosition $where, string $data): void {} + public function insertAdjacentHTML(AdjacentPosition $where, string $string): void {} /** * @readonly diff --git a/ext/dom/php_dom_arginfo.h b/ext/dom/php_dom_arginfo.h index 3d6f093eb22e9..08dbf22a9b91c 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: 20c13a727cffb452475989a743ec29a8412a52f1 */ + * Stub hash: 860bf40a97ec6570e9f5b0616407ba55d7c8d6f8 */ 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) @@ -785,6 +785,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_insertAdjacent ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_insertAdjacentHTML, 0, 2, IS_VOID, 0) + ZEND_ARG_OBJ_INFO(0, where, Dom\\AdjacentPosition, 0) + ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Dom_Element_setIdAttribute, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, qualifiedName, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, isId, _IS_BOOL, 0) @@ -1275,6 +1280,7 @@ ZEND_METHOD(Dom_Element, getElementsByTagName); ZEND_METHOD(Dom_Element, getElementsByTagNameNS); ZEND_METHOD(Dom_Element, insertAdjacentElement); ZEND_METHOD(Dom_Element, insertAdjacentText); +ZEND_METHOD(Dom_Element, insertAdjacentHTML); ZEND_METHOD(Dom_Element, setIdAttributeNode); ZEND_METHOD(Dom_Element, querySelector); ZEND_METHOD(Dom_Element, querySelectorAll); @@ -1649,6 +1655,7 @@ static const zend_function_entry class_Dom_Element_methods[] = { ZEND_ME(Dom_Element, getElementsByTagNameNS, arginfo_class_Dom_Element_getElementsByTagNameNS, ZEND_ACC_PUBLIC) ZEND_ME(Dom_Element, insertAdjacentElement, arginfo_class_Dom_Element_insertAdjacentElement, ZEND_ACC_PUBLIC) ZEND_ME(Dom_Element, insertAdjacentText, arginfo_class_Dom_Element_insertAdjacentText, ZEND_ACC_PUBLIC) + ZEND_ME(Dom_Element, insertAdjacentHTML, arginfo_class_Dom_Element_insertAdjacentHTML, ZEND_ACC_PUBLIC) ZEND_RAW_FENTRY("setIdAttribute", zim_DOMElement_setIdAttribute, arginfo_class_Dom_Element_setIdAttribute, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("setIdAttributeNS", zim_DOMElement_setIdAttributeNS, arginfo_class_Dom_Element_setIdAttributeNS, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_ME(Dom_Element, setIdAttributeNode, arginfo_class_Dom_Element_setIdAttributeNode, ZEND_ACC_PUBLIC) diff --git a/ext/dom/tests/dom004.phpt b/ext/dom/tests/dom004.phpt index 457b764abfb64..8656d2becf7b8 100644 --- a/ext/dom/tests/dom004.phpt +++ b/ext/dom/tests/dom004.phpt @@ -9,7 +9,7 @@ in_array('compress.zlib', stream_get_wrappers()) or die('skip compress.zlib wrap --FILE-- load("compress.zlib://".__DIR__."/book.xml.gz"); +$dom->load("compress.zlib://" . str_replace("\\", "/", __DIR__) . "/book.xml.gz"); print $dom->saveXML(); ?> --EXPECT-- diff --git a/ext/dom/tests/gh16533.phpt b/ext/dom/tests/gh16533.phpt new file mode 100644 index 0000000000000..dad40e88b4d16 --- /dev/null +++ b/ext/dom/tests/gh16533.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-16533 (Segfault when adding attribute to parent that is not an element) +--EXTENSIONS-- +dom +--FILE-- +appendChild($doc->createAttribute('foo')); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} + +echo $doc->saveXML(); + +?> +--EXPECT-- +Hierarchy Request Error + diff --git a/ext/dom/tests/gh16535.phpt b/ext/dom/tests/gh16535.phpt new file mode 100644 index 0000000000000..1c8d282303c88 --- /dev/null +++ b/ext/dom/tests/gh16535.phpt @@ -0,0 +1,25 @@ +--TEST-- +GH-16535 (UAF when using document as a child) +--EXTENSIONS-- +dom +--FILE-- +loadHTML("t"); +$v4 = $v2->createElement('foo'); +try { + $v4->appendChild($v2); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} +$v2->loadHTML("oU"); +echo $v2->saveXML(); + +?> +--EXPECT-- +Hierarchy Request Error + + +

oU

diff --git a/ext/dom/tests/gh16593.phpt b/ext/dom/tests/gh16593.phpt new file mode 100644 index 0000000000000..416d794a4f0d9 --- /dev/null +++ b/ext/dom/tests/gh16593.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-16593 (Assertion failure in DOM->replaceChild) +--EXTENSIONS-- +dom +--FILE-- +appendChild($doc->createElement('root')); +$child = $root->appendChild($doc->createElement('child')); +try { + $root->replaceChild($doc->createAttribute('foo'), $child); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} +echo $doc->saveXML(); + +?> +--EXPECT-- +Hierarchy Request Error + + diff --git a/ext/dom/tests/gh16594.phpt b/ext/dom/tests/gh16594.phpt new file mode 100644 index 0000000000000..adfde5948eefb --- /dev/null +++ b/ext/dom/tests/gh16594.phpt @@ -0,0 +1,25 @@ +--TEST-- +GH-16594 (Assertion failure in DOM -> before) +--EXTENSIONS-- +dom +--FILE-- +createElement("test"); +$v9->setAttributeNodeNS($v7); +$v7->appendChild($v1); + +try { + $v1->before($v6); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Hierarchy Request Error diff --git a/ext/dom/tests/gh16595.phpt b/ext/dom/tests/gh16595.phpt new file mode 100644 index 0000000000000..98927b2ebe91d --- /dev/null +++ b/ext/dom/tests/gh16595.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-16595 (Another UAF in DOM -> cloneNode) +--EXTENSIONS-- +dom +--CREDITS-- +chibinz +--FILE-- + insertBefore ( $v0 , $v9 ); } catch (\Throwable) { } +$v0 -> replaceChildren ( $v7 ); +$v7 -> before ( $v2 ); +$v1 -> insertBefore ( $v0 ); +$v2 -> cloneNode ( ); +echo $v1->saveXML(); +echo $v9->saveXML(); +?> +--EXPECT-- + + + diff --git a/ext/dom/tests/gh16777_1.phpt b/ext/dom/tests/gh16777_1.phpt new file mode 100644 index 0000000000000..d821842ace4e9 --- /dev/null +++ b/ext/dom/tests/gh16777_1.phpt @@ -0,0 +1,24 @@ +--TEST-- +GH-16777 (Calling the constructor again on a DOM object after it is in a document causes UAF) +--EXTENSIONS-- +dom +--FILE-- +appendChild($text); +$text->__construct('my new value'); +$doc->appendChild($text); +echo $doc->saveXML(); +$dom2 = new DOMDocument(); +try { + $dom2->appendChild($text); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- + +my value +my new value +Wrong Document Error diff --git a/ext/dom/tests/gh16777_2.phpt b/ext/dom/tests/gh16777_2.phpt new file mode 100644 index 0000000000000..a6f3a59621b45 --- /dev/null +++ b/ext/dom/tests/gh16777_2.phpt @@ -0,0 +1,27 @@ +--TEST-- +GH-16777 (Calling the constructor again on a DOM object after it is in a document causes UAF) +--EXTENSIONS-- +dom +--FILE-- +append($child = new DOMElement('child')); +$doc = new DOMDocument(); +$doc->appendChild($el); +$el->__construct('newname'); +$doc->appendChild($el); +echo $doc->saveXML(); +$dom2 = new DOMDocument(); +try { + $dom2->appendChild($el); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} +var_dump($child->ownerDocument === $doc); +?> +--EXPECT-- + + + +Wrong Document Error +bool(true) diff --git a/ext/dom/tests/modern/common/innerHTML_cache_invalidation.phpt b/ext/dom/tests/modern/common/innerHTML_cache_invalidation.phpt new file mode 100644 index 0000000000000..976be202cece2 --- /dev/null +++ b/ext/dom/tests/modern/common/innerHTML_cache_invalidation.phpt @@ -0,0 +1,27 @@ +--TEST-- +$innerHTML cache invalidation +--EXTENSIONS-- +dom +--FILE-- +'); +$els = $dom->getElementsByTagName('a'); +var_dump($els[0]->tagName); + +$dom->documentElement->innerHTML = ''; + +echo $dom->saveXML(), "\n"; +var_dump($els); +var_dump($els[0]?->tagName); + +?> +--EXPECT-- +string(1) "a" + + +object(Dom\HTMLCollection)#2 (1) { + ["length"]=> + int(0) +} +NULL diff --git a/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML.phpt b/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML.phpt new file mode 100644 index 0000000000000..a2c9471e669f0 --- /dev/null +++ b/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML.phpt @@ -0,0 +1,114 @@ +--TEST-- +Dom\Element::insertAdjacentHTML() with HTML nodes +--EXTENSIONS-- +dom +--FILE-- +name, " ---\n"; + + $dom = Dom\HTMLDocument::createFromString("
", LIBXML_NOERROR); + $div = $dom->body->firstChild; + $div->append("Sample text"); + + $div->insertAdjacentHTML($position, $html); + + echo $dom->saveXML(), "\n"; + echo $dom->saveHTML(), "\n"; + var_dump($div->childNodes->length); + var_dump($dom->body->childNodes->length); + } +} + +test("

foo

bar

"); +test("text"); +test(""); + +?> +--EXPECT-- +=== HTML (

foo

bar

) === +--- Position BeforeBegin --- + +

foo

bar

Sample text
+

foo

bar

Sample text
+int(1) +int(3) +--- Position AfterBegin --- + +

foo

bar

Sample text
+

foo

bar

Sample text
+int(3) +int(1) +--- Position BeforeEnd --- + +
Sample text

foo

bar

+
Sample text

foo

bar

+int(3) +int(1) +--- Position AfterEnd --- + +
Sample text

foo

bar

+
Sample text

foo

bar

+int(1) +int(3) +=== HTML (text) === +--- Position BeforeBegin --- + +text
Sample text
+text
Sample text
+int(1) +int(2) +--- Position AfterBegin --- + +
textSample text
+
textSample text
+int(2) +int(1) +--- Position BeforeEnd --- + +
Sample texttext
+
Sample texttext
+int(2) +int(1) +--- Position AfterEnd --- + +
Sample text
text +
Sample text
text +int(1) +int(2) +=== HTML () === +--- Position BeforeBegin --- + +
Sample text
+
Sample text
+int(1) +int(1) +--- Position AfterBegin --- + +
Sample text
+
Sample text
+int(1) +int(1) +--- Position BeforeEnd --- + +
Sample text
+
Sample text
+int(1) +int(1) +--- Position AfterEnd --- + +
Sample text
+
Sample text
+int(1) +int(1) diff --git a/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML_edge_case.phpt b/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML_edge_case.phpt new file mode 100644 index 0000000000000..f3f47eebf3319 --- /dev/null +++ b/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML_edge_case.phpt @@ -0,0 +1,24 @@ +--TEST-- +Dom\Element::insertAdjacentHTML() with HTML nodes - edge case +--EXTENSIONS-- +dom +--FILE-- +createDocumentFragment(); +$node = $fragment->appendChild($dom->createElement("node")); + +$node->insertAdjacentHTML(Dom\AdjacentPosition::BeforeBegin, "

foo

"); + +echo $dom->saveHtml($fragment), "\n"; + +$dom->firstChild->insertAdjacentHTML(Dom\AdjacentPosition::AfterBegin, $node->outerHTML); + +echo $dom->saveHtml(), "\n"; + +?> +--EXPECT-- +

foo

+ diff --git a/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML_errors.phpt b/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML_errors.phpt new file mode 100644 index 0000000000000..b8e13ba436b6b --- /dev/null +++ b/ext/dom/tests/modern/html/interactions/Dom_Element_insertAdjacentHTML_errors.phpt @@ -0,0 +1,54 @@ +--TEST-- +Dom\Element::insertAdjacentHTML() with HTML nodes - error conditions +--EXTENSIONS-- +dom +--FILE-- +createElement('root'); + +echo "--- BeforeBegin no parent ---\n"; + +try { + $element->insertAdjacentHTML(Dom\AdjacentPosition::BeforeBegin, "test"); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} + +echo "--- AfterEnd no parent ---\n"; + +try { + $element->insertAdjacentHTML(Dom\AdjacentPosition::AfterEnd, "test"); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} + +$dom->appendChild($element); + +echo "--- BeforeBegin document parent ---\n"; + +try { + $element->insertAdjacentHTML(Dom\AdjacentPosition::BeforeBegin, "test"); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} + +echo "--- AfterEnd document parent ---\n"; + +try { + $element->insertAdjacentHTML(Dom\AdjacentPosition::AfterEnd, "test"); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +--- BeforeBegin no parent --- +No Modification Allowed Error +--- AfterEnd no parent --- +No Modification Allowed Error +--- BeforeBegin document parent --- +No Modification Allowed Error +--- AfterEnd document parent --- +No Modification Allowed Error diff --git a/ext/dom/tests/modern/xml/Element_insertAdjacentHTML.phpt b/ext/dom/tests/modern/xml/Element_insertAdjacentHTML.phpt new file mode 100644 index 0000000000000..a233e01759f6f --- /dev/null +++ b/ext/dom/tests/modern/xml/Element_insertAdjacentHTML.phpt @@ -0,0 +1,101 @@ +--TEST-- +Dom\Element::insertAdjacentHTML() with XML nodes +--EXTENSIONS-- +dom +--FILE-- +name, " ---\n"; + + $dom = Dom\XMLDocument::createFromString('
'); + $div = $dom->documentElement->firstChild; + $div->append("Sample text"); + + $div->insertAdjacentHTML($position, $xml); + + echo $dom->saveXML(), "\n"; + var_dump($div->childNodes->length); + var_dump($dom->documentElement->childNodes->length); + } +} + +test(''); +test('&'); +test('text node'); + +?> +--EXPECT-- +=== XML () === +--- Position BeforeBegin --- + +
Sample text
+int(1) +int(3) +--- Position AfterBegin --- + +
Sample text
+int(3) +int(1) +--- Position BeforeEnd --- + +
Sample text
+int(3) +int(1) +--- Position AfterEnd --- + +
Sample text
+int(1) +int(3) +=== XML (&) === +--- Position BeforeBegin --- + +&
Sample text
+int(1) +int(4) +--- Position AfterBegin --- + +
&Sample text
+int(4) +int(1) +--- Position BeforeEnd --- + +
Sample text&
+int(4) +int(1) +--- Position AfterEnd --- + +
Sample text
&
+int(1) +int(4) +=== XML (text node) === +--- Position BeforeBegin --- + +text node
Sample text
+int(1) +int(2) +--- Position AfterBegin --- + +
text nodeSample text
+int(2) +int(1) +--- Position BeforeEnd --- + +
Sample texttext node
+int(2) +int(1) +--- Position AfterEnd --- + +
Sample text
text node
+int(1) +int(2) diff --git a/ext/dom/tests/modern/xml/Element_insertAdjacentHTML_errors.phpt b/ext/dom/tests/modern/xml/Element_insertAdjacentHTML_errors.phpt new file mode 100644 index 0000000000000..0ecd1d4873605 --- /dev/null +++ b/ext/dom/tests/modern/xml/Element_insertAdjacentHTML_errors.phpt @@ -0,0 +1,17 @@ +--TEST-- +Dom\Element::insertAdjacentHTML() with XML nodes - errors +--EXTENSIONS-- +dom +--FILE-- +'); +try { + $dom->documentElement->insertAdjacentHTML(Dom\AdjacentPosition::AfterBegin, ""); +} catch (DOMException $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +XML fragment is not well-formed diff --git a/ext/enchant/tests/broker_describe.phpt b/ext/enchant/tests/broker_describe.phpt index 80c3b78562434..83cf72ccf842a 100644 --- a/ext/enchant/tests/broker_describe.phpt +++ b/ext/enchant/tests/broker_describe.phpt @@ -41,7 +41,7 @@ if($broker) { } } else { - echo "failed, brocker describe array \n"; + echo "failed, broker describe array \n"; } @enchant_broker_free($broker); diff --git a/ext/exif/exif.c b/ext/exif/exif.c index c0bf6f7891599..859324b1b96f5 100644 --- a/ext/exif/exif.c +++ b/ext/exif/exif.c @@ -330,7 +330,7 @@ static char *exif_get_tagformat(int format) #define TAG_BITS_PER_SAMPLE 0x0102 #define TAG_COMPRESSION 0x0103 #define TAG_PHOTOMETRIC_INTERPRETATION 0x0106 -#define TAG_TRESHHOLDING 0x0107 +#define TAG_THRESHOLDING 0x0107 #define TAG_CELL_WIDTH 0x0108 #define TAG_CELL_HEIGHT 0x0109 #define TAG_FILL_ORDER 0x010A @@ -343,7 +343,7 @@ static char *exif_get_tagformat(int format) #define TAG_SAMPLES_PER_PIXEL 0x0115 #define TAG_ROWS_PER_STRIP 0x0116 #define TAG_STRIP_BYTE_COUNTS 0x0117 -#define TAG_MIN_SAMPPLE_VALUE 0x0118 +#define TAG_MIN_SAMPLE_VALUE 0x0118 #define TAG_MAX_SAMPLE_VALUE 0x0119 #define TAG_X_RESOLUTION 0x011A #define TAG_Y_RESOLUTION 0x011B @@ -372,7 +372,7 @@ static char *exif_get_tagformat(int format) #define TAG_TILE_OFFSETS 0x0144 #define TAG_TILE_BYTE_COUNTS 0x0145 #define TAG_SUB_IFD 0x014A -#define TAG_INK_SETMPUTER 0x014C +#define TAG_INK_SET 0x014C #define TAG_INK_NAMES 0x014D #define TAG_NUMBER_OF_INKS 0x014E #define TAG_DOT_RANGE 0x0150 @@ -412,7 +412,7 @@ static char *exif_get_tagformat(int format) #define TAG_EXIF_IFD_POINTER 0x8769 #define TAG_ICC_PROFILE 0x8773 #define TAG_EXPOSURE_PROGRAM 0x8822 -#define TAG_SPECTRAL_SENSITY 0x8824 +#define TAG_SPECTRAL_SENSITIVITY 0x8824 #define TAG_GPS_IFD_POINTER 0x8825 #define TAG_ISOSPEED 0x8827 #define TAG_OPTOELECTRIC_CONVERSION_F 0x8828 @@ -685,7 +685,7 @@ static tag_info_array tag_table_IFD = { { 0x8769, "Exif_IFD_Pointer"}, { 0x8773, "ICC_Profile"}, { 0x8822, "ExposureProgram"}, - { 0x8824, "SpectralSensity"}, + { 0x8824, "SpectralSensitivity"}, { 0x8825, "GPS_IFD_Pointer"}, { 0x8827, "ISOSpeedRatings"}, { 0x8828, "OECF"}, @@ -3206,7 +3206,7 @@ static bool exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * val /* It can be that motorola_intel is wrongly mapped, let's try inverting it */ if ((2+NumDirEntries*12) > value_len) { - exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Potentially invalid endianess, trying again with different endianness before imminent failure."); + exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Potentially invalid endianness, trying again with different endianness before imminent failure."); ImageInfo->motorola_intel = ImageInfo->motorola_intel == 0 ? 1 : 0; NumDirEntries = php_ifd_get16u(dir_start, ImageInfo->motorola_intel); @@ -3479,7 +3479,7 @@ static bool exif_process_IFD_TAG_impl(image_info_type *ImageInfo, char *dir_entr break; case TAG_SUBJECT_DISTANCE: - /* Inidcates the distacne the autofocus camera is focused to. + /* Indicates the distance the autofocus camera is focused to. Tends to be less accurate as distance increases. */ REQUIRE_NON_EMPTY(); ImageInfo->Distance = (float)exif_convert_any_format(value_ptr, format, ImageInfo->motorola_intel); @@ -3497,7 +3497,7 @@ static bool exif_process_IFD_TAG_impl(image_info_type *ImageInfo, char *dir_entr break; case 3: ImageInfo->FocalplaneUnits = 10; break; /* centimeter */ - case 4: ImageInfo->FocalplaneUnits = 1; break; /* milimeter */ + case 4: ImageInfo->FocalplaneUnits = 1; break; /* millimeter */ case 5: ImageInfo->FocalplaneUnits = .001; break; /* micrometer */ } break; @@ -4122,7 +4122,7 @@ static bool exif_process_IFD_in_TIFF_impl(image_info_type *ImageInfo, size_t dir } } else { entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); - /* if entry needs expading ifd cache and entry is at end of current ifd cache. */ + /* if entry needs expanding ifd cache and entry is at end of current ifd cache. */ /* otherwise there may be huge holes between two entries */ if (entry_offset + entry_length > dir_offset + ifd_size && entry_offset == dir_offset + ifd_size) { diff --git a/ext/exif/tests/filename_empty.phpt b/ext/exif/tests/filename_empty.phpt index 8e83f6b487f85..753a7c6acd093 100644 --- a/ext/exif/tests/filename_empty.phpt +++ b/ext/exif/tests/filename_empty.phpt @@ -1,5 +1,5 @@ --TEST-- -Passing empty filename to exif_read_data() and exif_thumnail() +Passing empty filename to exif_read_data() and exif_thumbnail() --EXTENSIONS-- exif --FILE-- diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c index 2648162ae9c0b..4e7253b9010e4 100644 --- a/ext/ffi/ffi.c +++ b/ext/ffi/ffi.c @@ -2974,6 +2974,41 @@ static zend_always_inline bool zend_ffi_validate_api_restriction(zend_execute_da } \ } while (0) +#ifdef PHP_WIN32 +# include +# ifndef DWORD_MAX +# define DWORD_MAX ULONG_MAX +# endif +# define NUM_MODULES 1024 +/* A rough approximation of dlysm(RTLD_DEFAULT) */ +static void *dlsym_loaded(char *symbol) +{ + HMODULE modules_static[NUM_MODULES], *modules = modules_static; + DWORD num = NUM_MODULES, i; + void * addr; + if (!EnumProcessModules(GetCurrentProcess(), modules, num * sizeof(HMODULE), &num)) { + return NULL; + } + if (num >= NUM_MODULES && num <= DWORD_MAX / sizeof(HMODULE)) { + modules = emalloc(num *sizeof(HMODULE)); + if (!EnumProcessModules(GetCurrentProcess(), modules, num * sizeof(HMODULE), &num)) { + efree(modules); + return NULL; + } + } + for (i = 0; i < num; i++) { + addr = GetProcAddress(modules[i], symbol); + if (addr != NULL) break; + } + if (modules != modules_static) { + efree(modules); + } + return addr; +} +# undef DL_FETCH_SYMBOL +# define DL_FETCH_SYMBOL(h, s) (h == NULL ? dlsym_loaded(s) : GetProcAddress(h, s)) +#endif + ZEND_METHOD(FFI, cdef) /* {{{ */ { zend_string *code = NULL; diff --git a/ext/ffi/tests/100.phpt b/ext/ffi/tests/100.phpt index 33b974a37b183..f231170315f30 100644 --- a/ext/ffi/tests/100.phpt +++ b/ext/ffi/tests/100.phpt @@ -3,10 +3,9 @@ FFI 100: PHP symbols --EXTENSIONS-- ffi --SKIPIF-- - get_zend_version())[0])); //var_dump(trim(FFI::string($zend->get_zend_version()))); var_dump($zend->zend_printf); diff --git a/ext/ffi/tests/101.phpt b/ext/ffi/tests/101.phpt index 4730e2689e03b..3362e98b9fdfb 100644 --- a/ext/ffi/tests/101.phpt +++ b/ext/ffi/tests/101.phpt @@ -3,10 +3,9 @@ FFI 101: PHP symbols (function address) --EXTENSIONS-- ffi --SKIPIF-- - get_zend_version; var_dump(trim(explode("\n",$f())[0])); //var_dump(trim(FFI::string($zend->get_zend_version()))); diff --git a/ext/ffi/tests/200.phpt b/ext/ffi/tests/200.phpt index 92aedc5435bb8..aae410de7b163 100644 --- a/ext/ffi/tests/200.phpt +++ b/ext/ffi/tests/200.phpt @@ -6,7 +6,7 @@ ffi ---INI-- -ffi.enable=1 ---FILE-- -php_printf("Hello World from %s!\n", "PHP"); -?> ---CLEAN-- - ---EXPECT-- -Hello World from PHP! diff --git a/ext/ffi/tests/301.phpt b/ext/ffi/tests/301.phpt index 0677a2cf30053..efe92633f07a2 100644 --- a/ext/ffi/tests/301.phpt +++ b/ext/ffi/tests/301.phpt @@ -2,8 +2,6 @@ FFI 301: FFI loading --EXTENSIONS-- ffi ---SKIPIF-- - --INI-- ffi.enable=1 --FILE-- diff --git a/ext/ffi/tests/303.phpt b/ext/ffi/tests/303.phpt index 2d84867051931..ea995a4f9ef67 100644 --- a/ext/ffi/tests/303.phpt +++ b/ext/ffi/tests/303.phpt @@ -1,5 +1,5 @@ --TEST-- -FFI 303: FFI preloading flob +FFI 303: FFI preloading glob --EXTENSIONS-- ffi --SKIPIF-- diff --git a/ext/ffi/tests/bug77632b.phpt b/ext/ffi/tests/bug77632b.phpt index 044c84ec097a3..8aedd0aa8aec9 100644 --- a/ext/ffi/tests/bug77632b.phpt +++ b/ext/ffi/tests/bug77632b.phpt @@ -4,9 +4,8 @@ Bug #77632 (FFI function pointers with variadics) ffi --SKIPIF-- zend_printf)(...$args); $args2 = ["Hello, %s from zend_printf\n", "world"]; diff --git a/ext/ffi/tests/bug78714.phpt b/ext/ffi/tests/bug78714.phpt index 81017b27d56cd..9542bdcb70c8b 100644 --- a/ext/ffi/tests/bug78714.phpt +++ b/ext/ffi/tests/bug78714.phpt @@ -6,9 +6,8 @@ ffi ffi.enable=1 --FILE-- get_zend_version()), 0, 4) . "\n"; ?> --EXPECT-- diff --git a/ext/ffi/tests/bug79096.phpt b/ext/ffi/tests/bug79096.phpt index 8c7ce6cc2af70..66db0a573927a 100644 --- a/ext/ffi/tests/bug79096.phpt +++ b/ext/ffi/tests/bug79096.phpt @@ -5,7 +5,6 @@ ffi zend_test --FILE-- bug79096(); var_dump($struct); ?> diff --git a/ext/ffi/tests/bug79177.phpt b/ext/ffi/tests/bug79177.phpt index 2b6e449d36d6a..fe980f95c6517 100644 --- a/ext/ffi/tests/bug79177.phpt +++ b/ext/ffi/tests/bug79177.phpt @@ -5,22 +5,12 @@ ffi zend_test --FILE-- bug79177_cb = function() { throw new \RuntimeException('Not allowed'); }; diff --git a/ext/ffi/tests/bug79532.phpt b/ext/ffi/tests/bug79532.phpt index 386c62540c163..553cfe71bef0c 100644 --- a/ext/ffi/tests/bug79532.phpt +++ b/ext/ffi/tests/bug79532.phpt @@ -5,22 +5,11 @@ ffi zend_test --FILE-- new("off_t[3]"); $ffi->bug79532($array, 3); var_dump($array); diff --git a/ext/ffi/tests/bug80847.phpt b/ext/ffi/tests/bug80847.phpt index 83929de7512b4..da499b1586f18 100644 --- a/ext/ffi/tests/bug80847.phpt +++ b/ext/ffi/tests/bug80847.phpt @@ -9,7 +9,6 @@ if (PHP_OS_FAMILY == 'Windows' && ((1 << 31) > 0)) die('xfail libffi doesn\'t pr ?> --FILE-- new('bug80847_02'); $x->a->b = 42; $x->a->c = 42.5; diff --git a/ext/ffi/tests/bug_gh9090.phpt b/ext/ffi/tests/bug_gh9090.phpt index 795e7bcaa5aa9..a13aaafe3aa98 100644 --- a/ext/ffi/tests/bug_gh9090.phpt +++ b/ext/ffi/tests/bug_gh9090.phpt @@ -6,7 +6,6 @@ zend_test --FILE-- gh11934b_ffi_var_test_cdata->cdata = 2; var_dump($ffi->gh11934b_ffi_var_test_cdata); $source = $ffi->new('int'); diff --git a/ext/ffi/tests/utils.inc b/ext/ffi/tests/utils.inc index 63c020fb5393d..d5a9fc31e6eae 100644 --- a/ext/ffi/tests/utils.inc +++ b/ext/ffi/tests/utils.inc @@ -1,28 +1,10 @@ 63 || (hostname && *s != '-' && !isalnum((int)*(unsigned char *)s))) { + if (i > 63 || (hostname && (*s != '-' || *(s + 1) == '\0') && !isalnum((int)*(unsigned char *)s))) { return 0; } diff --git a/ext/filter/tests/049.phpt b/ext/filter/tests/049.phpt index 797739d7cb69f..8e686e5a72655 100644 --- a/ext/filter/tests/049.phpt +++ b/ext/filter/tests/049.phpt @@ -1,5 +1,5 @@ --TEST-- -filter_var() and doubles with thousend separators +filter_var() and doubles with thousand separators --EXTENSIONS-- filter --FILE-- diff --git a/ext/filter/tests/gh16523.phpt b/ext/filter/tests/gh16523.phpt new file mode 100644 index 0000000000000..b2985c12a7827 --- /dev/null +++ b/ext/filter/tests/gh16523.phpt @@ -0,0 +1,20 @@ +--TEST-- +GH-16523 (FILTER_FLAG_HOSTNAME accepts ending hyphen) +--EXTENSIONS-- +filter +--FILE-- + +--EXPECT-- +bool(false) +bool(false) +bool(false) diff --git a/ext/ftp/tests/ftp_pasv.phpt b/ext/ftp/tests/ftp_pasv.phpt index 9acc247038979..e540e5b16bef0 100644 --- a/ext/ftp/tests/ftp_pasv.phpt +++ b/ext/ftp/tests/ftp_pasv.phpt @@ -1,5 +1,5 @@ --TEST-- -Testing ftp_pasv basic funcionality +Testing ftp_pasv basic functionality --CREDITS-- Gabriel Caruso (carusogabriel34@gmail.com) --EXTENSIONS-- diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index c2c8449a0686e..97f4f07d00202 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -431,7 +431,7 @@ if ($pid) { } } elseif (preg_match('/^EPSV/', $buf, $matches)) { - fputs($s, "550 Extended passsive mode not supported.\r\n"); + fputs($s, "550 Extended passive mode not supported.\r\n"); } elseif (preg_match('/^SITE EXEC/', $buf, $matches)) { fputs($s, "200 OK\r\n"); diff --git a/ext/gd/gd.c b/ext/gd/gd.c index a2c3e7d0de61e..938672ccc0c7d 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -1358,24 +1358,6 @@ PHP_FUNCTION(imagetypes) } /* }}} */ -/* {{{ _php_ctx_getmbi */ - -static int _php_ctx_getmbi(gdIOCtx *ctx) -{ - int i, mbi = 0; - - do { - i = (ctx->getC)(ctx); - if (i < 0) { - return -1; - } - mbi = (mbi << 7) | (i & 0x7f); - } while (i & 0x80); - - return mbi; -} -/* }}} */ - /* {{{ _php_image_type * Based on ext/standard/image.c */ @@ -1413,15 +1395,8 @@ static int _php_image_type(zend_string *data) } } - gdIOCtx *io_ctx; - io_ctx = gdNewDynamicCtxEx(8, ZSTR_VAL(data), 0); - if (io_ctx) { - if (_php_ctx_getmbi(io_ctx) == 0 && _php_ctx_getmbi(io_ctx) >= 0) { - io_ctx->gd_free(io_ctx); - return PHP_GDIMG_TYPE_WBM; - } else { - io_ctx->gd_free(io_ctx); - } + if (ZSTR_VAL(data)[0] == 0) { + return PHP_GDIMG_TYPE_WBM; } return -1; diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 8a0b4fb137b82..b08cc64aa30da 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -919,21 +919,29 @@ static inline LineContribType *_gdContributionsCalc(unsigned int line_size, unsi return res; } +/* Convert a double to an unsigned char, rounding to the nearest + * integer and clamping the result between 0 and max. The absolute + * value of clr must be less than the maximum value of an unsigned + * short. */ static inline unsigned char -uchar_clamp(double clr) { +uchar_clamp(double clr, unsigned char max) { unsigned short result; - assert(fabs(clr) <= SHRT_MAX); + + //assert(fabs(clr) <= SHRT_MAX); + /* Casting a negative float to an unsigned short is undefined. * However, casting a float to a signed truncates toward zero and * casting a negative signed value to an unsigned of the same size * results in a bit-identical value (assuming twos-complement * arithmetic). This is what we want: all legal negative values * for clr will be greater than 255. */ + /* Convert and clamp. */ result = (unsigned short)(short)(clr + 0.5); - if (result > 255) { - result = (clr < 0) ? 0 : 255; + if (result > max) { + result = (clr < 0) ? 0 : max; }/* if */ + return result; }/* uchar_clamp*/ @@ -957,7 +965,9 @@ static inline void _gdScaleRow(gdImagePtr pSrc, unsigned int src_width, gdImage b += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetBlue(p_src_row[i])); a += contrib->ContribRow[x].Weights[left_channel] * (double)(gdTrueColorGetAlpha(p_src_row[i])); } - p_dst_row[x] = gdTrueColorAlpha(uchar_clamp(r), uchar_clamp(g), uchar_clamp(b), uchar_clamp(a)); + p_dst_row[x] = gdTrueColorAlpha(uchar_clamp(r, 0xFF), uchar_clamp(g, 0xFF), + uchar_clamp(b, 0xFF), + uchar_clamp(a, 0x7F)); /* alpha is 0..127 */ } } @@ -1004,7 +1014,9 @@ static inline void _gdScaleCol (gdImagePtr pSrc, unsigned int src_width, gdImag b += contrib->ContribRow[y].Weights[i_iLeft] * (double)(gdTrueColorGetBlue(pCurSrc)); a += contrib->ContribRow[y].Weights[i_iLeft] * (double)(gdTrueColorGetAlpha(pCurSrc)); } - pRes->tpixels[y][uCol] = gdTrueColorAlpha(uchar_clamp(r), uchar_clamp(g), uchar_clamp(b), uchar_clamp(a)); + pRes->tpixels[y][uCol] = gdTrueColorAlpha(uchar_clamp(r, 0xFF), uchar_clamp(g, 0xFF), + uchar_clamp(b, 0xFF), + uchar_clamp(a, 0x7F)); /* alpha is 0..127 */ } } diff --git a/ext/gd/tests/gh16559.phpt b/ext/gd/tests/gh16559.phpt new file mode 100644 index 0000000000000..4481311c4c459 --- /dev/null +++ b/ext/gd/tests/gh16559.phpt @@ -0,0 +1,15 @@ +--TEST-- +GH-16559 (UBSan abort in ext/gd/libgd/gd_interpolation.c:1007) +--EXTENSIONS-- +gd +--FILE-- + +--EXPECT-- +object(GdImage)#2 (0) { +} diff --git a/ext/gd/tests/gh16771.phpt b/ext/gd/tests/gh16771.phpt new file mode 100644 index 0000000000000..232317cec11b5 --- /dev/null +++ b/ext/gd/tests/gh16771.phpt @@ -0,0 +1,10 @@ +--TEST-- +GH-16771 (UBSan abort in ext/gd/libgd/gd.c:1372) +--EXTENSIONS-- +gd +--FILE-- + +--FILE-- + +--EXPECT-- +int(200) +int(200) diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index f3cb4a6ce101f..177d0c7f7c91e 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -338,8 +338,34 @@ static zend_object *gmp_clone_obj(zend_object *obj) /* {{{ */ } /* }}} */ -static void shift_operator_helper(gmp_binary_ui_op_t op, zval *return_value, zval *op1, zval *op2, uint8_t opcode) { - zend_long shift = zval_get_long(op2); +static zend_result shift_operator_helper(gmp_binary_ui_op_t op, zval *return_value, zval *op1, zval *op2, uint8_t opcode) { + zend_long shift = 0; + + if (UNEXPECTED(Z_TYPE_P(op2) != IS_LONG)) { + if (UNEXPECTED(!IS_GMP(op2))) { + // For PHP 8.3 and up use zend_try_get_long() + switch (Z_TYPE_P(op2)) { + case IS_DOUBLE: + shift = zval_get_long(op2); + if (UNEXPECTED(EG(exception))) { + return FAILURE; + } + break; + case IS_STRING: + if (is_numeric_str_function(Z_STR_P(op2), &shift, NULL) != IS_LONG) { + goto valueof_op_failure; + } + break; + default: + goto typeof_op_failure; + } + } else { + // TODO We shouldn't cast the GMP object to int here + shift = zval_get_long(op2); + } + } else { + shift = Z_LVAL_P(op2); + } if (shift < 0) { zend_throw_error( @@ -347,16 +373,54 @@ static void shift_operator_helper(gmp_binary_ui_op_t op, zval *return_value, zva opcode == ZEND_POW ? "Exponent" : "Shift" ); ZVAL_UNDEF(return_value); - return; + return FAILURE; } else { mpz_ptr gmpnum_op, gmpnum_result; gmp_temp_t temp; - FETCH_GMP_ZVAL(gmpnum_op, op1, temp, 1); + /* We do not use FETCH_GMP_ZVAL(...); here as we don't use convert_to_gmp() + * as we want to handle the emitted exception ourself. */ + if (UNEXPECTED(!IS_GMP(op1))) { + if (UNEXPECTED(Z_TYPE_P(op1) != IS_LONG)) { + goto typeof_op_failure; + } + mpz_init(temp.num); + mpz_set_si(temp.num, Z_LVAL_P(op1)); + temp.is_used = 1; + gmpnum_op = temp.num; + } else { + gmpnum_op = GET_GMP_FROM_ZVAL(op1); + temp.is_used = 0; + } INIT_GMP_RETVAL(gmpnum_result); op(gmpnum_result, gmpnum_op, (gmp_ulong) shift); FREE_GMP_TEMP(temp); + return SUCCESS; + } + +typeof_op_failure: ; + /* Returning FAILURE without throwing an exception would emit the + * Unsupported operand types: GMP OP TypeOfOp2 + * However, this leads to the engine trying to interpret the GMP object as an integer + * and doing the operation that way, which is not something we want. */ + const char *op_sigil; + switch (opcode) { + case ZEND_POW: + op_sigil = "**"; + break; + case ZEND_SL: + op_sigil = "<<"; + break; + case ZEND_SR: + op_sigil = ">>"; + break; + EMPTY_SWITCH_DEFAULT_CASE(); } + zend_type_error("Unsupported operand types: %s %s %s", zend_zval_type_name(op1), op_sigil, zend_zval_type_name(op2)); + return FAILURE; +valueof_op_failure: + zend_value_error("Number is not an integer string"); + return FAILURE; } #define DO_BINARY_UI_OP_EX(op, uop, check_b_zero) \ @@ -385,18 +449,15 @@ static zend_result gmp_do_operation_ex(uint8_t opcode, zval *result, zval *op1, case ZEND_MUL: DO_BINARY_UI_OP(mpz_mul); case ZEND_POW: - shift_operator_helper(mpz_pow_ui, result, op1, op2, opcode); - return SUCCESS; + return shift_operator_helper(mpz_pow_ui, result, op1, op2, opcode); case ZEND_DIV: DO_BINARY_UI_OP_EX(mpz_tdiv_q, gmp_mpz_tdiv_q_ui, 1); case ZEND_MOD: DO_BINARY_UI_OP_EX(mpz_mod, gmp_mpz_mod_ui, 1); case ZEND_SL: - shift_operator_helper(mpz_mul_2exp, result, op1, op2, opcode); - return SUCCESS; + return shift_operator_helper(mpz_mul_2exp, result, op1, op2, opcode); case ZEND_SR: - shift_operator_helper(mpz_fdiv_q_2exp, result, op1, op2, opcode); - return SUCCESS; + return shift_operator_helper(mpz_fdiv_q_2exp, result, op1, op2, opcode); case ZEND_BW_OR: DO_BINARY_OP(mpz_ior); case ZEND_BW_AND: @@ -629,6 +690,13 @@ static zend_result convert_to_gmp(mpz_t gmpnumber, zval *val, zend_long base, ui case IS_STRING: { return convert_zstr_to_gmp(gmpnumber, Z_STR_P(val), base, arg_pos); } + case IS_NULL: + /* Just reject null for operator overloading */ + if (arg_pos == 0) { + zend_type_error("Number must be of type GMP|string|int, %s given", zend_zval_type_name(val)); + return FAILURE; + } + ZEND_FALLTHROUGH; default: { zend_long lval; if (!zend_parse_arg_long_slow(val, &lval, arg_pos)) { @@ -1292,39 +1360,27 @@ ZEND_FUNCTION(gmp_pow) RETURN_THROWS(); } + double powmax = log((double)ZEND_LONG_MAX); + if (Z_TYPE_P(base_arg) == IS_LONG && Z_LVAL_P(base_arg) >= 0) { INIT_GMP_RETVAL(gmpnum_result); - if (exp >= INT_MAX) { - mpz_t base_num, exp_num, mod; - mpz_init(base_num); - mpz_init(exp_num); - mpz_init(mod); - mpz_set_si(base_num, Z_LVAL_P(base_arg)); - mpz_set_si(exp_num, exp); - mpz_set_ui(mod, UINT_MAX); - mpz_powm(gmpnum_result, base_num, exp_num, mod); - mpz_clear(mod); - mpz_clear(exp_num); - mpz_clear(base_num); - } else { - mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp); + if ((log(Z_LVAL_P(base_arg)) * exp) > powmax) { + zend_value_error("base and exponent overflow"); + RETURN_THROWS(); } + mpz_ui_pow_ui(gmpnum_result, Z_LVAL_P(base_arg), exp); } else { mpz_ptr gmpnum_base; + zend_ulong gmpnum; FETCH_GMP_ZVAL(gmpnum_base, base_arg, temp_base, 1); INIT_GMP_RETVAL(gmpnum_result); - if (exp >= INT_MAX) { - mpz_t exp_num, mod; - mpz_init(exp_num); - mpz_init(mod); - mpz_set_si(exp_num, exp); - mpz_set_ui(mod, UINT_MAX); - mpz_powm(gmpnum_result, gmpnum_base, exp_num, mod); - mpz_clear(mod); - mpz_clear(exp_num); - } else { - mpz_pow_ui(gmpnum_result, gmpnum_base, exp); + gmpnum = mpz_get_ui(gmpnum_base); + if ((log(gmpnum) * exp) > powmax) { + FREE_GMP_TEMP(temp_base); + zend_value_error("base and exponent overflow"); + RETURN_THROWS(); } + mpz_pow_ui(gmpnum_result, gmpnum_base, exp); FREE_GMP_TEMP(temp_base); } } @@ -1821,15 +1877,21 @@ ZEND_FUNCTION(gmp_random_bits) RETURN_THROWS(); } - if (bits <= 0) { - zend_argument_value_error(1, "must be greater than or equal to 1"); +#if SIZEOF_SIZE_T == 4 + const zend_long maxbits = ULONG_MAX / GMP_NUMB_BITS; +#else + const zend_long maxbits = INT_MAX; +#endif + + if (bits <= 0 || bits > maxbits) { + zend_argument_value_error(1, "must be between 1 and " ZEND_LONG_FMT, maxbits); RETURN_THROWS(); } INIT_GMP_RETVAL(gmpnum_result); gmp_init_random(); - mpz_urandomb(gmpnum_result, GMPG(rand_state), bits); + mpz_urandomb(gmpnum_result, GMPG(rand_state), (mp_bitcnt_t)bits); } /* }}} */ diff --git a/ext/gmp/tests/gh16501.phpt b/ext/gmp/tests/gh16501.phpt new file mode 100644 index 0000000000000..325be85d1917e --- /dev/null +++ b/ext/gmp/tests/gh16501.phpt @@ -0,0 +1,14 @@ +--TEST-- +GH-16501 (gmp_random_bits overflow) +--EXTENSIONS-- +gmp +--FILE-- +getMessage(); +} +?> +--EXPECTF-- +gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d diff --git a/ext/gmp/tests/gmp_pow.phpt b/ext/gmp/tests/gmp_pow.phpt index f42e44e31abed..1d77bd5e96c80 100644 --- a/ext/gmp/tests/gmp_pow.phpt +++ b/ext/gmp/tests/gmp_pow.phpt @@ -2,6 +2,8 @@ gmp_pow() basic tests --EXTENSIONS-- gmp +--SKIPIF-- + --FILE-- +--FILE-- +getMessage() . "\n"; +} +var_dump(gmp_strval(gmp_pow("-2",10))); +try { + gmp_pow(20,10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + gmp_pow(50,10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + gmp_pow(50,-5); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + $n = gmp_init("20"); + gmp_pow($n,10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + $n = gmp_init("-20"); + gmp_pow($n,10); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} +try { + var_dump(gmp_pow(2,array())); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} + +try { + var_dump(gmp_pow(array(),10)); +} catch (\TypeError $e) { + echo $e->getMessage() . \PHP_EOL; +} + +echo "Done\n"; +?> +--EXPECT-- +string(4) "1024" +string(4) "1024" +string(5) "-2048" +string(4) "1024" +string(1) "1" +gmp_pow(): Argument #2 ($exponent) must be greater than or equal to 0 +string(4) "1024" +base and exponent overflow +base and exponent overflow +gmp_pow(): Argument #2 ($exponent) must be greater than or equal to 0 +base and exponent overflow +base and exponent overflow +gmp_pow(): Argument #2 ($exponent) must be of type int, array given +gmp_pow(): Argument #1 ($num) must be of type GMP|string|int, array given +Done diff --git a/ext/gmp/tests/gmp_pow_fpe.phpt b/ext/gmp/tests/gmp_pow_fpe.phpt index d564853799c8d..248922e80514d 100644 --- a/ext/gmp/tests/gmp_pow_fpe.phpt +++ b/ext/gmp/tests/gmp_pow_fpe.phpt @@ -6,15 +6,30 @@ gmp ---EXPECTF-- -object(GMP)#2 (1) { - ["num"]=> - string(%d) "%s" +try { + gmp_pow($g, PHP_INT_MAX); +} catch (\ValueError $e) { + echo $e->getMessage() . PHP_EOL; } -object(GMP)#2 (1) { - ["num"]=> - string(%d) "%s" +try { + gmp_pow(256, PHP_INT_MAX); +} catch (\ValueError $e) { + echo $e->getMessage() . PHP_EOL; +} + +try { + gmp_pow(gmp_add(gmp_mul(gmp_init(PHP_INT_MAX), gmp_init(PHP_INT_MAX)), 3), 256); +} catch (\ValueError $e) { + echo $e->getMessage() . PHP_EOL; } +try { + gmp_pow(gmp_init(PHP_INT_MAX), 256); +} catch (\ValueError $e) { + echo $e->getMessage(); +} +?> +--EXPECTF-- +base and exponent overflow +base and exponent overflow +base and exponent overflow +base and exponent overflow diff --git a/ext/gmp/tests/gmp_random_bits.phpt b/ext/gmp/tests/gmp_random_bits.phpt index 3dbfc097d28d5..4e7f337983891 100644 --- a/ext/gmp/tests/gmp_random_bits.phpt +++ b/ext/gmp/tests/gmp_random_bits.phpt @@ -40,7 +40,7 @@ while (1) { echo "Done\n"; ?> ---EXPECT-- -gmp_random_bits(): Argument #1 ($bits) must be greater than or equal to 1 -gmp_random_bits(): Argument #1 ($bits) must be greater than or equal to 1 +--EXPECTF-- +gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d +gmp_random_bits(): Argument #1 ($bits) must be between 1 and %d Done diff --git a/ext/gmp/tests/overloading_cmp_op_with_null.phpt b/ext/gmp/tests/overloading_cmp_op_with_null.phpt new file mode 100644 index 0000000000000..d84ef967868e1 --- /dev/null +++ b/ext/gmp/tests/overloading_cmp_op_with_null.phpt @@ -0,0 +1,53 @@ +--TEST-- +GMP comparison operator overloading supports null +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num > null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num <= null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num >= null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num == null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num <=> null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +bool(false) +bool(true) +bool(false) +bool(true) +bool(false) +int(1) diff --git a/ext/gmp/tests/overloading_with_array.phpt b/ext/gmp/tests/overloading_with_array.phpt new file mode 100644 index 0000000000000..a23df9381dcde --- /dev/null +++ b/ext/gmp/tests/overloading_with_array.phpt @@ -0,0 +1,84 @@ +--TEST-- +GMP operator overloading does not support [] +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> []); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +TypeError: Number must be of type GMP|string|int, array given +TypeError: Number must be of type GMP|string|int, array given +TypeError: Number must be of type GMP|string|int, array given +TypeError: Number must be of type GMP|string|int, array given +TypeError: Number must be of type GMP|string|int, array given +TypeError: Unsupported operand types: GMP ** array +TypeError: Number must be of type GMP|string|int, array given +TypeError: Number must be of type GMP|string|int, array given +TypeError: Number must be of type GMP|string|int, array given +TypeError: Unsupported operand types: GMP << array +TypeError: Unsupported operand types: GMP >> array diff --git a/ext/gmp/tests/overloading_with_float.phpt b/ext/gmp/tests/overloading_with_float.phpt new file mode 100644 index 0000000000000..f2bcfa7d51485 --- /dev/null +++ b/ext/gmp/tests/overloading_with_float.phpt @@ -0,0 +1,117 @@ +--TEST-- +GMP operator overloading does support float with no fractional +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> 42.0); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +object(GMP)#2 (1) { + ["num"]=> + string(2) "84" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#2 (1) { + ["num"]=> + string(4) "1764" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "1" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#2 (1) { + ["num"]=> + string(69) "150130937545296572356771972164254457814047970568738777235893533016064" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "42" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "42" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#2 (1) { + ["num"]=> + string(15) "184717953466368" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} diff --git a/ext/gmp/tests/overloading_with_float_fractional.phpt b/ext/gmp/tests/overloading_with_float_fractional.phpt new file mode 100644 index 0000000000000..fc078eeec3e98 --- /dev/null +++ b/ext/gmp/tests/overloading_with_float_fractional.phpt @@ -0,0 +1,132 @@ +--TEST-- +GMP operator overloading support for float with fractional is deprecated +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> 42.5); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECTF-- +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(2) "84" +} + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(4) "1764" +} + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(1) "1" +} + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#2 (1) { + ["num"]=> + string(69) "150130937545296572356771972164254457814047970568738777235893533016064" +} + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(2) "42" +} + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(2) "42" +} + +Deprecated: Implicit conversion from float 42.5 to int loses precision in %s on line %d +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#2 (1) { + ["num"]=> + string(15) "184717953466368" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} diff --git a/ext/gmp/tests/overloading_with_float_string.phpt b/ext/gmp/tests/overloading_with_float_string.phpt new file mode 100644 index 0000000000000..b01c99e969c23 --- /dev/null +++ b/ext/gmp/tests/overloading_with_float_string.phpt @@ -0,0 +1,84 @@ +--TEST-- +GMP operator overloading does not support float strings +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> "2.0"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string diff --git a/ext/gmp/tests/overloading_with_int_string.phpt b/ext/gmp/tests/overloading_with_int_string.phpt new file mode 100644 index 0000000000000..252916ef9a531 --- /dev/null +++ b/ext/gmp/tests/overloading_with_int_string.phpt @@ -0,0 +1,117 @@ +--TEST-- +GMP operator overloading does support int strings +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> "2"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +object(GMP)#2 (1) { + ["num"]=> + string(2) "44" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "40" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "84" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "21" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "0" +} +object(GMP)#2 (1) { + ["num"]=> + string(4) "1764" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "42" +} +object(GMP)#2 (1) { + ["num"]=> + string(1) "2" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "40" +} +object(GMP)#2 (1) { + ["num"]=> + string(3) "168" +} +object(GMP)#2 (1) { + ["num"]=> + string(2) "10" +} diff --git a/ext/gmp/tests/overloading_with_non_numeric_string.phpt b/ext/gmp/tests/overloading_with_non_numeric_string.phpt new file mode 100644 index 0000000000000..2f6c2d072342c --- /dev/null +++ b/ext/gmp/tests/overloading_with_non_numeric_string.phpt @@ -0,0 +1,84 @@ +--TEST-- +GMP operator overloading does not support non-numeric strings +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> "string"); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string +ValueError: Number is not an integer string diff --git a/ext/gmp/tests/overloading_with_null.phpt b/ext/gmp/tests/overloading_with_null.phpt new file mode 100644 index 0000000000000..95f8153e4e7a5 --- /dev/null +++ b/ext/gmp/tests/overloading_with_null.phpt @@ -0,0 +1,84 @@ +--TEST-- +GMP operator overloading does not support null +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> null); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +TypeError: Number must be of type GMP|string|int, null given +TypeError: Number must be of type GMP|string|int, null given +TypeError: Number must be of type GMP|string|int, null given +TypeError: Number must be of type GMP|string|int, null given +TypeError: Number must be of type GMP|string|int, null given +TypeError: Unsupported operand types: GMP ** null +TypeError: Number must be of type GMP|string|int, null given +TypeError: Number must be of type GMP|string|int, null given +TypeError: Number must be of type GMP|string|int, null given +TypeError: Unsupported operand types: GMP << null +TypeError: Unsupported operand types: GMP >> null diff --git a/ext/gmp/tests/overloading_with_object_not_stringable.phpt b/ext/gmp/tests/overloading_with_object_not_stringable.phpt new file mode 100644 index 0000000000000..c8fb924824dd4 --- /dev/null +++ b/ext/gmp/tests/overloading_with_object_not_stringable.phpt @@ -0,0 +1,85 @@ +--TEST-- +GMP operator overloading does not support non-stringable objects +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Unsupported operand types: GMP ** stdClass +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Number must be of type GMP|string|int, stdClass given +TypeError: Unsupported operand types: GMP << stdClass +TypeError: Unsupported operand types: GMP >> stdClass diff --git a/ext/gmp/tests/overloading_with_object_stringable.phpt b/ext/gmp/tests/overloading_with_object_stringable.phpt new file mode 100644 index 0000000000000..4425661b98924 --- /dev/null +++ b/ext/gmp/tests/overloading_with_object_stringable.phpt @@ -0,0 +1,91 @@ +--TEST-- +GMP operator overloading does not support stringable objects +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> $o); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECTF-- +TypeError: Number must be of type GMP|string|int, T given +TypeError: Number must be of type GMP|string|int, T given +TypeError: Number must be of type GMP|string|int, T given +TypeError: Number must be of type GMP|string|int, T given +TypeError: Number must be of type GMP|string|int, T given +TypeError: Unsupported operand types: GMP ** T +TypeError: Number must be of type GMP|string|int, T given +TypeError: Number must be of type GMP|string|int, T given +TypeError: Number must be of type GMP|string|int, T given +TypeError: Unsupported operand types: GMP << T +TypeError: Unsupported operand types: GMP >> T diff --git a/ext/gmp/tests/overloading_with_resource.phpt b/ext/gmp/tests/overloading_with_resource.phpt new file mode 100644 index 0000000000000..50b7af5d32746 --- /dev/null +++ b/ext/gmp/tests/overloading_with_resource.phpt @@ -0,0 +1,84 @@ +--TEST-- +GMP operator overloading does not support resources +--EXTENSIONS-- +gmp +--FILE-- +getMessage(), PHP_EOL; +} + +try { + var_dump($num - STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num * STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num / STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num % STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num ** STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +try { + var_dump($num | STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num & STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num ^ STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num << STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +try { + var_dump($num >> STDERR); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Unsupported operand types: GMP ** resource +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Number must be of type GMP|string|int, resource given +TypeError: Unsupported operand types: GMP << resource +TypeError: Unsupported operand types: GMP >> resource diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 9d099c2d50b45..5579aeb978e3c 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -1189,7 +1189,7 @@ static void mhash_init(INIT_FUNC_ARGS) } len = slprintf(buf, 127, "MHASH_%s", algorithm.mhash_name); - zend_register_long_constant(buf, len, algorithm.value, CONST_PERSISTENT, module_number); + zend_register_long_constant(buf, len, algorithm.value, CONST_PERSISTENT|CONST_DEPRECATED, module_number); } /* TODO: this cause #69823 zend_register_internal_module(&mhash_module_entry); */ @@ -1212,7 +1212,11 @@ PHP_FUNCTION(mhash) struct mhash_bc_entry algorithm_lookup = mhash_to_hash[algorithm]; if (algorithm_lookup.hash_name) { algo = zend_string_init(algorithm_lookup.hash_name, strlen(algorithm_lookup.hash_name), 0); + } else { + RETURN_FALSE; } + } else { + RETURN_FALSE; } if (key) { diff --git a/ext/hash/tests/gh16711_1.phpt b/ext/hash/tests/gh16711_1.phpt new file mode 100644 index 0000000000000..29aef6ac5d78c --- /dev/null +++ b/ext/hash/tests/gh16711_1.phpt @@ -0,0 +1,98 @@ +--TEST-- +GH-16711: Segmentation fault in mhash() +--SKIPIF-- + +--FILE-- +getConstants()); + +var_dump(mhash(133, 1086849124, 133)); +?> +--EXPECTF-- +array(40) { + ["HASH_HMAC"]=> + int(1) + ["MHASH_CRC32"]=> + int(0) + ["MHASH_MD5"]=> + int(1) + ["MHASH_SHA1"]=> + int(2) + ["MHASH_HAVAL256"]=> + int(3) + ["MHASH_RIPEMD160"]=> + int(5) + ["MHASH_TIGER"]=> + int(7) + ["MHASH_GOST"]=> + int(8) + ["MHASH_CRC32B"]=> + int(9) + ["MHASH_HAVAL224"]=> + int(10) + ["MHASH_HAVAL192"]=> + int(11) + ["MHASH_HAVAL160"]=> + int(12) + ["MHASH_HAVAL128"]=> + int(13) + ["MHASH_TIGER128"]=> + int(14) + ["MHASH_TIGER160"]=> + int(15) + ["MHASH_MD4"]=> + int(16) + ["MHASH_SHA256"]=> + int(17) + ["MHASH_ADLER32"]=> + int(18) + ["MHASH_SHA224"]=> + int(19) + ["MHASH_SHA512"]=> + int(20) + ["MHASH_SHA384"]=> + int(21) + ["MHASH_WHIRLPOOL"]=> + int(22) + ["MHASH_RIPEMD128"]=> + int(23) + ["MHASH_RIPEMD256"]=> + int(24) + ["MHASH_RIPEMD320"]=> + int(25) + ["MHASH_SNEFRU256"]=> + int(27) + ["MHASH_MD2"]=> + int(28) + ["MHASH_FNV132"]=> + int(29) + ["MHASH_FNV1A32"]=> + int(30) + ["MHASH_FNV164"]=> + int(31) + ["MHASH_FNV1A64"]=> + int(32) + ["MHASH_JOAAT"]=> + int(33) + ["MHASH_CRC32C"]=> + int(34) + ["MHASH_MURMUR3A"]=> + int(35) + ["MHASH_MURMUR3C"]=> + int(36) + ["MHASH_MURMUR3F"]=> + int(37) + ["MHASH_XXH32"]=> + int(38) + ["MHASH_XXH64"]=> + int(39) + ["MHASH_XXH3"]=> + int(40) + ["MHASH_XXH128"]=> + int(41) +} + +Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d +bool(false) diff --git a/ext/hash/tests/gh16711_2.phpt b/ext/hash/tests/gh16711_2.phpt new file mode 100644 index 0000000000000..a66faf29debd3 --- /dev/null +++ b/ext/hash/tests/gh16711_2.phpt @@ -0,0 +1,98 @@ +--TEST-- +GH-16711: Segmentation fault in mhash() +--SKIPIF-- + +--FILE-- +getConstants()); + +var_dump(mhash(4, 1086849124, 133)); +?> +--EXPECTF-- +array(40) { + ["HASH_HMAC"]=> + int(1) + ["MHASH_CRC32"]=> + int(0) + ["MHASH_MD5"]=> + int(1) + ["MHASH_SHA1"]=> + int(2) + ["MHASH_HAVAL256"]=> + int(3) + ["MHASH_RIPEMD160"]=> + int(5) + ["MHASH_TIGER"]=> + int(7) + ["MHASH_GOST"]=> + int(8) + ["MHASH_CRC32B"]=> + int(9) + ["MHASH_HAVAL224"]=> + int(10) + ["MHASH_HAVAL192"]=> + int(11) + ["MHASH_HAVAL160"]=> + int(12) + ["MHASH_HAVAL128"]=> + int(13) + ["MHASH_TIGER128"]=> + int(14) + ["MHASH_TIGER160"]=> + int(15) + ["MHASH_MD4"]=> + int(16) + ["MHASH_SHA256"]=> + int(17) + ["MHASH_ADLER32"]=> + int(18) + ["MHASH_SHA224"]=> + int(19) + ["MHASH_SHA512"]=> + int(20) + ["MHASH_SHA384"]=> + int(21) + ["MHASH_WHIRLPOOL"]=> + int(22) + ["MHASH_RIPEMD128"]=> + int(23) + ["MHASH_RIPEMD256"]=> + int(24) + ["MHASH_RIPEMD320"]=> + int(25) + ["MHASH_SNEFRU256"]=> + int(27) + ["MHASH_MD2"]=> + int(28) + ["MHASH_FNV132"]=> + int(29) + ["MHASH_FNV1A32"]=> + int(30) + ["MHASH_FNV164"]=> + int(31) + ["MHASH_FNV1A64"]=> + int(32) + ["MHASH_JOAAT"]=> + int(33) + ["MHASH_CRC32C"]=> + int(34) + ["MHASH_MURMUR3A"]=> + int(35) + ["MHASH_MURMUR3C"]=> + int(36) + ["MHASH_MURMUR3F"]=> + int(37) + ["MHASH_XXH32"]=> + int(38) + ["MHASH_XXH64"]=> + int(39) + ["MHASH_XXH3"]=> + int(40) + ["MHASH_XXH128"]=> + int(41) +} + +Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d +bool(false) diff --git a/ext/hash/tests/mhash_001.phpt b/ext/hash/tests/mhash_001.phpt index 6b2011b2f1f68..29f0f473380b1 100644 --- a/ext/hash/tests/mhash_001.phpt +++ b/ext/hash/tests/mhash_001.phpt @@ -35,56 +35,78 @@ foreach ($supported_hash_al as $hash=>$wanted) { } ?> --EXPECTF-- +Deprecated: Constant MHASH_MD5 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_MD5 ok +Deprecated: Constant MHASH_SHA1 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_SHA1 ok +Deprecated: Constant MHASH_HAVAL256 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_HAVAL256 ok +Deprecated: Constant MHASH_HAVAL192 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_HAVAL192 ok +Deprecated: Constant MHASH_HAVAL224 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_HAVAL224 ok +Deprecated: Constant MHASH_HAVAL160 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_HAVAL160 ok +Deprecated: Constant MHASH_RIPEMD160 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_RIPEMD160 ok +Deprecated: Constant MHASH_GOST is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_GOST ok +Deprecated: Constant MHASH_TIGER is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_TIGER ok +Deprecated: Constant MHASH_CRC32 is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_CRC32 ok +Deprecated: Constant MHASH_CRC32B is deprecated in %s on line %d + Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d MHASH_CRC32B ok diff --git a/ext/hash/tests/mhash_003.phpt b/ext/hash/tests/mhash_003.phpt index 26c54af6feb64..f39e1ff387cb9 100644 --- a/ext/hash/tests/mhash_003.phpt +++ b/ext/hash/tests/mhash_003.phpt @@ -35,56 +35,78 @@ foreach ($supported_hash_al as $hash=>$wanted) { } ?> --EXPECTF-- +Deprecated: Constant MHASH_MD5 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_MD5 ok +Deprecated: Constant MHASH_SHA1 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_SHA1 ok +Deprecated: Constant MHASH_HAVAL256 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_HAVAL256 ok +Deprecated: Constant MHASH_HAVAL224 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_HAVAL224 ok +Deprecated: Constant MHASH_HAVAL192 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_HAVAL192 ok +Deprecated: Constant MHASH_HAVAL160 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_HAVAL160 ok +Deprecated: Constant MHASH_RIPEMD160 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_RIPEMD160 ok +Deprecated: Constant MHASH_GOST is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_GOST ok +Deprecated: Constant MHASH_TIGER is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_TIGER ok +Deprecated: Constant MHASH_CRC32 is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_CRC32 ok +Deprecated: Constant MHASH_CRC32B is deprecated in %s on line %d + Deprecated: Function mhash_keygen_s2k() is deprecated since 8.1 in %s on line %d MHASH_CRC32B ok diff --git a/ext/hash/tests/mhash_004.phpt b/ext/hash/tests/mhash_004.phpt index 7087b090fabaf..e47d48eb1a5d8 100644 --- a/ext/hash/tests/mhash_004.phpt +++ b/ext/hash/tests/mhash_004.phpt @@ -12,6 +12,7 @@ var_dump($algo); ?> --EXPECTF-- +Deprecated: Constant MHASH_MD5 is deprecated in %s on line %d int(1) Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c index db2b73e2cb6d3..7154408146d90 100644 --- a/ext/intl/converter/converter.c +++ b/ext/intl/converter/converter.c @@ -27,7 +27,6 @@ typedef struct _php_converter_object { UConverter *src, *dest; - zend_fcall_info to_cb, from_cb; zend_fcall_info_cache to_cache, from_cache; intl_error error; zend_object obj; @@ -230,13 +229,9 @@ static void php_converter_to_u_callback(const void *context, ZVAL_LONG(&zargs[3], *pErrorCode); ZVAL_MAKE_REF(&zargs[3]); - objval->to_cb.param_count = 4; - objval->to_cb.params = zargs; - objval->to_cb.retval = &retval; - if (zend_call_function(&(objval->to_cb), &(objval->to_cache)) == FAILURE) { - /* Unlikely */ - php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR, "Unexpected failure calling toUCallback()"); - } else if (!Z_ISUNDEF(retval)) { + zend_call_known_fcc(&objval->to_cache, &retval, 4, zargs, NULL); + /* When no exception is thrown */ + if (EXPECTED(!Z_ISUNDEF(retval))) { php_converter_append_toUnicode_target(&retval, args, objval); zval_ptr_dtor(&retval); } @@ -297,11 +292,10 @@ static void php_converter_from_u_callback(const void *context, php_converter_object *objval = (php_converter_object*)context; zval retval; zval zargs[4]; - int i; ZVAL_LONG(&zargs[0], reason); array_init(&zargs[1]); - i = 0; + int i = 0; while (i < length) { UChar32 c; U16_NEXT(codeUnits, i, length, c); @@ -311,13 +305,9 @@ static void php_converter_from_u_callback(const void *context, ZVAL_LONG(&zargs[3], *pErrorCode); ZVAL_MAKE_REF(&zargs[3]); - objval->from_cb.param_count = 4; - objval->from_cb.params = zargs; - objval->from_cb.retval = &retval; - if (zend_call_function(&(objval->from_cb), &(objval->from_cache)) == FAILURE) { - /* Unlikely */ - php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR, "Unexpected failure calling fromUCallback()"); - } else if (!Z_ISUNDEF(retval)) { + zend_call_known_fcc(&objval->from_cache, &retval, 4, zargs, NULL); + /* When no exception is thrown */ + if (EXPECTED(!Z_ISUNDEF(retval))) { php_converter_append_fromUnicode_target(&retval, args, objval); zval_ptr_dtor(&retval); } @@ -503,26 +493,20 @@ PHP_METHOD(UConverter, getDestinationType) { /* }}} */ /* {{{ php_converter_resolve_callback */ -static void php_converter_resolve_callback(zval *zobj, - php_converter_object *objval, - const char *callback_name, - zend_fcall_info *finfo, - zend_fcall_info_cache *fcache) { - char *errstr = NULL; - zval caller; +static void php_converter_resolve_callback( + zend_fcall_info_cache *fcc, + zend_object *obj, + 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); - array_init(&caller); - Z_ADDREF_P(zobj); - add_index_zval(&caller, 0, zobj); - add_index_string(&caller, 1, callback_name); - if (zend_fcall_info_init(&caller, 0, finfo, fcache, NULL, &errstr) == FAILURE) { - php_converter_throw_failure(objval, U_INTERNAL_PROGRAM_ERROR, "Error setting converter callback: %s", errstr); - } - zend_array_destroy(Z_ARR(caller)); - ZVAL_UNDEF(&finfo->function_name); - if (errstr) { - efree(errstr); - } + fcc->function_handler = fn; + fcc->object = obj; + fcc->called_scope = obj->ce; + fcc->calling_scope = NULL; + fcc->closure = NULL; } /* }}} */ @@ -544,8 +528,8 @@ PHP_METHOD(UConverter, __construct) { php_converter_set_encoding(objval, &(objval->src), src, src_len ); php_converter_set_encoding(objval, &(objval->dest), dest, dest_len); - php_converter_resolve_callback(ZEND_THIS, objval, "toUCallback", &(objval->to_cb), &(objval->to_cache)); - php_converter_resolve_callback(ZEND_THIS, objval, "fromUCallback", &(objval->from_cb), &(objval->from_cache)); + php_converter_resolve_callback(&objval->to_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("toUCallback")); + php_converter_resolve_callback(&objval->from_cache, Z_OBJ_P(ZEND_THIS), ZEND_STRL("fromUCallback")); } /* }}} */ diff --git a/ext/intl/formatter/formatter.stub.php b/ext/intl/formatter/formatter.stub.php index b6f38e35481b3..e335698688d64 100644 --- a/ext/intl/formatter/formatter.stub.php +++ b/ext/intl/formatter/formatter.stub.php @@ -27,10 +27,8 @@ class NumberFormatter public const int PATTERN_RULEBASED = UNKNOWN; /** @cvalue UNUM_IGNORE */ public const int IGNORE = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 53 /** @cvalue UNUM_CURRENCY_ACCOUNTING */ public const int CURRENCY_ACCOUNTING = UNKNOWN; -#endif /** @cvalue UNUM_DEFAULT */ public const int DEFAULT_STYLE = UNKNOWN; diff --git a/ext/intl/formatter/formatter_arginfo.h b/ext/intl/formatter/formatter_arginfo.h index ac7fed58ec908..0e3d8b797e721 100644 --- a/ext/intl/formatter/formatter_arginfo.h +++ b/ext/intl/formatter/formatter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 79398fd5abd2d1f5176388b67423d937d0e25da4 */ + * Stub hash: caaa6ff408bfd88ec9bb998ffd753f4de971ccff */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter___construct, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0) @@ -184,14 +184,12 @@ static zend_class_entry *register_class_NumberFormatter(void) zend_string *const_IGNORE_name = zend_string_init_interned("IGNORE", sizeof("IGNORE") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 53 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_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); -#endif zval const_DEFAULT_STYLE_value; ZVAL_LONG(&const_DEFAULT_STYLE_value, UNUM_DEFAULT); diff --git a/ext/intl/normalizer/normalizer.h b/ext/intl/normalizer/normalizer.h index 9e71f04aaed83..3c6aa0e6eafc7 100644 --- a/ext/intl/normalizer/normalizer.h +++ b/ext/intl/normalizer/normalizer.h @@ -17,19 +17,6 @@ #include #include -#if U_ICU_VERSION_MAJOR_NUM < 56 -#include - -#define NORMALIZER_FORM_D UNORM_NFD -#define NORMALIZER_NFD UNORM_NFD -#define NORMALIZER_FORM_KD UNORM_NFKD -#define NORMALIZER_NFKD UNORM_NFKD -#define NORMALIZER_FORM_C UNORM_NFC -#define NORMALIZER_NFC UNORM_NFC -#define NORMALIZER_FORM_KC UNORM_NFKC -#define NORMALIZER_NFKC UNORM_NFKC -#define NORMALIZER_DEFAULT UNORM_DEFAULT -#else #include #define NORMALIZER_FORM_D 0x4 @@ -43,6 +30,5 @@ #define NORMALIZER_FORM_KC_CF 0x30 #define NORMALIZER_NFKC_CF NORMALIZER_FORM_KC_CF #define NORMALIZER_DEFAULT NORMALIZER_FORM_C -#endif #endif // NORMALIZER_NORMALIZER_H diff --git a/ext/intl/normalizer/normalizer.stub.php b/ext/intl/normalizer/normalizer.stub.php index aabba3b63cd85..035f43f1bcea7 100644 --- a/ext/intl/normalizer/normalizer.stub.php +++ b/ext/intl/normalizer/normalizer.stub.php @@ -20,12 +20,10 @@ class Normalizer public const int FORM_KC = UNKNOWN; /** @cvalue NORMALIZER_NFKC */ public const int NFKC = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 56 /** @cvalue NORMALIZER_FORM_KC_CF */ public const int FORM_KC_CF = UNKNOWN; /** @cvalue NORMALIZER_NFKC_CF */ public const int NFKC_CF = UNKNOWN; -#endif /** * @tentative-return-type @@ -39,11 +37,9 @@ public static function normalize(string $string, int $form = Normalizer::FORM_C) */ public static function isNormalized(string $string, int $form = Normalizer::FORM_C): bool {} -#if U_ICU_VERSION_MAJOR_NUM >= 56 /** * @tentative-return-type * @alias normalizer_get_raw_decomposition */ public static function getRawDecomposition(string $string, int $form = Normalizer::FORM_C): ?string {} -#endif } diff --git a/ext/intl/normalizer/normalizer_arginfo.h b/ext/intl/normalizer/normalizer_arginfo.h index 5b8d80e3573f8..e5ef152c0423a 100644 --- a/ext/intl/normalizer/normalizer_arginfo.h +++ b/ext/intl/normalizer/normalizer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: c198614563ff0b54d21c7572fe747ddc3191afa3 */ + * Stub hash: 908a9587edd132a41100be09c9908e088f3fa055 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Normalizer_normalize, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) @@ -11,25 +11,19 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Normalizer_isNor ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, form, IS_LONG, 0, "Normalizer::FORM_C") ZEND_END_ARG_INFO() -#if U_ICU_VERSION_MAJOR_NUM >= 56 ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Normalizer_getRawDecomposition, 0, 1, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, form, IS_LONG, 0, "Normalizer::FORM_C") ZEND_END_ARG_INFO() -#endif ZEND_FUNCTION(normalizer_normalize); ZEND_FUNCTION(normalizer_is_normalized); -#if U_ICU_VERSION_MAJOR_NUM >= 56 ZEND_FUNCTION(normalizer_get_raw_decomposition); -#endif static const zend_function_entry class_Normalizer_methods[] = { ZEND_RAW_FENTRY("normalize", zif_normalizer_normalize, arginfo_class_Normalizer_normalize, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) ZEND_RAW_FENTRY("isNormalized", zif_normalizer_is_normalized, arginfo_class_Normalizer_isNormalized, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) -#if U_ICU_VERSION_MAJOR_NUM >= 56 ZEND_RAW_FENTRY("getRawDecomposition", zif_normalizer_get_raw_decomposition, arginfo_class_Normalizer_getRawDecomposition, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) -#endif ZEND_FE_END }; @@ -87,22 +81,18 @@ static zend_class_entry *register_class_Normalizer(void) zend_string *const_NFKC_name = zend_string_init_interned("NFKC", sizeof("NFKC") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 56 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 56 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_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); -#endif return class_entry; } diff --git a/ext/intl/normalizer/normalizer_normalize.c b/ext/intl/normalizer/normalizer_normalize.c index eb55eaea5b7fe..38f12134146a5 100644 --- a/ext/intl/normalizer/normalizer_normalize.c +++ b/ext/intl/normalizer/normalizer_normalize.c @@ -17,18 +17,13 @@ #endif #include "php_intl.h" -#if U_ICU_VERSION_MAJOR_NUM < 56 -#include "unicode/unorm.h" -#else #include -#endif #include "normalizer.h" #include "normalizer_class.h" #include "intl_convert.h" #include -#if U_ICU_VERSION_MAJOR_NUM >= 56 static const UNormalizer2 *intl_get_normalizer(zend_long form, UErrorCode *err) {/*{{{*/ switch (form) @@ -74,7 +69,6 @@ static UBool intl_is_normalized(zend_long form, const UChar *uinput, int32_t uin return unorm2_isNormalized(norm, uinput, uinput_len, err); }/*}}}*/ -#endif /* {{{ Normalize a string. */ PHP_FUNCTION( normalizer_normalize ) @@ -116,9 +110,7 @@ PHP_FUNCTION( normalizer_normalize ) break; case NORMALIZER_FORM_C: case NORMALIZER_FORM_KC: -#if U_ICU_VERSION_MAJOR_NUM >= 56 case NORMALIZER_FORM_KC_CF: -#endif break; default: zend_argument_value_error(2, "must be a a valid normalization form"); @@ -151,11 +143,7 @@ PHP_FUNCTION( normalizer_normalize ) uret_buf = eumalloc( uret_len + 1 ); /* normalize */ -#if U_ICU_VERSION_MAJOR_NUM < 56 - size_needed = unorm_normalize( uinput, uinput_len, form, (int32_t) 0 /* options */, uret_buf, uret_len, &status); -#else size_needed = intl_normalize(form, uinput, uinput_len, uret_buf, uret_len, &status); -#endif /* Bail out if an unexpected error occurred. * (U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough). @@ -179,11 +167,7 @@ PHP_FUNCTION( normalizer_normalize ) status = U_ZERO_ERROR; /* try normalize again */ -#if U_ICU_VERSION_MAJOR_NUM < 56 - size_needed = unorm_normalize( uinput, uinput_len, form, (int32_t) 0 /* options */, uret_buf, uret_len, &status); -#else size_needed = intl_normalize(form, uinput, uinput_len, uret_buf, uret_len, &status); -#endif /* Bail out if an unexpected error occurred. */ if( U_FAILURE(status) ) { @@ -243,9 +227,7 @@ PHP_FUNCTION( normalizer_is_normalized ) case NORMALIZER_FORM_KD: case NORMALIZER_FORM_C: case NORMALIZER_FORM_KC: -#if U_ICU_VERSION_MAJOR_NUM >= 56 case NORMALIZER_FORM_KC_CF: -#endif break; default: zend_argument_value_error(2, "must be a a valid normalization form"); @@ -275,11 +257,7 @@ PHP_FUNCTION( normalizer_is_normalized ) /* test string */ -#if U_ICU_VERSION_MAJOR_NUM < 56 - uret = unorm_isNormalizedWithOptions( uinput, uinput_len, form, (int32_t) 0 /* options */, &status); -#else uret = intl_is_normalized(form, uinput, uinput_len, &status); -#endif efree( uinput ); @@ -298,7 +276,6 @@ PHP_FUNCTION( normalizer_is_normalized ) /* }}} */ /* {{{ Returns the Decomposition_Mapping property for the given UTF-8 encoded code point. */ -#if U_ICU_VERSION_MAJOR_NUM >= 56 PHP_FUNCTION( normalizer_get_raw_decomposition ) { char* input = NULL; @@ -344,5 +321,4 @@ PHP_FUNCTION( normalizer_get_raw_decomposition ) RETVAL_NEW_STR(intl_convert_utf16_to_utf8(decomposition, decomposition_length, &status)); } -#endif /* }}} */ diff --git a/ext/intl/php_intl.stub.php b/ext/intl/php_intl.stub.php index 8dd938e4ec3f2..f3a80dd511943 100644 --- a/ext/intl/php_intl.stub.php +++ b/ext/intl/php_intl.stub.php @@ -537,9 +537,7 @@ function normalizer_normalize(string $string, int $form = Normalizer::FORM_C): s function normalizer_is_normalized(string $string, int $form = Normalizer::FORM_C): bool {} -#if U_ICU_VERSION_MAJOR_NUM >= 56 function normalizer_get_raw_decomposition(string $string, int $form = Normalizer::FORM_C): ?string {} -#endif /* resourceboundle */ @@ -605,11 +603,9 @@ function intltz_get_tz_data_version(): string|false {} function intltz_get_unknown(): IntlTimeZone {} -#if U_ICU_VERSION_MAJOR_NUM >= 52 function intltz_get_windows_id(string $timezoneId): string|false {} function intltz_get_id_for_windows_id(string $timezoneId, ?string $region = null): string|false {} -#endif function intltz_has_same_rules(IntlTimeZone $timezone, IntlTimeZone $other): bool {} diff --git a/ext/intl/php_intl_arginfo.h b/ext/intl/php_intl_arginfo.h index e094df17b9373..11c585d8df63b 100644 --- a/ext/intl/php_intl_arginfo.h +++ b/ext/intl/php_intl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 7a1b6eb454be08742ba45131de8ec57ec70a88c7 */ + * Stub hash: 168eabfdcbf29189f2327448f104ea98752d1c5a */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timezone, "null") @@ -622,12 +622,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_normalizer_is_normalized, 0, 1, ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, form, IS_LONG, 0, "Normalizer::FORM_C") ZEND_END_ARG_INFO() -#if U_ICU_VERSION_MAJOR_NUM >= 56 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_normalizer_get_raw_decomposition, 0, 1, IS_STRING, 1) ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, form, IS_LONG, 0, "Normalizer::FORM_C") ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_resourcebundle_create, 0, 2, ResourceBundle, 1) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1) @@ -732,16 +730,12 @@ ZEND_END_ARG_INFO() #define arginfo_intltz_get_unknown arginfo_intltz_create_default -#if U_ICU_VERSION_MAJOR_NUM >= 52 -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intltz_get_windows_id, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, timezoneId, IS_STRING, 0) -ZEND_END_ARG_INFO() +#define arginfo_intltz_get_windows_id arginfo_intltz_get_region ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_intltz_get_id_for_windows_id, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, timezoneId, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, region, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_intltz_has_same_rules, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, timezone, IntlTimeZone, 0) @@ -938,9 +932,7 @@ ZEND_FUNCTION(msgfmt_get_error_code); ZEND_FUNCTION(msgfmt_get_error_message); ZEND_FUNCTION(normalizer_normalize); ZEND_FUNCTION(normalizer_is_normalized); -#if U_ICU_VERSION_MAJOR_NUM >= 56 ZEND_FUNCTION(normalizer_get_raw_decomposition); -#endif ZEND_FUNCTION(resourcebundle_create); ZEND_FUNCTION(resourcebundle_get); ZEND_FUNCTION(resourcebundle_count); @@ -966,10 +958,8 @@ ZEND_FUNCTION(intltz_get_raw_offset); ZEND_FUNCTION(intltz_get_region); ZEND_FUNCTION(intltz_get_tz_data_version); ZEND_FUNCTION(intltz_get_unknown); -#if U_ICU_VERSION_MAJOR_NUM >= 52 ZEND_FUNCTION(intltz_get_windows_id); ZEND_FUNCTION(intltz_get_id_for_windows_id); -#endif ZEND_FUNCTION(intltz_has_same_rules); ZEND_FUNCTION(intltz_to_date_time_zone); ZEND_FUNCTION(intltz_use_daylight_time); @@ -1129,9 +1119,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(msgfmt_get_error_message, arginfo_msgfmt_get_error_message) ZEND_FE(normalizer_normalize, arginfo_normalizer_normalize) ZEND_FE(normalizer_is_normalized, arginfo_normalizer_is_normalized) -#if U_ICU_VERSION_MAJOR_NUM >= 56 ZEND_FE(normalizer_get_raw_decomposition, arginfo_normalizer_get_raw_decomposition) -#endif ZEND_FE(resourcebundle_create, arginfo_resourcebundle_create) ZEND_FE(resourcebundle_get, arginfo_resourcebundle_get) ZEND_FE(resourcebundle_count, arginfo_resourcebundle_count) @@ -1157,10 +1145,8 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(intltz_get_region, arginfo_intltz_get_region) ZEND_FE(intltz_get_tz_data_version, arginfo_intltz_get_tz_data_version) ZEND_FE(intltz_get_unknown, arginfo_intltz_get_unknown) -#if U_ICU_VERSION_MAJOR_NUM >= 52 ZEND_FE(intltz_get_windows_id, arginfo_intltz_get_windows_id) ZEND_FE(intltz_get_id_for_windows_id, arginfo_intltz_get_id_for_windows_id) -#endif ZEND_FE(intltz_has_same_rules, arginfo_intltz_has_same_rules) ZEND_FE(intltz_to_date_time_zone, arginfo_intltz_to_date_time_zone) ZEND_FE(intltz_use_daylight_time, arginfo_intltz_use_daylight_time) diff --git a/ext/intl/tests/breakiter_getLocale_basic.phpt b/ext/intl/tests/breakiter_getLocale_basic.phpt deleted file mode 100644 index d99fe4a38ee07..0000000000000 --- a/ext/intl/tests/breakiter_getLocale_basic.phpt +++ /dev/null @@ -1,19 +0,0 @@ ---TEST-- -IntlBreakIterator::getLocale(): basic test ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 53.1'); ?> ---FILE-- -getLocale(0)); -var_dump($bi->getLocale(1)); -?> ---EXPECT-- -string(4) "root" -string(4) "root" diff --git a/ext/intl/tests/breakiter_getLocale_basic2.phpt b/ext/intl/tests/breakiter_getLocale_basic2.phpt index f274fe09e97ad..ee92043187ae3 100644 --- a/ext/intl/tests/breakiter_getLocale_basic2.phpt +++ b/ext/intl/tests/breakiter_getLocale_basic2.phpt @@ -3,7 +3,6 @@ IntlBreakIterator::getLocale(): basic test --EXTENSIONS-- intl --SKIPIF-- -= 53.1'); ?> = 0) die('skip for ICU < 64.0'); ?> --FILE-- = 58.1 intl --SKIPIF-- = 58.1'); +if (version_compare(INTL_ICU_VERSION, '57.1') <= 0) die('skip for ICU > 57.1'); ?> --FILE-- = 58.1 intl --SKIPIF-- = 58.1'); +if (version_compare(INTL_ICU_VERSION, '57.1') <= 0) die('skip for ICU > 57.1'); ?> --FILE-- = 51.2'); ?> --FILE-- = 0) - die('skip for ICU < 51.2'); -?> ---FILE-- -format(array($time)) . "\n"; - -//NOT FIXED: -/*$msgf = new MessageFormatter('en_US', -'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); - -echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; -*/ - -?> ---EXPECT-- -date: Tuesday, July 7, 2009 8:41:13 PM EDT -msgf: Tuesday, July 7, 2009 8:41:13 PM EDT diff --git a/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt b/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt index 34cf5aa498f23..6bfbbd8a2f0aa 100644 --- a/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt +++ b/ext/intl/tests/bug58756_MessageFormatter_variant2.phpt @@ -4,10 +4,6 @@ Bug #58756: w.r.t MessageFormatter intl --SKIPIF-- = 51.2'); -} if (str_contains(PHP_OS, 'FreeBSD')) { die('xfail Fails on FreeBSD for unknown reason'); } diff --git a/ext/intl/tests/bug62070_2.phpt b/ext/intl/tests/bug62070_2.phpt index 79471b46711e5..4ea5519e05375 100644 --- a/ext/intl/tests/bug62070_2.phpt +++ b/ext/intl/tests/bug62070_2.phpt @@ -3,7 +3,6 @@ Bug #62070: Collator::getSortKey() returns garbage --EXTENSIONS-- intl --SKIPIF-- -= 53.1'); ?> = 0) die('skip for ICU < 62.1'); ?> --FILE-- = 62.1'); ?> += 0) die('skip for ICU < 76.1'); ?> --FILE-- = 0) die('skip for ICU < 53.1'); ?> += 76.1'); ?> --FILE-- --EXPECT-- -5%2F%3D%3DC%01%09%01%8F%08 +93AAG%01%09%01%DC%08 diff --git a/ext/intl/tests/bug69374.phpt b/ext/intl/tests/bug69374.phpt index 8791c1b6cd550..d9270a2131c2c 100644 --- a/ext/intl/tests/bug69374.phpt +++ b/ext/intl/tests/bug69374.phpt @@ -2,8 +2,6 @@ IntlDateFormatter::formatObject(): returns wrong utf8 value when $format param is utf8 string pattern. --EXTENSIONS-- intl ---SKIPIF-- -= 51.1.2'); ?> --FILE-- = 0) die('skip for ICU >= 74.1'); +if (version_compare(INTL_ICU_VERSION, '74.1') >= 0) die('skip for ICU < 74.1'); ?> --FILE-- = 0) die('skip for ICU < 51.2'); ?> --FILE-- = 53.0'); -?> --FILE-- = 0) - die('skip for ICU < 52.1'); -?> ---FILE-- -setTime(strtotime('2012-02-29 00:00:00 +0000') * 1000); -var_dump( - intlcal_get_day_of_week_type($intlcal, IntlCalendar::DOW_SUNDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_MONDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_TUESDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_FRIDAY), - $intlcal->getDayOfWeekType(IntlCalendar::DOW_SATURDAY) -); - -?> ---EXPECT-- -int(3) -int(0) -int(0) -int(0) -int(1) diff --git a/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt b/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt index 8add2b97b591c..1694d87c59b49 100644 --- a/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt +++ b/ext/intl/tests/calendar_getDayOfWeekType_basic2.phpt @@ -4,11 +4,6 @@ IntlCalendar::getDayOfWeekType() basic test date.timezone=Atlantic/Azores --EXTENSIONS-- intl ---SKIPIF-- -= 52.1'); -?> --FILE-- = 0) die('skip for ICU < 51.2'); ?> ---FILE-- - 'y' , - 'c' => 'i' , - 'a' => 'k' ), - - array( 'a' => 'a' , - 'b' => 'aaa', - 'c' => 'aa' ), - - array( 'a' => 'a' , - 'aaa'=> 'a' , - 'aa' => 'a' ), - - array( '1' => 'abc', - '5' => '!' , - '2' => null , - '7' => '' ), - - array( '1' => '100', - '2' => '25' , - '3' => '36' ), - - array( '1' => 5 , - '2' => '30' , - '3' => 2 ) - ); - - $res_str .= sort_arrays( 'en_US', $test_params ); - - // Sort an array in SORT_STRING mode using en_US locale. - $test_params = array( - array( '1' => '100', - '2' => '25' , - '3' => '36' ), - - array( '1' => 5 , - '2' => '30' , - '3' => 2 ), - - array( '1' => 'd' , - '2' => '' , - '3' => ' a' ), - - array( '1' => 'y' , - '2' => 'k' , - '3' => 'i' ) - ); - - $res_str .= sort_arrays( 'en_US', $test_params, Collator::SORT_STRING ); - - // Sort a non-ASCII array using ru_RU locale. - $test_params = array( - array( 'п' => 'у', - 'б' => 'в', - 'е' => 'а' ), - - array( '1' => 'п', - '4' => '', - '7' => 'd', - '2' => 'пп' ) - ); - - $res_str .= sort_arrays( 'ru_RU', $test_params ); - - - // Sort an array using Lithuanian locale. - $test_params = array( - array( 'd' => 'y', - 'c' => 'i', - 'a' => 'k' ) - ); - - $res_str .= sort_arrays( 'lt_LT', $test_params ); - - return $res_str . "\n"; -} - -include_once( 'ut_common.inc' ); -ut_run(); -?> ---EXPECT-- -Test 1.162b81ac12878b817fc39063097e45b5: -array ( - 'c' => 'i', - 'a' => 'k', - 'd' => 'y', -) - Result: true - -Test 2.93d96e22f692d8a281b0a389f01f8d1e: -array ( - 'a' => 'a', - 'c' => 'aa', - 'b' => 'aaa', -) - Result: true - -Test 3.d5a9747a8bd4c32cb2a705f7e6d8a56f: -array ( - 'a' => 'a', - 'aaa' => 'a', - 'aa' => 'a', -) - Result: true - -Test 4.dcc371022fa1eac76e73b0455d70790a: -array ( - 2 => NULL, - 7 => '', - 5 => '!', - 1 => 'abc', -) - Result: true - -Test 5.99dc71f405b286e03d489061b36e6900: -array ( - 2 => '25', - 3 => '36', - 1 => '100', -) - Result: true - -Test 6.bf5bba243307c9d12934e756ad4be190: -array ( - 3 => 2, - 1 => 5, - 2 => '30', -) - Result: true - -Test 7.e4ee7024c61476e9e7a6c28b5e47df6f: -array ( - 1 => '100', - 2 => '25', - 3 => '36', -) - Result: true - -Test 8.5fa7033dd43784be0db1474eb48b83c8: -array ( - 3 => 2, - 2 => '30', - 1 => 5, -) - Result: true - -Test 9.588cdf4692bc09aa92ffe7e48f9e4579: -array ( - 2 => '', - 3 => ' a', - 1 => 'd', -) - Result: true - -Test 10.be02641a47ebcccd23e4183ca3a415f7: -array ( - 3 => 'i', - 2 => 'k', - 1 => 'y', -) - Result: true - -Test 11.153d9b11d1e5936afc917a94a4e11f34: -array ( - 'е' => 'а', - 'б' => 'в', - 'п' => 'у', -) - Result: true - -Test 12.6eaea3fa21b3b7d006ca7dfa27d4e282: -array ( - 4 => '', - 7 => 'd', - 1 => 'п', - 2 => 'пп', -) - Result: true - -Test 13.8800d48abb960a59002eef77f1d73ae0: -array ( - 'c' => 'i', - 'd' => 'y', - 'a' => 'k', -) - Result: true diff --git a/ext/intl/tests/collator_asort_variant2.phpt b/ext/intl/tests/collator_asort_variant2.phpt index 53c0825abc72c..cfead9f1ff9cd 100644 --- a/ext/intl/tests/collator_asort_variant2.phpt +++ b/ext/intl/tests/collator_asort_variant2.phpt @@ -2,8 +2,6 @@ asort() --EXTENSIONS-- intl ---SKIPIF-- -= 51.2'); ?> --FILE-- = 0) die('skip for ICU < 51.2'); ?> ---FILE-- -'; - case -1: // UCOL_LESS - return '<'; - default: - return '?'; - } -} - -/* - * Compare string pairs in the given array - * using specified locale. - */ -function compare_pairs( $locale, $test_array ) -{ - $res_str = ''; - - $coll = ut_coll_create( $locale ); - - foreach( $test_array as $test_strings ) - { - list( $str1, $str2 ) = $test_strings; - - // Compare strings. - $res_val = cmp_to_char( ut_coll_compare( $coll, $str1, $str2 ) ); - - // Concatenate result strings. - $res_str .= dump( $str1 ) . - ' ' . $res_val . ' ' . - dump( $str2 ) . "\n"; - } - - return $res_str; - -} - -function ut_main() -{ - $res_str = ''; - - // Compare strings using en_US locale. - $test_params = array( - array( 'abc', 'abc' ), - array( 'Abc', 'abc' ), - array( 'a' , 'abc' ), - array( 'a' , '' ), - array( '' , '' ), - array( 'a' , 'b' ), - array( 'ab' , 'b' ), - array( 'ab' , 'a' ), - array( 123 , 'abc' ), - array( 'ac' , null ), - array( '.' , '.' ), - // Try to compare long strings. - array( 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde', - 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea'), - array( null , null ) - ); - - $res_str .= compare_pairs( 'en_US', $test_params ); - - - // Compare strings using ru_RU locale. - $test_params = array( - array( 'а', 'б' ), - array( 'а', 'аа' ), - array( 'аб', 'ба' ), - array( 'а', ',' ), - array( 'а', 'b' ), - array( 'а', 'bb' ), - array( 'а', 'ab' ), - array( 'а', null ) - ); - - $res_str .= compare_pairs( 'ru_RU', $test_params ); - - - // Compare strings using lt_LT locale. - $test_params = array( - array( 'y', 'k' ) - ); - - $res_str .= compare_pairs( 'lt_LT', $test_params ); - - return $res_str; -} - -include_once( 'ut_common.inc' ); -ut_run(); -?> ---EXPECT-- -'abc' = 'abc' -'Abc' > 'abc' -'a' < 'abc' -'a' > '' -'' = '' -'a' < 'b' -'ab' < 'b' -'ab' > 'a' -123 < 'abc' -'ac' > NULL -'.' = '.' -'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde' < 'abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdea' -NULL = NULL -'а' < 'б' -'а' < 'аа' -'аб' < 'ба' -'а' > ',' -'а' > 'b' -'а' > 'bb' -'а' > 'ab' -'а' > NULL -'y' < 'k' diff --git a/ext/intl/tests/collator_compare_variant2.phpt b/ext/intl/tests/collator_compare_variant2.phpt index 6e18b9664ccde..b3188f012b2ee 100644 --- a/ext/intl/tests/collator_compare_variant2.phpt +++ b/ext/intl/tests/collator_compare_variant2.phpt @@ -2,8 +2,6 @@ compare() --EXTENSIONS-- intl ---SKIPIF-- -= 51.2'); ?> --FILE-- = 4.8 && icu < 53.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 53.1'); ?> ---FILE-- - ---EXPECTF-- -Locale: 'EN-US-ODESSA' - ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA' - ULOC_VALID_LOCALE = 'en_US' - ULOC_ACTUAL_LOCALE = 'root' -Locale: 'UK_UA_ODESSA' - ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA' - ULOC_VALID_LOCALE = 'uk_UA' - ULOC_ACTUAL_LOCALE = 'uk' -Locale: 'uk-ua_CALIFORNIA@currency=;currency=GRN' - ULOC_REQUESTED_LOCALE = 'uk-ua_CALIFORNIA@currency=;currency=GRN' - ULOC_VALID_LOCALE = 'uk_UA' - ULOC_ACTUAL_LOCALE = 'uk' -Locale: '' - ULOC_REQUESTED_LOCALE = '' - ULOC_VALID_LOCALE = '%s' - ULOC_ACTUAL_LOCALE = '%s' -Locale: 'root' - ULOC_REQUESTED_LOCALE = 'root' - ULOC_VALID_LOCALE = 'root' - ULOC_ACTUAL_LOCALE = 'root' -Locale: 'uk@currency=EURO' - ULOC_REQUESTED_LOCALE = 'uk@currency=EURO' - ULOC_VALID_LOCALE = 'uk' - ULOC_ACTUAL_LOCALE = 'uk' -Error creating collator with '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than %d characters: U_ILLEGAL_ARGUMENT_ERROR diff --git a/ext/intl/tests/collator_create3.phpt b/ext/intl/tests/collator_create3.phpt deleted file mode 100644 index f45eb7d0c55a5..0000000000000 --- a/ext/intl/tests/collator_create3.phpt +++ /dev/null @@ -1,84 +0,0 @@ ---TEST-- -create() icu >= 53.1 && icu < 54.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 53.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- - ---EXPECTF-- -Locale: 'EN-US-ODESSA' - ULOC_REQUESTED_LOCALE = 'EN-US-ODESSA' - ULOC_VALID_LOCALE = 'en_US' - ULOC_ACTUAL_LOCALE = 'root' -Locale: 'UK_UA_ODESSA' - ULOC_REQUESTED_LOCALE = 'UK_UA_ODESSA' - ULOC_VALID_LOCALE = 'uk' - ULOC_ACTUAL_LOCALE = 'uk' -Locale: 'uk-ua_CALIFORNIA@currency=;currency=GRN' - ULOC_REQUESTED_LOCALE = 'uk-ua_CALIFORNIA@currency=;currency=GRN' - ULOC_VALID_LOCALE = 'root' - ULOC_ACTUAL_LOCALE = 'root' -Locale: '' - ULOC_REQUESTED_LOCALE = '' - ULOC_VALID_LOCALE = '%s' - ULOC_ACTUAL_LOCALE = '%s' -Locale: 'root' - ULOC_REQUESTED_LOCALE = 'root' - ULOC_VALID_LOCALE = 'root' - ULOC_ACTUAL_LOCALE = 'root' -Locale: 'uk@currency=EURO' - ULOC_REQUESTED_LOCALE = 'uk@currency=EURO' - ULOC_VALID_LOCALE = 'uk' - ULOC_ACTUAL_LOCALE = 'uk' -Error creating collator with '12345678911131517192123252729313335373941434547495153575961636567697173757779818385878991939597991234567891113151719212325272931333537394143454749515357596163656769717375777981838587899193959799' locale: Locale string too long, should be no longer than %d characters: U_ILLEGAL_ARGUMENT_ERROR diff --git a/ext/intl/tests/collator_create4.phpt b/ext/intl/tests/collator_create4.phpt index 690b521ab3203..5747d366dcfa4 100644 --- a/ext/intl/tests/collator_create4.phpt +++ b/ext/intl/tests/collator_create4.phpt @@ -2,8 +2,6 @@ create() icu >= 53.1 --EXTENSIONS-- intl ---SKIPIF-- -= 54.1'); ?> --FILE-- = 4.8 and < 51.2 */ -if (version_compare(INTL_ICU_VERSION, '51.2') >= 0) die('skip for ICU < 51.2'); ?> ---FILE-- - ---EXPECT-- -source: abc -key: 27292b01070107 -source: abd -key: 27292d01070107 -source: aaa -key: 27272701070107 -source: аа -key: 5c0a0a01060106 -source: а -key: 5c0a01050105 -source: z -key: 5901050105 -source: -key: 0101 -source: -key: 0101 -source: 3 -key: 1801050105 -source: y -key: 5701050105 -source: i -key: 3701050105 -source: k -key: 3b01050105 -source: абг -key: 5c0a161a01070107 -source: абв -key: 5c0a161801070107 -source: жжж -key: 5c3a3a3a01070107 -source: эюя -key: 5d3b3f4501070107 -source: абг -key: 5c0a161a01070107 -source: абв -key: 5c0a161801070107 -source: жжж -key: 5c3a3a3a01070107 -source: эюя -key: 5d3b3f4501070107 diff --git a/ext/intl/tests/collator_get_sort_key_variant3.phpt b/ext/intl/tests/collator_get_sort_key_variant3.phpt deleted file mode 100644 index 1281112c5ae08..0000000000000 --- a/ext/intl/tests/collator_get_sort_key_variant3.phpt +++ /dev/null @@ -1,98 +0,0 @@ ---TEST-- -collator_get_sort_key() icu >= 53.1 && icu < 54.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 53.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- - ---EXPECT-- -source: abc -key: 292b2d01070107 -source: abd -key: 292b2f01070107 -source: aaa -key: 29292901070107 -source: аа -key: 5e090901060106 -source: а -key: 5e0901050105 -source: z -key: 5b01050105 -source: -key: 0101 -source: 3 -key: 1a01050105 -source: y -key: 5901050105 -source: i -key: 3901050105 -source: k -key: 3d01050105 -source: абг -key: 2809131701070107 -source: абв -key: 2809131501070107 -source: жжж -key: 2833333301070107 -source: эюя -key: 28cdd1d501070107 -source: абг -key: 5e09131701070107 -source: абв -key: 5e09131501070107 -source: жжж -key: 5e33333301070107 -source: эюя -key: 5ecdd1d501070107 diff --git a/ext/intl/tests/collator_get_sort_key_variant4.phpt b/ext/intl/tests/collator_get_sort_key_variant4.phpt deleted file mode 100644 index 32d1ea70114ff..0000000000000 --- a/ext/intl/tests/collator_get_sort_key_variant4.phpt +++ /dev/null @@ -1,98 +0,0 @@ ---TEST-- -collator_get_sort_key() icu >= 54.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 55.1'); ?> -= 54.1'); ?> ---FILE-- - ---EXPECT-- -source: abc -key: 292b2d01070107 -source: abd -key: 292b2f01070107 -source: aaa -key: 29292901070107 -source: аа -key: 5e060601060106 -source: а -key: 5e0601050105 -source: z -key: 5b01050105 -source: -key: 0101 -source: 3 -key: 1a01050105 -source: y -key: 5901050105 -source: i -key: 3901050105 -source: k -key: 3d01050105 -source: абг -key: 2806101401070107 -source: абв -key: 2806101201070107 -source: жжж -key: 2830303001070107 -source: эюя -key: 28ccd0d401070107 -source: абг -key: 5e06101401070107 -source: абв -key: 5e06101201070107 -source: жжж -key: 5e30303001070107 -source: эюя -key: 5eccd0d401070107 diff --git a/ext/intl/tests/collator_get_sort_key_variant5.phpt b/ext/intl/tests/collator_get_sort_key_variant5.phpt deleted file mode 100644 index 9c382aeabf9a4..0000000000000 --- a/ext/intl/tests/collator_get_sort_key_variant5.phpt +++ /dev/null @@ -1,98 +0,0 @@ ---TEST-- -collator_get_sort_key() icu >= 55.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 56.1'); ?> -= 55.1'); ?> ---FILE-- - ---EXPECT-- -source: abc -key: 292b2d01070107 -source: abd -key: 292b2f01070107 -source: aaa -key: 29292901070107 -source: аа -key: 60060601060106 -source: а -key: 600601050105 -source: z -key: 5b01050105 -source: -key: 0101 -source: 3 -key: 1801050105 -source: y -key: 5901050105 -source: i -key: 3901050105 -source: k -key: 3d01050105 -source: абг -key: 26060c1001070107 -source: абв -key: 26060c0e01070107 -source: жжж -key: 2626262601070107 -source: эюя -key: 26b4b6ba01070107 -source: абг -key: 60060c1001070107 -source: абв -key: 60060c0e01070107 -source: жжж -key: 6026262601070107 -source: эюя -key: 60b4b6ba01070107 diff --git a/ext/intl/tests/collator_get_sort_key_variant6.phpt b/ext/intl/tests/collator_get_sort_key_variant6.phpt index 75e7031379792..07cce1a0c36df 100644 --- a/ext/intl/tests/collator_get_sort_key_variant6.phpt +++ b/ext/intl/tests/collator_get_sort_key_variant6.phpt @@ -3,7 +3,6 @@ collator_get_sort_key() icu >= 56.1 --EXTENSIONS-- intl --SKIPIF-- -= 56.1'); ?> = 0) die('skip for ICU < 62.1'); ?> --FILE-- = 62.1 intl --SKIPIF-- = 62.1'); ?> += 0) die('skip for ICU < 76.1'); ?> --FILE-- = 62.1 --EXTENSIONS-- intl --SKIPIF-- -= 51.2'); ?> -= 0) die('skip for ICU < 53.1'); ?> += 76.1'); ?> --FILE-- --EXPECT-- source: abc -key: 27292b01070107 +key: 2b2d2f01070107 source: abd -key: 27292d01070107 +key: 2b2d3101070107 source: aaa -key: 27272701070107 +key: 2b2b2b01070107 source: аа -key: 5c0a0a01060106 +key: 62060601060106 source: а -key: 5c0a01050105 +key: 620601050105 source: z -key: 5901050105 +key: 5d01050105 source: key: 0101 source: 3 key: 1801050105 source: y -key: 5701050105 +key: 5b01050105 source: i -key: 3701050105 -source: k key: 3b01050105 +source: k +key: 3f01050105 source: абг -key: 260a161a01070107 +key: 28060c1001070107 source: абв -key: 260a161801070107 +key: 28060c0e01070107 source: жжж -key: 263a3a3a01070107 +key: 282c2c2c01070107 source: эюя -key: 273b3f4501070107 +key: 28eef0f401070107 source: абг -key: 5c0a161a01070107 +key: 62060c1001070107 source: абв -key: 5c0a161801070107 +key: 62060c0e01070107 source: жжж -key: 5c3a3a3a01070107 +key: 622c2c2c01070107 source: эюя -key: 5d3b3f4501070107 +key: 62eef0f401070107 diff --git a/ext/intl/tests/collator_sort.phpt b/ext/intl/tests/collator_sort.phpt deleted file mode 100644 index ff26d8f11b9f8..0000000000000 --- a/ext/intl/tests/collator_sort.phpt +++ /dev/null @@ -1,249 +0,0 @@ ---TEST-- -sort() ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 51.2'); ?> ---FILE-- - ---EXPECT-- -Test 1.e8f1cd28133d79ecd660002f1c660d0e: -array ( - 0 => 'aaa', - 1 => 'abc', - 2 => 'abd', -) - Result: true - -Test 2.c2ded12173dd2996927378cae37eb275: -array ( - 0 => '_', - 1 => '1', - 2 => 'm', -) - Result: true - -Test 3.54071c968d71cb98c5d379145f8d7d38: -array ( - 0 => 'a', - 1 => 'aa', - 2 => 'aaa', -) - Result: true - -Test 4.19abe63d6f6dfef65b0e3c9ab4826b07: -array ( - 0 => 'ab', - 1 => 'b', - 2 => 'ba', -) - Result: true - -Test 5.9a8dc0a9bc771368c2f1fc3d02754610: -array ( - 0 => 'a', - 1 => 'c', - 2 => 'e', -) - Result: true - -Test 6.ab530b060e5e54a65bfb8b9f8fc61870: -array ( - 0 => '25', - 1 => '36', - 2 => '100', -) - Result: true - -Test 7.0718dd838509017bded2ed307a6e785f: -array ( - 0 => 2, - 1 => 5, - 2 => '30', -) - Result: true - -Test 8.923d65739c5219c634616ffd100a50e4: -array ( - 0 => '', - 1 => ' a', - 2 => 'd', -) - Result: true - -Test 9.289bc2f28e87d3201ec9d7e8477ae1b0: -array ( - 0 => ' a', - 1 => 'd ', - 2 => 'f ', -) - Result: true - -Test 10.de0fd958484f2377a645835d7fbcf124: -array ( - 0 => NULL, - 1 => '3', - 2 => 'a', -) - Result: true - -Test 11.dd2b8f0adb37c45d528cad1a0cc0f361: -array ( - 0 => 'i', - 1 => 'k', - 2 => 'y', -) - Result: true - -Test 12.1e6b4d6f7df9d4580317634ea46d8208: -array ( - 0 => '100', - 1 => '25', - 2 => '36', -) - Result: true - -Test 13.cec115dc9850b98dfbdf102efa09e61b: -array ( - 0 => 2, - 1 => '30', - 2 => 5, -) - Result: true - -Test 14.923d65739c5219c634616ffd100a50e4: -array ( - 0 => '', - 1 => ' a', - 2 => 'd', -) - Result: true - -Test 15.dd2b8f0adb37c45d528cad1a0cc0f361: -array ( - 0 => 'i', - 1 => 'k', - 2 => 'y', -) - Result: true - -Test 16.ca0e38a2e3147dd97070f2128f140934: -array ( - 0 => 'abc', - 1 => 'ааа', - 2 => 'абв', - 3 => 'абг', -) - Result: true - -Test 17.91480b10473a0c96a4cd6d88c23c577a: -array ( - 0 => 'а', - 1 => 'аа', - 2 => 'ааа', -) - Result: true - -Test 18.fdd3fe3981476039164aa000bf9177f2: -array ( - 0 => 'i', - 1 => 'y', - 2 => 'k', -) - Result: true diff --git a/ext/intl/tests/collator_sort_variant2.phpt b/ext/intl/tests/collator_sort_variant2.phpt index 30fcc5a5ba30a..01c33bcc1f1a7 100644 --- a/ext/intl/tests/collator_sort_variant2.phpt +++ b/ext/intl/tests/collator_sort_variant2.phpt @@ -2,8 +2,6 @@ sort() --EXTENSIONS-- intl ---SKIPIF-- -= 51.2'); ?> --FILE-- = 0) die('skip for ICU < 51.2'); ?> ---FILE-- - ---EXPECT-- -Test 1.e8f1cd28133d79ecd660002f1c660d0e: -array ( - 0 => 'aaa', - 1 => 'abc', - 2 => 'abd', -) - Result: true - -Test 2.c2ded12173dd2996927378cae37eb275: -array ( - 0 => '_', - 1 => '1', - 2 => 'm', -) - Result: true - -Test 3.54071c968d71cb98c5d379145f8d7d38: -array ( - 0 => 'a', - 1 => 'aa', - 2 => 'aaa', -) - Result: true - -Test 4.19abe63d6f6dfef65b0e3c9ab4826b07: -array ( - 0 => 'ab', - 1 => 'b', - 2 => 'ba', -) - Result: true - -Test 5.9a8dc0a9bc771368c2f1fc3d02754610: -array ( - 0 => 'a', - 1 => 'c', - 2 => 'e', -) - Result: true - -Test 6.923d65739c5219c634616ffd100a50e4: -array ( - 0 => '', - 1 => ' a', - 2 => 'd', -) - Result: true - -Test 7.289bc2f28e87d3201ec9d7e8477ae1b0: -array ( - 0 => ' a', - 1 => 'd ', - 2 => 'f ', -) - Result: true - -Test 8.de0fd958484f2377a645835d7fbcf124: -array ( - 0 => NULL, - 1 => '3', - 2 => 'a', -) - Result: true - -Test 9.dd2b8f0adb37c45d528cad1a0cc0f361: -array ( - 0 => 'i', - 1 => 'k', - 2 => 'y', -) - Result: true - -Test 10.ca0e38a2e3147dd97070f2128f140934: -array ( - 0 => 'abc', - 1 => 'ааа', - 2 => 'абв', - 3 => 'абг', -) - Result: true - -Test 11.91480b10473a0c96a4cd6d88c23c577a: -array ( - 0 => 'а', - 1 => 'аа', - 2 => 'ааа', -) - Result: true - -Test 12.fdd3fe3981476039164aa000bf9177f2: -array ( - 0 => 'i', - 1 => 'y', - 2 => 'k', -) - Result: true diff --git a/ext/intl/tests/collator_sort_with_sort_keys_variant2.phpt b/ext/intl/tests/collator_sort_with_sort_keys_variant2.phpt index 72ea613cbe1f9..89bad4bf1b10c 100644 --- a/ext/intl/tests/collator_sort_with_sort_keys_variant2.phpt +++ b/ext/intl/tests/collator_sort_with_sort_keys_variant2.phpt @@ -2,8 +2,6 @@ sort_with_sort_keys() --EXTENSIONS-- intl ---SKIPIF-- -= 51.2'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -format(strtotime('2012-01-01 00:00:00 +0000'))); -var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); -var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); - -new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - -1); -?> -==DONE== ---EXPECTF-- -string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" -string(44) "Sunday, January 1, 2012 5:12:00 AM GMT+05:12" -string(42) "Sunday, Tevet 6, 5772 5:12:00 AM GMT+05:12" - -Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars.php:%d -Stack trace: -#0 %sdateformat_calendars.php(%d): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1) -#1 {main} - thrown in %sdateformat_calendars.php on line %d diff --git a/ext/intl/tests/dateformat_calendars_variant2.phpt b/ext/intl/tests/dateformat_calendars_variant2.phpt deleted file mode 100644 index 410d40f07f786..0000000000000 --- a/ext/intl/tests/dateformat_calendars_variant2.phpt +++ /dev/null @@ -1,49 +0,0 @@ ---TEST-- -IntlDateFormatter, calendars and time zone ---INI-- -date.timezone=Atlantic/Azores ---EXTENSIONS-- -intl ---SKIPIF-- -= 51.2'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- -format(strtotime('2012-01-01 00:00:00 +0000'))); -var_dump($fmt2->format(strtotime('2012-01-01 00:00:00 +0000'))); -var_dump($fmt3->format(strtotime('2012-01-01 00:00:00 +0000'))); - -new IntlDateFormatter('en_US@calendar=hebrew', - IntlDateFormatter::FULL, - IntlDateFormatter::FULL, - 'GMT+05:12', - -1); -?> -==DONE== ---EXPECTF-- -string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12" -string(47) "Sunday, January 1, 2012 at 5:12:00 AM GMT+05:12" -string(48) "Sunday, Tevet 6, 5772 AM at 5:12:00 AM GMT+05:12" - -Fatal error: Uncaught IntlException: IntlDateFormatter::__construct(): datefmt_create: Invalid value for calendar type; it must be one of IntlDateFormatter::TRADITIONAL (locale's default calendar) or IntlDateFormatter::GREGORIAN. Alternatively, it can be an IntlCalendar object in %sdateformat_calendars_variant2.php:27 -Stack trace: -#0 %sdateformat_calendars_variant2.php(27): IntlDateFormatter->__construct('en_US@calendar=...', 0, 0, 'GMT+05:12', -1) -#1 {main} - thrown in %sdateformat_calendars_variant2.php on line 27 diff --git a/ext/intl/tests/dateformat_calendars_variant3.phpt b/ext/intl/tests/dateformat_calendars_variant3.phpt index 1ad970d07d0e6..037d8066a0815 100644 --- a/ext/intl/tests/dateformat_calendars_variant3.phpt +++ b/ext/intl/tests/dateformat_calendars_variant3.phpt @@ -5,7 +5,6 @@ date.timezone=Atlantic/Azores --EXTENSIONS-- intl --SKIPIF-- -= 54.1'); ?> = 0) die('skip for ICU < 72.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -format($ts), "\n"; - -$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic'); -$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal); -echo $df->format($ts), "\n"; - -//override calendar's timezone -$cal = new IntlGregorianCalendar('UTC', NULL); -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal); -echo $df->format($ts), "\n"; - -//default calendar is gregorian -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0); -echo $df->format($ts), "\n"; - -//try now with traditional -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL); -echo $df->format($ts), "\n"; - -//the timezone can be overridden when not specifying a calendar -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0); -echo $df->format($ts), "\n"; - -?> ---EXPECTF-- -domingo%S 1 de enero de 2012 00:00:00 GMT -domingo%S 8 de Safar de 1433 00:00:00 GMT -domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central -sábado%S 31 de diciembre de 2011 d.C. 23:00:00 Hora %Sde las Azores -sábado%S 7 de Safar de 1433 AH 23:00:00 Hora %Sde las Azores -domingo%S 8 de Safar de 1433 AH 00:00:00 GMT -domingo%S 1 de enero de 2012 00:00:00 GMT diff --git a/ext/intl/tests/dateformat_create_cal_arg_variant2.phpt b/ext/intl/tests/dateformat_create_cal_arg_variant2.phpt deleted file mode 100644 index 08de3f60eda7b..0000000000000 --- a/ext/intl/tests/dateformat_create_cal_arg_variant2.phpt +++ /dev/null @@ -1,51 +0,0 @@ ---TEST-- -IntlDateFormatter: several forms of the calendar arg ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- -format($ts), "\n"; - -$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic'); -$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal); -echo $df->format($ts), "\n"; - -//override calendar's timezone -$cal = new IntlGregorianCalendar('UTC', NULL); -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal); -echo $df->format($ts), "\n"; - -//default calendar is gregorian -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0); -echo $df->format($ts), "\n"; - -//try now with traditional -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL); -echo $df->format($ts), "\n"; - -//the timezone can be overridden when not specifying a calendar -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0); -echo $df->format($ts), "\n"; - -?> ---EXPECTF-- -domingo%S 1 de enero de 2012 00:00:00 GMT -domingo%S 8 de Safar de 1433 00:00:00 GMT -domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa central -sábado%S 31 de diciembre de 2011 d.C. 23:00:00 Hora %Sde las Azores -sábado%S 7 de Safar de 1433 AH 23:00:00 Hora %Sde las Azores -domingo%S 8 de Safar de 1433 AH 00:00:00 GMT -domingo%S 1 de enero de 2012 00:00:00 GMT diff --git a/ext/intl/tests/dateformat_create_cal_arg_variant3.phpt b/ext/intl/tests/dateformat_create_cal_arg_variant3.phpt deleted file mode 100644 index 6c4814ee4391c..0000000000000 --- a/ext/intl/tests/dateformat_create_cal_arg_variant3.phpt +++ /dev/null @@ -1,52 +0,0 @@ ---TEST-- -IntlDateFormatter: several forms of the calendar arg ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- -format($ts), "\n"; - -$cal = IntlCalendar::createInstance('UTC', 'en@calendar=islamic'); -$df = new IntlDateFormatter('es_ES', 0, 0, NULL, $cal); -echo $df->format($ts), "\n"; - -//override calendar's timezone -$cal = new IntlGregorianCalendar('UTC', NULL); -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Madrid', $cal); -echo $df->format($ts), "\n"; - -//default calendar is gregorian -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0); -echo $df->format($ts), "\n"; - -//try now with traditional -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, NULL, IntlDateFormatter::TRADITIONAL); -echo $df->format($ts), "\n"; - -//the timezone can be overridden when not specifying a calendar -$df = new IntlDateFormatter('es_ES@calendar=islamic', 0, 0, 'UTC', IntlDateFormatter::TRADITIONAL); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'UTC', 0); -echo $df->format($ts), "\n"; - -?> ---EXPECTF-- -domingo%S 1 de enero de 2012, 0:00:00 (GMT) -domingo%S 8 de Safar de 1433, 0:00:00 (GMT) -domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central) -sábado%S 31 de diciembre de 2011 d. C., 23:00:00 (Hora estándar %Sde las Azores) -sábado%S 7 de Safar de 1433 AH, 23:00:00 (Hora estándar %Sde las Azores) -domingo%S 8 de Safar de 1433 AH, 0:00:00 (GMT) -domingo%S 1 de enero de 2012, 0:00:00 (GMT) diff --git a/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt b/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt index 7a1288c3e9fb3..1571e08740edd 100644 --- a/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt +++ b/ext/intl/tests/dateformat_create_cal_arg_variant4.phpt @@ -3,8 +3,7 @@ IntlDateFormatter: several forms of the calendar arg --EXTENSIONS-- intl --SKIPIF-- -= 54.1'); ?> -= 0) die('skip for ICU <= 57.1'); ?> += 0) die('skip for ICU < 58.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 4, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( - 'tm_sec' => 11, - 'tm_min' => 13, - 'tm_hour' => 0, - 'tm_mday' => 17, - 'tm_mon' => 11, - 'tm_year' => -5 - ); - - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); - $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); - $d2->setTimezone(new DateTimeZone("PDT")); - $dates = array( - $d1, - $d2, - new StdClass(), - ); - - //Test format with input as a timestamp : integer - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - } - } - } - - //Test format with input as a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ - $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - foreach($dates as $date_entry) { - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\n------------"; - $res_str .= "\nDate is: ".var_export($date_entry, true); - $res_str .= "\n------------"; - - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $date_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted DateTime is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - return $res_str; - -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); -?> ---EXPECT-- ------------- - -Input timestamp is : 0 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 31, 1969 2:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 31, 1969 2:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 31, 1969 2:00:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/31/69 2:00 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691231 02:00 PM ------------- - -Input timestamp is : -1200000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 17, 1969 4:40:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 17, 1969 4:40:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 17, 1969 4:40:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/17/69 4:40 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691217 04:40 PM ------------- - -Input timestamp is : 1200000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, January 14, 1970 11:20:00 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : January 14, 1970 11:20:00 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Jan 14, 1970 11:20:00 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 1/14/70 11:20 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19700114 11:20 AM ------------- - -Input timestamp is : 2200000000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Sunday, September 18, 2039 1:06:40 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : September 18, 2039 1:06:40 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Sep 18, 2039 1:06:40 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 9/18/39 1:06 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 20390918 01:06 PM ------------- - -Input timestamp is : -2200000000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Saturday, April 14, 1900 2:53:20 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : April 14, 1900 2:53:20 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Apr 14, 1900 2:53:20 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 4/14/00 2:53 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19000414 02:53 PM ------------- - -Input timestamp is : 90099999 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, November 8, 1972 9:46:39 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : November 8, 1972 9:46:39 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Nov 8, 1972 9:46:39 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 11/8/72 9:46 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19721108 09:46 AM ------------- - -Input timestamp is : 3600 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 31, 1969 3:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 31, 1969 3:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 31, 1969 3:00:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/31/69 3:00 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691231 03:00 PM ------------- - -Input timestamp is : -3600 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 31, 1969 1:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 31, 1969 1:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 31, 1969 1:00:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/31/69 1:00 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691231 01:00 PM ------------- - -Input localtime is : tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_mday : '3' , tm_mon : '3' , tm_year : '105' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Sunday, April 3, 2005 7:03:24 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : April 3, 2005 7:03:24 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : Apr 3, 2005 7:03:24 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted localtime_array is : 4/3/05 7:03 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted localtime_array is : 20050403 07:03 PM ------------- - -Input localtime is : tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_mday : '13' , tm_mon : '4' , tm_year : '205' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Wednesday, May 13, 2105 7:05:21 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : May 13, 2105 7:05:21 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : May 13, 2105 7:05:21 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted localtime_array is : 5/13/05 7:05 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted localtime_array is : 21050513 07:05 AM ------------- - -Input localtime is : tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_mday : '17' , tm_mon : '11' , tm_year : '-5' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Tuesday, December 17, 1895 12:13:11 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : December 17, 1895 12:13:11 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : Dec 17, 1895 12:13:11 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted localtime_array is : 12/17/95 12:13 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted localtime_array is : 18951217 12:13 AM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : Thursday, December 31, 2009 3:02:03 PM GMT-10:00 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : December 31, 2009 3:02:03 PM GMT-10:00 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : Dec 31, 2009 3:02:03 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : 12/31/09 3:02 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : 20091231 03:02 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 2, - 'timezone' => 'PDT', -)) ------------- -Formatted DateTime is : Saturday, December 30, 2000 5:04:05 PM GMT-10:00 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 2, - 'timezone' => 'PDT', -)) ------------- -Formatted DateTime is : December 30, 2000 5:04:05 PM GMT-10:00 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 2, - 'timezone' => 'PDT', -)) ------------- -Formatted DateTime is : Dec 30, 2000 5:04:05 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 2, - 'timezone' => 'PDT', -)) ------------- -Formatted DateTime is : 12/30/00 5:04 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 2, - 'timezone' => 'PDT', -)) ------------- -Formatted DateTime is : 20001230 05:04 PM ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' diff --git a/ext/intl/tests/dateformat_formatObject_calendar.phpt b/ext/intl/tests/dateformat_formatObject_calendar.phpt deleted file mode 100644 index 4c85bcfaa74db..0000000000000 --- a/ext/intl/tests/dateformat_formatObject_calendar.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -IntlDateFormatter::formatObject(): IntlCalendar tests ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -setTime(strtotime('2012-01-01 00:00:00')*1000.); -echo IntlDateFormatter::formatObject($cal), "\n"; -echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n"; - -?> ---EXPECTF-- -01/01/2012 00:00:00 -Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental -Jan 1, 2012 12:00:00 AM -1/1/12 12:00:00 AM Western European %STime -Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon) -Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00 -06/02/1433 00:00:00 -Sunday, Safar 6, 1433 12:00:00 AM Western European %STime diff --git a/ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt b/ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt deleted file mode 100644 index c6123f27347f0..0000000000000 --- a/ext/intl/tests/dateformat_formatObject_calendar_variant2.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -IntlDateFormatter::formatObject(): IntlCalendar tests ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- -setTime(strtotime('2012-01-01 00:00:00')*1000.); -echo IntlDateFormatter::formatObject($cal), "\n"; -echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n"; - -?> ---EXPECTF-- -01/01/2012, 00:00:00 -Domingo, 1 de Janeiro de 2012 às 00:00:00 Hora %Sda Europa Ocidental -Jan 1, 2012, 12:00:00 AM -1/1/12, 12:00:00 AM Western European Standard %STime -Sun 2012-01-1 00,00,00.000 Portugal Time -Domingo, 1 de Janeiro de 2012 às 05:00:00 GMT+03:00 -06/02/1433, 00:00:00 -Sunday, Safar 6, 1433 at 12:00:00 AM Western European Standard Time diff --git a/ext/intl/tests/dateformat_formatObject_calendar_variant3.phpt b/ext/intl/tests/dateformat_formatObject_calendar_variant3.phpt deleted file mode 100644 index 343074ccb9387..0000000000000 --- a/ext/intl/tests/dateformat_formatObject_calendar_variant3.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -IntlDateFormatter::formatObject(): IntlCalendar tests ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- -setTime(strtotime('2012-01-01 00:00:00')*1000.); -echo IntlDateFormatter::formatObject($cal), "\n"; -echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n"; - -?> ---EXPECTF-- -01/01/2012, 00:00:00 -domingo, 1 de Janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental -Jan 1, 2012, 12:00:00 AM -1/1/12, 12:00:00 AM Western European Standard %STime -Sun 2012-01-1 00,00,00.000 Portugal Time -domingo, 1 de Janeiro de 2012 às 05:00:00 GMT+03:00 -06/02/1433, 00:00:00 -Sunday, Safar 6, 1433 at 12:00:00 AM Western European Standard Time diff --git a/ext/intl/tests/dateformat_formatObject_calendar_variant4.phpt b/ext/intl/tests/dateformat_formatObject_calendar_variant4.phpt deleted file mode 100644 index 828585c6e3543..0000000000000 --- a/ext/intl/tests/dateformat_formatObject_calendar_variant4.phpt +++ /dev/null @@ -1,38 +0,0 @@ ---TEST-- -IntlDateFormatter::formatObject(): IntlCalendar tests ---EXTENSIONS-- -intl ---SKIPIF-- -= 54.1'); ?> -= 0) die('skip for ICU < 55.1'); ?> ---FILE-- -setTime(strtotime('2012-01-01 00:00:00')*1000.); -echo IntlDateFormatter::formatObject($cal), "\n"; -echo IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL, "en-US"), "\n"; - -?> ---EXPECTF-- -01/01/2012, 00:00:00 -domingo, 1 de janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental -Jan 1, 2012, 12:00:00 AM -1/1/12, 12:00:00 AM Western European Standard %STime -Sun 2012-01-1 00,00,00.000 Portugal Time -domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00 -06/02/1433, 00:00:00 -Sunday, Safar 6, 1433 at 12:00:00 AM Western European Standard Time diff --git a/ext/intl/tests/dateformat_formatObject_calendar_variant5.phpt b/ext/intl/tests/dateformat_formatObject_calendar_variant5.phpt index 9eb9f39a917a7..096d04bbb514d 100644 --- a/ext/intl/tests/dateformat_formatObject_calendar_variant5.phpt +++ b/ext/intl/tests/dateformat_formatObject_calendar_variant5.phpt @@ -3,7 +3,6 @@ IntlDateFormatter::formatObject(): IntlCalendar tests --EXTENSIONS-- intl --SKIPIF-- -= 55.1'); ?> = 0) die('skip for ICU < 72.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - ---EXPECTF-- -01/01/2012 00:00:00 -Domingo, 1 de Janeiro de 2012 0:00:00 Hora %Sda Europa Ocidental -Jan 1, 2012 12:00:00 AM -1/1/12 12:00:00 AM Western European %STime -Sun 2012-01-1 00,00,00.000 Portugal Time (Lisbon) -Domingo, 1 de Janeiro de 2012 5:00:00 GMT+03:00 diff --git a/ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt b/ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt deleted file mode 100644 index ada1f0a22e449..0000000000000 --- a/ext/intl/tests/dateformat_formatObject_datetime_variant2.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -IntlDateFormatter::formatObject(): DateTime tests ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- - ---EXPECTF-- -01/01/2012, 00:00:00 -Domingo, 1 de Janeiro de 2012 às 00:00:00 Hora %Sda Europa Ocidental -Jan 1, 2012, 12:00:00 AM -1/1/12, 12:00:00 AM Western European Standard %STime -Sun 2012-01-1 00,00,00.000 Portugal Time -Domingo, 1 de Janeiro de 2012 às 05:00:00 GMT+03:00 diff --git a/ext/intl/tests/dateformat_formatObject_datetime_variant3.phpt b/ext/intl/tests/dateformat_formatObject_datetime_variant3.phpt deleted file mode 100644 index 9abbea5469e9d..0000000000000 --- a/ext/intl/tests/dateformat_formatObject_datetime_variant3.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -IntlDateFormatter::formatObject(): DateTime tests ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- - ---EXPECTF-- -01/01/2012, 00:00:00 -domingo, 1 de Janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental -Jan 1, 2012, 12:00:00 AM -1/1/12, 12:00:00 AM Western European Standard %STime -Sun 2012-01-1 00,00,00.000 Portugal Time -domingo, 1 de Janeiro de 2012 às 05:00:00 GMT+03:00 diff --git a/ext/intl/tests/dateformat_formatObject_datetime_variant4.phpt b/ext/intl/tests/dateformat_formatObject_datetime_variant4.phpt deleted file mode 100644 index 4ff1bff5bcfb8..0000000000000 --- a/ext/intl/tests/dateformat_formatObject_datetime_variant4.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -IntlDateFormatter::formatObject(): DateTime tests ---EXTENSIONS-- -intl ---SKIPIF-- -= 54.1'); ?> -= 0) die('skip for ICU < 55.1'); ?> ---FILE-- - ---EXPECTF-- -01/01/2012, 00:00:00 -domingo, 1 de janeiro de 2012 às 00:00:00 Hora Padrão %Sda Europa Ocidental -Jan 1, 2012, 12:00:00 AM -1/1/12, 12:00:00 AM Western European Standard %STime -Sun 2012-01-1 00,00,00.000 Portugal Time -domingo, 1 de janeiro de 2012 às 05:00:00 GMT+03:00 diff --git a/ext/intl/tests/dateformat_formatObject_datetime_variant5.phpt b/ext/intl/tests/dateformat_formatObject_datetime_variant5.phpt index b3c2ecc8e7932..9279fb0af9103 100644 --- a/ext/intl/tests/dateformat_formatObject_datetime_variant5.phpt +++ b/ext/intl/tests/dateformat_formatObject_datetime_variant5.phpt @@ -3,7 +3,6 @@ IntlDateFormatter::formatObject(): DateTime tests --EXTENSIONS-- intl --SKIPIF-- -= 55.1'); ?> = 0) die('skip for ICU < 72.1'); ?> --FILE-- += 72.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 7, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( - 'tm_sec' => 11, - 'tm_min' => 13, - 'tm_hour' => 0, - 'tm_mday' => 17, - 'tm_mon' => 11, - 'tm_year' => -5 - ); - - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - //Test format and parse with a timestamp : long - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - $parsed = ut_datefmt_parse( $fmt , $formatted); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nParsed timestamp is : $parsed"; - }else{ - $res_str .= "\nError while parsing as: '".intl_get_error_message()."'"; - } - } - } - } - - //Test format and parse with a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ - $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry,$timezone); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - //Parsing - $parsed_arr = ut_datefmt_localtime( $fmt, $formatted1 ); - - if( $parsed_arr){ - $res_str .= "\nParsed array is: "; - foreach( $parsed_arr as $key => $value){ - $res_str .= "$key : '$value' , "; - } - } -/* - else{ - //$res_str .= "No values found from LocaleTime parsing."; - $res_str .= "\tError : '".intl_get_error_message()."'"; - } -*/ - } - } - } - - return $res_str; - -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); -?> ---EXPECT-- ------------- - -Input timestamp is : 0 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Thursday, January 1, 1970 5:00:00 AM GMT+05:00 -Parsed timestamp is : 0 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : January 1, 1970 5:00:00 AM GMT+05:00 -Parsed timestamp is : 0 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Jan 1, 1970 5:00:00 AM -Parsed timestamp is : 0 ------------- - -Input timestamp is : -1200000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Thursday, December 18, 1969 7:40:00 AM GMT+05:00 -Parsed timestamp is : -1200000 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 18, 1969 7:40:00 AM GMT+05:00 -Parsed timestamp is : -1200000 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 18, 1969 7:40:00 AM -Parsed timestamp is : -1200000 ------------- - -Input timestamp is : 1200000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Thursday, January 15, 1970 2:20:00 AM GMT+05:00 -Parsed timestamp is : 1200000 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : January 15, 1970 2:20:00 AM GMT+05:00 -Parsed timestamp is : 1200000 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Jan 15, 1970 2:20:00 AM -Parsed timestamp is : 1200000 ------------- - -Input timestamp is : 2200000000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Monday, September 19, 2039 4:06:40 AM GMT+05:00 -Parsed timestamp is : 2200000000 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : September 19, 2039 4:06:40 AM GMT+05:00 -Parsed timestamp is : 2200000000 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Sep 19, 2039 4:06:40 AM -Parsed timestamp is : 2200000000 ------------- - -Input timestamp is : -2200000000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Sunday, April 15, 1900 5:53:20 AM GMT+05:00 -Parsed timestamp is : -2200000000 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : April 15, 1900 5:53:20 AM GMT+05:00 -Parsed timestamp is : -2200000000 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Apr 15, 1900 5:53:20 AM -Parsed timestamp is : -2200000000 ------------- - -Input timestamp is : 90099999 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Thursday, November 9, 1972 12:46:39 AM GMT+05:00 -Parsed timestamp is : 90099999 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : November 9, 1972 12:46:39 AM GMT+05:00 -Parsed timestamp is : 90099999 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Nov 9, 1972 12:46:39 AM -Parsed timestamp is : 90099999 ------------- - -Input timestamp is : 3600 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Thursday, January 1, 1970 6:00:00 AM GMT+05:00 -Parsed timestamp is : 3600 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : January 1, 1970 6:00:00 AM GMT+05:00 -Parsed timestamp is : 3600 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Jan 1, 1970 6:00:00 AM -Parsed timestamp is : 3600 ------------- - -Input timestamp is : -3600 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Thursday, January 1, 1970 4:00:00 AM GMT+05:00 -Parsed timestamp is : -3600 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : January 1, 1970 4:00:00 AM GMT+05:00 -Parsed timestamp is : -3600 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Jan 1, 1970 4:00:00 AM -Parsed timestamp is : -3600 ------------- - -Input localtime is : tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_mday : '3' , tm_mon : '3' , tm_year : '105' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Sunday, April 3, 2005 7:03:24 PM GMT+05:00 -Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' , -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : April 3, 2005 7:03:24 PM GMT+05:00 -Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' , -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : Apr 3, 2005 7:03:24 PM -Parsed array is: tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_year : '105' , tm_mday : '3' , tm_wday : '0' , tm_yday : '93' , tm_mon : '3' , tm_isdst : '0' , ------------- - -Input localtime is : tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_mday : '13' , tm_mon : '7' , tm_year : '205' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Thursday, August 13, 2105 7:05:21 AM GMT+05:00 -Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' , -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : August 13, 2105 7:05:21 AM GMT+05:00 -Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' , -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : Aug 13, 2105 7:05:21 AM -Parsed array is: tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_year : '205' , tm_mday : '13' , tm_wday : '4' , tm_yday : '225' , tm_mon : '7' , tm_isdst : '0' , ------------- - -Input localtime is : tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_mday : '17' , tm_mon : '11' , tm_year : '-5' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Tuesday, December 17, 1895 12:13:11 AM GMT+05:00 -Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' , -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : December 17, 1895 12:13:11 AM GMT+05:00 -Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' , -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : Dec 17, 1895 12:13:11 AM -Parsed array is: tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_year : '-5' , tm_mday : '17' , tm_wday : '2' , tm_yday : '351' , tm_mon : '11' , tm_isdst : '0' , diff --git a/ext/intl/tests/dateformat_format_parse_version2.phpt b/ext/intl/tests/dateformat_format_parse_version2.phpt index 1293d29c383bf..1955a092cf5cf 100644 --- a/ext/intl/tests/dateformat_format_parse_version2.phpt +++ b/ext/intl/tests/dateformat_format_parse_version2.phpt @@ -3,7 +3,6 @@ datefmt_format_code() and datefmt_parse_code() --EXTENSIONS-- intl --SKIPIF-- -= 51.2'); ?> = 0) die('skip for ICU < 72.1'); ?> --FILE-- = 0) die('skip for ICU >= 51.2 && ICU < 52.1'); ?> ---FILE-- - 24 , - 'tm_min' => 3, - 'tm_hour' => 19, - 'tm_mday' => 3, - 'tm_mon' => 3, - 'tm_year' => 105, - ); - $localtime_arr2 = array ( - 'tm_sec' => 21, - 'tm_min' => 5, - 'tm_hour' => 7, - 'tm_mday' => 13, - 'tm_mon' => 4, - 'tm_year' => 205, - ); - $localtime_arr3 = array ( - 'tm_sec' => 11, - 'tm_min' => 13, - 'tm_hour' => 0, - 'tm_mday' => 17, - 'tm_mon' => 11, - 'tm_year' => -5 - ); - - $localtime_arr = array ( - $localtime_arr1, - $localtime_arr2, - $localtime_arr3 - ); - - $d1 = new DateTime("2010-01-01 01:02:03", new DateTimeZone("UTC")); - $d2 = new DateTime("2000-12-31 03:04:05", new DateTimeZone("UTC")); - $d2->setTimezone(new DateTimeZone("PDT")); - $dates = array( - $d1, - $d2, - new StdClass(), - ); - - //Test format with input as a timestamp : integer - foreach( $time_arr as $timestamp_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput timestamp is : $timestamp_entry"; - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN); - $formatted = ut_datefmt_format( $fmt , $timestamp_entry); - $res_str .= "\nFormatted timestamp is : $formatted"; - } - } - } - - //Test format with input as a localtime :array - foreach( $localtime_arr as $localtime_entry){ - $res_str .= "\n------------\n"; - $res_str .= "\nInput localtime is : "; - foreach( $localtime_entry as $key => $value){ - $res_str .= "$key : '$value' , "; - } - - $res_str .= "\n------------\n"; - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) - { - $res_str .= "\nIntlDateFormatter locale= $locale_entry ,datetype = $datetype_entry ,timetype =$datetype_entry "; - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $localtime_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted localtime_array is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - foreach($dates as $date_entry) { - foreach( $locale_arr as $locale_entry ){ - foreach( $datetype_arr as $datetype_entry ) { - $res_str .= "\n------------"; - $res_str .= "\nDate is: ".var_export($date_entry, true); - $res_str .= "\n------------"; - - $fmt = ut_datefmt_create( $locale_entry , $datetype_entry ,$datetype_entry, $timezone, IntlDateFormatter::GREGORIAN ); - $formatted1 = ut_datefmt_format( $fmt , $date_entry); - if( intl_get_error_code() == U_ZERO_ERROR){ - $res_str .= "\nFormatted DateTime is : $formatted1"; - }else{ - $res_str .= "\nError while formatting as: '".intl_get_error_message()."'"; - } - } - } - } - - return $res_str; - -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); -?> ---EXPECT-- ------------- - -Input timestamp is : 0 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 31, 1969 at 2:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 31, 1969 at 2:00:00 PM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 31, 1969, 2:00:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/31/69, 2:00 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691231 02:00 PM ------------- - -Input timestamp is : -1200000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 17, 1969 at 4:40:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 17, 1969 at 4:40:00 PM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 17, 1969, 4:40:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/17/69, 4:40 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691217 04:40 PM ------------- - -Input timestamp is : 1200000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, January 14, 1970 at 11:20:00 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : January 14, 1970 at 11:20:00 AM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Jan 14, 1970, 11:20:00 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 1/14/70, 11:20 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19700114 11:20 AM ------------- - -Input timestamp is : 2200000000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Sunday, September 18, 2039 at 1:06:40 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : September 18, 2039 at 1:06:40 PM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Sep 18, 2039, 1:06:40 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 9/18/39, 1:06 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 20390918 01:06 PM ------------- - -Input timestamp is : -2200000000 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Saturday, April 14, 1900 at 2:53:20 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : April 14, 1900 at 2:53:20 PM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Apr 14, 1900, 2:53:20 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 4/14/00, 2:53 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19000414 02:53 PM ------------- - -Input timestamp is : 90099999 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, November 8, 1972 at 9:46:39 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : November 8, 1972 at 9:46:39 AM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Nov 8, 1972, 9:46:39 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 11/8/72, 9:46 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19721108 09:46 AM ------------- - -Input timestamp is : 3600 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 31, 1969 at 3:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 31, 1969 at 3:00:00 PM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 31, 1969, 3:00:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/31/69, 3:00 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691231 03:00 PM ------------- - -Input timestamp is : -3600 ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted timestamp is : Wednesday, December 31, 1969 at 1:00:00 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted timestamp is : December 31, 1969 at 1:00:00 PM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted timestamp is : Dec 31, 1969, 1:00:00 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted timestamp is : 12/31/69, 1:00 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted timestamp is : 19691231 01:00 PM ------------- - -Input localtime is : tm_sec : '24' , tm_min : '3' , tm_hour : '19' , tm_mday : '3' , tm_mon : '3' , tm_year : '105' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Sunday, April 3, 2005 at 7:03:24 PM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : April 3, 2005 at 7:03:24 PM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : Apr 3, 2005, 7:03:24 PM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted localtime_array is : 4/3/05, 7:03 PM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted localtime_array is : 20050403 07:03 PM ------------- - -Input localtime is : tm_sec : '21' , tm_min : '5' , tm_hour : '7' , tm_mday : '13' , tm_mon : '4' , tm_year : '205' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Wednesday, May 13, 2105 at 7:05:21 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : May 13, 2105 at 7:05:21 AM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : May 13, 2105, 7:05:21 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted localtime_array is : 5/13/05, 7:05 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted localtime_array is : 21050513 07:05 AM ------------- - -Input localtime is : tm_sec : '11' , tm_min : '13' , tm_hour : '0' , tm_mday : '17' , tm_mon : '11' , tm_year : '-5' , ------------- - -IntlDateFormatter locale= en_US ,datetype = 0 ,timetype =0 -Formatted localtime_array is : Tuesday, December 17, 1895 at 12:13:11 AM GMT-10:00 -IntlDateFormatter locale= en_US ,datetype = 1 ,timetype =1 -Formatted localtime_array is : December 17, 1895 at 12:13:11 AM GMT-10 -IntlDateFormatter locale= en_US ,datetype = 2 ,timetype =2 -Formatted localtime_array is : Dec 17, 1895, 12:13:11 AM -IntlDateFormatter locale= en_US ,datetype = 3 ,timetype =3 -Formatted localtime_array is : 12/17/95, 12:13 AM -IntlDateFormatter locale= en_US ,datetype = -1 ,timetype =-1 -Formatted localtime_array is : 18951217 12:13 AM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : Thursday, December 31, 2009 at 3:02:03 PM GMT-10:00 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : December 31, 2009 at 3:02:03 PM GMT-10 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : Dec 31, 2009, 3:02:03 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : 12/31/09, 3:02 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2010-01-01 01:02:03.000000', - 'timezone_type' => 3, - 'timezone' => 'UTC', -)) ------------- -Formatted DateTime is : 20091231 03:02 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 3, - 'timezone' => 'America/Los_Angeles', -)) ------------- -Formatted DateTime is : Saturday, December 30, 2000 at 5:04:05 PM GMT-10:00 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 3, - 'timezone' => 'America/Los_Angeles', -)) ------------- -Formatted DateTime is : December 30, 2000 at 5:04:05 PM GMT-10 ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 3, - 'timezone' => 'America/Los_Angeles', -)) ------------- -Formatted DateTime is : Dec 30, 2000, 5:04:05 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 3, - 'timezone' => 'America/Los_Angeles', -)) ------------- -Formatted DateTime is : 12/30/00, 5:04 PM ------------- -Date is: \DateTime::__set_state(array( - 'date' => '2000-12-30 19:04:05.000000', - 'timezone_type' => 3, - 'timezone' => 'America/Los_Angeles', -)) ------------- -Formatted DateTime is : 20001230 05:04 PM ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' ------------- -Date is: (object) array( -) ------------- -Error while formatting as: 'datefmt_format: invalid object type for date/time (only IntlCalendar and DateTimeInterface permitted): U_ILLEGAL_ARGUMENT_ERROR' diff --git a/ext/intl/tests/dateformat_format_variant3.phpt b/ext/intl/tests/dateformat_format_variant3.phpt index 86582d39229ba..e2d0a02637489 100644 --- a/ext/intl/tests/dateformat_format_variant3.phpt +++ b/ext/intl/tests/dateformat_format_variant3.phpt @@ -4,8 +4,6 @@ datefmt_format_code() intl --XFAIL-- This test assumes wrong data wrt PDT. It is also too big and needs splitting up. ---SKIPIF-- -= 52.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -format($ts), "\n"; -var_dump($df->getCalendar(), -$df->getCalendarObject()->getType(), -$df->getCalendarObject()->getTimeZone()->getId()); -echo "\n"; -} - -$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk'); -d($df); - - -//changing the calendar with a cal type should not change tz -$df->setCalendar(IntlDateFormatter::TRADITIONAL); -d($df); - -//but changing with an actual calendar should -$cal = IntlCalendar::createInstance("UTC"); -$df->setCalendar($cal); -d($df); - -?> ---EXPECT-- -dimanche 1 janvier 2012 ap. J.-C. 03:00:00 UTC+03:00 -int(1) -string(9) "gregorian" -string(12) "Europe/Minsk" - -dimanche 8 Safar 1433 AH 03:00:00 UTC+03:00 -int(0) -string(7) "islamic" -string(12) "Europe/Minsk" - -dimanche 1 janvier 2012 ap. J.-C. 00:00:00 UTC -bool(false) -string(9) "gregorian" -string(3) "UTC" - diff --git a/ext/intl/tests/dateformat_get_set_calendar_variant2.phpt b/ext/intl/tests/dateformat_get_set_calendar_variant2.phpt deleted file mode 100644 index 8e58b50f71015..0000000000000 --- a/ext/intl/tests/dateformat_get_set_calendar_variant2.phpt +++ /dev/null @@ -1,53 +0,0 @@ ---TEST-- -IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- -format($ts), "\n"; -var_dump($df->getCalendar(), -$df->getCalendarObject()->getType(), -$df->getCalendarObject()->getTimeZone()->getId()); -echo "\n"; -} - -$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk'); -d($df); - - -//changing the calendar with a cal type should not change tz -$df->setCalendar(IntlDateFormatter::TRADITIONAL); -d($df); - -//but changing with an actual calendar should -$cal = IntlCalendar::createInstance("UTC"); -$df->setCalendar($cal); -d($df); - -?> ---EXPECT-- -dimanche 1 janvier 2012 ap. J.-C. 03:00:00 UTC+03:00 -int(1) -string(9) "gregorian" -string(12) "Europe/Minsk" - -dimanche 8 safar 1433 AH 03:00:00 UTC+03:00 -int(0) -string(7) "islamic" -string(12) "Europe/Minsk" - -dimanche 1 janvier 2012 ap. J.-C. 00:00:00 UTC -bool(false) -string(9) "gregorian" -string(3) "UTC" - diff --git a/ext/intl/tests/dateformat_get_set_calendar_variant3.phpt b/ext/intl/tests/dateformat_get_set_calendar_variant3.phpt deleted file mode 100644 index f0446e28c5dca..0000000000000 --- a/ext/intl/tests/dateformat_get_set_calendar_variant3.phpt +++ /dev/null @@ -1,54 +0,0 @@ ---TEST-- -IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- -format($ts), "\n"; -var_dump($df->getCalendar(), -$df->getCalendarObject()->getType(), -$df->getCalendarObject()->getTimeZone()->getId()); -echo "\n"; -} - -$df = new IntlDateFormatter('fr@calendar=islamic', 0, 0, 'Europe/Minsk'); -d($df); - - -//changing the calendar with a cal type should not change tz -$df->setCalendar(IntlDateFormatter::TRADITIONAL); -d($df); - -//but changing with an actual calendar should -$cal = IntlCalendar::createInstance("UTC"); -$df->setCalendar($cal); -d($df); - -?> ---EXPECT-- -dimanche 1 janvier 2012 ap. J.-C. à 03:00:00 UTC+03:00 -int(1) -string(9) "gregorian" -string(12) "Europe/Minsk" - -dimanche 8 safar 1433 AH à 03:00:00 UTC+03:00 -int(0) -string(7) "islamic" -string(12) "Europe/Minsk" - -dimanche 1 janvier 2012 ap. J.-C. à 00:00:00 UTC -bool(false) -string(9) "gregorian" -string(3) "UTC" - diff --git a/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt b/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt index 6e7c7dc454952..6842cdf1c4084 100644 --- a/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt +++ b/ext/intl/tests/dateformat_get_set_calendar_variant4.phpt @@ -3,8 +3,7 @@ IntlDateFormatter: setCalendar()/getCalendar()/getCalendarObject() --EXTENSIONS-- intl --SKIPIF-- -= 54.1'); ?> -= 0) die('skip for ICU <= 57.1'); ?> += 0) die('skip for ICU < 58.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -format($ts), "\n"; -var_dump( -$df->getTimeZoneID(), -$df->getTimeZone()->getID()); -echo "\n"; -} - -$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk'); -d($df); - -$df->setTimeZone(NULL); -d($df); - -$df->setTimeZone('Europe/Madrid'); -d($df); - -$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris')); -d($df); - -$df->setTimeZone(new DateTimeZone('Europe/Amsterdam')); -d($df); - -?> ---EXPECTF-- -Domingo, 1 de Janeiro de 2012 3:00:00 GMT+03:00 -string(12) "Europe/Minsk" -string(12) "Europe/Minsk" - -Sábado, 31 de Dezembro de 2011 23:00:00 Hor%s %Sdos Açores -string(15) "Atlantic/Azores" -string(15) "Atlantic/Azores" - -Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central -string(13) "Europe/Madrid" -string(13) "Europe/Madrid" - -Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central -string(12) "Europe/Paris" -string(12) "Europe/Paris" - -Domingo, 1 de Janeiro de 2012 1:00:00 Hor%s %Sda Europa Central -string(16) "Europe/Amsterdam" -string(16) "Europe/Amsterdam" - diff --git a/ext/intl/tests/dateformat_get_set_timezone_variant2.phpt b/ext/intl/tests/dateformat_get_set_timezone_variant2.phpt deleted file mode 100644 index eea0c7d8f9b27..0000000000000 --- a/ext/intl/tests/dateformat_get_set_timezone_variant2.phpt +++ /dev/null @@ -1,60 +0,0 @@ ---TEST-- -IntlDateFormatter: get/setTimeZone() ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- -format($ts), "\n"; -var_dump( -$df->getTimeZoneID(), -$df->getTimeZone()->getID()); -echo "\n"; -} - -$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk'); -d($df); - -$df->setTimeZone(NULL); -d($df); - -$df->setTimeZone('Europe/Madrid'); -d($df); - -$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris')); -d($df); - -$df->setTimeZone(new DateTimeZone('Europe/Amsterdam')); -d($df); - -?> ---EXPECTF-- -Domingo, 1 de Janeiro de 2012 às 03:00:00 GMT+03:00 -string(12) "Europe/Minsk" -string(12) "Europe/Minsk" - -Sábado, 31 de Dezembro de 2011 às 23:00:00 Hor%s %Sdos Açores -string(15) "Atlantic/Azores" -string(15) "Atlantic/Azores" - -Domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s %Sda Europa Central -string(13) "Europe/Madrid" -string(13) "Europe/Madrid" - -Domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s %Sda Europa Central -string(12) "Europe/Paris" -string(12) "Europe/Paris" - -Domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s %Sda Europa Central -string(16) "Europe/Amsterdam" -string(16) "Europe/Amsterdam" - diff --git a/ext/intl/tests/dateformat_get_set_timezone_variant3.phpt b/ext/intl/tests/dateformat_get_set_timezone_variant3.phpt deleted file mode 100644 index 9f4a295aa8ff0..0000000000000 --- a/ext/intl/tests/dateformat_get_set_timezone_variant3.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -IntlDateFormatter: get/setTimeZone() ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- -format($ts), "\n"; -var_dump( -$df->getTimeZoneID(), -$df->getTimeZone()->getID()); -echo "\n"; -} - -$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk'); -d($df); - -$df->setTimeZone(NULL); -d($df); - -$df->setTimeZone('Europe/Madrid'); -d($df); - -$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris')); -d($df); - -$df->setTimeZone(new DateTimeZone('Europe/Amsterdam')); -d($df); - -?> ---EXPECTF-- -domingo, 1 de Janeiro de 2012 às 03:00:00 GMT+03:00 -string(12) "Europe/Minsk" -string(12) "Europe/Minsk" - -sábado, 31 de Dezembro de 2011 às 23:00:00 Hor%s Padrão %Sdos Açores -string(15) "Atlantic/Azores" -string(15) "Atlantic/Azores" - -domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central -string(13) "Europe/Madrid" -string(13) "Europe/Madrid" - -domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central -string(12) "Europe/Paris" -string(12) "Europe/Paris" - -domingo, 1 de Janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central -string(16) "Europe/Amsterdam" -string(16) "Europe/Amsterdam" - diff --git a/ext/intl/tests/dateformat_get_set_timezone_variant4.phpt b/ext/intl/tests/dateformat_get_set_timezone_variant4.phpt deleted file mode 100644 index c8e5c5a19659e..0000000000000 --- a/ext/intl/tests/dateformat_get_set_timezone_variant4.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -IntlDateFormatter: get/setTimeZone() ---EXTENSIONS-- -intl ---SKIPIF-- -= 54.1'); ?> -= 0) die('skip for ICU < 55.1'); ?> ---FILE-- -format($ts), "\n"; -var_dump( -$df->getTimeZoneID(), -$df->getTimeZone()->getID()); -echo "\n"; -} - -$df = new IntlDateFormatter('pt_PT', 0, 0, 'Europe/Minsk'); -d($df); - -$df->setTimeZone(NULL); -d($df); - -$df->setTimeZone('Europe/Madrid'); -d($df); - -$df->setTimeZone(IntlTimeZone::createTimeZone('Europe/Paris')); -d($df); - -$df->setTimeZone(new DateTimeZone('Europe/Amsterdam')); -d($df); - -?> ---EXPECTF-- -domingo, 1 de janeiro de 2012 às 03:00:00 Hor%s do Extremo Leste da Europa -string(12) "Europe/Minsk" -string(12) "Europe/Minsk" - -sábado, 31 de dezembro de 2011 às 23:00:00 Hor%s Padrão %Sdos Açores -string(15) "Atlantic/Azores" -string(15) "Atlantic/Azores" - -domingo, 1 de janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central -string(13) "Europe/Madrid" -string(13) "Europe/Madrid" - -domingo, 1 de janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central -string(12) "Europe/Paris" -string(12) "Europe/Paris" - -domingo, 1 de janeiro de 2012 às 01:00:00 Hor%s Padrão %Sda Europa Central -string(16) "Europe/Amsterdam" -string(16) "Europe/Amsterdam" - diff --git a/ext/intl/tests/dateformat_get_set_timezone_variant5.phpt b/ext/intl/tests/dateformat_get_set_timezone_variant5.phpt index 3cce942e74161..8d2142b17da3d 100644 --- a/ext/intl/tests/dateformat_get_set_timezone_variant5.phpt +++ b/ext/intl/tests/dateformat_get_set_timezone_variant5.phpt @@ -2,8 +2,6 @@ IntlDateFormatter: get/setTimeZone() --EXTENSIONS-- intl ---SKIPIF-- -= 55.1'); ?> --FILE-- = 4.8 ---INI-- -date.timezone=Atlantic/Azores ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - ---EXPECTF-- -Warning: IntlDateFormatter::setTimeZone(): datefmt_set_timezone: No such time zone: 'CN' in %s on line %d - -Warning: datefmt_set_timezone(): datefmt_set_timezone: No such time zone: 'CN' in %s on line %d - -After creation of the dateformatter : timezone_id= US/Pacific ------------ -Trying to set timezone_id= America/New_York -After call to set_timezone_id : timezone_id= America/New_York -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 7:00:00 PM Eastern Standard Time -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 8:00:00 PM Eastern Standard Time ------------ -Trying to set timezone_id= America/Los_Angeles -After call to set_timezone_id : timezone_id= America/Los_Angeles -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 5:00:00 PM Pacific Standard Time ------------ -Trying to set timezone_id= America/Chicago -After call to set_timezone_id : timezone_id= America/Chicago -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time ------------ -Trying to set timezone_id= CN -After call to set_timezone_id : timezone_id= America/Chicago -Formatting timestamp=0 resulted in Wednesday, December 31, 1969 6:00:00 PM Central Standard Time -Formatting timestamp=3600 resulted in Wednesday, December 31, 1969 7:00:00 PM Central Standard Time diff --git a/ext/intl/tests/dateformat_set_timezone_id3.phpt b/ext/intl/tests/dateformat_set_timezone_id3.phpt index ec14db3e60623..a964bb620bc1f 100644 --- a/ext/intl/tests/dateformat_set_timezone_id3.phpt +++ b/ext/intl/tests/dateformat_set_timezone_id3.phpt @@ -5,7 +5,6 @@ date.timezone=Atlantic/Azores --EXTENSIONS-- intl --SKIPIF-- -= 51.2'); ?> = 0) die('skip for ICU < 72.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam'); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York')); -echo $df->format($ts), "\n"; - -//time zone has priority -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -//calendar has priority -$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0); -echo $df->format($ts), "\n"; -?> ---EXPECTF-- -sábado%S 31 de diciembre de 2011 23:00:00 Hora%S de las Azores -domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central -domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental -sábado%S 31 de diciembre de 2011 19:00:00 Hora estándar oriental -domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central -domingo%S 1 de enero de 2012 00:00:00 Hora%S de Europa Occidental -domingo%S 1 de enero de 2012 01:00:00 Hora estándar de Europa Central diff --git a/ext/intl/tests/dateformat_timezone_arg_variations2.phpt b/ext/intl/tests/dateformat_timezone_arg_variations2.phpt deleted file mode 100644 index 43785f8878fe9..0000000000000 --- a/ext/intl/tests/dateformat_timezone_arg_variations2.phpt +++ /dev/null @@ -1,45 +0,0 @@ ---TEST-- -IntlDateFormatter: several forms of the timezone arg ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- -format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam'); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York')); -echo $df->format($ts), "\n"; - -//time zone has priority -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -//calendar has priority -$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0); -echo $df->format($ts), "\n"; -?> ---EXPECTF-- -sábado%S, 31 de diciembre de 2011 23:00:00 Hora estándar de las Azores -domingo%S, 1 de enero de 2012 01:00:00 Hora estándar de Europa central -domingo%S, 1 de enero de 2012 00:00:00 Hora%S de Europa occidental -sábado%S, 31 de diciembre de 2011 19:00:00 Hora estándar oriental -domingo%S, 1 de enero de 2012 01:00:00 Hora estándar de Europa central -domingo%S, 1 de enero de 2012 00:00:00 Hora%S de Europa occidental -domingo%S, 1 de enero de 2012 01:00:00 Hora estándar de Europa central diff --git a/ext/intl/tests/dateformat_timezone_arg_variations3.phpt b/ext/intl/tests/dateformat_timezone_arg_variations3.phpt deleted file mode 100644 index 766f67b990c7e..0000000000000 --- a/ext/intl/tests/dateformat_timezone_arg_variations3.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -IntlDateFormatter: several forms of the timezone arg ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- -format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam'); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, new DateTimeZone('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, IntlTimeZone::createTimeZone('America/New_York')); -echo $df->format($ts), "\n"; - -//time zone has priority -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', new IntlGregorianCalendar('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -//calendar has priority -$df = new IntlDateFormatter('es_ES', 0, 0, NULL, new IntlGregorianCalendar('Europe/Lisbon')); -echo $df->format($ts), "\n"; - -$df = new IntlDateFormatter('es_ES', 0, 0, 'Europe/Amsterdam', 0); -echo $df->format($ts), "\n"; -?> ---EXPECTF-- -sábado%S 31 de diciembre de 2011, 23:00:00 (Hora estándar de las Azores) -domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central) -domingo%S 1 de enero de 2012, 0:00:00 (Hora%S estándar de Europa occidental) -sábado%S 31 de diciembre de 2011, 19:00:00 (Hora estándar oriental) -domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central) -domingo%S 1 de enero de 2012, 0:00:00 (Hora%S estándar de Europa occidental) -domingo%S 1 de enero de 2012, 1:00:00 (Hora estándar de Europa central) diff --git a/ext/intl/tests/dateformat_timezone_arg_variations4.phpt b/ext/intl/tests/dateformat_timezone_arg_variations4.phpt index 74320cfee828c..0c2ea02a56d48 100644 --- a/ext/intl/tests/dateformat_timezone_arg_variations4.phpt +++ b/ext/intl/tests/dateformat_timezone_arg_variations4.phpt @@ -2,8 +2,6 @@ IntlDateFormatter: several forms of the timezone arg --EXTENSIONS-- intl ---SKIPIF-- -= 54.1'); ?> --FILE-- = 4.8 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU <= 52.1'); ?> ---FILE-- - '##.#####################', - NumberFormatter::DECIMAL => '', - NumberFormatter::CURRENCY => '', - NumberFormatter::PERCENT => '', - NumberFormatter::SCIENTIFIC => '', - NumberFormatter::SPELLOUT => '@@@@@@@', - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - NumberFormatter::PATTERN_RULEBASED => '#####.###', - 1234999, // bad one - ); - - $integer = array( - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - ); - $locales = array( - 'en_US', - 'ru_UA', - 'de', - 'fr', - 'en_UK' - ); - - $str_res = ''; - $number = 1234567.891234567890000; - - foreach( $locales as $locale ) - { - $str_res .= "\nLocale is: $locale\n"; - foreach( $styles as $style => $pattern ) - { - $fmt = ut_nfmt_create( $locale, $style, $pattern ); - - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } - $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; - } - } - return $str_res; -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); - -?> ---EXPECTREGEX-- -Locale is: en_US -'1234567.89123457' -'1,234,567.891' -'\$1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -Bad formatter! - -Locale is: ru_UA -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ?(грн\.|₴)' -'123 456 789 ?%' -'1,23456789123457E6' -'один миллион двести тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь' -'1 234 567.?' -'1 234 567' -'#####.###' -Bad formatter! - -Locale is: de -'1234567,89123457' -'1.234.567,891' -'(¤ )?1.234.567,89( ¤)?' -'123\.456\.789 %' -'1,23456789123457E6' -'eine Million zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig Komma acht neun eins zwei drei vier fünf sieben' -'1.234.567.?' -'1.234.567' -'#####.###' -Bad formatter! - -Locale is: fr -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ¤' -'123 456 789 ?%' -'1,23456789123457E6' -'un million deux-cent-trente-quatre-mille-cinq-cent-soixante-sept virgule huit neuf un deux trois quatre cinq sept' -'1 234 567e' -'1 234 567' -'#####.###' -Bad formatter! - -Locale is: en_UK -'1234567.89123457' -'1,234,567.891' -'¤1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -Bad formatter! diff --git a/ext/intl/tests/formatter_format3.phpt b/ext/intl/tests/formatter_format3.phpt deleted file mode 100644 index 773fa522e5a1f..0000000000000 --- a/ext/intl/tests/formatter_format3.phpt +++ /dev/null @@ -1,132 +0,0 @@ ---TEST-- -numfmt_format() icu >= 52.1 && icu < 53.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'; ?> -= 0) die('skip for ICU < 53.1'); ?> ---FILE-- - '##.#####################', - NumberFormatter::DECIMAL => '', - NumberFormatter::CURRENCY => '', - NumberFormatter::PERCENT => '', - NumberFormatter::SCIENTIFIC => '', - NumberFormatter::SPELLOUT => '@@@@@@@', - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - NumberFormatter::PATTERN_RULEBASED => '#####.###', - 1234999, // bad one - ); - - $integer = array( - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - ); - $locales = array( - 'en_US', - 'ru_UA', - 'de', - 'fr', - 'en_UK' - ); - - $str_res = ''; - $number = 1234567.891234567890000; - - foreach( $locales as $locale ) - { - $str_res .= "\nLocale is: $locale\n"; - foreach( $styles as $style => $pattern ) - { - $fmt = ut_nfmt_create( $locale, $style, $pattern ); - - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } - $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; - } - } - return $str_res; -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); - -?> ---EXPECTREGEX-- -Locale is: en_US -'1234567.89123457' -'1,234,567.891' -'\$1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -Bad formatter! - -Locale is: ru_UA -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ?(грн\.|₴)' -'123 456 789 ?%' -'1,23456789123457E6' -'один миллион двести тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь' -'1 234 567.?' -'1 234 567' -'#####.###' -Bad formatter! - -Locale is: de -'1234567,89123457' -'1.234.567,891' -'(¤ )?1.234.567,89( ¤)?' -'123\.456\.789 %' -'1,23456789123457E6' -'eine Million zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig Komma acht neun eins zwei drei vier fünf sieben' -'1.234.567.?' -'1.234.567' -'#####.###' -Bad formatter! - -Locale is: fr -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ¤' -'123 456 789 ?%' -'1,23456789123457E6' -'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept' -'1 234 567e' -'1 234 567' -'#####.###' -Bad formatter! - -Locale is: en_UK -'1234567.89123457' -'1,234,567.891' -'¤1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -Bad formatter! diff --git a/ext/intl/tests/formatter_format4.phpt b/ext/intl/tests/formatter_format4.phpt deleted file mode 100644 index 5517eebdee292..0000000000000 --- a/ext/intl/tests/formatter_format4.phpt +++ /dev/null @@ -1,132 +0,0 @@ ---TEST-- -numfmt_format() icu >= 53.1 && icu < 54.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 53.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- - '##.#####################', - NumberFormatter::DECIMAL => '', - NumberFormatter::CURRENCY => '', - NumberFormatter::PERCENT => '', - NumberFormatter::SCIENTIFIC => '', - NumberFormatter::SPELLOUT => '@@@@@@@', - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - NumberFormatter::PATTERN_RULEBASED => '#####.###', - 1234999, // bad one - ); - - $integer = array( - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - ); - $locales = array( - 'en_US', - 'ru_UA', - 'de', - 'fr', - 'en_UK' - ); - - $str_res = ''; - $number = 1234567.891234567890000; - - foreach( $locales as $locale ) - { - $str_res .= "\nLocale is: $locale\n"; - foreach( $styles as $style => $pattern ) - { - $fmt = ut_nfmt_create( $locale, $style, $pattern ); - - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } - $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; - } - } - return $str_res; -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); - -?> ---EXPECTREGEX-- -Locale is: en_US -'1234567.89123457' -'1,234,567.891' -'\$1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -'USD1,234,567.89' - -Locale is: ru_UA -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ?(грн\.|₴)' -'123 456 789 ?%' -'1,23456789123457E6' -'один миллион двести тридцать четыре тысяч пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь' -'1 234 567.?' -'1 234 567' -'#####.###' -'1 234 567,89 UAH' - -Locale is: de -'1234567,89123457' -'1.234.567,891' -'(¤ )?1.234.567,89( ¤)?' -'123\.456\.789 %' -'1,23456789123457E6' -'eine Million zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig Komma acht neun eins zwei drei vier fünf sieben' -'1.234.567.?' -'1.234.567' -'#####.###' -'1.234.567,89 ¤¤' - -Locale is: fr -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ¤' -'123 456 789 ?%' -'1,23456789123457E6' -'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept' -'1 234 567e' -'1 234 567' -'#####.###' -'1 234 567,89 ¤¤' - -Locale is: en_UK -'1234567.89123457' -'1,234,567.891' -'¤1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -'¤¤1,234,567.89' diff --git a/ext/intl/tests/formatter_format5.phpt b/ext/intl/tests/formatter_format5.phpt deleted file mode 100644 index 62ddd4ec24fb5..0000000000000 --- a/ext/intl/tests/formatter_format5.phpt +++ /dev/null @@ -1,132 +0,0 @@ ---TEST-- -numfmt_format() icu >= 54.1 && icu < 56.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 56.1'); ?> -= 54.1'); ?> ---FILE-- - '##.#####################', - NumberFormatter::DECIMAL => '', - NumberFormatter::CURRENCY => '', - NumberFormatter::PERCENT => '', - NumberFormatter::SCIENTIFIC => '', - NumberFormatter::SPELLOUT => '@@@@@@@', - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - NumberFormatter::PATTERN_RULEBASED => '#####.###', - 1234999, // bad one - ); - - $integer = array( - NumberFormatter::ORDINAL => '', - NumberFormatter::DURATION => '', - ); - $locales = array( - 'en_US', - 'ru_UA', - 'de', - 'fr', - 'en_UK' - ); - - $str_res = ''; - $number = 1234567.891234567890000; - - foreach( $locales as $locale ) - { - $str_res .= "\nLocale is: $locale\n"; - foreach( $styles as $style => $pattern ) - { - $fmt = ut_nfmt_create( $locale, $style, $pattern ); - - if(!$fmt) { - $str_res .= "Bad formatter!\n"; - continue; - } - $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; - } - } - return $str_res; -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); - -?> ---EXPECTREGEX-- -Locale is: en_US -'1234567.89123457' -'1,234,567.891' -'\$1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -'USD1,234,567.89' - -Locale is: ru_UA -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ?(грн\.|₴)' -'123 456 789 ?%' -'1,23456789123457E6' -'один миллион двести тридцать четыре тысячи пятьсот шестьдесят семь запятая восемь девять один два три четыре пять семь' -'1 234 567.?' -'1 234 567' -'#####.###' -'1 234 567,89 UAH' - -Locale is: de -'1234567,89123457' -'1.234.567,891' -'(¤ )?1.234.567,89( ¤)?' -'123\.456\.789 %' -'1,23456789123457E6' -'eine Million zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig Komma acht neun eins zwei drei vier fünf sieben' -'1.234.567.?' -'1.234.567' -'#####.###' -'1.234.567,89 ¤¤' - -Locale is: fr -'1234567,89123457' -'1 234 567,891' -'1 234 567,89 ¤' -'123 456 789 ?%' -'1,23456789123457E6' -'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq sept' -'1 234 567e' -'1 234 567' -'#####.###' -'1 234 567,89 ¤¤' - -Locale is: en_UK -'1234567.89123457' -'1,234,567.891' -'¤1,234,567.89' -'123,456,789%' -'1.23456789123457E6' -'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five seven' -'1,234,567(th|ᵗʰ)' -'342:56:07' -'#####.###' -'¤¤1,234,567.89' diff --git a/ext/intl/tests/formatter_format6.phpt b/ext/intl/tests/formatter_format6.phpt index 9d9c3586d712a..b4c047a98e6cc 100644 --- a/ext/intl/tests/formatter_format6.phpt +++ b/ext/intl/tests/formatter_format6.phpt @@ -4,7 +4,6 @@ numfmt_format() icu >= 56.1 && icu < 61.1 intl --SKIPIF-- = 0) die('skip for ICU < 61.1'); ?> -= 56.1'); ?> --FILE-- = 4.8 && icu < 50.1.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - 'actual', - Locale::VALID_LOCALE => 'valid', - ); - - $res_str = ''; - - foreach( $locales as $locale ) - { - $fmt = ut_nfmt_create( $locale, NumberFormatter::DECIMAL ); - $res_str .= "$locale: "; - foreach( $loc_types as $loc_type => $loc_type_name ) - $res_str .= sprintf( " %s=%s", - $loc_type_name, - dump( ut_nfmt_get_locale( $fmt, $loc_type ) ) ); - $res_str .= "\n"; - } - - return $res_str; -} - -include_once( 'ut_common.inc' ); - -// Run the test -ut_run(); -?> ---EXPECT-- -en_UK: actual='en' valid='en' -en_US@California: actual='en' valid='en' -fr_CA: actual='fr_CA' valid='fr_CA' diff --git a/ext/intl/tests/formatter_get_locale_variant2.phpt b/ext/intl/tests/formatter_get_locale_variant2.phpt index a841b1afff115..53f8f06aafa41 100644 --- a/ext/intl/tests/formatter_get_locale_variant2.phpt +++ b/ext/intl/tests/formatter_get_locale_variant2.phpt @@ -3,7 +3,6 @@ numfmt_get_locale() --EXTENSIONS-- intl --SKIPIF-- -= 51.2'); ?> = 0) die('skip for ICU < 58.1'); ?> --FILE-- = 0) die('skip for ICU < 56.1'); ?> ---FILE-- - array( NumberFormatter::POSITIVE_PREFIX, '_+_', 12345.1234 ), - 'POSITIVE_SUFFIX' => array( NumberFormatter::POSITIVE_SUFFIX, '_+_', 12345.1234 ), - 'NEGATIVE_PREFIX' => array( NumberFormatter::NEGATIVE_PREFIX, '_-_', -12345.1234 ), - 'NEGATIVE_SUFFIX' => array( NumberFormatter::NEGATIVE_SUFFIX, '_-_', -12345.1234 ), - 'PADDING_CHARACTER' => array( NumberFormatter::PADDING_CHARACTER, '^', 12345.1234 ), - 'POSITIVE_PREFIX-2' => array( NumberFormatter::POSITIVE_PREFIX, $long_str, 12345.1234 ), -// 'CURRENCY_CODE' => array( NumberFormatter::CURRENCY_CODE, '_C_', 12345.1234 ) -// 'DEFAULT_RULESET' => array( NumberFormatter::DEFAULT_RULESET, '_DR_', 12345.1234 ), -// 'PUBLIC_RULESETS' => array( NumberFormatter::PUBLIC_RULESETS, '_PR_', 12345.1234 ) - ); - - $res_str = ''; - - $fmt = ut_nfmt_create( "en_US", NumberFormatter::DECIMAL ); - - foreach( $attributes as $attr_name => $data ) - { - list( $attr, $new_val, $test_number ) = $data; - $res_str .= "\nAttribute $attr_name\n"; - - if( $attr == NumberFormatter::PADDING_CHARACTER ) - ut_nfmt_set_attribute( $fmt, NumberFormatter::FORMAT_WIDTH, 21 ); - - // Get default attribute's value - $def_val = ut_nfmt_get_text_attribute( $fmt, $attr ); - if( $def_val === false ) - $res_str .= "get_text_attribute() error: " . ut_nfmt_get_error_message( $fmt ) . "\n"; - - $res_str .= "Default value: [$def_val]\n"; - $res_str .= "Formatting number with default value: " . ut_nfmt_format( $fmt, $test_number ) . "\n"; - - // Set new attribute's value and see if it works out. - $res_val = ut_nfmt_set_text_attribute( $fmt, $attr, $new_val ); - if( !$res_val ) - $res_str .= "set_text_attribute() error: " . ut_nfmt_get_error_message( $fmt ) . "\n"; - - // Get attribute value back. - $new_val_check = ut_nfmt_get_text_attribute( $fmt, $attr ); - $res_str .= "New value: [$new_val_check]\n"; - $res_str .= "Formatting number with new value: " . ut_nfmt_format( $fmt, $test_number ) . "\n"; - - // Check if the new value has been set. - if( $new_val !== $new_val_check ) - $res_str .= "ERROR: New $attr_name symbol value has not been set correctly.\n"; - - // Restore attribute's value to default - ut_nfmt_set_text_attribute( $fmt, $attr, $def_val ); - - if( $attr == NumberFormatter::PADDING_CHARACTER ) - ut_nfmt_set_attribute( $fmt, NumberFormatter::FORMAT_WIDTH, 0 ); - } - - // - $fmt = ut_nfmt_create( "uk_UA", NumberFormatter::CURRENCY ); - $res_str .= sprintf( "\nCurrency ISO-code for locale 'uk_UA' is: %s\n", - ut_nfmt_get_text_attribute( $fmt, NumberFormatter::CURRENCY_CODE ) ); - - return $res_str; -} - -include_once( 'ut_common.inc' ); -ut_run(); - -?> ---EXPECT-- -Attribute POSITIVE_PREFIX -Default value: [] -Formatting number with default value: 12,345.123 -New value: [_+_] -Formatting number with new value: _+_12,345.123 - -Attribute POSITIVE_SUFFIX -Default value: [] -Formatting number with default value: 12,345.123 -New value: [_+_] -Formatting number with new value: 12,345.123_+_ - -Attribute NEGATIVE_PREFIX -Default value: [-] -Formatting number with default value: -12,345.123 -New value: [_-_] -Formatting number with new value: _-_12,345.123 - -Attribute NEGATIVE_SUFFIX -Default value: [] -Formatting number with default value: -12,345.123 -New value: [_-_] -Formatting number with new value: -12,345.123_-_ - -Attribute PADDING_CHARACTER -Default value: [*] -Formatting number with default value: ***********12,345.123 -New value: [^] -Formatting number with new value: ^^^^^^^^^^^12,345.123 - -Attribute POSITIVE_PREFIX-2 -Default value: [] -Formatting number with default value: 12,345.123 -New value: [blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah] -Formatting number with new value: blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah12,345.123 - -Currency ISO-code for locale 'uk_UA' is: UAH diff --git a/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt b/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt index d21213d9ee847..7988a1d62d14e 100644 --- a/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt +++ b/ext/intl/tests/formatter_get_set_text_attribute_var2.phpt @@ -2,8 +2,6 @@ numfmt_get/set_text_attribute() ICU >= 56.1 --EXTENSIONS-- intl ---SKIPIF-- -= 56.1'); ?> --FILE-- = 4.8 && icu < 50.1.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - ---EXPECT-- --------------- -loc_range:de-de matches lang_tag de-DEVA ? NO -loc_range:de_DE canonically matches lang_tag de_Deva ? NO --------------- -loc_range:de-de matches lang_tag de-DE-1996 ? YES -loc_range:de_DE canonically matches lang_tag de_DE_1996 ? YES --------------- -loc_range:de-de matches lang_tag de-DE ? YES -loc_range:de_DE canonically matches lang_tag de_DE ? YES --------------- -loc_range:de-de matches lang_tag zh_Hans ? NO -loc_range:de_DE canonically matches lang_tag zh_Hans ? NO --------------- -loc_range:de-de matches lang_tag de-CH-1996 ? NO -loc_range:de_DE canonically matches lang_tag de_CH_1996 ? NO --------------- -loc_range:de-de matches lang_tag sl_IT ? NO -loc_range:de_DE canonically matches lang_tag sl_IT ? NO --------------- -loc_range:de-de matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO -loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO --------------- -loc_range:de-de matches lang_tag sl_IT_rozaj ? NO -loc_range:de_DE canonically matches lang_tag sl_IT_ROZAJ ? NO --------------- -loc_range:de-de matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO -loc_range:de_DE canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO --------------- -loc_range:de-de matches lang_tag i-enochian ? NO -loc_range:de_DE canonically matches lang_tag @x=i-enochian ? NO --------------- -loc_range:de-de matches lang_tag sgn-CH-de ? NO -loc_range:de_DE canonically matches lang_tag sgn_CH_DE ? NO --------------- -loc_range:de-de matches lang_tag art-lojban ? NO -loc_range:de_DE canonically matches lang_tag jbo ? NO --------------- -loc_range:de-de matches lang_tag i-lux ? NO -loc_range:de_DE canonically matches lang_tag lb ? NO --------------- -loc_range:de-de matches lang_tag art-lojban ? NO -loc_range:de_DE canonically matches lang_tag jbo ? NO --------------- -loc_range:de-de matches lang_tag jbo ? NO -loc_range:de_DE canonically matches lang_tag jbo ? NO --------------- -loc_range:de-de matches lang_tag en_sl_IT ? NO -loc_range:de_DE canonically matches lang_tag en_SL_IT ? NO --------------- -loc_range:sl_IT matches lang_tag de-DEVA ? NO -loc_range:sl_IT canonically matches lang_tag de_Deva ? NO --------------- -loc_range:sl_IT matches lang_tag de-DE-1996 ? NO -loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO --------------- -loc_range:sl_IT matches lang_tag de-DE ? NO -loc_range:sl_IT canonically matches lang_tag de_DE ? NO --------------- -loc_range:sl_IT matches lang_tag zh_Hans ? NO -loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO --------------- -loc_range:sl_IT matches lang_tag de-CH-1996 ? NO -loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO --------------- -loc_range:sl_IT matches lang_tag sl_IT ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT ? YES --------------- -loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES --------------- -loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES --------------- -loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES --------------- -loc_range:sl_IT matches lang_tag i-enochian ? NO -loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO --------------- -loc_range:sl_IT matches lang_tag sgn-CH-de ? NO -loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO --------------- -loc_range:sl_IT matches lang_tag art-lojban ? NO -loc_range:sl_IT canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT matches lang_tag i-lux ? NO -loc_range:sl_IT canonically matches lang_tag lb ? NO --------------- -loc_range:sl_IT matches lang_tag art-lojban ? NO -loc_range:sl_IT canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT matches lang_tag jbo ? NO -loc_range:sl_IT canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT matches lang_tag en_sl_IT ? NO -loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag de-DEVA ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag de_Deva ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag de-DE-1996 ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE_1996 ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag de-DE ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag de_DE ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag zh_Hans ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag zh_Hans ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag de-CH-1996 ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag de_CH_1996 ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag sl_IT ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES -loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES --------------- -loc_range:sl_IT_Nedis matches lang_tag sl_IT_rozaj ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_ROZAJ ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES -loc_range:sl_IT_NEDIS canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES --------------- -loc_range:sl_IT_Nedis matches lang_tag i-enochian ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag @x=i-enochian ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag sgn-CH-de ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag sgn_CH_DE ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag i-lux ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag lb ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag art-lojban ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag jbo ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT_Nedis matches lang_tag en_sl_IT ? NO -loc_range:sl_IT_NEDIS canonically matches lang_tag en_SL_IT ? NO --------------- -loc_range:jbo matches lang_tag de-DEVA ? NO -loc_range:jbo canonically matches lang_tag de_Deva ? NO --------------- -loc_range:jbo matches lang_tag de-DE-1996 ? NO -loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO --------------- -loc_range:jbo matches lang_tag de-DE ? NO -loc_range:jbo canonically matches lang_tag de_DE ? NO --------------- -loc_range:jbo matches lang_tag zh_Hans ? NO -loc_range:jbo canonically matches lang_tag zh_Hans ? NO --------------- -loc_range:jbo matches lang_tag de-CH-1996 ? NO -loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO --------------- -loc_range:jbo matches lang_tag sl_IT ? NO -loc_range:jbo canonically matches lang_tag sl_IT ? NO --------------- -loc_range:jbo matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO -loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO --------------- -loc_range:jbo matches lang_tag sl_IT_rozaj ? NO -loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO --------------- -loc_range:jbo matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO -loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO --------------- -loc_range:jbo matches lang_tag i-enochian ? NO -loc_range:jbo canonically matches lang_tag @x=i-enochian ? NO --------------- -loc_range:jbo matches lang_tag sgn-CH-de ? NO -loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO --------------- -loc_range:jbo matches lang_tag art-lojban ? NO -loc_range:jbo canonically matches lang_tag jbo ? YES --------------- -loc_range:jbo matches lang_tag i-lux ? NO -loc_range:jbo canonically matches lang_tag lb ? NO --------------- -loc_range:jbo matches lang_tag art-lojban ? NO -loc_range:jbo canonically matches lang_tag jbo ? YES --------------- -loc_range:jbo matches lang_tag jbo ? YES -loc_range:jbo canonically matches lang_tag jbo ? YES --------------- -loc_range:jbo matches lang_tag en_sl_IT ? NO -loc_range:jbo canonically matches lang_tag en_SL_IT ? NO --------------- -loc_range:art-lojban matches lang_tag de-DEVA ? NO -loc_range:jbo canonically matches lang_tag de_Deva ? NO --------------- -loc_range:art-lojban matches lang_tag de-DE-1996 ? NO -loc_range:jbo canonically matches lang_tag de_DE_1996 ? NO --------------- -loc_range:art-lojban matches lang_tag de-DE ? NO -loc_range:jbo canonically matches lang_tag de_DE ? NO --------------- -loc_range:art-lojban matches lang_tag zh_Hans ? NO -loc_range:jbo canonically matches lang_tag zh_Hans ? NO --------------- -loc_range:art-lojban matches lang_tag de-CH-1996 ? NO -loc_range:jbo canonically matches lang_tag de_CH_1996 ? NO --------------- -loc_range:art-lojban matches lang_tag sl_IT ? NO -loc_range:jbo canonically matches lang_tag sl_IT ? NO --------------- -loc_range:art-lojban matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? NO -loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? NO --------------- -loc_range:art-lojban matches lang_tag sl_IT_rozaj ? NO -loc_range:jbo canonically matches lang_tag sl_IT_ROZAJ ? NO --------------- -loc_range:art-lojban matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO -loc_range:jbo canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? NO --------------- -loc_range:art-lojban matches lang_tag i-enochian ? NO -loc_range:jbo canonically matches lang_tag @x=i-enochian ? NO --------------- -loc_range:art-lojban matches lang_tag sgn-CH-de ? NO -loc_range:jbo canonically matches lang_tag sgn_CH_DE ? NO --------------- -loc_range:art-lojban matches lang_tag art-lojban ? YES -loc_range:jbo canonically matches lang_tag jbo ? YES --------------- -loc_range:art-lojban matches lang_tag i-lux ? NO -loc_range:jbo canonically matches lang_tag lb ? NO --------------- -loc_range:art-lojban matches lang_tag art-lojban ? YES -loc_range:jbo canonically matches lang_tag jbo ? YES --------------- -loc_range:art-lojban matches lang_tag jbo ? NO -loc_range:jbo canonically matches lang_tag jbo ? YES --------------- -loc_range:art-lojban matches lang_tag en_sl_IT ? NO -loc_range:jbo canonically matches lang_tag en_SL_IT ? NO --------------- -loc_range:sl_IT matches lang_tag de-DEVA ? NO -loc_range:sl_IT canonically matches lang_tag de_Deva ? NO --------------- -loc_range:sl_IT matches lang_tag de-DE-1996 ? NO -loc_range:sl_IT canonically matches lang_tag de_DE_1996 ? NO --------------- -loc_range:sl_IT matches lang_tag de-DE ? NO -loc_range:sl_IT canonically matches lang_tag de_DE ? NO --------------- -loc_range:sl_IT matches lang_tag zh_Hans ? NO -loc_range:sl_IT canonically matches lang_tag zh_Hans ? NO --------------- -loc_range:sl_IT matches lang_tag de-CH-1996 ? NO -loc_range:sl_IT canonically matches lang_tag de_CH_1996 ? NO --------------- -loc_range:sl_IT matches lang_tag sl_IT ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT ? YES --------------- -loc_range:sl_IT matches lang_tag sl_IT_nedis-a-kirti-x-xyz ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_A_KIRTI_X_XYZ ? YES --------------- -loc_range:sl_IT matches lang_tag sl_IT_rozaj ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT_ROZAJ ? YES --------------- -loc_range:sl_IT matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES -loc_range:sl_IT canonically matches lang_tag sl_IT_NEDIS_ROJAZ_1901 ? YES --------------- -loc_range:sl_IT matches lang_tag i-enochian ? NO -loc_range:sl_IT canonically matches lang_tag @x=i-enochian ? NO --------------- -loc_range:sl_IT matches lang_tag sgn-CH-de ? NO -loc_range:sl_IT canonically matches lang_tag sgn_CH_DE ? NO --------------- -loc_range:sl_IT matches lang_tag art-lojban ? NO -loc_range:sl_IT canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT matches lang_tag i-lux ? NO -loc_range:sl_IT canonically matches lang_tag lb ? NO --------------- -loc_range:sl_IT matches lang_tag art-lojban ? NO -loc_range:sl_IT canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT matches lang_tag jbo ? NO -loc_range:sl_IT canonically matches lang_tag jbo ? NO --------------- -loc_range:sl_IT matches lang_tag en_sl_IT ? NO -loc_range:sl_IT canonically matches lang_tag en_SL_IT ? NO diff --git a/ext/intl/tests/locale_get_display_name2.phpt b/ext/intl/tests/locale_get_display_name2.phpt deleted file mode 100644 index 1010f168ae1f0..0000000000000 --- a/ext/intl/tests/locale_get_display_name2.phpt +++ /dev/null @@ -1,343 +0,0 @@ ---TEST-- -locale_get_display_name() icu >= 4.8 && icu < 50.1.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - ---EXPECTREGEX-- -locale='sl_IT_nedis_KIRTI' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI# -disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI# ------------------ -locale='sl_IT_nedis-a-kirti-x-xyz' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ# -disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ# ------------------ -locale='sl_IT_rozaj' -disp_locale=en : display_name=Slovenian #Italy, Resian# -disp_locale=fr : display_name=slovène #Italie, dialecte de Resia# -disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)# ------------------ -locale='sl_IT_NEDIS_ROJAZ_1901' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901# -disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901# ------------------ -locale='i-enochian' -disp_locale=en : display_name=i-enochian #Private-Use=i-enochian# -disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian# -disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian# ------------------ -locale='zh-hakka' -disp_locale=en : display_name=Chinese( #HAKKA#)? -disp_locale=fr : display_name=chinois( #HAKKA#)? -disp_locale=de : display_name=Chinesisch( #HAKKA#)? ------------------ -locale='zh-wuu' -disp_locale=en : display_name=Chinese #WUU# -disp_locale=fr : display_name=chinois #WUU# -disp_locale=de : display_name=Chinesisch #WUU# ------------------ -locale='i-tay' -disp_locale=en : display_name=i-tay -disp_locale=fr : display_name=i-tay -disp_locale=de : display_name=i-tay ------------------ -locale='sgn-BE-nl' -disp_locale=en : display_name=Sign Languages? #Belgium, NL# -disp_locale=fr : display_name=langues? des signes #Belgique, NL# -disp_locale=de : display_name=Gebärdensprache #Belgien, NL# ------------------ -locale='sgn-CH-de' -disp_locale=en : display_name=Sign Languages? #Switzerland, DE# -disp_locale=fr : display_name=langues? des signes #Suisse, DE# -disp_locale=de : display_name=Gebärdensprache #Schweiz, DE# ------------------ -locale='sl_IT_rozaj@currency=EUR' -disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro# -disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, Devise=euro# -disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro# ------------------ -locale='uk-ua_CALIFORNIA@currency=;currency=GRN' -disp_locale=en : display_name=Ukrainian #Ukraine, CALIFORNIA, [Cc]urrency# -disp_locale=fr : display_name=ukrainien #Ukraine, CALIFORNIA, Devise# -disp_locale=de : display_name=Ukrainisch #Ukraine, CALIFORNIA, Währung# ------------------ -locale='root' -disp_locale=en : display_name=Root -disp_locale=fr : display_name=racine -disp_locale=de : display_name=[Rr]oot ------------------ -locale='uk@currency=EURO' -disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO# -disp_locale=fr : display_name=ukrainien #Devise=EURO# -disp_locale=de : display_name=Ukrainisch #Währung=EURO# ------------------ -locale='Hindi' -disp_locale=en : display_name=hindi -disp_locale=fr : display_name=hindi -disp_locale=de : display_name=hindi ------------------ -locale='de' -disp_locale=en : display_name=German -disp_locale=fr : display_name=allemand -disp_locale=de : display_name=Deutsch ------------------ -locale='fr' -disp_locale=en : display_name=French -disp_locale=fr : display_name=français -disp_locale=de : display_name=Französisch ------------------ -locale='ja' -disp_locale=en : display_name=Japanese -disp_locale=fr : display_name=japonais -disp_locale=de : display_name=Japanisch ------------------ -locale='i-enochian' -disp_locale=en : display_name=i-enochian #Private-Use=i-enochian# -disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian# -disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian# ------------------ -locale='zh-Hant' -disp_locale=en : display_name=Chinese #Traditional# -disp_locale=fr : display_name=chinois #idéogrammes han (#variante traditionnelle#|traditionnels)# -disp_locale=de : display_name=Chinesisch #Traditionell# ------------------ -locale='zh-Hans' -disp_locale=en : display_name=Chinese #Simplified# -disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés)# -disp_locale=de : display_name=Chinesisch #Vereinfacht# ------------------ -locale='sr-Cyrl' -disp_locale=en : display_name=Serbian #Cyrillic# -disp_locale=fr : display_name=serbe #cyrillique# -disp_locale=de : display_name=Serbisch #Kyrillisch# ------------------ -locale='sr-Latn' -disp_locale=en : display_name=Serbian #Latin# -disp_locale=fr : display_name=serbe #latin# -disp_locale=de : display_name=Serbisch #Lateinisch# ------------------ -locale='zh-Hans-CN' -disp_locale=en : display_name=Chinese #Simplified, China# -disp_locale=fr : display_name=chinois #idéogrammes han (#variante simplifiée#|simplifiés), Chine# -disp_locale=de : display_name=Chinesisch #Vereinfacht, China# ------------------ -locale='sr-Latn-CS' -disp_locale=en : display_name=Serbian #Latin, Serbia [aA]nd Montenegro# -disp_locale=fr : display_name=serbe #latin, Serbie-et-Monténégro# -disp_locale=de : display_name=Serbisch #Lateinisch, Serbien und Montenegro# ------------------ -locale='sl-rozaj' -disp_locale=en : display_name=Slovenian #Resian# -disp_locale=fr : display_name=slovène #dialecte de Resia# -disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)? ------------------ -locale='sl-nedis' -disp_locale=en : display_name=Slovenian #Natisone dialect# -disp_locale=fr : display_name=slovène #dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Natisone-Dialekt# ------------------ -locale='de-CH-1901' -disp_locale=en : display_name=German #Switzerland, Traditional German orthography# -disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle# -disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)# ------------------ -locale='sl-IT-nedis' -disp_locale=en : display_name=Slovenian #Italy, Natisone dialect# -disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)# ------------------ -locale='sl-Latn-IT-nedis' -disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect# -disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)# ------------------ -locale='de-DE' -disp_locale=en : display_name=German #Germany# -disp_locale=fr : display_name=allemand #Allemagne# -disp_locale=de : display_name=Deutsch #Deutschland# ------------------ -locale='en-US' -disp_locale=en : display_name=English #United States# -disp_locale=fr : display_name=anglais #États-Unis# -disp_locale=de : display_name=Englisch #Vereinigte Staaten# ------------------ -locale='es-419' -disp_locale=en : display_name=Spanish #Latin America# -disp_locale=fr : display_name=espagnol #Amérique latine# -disp_locale=de : display_name=Spanisch #Lateinamerika# ------------------ -locale='de-CH-x-phonebk' -disp_locale=en : display_name=German #Switzerland, Private-Use=phonebk# -disp_locale=fr : display_name=allemand #Suisse, Usage privé=phonebk# -disp_locale=de : display_name=Deutsch #Schweiz, Privatnutzung=phonebk# ------------------ -locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_name=Azerbaijani #Arabic, Private-Use=aze-derbend# -disp_locale=fr : display_name=azéri #arabe, Usage privé=aze-derbend# -disp_locale=de : display_name=Aserbaidschanisch #Arabisch, Privatnutzung=aze-derbend# ------------------ -locale='zh-min' -disp_locale=en : display_name=Chinese #MIN# -disp_locale=fr : display_name=chinois #MIN# -disp_locale=de : display_name=Chinesisch #MIN# ------------------ -locale='zh-min-nan-Hant-CN' -disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN# -disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN# -disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN# ------------------ -locale='x-whatever' -disp_locale=en : display_name=x-whatever #Private-Use=whatever# -disp_locale=fr : display_name=x-whatever #Usage privé=whatever# -disp_locale=de : display_name=x-whatever #Privatnutzung=whatever# ------------------ -locale='qaa-Qaaa-QM-x-southern' -disp_locale=en : display_name=qaa #Qaaa, QM, Private-Use=southern# -disp_locale=fr : display_name=qaa #Qaaa, QM, Usage privé=southern# -disp_locale=de : display_name=qaa #Qaaa, QM, Privatnutzung=southern# ------------------ -locale='sr-Latn-QM' -disp_locale=en : display_name=Serbian #Latin, QM# -disp_locale=fr : display_name=serbe #latin, QM# -disp_locale=de : display_name=Serbisch #Lateinisch, QM# ------------------ -locale='sr-Qaaa-CS' -disp_locale=en : display_name=Serbian #Qaaa, Serbia [aA]nd Montenegro# -disp_locale=fr : display_name=serbe #Qaaa, Serbie-et-Monténégro# -disp_locale=de : display_name=Serbisch #Qaaa, Serbien und Montenegro# ------------------ -locale='en-US-u-islamCal' -disp_locale=en : display_name=English #United States, attribute=islamcal# -disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal# -disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal# ------------------ -locale='zh-CN-a-myExt-x-private' -disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private# -disp_locale=fr : display_name=chinois #Chine, a=myext, Usage privé=private# -disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private# ------------------ -locale='en-a-myExt-b-another' -disp_locale=en : display_name=English #a=myext, b=another# -disp_locale=fr : display_name=anglais #a=myext, b=another# -disp_locale=de : display_name=Englisch #a=myext, b=another# ------------------ -locale='de-419-DE' -disp_locale=en : display_name=German #Latin America, DE# -disp_locale=fr : display_name=allemand #Amérique latine, DE# -disp_locale=de : display_name=Deutsch #Lateinamerika, DE# ------------------ -locale='a-DE' -disp_locale=en : display_name=a #Germany# -disp_locale=fr : display_name=a #Allemagne# -disp_locale=de : display_name=a #Deutschland# ------------------ -locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_name=Arabic #a=aaa, b=bbb# -disp_locale=fr : display_name=arabe #a=aaa, b=bbb# -disp_locale=de : display_name=Arabisch #a=aaa, b=bbb# ------------------ diff --git a/ext/intl/tests/locale_get_display_name3.phpt b/ext/intl/tests/locale_get_display_name3.phpt deleted file mode 100644 index b0c45e6f21d48..0000000000000 --- a/ext/intl/tests/locale_get_display_name3.phpt +++ /dev/null @@ -1,343 +0,0 @@ ---TEST-- -locale_get_display_name() icu >= 51.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- - ---EXPECTREGEX-- -locale='sl_IT_nedis_KIRTI' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI# -disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI# ------------------ -locale='sl_IT_nedis-a-kirti-x-xyz' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ# -disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ# ------------------ -locale='sl_IT_rozaj' -disp_locale=en : display_name=Slovenian #Italy, Resian# -disp_locale=fr : display_name=slovène #Italie, dialecte de Resia# -disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)# ------------------ -locale='sl_IT_NEDIS_ROJAZ_1901' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901# -disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901# ------------------ -locale='i-enochian' -disp_locale=en : display_name=i-enochian #Private-Use=i-enochian# -disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian# -disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian# ------------------ -locale='zh-hakka' -disp_locale=en : display_name=Chinese( #HAKKA#)? -disp_locale=fr : display_name=chinois( #HAKKA#)? -disp_locale=de : display_name=Chinesisch( #HAKKA#)? ------------------ -locale='zh-wuu' -disp_locale=en : display_name=Chinese #WUU# -disp_locale=fr : display_name=chinois #WUU# -disp_locale=de : display_name=Chinesisch #WUU# ------------------ -locale='i-tay' -disp_locale=en : display_name=i-tay -disp_locale=fr : display_name=i-tay -disp_locale=de : display_name=i-tay ------------------ -locale='sgn-BE-nl' -disp_locale=en : display_name=Sign Languages? #Belgium, NL# -disp_locale=fr : display_name=langues? des signes #Belgique, NL# -disp_locale=de : display_name=Gebärdensprache #Belgien, NL# ------------------ -locale='sgn-CH-de' -disp_locale=en : display_name=Sign Languages? #Switzerland, DE# -disp_locale=fr : display_name=langues? des signes #Suisse, DE# -disp_locale=de : display_name=Gebärdensprache #Schweiz, DE# ------------------ -locale='sl_IT_rozaj@currency=EUR' -disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro# -disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, [Dd]evise=euro# -disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro# ------------------ -locale='uk-ua_CALIFORNIA@currency=;currency=GRN' -disp_locale=en : display_name=Ukrainian #Ukraine, CALIFORNIA, [Cc]urrency# -disp_locale=fr : display_name=ukrainien #Ukraine, CALIFORNIA, [Dd]evise# -disp_locale=de : display_name=Ukrainisch #Ukraine, CALIFORNIA, Währung# ------------------ -locale='root' -disp_locale=en : display_name=Root -disp_locale=fr : display_name=racine -disp_locale=de : display_name=[Rr]oot ------------------ -locale='uk@currency=EURO' -disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO# -disp_locale=fr : display_name=ukrainien #[Dd]evise=EURO# -disp_locale=de : display_name=Ukrainisch #Währung=EURO# ------------------ -locale='Hindi' -disp_locale=en : display_name=hindi -disp_locale=fr : display_name=hindi -disp_locale=de : display_name=hindi ------------------ -locale='de' -disp_locale=en : display_name=German -disp_locale=fr : display_name=allemand -disp_locale=de : display_name=Deutsch ------------------ -locale='fr' -disp_locale=en : display_name=French -disp_locale=fr : display_name=français -disp_locale=de : display_name=Französisch ------------------ -locale='ja' -disp_locale=en : display_name=Japanese -disp_locale=fr : display_name=japonais -disp_locale=de : display_name=Japanisch ------------------ -locale='i-enochian' -disp_locale=en : display_name=i-enochian #Private-Use=i-enochian# -disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian# -disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian# ------------------ -locale='zh-Hant' -disp_locale=en : display_name=Chinese #Traditional# -disp_locale=fr : display_name=chinois #traditionnel# -disp_locale=de : display_name=Chinesisch #Traditionell# ------------------ -locale='zh-Hans' -disp_locale=en : display_name=Chinese #Simplified# -disp_locale=fr : display_name=chinois #simplifié# -disp_locale=de : display_name=Chinesisch #Vereinfacht# ------------------ -locale='sr-Cyrl' -disp_locale=en : display_name=Serbian #Cyrillic# -disp_locale=fr : display_name=serbe #cyrillique# -disp_locale=de : display_name=Serbisch #Kyrillisch# ------------------ -locale='sr-Latn' -disp_locale=en : display_name=Serbian #Latin# -disp_locale=fr : display_name=serbe #latin# -disp_locale=de : display_name=Serbisch #Lateinisch# ------------------ -locale='zh-Hans-CN' -disp_locale=en : display_name=Chinese #Simplified, China# -disp_locale=fr : display_name=chinois #simplifié, Chine# -disp_locale=de : display_name=Chinesisch #Vereinfacht, China# ------------------ -locale='sr-Latn-CS' -disp_locale=en : display_name=Serbian #Latin, Serbia# -disp_locale=fr : display_name=serbe #latin, Serbie# -disp_locale=de : display_name=Serbisch #Lateinisch, Serbien# ------------------ -locale='sl-rozaj' -disp_locale=en : display_name=Slovenian #Resian# -disp_locale=fr : display_name=slovène #dialecte de Resia# -disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)? ------------------ -locale='sl-nedis' -disp_locale=en : display_name=Slovenian #Natisone dialect# -disp_locale=fr : display_name=slovène #dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Natisone-Dialekt# ------------------ -locale='de-CH-1901' -disp_locale=en : display_name=German #Switzerland, Traditional German orthography# -disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle# -disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)# ------------------ -locale='sl-IT-nedis' -disp_locale=en : display_name=Slovenian #Italy, Natisone dialect# -disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)# ------------------ -locale='sl-Latn-IT-nedis' -disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect# -disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)# ------------------ -locale='de-DE' -disp_locale=en : display_name=German #Germany# -disp_locale=fr : display_name=allemand #Allemagne# -disp_locale=de : display_name=Deutsch #Deutschland# ------------------ -locale='en-US' -disp_locale=en : display_name=English #United States# -disp_locale=fr : display_name=anglais #États-Unis# -disp_locale=de : display_name=Englisch #Vereinigte Staaten# ------------------ -locale='es-419' -disp_locale=en : display_name=Spanish #Latin America# -disp_locale=fr : display_name=espagnol #Amérique latine# -disp_locale=de : display_name=Spanisch #Lateinamerika# ------------------ -locale='de-CH-x-phonebk' -disp_locale=en : display_name=German #Switzerland, Private-Use=phonebk# -disp_locale=fr : display_name=allemand #Suisse, Usage privé=phonebk# -disp_locale=de : display_name=Deutsch #Schweiz, Privatnutzung=phonebk# ------------------ -locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_name=Azerbaijani #Arabic, Private-Use=aze-derbend# -disp_locale=fr : display_name=azéri #arabe, Usage privé=aze-derbend# -disp_locale=de : display_name=Aserbaidschanisch #Arabisch, Privatnutzung=aze-derbend# ------------------ -locale='zh-min' -disp_locale=en : display_name=Chinese #MIN# -disp_locale=fr : display_name=chinois #MIN# -disp_locale=de : display_name=Chinesisch #MIN# ------------------ -locale='zh-min-nan-Hant-CN' -disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN# -disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN# -disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN# ------------------ -locale='x-whatever' -disp_locale=en : display_name=x-whatever #Private-Use=whatever# -disp_locale=fr : display_name=x-whatever #Usage privé=whatever# -disp_locale=de : display_name=x-whatever #Privatnutzung=whatever# ------------------ -locale='qaa-Qaaa-QM-x-southern' -disp_locale=en : display_name=qaa #Qaaa, QM, Private-Use=southern# -disp_locale=fr : display_name=qaa #Qaaa, QM, Usage privé=southern# -disp_locale=de : display_name=qaa #Qaaa, QM, Privatnutzung=southern# ------------------ -locale='sr-Latn-QM' -disp_locale=en : display_name=Serbian #Latin, QM# -disp_locale=fr : display_name=serbe #latin, QM# -disp_locale=de : display_name=Serbisch #Lateinisch, QM# ------------------ -locale='sr-Qaaa-CS' -disp_locale=en : display_name=Serbian #Qaaa, Serbia# -disp_locale=fr : display_name=serbe #Qaaa, Serbie# -disp_locale=de : display_name=Serbisch #Qaaa, Serbien# ------------------ -locale='en-US-u-islamCal' -disp_locale=en : display_name=English #United States, attribute=islamcal# -disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal# -disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal# ------------------ -locale='zh-CN-a-myExt-x-private' -disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private# -disp_locale=fr : display_name=chinois #Chine, a=myext, Usage privé=private# -disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private# ------------------ -locale='en-a-myExt-b-another' -disp_locale=en : display_name=English #a=myext, b=another# -disp_locale=fr : display_name=anglais #a=myext, b=another# -disp_locale=de : display_name=Englisch #a=myext, b=another# ------------------ -locale='de-419-DE' -disp_locale=en : display_name=German #Latin America, DE# -disp_locale=fr : display_name=allemand #Amérique latine, DE# -disp_locale=de : display_name=Deutsch #Lateinamerika, DE# ------------------ -locale='a-DE' -disp_locale=en : display_name=a #Germany# -disp_locale=fr : display_name=a #Allemagne# -disp_locale=de : display_name=a #Deutschland# ------------------ -locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_name=Arabic #a=aaa, b=bbb# -disp_locale=fr : display_name=arabe #a=aaa, b=bbb# -disp_locale=de : display_name=Arabisch #a=aaa, b=bbb# ------------------ diff --git a/ext/intl/tests/locale_get_display_name4.phpt b/ext/intl/tests/locale_get_display_name4.phpt deleted file mode 100644 index e2773a2cf039e..0000000000000 --- a/ext/intl/tests/locale_get_display_name4.phpt +++ /dev/null @@ -1,344 +0,0 @@ ---TEST-- -locale_get_display_name() icu >= 52.1 && icu < 53.1 ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 53.1'); ?> ---FILE-- - ---EXPECTREGEX-- -locale='sl_IT_nedis_KIRTI' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_KIRTI# -disp_locale=fr : display_name=slovène #Italie, NEDIS_KIRTI# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_KIRTI# ------------------ -locale='sl_IT_nedis-a-kirti-x-xyz' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_A_KIRTI_X_XYZ# -disp_locale=fr : display_name=slovène #Italie, NEDIS_A_KIRTI_X_XYZ# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_A_KIRTI_X_XYZ# ------------------ -locale='sl_IT_rozaj' -disp_locale=en : display_name=Slovenian #Italy, Resian# -disp_locale=fr : display_name=slovène #Italie, dialecte de Resia# -disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch)# ------------------ -locale='sl_IT_NEDIS_ROJAZ_1901' -disp_locale=en : display_name=Slovenian #Italy, NEDIS_ROJAZ_1901# -disp_locale=fr : display_name=slovène #Italie, NEDIS_ROJAZ_1901# -disp_locale=de : display_name=Slowenisch #Italien, NEDIS_ROJAZ_1901# ------------------ -locale='i-enochian' -disp_locale=en : display_name=i-enochian #Private-Use=i-enochian# -disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian# -disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian# ------------------ -locale='zh-hakka' -disp_locale=en : display_name=Chinese( #HAKKA#)? -disp_locale=fr : display_name=chinois( #HAKKA#)? -disp_locale=de : display_name=Chinesisch( #HAKKA#)? ------------------ -locale='zh-wuu' -disp_locale=en : display_name=Chinese #WUU# -disp_locale=fr : display_name=chinois #WUU# -disp_locale=de : display_name=Chinesisch #WUU# ------------------ -locale='i-tay' -disp_locale=en : display_name=i-tay -disp_locale=fr : display_name=i-tay -disp_locale=de : display_name=i-tay ------------------ -locale='sgn-BE-nl' -disp_locale=en : display_name=Sign Languages? #Belgium, NL# -disp_locale=fr : display_name=langues? des signes #Belgique, NL# -disp_locale=de : display_name=Gebärdensprache #Belgien, NL# ------------------ -locale='sgn-CH-de' -disp_locale=en : display_name=Sign Languages? #Switzerland, DE# -disp_locale=fr : display_name=langues? des signes #Suisse, DE# -disp_locale=de : display_name=Gebärdensprache #Schweiz, DE# ------------------ -locale='sl_IT_rozaj@currency=EUR' -disp_locale=en : display_name=Slovenian #Italy, Resian, [Cc]urrency=Euro# -disp_locale=fr : display_name=slovène #Italie, dialecte de Resia, [Dd]evise=euro# -disp_locale=de : display_name=Slowenisch #Italien, (ROZAJ|Resianisch), Währung=Euro# ------------------ -locale='uk-ua_CALIFORNIA@currency=;currency=GRN' -disp_locale=en : display_name= -disp_locale=fr : display_name= -disp_locale=de : display_name= ------------------ -locale='root' -disp_locale=en : display_name=Root -disp_locale=fr : display_name=racine -disp_locale=de : display_name=[Rr]oot ------------------ -locale='uk@currency=EURO' -disp_locale=en : display_name=Ukrainian #[Cc]urrency=EURO# -disp_locale=fr : display_name=ukrainien #[Dd]evise=EURO# -disp_locale=de : display_name=Ukrainisch #Währung=EURO# ------------------ -locale='Hindi' -disp_locale=en : display_name=hindi -disp_locale=fr : display_name=hindi -disp_locale=de : display_name=hindi ------------------ -locale='de' -disp_locale=en : display_name=German -disp_locale=fr : display_name=allemand -disp_locale=de : display_name=Deutsch ------------------ -locale='fr' -disp_locale=en : display_name=French -disp_locale=fr : display_name=français -disp_locale=de : display_name=Französisch ------------------ -locale='ja' -disp_locale=en : display_name=Japanese -disp_locale=fr : display_name=japonais -disp_locale=de : display_name=Japanisch ------------------ -locale='i-enochian' -disp_locale=en : display_name=i-enochian #Private-Use=i-enochian# -disp_locale=fr : display_name=i-enochian #Usage privé=i-enochian# -disp_locale=de : display_name=i-enochian #Privatnutzung=i-enochian# ------------------ -locale='zh-Hant' -disp_locale=en : display_name=Chinese #Traditional# -disp_locale=fr : display_name=chinois #traditionnel# -disp_locale=de : display_name=Chinesisch #Traditionell# ------------------ -locale='zh-Hans' -disp_locale=en : display_name=Chinese #Simplified# -disp_locale=fr : display_name=chinois #simplifié# -disp_locale=de : display_name=Chinesisch #Vereinfacht# ------------------ -locale='sr-Cyrl' -disp_locale=en : display_name=Serbian #Cyrillic# -disp_locale=fr : display_name=serbe #cyrillique# -disp_locale=de : display_name=Serbisch #Kyrillisch# ------------------ -locale='sr-Latn' -disp_locale=en : display_name=Serbian #Latin# -disp_locale=fr : display_name=serbe #latin# -disp_locale=de : display_name=Serbisch #Lateinisch# ------------------ -locale='zh-Hans-CN' -disp_locale=en : display_name=Chinese #Simplified, China# -disp_locale=fr : display_name=chinois #simplifié, Chine# -disp_locale=de : display_name=Chinesisch #Vereinfacht, China# ------------------ -locale='sr-Latn-CS' -disp_locale=en : display_name=Serbian #Latin, Serbia# -disp_locale=fr : display_name=serbe #latin, Serbie# -disp_locale=de : display_name=Serbisch #Lateinisch, Serbien# ------------------ -locale='sl-rozaj' -disp_locale=en : display_name=Slovenian #Resian# -disp_locale=fr : display_name=slovène #dialecte de Resia# -disp_locale=de : display_name=Slowenisch( #(ROZAJ|Resianisch)#)? ------------------ -locale='sl-nedis' -disp_locale=en : display_name=Slovenian #Natisone dialect# -disp_locale=fr : display_name=slovène #dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Natisone-Dialekt# ------------------ -locale='de-CH-1901' -disp_locale=en : display_name=German #Switzerland, Traditional German orthography# -disp_locale=fr : display_name=allemand #Suisse, orthographe allemande traditionnelle# -disp_locale=de : display_name=Deutsch #Schweiz, (1901|[aA]lte deutsche Rechtschreibung)# ------------------ -locale='sl-IT-nedis' -disp_locale=en : display_name=Slovenian #Italy, Natisone dialect# -disp_locale=fr : display_name=slovène #Italie, dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Italien, (NEDIS|Natisone-Dialekt)# ------------------ -locale='sl-Latn-IT-nedis' -disp_locale=en : display_name=Slovenian #Latin, Italy, Natisone dialect# -disp_locale=fr : display_name=slovène #latin, Italie, dialecte de Natisone# -disp_locale=de : display_name=Slowenisch #Lateinisch, Italien, (NEDIS|Natisone-Dialekt)# ------------------ -locale='de-DE' -disp_locale=en : display_name=German #Germany# -disp_locale=fr : display_name=allemand #Allemagne# -disp_locale=de : display_name=Deutsch #Deutschland# ------------------ -locale='en-US' -disp_locale=en : display_name=English #United States# -disp_locale=fr : display_name=anglais #États-Unis# -disp_locale=de : display_name=Englisch #Vereinigte Staaten# ------------------ -locale='es-419' -disp_locale=en : display_name=Spanish #Latin America# -disp_locale=fr : display_name=espagnol #Amérique latine# -disp_locale=de : display_name=Spanisch #Lateinamerika# ------------------ -locale='de-CH-x-phonebk' -disp_locale=en : display_name=German #Switzerland, Private-Use=phonebk# -disp_locale=fr : display_name=allemand #Suisse, Usage privé=phonebk# -disp_locale=de : display_name=Deutsch #Schweiz, Privatnutzung=phonebk# ------------------ -locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_name=Azerbaijani #Arabic, Private-Use=aze-derbend# -disp_locale=fr : display_name=azéri #arabe, Usage privé=aze-derbend# -disp_locale=de : display_name=Aserbaidschanisch #Arabisch, Privatnutzung=aze-derbend# ------------------ -locale='zh-min' -disp_locale=en : display_name=Chinese #MIN# -disp_locale=fr : display_name=chinois #MIN# -disp_locale=de : display_name=Chinesisch #MIN# ------------------ -locale='zh-min-nan-Hant-CN' -disp_locale=en : display_name=Chinese #MIN, NAN_HANT_CN# -disp_locale=fr : display_name=chinois #MIN, NAN_HANT_CN# -disp_locale=de : display_name=Chinesisch #MIN, NAN_HANT_CN# ------------------ -locale='x-whatever' -disp_locale=en : display_name=x-whatever #Private-Use=whatever# -disp_locale=fr : display_name=x-whatever #Usage privé=whatever# -disp_locale=de : display_name=x-whatever #Privatnutzung=whatever# ------------------ -locale='qaa-Qaaa-QM-x-southern' -disp_locale=en : display_name=qaa #Qaaa, QM, Private-Use=southern# -disp_locale=fr : display_name=qaa #Qaaa, QM, Usage privé=southern# -disp_locale=de : display_name=qaa #Qaaa, QM, Privatnutzung=southern# ------------------ -locale='sr-Latn-QM' -disp_locale=en : display_name=Serbian #Latin, QM# -disp_locale=fr : display_name=serbe #latin, QM# -disp_locale=de : display_name=Serbisch #Lateinisch, QM# ------------------ -locale='sr-Qaaa-CS' -disp_locale=en : display_name=Serbian #Qaaa, Serbia# -disp_locale=fr : display_name=serbe #Qaaa, Serbie# -disp_locale=de : display_name=Serbisch #Qaaa, Serbien# ------------------ -locale='en-US-u-islamCal' -disp_locale=en : display_name=English #United States, attribute=islamcal# -disp_locale=fr : display_name=anglais #États-Unis, attribute=islamcal# -disp_locale=de : display_name=Englisch #Vereinigte Staaten, attribute=islamcal# ------------------ -locale='zh-CN-a-myExt-x-private' -disp_locale=en : display_name=Chinese #China, a=myext, Private-Use=private# -disp_locale=fr : display_name=chinois #Chine, a=myext, Usage privé=private# -disp_locale=de : display_name=Chinesisch #China, a=myext, Privatnutzung=private# ------------------ -locale='en-a-myExt-b-another' -disp_locale=en : display_name=English #a=myext, b=another# -disp_locale=fr : display_name=anglais #a=myext, b=another# -disp_locale=de : display_name=Englisch #a=myext, b=another# ------------------ -locale='de-419-DE' -disp_locale=en : display_name=German #Latin America, DE# -disp_locale=fr : display_name=allemand #Amérique latine, DE# -disp_locale=de : display_name=Deutsch #Lateinamerika, DE# ------------------ -locale='a-DE' -disp_locale=en : display_name=a #Germany# -disp_locale=fr : display_name=a #Allemagne# -disp_locale=de : display_name=a #Deutschland# ------------------ -locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_name=Arabic #a=aaa, b=bbb# -disp_locale=fr : display_name=arabe #a=aaa, b=bbb# -disp_locale=de : display_name=Arabisch #a=aaa, b=bbb# ------------------ diff --git a/ext/intl/tests/locale_get_display_name5.phpt b/ext/intl/tests/locale_get_display_name5.phpt index 62e46099da27f..27f86f98f2a3e 100644 --- a/ext/intl/tests/locale_get_display_name5.phpt +++ b/ext/intl/tests/locale_get_display_name5.phpt @@ -3,7 +3,6 @@ locale_get_display_name() icu >= 53.1 --EXTENSIONS-- intl --SKIPIF-- -= 53.1'); ?> = 0) die('skip for ICU < 64.0'); ?> --FILE-- = 4.8 && icu < 51.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU <= 50.1.2'); ?> ---FILE-- - ---EXPECTREGEX-- -locale='uk-ua_CALIFORNIA@currency=;currency=GRN' -disp_locale=en : display_region=Ukraine -disp_locale=fr : display_region=Ukraine -disp_locale=de : display_region=Ukraine ------------------ -locale='root' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='uk@currency=EURO' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='Hindi' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='de' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='fr' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='ja' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='i-enochian' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-Hant' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-Hans' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='sr-Cyrl' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='sr-Latn' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-Hans-CN' -disp_locale=en : display_region=China -disp_locale=fr : display_region=Chine -disp_locale=de : display_region=China ------------------ -locale='sr-Latn-CS' -disp_locale=en : display_region=Serbia [Aa]nd Montenegro -disp_locale=fr : display_region=Serbie-et-Monténégro -disp_locale=de : display_region=Serbien und Montenegro ------------------ -locale='sl-rozaj' -disp_locale=en : display_region=(ROZAJ)? -disp_locale=fr : display_region=(ROZAJ)? -disp_locale=de : display_region=(ROZAJ)? ------------------ -locale='sl-nedis' -disp_locale=en : display_region=(NEDIS)? -disp_locale=fr : display_region=(NEDIS)? -disp_locale=de : display_region=(NEDIS)? ------------------ -locale='de-CH-1901' -disp_locale=en : display_region=Switzerland -disp_locale=fr : display_region=Suisse -disp_locale=de : display_region=Schweiz ------------------ -locale='sl-IT-nedis' -disp_locale=en : display_region=Italy -disp_locale=fr : display_region=Italie -disp_locale=de : display_region=Italien ------------------ -locale='sl-Latn-IT-nedis' -disp_locale=en : display_region=Italy -disp_locale=fr : display_region=Italie -disp_locale=de : display_region=Italien ------------------ -locale='de-DE' -disp_locale=en : display_region=Germany -disp_locale=fr : display_region=Allemagne -disp_locale=de : display_region=Deutschland ------------------ -locale='en-US' -disp_locale=en : display_region=United States -disp_locale=fr : display_region=États-Unis -disp_locale=de : display_region=Vereinigte Staaten ------------------ -locale='es-419' -disp_locale=en : display_region=Latin America -disp_locale=fr : display_region=Amérique latine -disp_locale=de : display_region=Lateinamerika ------------------ -locale='de-CH-x-phonebk' -disp_locale=en : display_region=Switzerland -disp_locale=fr : display_region=Suisse -disp_locale=de : display_region=Schweiz ------------------ -locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_region=X? -disp_locale=fr : display_region=X? -disp_locale=de : display_region=X? ------------------ -locale='zh-min' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-min-nan-Hant-CN' -disp_locale=en : display_region=MIN -disp_locale=fr : display_region=MIN -disp_locale=de : display_region=MIN ------------------ -locale='x-whatever' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='qaa-Qaaa-QM-x-southern' -disp_locale=en : display_region=QM -disp_locale=fr : display_region=QM -disp_locale=de : display_region=QM ------------------ -locale='sr-Latn-QM' -disp_locale=en : display_region=QM -disp_locale=fr : display_region=QM -disp_locale=de : display_region=QM ------------------ -locale='sr-Qaaa-CS' -disp_locale=en : display_region=Serbia [Aa]nd Montenegro -disp_locale=fr : display_region=Serbie-et-Monténégro -disp_locale=de : display_region=Serbien und Montenegro ------------------ -locale='en-US-u-islamCal' -disp_locale=en : display_region=United States -disp_locale=fr : display_region=États-Unis -disp_locale=de : display_region=Vereinigte Staaten ------------------ -locale='zh-CN-a-myExt-x-private' -disp_locale=en : display_region=China -disp_locale=fr : display_region=Chine -disp_locale=de : display_region=China ------------------ -locale='en-a-myExt-b-another' -disp_locale=en : display_region=A? -disp_locale=fr : display_region=A? -disp_locale=de : display_region=A? ------------------ -locale='de-419-DE' -disp_locale=en : display_region=Latin America -disp_locale=fr : display_region=Amérique latine -disp_locale=de : display_region=Lateinamerika ------------------ -locale='a-DE' -disp_locale=en : display_region=Germany -disp_locale=fr : display_region=Allemagne -disp_locale=de : display_region=Deutschland ------------------ -locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_region=A? -disp_locale=fr : display_region=A? -disp_locale=de : display_region=A? ------------------ diff --git a/ext/intl/tests/locale_get_display_region3.phpt b/ext/intl/tests/locale_get_display_region3.phpt deleted file mode 100644 index 56f19e0aafd84..0000000000000 --- a/ext/intl/tests/locale_get_display_region3.phpt +++ /dev/null @@ -1,276 +0,0 @@ ---TEST-- -locale_get_display_region() icu >= 51.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 51.2'); ?> ---FILE-- - ---EXPECTREGEX-- -locale='uk-ua_CALIFORNIA@currency=;currency=GRN' -disp_locale=en : display_region=Ukraine -disp_locale=fr : display_region=Ukraine -disp_locale=de : display_region=Ukraine ------------------ -locale='root' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='uk@currency=EURO' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='Hindi' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='de' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='fr' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='ja' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='i-enochian' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-Hant' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-Hans' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='sr-Cyrl' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='sr-Latn' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-Hans-CN' -disp_locale=en : display_region=China -disp_locale=fr : display_region=Chine -disp_locale=de : display_region=China ------------------ -locale='sr-Latn-CS' -disp_locale=en : display_region=Serbia -disp_locale=fr : display_region=Serbie -disp_locale=de : display_region=Serbien ------------------ -locale='sl-rozaj' -disp_locale=en : display_region=(ROZAJ)? -disp_locale=fr : display_region=(ROZAJ)? -disp_locale=de : display_region=(ROZAJ)? ------------------ -locale='sl-nedis' -disp_locale=en : display_region=(NEDIS)? -disp_locale=fr : display_region=(NEDIS)? -disp_locale=de : display_region=(NEDIS)? ------------------ -locale='de-CH-1901' -disp_locale=en : display_region=Switzerland -disp_locale=fr : display_region=Suisse -disp_locale=de : display_region=Schweiz ------------------ -locale='sl-IT-nedis' -disp_locale=en : display_region=Italy -disp_locale=fr : display_region=Italie -disp_locale=de : display_region=Italien ------------------ -locale='sl-Latn-IT-nedis' -disp_locale=en : display_region=Italy -disp_locale=fr : display_region=Italie -disp_locale=de : display_region=Italien ------------------ -locale='de-DE' -disp_locale=en : display_region=Germany -disp_locale=fr : display_region=Allemagne -disp_locale=de : display_region=Deutschland ------------------ -locale='en-US' -disp_locale=en : display_region=United States -disp_locale=fr : display_region=États-Unis -disp_locale=de : display_region=Vereinigte Staaten ------------------ -locale='es-419' -disp_locale=en : display_region=Latin America -disp_locale=fr : display_region=Amérique latine -disp_locale=de : display_region=Lateinamerika ------------------ -locale='de-CH-x-phonebk' -disp_locale=en : display_region=Switzerland -disp_locale=fr : display_region=Suisse -disp_locale=de : display_region=Schweiz ------------------ -locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_region=X? -disp_locale=fr : display_region=X? -disp_locale=de : display_region=X? ------------------ -locale='zh-min' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='zh-min-nan-Hant-CN' -disp_locale=en : display_region=MIN -disp_locale=fr : display_region=MIN -disp_locale=de : display_region=MIN ------------------ -locale='x-whatever' -disp_locale=en : display_region= -disp_locale=fr : display_region= -disp_locale=de : display_region= ------------------ -locale='qaa-Qaaa-QM-x-southern' -disp_locale=en : display_region=QM -disp_locale=fr : display_region=QM -disp_locale=de : display_region=QM ------------------ -locale='sr-Latn-QM' -disp_locale=en : display_region=QM -disp_locale=fr : display_region=QM -disp_locale=de : display_region=QM ------------------ -locale='sr-Qaaa-CS' -disp_locale=en : display_region=Serbia -disp_locale=fr : display_region=Serbie -disp_locale=de : display_region=Serbien ------------------ -locale='en-US-u-islamCal' -disp_locale=en : display_region=United States -disp_locale=fr : display_region=États-Unis -disp_locale=de : display_region=Vereinigte Staaten ------------------ -locale='zh-CN-a-myExt-x-private' -disp_locale=en : display_region=China -disp_locale=fr : display_region=Chine -disp_locale=de : display_region=China ------------------ -locale='en-a-myExt-b-another' -disp_locale=en : display_region=A? -disp_locale=fr : display_region=A? -disp_locale=de : display_region=A? ------------------ -locale='de-419-DE' -disp_locale=en : display_region=Latin America -disp_locale=fr : display_region=Amérique latine -disp_locale=de : display_region=Lateinamerika ------------------ -locale='a-DE' -disp_locale=en : display_region=Germany -disp_locale=fr : display_region=Allemagne -disp_locale=de : display_region=Deutschland ------------------ -locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_region=A? -disp_locale=fr : display_region=A? -disp_locale=de : display_region=A? ------------------ diff --git a/ext/intl/tests/locale_get_display_script3.phpt b/ext/intl/tests/locale_get_display_script3.phpt deleted file mode 100644 index 1016a171569ad..0000000000000 --- a/ext/intl/tests/locale_get_display_script3.phpt +++ /dev/null @@ -1,276 +0,0 @@ ---TEST-- -locale_get_display_script() icu >= 49 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 52.1'); ?> ---FILE-- - ---EXPECT-- -locale='uk-ua_CALIFORNIA@currency=;currency=GRN' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='root' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='uk@currency=EURO' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='Hindi' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='de' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='fr' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='ja' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='i-enochian' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='zh-Hant' -disp_locale=en : display_script=Traditional Han -disp_locale=fr : display_script=chinois traditionnel -disp_locale=de : display_script=Traditionelles Chinesisch ------------------ -locale='zh-Hans' -disp_locale=en : display_script=Simplified Han -disp_locale=fr : display_script=chinois simplifié -disp_locale=de : display_script=Vereinfachtes Chinesisch ------------------ -locale='sr-Cyrl' -disp_locale=en : display_script=Cyrillic -disp_locale=fr : display_script=cyrillique -disp_locale=de : display_script=Kyrillisch ------------------ -locale='sr-Latn' -disp_locale=en : display_script=Latin -disp_locale=fr : display_script=latin -disp_locale=de : display_script=Lateinisch ------------------ -locale='zh-Hans-CN' -disp_locale=en : display_script=Simplified Han -disp_locale=fr : display_script=chinois simplifié -disp_locale=de : display_script=Vereinfachtes Chinesisch ------------------ -locale='sr-Latn-CS' -disp_locale=en : display_script=Latin -disp_locale=fr : display_script=latin -disp_locale=de : display_script=Lateinisch ------------------ -locale='sl-rozaj' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='sl-nedis' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='de-CH-1901' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='sl-IT-nedis' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='sl-Latn-IT-nedis' -disp_locale=en : display_script=Latin -disp_locale=fr : display_script=latin -disp_locale=de : display_script=Lateinisch ------------------ -locale='de-DE' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='en-US' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='es-419' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='de-CH-x-phonebk' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='az-Arab-x-AZE-derbend' -disp_locale=en : display_script=Arabic -disp_locale=fr : display_script=arabe -disp_locale=de : display_script=Arabisch ------------------ -locale='zh-min' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='zh-min-nan-Hant-CN' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='x-whatever' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='qaa-Qaaa-QM-x-southern' -disp_locale=en : display_script=Qaaa -disp_locale=fr : display_script=Qaaa -disp_locale=de : display_script=Qaaa ------------------ -locale='sr-Latn-QM' -disp_locale=en : display_script=Latin -disp_locale=fr : display_script=latin -disp_locale=de : display_script=Lateinisch ------------------ -locale='sr-Qaaa-CS' -disp_locale=en : display_script=Qaaa -disp_locale=fr : display_script=Qaaa -disp_locale=de : display_script=Qaaa ------------------ -locale='en-US-u-islamCal' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='zh-CN-a-myExt-x-private' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='en-a-myExt-b-another' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='de-419-DE' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='a-DE' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ -locale='ar-a-aaa-b-bbb-a-ccc' -disp_locale=en : display_script= -disp_locale=fr : display_script= -disp_locale=de : display_script= ------------------ diff --git a/ext/intl/tests/locale_get_display_script4.phpt b/ext/intl/tests/locale_get_display_script4.phpt index cf1e5b0cd5c67..77c630393c88a 100644 --- a/ext/intl/tests/locale_get_display_script4.phpt +++ b/ext/intl/tests/locale_get_display_script4.phpt @@ -2,8 +2,6 @@ locale_get_display_script() icu >= 52.1 --EXTENSIONS-- intl ---SKIPIF-- -= 52.1'; ?> --FILE-- = 4.8 && icu < 50.1.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- - ---EXPECT-- --------------- -loc_range:de-de -lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2 - -lookup result:de-DE -Canonical lookup result:de_de --------------- -loc_range:sl_IT -lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2 - -lookup result:sl_IT -Canonical lookup result:sl_it --------------- -loc_range:sl_IT_Nedis -lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2 - -lookup result:sl_IT -Canonical lookup result:sl_it --------------- -loc_range:jbo -lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2 - -lookup result:jbo -Canonical lookup result:jbo --------------- -loc_range:art-lojban -lang_tags: de-DEVA,de-DE-1996,de-DE,zh_Hans,de-CH-1996,sl_IT,sl_IT_nedis-a-kirti-x-xyz,sl_IT_rozaj,sl_IT_NEDIS_ROJAZ_1901,i-enochian,sgn-CH-de,art-lojban,i-lux,art-lojban,jbo,en_sl_IT,zh-Hant-CN-x-prv1-prv2 - -lookup result:art-lojban -Canonical lookup result:jbo diff --git a/ext/intl/tests/msgfmt_format_intlcalendar.phpt b/ext/intl/tests/msgfmt_format_intlcalendar.phpt deleted file mode 100644 index 26ae9925fe33e..0000000000000 --- a/ext/intl/tests/msgfmt_format_intlcalendar.phpt +++ /dev/null @@ -1,28 +0,0 @@ ---TEST-- -MessageFormat accepts IntlCalendar args icu >= 4.8 && icu < 50.1.2 ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -format(array($cal)), "\n"; - -//NOT FIXED: -/*$msgf = new MessageFormatter('en_US', -'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); - -echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; -*/ - -?> ---EXPECT-- -Quinta-feira, 17 de Maio de 2012 5:35:36 p.m. WEST diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt deleted file mode 100644 index 3747ab6913184..0000000000000 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant2.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -MessageFormat accepts IntlCalendar args ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU >= 51.2 and < 52.1'); ?> ---FILE-- -format(array($cal)), "\n"; - -//NOT FIXED: -/*$msgf = new MessageFormatter('en_US', -'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); - -echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; -*/ - -?> ---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 PM ptlis diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt deleted file mode 100644 index fcb841b113691..0000000000000 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant3.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -MessageFormat accepts IntlCalendar args ---EXTENSIONS-- -intl ---SKIPIF-- -= 52.1'); ?> -= 0) die('skip for ICU < 54.1'); ?> ---FILE-- -format(array($cal)), "\n"; - -//NOT FIXED: -/*$msgf = new MessageFormatter('en_US', -'{1, select, date {{0,date,full}} other {{0,time,h:m:s a V}}}'); - -echo "msgf2: ", $msgf->format(array($time, 'date')), " ", - $msgf->format(array($time, 'time')), "\n"; -*/ - -?> ---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 diff --git a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt index e14d30337b775..0b8e607ad2db1 100644 --- a/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt +++ b/ext/intl/tests/msgfmt_format_intlcalendar_variant4.phpt @@ -4,7 +4,6 @@ MessageFormat accepts IntlCalendar args intl --SKIPIF-- = 54.1'); if (str_contains(PHP_OS, 'FreeBSD')) { die('xfail Fails on FreeBSD for unknown reason'); } diff --git a/ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt b/ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt index de154d6d2150f..27801bff3b3b2 100644 --- a/ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt +++ b/ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt @@ -3,7 +3,7 @@ IntlRuleBasedBreakIterator::getBinaryRules(): basic test icu >= 61.1 && icu < 68 --EXTENSIONS-- intl --SKIPIF-- -= 61.1 only'; ?> += 61.1'; ?> = 0) die('skip for ICU < 68.1'); ?> --FILE-- = 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0); -var_dump($c); - -ini_set('intl.default_locale', 'pt_PT'); -$r = new ResourceBundle(NULL, NULL); -$c = $r->get('calendar')->get('gregorian')->get('DateTimePatterns')->get(0); -var_dump($c); -?> ---EXPECT-- -string(14) "h:mm:ss a zzzz" -string(12) "H:mm:ss zzzz" diff --git a/ext/intl/tests/resourcebundle_null_mandatory_args_variant2.phpt b/ext/intl/tests/resourcebundle_null_mandatory_args_variant2.phpt index 5aefcf268dff5..9d13be94aed55 100644 --- a/ext/intl/tests/resourcebundle_null_mandatory_args_variant2.phpt +++ b/ext/intl/tests/resourcebundle_null_mandatory_args_variant2.phpt @@ -5,7 +5,6 @@ date.timezone=Atlantic/Azores --EXTENSIONS-- intl --SKIPIF-- -= 51.2'); ?> = 0) die('skip for ICU < 72.1'); ?> --FILE-- -= 0)die('skip for ICU <= 57.1'); ?> ---FILE-- -isSuspicious($url)); - -echo "certain all-uppercase Latin sequences can be spoof of Greek\n"; -var_dump($x->isSuspicious("NAPKIN PEZ")); -var_dump($x->isSuspicious("napkin pez")); -?> ---EXPECT-- -paypal with Cyrillic spoof characters -bool(true) -certain all-uppercase Latin sequences can be spoof of Greek -bool(true) -bool(false) diff --git a/ext/intl/tests/spoofchecker_004.phpt b/ext/intl/tests/spoofchecker_004.phpt deleted file mode 100644 index ab23722cf28f6..0000000000000 --- a/ext/intl/tests/spoofchecker_004.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -spoofchecker with settings changed ---EXTENSIONS-- -intl ---SKIPIF-- - -= 0) die('skip for ICU < 55.1'); ?> ---FILE-- -areConfusable("HELLO", "H\xD0\x95LLO")); -var_dump($x->areConfusable("hello", "h\xD0\xB5llo")); - -echo "Change confusable settings\n"; -$x->setChecks(Spoofchecker::MIXED_SCRIPT_CONFUSABLE | - Spoofchecker::WHOLE_SCRIPT_CONFUSABLE | - Spoofchecker::SINGLE_SCRIPT_CONFUSABLE); -var_dump($x->areConfusable("HELLO", "H\xD0\x95LLO")); -var_dump($x->areConfusable("hello", "h\xD0\xB5llo")); -?> ---EXPECT-- -Check with default settings -bool(true) -bool(true) -Change confusable settings -bool(false) -bool(true) diff --git a/ext/intl/tests/spoofchecker_005.phpt b/ext/intl/tests/spoofchecker_005.phpt index a94770c89ccb0..9fc6628e6ae41 100644 --- a/ext/intl/tests/spoofchecker_005.phpt +++ b/ext/intl/tests/spoofchecker_005.phpt @@ -4,7 +4,6 @@ spoofchecker with settings changed intl --SKIPIF-- -= 55.1'); ?> --FILE-- -= 58.1'); ?> --FILE-- = 52'); ?> -= 0) die('skip for ICU <= 57.1'); ?> += 0) die('skip for ICU < 58.1'); ?> --FILE-- = 58.1'); ?> += 0) die('skip for ICU <= 76.1'); ?> --FILE-- = 76.1'); ?> +--FILE-- + array(NULL), + 'India Standard Time' => array(NULL), + 'Pacific Standard Time' => array('001', 'CA', 'MX', 'US', 'ZZ'), + 'Romance Standard Time' => array('001', 'BE', 'DK', 'ES', 'FR'), +); + +foreach ($tzs as $tz => $regions) { + echo "** $tz\n"; + foreach ($regions as $region) { + var_dump(IntlTimeZone::getIDForWindowsID($tz, $region)); + if (intl_get_error_code() != U_ZERO_ERROR) { + echo "Error: ", intl_get_error_message(), "\n"; + } + } +} +?> +--EXPECTF-- +** Gnomeregan +bool(false) +Error: %snknown windows timezone: U_ILLEGAL_ARGUMENT_ERROR +** India Standard Time +string(13) "Asia/Calcutta" +** Pacific Standard Time +string(19) "America/Los_Angeles" +string(17) "America/Vancouver" +string(19) "America/Los_Angeles" +string(19) "America/Los_Angeles" +string(19) "America/Los_Angeles" +** Romance Standard Time +string(12) "Europe/Paris" +string(15) "Europe/Brussels" +string(17) "Europe/Copenhagen" +string(13) "Europe/Madrid" +string(12) "Europe/Paris" diff --git a/ext/intl/tests/timezone_getCanonicalID_variant1.phpt b/ext/intl/tests/timezone_getCanonicalID_variant1.phpt deleted file mode 100644 index 198a62cfa9a42..0000000000000 --- a/ext/intl/tests/timezone_getCanonicalID_variant1.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -IntlTimeZone::getCanonicalID(): second argument ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 53.1'); ?> ---FILE-- - ---EXPECT-- -string(13) "Europe/Lisbon" -bool(true) -string(0) "" -bool(false) diff --git a/ext/intl/tests/timezone_getCanonicalID_variant1_2.phpt b/ext/intl/tests/timezone_getCanonicalID_variant1_2.phpt index fe3464b276a16..3fedf4377197a 100644 --- a/ext/intl/tests/timezone_getCanonicalID_variant1_2.phpt +++ b/ext/intl/tests/timezone_getCanonicalID_variant1_2.phpt @@ -2,8 +2,6 @@ IntlTimeZone::getCanonicalID(): second argument --EXTENSIONS-- intl ---SKIPIF-- -= 53.1'); ?> --FILE-- = 49 && ICU < 50.1.2) ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 50.1.2'); ?> ---FILE-- -getDisplayName(false, IntlTimeZone::DISPLAY_SHORT)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GENERIC)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GENERIC)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_GMT)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG_GMT)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_SHORT_COMMONLY_USED)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_GENERIC_LOCATION)); - -?> ---EXPECT-- -string(3) "GMT" -string(30) "Western European Standard Time" -string(22) "Portugal Time (Lisbon)" -string(21) "Western European Time" -string(5) "+0000" -string(3) "GMT" -string(3) "GMT" -string(22) "Portugal Time (Lisbon)" diff --git a/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt b/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt deleted file mode 100644 index ed0a5c743c477..0000000000000 --- a/ext/intl/tests/timezone_getDisplayName_variant3-49+.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -IntlTimeZone::getDisplayName(): locale parameter ---EXTENSIONS-- -intl ---SKIPIF-- -= 0) die('skip for ICU < 55.1'); ?> ---FILE-- -getDisplayName(false, IntlTimeZone::DISPLAY_LONG)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, NULL)); -var_dump($lsb->getDisplayName(false, IntlTimeZone::DISPLAY_LONG, 'pt_PT')); - -?> ---EXPECTF-- -string(30) "Western European Standard Time" -string(30) "Western European Standard Time" -string(32) "Hora %cadrão da Europa Ocidental" diff --git a/ext/intl/tests/timezone_getDisplayName_variant4.phpt b/ext/intl/tests/timezone_getDisplayName_variant4.phpt index 4bab07c744fa9..eccf6c78d2ca4 100644 --- a/ext/intl/tests/timezone_getDisplayName_variant4.phpt +++ b/ext/intl/tests/timezone_getDisplayName_variant4.phpt @@ -2,8 +2,6 @@ IntlTimeZone::getDisplayName(): type parameter (ICU >= 51.2) --EXTENSIONS-- intl ---SKIPIF-- -= 51.2'); ?> --FILE-- = 52'); ?> -= 0) die('skip for ICU <= 57.1'); ?> += 0) die('skip for ICU < 58.1'); ?> --FILE-- = 0) die('skip for ICU <= 57.1'); ?> += 0) die('skip for ICU < 58.1'); ?> --FILE-- = 52 /** * @tentative-return-type * @alias intltz_get_windows_id @@ -169,7 +168,7 @@ public static function getWindowsID(string $timezoneId): string|false {} * @alias intltz_get_id_for_windows_id */ public static function getIDForWindowsID(string $timezoneId, ?string $region = null): string|false {} -#endif + /** * @tentative-return-type * @alias intltz_has_same_rules diff --git a/ext/intl/timezone/timezone_arginfo.h b/ext/intl/timezone/timezone_arginfo.h index fb467a2d4ae47..6206e03efad3e 100644 --- a/ext/intl/timezone/timezone_arginfo.h +++ b/ext/intl/timezone/timezone_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ff6d6bb0789c719625f4271bf9ce1c12eea5c95e */ + * Stub hash: 6ffeea8491aa48c49879fa77bdb644d10d5c71bd */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlTimeZone___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -81,16 +81,12 @@ ZEND_END_ARG_INFO() #define arginfo_class_IntlTimeZone_getUnknown arginfo_class_IntlTimeZone_createDefault -#if U_ICU_VERSION_MAJOR_NUM >= 52 -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_IntlTimeZone_getWindowsID, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, timezoneId, IS_STRING, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_IntlTimeZone_getWindowsID arginfo_class_IntlTimeZone_getRegion ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_IntlTimeZone_getIDForWindowsID, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, timezoneId, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, region, IS_STRING, 1, "null") ZEND_END_ARG_INFO() -#endif ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_IntlTimeZone_hasSameRules, 0, 1, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, other, IntlTimeZone, 0) @@ -125,10 +121,8 @@ ZEND_FUNCTION(intltz_get_raw_offset); ZEND_FUNCTION(intltz_get_region); ZEND_FUNCTION(intltz_get_tz_data_version); ZEND_FUNCTION(intltz_get_unknown); -#if U_ICU_VERSION_MAJOR_NUM >= 52 ZEND_FUNCTION(intltz_get_windows_id); ZEND_FUNCTION(intltz_get_id_for_windows_id); -#endif ZEND_FUNCTION(intltz_has_same_rules); ZEND_FUNCTION(intltz_to_date_time_zone); ZEND_FUNCTION(intltz_use_daylight_time); @@ -157,10 +151,8 @@ static const zend_function_entry class_IntlTimeZone_methods[] = { ZEND_RAW_FENTRY("getRegion", zif_intltz_get_region, arginfo_class_IntlTimeZone_getRegion, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) ZEND_RAW_FENTRY("getTZDataVersion", zif_intltz_get_tz_data_version, arginfo_class_IntlTimeZone_getTZDataVersion, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) ZEND_RAW_FENTRY("getUnknown", zif_intltz_get_unknown, arginfo_class_IntlTimeZone_getUnknown, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) -#if U_ICU_VERSION_MAJOR_NUM >= 52 ZEND_RAW_FENTRY("getWindowsID", zif_intltz_get_windows_id, arginfo_class_IntlTimeZone_getWindowsID, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) ZEND_RAW_FENTRY("getIDForWindowsID", zif_intltz_get_id_for_windows_id, arginfo_class_IntlTimeZone_getIDForWindowsID, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC, NULL, NULL) -#endif ZEND_RAW_FENTRY("hasSameRules", zif_intltz_has_same_rules, arginfo_class_IntlTimeZone_hasSameRules, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("toDateTimeZone", zif_intltz_to_date_time_zone, arginfo_class_IntlTimeZone_toDateTimeZone, ZEND_ACC_PUBLIC, NULL, NULL) ZEND_RAW_FENTRY("useDaylightTime", zif_intltz_use_daylight_time, arginfo_class_IntlTimeZone_useDaylightTime, ZEND_ACC_PUBLIC, NULL, NULL) diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index ebde6578a990a..21f847819a9c7 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -618,7 +618,6 @@ U_CFUNC PHP_FUNCTION(intltz_get_error_message) RETURN_STR(message); } -#if U_ICU_VERSION_MAJOR_NUM >= 52 /* {{{ Translate a system timezone (e.g. "America/Los_Angeles" into a Windows Timezone (e.g. "Pacific Standard Time") */ @@ -692,4 +691,3 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id) RETURN_STR(id); } /* }}} */ -#endif diff --git a/ext/intl/uchar/uchar.c b/ext/intl/uchar/uchar.c index 4d3d424df798e..ecfcd8fbe624a 100644 --- a/ext/intl/uchar/uchar.c +++ b/ext/intl/uchar/uchar.c @@ -616,9 +616,7 @@ IC_CHAR_METHOD_CHAR(charMirror) IC_CHAR_METHOD_CHAR(tolower) IC_CHAR_METHOD_CHAR(toupper) IC_CHAR_METHOD_CHAR(totitle) -#if U_ICU_VERSION_MAJOR_NUM >= 52 IC_CHAR_METHOD_CHAR(getBidiPairedBracket) -#endif /* ICU >= 52 */ #undef IC_CHAR_METHOD_CHAR /* }}} */ diff --git a/ext/intl/uchar/uchar.stub.php b/ext/intl/uchar/uchar.stub.php index baaf2bea99a76..aa81a9cab3081 100644 --- a/ext/intl/uchar/uchar.stub.php +++ b/ext/intl/uchar/uchar.stub.php @@ -183,10 +183,8 @@ class IntlChar public const int PROPERTY_SENTENCE_BREAK = UNKNOWN; /** @cvalue UCHAR_WORD_BREAK */ public const int PROPERTY_WORD_BREAK = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 52 /** @cvalue UCHAR_BIDI_PAIRED_BRACKET_TYPE */ public const int PROPERTY_BIDI_PAIRED_BRACKET_TYPE = UNKNOWN; -#endif /** @cvalue UCHAR_INT_LIMIT */ public const int PROPERTY_INT_LIMIT = UNKNOWN; /** @cvalue UCHAR_GENERAL_CATEGORY_MASK */ @@ -229,10 +227,8 @@ class IntlChar public const int PROPERTY_UNICODE_1_NAME = UNKNOWN; /** @cvalue UCHAR_UPPERCASE_MAPPING */ public const int PROPERTY_UPPERCASE_MAPPING = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 52 /** @cvalue UCHAR_BIDI_PAIRED_BRACKET */ public const int PROPERTY_BIDI_PAIRED_BRACKET = UNKNOWN; -#endif /** @cvalue UCHAR_STRING_LIMIT */ public const int PROPERTY_STRING_LIMIT = UNKNOWN; /** @cvalue UCHAR_SCRIPT_EXTENSIONS */ @@ -347,7 +343,6 @@ class IntlChar public const int CHAR_DIRECTION_DIR_NON_SPACING_MARK = UNKNOWN; /** @cvalue U_BOUNDARY_NEUTRAL */ public const int CHAR_DIRECTION_BOUNDARY_NEUTRAL = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 52 /** @cvalue U_FIRST_STRONG_ISOLATE */ public const int CHAR_DIRECTION_FIRST_STRONG_ISOLATE = UNKNOWN; /** @cvalue U_LEFT_TO_RIGHT_ISOLATE */ @@ -356,7 +351,6 @@ class IntlChar public const int CHAR_DIRECTION_RIGHT_TO_LEFT_ISOLATE = UNKNOWN; /** @cvalue U_POP_DIRECTIONAL_ISOLATE */ public const int CHAR_DIRECTION_POP_DIRECTIONAL_ISOLATE = UNKNOWN; -#endif /** @cvalue U_CHAR_DIRECTION_COUNT */ public const int CHAR_DIRECTION_CHAR_DIRECTION_COUNT = UNKNOWN; @@ -806,7 +800,6 @@ class IntlChar public const int BLOCK_CODE_SUNDANESE_SUPPLEMENT = UNKNOWN; /** @cvalue UBLOCK_TAKRI */ public const int BLOCK_CODE_TAKRI = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 54 /** @cvalue UBLOCK_BASSA_VAH */ public const int BLOCK_CODE_BASSA_VAH = UNKNOWN; /** @cvalue UBLOCK_CAUCASIAN_ALBANIAN */ @@ -871,7 +864,6 @@ class IntlChar public const int BLOCK_CODE_TIRHUTA = UNKNOWN; /** @cvalue UBLOCK_WARANG_CITI */ public const int BLOCK_CODE_WARANG_CITI = UNKNOWN; -#endif /** @cvalue UBLOCK_COUNT */ public const int BLOCK_CODE_COUNT = UNKNOWN; /** @cvalue UBLOCK_INVALID_CODE */ @@ -879,7 +871,6 @@ class IntlChar /* UBidiPairedBracketType - http://icu-project.org/apiref/icu4c/uchar_8h.html#af954219aa1df452657ec355221c6703d */ -#if U_ICU_VERSION_MAJOR_NUM >= 52 /** @cvalue U_BPT_NONE */ public const int BPT_NONE = UNKNOWN; /** @cvalue U_BPT_OPEN */ @@ -888,7 +879,6 @@ class IntlChar public const int BPT_CLOSE = UNKNOWN; /** @cvalue U_BPT_COUNT */ public const int BPT_COUNT = UNKNOWN; -#endif /* UEastAsianWidth - http://icu-project.org/apiref/icu4c/uchar_8h.html#a95cc2ca2f9cfd6d0c63eee2c65951333 */ @@ -1107,7 +1097,6 @@ class IntlChar public const int JG_NYA = UNKNOWN; /** @cvalue U_JG_ROHINGYA_YEH */ public const int JG_ROHINGYA_YEH = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 54 /** @cvalue U_JG_MANICHAEAN_ALEPH */ public const int JG_MANICHAEAN_ALEPH = UNKNOWN; /** @cvalue U_JG_MANICHAEAN_AYIN */ @@ -1164,7 +1153,6 @@ class IntlChar public const int JG_MANICHAEAN_ZAYIN = UNKNOWN; /** @cvalue U_JG_STRAIGHT_WAW */ public const int JG_STRAIGHT_WAW = UNKNOWN; -#endif /** @cvalue U_JG_COUNT */ public const int JG_COUNT = UNKNOWN; @@ -1229,14 +1217,12 @@ class IntlChar public const int WB_NEWLINE = UNKNOWN; /** @cvalue U_WB_REGIONAL_INDICATOR */ public const int WB_REGIONAL_INDICATOR = UNKNOWN; -#if U_ICU_VERSION_MAJOR_NUM >= 52 /** @cvalue U_WB_HEBREW_LETTER */ public const int WB_HEBREW_LETTER = UNKNOWN; /** @cvalue U_WB_SINGLE_QUOTE */ public const int WB_SINGLE_QUOTE = UNKNOWN; /** @cvalue U_WB_DOUBLE_QUOTE */ public const int WB_DOUBLE_QUOTE = UNKNOWN; -#endif /** @cvalue U_WB_COUNT */ public const int WB_COUNT = UNKNOWN; @@ -1441,10 +1427,8 @@ public static function foldCase(int|string $codepoint, int $options = IntlChar:: /** @tentative-return-type */ public static function forDigit(int $digit, int $base = 10): int {} -#if U_ICU_VERSION_MAJOR_NUM >= 52 /** @tentative-return-type */ public static function getBidiPairedBracket(int|string $codepoint): int|string|null {} -#endif /** @tentative-return-type */ public static function getBlockCode(int|string $codepoint): ?int {} diff --git a/ext/intl/uchar/uchar_arginfo.h b/ext/intl/uchar/uchar_arginfo.h index ea70f17658867..085b3b0a5eff3 100644 --- a/ext/intl/uchar/uchar_arginfo.h +++ b/ext/intl/uchar/uchar_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f0c67026b921d853e745fcc5d980bdb86f475c80 */ + * Stub hash: 58fb5f326ee08cca73977720d3b055b0118d78bb */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_IntlChar_hasBinaryProperty, 0, 2, _IS_BOOL, 1) ZEND_ARG_TYPE_MASK(0, codepoint, MAY_BE_LONG|MAY_BE_STRING, NULL) @@ -62,11 +62,7 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_IntlChar_forDigi ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, base, IS_LONG, 0, "10") ZEND_END_ARG_INFO() -#if U_ICU_VERSION_MAJOR_NUM >= 52 -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_IntlChar_getBidiPairedBracket, 0, 1, MAY_BE_LONG|MAY_BE_STRING|MAY_BE_NULL) - ZEND_ARG_TYPE_MASK(0, codepoint, MAY_BE_LONG|MAY_BE_STRING, NULL) -ZEND_END_ARG_INFO() -#endif +#define arginfo_class_IntlChar_getBidiPairedBracket arginfo_class_IntlChar_charMirror #define arginfo_class_IntlChar_getBlockCode arginfo_class_IntlChar_charDigitValue @@ -196,9 +192,7 @@ ZEND_METHOD(IntlChar, enumCharNames); ZEND_METHOD(IntlChar, enumCharTypes); ZEND_METHOD(IntlChar, foldCase); ZEND_METHOD(IntlChar, forDigit); -#if U_ICU_VERSION_MAJOR_NUM >= 52 ZEND_METHOD(IntlChar, getBidiPairedBracket); -#endif ZEND_METHOD(IntlChar, getBlockCode); ZEND_METHOD(IntlChar, getCombiningClass); ZEND_METHOD(IntlChar, getFC_NFKC_Closure); @@ -259,9 +253,7 @@ static const zend_function_entry class_IntlChar_methods[] = { ZEND_ME(IntlChar, enumCharTypes, arginfo_class_IntlChar_enumCharTypes, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ME(IntlChar, foldCase, arginfo_class_IntlChar_foldCase, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ME(IntlChar, forDigit, arginfo_class_IntlChar_forDigit, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) -#if U_ICU_VERSION_MAJOR_NUM >= 52 ZEND_ME(IntlChar, getBidiPairedBracket, arginfo_class_IntlChar_getBidiPairedBracket, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) -#endif ZEND_ME(IntlChar, getBlockCode, arginfo_class_IntlChar_getBlockCode, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ME(IntlChar, getCombiningClass, arginfo_class_IntlChar_getCombiningClass, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) ZEND_ME(IntlChar, getFC_NFKC_Closure, arginfo_class_IntlChar_getFC_NFKC_Closure, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) @@ -850,14 +842,12 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_PROPERTY_WORD_BREAK_name = zend_string_init_interned("PROPERTY_WORD_BREAK", sizeof("PROPERTY_WORD_BREAK") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif zval const_PROPERTY_INT_LIMIT_value; ZVAL_LONG(&const_PROPERTY_INT_LIMIT_value, UCHAR_INT_LIMIT); @@ -984,14 +974,12 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_PROPERTY_UPPERCASE_MAPPING_name = zend_string_init_interned("PROPERTY_UPPERCASE_MAPPING", sizeof("PROPERTY_UPPERCASE_MAPPING") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif zval const_PROPERTY_STRING_LIMIT_value; ZVAL_LONG(&const_PROPERTY_STRING_LIMIT_value, UCHAR_STRING_LIMIT); @@ -1328,38 +1316,30 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_CHAR_DIRECTION_BOUNDARY_NEUTRAL_name = zend_string_init_interned("CHAR_DIRECTION_BOUNDARY_NEUTRAL", sizeof("CHAR_DIRECTION_BOUNDARY_NEUTRAL") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif zval const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_value; ZVAL_LONG(&const_CHAR_DIRECTION_CHAR_DIRECTION_COUNT_value, U_CHAR_DIRECTION_COUNT); @@ -2704,262 +2684,198 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_BLOCK_CODE_TAKRI_name = zend_string_init_interned("BLOCK_CODE_TAKRI", sizeof("BLOCK_CODE_TAKRI") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif zval const_BLOCK_CODE_COUNT_value; ZVAL_LONG(&const_BLOCK_CODE_COUNT_value, UBLOCK_COUNT); @@ -2972,38 +2888,30 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_BLOCK_CODE_INVALID_CODE_name = zend_string_init_interned("BLOCK_CODE_INVALID_CODE", sizeof("BLOCK_CODE_INVALID_CODE") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif zval const_EA_NEUTRAL_value; ZVAL_LONG(&const_EA_NEUTRAL_value, U_EA_NEUTRAL); @@ -3604,230 +3512,174 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_JG_ROHINGYA_YEH_name = zend_string_init_interned("JG_ROHINGYA_YEH", sizeof("JG_ROHINGYA_YEH") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 54 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_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); -#endif zval const_JG_COUNT_value; ZVAL_LONG(&const_JG_COUNT_value, U_JG_COUNT); @@ -4002,30 +3854,24 @@ static zend_class_entry *register_class_IntlChar(void) zend_string *const_WB_REGIONAL_INDICATOR_name = zend_string_init_interned("WB_REGIONAL_INDICATOR", sizeof("WB_REGIONAL_INDICATOR") - 1, 1); 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); -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif -#if U_ICU_VERSION_MAJOR_NUM >= 52 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_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); -#endif zval const_WB_COUNT_value; ZVAL_LONG(&const_WB_COUNT_value, U_WB_COUNT); diff --git a/ext/json/tests/gh15168.phpt b/ext/json/tests/gh15168.phpt index 9b674d6b4ac07..66000e5b90e68 100644 --- a/ext/json/tests/gh15168.phpt +++ b/ext/json/tests/gh15168.phpt @@ -31,6 +31,10 @@ var_dump(json_encode($firstNode, depth: 500000)); var_dump(json_last_error()); var_dump(json_last_error_msg()); +while ($next = $firstNode->next) { + $firstNode->next = $next->next; +} + ?> --EXPECT-- bool(false) diff --git a/ext/ldap/tests/ldap_sasl_bind_error.phpt b/ext/ldap/tests/ldap_sasl_bind_error.phpt index 3c43f77096bc8..f5497c33fecaa 100644 --- a/ext/ldap/tests/ldap_sasl_bind_error.phpt +++ b/ext/ldap/tests/ldap_sasl_bind_error.phpt @@ -5,6 +5,7 @@ Patrick Allaert # Belgian PHP Testfest 2009 --EXTENSIONS-- ldap +--XLEAK-- --SKIPIF-- diff --git a/ext/ldap/tests/ldap_set_rebind_proc_basic.phpt b/ext/ldap/tests/ldap_set_rebind_proc_basic.phpt index 00c7bb81d9dd3..a328912a5e168 100644 --- a/ext/ldap/tests/ldap_set_rebind_proc_basic.phpt +++ b/ext/ldap/tests/ldap_set_rebind_proc_basic.phpt @@ -6,7 +6,10 @@ Patrick Allaert --EXTENSIONS-- ldap --SKIPIF-- - + --FILE-- --EXTENSIONS-- ldap --SKIPIF-- - + --FILE-- = 20904) { diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index a72aad5038de0..d1b06c5802dc1 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -49,11 +49,11 @@ #include "libxml_arginfo.h" /* a true global for initialization */ -static int _php_libxml_initialized = 0; -static int _php_libxml_per_request_initialization = 1; -static xmlExternalEntityLoader _php_libxml_default_entity_loader; +static int php_libxml_initialized = 0; +static int php_libxml_per_request_initialization = 1; +static xmlExternalEntityLoader php_libxml_default_entity_loader; -typedef struct _php_libxml_func_handler { +typedef struct php_libxml_func_handler { php_libxml_export_node export_func; } php_libxml_func_handler; @@ -423,10 +423,11 @@ static void *php_libxml_streams_IO_open_wrapper(const char *filename, const char (xmlStrncmp(BAD_CAST uri->scheme, BAD_CAST "file", 4) == 0))) { resolved_path = xmlURIUnescapeString(filename, 0, NULL); isescaped = 1; -#if LIBXML_VERSION >= 20902 && defined(PHP_WIN32) +#if LIBXML_VERSION >= 20902 && LIBXML_VERSION < 21300 && defined(PHP_WIN32) /* Libxml 2.9.2 prefixes local paths with file:/ instead of file://, thus the php stream wrapper will fail on a valid case. For this - reason the prefix is rather better cut off. */ + reason the prefix is rather better cut off. + As of libxml 2.13.0 this issue is resolved. */ { size_t pre_len = sizeof("file:/") - 1; @@ -600,16 +601,16 @@ php_libxml_output_buffer_create_filename(const char *URI, return(ret); } -static void _php_libxml_free_error(void *ptr) +static void php_libxml_free_error(void *ptr) { /* This will free the libxml alloc'd memory */ xmlResetError((xmlErrorPtr) ptr); } #if LIBXML_VERSION >= 21200 -static void _php_list_set_error_structure(const xmlError *error, const char *msg, int line, int column) +static void php_list_set_error_structure(const xmlError *error, const char *msg, int line, int column) #else -static void _php_list_set_error_structure(xmlError *error, const char *msg, int line, int column) +static void php_list_set_error_structure(xmlError *error, const char *msg, int line, int column) #endif { xmlError error_copy; @@ -654,7 +655,7 @@ static void php_libxml_ctx_error_level(int level, void *ctx, const char *msg, in void php_libxml_issue_error(int level, const char *msg) { if (LIBXML(error_list)) { - _php_list_set_error_structure(NULL, msg, 0, 0); + php_list_set_error_structure(NULL, msg, 0, 0); } else { php_error_docref(NULL, level, "%s", msg); } @@ -680,7 +681,7 @@ static void php_libxml_internal_error_handler_ex(php_libxml_error_level error_ty if (output) { if (LIBXML(error_list)) { - _php_list_set_error_structure(NULL, ZSTR_VAL(LIBXML(error_buffer).s), line, column); + php_list_set_error_structure(NULL, ZSTR_VAL(LIBXML(error_buffer).s), line, column); } else if (!EG(exception)) { /* Don't throw additional notices/warnings if an exception has already been thrown. */ switch (error_type) { @@ -711,7 +712,7 @@ PHP_LIBXML_API void php_libxml_error_handler_va(php_libxml_error_level error_typ php_libxml_internal_error_handler_ex(error_type, ctx, msg, ap, line, column); } -static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL, +static xmlParserInputPtr php_libxml_external_entity_loader(const char *URL, const char *ID, xmlParserCtxtPtr context) { xmlParserInputPtr ret = NULL; @@ -721,7 +722,7 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL, /* no custom user-land callback set up; delegate to original loader */ if (!ZEND_FCC_INITIALIZED(LIBXML(entity_loader_callback))) { - return _php_libxml_default_entity_loader(URL, ID, context); + return php_libxml_default_entity_loader(URL, ID, context); } if (ID != NULL) { @@ -820,7 +821,7 @@ static xmlParserInputPtr _php_libxml_external_entity_loader(const char *URL, return ret; } -static xmlParserInputPtr _php_libxml_pre_ext_ent_loader(const char *URL, +static xmlParserInputPtr php_libxml_pre_ext_ent_loader(const char *URL, const char *ID, xmlParserCtxtPtr context) { @@ -832,11 +833,11 @@ static xmlParserInputPtr _php_libxml_pre_ext_ent_loader(const char *URL, * we don't even have a resource list by then), but then whether one * extension would be using the custom external entity loader or not * could depend on extension loading order - * (if _php_libxml_per_request_initialization */ + * (if php_libxml_per_request_initialization */ if (xmlGenericError == php_libxml_error_handler && PG(modules_activated)) { - return _php_libxml_external_entity_loader(URL, ID, context); + return php_libxml_external_entity_loader(URL, ID, context); } else { - return _php_libxml_default_entity_loader(URL, ID, context); + return php_libxml_default_entity_loader(URL, ID, context); } } @@ -878,7 +879,7 @@ static void php_libxml_structured_error_handler(void *userData, const xmlError * static void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error) #endif { - _php_list_set_error_structure(error, NULL, 0, 0); + php_list_set_error_structure(error, NULL, 0, 0); } PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...) @@ -896,32 +897,32 @@ static void php_libxml_exports_dtor(zval *zv) PHP_LIBXML_API void php_libxml_initialize(void) { - if (!_php_libxml_initialized) { + if (!php_libxml_initialized) { /* we should be the only one's to ever init!! */ ZEND_IGNORE_LEAKS_BEGIN(); xmlInitParser(); ZEND_IGNORE_LEAKS_END(); - _php_libxml_default_entity_loader = xmlGetExternalEntityLoader(); - xmlSetExternalEntityLoader(_php_libxml_pre_ext_ent_loader); + php_libxml_default_entity_loader = xmlGetExternalEntityLoader(); + xmlSetExternalEntityLoader(php_libxml_pre_ext_ent_loader); zend_hash_init(&php_libxml_exports, 0, NULL, php_libxml_exports_dtor, 1); - _php_libxml_initialized = 1; + php_libxml_initialized = 1; } } PHP_LIBXML_API void php_libxml_shutdown(void) { - if (_php_libxml_initialized) { + if (php_libxml_initialized) { #if defined(LIBXML_SCHEMAS_ENABLED) && LIBXML_VERSION < 21000 xmlRelaxNGCleanupTypes(); #endif /* xmlCleanupParser(); */ zend_hash_destroy(&php_libxml_exports); - xmlSetExternalEntityLoader(_php_libxml_default_entity_loader); - _php_libxml_initialized = 0; + xmlSetExternalEntityLoader(php_libxml_default_entity_loader); + php_libxml_initialized = 0; } } @@ -953,13 +954,13 @@ static PHP_MINIT_FUNCTION(libxml) for (sapi_name = supported_sapis; *sapi_name; sapi_name++) { if (strcmp(sapi_module.name, *sapi_name) == 0) { - _php_libxml_per_request_initialization = 0; + php_libxml_per_request_initialization = 0; break; } } } - if (!_php_libxml_per_request_initialization) { + if (!php_libxml_per_request_initialization) { /* report errors via handler rather than stderr */ xmlSetGenericErrorFunc(NULL, php_libxml_error_handler); xmlParserInputBufferCreateFilenameDefault(php_libxml_input_buffer_create_filename); @@ -972,7 +973,7 @@ static PHP_MINIT_FUNCTION(libxml) static PHP_RINIT_FUNCTION(libxml) { - if (_php_libxml_per_request_initialization) { + if (php_libxml_per_request_initialization) { /* report errors via handler rather than stderr */ xmlSetGenericErrorFunc(NULL, php_libxml_error_handler); xmlParserInputBufferCreateFilenameDefault(php_libxml_input_buffer_create_filename); @@ -999,7 +1000,7 @@ static PHP_RSHUTDOWN_FUNCTION(libxml) static PHP_MSHUTDOWN_FUNCTION(libxml) { - if (!_php_libxml_per_request_initialization) { + if (!php_libxml_per_request_initialization) { xmlSetGenericErrorFunc(NULL, NULL); xmlParserInputBufferCreateFilenameDefault(NULL); @@ -1013,7 +1014,7 @@ static PHP_MSHUTDOWN_FUNCTION(libxml) static zend_result php_libxml_post_deactivate(void) { /* reset libxml generic error handling */ - if (_php_libxml_per_request_initialization) { + if (php_libxml_per_request_initialization) { xmlSetGenericErrorFunc(NULL, NULL); xmlParserInputBufferCreateFilenameDefault(NULL); @@ -1096,7 +1097,7 @@ PHP_FUNCTION(libxml_use_internal_errors) xmlSetStructuredErrorFunc(NULL, php_libxml_structured_error_handler); if (LIBXML(error_list) == NULL) { LIBXML(error_list) = (zend_llist *) emalloc(sizeof(zend_llist)); - zend_llist_init(LIBXML(error_list), sizeof(xmlError), _php_libxml_free_error, 0); + zend_llist_init(LIBXML(error_list), sizeof(xmlError), php_libxml_free_error, 0); } } RETURN_BOOL(retval); @@ -1290,9 +1291,9 @@ PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object) return node; } -PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data) +PHP_LIBXML_API unsigned int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data) { - int ret_refcount = -1; + unsigned int ret_refcount = 0; if (object != NULL && node != NULL) { if (object->node != NULL) { @@ -1322,11 +1323,11 @@ PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, return ret_refcount; } -PHP_LIBXML_API int php_libxml_decrement_node_ptr_ref(php_libxml_node_ptr *ptr) +PHP_LIBXML_API unsigned int php_libxml_decrement_node_ptr_ref(php_libxml_node_ptr *ptr) { ZEND_ASSERT(ptr != NULL); - int ret_refcount = --ptr->refcount; + unsigned int ret_refcount = --ptr->refcount; if (ret_refcount == 0) { if (ptr->node != NULL) { ptr->node->_private = NULL; @@ -1340,17 +1341,17 @@ PHP_LIBXML_API int php_libxml_decrement_node_ptr_ref(php_libxml_node_ptr *ptr) return ret_refcount; } -PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object) +PHP_LIBXML_API unsigned int php_libxml_decrement_node_ptr(php_libxml_node_object *object) { if (object != NULL && object->node != NULL) { return php_libxml_decrement_node_ptr_ref(object->node); } - return -1; + return 0; } -PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp) +PHP_LIBXML_API unsigned int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp) { - int ret_refcount = -1; + unsigned int ret_refcount = 0; if (object->document != NULL) { object->document->refcount++; @@ -1371,9 +1372,9 @@ PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, return ret_refcount; } -PHP_LIBXML_API int php_libxml_decrement_doc_ref_directly(php_libxml_ref_obj *document) +PHP_LIBXML_API unsigned int php_libxml_decrement_doc_ref_directly(php_libxml_ref_obj *document) { - int ret_refcount = --document->refcount; + unsigned int ret_refcount = --document->refcount; if (ret_refcount == 0) { if (document->private_data != NULL) { document->private_data->dtor(document->private_data); @@ -1394,9 +1395,9 @@ PHP_LIBXML_API int php_libxml_decrement_doc_ref_directly(php_libxml_ref_obj *doc return ret_refcount; } -PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object) +PHP_LIBXML_API unsigned int php_libxml_decrement_doc_ref(php_libxml_node_object *object) { - int ret_refcount = -1; + unsigned int ret_refcount = 0; if (object != NULL && object->document != NULL) { ret_refcount = php_libxml_decrement_doc_ref_directly(object->document); @@ -1444,7 +1445,7 @@ PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *o if (object != NULL && object->node != NULL) { php_libxml_node_ptr *obj_node = (php_libxml_node_ptr *) object->node; xmlNodePtr nodep = obj_node->node; - int ret_refcount = php_libxml_decrement_node_ptr(object); + unsigned int ret_refcount = php_libxml_decrement_node_ptr(object); if (ret_refcount == 0) { php_libxml_node_free_resource(nodep); } else { diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h index 4bf260c3efb03..3314bf6a7b28c 100644 --- a/ext/libxml/php_libxml.h +++ b/ext/libxml/php_libxml.h @@ -189,12 +189,12 @@ typedef enum { PHP_LIBXML_CTX_WARNING = 2, } php_libxml_error_level; -PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data); -PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object); -PHP_LIBXML_API int php_libxml_decrement_node_ptr_ref(php_libxml_node_ptr *ptr); -PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp); -PHP_LIBXML_API int php_libxml_decrement_doc_ref_directly(php_libxml_ref_obj *document); -PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object); +PHP_LIBXML_API unsigned int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data); +PHP_LIBXML_API unsigned int php_libxml_decrement_node_ptr(php_libxml_node_object *object); +PHP_LIBXML_API unsigned int php_libxml_decrement_node_ptr_ref(php_libxml_node_ptr *ptr); +PHP_LIBXML_API unsigned int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp); +PHP_LIBXML_API unsigned int php_libxml_decrement_doc_ref_directly(php_libxml_ref_obj *document); +PHP_LIBXML_API unsigned int php_libxml_decrement_doc_ref(php_libxml_node_object *object); PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object); PHP_LIBXML_API zval *php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function); /* When an explicit freeing of node and children is required */ diff --git a/ext/libxml/tests/bug69753-mb.phpt b/ext/libxml/tests/bug69753-mb.phpt index e89034db16268..6f358f94bf098 100644 --- a/ext/libxml/tests/bug69753-mb.phpt +++ b/ext/libxml/tests/bug69753-mb.phpt @@ -1,12 +1,11 @@ --TEST-- Bug #69753 - libXMLError::file contains invalid URI ---XFAIL-- -Awaiting upstream fix: https://gitlab.gnome.org/GNOME/libxml2/-/issues/611 --EXTENSIONS-- dom --SKIPIF-- --FILE-- file); ?> --EXPECTF-- -string(%d) "file:///%s/ext/libxml/tests/bug69753.xml" +string(%d) "%s\ext\libxml\tests\bug69753私はガラスを食べられます.xml" diff --git a/ext/libxml/tests/bug69753.phpt b/ext/libxml/tests/bug69753.phpt index bd2a9c0b82581..e9f0c56c2ee0a 100644 --- a/ext/libxml/tests/bug69753.phpt +++ b/ext/libxml/tests/bug69753.phpt @@ -1,12 +1,11 @@ --TEST-- Bug #69753 - libXMLError::file contains invalid URI ---XFAIL-- -Awaiting upstream fix: https://gitlab.gnome.org/GNOME/libxml2/-/issues/611 --EXTENSIONS-- dom --SKIPIF-- --FILE-- file); ?> --EXPECTF-- -string(%d) "file:///%s/ext/libxml/tests/bug69753.xml" +string(%d) "%s\ext\libxml\tests\bug69753.xml" diff --git a/ext/mysqlnd/config.w32 b/ext/mysqlnd/config.w32 index 9fb58ed50ddf7..e9ff75f237ced 100644 --- a/ext/mysqlnd/config.w32 +++ b/ext/mysqlnd/config.w32 @@ -37,7 +37,7 @@ if (PHP_MYSQLND != "no") { AC_DEFINE("MYSQLND_COMPRESSION_ENABLED", 1, "Define to 1 if mysqlnd has compressed protocol support."); AC_DEFINE("MYSQLND_SSL_SUPPORTED", 1, "Define to 1 if mysqlnd core SSL is enabled."); if (CHECK_LIB("crypt32.lib", "mysqlnd")) { - AC_DEFINE("MYSQLND_HAVE_SSL", 1, "Define to 1 if mysqlnd extended SSL is enabled through OpenSSL."); + AC_DEFINE("MYSQLND_HAVE_SSL", 1, "Define to 1 if mysqlnd extended SSL is enabled through a system library."); ADD_EXTENSION_DEP('mysqlnd', 'hash'); } } diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4 index 1b1d576d440c8..800677f8d731e 100644 --- a/ext/mysqlnd/config9.m4 +++ b/ext/mysqlnd/config9.m4 @@ -66,7 +66,7 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then AS_VAR_IF([PHP_MYSQLND_SSL], [no],, [PHP_SETUP_OPENSSL([MYSQLND_SHARED_LIBADD], [ AC_DEFINE([MYSQLND_HAVE_SSL], [1], - [Define to 1 if mysqlnd extended SSL is enabled through OpenSSL.]) + [Define to 1 if mysqlnd extended SSL is enabled through a system library.]) PHP_ADD_EXTENSION_DEP(mysqlnd, hash) ])]) diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 464e0f0d45935..4017c72a35a67 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -545,7 +545,6 @@ PHP_MINIT_FUNCTION(odbc) /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(odbc) { - ODBCG(defConn) = -1; ODBCG(num_links) = ODBCG(num_persistent); memset(ODBCG(laststate), '\0', 6); memset(ODBCG(lasterrormsg), '\0', SQL_MAX_MESSAGE_LENGTH); diff --git a/ext/odbc/php_odbc_includes.h b/ext/odbc/php_odbc_includes.h index 59404ecd266ba..e0c6330d74498 100644 --- a/ext/odbc/php_odbc_includes.h +++ b/ext/odbc/php_odbc_includes.h @@ -187,10 +187,10 @@ #endif typedef struct odbc_connection { - ODBC_SQL_ENV_T henv; - ODBC_SQL_CONN_T hdbc; - char laststate[6]; - char lasterrormsg[SQL_MAX_MESSAGE_LENGTH]; + ODBC_SQL_ENV_T henv; + ODBC_SQL_CONN_T hdbc; + char laststate[6]; + char lasterrormsg[SQL_MAX_MESSAGE_LENGTH]; HashTable results; } odbc_connection; @@ -239,12 +239,11 @@ ZEND_BEGIN_MODULE_GLOBALS(odbc) zend_long max_links; zend_long num_persistent; zend_long num_links; - int defConn; - zend_long defaultlrl; - zend_long defaultbinmode; - zend_long default_cursortype; - char laststate[6]; - char lasterrormsg[SQL_MAX_MESSAGE_LENGTH]; + zend_long defaultlrl; + zend_long defaultbinmode; + zend_long default_cursortype; + char laststate[6]; + char lasterrormsg[SQL_MAX_MESSAGE_LENGTH]; /* Stores ODBC links throughout the duration of a request. The connection member may be either persistent or * non-persistent. In the former case, it is a pointer to an item in EG(persistent_list). This solution makes it * possible to properly free links during RSHUTDOWN (or when they are explicitly closed), while persistent diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 3e8bdea9c7a6b..406c539f44a27 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -3408,6 +3408,8 @@ void accel_shutdown(void) /* Delay SHM detach */ orig_post_shutdown_cb = zend_post_shutdown_cb; zend_post_shutdown_cb = accel_post_shutdown; + } else { + free(accel_shared_globals); } zend_compile_file = accelerator_orig_compile_file; @@ -4462,6 +4464,12 @@ static zend_result accel_preload(const char *config, bool in_child) /* Release stored values to avoid dangling pointers */ zend_shutdown_executor_values(/* fast_shutdown */ false); + /* On ZTS we execute `executor_globals_ctor` which reset the freelist and p5s pointers, while on NTS we don't. + * We have to clean up the memory before the actual request takes place to avoid a memory leak. */ +#ifdef ZTS + zend_shutdown_strtod(); +#endif + /* We don't want to preload constants. * Check that zend_shutdown_executor_values() also destroys constants. */ ZEND_ASSERT(zend_hash_num_elements(EG(zend_constants)) == EG(persistent_constants_count)); diff --git a/ext/opcache/jit/ir/ir.c b/ext/opcache/jit/ir/ir.c index 95a5d2b0ea8e3..5da5beaae4e50 100644 --- a/ext/opcache/jit/ir/ir.c +++ b/ext/opcache/jit/ir/ir.c @@ -2369,6 +2369,24 @@ ir_ref _ir_CALL_5(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref ar return call; } +ir_ref _ir_CALL_6(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4, ir_ref arg5, ir_ref arg6) +{ + ir_ref call; + + IR_ASSERT(ctx->control); + call = ir_emit_N(ctx, IR_OPT(IR_CALL, type), 8); + ir_set_op(ctx, call, 1, ctx->control); + ir_set_op(ctx, call, 2, func); + ir_set_op(ctx, call, 3, arg1); + ir_set_op(ctx, call, 4, arg2); + ir_set_op(ctx, call, 5, arg3); + ir_set_op(ctx, call, 6, arg4); + ir_set_op(ctx, call, 7, arg5); + ir_set_op(ctx, call, 8, arg6); + ctx->control = call; + return call; +} + ir_ref _ir_CALL_N(ir_ctx *ctx, ir_type type, ir_ref func, uint32_t count, ir_ref *args) { ir_ref call; @@ -2493,6 +2511,28 @@ void _ir_TAILCALL_5(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref _ir_UNREACHABLE(ctx); } +void _ir_TAILCALL_6(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4, ir_ref arg5, ir_ref arg6) +{ + ir_ref call; + + IR_ASSERT(ctx->control); + if (ctx->ret_type == (ir_type)-1) { + ctx->ret_type = type; + } + IR_ASSERT(ctx->ret_type == type && "conflicting return type"); + call = ir_emit_N(ctx, IR_OPT(IR_TAILCALL, type), 8); + ir_set_op(ctx, call, 1, ctx->control); + ir_set_op(ctx, call, 2, func); + ir_set_op(ctx, call, 3, arg1); + ir_set_op(ctx, call, 4, arg2); + ir_set_op(ctx, call, 5, arg3); + ir_set_op(ctx, call, 6, arg4); + ir_set_op(ctx, call, 7, arg5); + ir_set_op(ctx, call, 8, arg6); + ctx->control = call; + _ir_UNREACHABLE(ctx); +} + void _ir_TAILCALL_N(ir_ctx *ctx, ir_type type, ir_ref func, uint32_t count, ir_ref *args) { ir_ref call; diff --git a/ext/opcache/jit/ir/ir_builder.h b/ext/opcache/jit/ir/ir_builder.h index 097c80e048a48..0fbdcb3e04586 100644 --- a/ext/opcache/jit/ir/ir_builder.h +++ b/ext/opcache/jit/ir/ir_builder.h @@ -514,6 +514,7 @@ extern "C" { #define ir_CALL_3(type, func, a1, a2, a3) _ir_CALL_3(_ir_CTX, type, func, a1, a2, a3) #define ir_CALL_4(type, func, a1, a2, a3, a4) _ir_CALL_4(_ir_CTX, type, func, a1, a2, a3, a4) #define ir_CALL_5(type, func, a1, a2, a3, a4, a5) _ir_CALL_5(_ir_CTX, type, func, a1, a2, a3, a4, a5) +#define ir_CALL_6(type, func, a, b, c, d, e, f) _ir_CALL_6(_ir_CTX, type, func, a, b, c, d, e, f) #define ir_CALL_N(type, func, count, args) _ir_CALL_N(_ir_CTX, type, func, count, args) #define ir_TAILCALL(type, func) _ir_TAILCALL(_ir_CTX, type, func) @@ -522,6 +523,7 @@ extern "C" { #define ir_TAILCALL_3(type, func, a1, a2, a3) _ir_TAILCALL_3(_ir_CTX, type, func, a1, a2, a3) #define ir_TAILCALL_4(type, func, a1, a2, a3, a4) _ir_TAILCALL_4(_ir_CTX, type, func, a1, a2, a3, a4) #define ir_TAILCALL_5(type, func, a1, a2, a3, a4, a5) _ir_TAILCALL_5(_ir_CTX, type, func, a1, a2, a3, a4, a5) +#define ir_TAILCALL_6(type, func, a, b, c, d, e, f) _ir_TAILCALL_6(_ir_CTX, type, func, a, b, c, d, e, f) #define ir_TAILCALL_N(type, func, count, args) _ir_TAILCALL_N(_ir_CTX, type, func, count, args) #define ir_ALLOCA(_size) _ir_ALLOCA(_ir_CTX, (_size)) @@ -636,6 +638,7 @@ ir_ref _ir_CALL_2(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref ar ir_ref _ir_CALL_3(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3); ir_ref _ir_CALL_4(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4); ir_ref _ir_CALL_5(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4, ir_ref arg5); +ir_ref _ir_CALL_6(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4, ir_ref arg5, ir_ref atg6); ir_ref _ir_CALL_N(ir_ctx *ctx, ir_type type, ir_ref func, uint32_t count, ir_ref *args); void _ir_TAILCALL(ir_ctx *ctx, ir_type type, ir_ref func); void _ir_TAILCALL_1(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1); @@ -643,6 +646,7 @@ void _ir_TAILCALL_2(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_re void _ir_TAILCALL_3(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3); void _ir_TAILCALL_4(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4); void _ir_TAILCALL_5(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4, ir_ref arg5); +void _ir_TAILCALL_6(ir_ctx *ctx, ir_type type, ir_ref func, ir_ref arg1, ir_ref arg2, ir_ref arg3, ir_ref arg4, ir_ref arg5, ir_ref arg6); ir_ref _ir_TAILCALL_N(ir_ctx *ctx, ir_type type, ir_ref func, uint32_t count, ir_ref *args); ir_ref _ir_ALLOCA(ir_ctx *ctx, ir_ref size); void _ir_AFREE(ir_ctx *ctx, ir_ref size); diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index da3dacf338d57..ffcb8daaf568f 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -692,6 +692,78 @@ static bool zend_may_be_dynamic_property(zend_class_entry *ce, zend_string *memb return 0; } +static bool zend_jit_class_may_be_modified(const zend_class_entry *ce, const zend_op_array *called_from) +{ + uint32_t i; + + if (ce->type == ZEND_INTERNAL_CLASS) { +#ifdef _WIN32 + /* ASLR */ + return 1; +#else + return 0; +#endif + } else if (ce->type == ZEND_USER_CLASS) { + if (ce->ce_flags & ZEND_ACC_PRELOADED) { + return 0; + } + if (ce->info.user.filename == called_from->filename) { + if (ce->parent + && (!(ce->ce_flags & ZEND_ACC_LINKED) + || zend_jit_class_may_be_modified(ce->parent, called_from))) { + return 1; + } + if (ce->num_interfaces) { + if (!(ce->ce_flags & ZEND_ACC_LINKED)) { + return 1; + } + for (i = 0; i < ce->num_interfaces; i++) { + if (zend_jit_class_may_be_modified(ce->interfaces[i], called_from)) { + return 1; + } + } + } + if (ce->num_traits) { + if (!(ce->ce_flags & ZEND_ACC_LINKED)) { + return 1; + } + for (i=0; i < ce->num_traits; i++) { + zend_class_entry *trait = zend_fetch_class_by_name(ce->trait_names[i].name, + ce->trait_names[i].lc_name, + ZEND_FETCH_CLASS_TRAIT | ZEND_FETCH_CLASS_NO_AUTOLOAD | ZEND_FETCH_CLASS_SILENT); + if (!trait || zend_jit_class_may_be_modified(trait, called_from)) { + return 1; + } + } + } + return 0; + } + } + return 1; +} + +static bool zend_jit_may_be_modified(const zend_function *func, const zend_op_array *called_from) +{ + if (func->type == ZEND_INTERNAL_FUNCTION) { +#ifdef _WIN32 + /* ASLR */ + return 1; +#else + return 0; +#endif + } else if (func->type == ZEND_USER_FUNCTION) { + if (func->common.fn_flags & ZEND_ACC_PRELOADED) { + return 0; + } + if (func->op_array.filename == called_from->filename + && (!func->op_array.scope + || !zend_jit_class_may_be_modified(func->op_array.scope, called_from))) { + return 0; + } + } + return 1; +} + #define OP_RANGE(ssa_op, opN) \ (((opline->opN##_type & (IS_TMP_VAR|IS_VAR|IS_CV)) && \ ssa->var_info && \ @@ -1788,7 +1860,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; @@ -1839,7 +1911,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; @@ -1883,7 +1955,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; @@ -2361,7 +2433,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } on_this = 1; } else { @@ -2531,7 +2603,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } on_this = 1; } else { diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 3eec4df0ecc7e..56b8b2d69cac2 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1917,6 +1917,12 @@ static bool ZEND_FASTCALL zend_jit_verify_arg_slow(zval *arg, zend_arg_info *arg static void ZEND_FASTCALL zend_jit_verify_return_slow(zval *arg, const zend_op_array *op_array, zend_arg_info *arg_info, void **cache_slot) { + if (Z_TYPE_P(arg) == IS_NULL) { + ZEND_ASSERT(ZEND_TYPE_IS_SET(arg_info->type)); + if (EXPECTED(ZEND_TYPE_CONTAINS_CODE(arg_info->type, IS_NULL))) { + return; + } + } if (UNEXPECTED(!zend_check_user_type_slow( &arg_info->type, arg, /* ref */ NULL, cache_slot, /* is_return_type */ true))) { zend_verify_return_error((zend_function*)op_array, arg); diff --git a/ext/opcache/jit/zend_jit_internal.h b/ext/opcache/jit/zend_jit_internal.h index 9a09be49f1bd5..61d8a853fa005 100644 --- a/ext/opcache/jit/zend_jit_internal.h +++ b/ext/opcache/jit/zend_jit_internal.h @@ -683,26 +683,6 @@ static zend_always_inline const zend_op* zend_jit_trace_get_exit_opline(zend_jit return NULL; } -static inline bool zend_jit_may_be_modified(const zend_function *func, const zend_op_array *called_from) -{ - if (func->type == ZEND_INTERNAL_FUNCTION) { -#ifdef _WIN32 - /* ASLR */ - return 1; -#else - return 0; -#endif - } else if (func->type == ZEND_USER_FUNCTION) { - if (func->common.fn_flags & ZEND_ACC_PRELOADED) { - return 0; - } - if (func->op_array.filename == called_from->filename && !func->op_array.scope) { - return 0; - } - } - return 1; -} - static zend_always_inline bool zend_jit_may_be_polymorphic_call(const zend_op *opline) { if (opline->opcode == ZEND_INIT_FCALL diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index b50dfc2bc058e..9124b8400bcea 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -10084,6 +10084,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; + uint32_t num_args = 0; // JIT: EX(call) = NULL; ir_STORE(jit_CALL(rx, call), IR_NULL); @@ -10148,8 +10149,6 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen if (call_num_args <= func->op_array.num_args) { if (!trace || (trace->op == ZEND_JIT_TRACE_END && trace->stop >= ZEND_JIT_TRACE_STOP_INTERPRETER)) { - uint32_t num_args; - if ((func->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) != 0) { if (trace) { num_args = 0; @@ -10345,7 +10344,7 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen ir_insn *insn; /* attempt to convert direct recursive call into loop */ - begin = jit->bb_start_ref[call_num_args]; + begin = jit->bb_start_ref[num_args]; ZEND_ASSERT(begin != IR_UNUSED); insn = &jit->ctx.ir_base[begin]; if (insn->op == IR_BEGIN) { @@ -12727,7 +12726,7 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit, static zend_jit_addr zend_jit_prepare_array_update(zend_jit_ctx *jit, const zend_op *opline, - uint32_t op1_info, + uint32_t *op1_info_ptr, zend_jit_addr op1_addr, ir_ref *if_type, ir_ref *ht_ref, @@ -12736,6 +12735,7 @@ static zend_jit_addr zend_jit_prepare_array_update(zend_jit_ctx *jit, ir_ref ref = IR_UNUSED; ir_ref array_reference_end = IR_UNUSED, array_reference_ref = IR_UNUSED; ir_refs *array_inputs, *array_values; + uint32_t op1_info = *op1_info_ptr; ir_refs_init(array_inputs, 4); ir_refs_init(array_values, 4); @@ -12827,6 +12827,9 @@ static zend_jit_addr zend_jit_prepare_array_update(zend_jit_ctx *jit, ir_refs_add(array_inputs, ir_END()); ir_refs_add(array_values, ref); } + op1_info &= ~(MAY_BE_UNDEF | MAY_BE_NULL); + op1_info |= MAY_BE_ARRAY | MAY_BE_RC1; + *op1_info_ptr = op1_info; } if (array_inputs->count) { @@ -12856,9 +12859,9 @@ static int zend_jit_fetch_dim(zend_jit_ctx *jit, jit_SET_EX_OPLINE(jit, opline); } - op1_addr = zend_jit_prepare_array_update(jit, opline, op1_info, op1_addr, &if_type, &ht_ref, &may_throw); + op1_addr = zend_jit_prepare_array_update(jit, opline, &op1_info, op1_addr, &if_type, &ht_ref, &may_throw); - if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_ARRAY)) { + if (op1_info & MAY_BE_ARRAY) { ir_refs *found_inputs, *found_vals; ir_refs_init(found_inputs, 8); @@ -12938,7 +12941,7 @@ static int zend_jit_fetch_dim(zend_jit_ctx *jit, } } - if (op1_info & (MAY_BE_ANY-(MAY_BE_NULL|MAY_BE_ARRAY))) { + if (op1_info & (MAY_BE_ANY-MAY_BE_ARRAY)) { ir_ref arg2; may_throw = 1; @@ -13248,9 +13251,9 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, val_info &= ~MAY_BE_UNDEF; } - op1_addr = zend_jit_prepare_array_update(jit, opline, op1_info, op1_addr, &if_type, &ht_ref, &may_throw); + op1_addr = zend_jit_prepare_array_update(jit, opline, &op1_info, op1_addr, &if_type, &ht_ref, &may_throw); - if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_ARRAY)) { + if (op1_info & MAY_BE_ARRAY) { if (opline->op2_type == IS_UNUSED) { uint32_t var_info = MAY_BE_NULL; ir_ref if_ok, ref; @@ -13321,7 +13324,7 @@ static int zend_jit_assign_dim(zend_jit_ctx *jit, ir_END_list(end_inputs); } - if (op1_info & (MAY_BE_ANY-(MAY_BE_NULL|MAY_BE_ARRAY))) { + if (op1_info & (MAY_BE_ANY-MAY_BE_ARRAY)) { ir_ref arg2, arg4; if (if_type) { @@ -13412,9 +13415,9 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, jit_SET_EX_OPLINE(jit, opline); } - op1_addr = zend_jit_prepare_array_update(jit, opline, op1_info, op1_addr, &if_type, &ht_ref, &may_throw); + op1_addr = zend_jit_prepare_array_update(jit, opline, &op1_info, op1_addr, &if_type, &ht_ref, &may_throw); - if (op1_info & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_ARRAY)) { + if (op1_info & MAY_BE_ARRAY) { uint32_t var_def_info = zend_array_element_type(op1_def_info, opline->op1_type, 1, 0); if (opline->op2_type == IS_UNUSED) { @@ -13556,7 +13559,7 @@ static int zend_jit_assign_dim_op(zend_jit_ctx *jit, } } - if (op1_info & (MAY_BE_ANY-(MAY_BE_NULL|MAY_BE_ARRAY))) { + if (op1_info & (MAY_BE_ANY-MAY_BE_ARRAY)) { binary_op_type binary_op; ir_ref arg2; diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index a3abbc1217900..563127cc10aa4 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -1860,11 +1860,6 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin ADD_OP2_TRACE_GUARD(); break; case ZEND_ASSIGN_DIM_OP: - if (opline->extended_value == ZEND_POW - || opline->extended_value == ZEND_DIV) { - // TODO: check for division by zero ??? - break; - } if (opline->result_type != IS_UNUSED) { break; } @@ -1875,23 +1870,18 @@ static zend_ssa *zend_jit_trace_build_tssa(zend_jit_trace_rec *trace_buffer, uin } ZEND_FALLTHROUGH; case ZEND_ASSIGN_DIM: - if (opline->op1_type == IS_CV) { - if ((opline+1)->op1_type == IS_CV - && (opline+1)->op1.var == opline->op1.var) { - /* skip $a[x] = $a; */ - break; - } + if (opline->opcode == ZEND_ASSIGN_DIM + && opline->op1_type == IS_CV + && (opline+1)->op1_type == IS_CV + && (opline+1)->op1.var == opline->op1.var) { + /* skip $a[x] = $a; */ + break; + } + if (opline->op1_type == IS_CV || opline->opcode == ZEND_ASSIGN_DIM_OP) { ADD_OP1_DATA_TRACE_GUARD(); - ADD_OP2_TRACE_GUARD(); - ADD_OP1_TRACE_GUARD(); - } else if (orig_op1_type != IS_UNKNOWN - && (orig_op1_type & IS_TRACE_INDIRECT) - && opline->result_type == IS_UNUSED) { - if (opline->opcode == ZEND_ASSIGN_DIM_OP) { - ADD_OP1_DATA_TRACE_GUARD(); - } - ADD_OP2_TRACE_GUARD(); } + ADD_OP2_TRACE_GUARD(); + ADD_OP1_TRACE_GUARD(); if (op1_type == IS_ARRAY && ((opline->op2_type == IS_CONST && Z_TYPE_P(RT_CONSTANT(opline, opline->op2)) == IS_LONG) @@ -4773,6 +4763,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par op1_info, op2_info, op1_data_info, val_type))) { goto jit_failure; } + if (opline->op1_type == IS_VAR && !(op1_info & (MAY_BE_ANY-MAY_BE_NULL))) { + SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var), IS_ARRAY, 1); + } goto done; case ZEND_PRE_INC_OBJ: case ZEND_PRE_DEC_OBJ: @@ -4792,7 +4785,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; @@ -4886,7 +4879,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; @@ -4969,7 +4962,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; @@ -5097,6 +5090,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par && ssa->vars[(ssa_op+1)->op1_def].alias == NO_ALIAS) { ssa->var_info[(ssa_op+1)->op1_def].guarded_reference = ssa->var_info[(ssa_op+1)->op1_use].guarded_reference; } + if (opline->op1_type == IS_VAR && !(op1_info & (MAY_BE_ANY-MAY_BE_NULL))) { + SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->op1.var), IS_ARRAY, 1); + } goto done; case ZEND_ASSIGN: if (opline->op1_type != IS_CV) { @@ -5564,6 +5560,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par res_type = Z_TYPE_P(RT_CONSTANT(opline, opline->op1)); } else if (op1_type != IS_UNKNOWN) { res_type = op1_type; + if (res_type == IS_UNDEF) { + res_type = IS_NULL; + } } if (op_array->type == ZEND_EVAL_CODE // TODO: support for top-level code @@ -6039,7 +6038,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; @@ -6345,7 +6344,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par ce = op_array->scope; /* scope is NULL for closures. */ if (ce) { - ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0; + ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL); } op1_addr = 0; on_this = 1; diff --git a/ext/opcache/tests/gh16577.inc b/ext/opcache/tests/gh16577.inc new file mode 100644 index 0000000000000..f016d61281784 --- /dev/null +++ b/ext/opcache/tests/gh16577.inc @@ -0,0 +1,2 @@ + +--FILE-- + +--EXPECT-- +float(1.5) +Done diff --git a/ext/opcache/tests/jit/assign_obj_005.phpt b/ext/opcache/tests/jit/assign_obj_005.phpt new file mode 100644 index 0000000000000..cbda0b0c17948 --- /dev/null +++ b/ext/opcache/tests/jit/assign_obj_005.phpt @@ -0,0 +1,38 @@ +--TEST-- +JIT ASSIGN_OBJ: Typed & not-typed property +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- +x = $x; + } +} +class C2 extends C1 { + public $x = 0; +} +class C3 extends C1 { + public int $x = 0; +} +$o = new C2("abcd"); +var_dump($o->x); +$o = new C3(42); +var_dump($o->x); +$o = new C3("abcd"); +var_dump($o->x); +?> +--EXPECTF-- +string(4) "abcd" +int(42) + +Fatal error: Uncaught TypeError: Cannot assign string to property C3::$x of type int in %sassign_obj_005.php:6 +Stack trace: +#0 %sassign_obj_005.php(19): C1->__construct('abcd') +#1 {main} + thrown in %sassign_obj_005.php on line 6 diff --git a/ext/opcache/tests/jit/gh16499.phpt b/ext/opcache/tests/jit/gh16499.phpt new file mode 100644 index 0000000000000..6aec1012ab5ee --- /dev/null +++ b/ext/opcache/tests/jit/gh16499.phpt @@ -0,0 +1,28 @@ +--TEST-- +GH-16499 (Undefined to null coercion issues for return) +--EXTENSIONS-- +opcache +--INI-- +opcache.jit_buffer_size=64M +--FILE-- + +--EXPECTF-- +Warning: Undefined variable $i in %sgh16499.php on line 6 + +Warning: Undefined variable $i in %sgh16499.php on line 6 +NULL + +Warning: Undefined variable $i in %sgh16499.php on line 6 + +Warning: Undefined variable $i in %sgh16499.php on line 6 +NULL \ No newline at end of file diff --git a/ext/opcache/tests/jit/gh16572.phpt b/ext/opcache/tests/jit/gh16572.phpt new file mode 100644 index 0000000000000..b3a6850561c02 --- /dev/null +++ b/ext/opcache/tests/jit/gh16572.phpt @@ -0,0 +1,24 @@ +--TEST-- +GH-16572 (Incorrect result with reflection in low-trigger JIT) +--EXTENSIONS-- +opcache +--INI-- +opcache.jit=1215 +--FILE-- +getReturnType()); +?> +--EXPECTF-- +string(19) "ReflectionNamedType" + +Fatal error: Uncaught TypeError: dumpType(): Argument #1 ($rt) must be of type ReflectionType, null given, called in %s on line %d and defined in %s:%d +Stack trace: +#0 %s(%d): dumpType(NULL) +#1 %s(%d): dumpType(Object(ReflectionNamedType)) +#2 {main} + thrown in %s on line %d diff --git a/ext/opcache/tests/jit/gh16770.phpt b/ext/opcache/tests/jit/gh16770.phpt new file mode 100644 index 0000000000000..71d796ade8ed9 --- /dev/null +++ b/ext/opcache/tests/jit/gh16770.phpt @@ -0,0 +1,39 @@ +--TEST-- +GH-16770 (Tracing JIT type mismatch when returning UNDEF) +--INI-- +opcache.jit=1254 +opcache.jit_hot_loop=1 +opcache.jit_buffer_size=32M +--EXTENSIONS-- +opcache +--FILE-- + +--EXPECTF-- +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d + +Warning: Undefined variable $undefined in %s on line %d +NULL diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index a8eefad60c2fe..716a6e4df0094 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -175,13 +175,13 @@ static zend_always_inline void _zend_accel_function_hash_copy(HashTable *target, function2 = Z_PTR_P(t); CG(in_compilation) = 1; zend_set_compiled_filename(function1->op_array.filename); - CG(zend_lineno) = function1->op_array.opcodes[0].lineno; + CG(zend_lineno) = function1->op_array.line_start; if (function2->type == ZEND_USER_FUNCTION && function2->op_array.last > 0) { zend_error_noreturn(E_ERROR, "Cannot redeclare function %s() (previously declared in %s:%d)", ZSTR_VAL(function1->common.function_name), ZSTR_VAL(function2->op_array.filename), - (int)function2->op_array.opcodes[0].lineno); + (int)function2->op_array.line_start); } else { zend_error_noreturn(E_ERROR, "Cannot redeclare function %s()", ZSTR_VAL(function1->common.function_name)); } diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index f6994a06c5428..be68216b524a9 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1562,7 +1562,7 @@ PHP_FUNCTION(openssl_x509_export_to_file) } if (!php_openssl_check_path(filename, filename_len, file_path, 2)) { - return; + goto exit_cleanup_cert; } bio_out = BIO_new_file(file_path, PHP_OPENSSL_BIO_MODE_W(PKCS7_BINARY)); @@ -1580,13 +1580,14 @@ PHP_FUNCTION(openssl_x509_export_to_file) php_error_docref(NULL, E_WARNING, "Error opening file %s", file_path); } - if (cert_str) { - X509_free(cert); - } - if (!BIO_free(bio_out)) { php_openssl_store_errors(); } + +exit_cleanup_cert: + if (cert_str) { + X509_free(cert); + } } /* }}} */ @@ -2153,7 +2154,7 @@ PHP_FUNCTION(openssl_x509_parse) /* Can return NULL on error or memory allocation failure */ if (!bn_serial) { php_openssl_store_errors(); - RETURN_FALSE; + goto err; } hex_serial = BN_bn2hex(bn_serial); @@ -2161,7 +2162,7 @@ PHP_FUNCTION(openssl_x509_parse) /* Can return NULL on error or memory allocation failure */ if (!hex_serial) { php_openssl_store_errors(); - RETURN_FALSE; + goto err; } str_serial = i2s_ASN1_INTEGER(NULL, asn1_serial); @@ -2233,19 +2234,15 @@ PHP_FUNCTION(openssl_x509_parse) bio_out = BIO_new(BIO_s_mem()); if (bio_out == NULL) { php_openssl_store_errors(); - RETURN_FALSE; + goto err_subitem; } if (nid == NID_subject_alt_name) { if (openssl_x509v3_subjectAltName(bio_out, extension) == 0) { BIO_get_mem_ptr(bio_out, &bio_buf); add_assoc_stringl(&subitem, extname, bio_buf->data, bio_buf->length); } else { - zend_array_destroy(Z_ARR_P(return_value)); BIO_free(bio_out); - if (cert_str) { - X509_free(cert); - } - RETURN_FALSE; + goto err_subitem; } } else if (X509V3_EXT_print(bio_out, extension, 0, 0)) { @@ -2260,6 +2257,16 @@ PHP_FUNCTION(openssl_x509_parse) if (cert_str) { X509_free(cert); } + return; + +err_subitem: + zval_ptr_dtor(&subitem); +err: + zend_array_destroy(Z_ARR_P(return_value)); + if (cert_str) { + X509_free(cert); + } + RETURN_FALSE; } /* }}} */ @@ -3137,7 +3144,7 @@ PHP_FUNCTION(openssl_csr_export_to_file) } if (!php_openssl_check_path(filename, filename_len, file_path, 2)) { - return; + goto exit_cleanup; } bio_out = BIO_new_file(file_path, PHP_OPENSSL_BIO_MODE_W(PKCS7_BINARY)); @@ -3157,6 +3164,7 @@ PHP_FUNCTION(openssl_csr_export_to_file) php_error_docref(NULL, E_WARNING, "Error opening file %s", file_path); } +exit_cleanup: if (csr_str) { X509_REQ_free(csr); } @@ -3623,6 +3631,7 @@ static EVP_PKEY *php_openssl_pkey_from_zval( } else { ZVAL_COPY(&tmp, zphrase); if (!try_convert_to_string(&tmp)) { + zval_ptr_dtor(&tmp); return NULL; } @@ -3669,12 +3678,14 @@ static EVP_PKEY *php_openssl_pkey_from_zval( if (!(Z_TYPE_P(val) == IS_STRING || Z_TYPE_P(val) == IS_OBJECT)) { TMP_CLEAN; } - if (!try_convert_to_string(val)) { + zend_string *val_str = zval_try_get_string(val); + if (!val_str) { TMP_CLEAN; } - if (Z_STRLEN_P(val) > 7 && memcmp(Z_STRVAL_P(val), "file://", sizeof("file://") - 1) == 0) { - if (!php_openssl_check_path_str(Z_STR_P(val), file_path, arg_num)) { + if (ZSTR_LEN(val_str) > 7 && memcmp(ZSTR_VAL(val_str), "file://", sizeof("file://") - 1) == 0) { + if (!php_openssl_check_path_str(val_str, file_path, arg_num)) { + zend_string_release_ex(val_str, false); TMP_CLEAN; } is_file = true; @@ -3682,7 +3693,7 @@ static EVP_PKEY *php_openssl_pkey_from_zval( /* it's an X509 file/cert of some kind, and we need to extract the data from that */ if (public_key) { php_openssl_errors_set_mark(); - cert = php_openssl_x509_from_str(Z_STR_P(val), arg_num, false, NULL); + cert = php_openssl_x509_from_str(val_str, arg_num, false, NULL); if (cert) { free_cert = 1; @@ -3693,10 +3704,11 @@ static EVP_PKEY *php_openssl_pkey_from_zval( if (is_file) { in = BIO_new_file(file_path, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY)); } else { - in = BIO_new_mem_buf(Z_STRVAL_P(val), (int)Z_STRLEN_P(val)); + in = BIO_new_mem_buf(ZSTR_VAL(val_str), (int)ZSTR_LEN(val_str)); } if (in == NULL) { php_openssl_store_errors(); + zend_string_release_ex(val_str, false); TMP_CLEAN; } key = PEM_read_bio_PUBKEY(in, NULL,NULL, NULL); @@ -3709,10 +3721,11 @@ static EVP_PKEY *php_openssl_pkey_from_zval( if (is_file) { in = BIO_new_file(file_path, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY)); } else { - in = BIO_new_mem_buf(Z_STRVAL_P(val), (int)Z_STRLEN_P(val)); + in = BIO_new_mem_buf(ZSTR_VAL(val_str), (int)ZSTR_LEN(val_str)); } if (in == NULL) { + zend_string_release_ex(val_str, false); TMP_CLEAN; } if (passphrase == NULL) { @@ -3725,6 +3738,8 @@ static EVP_PKEY *php_openssl_pkey_from_zval( } BIO_free(in); } + + zend_string_release_ex(val_str, false); } if (key == NULL) { @@ -4903,7 +4918,7 @@ PHP_FUNCTION(openssl_pkey_export_to_file) } if (!php_openssl_check_path(filename, filename_len, file_path, 2)) { - RETURN_FALSE; + goto clean_exit_key; } PHP_SSL_REQ_INIT(&req); @@ -4939,8 +4954,9 @@ PHP_FUNCTION(openssl_pkey_export_to_file) clean_exit: PHP_SSL_REQ_DISPOSE(&req); - EVP_PKEY_free(key); BIO_free(bio_out); +clean_exit_key: + EVP_PKEY_free(key); } /* }}} */ diff --git a/ext/openssl/tests/openssl_csr_export_to_file_leak.phpt b/ext/openssl/tests/openssl_csr_export_to_file_leak.phpt new file mode 100644 index 0000000000000..e6ce373d355b1 --- /dev/null +++ b/ext/openssl/tests/openssl_csr_export_to_file_leak.phpt @@ -0,0 +1,14 @@ +--TEST-- +openssl_csr_export_to_file memory leak +--EXTENSIONS-- +openssl +--FILE-- + +--EXPECTF-- +Warning: openssl_csr_export_to_file(output_filename): must be a valid file path %s +bool(false) diff --git a/ext/openssl/tests/openssl_pkey_export_to_file_leak.phpt b/ext/openssl/tests/openssl_pkey_export_to_file_leak.phpt new file mode 100644 index 0000000000000..5e2bdff6b48fc --- /dev/null +++ b/ext/openssl/tests/openssl_pkey_export_to_file_leak.phpt @@ -0,0 +1,15 @@ +--TEST-- +openssl_pkey_export_to_file memory leak +--EXTENSIONS-- +openssl +--FILE-- + +--EXPECTF-- +Warning: openssl_pkey_export_to_file(output_filename): must be a valid file path %s +bool(false) diff --git a/ext/openssl/tests/openssl_pkey_export_to_file_object_to_string.phpt b/ext/openssl/tests/openssl_pkey_export_to_file_object_to_string.phpt new file mode 100644 index 0000000000000..0e504bfa4ac63 --- /dev/null +++ b/ext/openssl/tests/openssl_pkey_export_to_file_object_to_string.phpt @@ -0,0 +1,27 @@ +--TEST-- +openssl_pkey_export_to_file object to string conversion +--EXTENSIONS-- +openssl +--FILE-- + +--EXPECT-- +array(2) { + [0]=> + object(Test)#1 (0) { + } + [1]=> + string(0) "" +} diff --git a/ext/openssl/tests/openssl_x509_export_to_file_leak.phpt b/ext/openssl/tests/openssl_x509_export_to_file_leak.phpt new file mode 100644 index 0000000000000..5775c2597c3e0 --- /dev/null +++ b/ext/openssl/tests/openssl_x509_export_to_file_leak.phpt @@ -0,0 +1,14 @@ +--TEST-- +openssl_x509_export_to_file memory leak +--EXTENSIONS-- +openssl +--FILE-- + +--EXPECTF-- +Warning: openssl_x509_export_to_file(output_filename): must be a valid file path %s +bool(false) diff --git a/ext/openssl/tests/php_openssl_pkey_from_zval_leak.phpt b/ext/openssl/tests/php_openssl_pkey_from_zval_leak.phpt new file mode 100644 index 0000000000000..2b19dd311150a --- /dev/null +++ b/ext/openssl/tests/php_openssl_pkey_from_zval_leak.phpt @@ -0,0 +1,23 @@ +--TEST-- +php_openssl_pkey_from_zval memory leak +--EXTENSIONS-- +openssl +--FILE-- +getMessage(), "\n"; +} + +?> +--EXPECT-- +create a leak diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index b2fe964e7face..c3b53aec0ebb8 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -874,6 +874,7 @@ static bool php_pcntl_set_user_signal_infos( zval *user_signal_no; ZEND_HASH_FOREACH_VAL(user_signals, user_signal_no) { bool failed = true; + ZVAL_DEREF(user_signal_no); zend_long tmp = zval_try_get_long(user_signal_no, &failed); if (failed) { diff --git a/ext/pcntl/tests/gh16769.phpt b/ext/pcntl/tests/gh16769.phpt new file mode 100644 index 0000000000000..60baee616101d --- /dev/null +++ b/ext/pcntl/tests/gh16769.phpt @@ -0,0 +1,18 @@ +--TEST-- +pcntl_sigwaitinfo abort when signals is an array with self-reference. +--EXTENSIONS-- +pcntl +--SKIPIF-- + +--FILE-- +getMessage(); +} +?> +--EXPECT-- +pcntl_sigwaitinfo(): Argument #1 ($signals) signals must be of type int, array given diff --git a/ext/pcntl/tests/pcntl_setns_basic.phpt b/ext/pcntl/tests/pcntl_setns_basic.phpt index a4f2ea773c57f..1a08d8f1c8559 100644 --- a/ext/pcntl/tests/pcntl_setns_basic.phpt +++ b/ext/pcntl/tests/pcntl_setns_basic.phpt @@ -7,6 +7,14 @@ posix --FILE-- --FILE-- name), driver->driver_name, ZSTR_VAL(ce_based_on_driver_name->name)); + "%s::%s() cannot be used for connecting to the \"%s\" driver, " + "either call %s::%s() or PDO::%s() instead", + ZSTR_VAL(called_scope->name), + new_zval_object ? "connect" : "__construct", + driver->driver_name, + ZSTR_VAL(ce_based_on_driver_name->name), + new_zval_object ? "connect" : "__construct", + new_zval_object ? "connect" : "__construct" + ); return false; } - /* A driver-specific implementation was instantiated via the connect() method of the appropriate driver class */ - object_init_ex(new_object, ce_based_on_called_object); + /* A driver-specific implementation is instantiated with the appropriate driver class */ + if (new_zval_object) { + object_init_ex(new_zval_object, called_scope); + } return true; } else { zend_throw_exception_ex(pdo_exception_ce, 0, - "%s::connect() cannot be called when connecting to an unknown driver, " - "PDO::connect() must be called instead", - ZSTR_VAL(called_scope->name)); + "%s::%s() cannot be used for connecting to an unknown driver, " + "call PDO::%s() instead", + ZSTR_VAL(called_scope->name), + new_zval_object ? "connect" : "__construct", + new_zval_object ? "connect" : "__construct" + ); return false; } } + /* A non-driver specific PDO subclass is instantiated via the constructor. This results in the legacy behavior. */ + if (called_scope != pdo_dbh_ce && new_zval_object == NULL) { + return true; + } + if (ce_based_on_driver_name) { if (called_scope != pdo_dbh_ce) { - /* A driver-specific implementation was instantiated via the connect method of a wrong driver class */ + /* A driver-specific implementation is instantiated with a wrong driver class */ zend_throw_exception_ex(pdo_exception_ce, 0, - "%s::connect() cannot be called when connecting to the \"%s\" driver, " - "either %s::connect() or PDO::connect() must be called instead", - ZSTR_VAL(called_scope->name), driver->driver_name, ZSTR_VAL(ce_based_on_driver_name->name)); + "%s::%s() cannot be used for connecting to the \"%s\" driver, " + "either call %s::%s() or PDO::%s() instead", + ZSTR_VAL(called_scope->name), + new_zval_object ? "connect" : "__construct", + driver->driver_name, + ZSTR_VAL(ce_based_on_driver_name->name), + new_zval_object ? "connect" : "__construct", + new_zval_object ? "connect" : "__construct" + ); return false; } - /* A driver-specific implementation was instantiated via PDO::__construct() */ - object_init_ex(new_object, ce_based_on_driver_name); - } else { + if (new_zval_object) { + object_init_ex(new_zval_object, ce_based_on_driver_name); + } + } else if (new_zval_object) { /* No driver-specific implementation found */ - object_init_ex(new_object, called_scope); + object_init_ex(new_zval_object, called_scope); } return true; } -static void internal_construct(INTERNAL_FUNCTION_PARAMETERS, zend_object *object, zend_class_entry *current_scope, zval *new_zval_object) +PDO_API void php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAMETERS, zend_object *current_object, zend_class_entry *called_scope, zval *new_zval_object) { pdo_dbh_t *dbh = NULL; bool is_persistent = 0; @@ -343,15 +366,16 @@ static void internal_construct(INTERNAL_FUNCTION_PARAMETERS, zend_object *object RETURN_THROWS(); } - if (new_zval_object != NULL) { - ZEND_ASSERT((driver->driver_name != NULL) && "PDO driver name is null"); - if (!create_driver_specific_pdo_object(driver, current_scope, new_zval_object)) { - RETURN_THROWS(); - } + ZEND_ASSERT((driver->driver_name != NULL) && "PDO driver name is null"); + if (!create_driver_specific_pdo_object(driver, called_scope, new_zval_object)) { + RETURN_THROWS(); + } + + if (new_zval_object) { dbh = Z_PDO_DBH_P(new_zval_object); } else { - dbh = php_pdo_dbh_fetch_inner(object); + dbh = php_pdo_dbh_fetch_inner(current_object); } /* is this supposed to be a persistent connection ? */ @@ -412,8 +436,16 @@ static void internal_construct(INTERNAL_FUNCTION_PARAMETERS, zend_object *object if (pdbh) { efree(dbh); + + pdo_dbh_object_t *pdo_obj; + if (new_zval_object) { + pdo_obj = Z_PDO_OBJECT_P(new_zval_object); + } else { + pdo_obj = php_pdo_dbh_fetch_object(current_object); + } + /* switch over to the persistent one */ - php_pdo_dbh_fetch_object(object)->inner = pdbh; + pdo_obj->inner = pdbh; pdbh->refcount++; dbh = pdbh; } @@ -497,14 +529,14 @@ static void internal_construct(INTERNAL_FUNCTION_PARAMETERS, zend_object *object /* {{{ */ PHP_METHOD(PDO, __construct) { - internal_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, Z_OBJ(EX(This)), EX(This).value.ce, NULL); + php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAM_PASSTHRU, Z_OBJ_P(ZEND_THIS), Z_OBJCE_P(ZEND_THIS), NULL); } /* }}} */ /* {{{ */ PHP_METHOD(PDO, connect) { - internal_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, Z_OBJ(EX(This)), EX(This).value.ce, return_value); + php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAM_PASSTHRU, NULL, Z_CE_P(ZEND_THIS), return_value); } /* }}} */ diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c index 2ba34527bad84..a39b7a3b06804 100644 --- a/ext/pdo/pdo_stmt.c +++ b/ext/pdo/pdo_stmt.c @@ -2066,6 +2066,23 @@ static zend_function *dbstmt_method_get(zend_object **object_pp, zend_string *me return fbc; } +static HashTable *dbstmt_get_gc(zend_object *object, zval **gc_data, int *gc_count) +{ + pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); + *gc_data = &stmt->fetch.into; + *gc_count = 1; + + /** + * If there are no dynamic properties and the default property is 1 (that is, there is only one property + * of string that does not participate in GC), there is no need to call zend_std_get_properties(). + */ + if (object->properties == NULL && object->ce->default_properties_count <= 1) { + return NULL; + } else { + return zend_std_get_properties(object); + } +} + zend_object_handlers pdo_dbstmt_object_handlers; zend_object_handlers pdo_row_object_handlers; @@ -2483,6 +2500,7 @@ void pdo_stmt_init(void) pdo_dbstmt_object_handlers.get_method = dbstmt_method_get; pdo_dbstmt_object_handlers.compare = zend_objects_not_comparable; pdo_dbstmt_object_handlers.clone_obj = NULL; + pdo_dbstmt_object_handlers.get_gc = dbstmt_get_gc; pdo_row_ce = register_class_PDORow(); pdo_row_ce->create_object = pdo_row_new; diff --git a/ext/pdo/php_pdo_driver.h b/ext/pdo/php_pdo_driver.h index 0f700c6818da5..c3930f4022464 100644 --- a/ext/pdo/php_pdo_driver.h +++ b/ext/pdo/php_pdo_driver.h @@ -694,6 +694,8 @@ PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh); PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt); PDO_API void php_pdo_stmt_set_column_count(pdo_stmt_t *stmt, int new_count); +PDO_API void php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAMETERS, zend_object *current_object, zend_class_entry *called_scope, zval *new_zval_object); + /* Normalization for fetching long param for driver attributes */ PDO_API bool pdo_get_long_param(zend_long *lval, zval *value); PDO_API bool pdo_get_bool_param(bool *bval, zval *value); diff --git a/ext/pdo/tests/gh16703.phpt b/ext/pdo/tests/gh16703.phpt new file mode 100644 index 0000000000000..e5b4b8640389e --- /dev/null +++ b/ext/pdo/tests/gh16703.phpt @@ -0,0 +1,48 @@ +--TEST-- +GH-16703: Memory leak of setFetchMode() +--EXTENSIONS-- +pdo +--SKIPIF-- + +--FILE-- + PDO::CASE_LOWER, + PDO::ATTR_STATEMENT_CLASS => [TestStmt::class], + ], +); + +$db->exec('CREATE TABLE gh16703 (name varchar(255))'); +$db->exec("INSERT INTO gh16703 (name) VALUES ('test_name')"); + +$stmt = $db->query('SELECT name FROM gh16703'); +$t = $stmt; +$stmt->setFetchMode(PDO::FETCH_INTO, $stmt); +$stmt->fetch(); +echo "done!\n"; +?> +--CLEAN-- +exec('DROP TABLE gh16703'); +?> +--EXPECT-- +done! diff --git a/ext/pdo/tests/pdo_test.inc b/ext/pdo/tests/pdo_test.inc index 5138452ff9c51..0c5d5412a273f 100644 --- a/ext/pdo/tests/pdo_test.inc +++ b/ext/pdo/tests/pdo_test.inc @@ -18,7 +18,7 @@ if (getenv('PDOTEST_DSN') === false) { class PDOTest { // create an instance of the PDO driver, based on // the current environment - static function factory($classname = PDO::class) { + static function factory($classname = PDO::class, bool $useConnectMethod = false) { $dsn = getenv('PDOTEST_DSN'); $user = getenv('PDOTEST_USER'); $pass = getenv('PDOTEST_PASS'); @@ -32,7 +32,11 @@ class PDOTest { if ($user === false) $user = NULL; if ($pass === false) $pass = NULL; - $db = new $classname($dsn, $user, $pass, $attr); + if ($useConnectMethod) { + $db = $classname::connect($dsn, $user, $pass, $attr); + } else { + $db = new $classname($dsn, $user, $pass, $attr); + } if (!$db) { die("Could not create PDO object (DSN=$dsn, user=$user)\n"); @@ -54,12 +58,12 @@ class PDOTest { } } - static function test_factory($file, $classname = PDO::class) { + static function test_factory($file, $classname = PDO::class, bool $useConnectMethod = false) { $config = self::get_config($file); foreach ($config['ENV'] as $k => $v) { putenv("$k=$v"); } - return self::factory($classname); + return self::factory($classname, $useConnectMethod); } static function get_config($file) { diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index 23f17914dcd76..c0e6b5bfb1cf6 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -1219,27 +1219,9 @@ static int pdo_firebird_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) ZVAL_BOOL(val, !isc_version(&H->db, php_firebird_info_cb, NULL)); return 1; - case PDO_ATTR_CLIENT_VERSION: { -#if defined(__GNUC__) || defined(PHP_WIN32) - info_func_t info_func = NULL; -#ifdef __GNUC__ - info_func = (info_func_t)dlsym(RTLD_DEFAULT, "isc_get_client_version"); -#else - HMODULE l = GetModuleHandle("fbclient"); - - if (!l) { - break; - } - info_func = (info_func_t)GetProcAddress(l, "isc_get_client_version"); -#endif - if (info_func) { - info_func(tmp); - ZVAL_STRING(val, tmp); - } -#else - ZVAL_NULL(val); -#endif - } + case PDO_ATTR_CLIENT_VERSION: + isc_get_client_version(tmp); + ZVAL_STRING(val, tmp); return 1; case PDO_ATTR_SERVER_VERSION: diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h index 2b8d00a4e37e6..db7b730ead40d 100644 --- a/ext/pdo_firebird/php_pdo_firebird_int.h +++ b/ext/pdo_firebird/php_pdo_firebird_int.h @@ -45,12 +45,6 @@ /* Firebird API has a couple of missing const decls in its API */ #define const_cast(s) ((char*)(s)) -#ifdef PHP_WIN32 -typedef void (__stdcall *info_func_t)(char*); -#else -typedef void (*info_func_t)(char*); -#endif - #ifndef min #define min(a,b) ((a)<(b)?(a):(b)) #endif diff --git a/ext/pdo_mysql/tests/gh16314.phpt b/ext/pdo_mysql/tests/gh16314.phpt new file mode 100644 index 0000000000000..01955d3ba4a07 --- /dev/null +++ b/ext/pdo_mysql/tests/gh16314.phpt @@ -0,0 +1,67 @@ +--TEST-- +GH-16314 "Pdo\Mysql object is uninitialized" when opening a persistent connection +--EXTENSIONS-- +pdo_mysql +--SKIPIF-- + +--FILE-- + true, + PDO::ATTR_STRINGIFY_FETCHES => true, +]; + +$pdo = MySQLPDOTest::factory(Pdo\Mysql::class, null, $attr, false); +var_dump($pdo->query('SELECT 1;')->fetchAll()); + +$pdo = MySQLPDOTest::factory(Pdo\Mysql::class, null, $attr, true); +var_dump($pdo->query('SELECT 1;')->fetchAll()); + +$pdo = MySQLPDOTest::factory(Pdo::class, null, $attr, false); +var_dump($pdo->query('SELECT 1;')->fetchAll()); + +$pdo = MySQLPDOTest::factory(Pdo::class, null, $attr, true); +var_dump($pdo->query('SELECT 1;')->fetchAll()); +?> +--EXPECT-- +array(1) { + [0]=> + array(2) { + [1]=> + string(1) "1" + [0]=> + string(1) "1" + } +} +array(1) { + [0]=> + array(2) { + [1]=> + string(1) "1" + [0]=> + string(1) "1" + } +} +array(1) { + [0]=> + array(2) { + [1]=> + string(1) "1" + [0]=> + string(1) "1" + } +} +array(1) { + [0]=> + array(2) { + [1]=> + string(1) "1" + [0]=> + string(1) "1" + } +} diff --git a/ext/pdo_mysql/tests/inc/mysql_pdo_test.inc b/ext/pdo_mysql/tests/inc/mysql_pdo_test.inc index 48a7c525a7016..75f299ff9e198 100644 --- a/ext/pdo_mysql/tests/inc/mysql_pdo_test.inc +++ b/ext/pdo_mysql/tests/inc/mysql_pdo_test.inc @@ -8,7 +8,7 @@ foreach ($env as $k => $v) { class MySQLPDOTest extends PDOTest { - static function factory($classname = PDO::class, $mydsn = null, $myAttr = null) { + static function factory($classname = PDO::class, $mydsn = null, $myAttr = null, bool $useConnectMethod = false) { $dsn = self::getDSN($mydsn); $user = PDO_MYSQL_TEST_USER; $pass = PDO_MYSQL_TEST_PASS; @@ -20,7 +20,12 @@ class MySQLPDOTest extends PDOTest { $attr = is_string($attr) && strlen($attr) ? unserialize($attr) : null; } - $db = new $classname($dsn, $user, $pass, $attr); + if ($useConnectMethod) { + $db = $classname::connect($dsn, $user, $pass, $attr); + } else { + $db = new $classname($dsn, $user, $pass, $attr); + } + if (!$db) { die("Could not create PDO object (DSN=$dsn, user=$user)\n"); } diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 7550d080249db..ffe09a6bf16aa 100644 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -689,11 +689,12 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo /* read block. 256 bytes => 255 bytes are actually read, the last 1 is NULL */ rc = SQLGetData(S->stmt, colno+1, C->is_unicode ? SQL_C_BINARY : SQL_C_CHAR, buf2, 256, &C->fetched_len); - /* adjust `used` in case we have length info from the driver */ + /* adjust `used` in case we have proper length info from the driver */ if (orig_fetched_len >= 0 && C->fetched_len >= 0) { SQLLEN fixed_used = orig_fetched_len - C->fetched_len; - ZEND_ASSERT(fixed_used <= used + 1); - used = fixed_used; + if (fixed_used <= used + 1) { + used = fixed_used; + } } /* resize output buffer and reassemble block */ diff --git a/ext/pdo_odbc/tests/gh16450.phpt b/ext/pdo_odbc/tests/gh16450.phpt new file mode 100644 index 0000000000000..e29d7672ee74b --- /dev/null +++ b/ext/pdo_odbc/tests/gh16450.phpt @@ -0,0 +1,35 @@ +--TEST-- +GH-16450 (PDO_ODBC can inject garbage into field values) +--EXTENSIONS-- +pdo_odbc +--SKIPIF-- + +--FILE-- +exec("CREATE TABLE gh16450 (Id INT, MyLongText LONGCHAR)"); +$pdo->exec(sprintf("INSERT INTO gh16450 VALUES (1, '%s')", str_repeat("_", 2048))); +$pdo->exec(sprintf("INSERT INTO gh16450 VALUES (1, '%s')", str_repeat("_", 2049))); + +$stmt = $pdo->query("SELECT MyLongText FROM gh16450"); +var_dump($stmt->fetchColumn(0)); +var_dump($stmt->fetchColumn(0)); +?> +--CLEAN-- +exec("DROP TABLE gh16450"); +?> +--EXPECT-- +string(2048) "________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________" +string(2049) "_________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________" diff --git a/ext/pdo_odbc/tests/long_columns.phpt b/ext/pdo_odbc/tests/long_columns.phpt index 63422c3040886..639e03cb6902a 100644 --- a/ext/pdo_odbc/tests/long_columns.phpt +++ b/ext/pdo_odbc/tests/long_columns.phpt @@ -4,10 +4,8 @@ PDO ODBC "long" columns pdo_odbc --SKIPIF-- --FILE-- create_object = pdo_dbh_new; diff --git a/ext/pdo_pgsql/tests/gh16314.phpt b/ext/pdo_pgsql/tests/gh16314.phpt new file mode 100644 index 0000000000000..0dde12a4e0e3d --- /dev/null +++ b/ext/pdo_pgsql/tests/gh16314.phpt @@ -0,0 +1,65 @@ +--TEST-- +GH-16314 "Pdo\Pgsql object is uninitialized" when opening a persistent connection +--EXTENSIONS-- +pdo_pgsql +--SKIPIF-- + +--FILE-- + true])); + +require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; + +$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt', Pdo\Pgsql::class, false); +var_dump($pdo->query('SELECT 1;')->fetchAll()); + +$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt', Pdo\Pgsql::class, true); +var_dump($pdo->query('SELECT 1;')->fetchAll()); + +$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt', Pdo::class, false); +var_dump($pdo->query('SELECT 1;')->fetchAll()); + +$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt', Pdo::class, true); +var_dump($pdo->query('SELECT 1;')->fetchAll()); +?> +--EXPECT-- +array(1) { + [0]=> + array(2) { + ["?column?"]=> + string(1) "1" + [0]=> + string(1) "1" + } +} +array(1) { + [0]=> + array(2) { + ["?column?"]=> + string(1) "1" + [0]=> + string(1) "1" + } +} +array(1) { + [0]=> + array(2) { + ["?column?"]=> + string(1) "1" + [0]=> + string(1) "1" + } +} +array(1) { + [0]=> + array(2) { + ["?column?"]=> + string(1) "1" + [0]=> + string(1) "1" + } +} diff --git a/ext/pdo_pgsql/tests/result_memory_size.phpt b/ext/pdo_pgsql/tests/result_memory_size.phpt index ce73e4af32664..7b382ea63e8bd 100644 --- a/ext/pdo_pgsql/tests/result_memory_size.phpt +++ b/ext/pdo_pgsql/tests/result_memory_size.phpt @@ -1,5 +1,5 @@ --TEST-- -PDO PgSQL PDOStatement::getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE) +PDO PgSQL PDOStatement::getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE) --EXTENSIONS-- pdo_pgsql --SKIPIF-- @@ -7,7 +7,7 @@ pdo_pgsql require __DIR__ . '/config.inc'; require dirname(__DIR__, 2) . '/pdo/tests/pdo_test.inc'; PDOTest::skip(); -if (!defined('PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE')) die('skip constant PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE does not exist'); +if (!defined('Pgsql::ATTR_RESULT_MEMORY_SIZE')) die('skip constant Pgsql::ATTR_RESULT_MEMORY_SIZE does not exist'); --FILE-- query('select 1'); -$result_1 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE); +$result_1 = $statement->getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE); var_dump($result_1); echo 'Result set with many rows: '; $result = $db->query('select generate_series(1, 10000)'); -$result_2 = $result->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE); +$result_2 = $result->getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE); var_dump($result_2); echo 'Large result sets should require more memory than small ones: '; @@ -31,7 +31,7 @@ var_dump($result_2 > $result_1); echo 'Statements that are not executed should not consume memory: '; $statement = $db->prepare('select 1'); -$result_3 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE); +$result_3 = $statement->getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE); var_dump($result_3); echo 'and should emit Error: '; diff --git a/ext/pdo_sqlite/tests/subclasses/gh_16131.phpt b/ext/pdo_sqlite/tests/subclasses/gh_16131.phpt new file mode 100644 index 0000000000000..601ce24f51521 --- /dev/null +++ b/ext/pdo_sqlite/tests/subclasses/gh_16131.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test calling a PDO sub-class constructor with a different DSN +--EXTENSIONS-- +pdo_pgsql +pdo_sqlite +--FILE-- +getMessage() . "\n"; +} + +class MyPgsql extends Pdo\Pgsql +{ +} + +try { + new MyPgsql('sqlite::memory:'); +} catch (PDOException $e) { + echo $e->getMessage() . "\n"; +} + +?> +--EXPECT-- +Pdo\Pgsql::__construct() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::__construct() or PDO::__construct() instead +MyPgsql::__construct() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::__construct() or PDO::__construct() instead diff --git a/ext/pdo_sqlite/tests/subclasses/pdosqlite_005.phpt b/ext/pdo_sqlite/tests/subclasses/pdosqlite_005.phpt index 3674c2b342239..24120f1d82053 100644 --- a/ext/pdo_sqlite/tests/subclasses/pdosqlite_005.phpt +++ b/ext/pdo_sqlite/tests/subclasses/pdosqlite_005.phpt @@ -14,4 +14,4 @@ try { ?> --EXPECT-- -Pdo\Pgsql::connect() cannot be called when connecting to the "sqlite" driver, either Pdo\Sqlite::connect() or PDO::connect() must be called instead +Pdo\Pgsql::connect() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::connect() or PDO::connect() instead diff --git a/ext/pdo_sqlite/tests/subclasses/pdosqlite_007.phpt b/ext/pdo_sqlite/tests/subclasses/pdosqlite_007.phpt index e4060071ccf7f..58568abe7363c 100644 --- a/ext/pdo_sqlite/tests/subclasses/pdosqlite_007.phpt +++ b/ext/pdo_sqlite/tests/subclasses/pdosqlite_007.phpt @@ -15,4 +15,4 @@ try { ?> --EXPECT-- -MyPDO::connect() cannot be called when connecting to the "sqlite" driver, either Pdo\Sqlite::connect() or PDO::connect() must be called instead +MyPDO::connect() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::connect() or PDO::connect() instead diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 9e57522aeaa72..b50142914ec2d 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1776,7 +1776,7 @@ static zend_result phar_open_from_fp(php_stream* fp, char *fname, size_t fname_l return phar_parse_zipfile(fp, fname, fname_len, alias, alias_len, pphar, error); } - if (got > 512) { + if (got >= 512) { if (phar_is_tar(pos, fname)) { php_stream_rewind(fp); return phar_parse_tarfile(fp, fname, fname_len, alias, alias_len, pphar, compression, error); diff --git a/ext/phar/tar.c b/ext/phar/tar.c index bfbcd4216af21..46f59a6042304 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -249,9 +249,8 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch entry.is_tar = 1; entry.is_crc_checked = 1; entry.phar = myphar; - pos += sizeof(buf); - do { + while (true) { phar_entry_info *newentry; pos = php_stream_tell(fp); @@ -592,6 +591,11 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch } } + /* Only read next header if we're not yet at the end */ + if (php_stream_tell(fp) == totalsize) { + break; + } + read = php_stream_read(fp, buf, sizeof(buf)); if (read != sizeof(buf)) { @@ -602,7 +606,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch phar_destroy_phar_data(myphar); return FAILURE; } - } while (!php_stream_eof(fp)); + } if (zend_hash_str_exists(&(myphar->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1)) { myphar->is_data = 0; diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt index b893c573c3d67..bb747941425a7 100644 --- a/ext/phar/tests/phpinfo_004.phpt +++ b/ext/phar/tests/phpinfo_004.phpt @@ -27,7 +27,7 @@ phpinfo(INFO_MODULES); %a

Phar

- + @@ -49,7 +49,7 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar full %a

Phar

Phar: PHP Archive supportenabled
Phar: PHP Archive support enabled
Phar API version 1.1.1
Phar-based phar archives enabled
Tar-based phar archives enabled
- + diff --git a/ext/phar/tests/tar/gh16695_1.phpt b/ext/phar/tests/tar/gh16695_1.phpt new file mode 100644 index 0000000000000..8ce82bcf28dd9 --- /dev/null +++ b/ext/phar/tests/tar/gh16695_1.phpt @@ -0,0 +1,28 @@ +--TEST-- +GH-16695 (phar:// tar parser and zero-length file header blocks) +--CREDITS-- +hakre +--EXTENSIONS-- +phar +--INI-- +phar.require_hash=0 +--FILE-- + +--CLEAN-- + +--EXPECTF-- +int(512) + +Warning: file_get_contents(%stls): Failed to open stream: phar error: path "tls" is a directory in %s on line %d +bool(false) diff --git a/ext/phar/tests/tar/gh16695_2.phpt b/ext/phar/tests/tar/gh16695_2.phpt new file mode 100644 index 0000000000000..5b7200398c496 --- /dev/null +++ b/ext/phar/tests/tar/gh16695_2.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-16695 (phar:// tar parser and zero-length file header blocks) +--CREDITS-- +hakre +--EXTENSIONS-- +phar +--INI-- +phar.require_hash=0 +--FILE-- + +--CLEAN-- + +--EXPECT-- +int(1024) +string(122) "{"Name":"default","Metadata":{},"Endpoints":{"docker":{"Host":"unix:///run/user/1000/docker.sock","SkipTLSVerify":false}}}" diff --git a/ext/phar/tests/tar/gh16695_3.phpt b/ext/phar/tests/tar/gh16695_3.phpt new file mode 100644 index 0000000000000..eddf697b0137c --- /dev/null +++ b/ext/phar/tests/tar/gh16695_3.phpt @@ -0,0 +1,26 @@ +--TEST-- +GH-16695 (phar:// tar parser and zero-length file header blocks) +--CREDITS-- +hakre +--EXTENSIONS-- +phar +--INI-- +phar.require_hash=0 +--FILE-- + +--CLEAN-- + +--EXPECT-- +int(512) +string(0) "" diff --git a/ext/phar/util.c b/ext/phar/util.c index 8d42fc26a2222..f03f66c1d9dd3 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -36,7 +36,7 @@ #include #include #else -static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t end, char *key, size_t key_len, char **signature, size_t *signature_len, uint32_t sig_type); +static zend_result phar_call_openssl_signverify(bool is_sign, php_stream *fp, zend_off_t end, char *key, size_t key_len, char **signature, size_t *signature_len, uint32_t sig_type); #endif /* for links to relative location, prepend cwd of the entry */ @@ -1427,14 +1427,23 @@ static int phar_hex_str(const char *digest, size_t digest_len, char **signature) /* }}} */ #ifndef PHAR_HAVE_OPENSSL -static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t end, char *key, size_t key_len, char **signature, size_t *signature_len, uint32_t sig_type) /* {{{ */ +static zend_result phar_call_openssl_signverify(bool is_sign, php_stream *fp, zend_off_t end, char *key, size_t key_len, char **signature, size_t *signature_len, uint32_t sig_type) /* {{{ */ { - zend_fcall_info fci; - zend_fcall_info_cache fcc; - zval retval, zp[4], openssl; + zval retval, zp[4]; zend_string *str; - ZVAL_STRINGL(&openssl, is_sign ? "openssl_sign" : "openssl_verify", is_sign ? sizeof("openssl_sign")-1 : sizeof("openssl_verify")-1); + zend_function *fn = NULL; + if (is_sign) { + fn = zend_hash_str_find_ptr(CG(function_table), ZEND_STRL("openssl_sign")); + } else { + fn = zend_hash_str_find_ptr(CG(function_table), ZEND_STRL("openssl_verify")); + } + + /* OpenSSL is not available, even as a shared module */ + if (fn == NULL) { + return FAILURE; + } + if (*signature_len) { ZVAL_STRINGL(&zp[1], *signature, *signature_len); } else { @@ -1461,20 +1470,9 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t zval_ptr_dtor_str(&zp[0]); zval_ptr_dtor_str(&zp[1]); zval_ptr_dtor_str(&zp[2]); - zval_ptr_dtor_str(&openssl); - return FAILURE; - } - - if (FAILURE == zend_fcall_info_init(&openssl, 0, &fci, &fcc, NULL, NULL)) { - zval_ptr_dtor_str(&zp[0]); - zval_ptr_dtor_str(&zp[1]); - zval_ptr_dtor_str(&zp[2]); - zval_ptr_dtor_str(&openssl); return FAILURE; } - fci.param_count = 4; - fci.params = zp; Z_ADDREF(zp[0]); if (is_sign) { ZVAL_NEW_REF(&zp[1], &zp[1]); @@ -1483,17 +1481,8 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t } Z_ADDREF(zp[2]); - fci.retval = &retval; - - if (FAILURE == zend_call_function(&fci, &fcc)) { - zval_ptr_dtor_str(&zp[0]); - zval_ptr_dtor(&zp[1]); - zval_ptr_dtor_str(&zp[2]); - zval_ptr_dtor_str(&openssl); - return FAILURE; - } + zend_call_known_function(fn, NULL, NULL, &retval, /* param_count */ 4, zp, NULL); - zval_ptr_dtor_str(&openssl); Z_DELREF(zp[0]); if (is_sign) { @@ -1507,7 +1496,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t zval_ptr_dtor_str(&zp[2]); switch (Z_TYPE(retval)) { - default: case IS_LONG: zval_ptr_dtor(&zp[1]); if (1 == Z_LVAL(retval)) { @@ -1520,6 +1508,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, zend_off_t zval_ptr_dtor(&zp[1]); return SUCCESS; case IS_FALSE: + default: zval_ptr_dtor(&zp[1]); return FAILURE; } @@ -1585,7 +1574,7 @@ zend_result phar_verify_signature(php_stream *fp, size_t end_of_phar, uint32_t s #ifndef PHAR_HAVE_OPENSSL tempsig = sig_len; - if (FAILURE == phar_call_openssl_signverify(0, fp, end_of_phar, ZSTR_VAL(pubkey), ZSTR_LEN(pubkey), &sig, &tempsig, sig_type)) { + if (FAILURE == phar_call_openssl_signverify(false, fp, end_of_phar, ZSTR_VAL(pubkey), ZSTR_LEN(pubkey), &sig, &tempsig, sig_type)) { zend_string_release_ex(pubkey, 0); if (error) { @@ -1975,7 +1964,7 @@ zend_result phar_create_signature(phar_archive_data *phar, php_stream *fp, char siglen = 0; php_stream_seek(fp, 0, SEEK_END); - if (FAILURE == phar_call_openssl_signverify(1, fp, php_stream_tell(fp), PHAR_G(openssl_privatekey), PHAR_G(openssl_privatekey_len), (char **)&sigbuf, &siglen, phar->sig_flags)) { + 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); } diff --git a/ext/posix/posix.stub.php b/ext/posix/posix.stub.php index d34415107a07f..2ee9cdbc31473 100644 --- a/ext/posix/posix.stub.php +++ b/ext/posix/posix.stub.php @@ -303,6 +303,13 @@ */ const POSIX_PC_SYMLINK_MAX = UNKNOWN; #endif +#ifdef _SC_OPEN_MAX +/** + * @var int + * @cvalue _SC_OPEN_MAX + */ +const POSIX_SC_OPEN_MAX = UNKNOWN; +#endif function posix_kill(int $process_id, int $signal): bool {} diff --git a/ext/posix/posix_arginfo.h b/ext/posix/posix_arginfo.h index 664d822db9eda..dceac3eabc995 100644 --- a/ext/posix/posix_arginfo.h +++ b/ext/posix/posix_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 82caf527a8ec686bc450e5d782bb79275d5a13e3 */ + * Stub hash: 25e0aa769d72988ebca07fff96c8ed1fcb6b7d5e */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_posix_kill, 0, 2, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, process_id, IS_LONG, 0) @@ -461,4 +461,7 @@ static void register_posix_symbols(int module_number) #if defined(_PC_SYMLINK_MAX) REGISTER_LONG_CONSTANT("POSIX_PC_SYMLINK_MAX", _PC_SYMLINK_MAX, CONST_PERSISTENT); #endif +#if defined(_SC_OPEN_MAX) + REGISTER_LONG_CONSTANT("POSIX_SC_OPEN_MAX", _SC_OPEN_MAX, CONST_PERSISTENT); +#endif } diff --git a/ext/posix/tests/posix_sysconf.phpt b/ext/posix/tests/posix_sysconf.phpt index 6acebe1f0e0f3..026aecacc4ef8 100644 --- a/ext/posix/tests/posix_sysconf.phpt +++ b/ext/posix/tests/posix_sysconf.phpt @@ -7,8 +7,10 @@ posix var_dump(posix_sysconf(-1)); var_dump(posix_errno() != 0); var_dump(posix_sysconf(POSIX_SC_NPROCESSORS_ONLN)); +var_dump(posix_sysconf(POSIX_SC_OPEN_MAX) >= 256); ?> --EXPECTF-- int(-1) bool(false) int(%d) +bool(true) diff --git a/ext/readline/readline.c b/ext/readline/readline.c index d94e20db9c32d..30f84d610022f 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -181,7 +181,7 @@ PHP_FUNCTION(readline_info) add_assoc_long(return_value,"attempted_completion_over",rl_attempted_completion_over); } else { if (zend_string_equals_literal_ci(what,"line_buffer")) { - oldstr = rl_line_buffer; + oldstr = strdup(rl_line_buffer ? rl_line_buffer : ""); if (value) { if (!try_convert_to_string(value)) { RETURN_THROWS(); @@ -191,7 +191,8 @@ PHP_FUNCTION(readline_info) rl_line_buffer = malloc(Z_STRLEN_P(value) + 1); } else if (strlen(oldstr) < Z_STRLEN_P(value)) { rl_extend_line_buffer(Z_STRLEN_P(value) + 1); - oldstr = rl_line_buffer; + free(oldstr); + oldstr = strdup(rl_line_buffer ? rl_line_buffer : ""); } memcpy(rl_line_buffer, Z_STRVAL_P(value), Z_STRLEN_P(value) + 1); #else @@ -208,6 +209,7 @@ PHP_FUNCTION(readline_info) #endif } RETVAL_STRING(SAFE_STRING(oldstr)); + free(oldstr); } else if (zend_string_equals_literal_ci(what, "point")) { RETVAL_LONG(rl_point); #ifndef PHP_WIN32 diff --git a/ext/readline/readline.stub.php b/ext/readline/readline.stub.php index 0b31b09006d96..be445df214155 100644 --- a/ext/readline/readline.stub.php +++ b/ext/readline/readline.stub.php @@ -13,9 +13,9 @@ function readline(?string $prompt = null): string|false {} /** @param int|string|bool|null $value */ function readline_info(?string $var_name = null, $value = null): mixed {} -function readline_add_history(string $prompt): bool {} +function readline_add_history(string $prompt): true {} -function readline_clear_history(): bool {} +function readline_clear_history(): true {} #ifdef HAVE_HISTORY_LIST /** @@ -33,7 +33,7 @@ function readline_completion_function(callable $callback): bool {} #ifdef HAVE_RL_CALLBACK_READ_CHAR -function readline_callback_handler_install(string $prompt, callable $callback): bool {} +function readline_callback_handler_install(string $prompt, callable $callback): true {} function readline_callback_read_char(): void {} diff --git a/ext/readline/readline_arginfo.h b/ext/readline/readline_arginfo.h index 804a49eb525a5..c6fa7ee4590fc 100644 --- a/ext/readline/readline_arginfo.h +++ b/ext/readline/readline_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 7b72b1af4217ac8647096cb7e2c239466949cbd2 */ + * Stub hash: 7a314f75d9a89a9ea4d525515bb6bacdf7be6746 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_readline, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, prompt, IS_STRING, 1, "null") @@ -10,11 +10,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_info, 0, 0, IS_MIXED, 0 ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, value, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_add_history, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_add_history, 0, 1, IS_TRUE, 0) ZEND_ARG_TYPE_INFO(0, prompt, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_clear_history, 0, 0, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_clear_history, 0, 0, IS_TRUE, 0) ZEND_END_ARG_INFO() #if defined(HAVE_HISTORY_LIST) @@ -33,7 +33,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_completion_function, 0, ZEND_END_ARG_INFO() #if defined(HAVE_RL_CALLBACK_READ_CHAR) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_callback_handler_install, 0, 2, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_readline_callback_handler_install, 0, 2, IS_TRUE, 0) ZEND_ARG_TYPE_INFO(0, prompt, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0) ZEND_END_ARG_INFO() diff --git a/ext/readline/tests/gh16812.phpt b/ext/readline/tests/gh16812.phpt new file mode 100644 index 0000000000000..e148f731cab51 --- /dev/null +++ b/ext/readline/tests/gh16812.phpt @@ -0,0 +1,15 @@ +--TEST-- +GH-16812 readline_info(): UAF +--EXTENSIONS-- +readline +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(0) "" diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index a5562f165f76e..ecfa20fe0c0c8 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -225,18 +225,26 @@ static void _free_function(zend_function *fptr) /* {{{ */ } /* }}} */ +static void reflection_free_property_reference(property_reference *reference) +{ + zend_string_release_ex(reference->unmangled_name, 0); + efree(reference); +} + +static void reflection_free_parameter_reference(parameter_reference *reference) +{ + _free_function(reference->fptr); + efree(reference); +} + static void reflection_free_objects_storage(zend_object *object) /* {{{ */ { reflection_object *intern = reflection_object_from_obj(object); - parameter_reference *reference; - property_reference *prop_reference; if (intern->ptr) { switch (intern->ref_type) { case REF_TYPE_PARAMETER: - reference = (parameter_reference*)intern->ptr; - _free_function(reference->fptr); - efree(intern->ptr); + reflection_free_parameter_reference(intern->ptr); break; case REF_TYPE_TYPE: { @@ -251,9 +259,7 @@ static void reflection_free_objects_storage(zend_object *object) /* {{{ */ _free_function(intern->ptr); break; case REF_TYPE_PROPERTY: - prop_reference = (property_reference*)intern->ptr; - zend_string_release_ex(prop_reference->unmangled_name, 0); - efree(intern->ptr); + reflection_free_property_reference(intern->ptr); break; case REF_TYPE_ATTRIBUTE: { attribute_reference *attr_ref = intern->ptr; @@ -295,13 +301,6 @@ static zend_object *reflection_objects_new(zend_class_entry *class_type) /* {{{ } /* }}} */ -static zval *reflection_instantiate(zend_class_entry *pce, zval *object) /* {{{ */ -{ - object_init_ex(object, pce); - return object; -} -/* }}} */ - static void _const_string(smart_str *str, const char *name, zval *value, const char *indent); static void _function_string(smart_str *str, zend_function *fptr, zend_class_entry *scope, const char* indent); static void _property_string(smart_str *str, zend_property_info *prop, const char *prop_name, const char* indent); @@ -1162,7 +1161,7 @@ static void reflection_attribute_factory(zval *object, HashTable *attributes, ze reflection_object *intern; attribute_reference *reference; - reflection_instantiate(reflection_attribute_ptr, object); + object_init_ex(object, reflection_attribute_ptr); intern = Z_REFLECTION_P(object); reference = (attribute_reference*) emalloc(sizeof(attribute_reference)); reference->attributes = attributes; @@ -1297,9 +1296,7 @@ static void _function_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) reflection_object *intern; zend_function *mptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); RETURN_BOOL(mptr->common.fn_flags & mask); } @@ -1312,7 +1309,7 @@ PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object) zend_class_entry *reflection_ce = ce->ce_flags & ZEND_ACC_ENUM ? reflection_enum_ptr : reflection_class_ptr; - reflection_instantiate(reflection_ce, object); + object_init_ex(object, reflection_ce); intern = Z_REFLECTION_P(object); intern->ptr = ce; intern->ref_type = REF_TYPE_OTHER; @@ -1321,10 +1318,21 @@ PHPAPI void zend_reflection_class_factory(zend_class_entry *ce, zval *object) } /* }}} */ +/* {{{ reflection_extension_factory_ex */ +static void reflection_extension_factory_ex(zval *object, zend_module_entry *module) +{ + object_init_ex(object, reflection_extension_ptr); + reflection_object *intern = Z_REFLECTION_P(object); + intern->ptr = module; + intern->ref_type = REF_TYPE_OTHER; + intern->ce = NULL; + ZVAL_STRING(reflection_prop_name(object), module->name); +} +/* }}} */ + /* {{{ reflection_extension_factory */ static void reflection_extension_factory(zval *object, const char *name_str) { - reflection_object *intern; size_t name_len = strlen(name_str); zend_string *lcname; struct _zend_module_entry *module; @@ -1337,12 +1345,7 @@ static void reflection_extension_factory(zval *object, const char *name_str) return; } - reflection_instantiate(reflection_extension_ptr, object); - intern = Z_REFLECTION_P(object); - intern->ptr = module; - intern->ref_type = REF_TYPE_OTHER; - intern->ce = NULL; - ZVAL_STRINGL(reflection_prop_name(object), module->name, name_len); + reflection_extension_factory_ex(object, module); } /* }}} */ @@ -1353,7 +1356,7 @@ static void reflection_parameter_factory(zend_function *fptr, zval *closure_obje parameter_reference *reference; zval *prop_name; - reflection_instantiate(reflection_parameter_ptr, object); + object_init_ex(object, reflection_parameter_ptr); intern = Z_REFLECTION_P(object); reference = (parameter_reference*) emalloc(sizeof(parameter_reference)); reference->arg_info = arg_info; @@ -1428,13 +1431,13 @@ static void reflection_type_factory(zend_type type, zval *object, bool legacy_be switch (type_kind) { case INTERSECTION_TYPE: - reflection_instantiate(reflection_intersection_type_ptr, object); + object_init_ex(object, reflection_intersection_type_ptr); break; case UNION_TYPE: - reflection_instantiate(reflection_union_type_ptr, object); + object_init_ex(object, reflection_union_type_ptr); break; case NAMED_TYPE: - reflection_instantiate(reflection_named_type_ptr, object); + object_init_ex(object, reflection_named_type_ptr); break; EMPTY_SWITCH_DEFAULT_CASE(); } @@ -1461,7 +1464,7 @@ static void reflection_type_factory(zend_type type, zval *object, bool legacy_be static void reflection_function_factory(zend_function *function, zval *closure_object, zval *object) { reflection_object *intern; - reflection_instantiate(reflection_function_ptr, object); + object_init_ex(object, reflection_function_ptr); intern = Z_REFLECTION_P(object); intern->ptr = function; intern->ref_type = REF_TYPE_FUNCTION; @@ -1478,7 +1481,7 @@ static void reflection_method_factory(zend_class_entry *ce, zend_function *metho { reflection_object *intern; - reflection_instantiate(reflection_method_ptr, object); + object_init_ex(object, reflection_method_ptr); intern = Z_REFLECTION_P(object); intern->ptr = method; intern->ref_type = REF_TYPE_FUNCTION; @@ -1498,7 +1501,7 @@ static void reflection_property_factory(zend_class_entry *ce, zend_string *name, reflection_object *intern; property_reference *reference; - reflection_instantiate(reflection_property_ptr, object); + object_init_ex(object, reflection_property_ptr); intern = Z_REFLECTION_P(object); reference = (property_reference*) emalloc(sizeof(property_reference)); reference->prop = prop; @@ -1523,7 +1526,7 @@ static void reflection_class_constant_factory(zend_string *name_str, zend_class_ { reflection_object *intern; - reflection_instantiate(reflection_class_constant_ptr, object); + object_init_ex(object, reflection_class_constant_ptr); intern = Z_REFLECTION_P(object); intern->ptr = constant; intern->ref_type = REF_TYPE_CLASS_CONSTANT; @@ -1541,7 +1544,7 @@ static void reflection_enum_case_factory(zend_class_entry *ce, zend_string *name zend_class_entry *case_reflection_class = ce->enum_backing_type == IS_UNDEF ? reflection_enum_unit_case_ptr : reflection_enum_backed_case_ptr; - reflection_instantiate(case_reflection_class, object); + object_init_ex(object, case_reflection_class); intern = Z_REFLECTION_P(object); intern->ptr = constant; intern->ref_type = REF_TYPE_CLASS_CONSTANT; @@ -1685,9 +1688,7 @@ ZEND_METHOD(ReflectionFunction, __toString) zend_function *fptr; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); _function_string(&str, fptr, intern->ce, ""); RETURN_STR(smart_str_extract(&str)); @@ -1700,9 +1701,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getName) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_STR_COPY(fptr->common.function_name); @@ -1715,9 +1714,8 @@ ZEND_METHOD(ReflectionFunctionAbstract, isClosure) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); + GET_REFLECTION_OBJECT_PTR(fptr); RETURN_BOOL(fptr->common.fn_flags & ZEND_ACC_CLOSURE); } @@ -1729,9 +1727,8 @@ ZEND_METHOD(ReflectionFunctionAbstract, getClosureThis) reflection_object *intern; zval* closure_this; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); + GET_REFLECTION_OBJECT(); if (!Z_ISUNDEF(intern->obj)) { closure_this = zend_get_closure_this_ptr(&intern->obj); @@ -1748,9 +1745,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getClosureScopeClass) reflection_object *intern; const zend_function *closure_func; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT(); if (!Z_ISUNDEF(intern->obj)) { closure_func = zend_get_closure_method_def(Z_OBJ(intern->obj)); @@ -1766,9 +1761,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getClosureCalledClass) { reflection_object *intern; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT(); if (!Z_ISUNDEF(intern->obj)) { zend_class_entry *called_scope; @@ -1789,9 +1782,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getClosureUsedVariables) reflection_object *intern; const zend_function *closure_func; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT(); array_init(return_value); @@ -1841,9 +1832,7 @@ ZEND_METHOD(ReflectionFunction, getClosure) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); if (!Z_ISUNDEF(intern->obj)) { @@ -1861,9 +1850,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, isInternal) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_BOOL(fptr->type == ZEND_INTERNAL_FUNCTION); } @@ -1875,9 +1862,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, isUserDefined) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); RETURN_BOOL(fptr->type == ZEND_USER_FUNCTION); } @@ -1899,9 +1884,7 @@ ZEND_METHOD(ReflectionFunction, isAnonymous) /* {{{ Returns whether this function has been disabled or not */ ZEND_METHOD(ReflectionFunction, isDisabled) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); /* A disabled function cannot be queried using Reflection. */ RETURN_FALSE; @@ -1914,9 +1897,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getFileName) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type == ZEND_USER_FUNCTION) { RETURN_STR_COPY(fptr->op_array.filename); @@ -1931,9 +1912,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getStartLine) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type == ZEND_USER_FUNCTION) { RETURN_LONG(fptr->op_array.line_start); @@ -1948,9 +1927,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getEndLine) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); if (fptr->type == ZEND_USER_FUNCTION) { RETURN_LONG(fptr->op_array.line_end); @@ -1965,9 +1942,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getDocComment) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -2010,9 +1985,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getStaticVariables) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); /* Return an empty array in case no static variables exist */ @@ -2118,9 +2091,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, returnsReference) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -2135,9 +2106,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getNumberOfParameters) zend_function *fptr; uint32_t num_args; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -2156,9 +2125,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getNumberOfRequiredParameters) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -2174,9 +2141,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getParameters) uint32_t i, num_args; struct _zend_arg_info *arg_info; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -2216,9 +2181,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getExtension) zend_function *fptr; zend_internal_function *internal; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -2242,9 +2205,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getExtensionName) zend_function *fptr; zend_internal_function *internal; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -2332,9 +2293,7 @@ ZEND_METHOD(ReflectionGenerator, getExecutingLine) zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj); zend_execute_data *ex = generator->execute_data; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); REFLECTION_CHECK_VALID_GENERATOR(ex) @@ -2348,9 +2307,7 @@ ZEND_METHOD(ReflectionGenerator, getExecutingFile) zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj); zend_execute_data *ex = generator->execute_data; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); REFLECTION_CHECK_VALID_GENERATOR(ex) @@ -2364,9 +2321,7 @@ ZEND_METHOD(ReflectionGenerator, getFunction) zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj); zend_function *func = generator->func; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (func->common.fn_flags & ZEND_ACC_CLOSURE) { zval closure; @@ -2386,9 +2341,7 @@ ZEND_METHOD(ReflectionGenerator, getThis) zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj); zend_execute_data *ex = generator->execute_data; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); REFLECTION_CHECK_VALID_GENERATOR(ex) @@ -2407,9 +2360,7 @@ ZEND_METHOD(ReflectionGenerator, getExecutingGenerator) zend_execute_data *ex = generator->execute_data; zend_generator *current; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); REFLECTION_CHECK_VALID_GENERATOR(ex) @@ -2423,9 +2374,7 @@ ZEND_METHOD(ReflectionGenerator, isClosed) zend_generator *generator = (zend_generator *) Z_OBJ(Z_REFLECTION_P(ZEND_THIS)->obj); zend_execute_data *ex = generator->execute_data; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); RETURN_BOOL(ex == NULL); } @@ -2585,6 +2534,10 @@ ZEND_METHOD(ReflectionParameter, __construct) } } + if (intern->ptr) { + reflection_free_parameter_reference(intern->ptr); + } + ref = (parameter_reference*) emalloc(sizeof(parameter_reference)); ref->arg_info = &arg_info[position]; ref->offset = (uint32_t)position; @@ -2594,11 +2547,15 @@ ZEND_METHOD(ReflectionParameter, __construct) intern->ptr = ref; intern->ref_type = REF_TYPE_PARAMETER; intern->ce = ce; + zval_ptr_dtor(&intern->obj); if (reference && is_closure) { ZVAL_COPY_VALUE(&intern->obj, reference); + } else { + ZVAL_UNDEF(&intern->obj); } 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 { @@ -2625,9 +2582,7 @@ ZEND_METHOD(ReflectionParameter, __toString) parameter_reference *param; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); _parameter_string(&str, param->fptr, param->arg_info, param->offset, param->required, ""); RETURN_STR(smart_str_extract(&str)); @@ -2641,9 +2596,7 @@ ZEND_METHOD(ReflectionParameter, getName) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); if (has_internal_arg_info(param->fptr)) { @@ -2660,9 +2613,7 @@ ZEND_METHOD(ReflectionParameter, getDeclaringFunction) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); if (!param->fptr->common.scope) { @@ -2679,9 +2630,7 @@ ZEND_METHOD(ReflectionParameter, getDeclaringClass) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); if (param->fptr->common.scope) { @@ -2697,9 +2646,7 @@ ZEND_METHOD(ReflectionParameter, getClass) parameter_reference *param; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); // TODO: This is going to return null for union types, which is rather odd. @@ -2758,9 +2705,7 @@ ZEND_METHOD(ReflectionParameter, hasType) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_BOOL(ZEND_TYPE_IS_SET(param->arg_info->type)); @@ -2773,9 +2718,7 @@ ZEND_METHOD(ReflectionParameter, getType) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); if (!ZEND_TYPE_IS_SET(param->arg_info->type)) { @@ -2792,9 +2735,7 @@ ZEND_METHOD(ReflectionParameter, isArray) parameter_reference *param; uint32_t type_mask; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); /* BC For iterable */ @@ -2814,9 +2755,7 @@ ZEND_METHOD(ReflectionParameter, isCallable) parameter_reference *param; uint32_t type_mask; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); type_mask = ZEND_TYPE_PURE_MASK_WITHOUT_NULL(param->arg_info->type); @@ -2830,9 +2769,7 @@ ZEND_METHOD(ReflectionParameter, allowsNull) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_BOOL(!ZEND_TYPE_IS_SET(param->arg_info->type) @@ -2846,9 +2783,7 @@ ZEND_METHOD(ReflectionParameter, isPassedByReference) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_BOOL(ZEND_ARG_SEND_MODE(param->arg_info)); @@ -2861,9 +2796,7 @@ ZEND_METHOD(ReflectionParameter, canBePassedByValue) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); /* true if it's ZEND_SEND_BY_VAL or ZEND_SEND_PREFER_REF */ @@ -2887,15 +2820,13 @@ ZEND_METHOD(ReflectionParameter, getAttributes) param->fptr->type == ZEND_USER_FUNCTION ? param->fptr->op_array.filename : NULL); } -/* {{{ Returns whether this parameter is an optional parameter */ +/* {{{ Returns the index of the parameter, starting from 0 */ ZEND_METHOD(ReflectionParameter, getPosition) { reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_LONG(param->offset); @@ -2908,9 +2839,7 @@ ZEND_METHOD(ReflectionParameter, isOptional) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_BOOL(!param->required); @@ -2923,9 +2852,7 @@ ZEND_METHOD(ReflectionParameter, isDefaultValueAvailable) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); @@ -2945,9 +2872,7 @@ ZEND_METHOD(ReflectionParameter, getDefaultValue) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); @@ -2969,9 +2894,7 @@ ZEND_METHOD(ReflectionParameter, isDefaultValueConstant) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); @@ -3001,9 +2924,7 @@ ZEND_METHOD(ReflectionParameter, getDefaultValueConstantName) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); @@ -3043,9 +2964,7 @@ ZEND_METHOD(ReflectionParameter, isVariadic) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_BOOL(ZEND_ARG_IS_VARIADIC(param->arg_info)); @@ -3058,9 +2977,7 @@ ZEND_METHOD(ReflectionParameter, isPromoted) reflection_object *intern; parameter_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_BOOL(ZEND_ARG_IS_PROMOTED(param->arg_info)); @@ -3073,9 +2990,7 @@ ZEND_METHOD(ReflectionType, allowsNull) reflection_object *intern; type_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETVAL_BOOL(ZEND_TYPE_ALLOW_NULL(param->type)); @@ -3105,9 +3020,7 @@ ZEND_METHOD(ReflectionType, __toString) reflection_object *intern; type_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); RETURN_STR(zend_named_reflection_type_to_string(param->type)); @@ -3120,9 +3033,7 @@ ZEND_METHOD(ReflectionNamedType, getName) reflection_object *intern; type_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); if (param->legacy_behavior) { @@ -3138,9 +3049,7 @@ ZEND_METHOD(ReflectionNamedType, isBuiltin) reflection_object *intern; type_reference *param; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); if (ZEND_TYPE_IS_ITERABLE_FALLBACK(param->type)) { @@ -3175,9 +3084,7 @@ ZEND_METHOD(ReflectionUnionType, getTypes) type_reference *param; uint32_t type_mask; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); array_init(return_value); @@ -3235,9 +3142,7 @@ ZEND_METHOD(ReflectionIntersectionType, getTypes) type_reference *param; zend_type *list_type; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(param); ZEND_ASSERT(ZEND_TYPE_HAS_LIST(param->type)); @@ -3376,9 +3281,7 @@ ZEND_METHOD(ReflectionMethod, __toString) zend_function *mptr; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); _function_string(&str, mptr, intern->ce, ""); RETURN_STR(smart_str_extract(&str)); @@ -3581,9 +3484,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, inNamespace) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -3603,9 +3504,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getNamespaceName) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -3628,9 +3527,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getShortName) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -3652,9 +3549,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, hasReturnType) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -3668,9 +3563,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getReturnType) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -3688,9 +3581,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, hasTentativeReturnType) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -3704,9 +3595,7 @@ ZEND_METHOD(ReflectionFunctionAbstract, getTentativeReturnType) reflection_object *intern; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(fptr); @@ -3724,9 +3613,7 @@ ZEND_METHOD(ReflectionMethod, isConstructor) reflection_object *intern; zend_function *mptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); /* we need to check if the ctor is the ctor of the class level we we * looking at since we might be looking at an inherited old style ctor @@ -3741,9 +3628,7 @@ ZEND_METHOD(ReflectionMethod, isDestructor) reflection_object *intern; zend_function *mptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); RETURN_BOOL(zend_string_equals_literal_ci( mptr->common.function_name, ZEND_DESTRUCTOR_FUNC_NAME)); @@ -3758,9 +3643,7 @@ ZEND_METHOD(ReflectionMethod, getModifiers) uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); RETURN_LONG((mptr->common.fn_flags & keep_flags)); @@ -3773,9 +3656,7 @@ ZEND_METHOD(ReflectionMethod, getDeclaringClass) reflection_object *intern; zend_function *mptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); @@ -3789,9 +3670,7 @@ ZEND_METHOD(ReflectionMethod, hasPrototype) reflection_object *intern; zend_function *mptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); RETURN_BOOL(mptr->common.prototype != NULL); @@ -3804,9 +3683,7 @@ ZEND_METHOD(ReflectionMethod, getPrototype) reflection_object *intern; zend_function *mptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(mptr); @@ -3879,9 +3756,7 @@ ZEND_METHOD(ReflectionClassConstant, __toString) zend_class_constant *ref; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -3903,9 +3778,7 @@ ZEND_METHOD(ReflectionClassConstant, __toString) /* {{{ Returns the constant' name */ ZEND_METHOD(ReflectionClassConstant, getName) { - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); zval *name = reflection_prop_name(ZEND_THIS); if (Z_ISUNDEF_P(name)) { @@ -3925,9 +3798,7 @@ ZEND_METHOD(ReflectionClassConstant, getType) reflection_object *intern; zend_class_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -3944,9 +3815,7 @@ ZEND_METHOD(ReflectionClassConstant, hasType) reflection_object *intern; zend_class_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); RETVAL_BOOL(ZEND_TYPE_IS_SET(ref->type)); @@ -3957,9 +3826,7 @@ static void _class_constant_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) / reflection_object *intern; zend_class_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); RETURN_BOOL(ZEND_CLASS_CONST_FLAGS(ref) & mask); } @@ -3999,9 +3866,7 @@ ZEND_METHOD(ReflectionClassConstant, getModifiers) zend_class_constant *ref; uint32_t keep_flags = ZEND_ACC_FINAL | ZEND_ACC_PPP_MASK; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); RETURN_LONG(ZEND_CLASS_CONST_FLAGS(ref) & keep_flags); @@ -4042,9 +3907,7 @@ ZEND_METHOD(ReflectionClassConstant, getDeclaringClass) reflection_object *intern; zend_class_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); zend_reflection_class_factory(ref->ce, return_value); @@ -4057,9 +3920,7 @@ ZEND_METHOD(ReflectionClassConstant, getDocComment) reflection_object *intern; zend_class_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); if (ref->doc_comment) { RETURN_STR_COPY(ref->doc_comment); @@ -4097,9 +3958,7 @@ ZEND_METHOD(ReflectionClassConstant, isDeprecated) reflection_object *intern; zend_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -4128,10 +3987,12 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob object = ZEND_THIS; intern = Z_REFLECTION_P(object); + /* Note: class entry name is interned, no need to destroy them */ if (arg_obj) { ZVAL_STR_COPY(reflection_prop_name(object), arg_obj->ce->name); intern->ptr = arg_obj->ce; if (is_object) { + zval_ptr_dtor(&intern->obj); ZVAL_OBJ_COPY(&intern->obj, arg_obj); } } else { @@ -4205,9 +4066,7 @@ ZEND_METHOD(ReflectionClass, getStaticProperties) zval *prop; zend_string *key; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -4336,9 +4195,7 @@ ZEND_METHOD(ReflectionClass, getDefaultProperties) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); array_init(return_value); if (UNEXPECTED(zend_update_class_constants(ce) != SUCCESS)) { @@ -4356,9 +4213,7 @@ ZEND_METHOD(ReflectionClass, __toString) zend_class_entry *ce; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); _class_string(&str, ce, &intern->obj, ""); RETURN_STR(smart_str_extract(&str)); @@ -4371,9 +4226,7 @@ ZEND_METHOD(ReflectionClass, getName) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); RETURN_STR_COPY(ce->name); @@ -4386,9 +4239,7 @@ ZEND_METHOD(ReflectionClass, isInternal) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); RETURN_BOOL(ce->type == ZEND_INTERNAL_CLASS); } @@ -4400,9 +4251,7 @@ ZEND_METHOD(ReflectionClass, isUserDefined) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); RETURN_BOOL(ce->type == ZEND_USER_CLASS); } @@ -4414,9 +4263,7 @@ ZEND_METHOD(ReflectionClass, isAnonymous) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); RETURN_BOOL(ce->ce_flags & ZEND_ACC_ANON_CLASS); } @@ -4428,9 +4275,7 @@ ZEND_METHOD(ReflectionClass, getFileName) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_CLASS) { RETURN_STR_COPY(ce->info.user.filename); @@ -4445,9 +4290,7 @@ ZEND_METHOD(ReflectionClass, getStartLine) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_CLASS) { RETURN_LONG(ce->info.user.line_start); @@ -4462,9 +4305,7 @@ ZEND_METHOD(ReflectionClass, getEndLine) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->type == ZEND_USER_CLASS) { RETURN_LONG(ce->info.user.line_end); @@ -4479,9 +4320,7 @@ ZEND_METHOD(ReflectionClass, getDocComment) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->doc_comment) { RETURN_STR_COPY(ce->doc_comment); @@ -4510,9 +4349,7 @@ ZEND_METHOD(ReflectionClass, getConstructor) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->constructor) { @@ -4946,9 +4783,7 @@ static void _class_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); RETVAL_BOOL(ce->ce_flags & mask); } @@ -4960,9 +4795,7 @@ ZEND_METHOD(ReflectionClass, isInstantiable) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_ENUM)) { RETURN_FALSE; @@ -4985,9 +4818,7 @@ ZEND_METHOD(ReflectionClass, isCloneable) zend_class_entry *ce; zval obj; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->ce_flags & (ZEND_ACC_INTERFACE | ZEND_ACC_TRAIT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS | ZEND_ACC_ENUM)) { RETURN_FALSE; @@ -5060,9 +4891,7 @@ ZEND_METHOD(ReflectionClass, getModifiers) zend_class_entry *ce; uint32_t keep_flags = ZEND_ACC_FINAL | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_READONLY_CLASS; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); RETURN_LONG((ce->ce_flags & keep_flags)); @@ -5139,9 +4968,7 @@ ZEND_METHOD(ReflectionClass, newInstanceWithoutConstructor) GET_REFLECTION_OBJECT_PTR(ce); - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); if (ce->type == ZEND_INTERNAL_CLASS && ce->create_object != NULL && (ce->ce_flags & ZEND_ACC_FINAL)) { @@ -5402,9 +5229,7 @@ ZEND_METHOD(ReflectionClass, getInterfaces) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->num_interfaces) { @@ -5430,9 +5255,7 @@ ZEND_METHOD(ReflectionClass, getInterfaceNames) zend_class_entry *ce; uint32_t i; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (!ce->num_interfaces) { @@ -5456,9 +5279,7 @@ ZEND_METHOD(ReflectionClass, getTraits) zend_class_entry *ce; uint32_t i; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (!ce->num_traits) { @@ -5487,9 +5308,7 @@ ZEND_METHOD(ReflectionClass, getTraitNames) zend_class_entry *ce; uint32_t i; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (!ce->num_traits) { @@ -5510,9 +5329,7 @@ ZEND_METHOD(ReflectionClass, getTraitAliases) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -5562,9 +5379,7 @@ ZEND_METHOD(ReflectionClass, getParentClass) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); if (ce->parent) { @@ -5652,9 +5467,7 @@ ZEND_METHOD(ReflectionClass, isIterable) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -5673,9 +5486,7 @@ ZEND_METHOD(ReflectionClass, getExtension) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -5691,9 +5502,7 @@ ZEND_METHOD(ReflectionClass, getExtensionName) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -5711,9 +5520,7 @@ ZEND_METHOD(ReflectionClass, inNamespace) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -5729,9 +5536,7 @@ ZEND_METHOD(ReflectionClass, getNamespaceName) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -5750,9 +5555,7 @@ ZEND_METHOD(ReflectionClass, getShortName) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -5818,13 +5621,20 @@ ZEND_METHOD(ReflectionProperty, __construct) } } - ZVAL_STR_COPY(reflection_prop_name(object), name); + zval *prop_name = reflection_prop_name(object); + zval_ptr_dtor(prop_name); + ZVAL_STR_COPY(prop_name, name); + /* Note: class name are always interned, no need to destroy them */ if (dynam_prop == 0) { ZVAL_STR_COPY(reflection_prop_class(object), property_info->ce->name); } else { ZVAL_STR_COPY(reflection_prop_class(object), ce->name); } + if (intern->ptr) { + reflection_free_property_reference(intern->ptr); + } + reference = (property_reference*) emalloc(sizeof(property_reference)); reference->prop = dynam_prop ? NULL : property_info; reference->unmangled_name = zend_string_copy(name); @@ -5841,9 +5651,7 @@ ZEND_METHOD(ReflectionProperty, __toString) property_reference *ref; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); _property_string(&str, ref->prop, ZSTR_VAL(ref->unmangled_name), ""); RETURN_STR(smart_str_extract(&str)); @@ -5856,9 +5664,7 @@ ZEND_METHOD(ReflectionProperty, getName) reflection_object *intern; property_reference *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); RETURN_STR_COPY(ref->unmangled_name); @@ -5870,9 +5676,7 @@ static void _property_check_flag(INTERNAL_FUNCTION_PARAMETERS, int mask) /* {{{ reflection_object *intern; property_reference *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); RETURN_BOOL(prop_get_flags(ref) & mask); } @@ -5936,9 +5740,7 @@ static void _property_check_dynamic(INTERNAL_FUNCTION_PARAMETERS, bool dynamic_t reflection_object *intern; property_reference *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); bool is_dynamic = ref->prop == NULL; RETURN_BOOL(dynamic_true ? is_dynamic : !is_dynamic); @@ -5972,9 +5774,7 @@ ZEND_METHOD(ReflectionProperty, getModifiers) property_reference *ref; uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_PPP_SET_MASK | ZEND_ACC_STATIC | ZEND_ACC_READONLY | ZEND_ACC_ABSTRACT | ZEND_ACC_VIRTUAL | ZEND_ACC_FINAL; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); RETURN_LONG(prop_get_flags(ref) & keep_flags); @@ -6271,6 +6071,30 @@ ZEND_METHOD(ReflectionProperty, skipLazyInitialization) } } +ZEND_METHOD(ReflectionProperty, isLazy) +{ + reflection_object *intern; + property_reference *ref; + zend_object *object; + + GET_REFLECTION_OBJECT_PTR(ref); + + ZEND_PARSE_PARAMETERS_START(1, 1) { + Z_PARAM_OBJ_OF_CLASS(object, intern->ce) + } ZEND_PARSE_PARAMETERS_END(); + + if (!ref->prop || ref->prop->flags & (ZEND_ACC_STATIC | ZEND_ACC_VIRTUAL)) { + RETURN_FALSE; + } + + while (zend_object_is_lazy_proxy(object) + && zend_lazy_object_initialized(object)) { + object = zend_lazy_object_get_instance(object); + } + + RETURN_BOOL(Z_PROP_FLAG_P(OBJ_PROP(object, ref->prop->offset)) & IS_PROP_LAZY); +} + /* {{{ Returns true if property was initialized */ ZEND_METHOD(ReflectionProperty, isInitialized) { @@ -6323,9 +6147,7 @@ ZEND_METHOD(ReflectionProperty, getDeclaringClass) property_reference *ref; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); ce = ref->prop ? ref->prop->ce : intern->ce; @@ -6339,9 +6161,7 @@ ZEND_METHOD(ReflectionProperty, getDocComment) reflection_object *intern; property_reference *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); if (ref->prop && ref->prop->doc_comment) { RETURN_STR_COPY(ref->prop->doc_comment); @@ -6385,9 +6205,7 @@ ZEND_METHOD(ReflectionProperty, getType) reflection_object *intern; property_reference *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -6404,9 +6222,7 @@ ZEND_METHOD(ReflectionProperty, getSettableType) reflection_object *intern; property_reference *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -6446,9 +6262,7 @@ ZEND_METHOD(ReflectionProperty, hasType) reflection_object *intern; property_reference *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -6464,9 +6278,7 @@ ZEND_METHOD(ReflectionProperty, hasDefaultValue) zend_property_info *prop_info; zval *prop; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -6489,9 +6301,7 @@ ZEND_METHOD(ReflectionProperty, getDefaultValue) zend_property_info *prop_info; zval *prop; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); @@ -6646,7 +6456,9 @@ ZEND_METHOD(ReflectionExtension, __construct) RETURN_THROWS(); } free_alloca(lcname, use_heap); - ZVAL_STRING(reflection_prop_name(object), module->name); + zval *prop_name = reflection_prop_name(object); + zval_ptr_dtor(prop_name); + ZVAL_STRING(prop_name, module->name); intern->ptr = module; intern->ref_type = REF_TYPE_OTHER; intern->ce = NULL; @@ -6660,9 +6472,7 @@ ZEND_METHOD(ReflectionExtension, __toString) zend_module_entry *module; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); _extension_string(&str, module, ""); RETURN_STR(smart_str_extract(&str)); @@ -6675,9 +6485,7 @@ ZEND_METHOD(ReflectionExtension, getName) reflection_object *intern; zend_module_entry *module; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); RETURN_STRING(module->name); @@ -6690,9 +6498,7 @@ ZEND_METHOD(ReflectionExtension, getVersion) reflection_object *intern; zend_module_entry *module; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); /* An extension does not necessarily have a version number */ @@ -6712,9 +6518,7 @@ ZEND_METHOD(ReflectionExtension, getFunctions) zval function; zend_function *fptr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); @@ -6735,9 +6539,7 @@ ZEND_METHOD(ReflectionExtension, getConstants) zend_module_entry *module; zend_constant *constant; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); @@ -6773,9 +6575,7 @@ ZEND_METHOD(ReflectionExtension, getINIEntries) zend_module_entry *module; zend_ini_entry *ini_entry; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); @@ -6817,9 +6617,7 @@ ZEND_METHOD(ReflectionExtension, getClasses) zend_string *key; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); @@ -6837,9 +6635,7 @@ ZEND_METHOD(ReflectionExtension, getClassNames) zend_string *key; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); array_init(return_value); @@ -6856,9 +6652,7 @@ ZEND_METHOD(ReflectionExtension, getDependencies) zend_module_entry *module; const zend_module_dep *dep; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); dep = module->deps; @@ -6920,9 +6714,7 @@ ZEND_METHOD(ReflectionExtension, info) reflection_object *intern; zend_module_entry *module; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); php_info_print_module(module); @@ -6935,9 +6727,7 @@ ZEND_METHOD(ReflectionExtension, isPersistent) reflection_object *intern; zend_module_entry *module; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); RETURN_BOOL(module->type == MODULE_PERSISTENT); @@ -6950,9 +6740,7 @@ ZEND_METHOD(ReflectionExtension, isTemporary) reflection_object *intern; zend_module_entry *module; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(module); RETURN_BOOL(module->type == MODULE_TEMPORARY); @@ -6995,9 +6783,7 @@ ZEND_METHOD(ReflectionZendExtension, __toString) zend_extension *extension; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(extension); _zend_extension_string(&str, extension, ""); RETURN_STR(smart_str_extract(&str)); @@ -7010,9 +6796,7 @@ ZEND_METHOD(ReflectionZendExtension, getName) reflection_object *intern; zend_extension *extension; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(extension); RETURN_STRING(extension->name); @@ -7025,9 +6809,7 @@ ZEND_METHOD(ReflectionZendExtension, getVersion) reflection_object *intern; zend_extension *extension; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(extension); if (extension->version) { @@ -7044,9 +6826,7 @@ ZEND_METHOD(ReflectionZendExtension, getAuthor) reflection_object *intern; zend_extension *extension; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(extension); if (extension->author) { @@ -7063,9 +6843,7 @@ ZEND_METHOD(ReflectionZendExtension, getURL) reflection_object *intern; zend_extension *extension; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(extension); if (extension->URL) { @@ -7082,9 +6860,7 @@ ZEND_METHOD(ReflectionZendExtension, getCopyright) reflection_object *intern; zend_extension *extension; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(extension); if (extension->copyright) { @@ -7159,9 +6935,7 @@ ZEND_METHOD(ReflectionReference, getId) unsigned char digest[20]; PHP_SHA1_CTX context; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); intern = Z_REFLECTION_P(ZEND_THIS); if (Z_TYPE(intern->obj) != IS_REFERENCE) { @@ -7204,9 +6978,7 @@ ZEND_METHOD(ReflectionAttribute, __toString) reflection_object *intern; attribute_reference *attr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(attr); @@ -7250,9 +7022,7 @@ ZEND_METHOD(ReflectionAttribute, getName) reflection_object *intern; attribute_reference *attr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(attr); RETURN_STR_COPY(attr->data->name); @@ -7265,9 +7035,7 @@ ZEND_METHOD(ReflectionAttribute, getTarget) reflection_object *intern; attribute_reference *attr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(attr); RETURN_LONG(attr->target); @@ -7280,9 +7048,7 @@ ZEND_METHOD(ReflectionAttribute, isRepeated) reflection_object *intern; attribute_reference *attr; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(attr); RETURN_BOOL(zend_is_attribute_repeated(attr->attributes, attr->data)); @@ -7298,9 +7064,7 @@ ZEND_METHOD(ReflectionAttribute, getArguments) zval tmp; uint32_t i; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(attr); array_init(return_value); @@ -7329,9 +7093,7 @@ ZEND_METHOD(ReflectionAttribute, newInstance) zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(attr); @@ -7451,9 +7213,7 @@ ZEND_METHOD(ReflectionEnum, getCases) zend_string *name; zend_class_constant *constant; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -7472,9 +7232,7 @@ ZEND_METHOD(ReflectionEnum, isBacked) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); RETURN_BOOL(ce->enum_backing_type != IS_UNDEF); @@ -7485,9 +7243,7 @@ ZEND_METHOD(ReflectionEnum, getBackingType) reflection_object *intern; zend_class_entry *ce; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ce); @@ -7523,9 +7279,7 @@ ZEND_METHOD(ReflectionEnumUnitCase, getEnum) reflection_object *intern; zend_class_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); zend_reflection_class_factory(ref->ce, return_value); @@ -7555,9 +7309,7 @@ ZEND_METHOD(ReflectionEnumBackedCase, getBackingValue) reflection_object *intern; zend_class_constant *ref; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(ref); if (Z_TYPE(ref->value) == IS_CONSTANT_AST) { @@ -7760,9 +7512,7 @@ ZEND_METHOD(ReflectionConstant, getName) reflection_object *intern; zend_constant *const_; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(const_); RETURN_STR_COPY(const_->name); @@ -7773,9 +7523,7 @@ ZEND_METHOD(ReflectionConstant, getNamespaceName) reflection_object *intern; zend_constant *const_; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(const_); @@ -7793,9 +7541,7 @@ ZEND_METHOD(ReflectionConstant, getShortName) reflection_object *intern; zend_constant *const_; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(const_); @@ -7814,9 +7560,7 @@ ZEND_METHOD(ReflectionConstant, getValue) reflection_object *intern; zend_constant *const_; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(const_); RETURN_COPY(&const_->value); @@ -7827,23 +7571,86 @@ ZEND_METHOD(ReflectionConstant, isDeprecated) reflection_object *intern; zend_constant *const_; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(const_); RETURN_BOOL(ZEND_CONSTANT_FLAGS(const_) & CONST_DEPRECATED); } +ZEND_METHOD(ReflectionConstant, getFileName) +{ + reflection_object *intern; + zend_constant *const_; + + ZEND_PARSE_PARAMETERS_NONE(); + + GET_REFLECTION_OBJECT_PTR(const_); + if (const_->filename != NULL) { + RETURN_STR_COPY(const_->filename); + } + RETURN_FALSE; +} + +static void reflection_constant_find_ext(INTERNAL_FUNCTION_PARAMETERS, bool only_name) +{ + reflection_object *intern; + zend_constant *const_; + + ZEND_PARSE_PARAMETERS_NONE(); + + GET_REFLECTION_OBJECT_PTR(const_); + int module_number = ZEND_CONSTANT_MODULE_NUMBER(const_); + if (module_number == PHP_USER_CONSTANT) { + // For user constants, ReflectionConstant::getExtension() returns null, + // ReflectionConstant::getExtensionName() returns false + if (only_name) { + RETURN_FALSE; + } + RETURN_NULL(); + } + zend_module_entry *module; + ZEND_HASH_MAP_FOREACH_PTR(&module_registry, module) { + if (module->module_number != module_number) { + continue; + } + if (only_name) { + RETURN_STRING(module->name); + } + reflection_extension_factory_ex(return_value, module); + return; + } ZEND_HASH_FOREACH_END(); + + zend_throw_exception_ex( + reflection_exception_ptr, + 0, + "Unable to locate extension with module_number %d that provides constant %s", + module_number, + ZSTR_VAL(const_->name) + ); + RETURN_THROWS(); +} + +/* {{{ Returns NULL or the extension the constant belongs to */ +ZEND_METHOD(ReflectionConstant, getExtension) +{ + reflection_constant_find_ext(INTERNAL_FUNCTION_PARAM_PASSTHRU, false); +} +/* }}} */ + +/* {{{ Returns false or the name of the extension the constant belongs to */ +ZEND_METHOD(ReflectionConstant, getExtensionName) +{ + reflection_constant_find_ext(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); +} +/* }}} */ + ZEND_METHOD(ReflectionConstant, __toString) { reflection_object *intern; zend_constant *const_; smart_str str = {0}; - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } + ZEND_PARSE_PARAMETERS_NONE(); GET_REFLECTION_OBJECT_PTR(const_); _const_string(&str, ZSTR_VAL(const_->name), &const_->value, ""); diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php index d9acc08d22424..be511d7ee14cd 100644 --- a/ext/reflection/php_reflection.stub.php +++ b/ext/reflection/php_reflection.stub.php @@ -374,7 +374,7 @@ public function newLazyGhost(callable $initializer, int $options = 0): object {} public function newLazyProxy(callable $factory, int $options = 0): object {} - public function resetAsLazyGhost(object $object, callable $factory, int $options = 0): void {} + public function resetAsLazyGhost(object $object, callable $initializer, int $options = 0): void {} public function resetAsLazyProxy(object $object, callable $factory, int $options = 0): void {} @@ -496,6 +496,8 @@ public function setRawValueWithoutLazyInitialization(object $object, mixed $valu public function skipLazyInitialization(object $object): void {} + public function isLazy(object $object): bool {} + /** @tentative-return-type */ public function isInitialized(?object $object = null): bool {} @@ -914,5 +916,11 @@ public function getValue(): mixed {} public function isDeprecated(): bool {} + public function getFileName(): string|false {} + + public function getExtension(): ?ReflectionExtension {} + + public function getExtensionName(): string|false {} + public function __toString(): string {} } diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h index 92d80de5a60ca..d78a685dde9c9 100644 --- a/ext/reflection/php_reflection_arginfo.h +++ b/ext/reflection/php_reflection_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 1cdf310b94e2297a4e426bd4c0c1ab4d5995936d */ + * Stub hash: 3c6be99bb36965139464925a618cb0bf03affa62 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0) ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0) @@ -301,11 +301,15 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionClass_resetAsLazyGhost, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0) - ZEND_ARG_TYPE_INFO(0, factory, IS_CALLABLE, 0) + ZEND_ARG_TYPE_INFO(0, initializer, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") ZEND_END_ARG_INFO() -#define arginfo_class_ReflectionClass_resetAsLazyProxy arginfo_class_ReflectionClass_resetAsLazyGhost +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionClass_resetAsLazyProxy, 0, 2, IS_VOID, 0) + ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0) + ZEND_ARG_TYPE_INFO(0, factory, IS_CALLABLE, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_LONG, 0, "0") +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionClass_initializeLazyObject, 0, 1, IS_OBJECT, 0) ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0) @@ -401,6 +405,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionProperty_skipLaz ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0) ZEND_END_ARG_INFO() +#define arginfo_class_ReflectionProperty_isLazy arginfo_class_ReflectionClass_isUninitializedLazyObject + ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ReflectionProperty_isInitialized, 0, 0, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, object, IS_OBJECT, 1, "null") ZEND_END_ARG_INFO() @@ -703,6 +709,14 @@ ZEND_END_ARG_INFO() #define arginfo_class_ReflectionConstant_isDeprecated arginfo_class_ReflectionFunctionAbstract_hasTentativeReturnType +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_ReflectionConstant_getFileName, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_ReflectionConstant_getExtension, 0, 0, ReflectionExtension, 1) +ZEND_END_ARG_INFO() + +#define arginfo_class_ReflectionConstant_getExtensionName arginfo_class_ReflectionConstant_getFileName + #define arginfo_class_ReflectionConstant___toString arginfo_class_ReflectionFunction___toString ZEND_METHOD(Reflection, getModifierNames); @@ -843,6 +857,7 @@ ZEND_METHOD(ReflectionProperty, getRawValue); ZEND_METHOD(ReflectionProperty, setRawValue); ZEND_METHOD(ReflectionProperty, setRawValueWithoutLazyInitialization); ZEND_METHOD(ReflectionProperty, skipLazyInitialization); +ZEND_METHOD(ReflectionProperty, isLazy); ZEND_METHOD(ReflectionProperty, isInitialized); ZEND_METHOD(ReflectionProperty, isPublic); ZEND_METHOD(ReflectionProperty, isPrivate); @@ -968,6 +983,9 @@ ZEND_METHOD(ReflectionConstant, getNamespaceName); ZEND_METHOD(ReflectionConstant, getShortName); ZEND_METHOD(ReflectionConstant, getValue); ZEND_METHOD(ReflectionConstant, isDeprecated); +ZEND_METHOD(ReflectionConstant, getFileName); +ZEND_METHOD(ReflectionConstant, getExtension); +ZEND_METHOD(ReflectionConstant, getExtensionName); ZEND_METHOD(ReflectionConstant, __toString); static const zend_function_entry class_Reflection_methods[] = { @@ -1140,6 +1158,7 @@ static const zend_function_entry class_ReflectionProperty_methods[] = { ZEND_ME(ReflectionProperty, setRawValue, arginfo_class_ReflectionProperty_setRawValue, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionProperty, setRawValueWithoutLazyInitialization, arginfo_class_ReflectionProperty_setRawValueWithoutLazyInitialization, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionProperty, skipLazyInitialization, arginfo_class_ReflectionProperty_skipLazyInitialization, ZEND_ACC_PUBLIC) + ZEND_ME(ReflectionProperty, isLazy, arginfo_class_ReflectionProperty_isLazy, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionProperty, isInitialized, arginfo_class_ReflectionProperty_isInitialized, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionProperty, isPublic, arginfo_class_ReflectionProperty_isPublic, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionProperty, isPrivate, arginfo_class_ReflectionProperty_isPrivate, ZEND_ACC_PUBLIC) @@ -1332,6 +1351,9 @@ static const zend_function_entry class_ReflectionConstant_methods[] = { ZEND_ME(ReflectionConstant, getShortName, arginfo_class_ReflectionConstant_getShortName, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionConstant, getValue, arginfo_class_ReflectionConstant_getValue, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionConstant, isDeprecated, arginfo_class_ReflectionConstant_isDeprecated, ZEND_ACC_PUBLIC) + ZEND_ME(ReflectionConstant, getFileName, arginfo_class_ReflectionConstant_getFileName, ZEND_ACC_PUBLIC) + ZEND_ME(ReflectionConstant, getExtension, arginfo_class_ReflectionConstant_getExtension, ZEND_ACC_PUBLIC) + ZEND_ME(ReflectionConstant, getExtensionName, arginfo_class_ReflectionConstant_getExtensionName, ZEND_ACC_PUBLIC) ZEND_ME(ReflectionConstant, __toString, arginfo_class_ReflectionConstant___toString, ZEND_ACC_PUBLIC) ZEND_FE_END }; diff --git a/ext/reflection/tests/ReflectionClass_toString_001.phpt b/ext/reflection/tests/ReflectionClass_toString_001.phpt index 9b5c7db436b09..fd5d83e917419 100644 --- a/ext/reflection/tests/ReflectionClass_toString_001.phpt +++ b/ext/reflection/tests/ReflectionClass_toString_001.phpt @@ -354,7 +354,7 @@ Class [ class ReflectionClass implements Stringable, Refle - Parameters [3] { Parameter #0 [ object $object ] - Parameter #1 [ callable $factory ] + Parameter #1 [ callable $initializer ] Parameter #2 [ int $options = 0 ] } - Return [ void ] diff --git a/ext/reflection/tests/ReflectionConstant_getExtension.phpt b/ext/reflection/tests/ReflectionConstant_getExtension.phpt new file mode 100644 index 0000000000000..9cc010461dc57 --- /dev/null +++ b/ext/reflection/tests/ReflectionConstant_getExtension.phpt @@ -0,0 +1,32 @@ +--TEST-- +ReflectionConstant::getExtension() +--EXTENSIONS-- +json +--FILE-- +getExtension()); + +$reflectionConstant = new ReflectionConstant('JSON_ERROR_NONE'); +var_dump($reflectionConstant->getExtension()); + +const CT_CONST = 5; +$reflectionConstant = new ReflectionConstant('CT_CONST'); +var_dump($reflectionConstant->getExtension()); + +define('RT_CONST', 6); +$reflectionConstant = new ReflectionConstant('RT_CONST'); +var_dump($reflectionConstant->getExtension()); +?> +--EXPECTF-- +object(ReflectionExtension)#%d (1) { + ["name"]=> + string(4) "Core" +} +object(ReflectionExtension)#%d (1) { + ["name"]=> + string(4) "json" +} +NULL +NULL diff --git a/ext/reflection/tests/ReflectionConstant_getExtensionName.phpt b/ext/reflection/tests/ReflectionConstant_getExtensionName.phpt new file mode 100644 index 0000000000000..dc4322dce4aba --- /dev/null +++ b/ext/reflection/tests/ReflectionConstant_getExtensionName.phpt @@ -0,0 +1,26 @@ +--TEST-- +ReflectionConstant::getExtensionName() +--EXTENSIONS-- +json +--FILE-- +getExtensionName()); + +$reflectionConstant = new ReflectionConstant('JSON_ERROR_NONE'); +var_dump($reflectionConstant->getExtensionName()); + +const CT_CONST = 5; +$reflectionConstant = new ReflectionConstant('CT_CONST'); +var_dump($reflectionConstant->getExtensionName()); + +define('RT_CONST', 6); +$reflectionConstant = new ReflectionConstant('RT_CONST'); +var_dump($reflectionConstant->getExtensionName()); +?> +--EXPECT-- +string(4) "Core" +string(4) "json" +bool(false) +bool(false) diff --git a/ext/reflection/tests/ReflectionConstant_getFileName.phpt b/ext/reflection/tests/ReflectionConstant_getFileName.phpt new file mode 100644 index 0000000000000..b627acceec4bc --- /dev/null +++ b/ext/reflection/tests/ReflectionConstant_getFileName.phpt @@ -0,0 +1,44 @@ +--TEST-- +ReflectionConstant::getFileName() +--FILE-- +getFileName()); +} + +define('IN_CURRENT_FILE_DEFINED', 42); +const IN_CURRENT_FILE_AST = 123; + +echo "From PHP:\n"; +testConstant('PHP_VERSION'); +testConstant('STDIN'); +testConstant('STDOUT'); +testConstant('STDERR'); + +echo "\nFrom the current file:\n"; +testConstant('IN_CURRENT_FILE_DEFINED'); +testConstant('IN_CURRENT_FILE_AST'); + +echo "\nFrom an included file:\n"; +testConstant('INCLUDED_CONSTANT_DEFINED'); +testConstant('INCLUDED_CONSTANT_AST'); +?> +--EXPECTF-- +From PHP: +PHP_VERSION: bool(false) +STDIN: bool(false) +STDOUT: bool(false) +STDERR: bool(false) + +From the current file: +IN_CURRENT_FILE_DEFINED: string(%d) "%sReflectionConstant_getFileName.php" +IN_CURRENT_FILE_AST: string(%d) "%sReflectionConstant_getFileName.php" + +From an included file: +INCLUDED_CONSTANT_DEFINED: string(%d) "%sincluded5.inc" +INCLUDED_CONSTANT_AST: string(%d) "%sincluded5.inc" diff --git a/ext/reflection/tests/ReflectionExtension_double_construct.phpt b/ext/reflection/tests/ReflectionExtension_double_construct.phpt new file mode 100644 index 0000000000000..7bff11c4b1750 --- /dev/null +++ b/ext/reflection/tests/ReflectionExtension_double_construct.phpt @@ -0,0 +1,20 @@ +--TEST-- +ReflectionExtension double construct call +--FILE-- +__construct('standard'); +var_dump($r); + +?> +--EXPECT-- +object(ReflectionExtension)#1 (1) { + ["name"]=> + string(8) "standard" +} +object(ReflectionExtension)#1 (1) { + ["name"]=> + string(8) "standard" +} diff --git a/ext/reflection/tests/ReflectionObject_double_construct.phpt b/ext/reflection/tests/ReflectionObject_double_construct.phpt new file mode 100644 index 0000000000000..536b145243b1e --- /dev/null +++ b/ext/reflection/tests/ReflectionObject_double_construct.phpt @@ -0,0 +1,21 @@ +--TEST-- +ReflectionObject double construct call +--FILE-- +__construct($obj); +var_dump($r); + +?> +--EXPECT-- +object(ReflectionObject)#2 (1) { + ["name"]=> + string(8) "stdClass" +} +object(ReflectionObject)#2 (1) { + ["name"]=> + string(8) "stdClass" +} diff --git a/ext/reflection/tests/ReflectionParameter_double_construct.phpt b/ext/reflection/tests/ReflectionParameter_double_construct.phpt new file mode 100644 index 0000000000000..cc69e6b10e3c5 --- /dev/null +++ b/ext/reflection/tests/ReflectionParameter_double_construct.phpt @@ -0,0 +1,27 @@ +--TEST-- +ReflectionParameter double construct call +--FILE-- +__construct($closure, 'x'); +var_dump($r); +$r->__construct('ord', 'character'); +var_dump($r); + +?> +--EXPECT-- +object(ReflectionParameter)#2 (1) { + ["name"]=> + string(1) "x" +} +object(ReflectionParameter)#2 (1) { + ["name"]=> + string(1) "x" +} +object(ReflectionParameter)#2 (1) { + ["name"]=> + string(9) "character" +} diff --git a/ext/reflection/tests/ReflectionProperty_double_construct.phpt b/ext/reflection/tests/ReflectionProperty_double_construct.phpt new file mode 100644 index 0000000000000..086f2f781a513 --- /dev/null +++ b/ext/reflection/tests/ReflectionProperty_double_construct.phpt @@ -0,0 +1,24 @@ +--TEST-- +ReflectionProperty double construct call +--FILE-- +__construct(Exception::class, 'message'); +var_dump($r); + +?> +--EXPECT-- +object(ReflectionProperty)#1 (2) { + ["name"]=> + string(7) "message" + ["class"]=> + string(9) "Exception" +} +object(ReflectionProperty)#1 (2) { + ["name"]=> + string(7) "message" + ["class"]=> + string(9) "Exception" +} diff --git a/ext/reflection/tests/included5.inc b/ext/reflection/tests/included5.inc new file mode 100644 index 0000000000000..d406ce0f0f6a5 --- /dev/null +++ b/ext/reflection/tests/included5.inc @@ -0,0 +1,5 @@ + diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 65bf7de204491..dfa7632e5a447 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -291,8 +291,13 @@ PHPAPI zend_result php_session_reset_id(void); zend_ulong num_key; \ zval *struc; +/* Do not use a return statement in `code` because that may leak memory. + * Break out of the loop instead. */ #define PS_ENCODE_LOOP(code) do { \ - HashTable *_ht = Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars))); \ + zval _zv; \ + /* protect against user interference */ \ + ZVAL_COPY(&_zv, Z_REFVAL(PS(http_session_vars))); \ + HashTable *_ht = Z_ARRVAL(_zv); \ ZEND_HASH_FOREACH_KEY(_ht, num_key, key) { \ if (key == NULL) { \ php_error_docref(NULL, E_WARNING, \ @@ -303,6 +308,7 @@ PHPAPI zend_result php_session_reset_id(void); code; \ } \ } ZEND_HASH_FOREACH_END(); \ + zval_ptr_dtor(&_zv); \ } while(0) PHPAPI ZEND_EXTERN_MODULE_GLOBALS(ps) diff --git a/ext/session/session.c b/ext/session/session.c index db3cda305d17f..813c008b5c359 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1079,6 +1079,7 @@ PS_SERIALIZER_ENCODE_FUNC(php) /* {{{ */ { smart_str buf = {0}; php_serialize_data_t var_hash; + bool fail = false; PS_ENCODE_VARS; PHP_VAR_SERIALIZE_INIT(var_hash); @@ -1088,12 +1089,17 @@ PS_SERIALIZER_ENCODE_FUNC(php) /* {{{ */ if (memchr(ZSTR_VAL(key), PS_DELIMITER, ZSTR_LEN(key))) { PHP_VAR_SERIALIZE_DESTROY(var_hash); smart_str_free(&buf); - return NULL; + fail = true; + break; } smart_str_appendc(&buf, PS_DELIMITER); php_var_serialize(&buf, struc, &var_hash); ); + if (fail) { + return NULL; + } + smart_str_0(&buf); PHP_VAR_SERIALIZE_DESTROY(var_hash); diff --git a/ext/session/tests/gh16590.phpt b/ext/session/tests/gh16590.phpt new file mode 100644 index 0000000000000..781f6a78e093e --- /dev/null +++ b/ext/session/tests/gh16590.phpt @@ -0,0 +1,36 @@ +--TEST-- +GH-16590 (UAF in session_encode()) +--EXTENSIONS-- +session +--SKIPIF-- + +--INI-- +session.use_cookies=0 +session.cache_limiter= +session.serialize_handler=php +session.save_handler=files +--FILE-- + +--EXPECTF-- +Warning: session_encode(): Skipping numeric key 0 in %s on line %d + +Warning: session_encode(): Skipping numeric key 1 in %s on line %d +string(15) "Lz|O:1:"C":0:{}" diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 49f3b2b4e67a1..2e47968e6762d 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2479,7 +2479,11 @@ static zval *php_sxe_iterator_current_data(zend_object_iterator *iter) /* {{{ */ { php_sxe_iterator *iterator = (php_sxe_iterator *)iter; - return &iterator->sxe->iter.data; + zval *data = &iterator->sxe->iter.data; + if (Z_ISUNDEF_P(data)) { + return NULL; + } + return data; } /* }}} */ diff --git a/ext/simplexml/tests/gh16808.phpt b/ext/simplexml/tests/gh16808.phpt new file mode 100644 index 0000000000000..be0bc59fb655a --- /dev/null +++ b/ext/simplexml/tests/gh16808.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-16808 (Segmentation fault in RecursiveIteratorIterator->current() with a xml element input) +--EXTENSIONS-- +simplexml +--FILE-- +"); +$test = new RecursiveIteratorIterator($sxe); +var_dump($test->current()); +?> +--EXPECT-- +NULL diff --git a/ext/soap/tests/gh15711.phpt b/ext/soap/tests/gh15711.phpt index a49ff280fee59..b72251cc6f95b 100644 --- a/ext/soap/tests/gh15711.phpt +++ b/ext/soap/tests/gh15711.phpt @@ -33,7 +33,7 @@ class TestSoapClient extends SoapClient { } } -$client = new TestSoapClient('ext/soap/tests/gh15711.wsdl', ['classmap' => ['book' => 'book']]); +$client = new TestSoapClient(__DIR__ . '/gh15711.wsdl', ['classmap' => ['book' => 'book']]); echo "--- Test with backed enum ---\n"; diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index f19672ecd5339..b55d36429b4ef 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -1647,6 +1647,20 @@ */ const SOL_UDPLITE = UNKNOWN; #endif +#if defined(IPPROTO_ICMP) || defined(PHP_WIN32) +/** + * @var int + * @cvalue IPPROTO_ICMP + */ +const IPPROTO_ICMP = UNKNOWN; +#endif +#if defined(IPPROTO_ICMPV6) || defined(PHP_WIN32) +/** + * @var int + * @cvalue IPPROTO_ICMPV6 + */ +const IPPROTO_ICMPV6 = UNKNOWN; +#endif #ifdef HAVE_IPV6 /** diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index 524bf605b56b3..abb6e08721711 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: 08677a3dd11366b55a1c539475adead74109595e */ + * Stub hash: 4fdd210a2de6f3b5df10caf5ac7fefa6aa71926c */ 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) @@ -945,6 +945,12 @@ static void register_sockets_symbols(int module_number) #if defined(IPPROTO_UDPLITE) REGISTER_LONG_CONSTANT("SOL_UDPLITE", IPPROTO_UDPLITE, CONST_PERSISTENT); #endif +#if defined(IPPROTO_ICMP) || defined(PHP_WIN32) + REGISTER_LONG_CONSTANT("IPPROTO_ICMP", IPPROTO_ICMP, CONST_PERSISTENT); +#endif +#if defined(IPPROTO_ICMPV6) || defined(PHP_WIN32) + REGISTER_LONG_CONSTANT("IPPROTO_ICMPV6", IPPROTO_ICMPV6, CONST_PERSISTENT); +#endif #if defined(HAVE_IPV6) REGISTER_LONG_CONSTANT("IPV6_UNICAST_HOPS", IPV6_UNICAST_HOPS, CONST_PERSISTENT); #endif diff --git a/ext/sockets/tests/socket_icmp.phpt b/ext/sockets/tests/socket_icmp.phpt new file mode 100644 index 0000000000000..c6b4026c7381a --- /dev/null +++ b/ext/sockets/tests/socket_icmp.phpt @@ -0,0 +1,57 @@ +--TEST-- +socket_create with IPPROTO_ICMP +--EXTENSIONS-- +sockets +--SKIPIF-- + +--FILE-- +> 16) { + $sum = ($sum & 0xFFFF) + ($sum >> 16); + } + return ~ $sum & 0xFFFF; +}; +$header = pack('C2n3a*', $type, $code, $checksum($header), $identifier, $sequence, $data); + +if (!socket_sendto($socket, $header, strlen($header), 0, $host, 0)) { + die("Unable to send packet: " . socket_strerror(socket_last_error($socket)) . "\n"); +} + +$read = [$socket]; +$write = $except = []; +$timeout = ['sec' => 4, 'usec' => 0]; +if (socket_select($read, $write, $except, $timeout['sec'], $timeout['usec']) > 0) { + $response = ''; + socket_recv($socket, $response, 65535, 0); + var_dump(bin2hex($response)); +} else { + die("Unable to read the response\n"); +} + +socket_close($socket); +?> +--EXPECTF-- +string(64) "%s" diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index ffe8178afa77d..af886944bc49e 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -553,13 +553,15 @@ static void spl_array_unset_dimension_ex(int check_inherited, zend_object *objec if (Z_TYPE_P(data) == IS_INDIRECT) { data = Z_INDIRECT_P(data); if (Z_TYPE_P(data) != IS_UNDEF) { - zval_ptr_dtor(data); + zval garbage; + ZVAL_COPY_VALUE(&garbage, data); ZVAL_UNDEF(data); HT_FLAGS(ht) |= HASH_FLAG_HAS_EMPTY_IND; zend_hash_move_forward_ex(ht, spl_array_get_pos_ptr(ht, intern)); if (spl_array_is_object(intern)) { spl_array_skip_protected(intern, ht); } + zval_ptr_dtor(&garbage); } } else { zend_hash_del(ht, key.key); @@ -931,8 +933,10 @@ static zend_result spl_array_skip_protected(spl_array_object *intern, HashTable static void spl_array_set_array(zval *object, spl_array_object *intern, zval *array, zend_long ar_flags, bool just_array) { /* Handled by ZPP prior to this, or for __unserialize() before passing to here */ ZEND_ASSERT(Z_TYPE_P(array) == IS_ARRAY || Z_TYPE_P(array) == IS_OBJECT); + zval garbage; + ZVAL_UNDEF(&garbage); if (Z_TYPE_P(array) == IS_ARRAY) { - zval_ptr_dtor(&intern->array); + ZVAL_COPY_VALUE(&garbage, &intern->array); if (Z_REFCOUNT_P(array) == 1) { ZVAL_COPY(&intern->array, array); } else { @@ -950,7 +954,7 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar } } else { if (Z_OBJ_HT_P(array) == &spl_handler_ArrayObject) { - zval_ptr_dtor(&intern->array); + ZVAL_COPY_VALUE(&garbage, &intern->array); if (just_array) { spl_array_object *other = Z_SPLARRAY_P(array); ar_flags = other->ar_flags & ~SPL_ARRAY_INT_MASK; @@ -968,15 +972,17 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Overloaded object of type %s is not compatible with %s", ZSTR_VAL(Z_OBJCE_P(array)->name), ZSTR_VAL(intern->std.ce->name)); + ZEND_ASSERT(Z_TYPE(garbage) == IS_UNDEF); return; } if (UNEXPECTED(Z_OBJCE_P(array)->ce_flags & ZEND_ACC_ENUM)) { zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Enums are not compatible with %s", ZSTR_VAL(intern->std.ce->name)); + ZEND_ASSERT(Z_TYPE(garbage) == IS_UNDEF); return; } - zval_ptr_dtor(&intern->array); + ZVAL_COPY_VALUE(&garbage, &intern->array); ZVAL_COPY(&intern->array, array); } } @@ -987,6 +993,8 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar zend_hash_iterator_del(intern->ht_iter); intern->ht_iter = (uint32_t)-1; } + + zval_ptr_dtor(&garbage); } /* }}} */ diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 10134c21e1e90..94b6e0e604bbc 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -636,7 +636,7 @@ static inline HashTable *spl_filesystem_object_get_debug_info(zend_object *objec } if (intern->type == SPL_FS_DIR) { #ifdef HAVE_GLOB - if (php_stream_is(intern->u.dir.dirp, &php_glob_stream_ops)) { + if (intern->u.dir.dirp && php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) { ZVAL_STR_COPY(&tmp, intern->path); } else { ZVAL_FALSE(&tmp); @@ -2016,22 +2016,27 @@ static void spl_filesystem_file_rewind(zval * this_ptr, spl_filesystem_object *i PHP_METHOD(SplFileObject, __construct) { spl_filesystem_object *intern = spl_filesystem_from_obj(Z_OBJ_P(ZEND_THIS)); + zend_string *file_name = NULL; zend_string *open_mode = ZSTR_CHAR('r'); + zval *stream_context = NULL; bool use_include_path = 0; size_t path_len; zend_error_handling error_handling; - intern->u.file.open_mode = ZSTR_CHAR('r'); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|Sbr!", &file_name, &open_mode, &use_include_path, &stream_context) == FAILURE) { + RETURN_THROWS(); + } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "P|Sbr!", - &intern->file_name, &open_mode, - &use_include_path, &intern->u.file.zcontext) == FAILURE) { - intern->u.file.open_mode = NULL; - intern->file_name = NULL; + /* Prevent reinitialization of Object */ + if (UNEXPECTED(intern->u.file.stream)) { + zend_throw_error(NULL, "Cannot call constructor twice"); RETURN_THROWS(); } intern->u.file.open_mode = zend_string_copy(open_mode); + /* file_name and zcontext are copied by spl_filesystem_file_open() */ + intern->file_name = file_name; + intern->u.file.zcontext = stream_context; /* spl_filesystem_file_open() can generate E_WARNINGs which we want to promote to exceptions */ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling); @@ -2070,6 +2075,12 @@ PHP_METHOD(SplTempFileObject, __construct) RETURN_THROWS(); } + /* Prevent reinitialization of Object */ + if (UNEXPECTED(intern->u.file.stream)) { + zend_throw_error(NULL, "Cannot call constructor twice"); + RETURN_THROWS(); + } + if (max_memory < 0) { file_name = ZSTR_INIT_LITERAL("php://memory", 0); } else if (ZEND_NUM_ARGS()) { diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 74ae655b220dc..5a78db2921a81 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -41,10 +41,13 @@ PHPAPI zend_class_entry *spl_ce_SplStack; efree(elem); \ } -#define SPL_LLIST_CHECK_DELREF(elem) if ((elem) && !--SPL_LLIST_RC(elem)) { \ +#define SPL_LLIST_CHECK_DELREF_EX(elem, on_free) if ((elem) && !--SPL_LLIST_RC(elem)) { \ efree(elem); \ + on_free \ } +#define SPL_LLIST_CHECK_DELREF(elem) SPL_LLIST_CHECK_DELREF_EX(elem, ;) + #define SPL_LLIST_ADDREF(elem) SPL_LLIST_RC(elem)++ #define SPL_LLIST_CHECK_ADDREF(elem) if (elem) SPL_LLIST_RC(elem)++ @@ -1013,8 +1016,12 @@ PHP_METHOD(SplDoublyLinkedList, serialize) smart_str_appendc(&buf, ':'); next = current->next; + SPL_LLIST_CHECK_ADDREF(next); + php_var_serialize(&buf, ¤t->data, &var_hash); + SPL_LLIST_CHECK_DELREF_EX(next, break;); + current = next; } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 349410ed9feba..d4e40bf6b684a 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -524,6 +524,20 @@ static zend_result spl_get_iterator_from_aggregate(zval *retval, zend_class_entr return SUCCESS; } +static void spl_RecursiveIteratorIterator_free_iterators(spl_recursive_it_object *object) +{ + if (object->iterators) { + while (object->level >= 0) { + zend_object_iterator *sub_iter = object->iterators[object->level].iterator; + zend_iterator_dtor(sub_iter); + zval_ptr_dtor(&object->iterators[object->level].zobject); + object->level--; + } + efree(object->iterators); + object->iterators = NULL; + } +} + static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *ce_base, zend_class_entry *ce_inner, recursive_it_it_type rit_type) { zval *object = ZEND_THIS; @@ -594,6 +608,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla } intern = Z_SPLRECURSIVE_IT_P(object); + spl_RecursiveIteratorIterator_free_iterators(intern); intern->iterators = emalloc(sizeof(spl_sub_iterator)); intern->level = 0; intern->mode = mode; @@ -640,15 +655,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla intern->iterators[0].getchildren = NULL; if (EG(exception)) { - zend_object_iterator *sub_iter; - - while (intern->level >= 0) { - sub_iter = intern->iterators[intern->level].iterator; - zend_iterator_dtor(sub_iter); - zval_ptr_dtor(&intern->iterators[intern->level--].zobject); - } - efree(intern->iterators); - intern->iterators = NULL; + spl_RecursiveIteratorIterator_free_iterators(intern); } } @@ -912,16 +919,7 @@ static void spl_RecursiveIteratorIterator_free_storage(zend_object *_object) { spl_recursive_it_object *object = spl_recursive_it_from_obj(_object); - if (object->iterators) { - while (object->level >= 0) { - zend_object_iterator *sub_iter = object->iterators[object->level].iterator; - zend_iterator_dtor(sub_iter); - zval_ptr_dtor(&object->iterators[object->level].zobject); - object->level--; - } - efree(object->iterators); - object->iterators = NULL; - } + spl_RecursiveIteratorIterator_free_iterators(object); zend_object_std_dtor(&object->std); for (size_t i = 0; i < 6; i++) { diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index aff414e786491..5222fe2a7fa4d 100644 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -833,11 +833,18 @@ PHP_METHOD(SplObjectStorage, serialize) RETURN_NULL(); } ZVAL_OBJ(&obj, element->obj); + + /* Protect against modification; we need a full copy because the data may be refcounted. */ + zval inf_copy; + ZVAL_COPY(&inf_copy, &element->inf); + php_var_serialize(&buf, &obj, &var_hash); smart_str_appendc(&buf, ','); - php_var_serialize(&buf, &element->inf, &var_hash); + php_var_serialize(&buf, &inf_copy, &var_hash); smart_str_appendc(&buf, ';'); zend_hash_move_forward_ex(&intern->storage, &pos); + + zval_ptr_dtor(&inf_copy); } /* members */ diff --git a/ext/spl/tests/gh14687.phpt b/ext/spl/tests/gh14687.phpt new file mode 100644 index 0000000000000..1e95d6b6517cc --- /dev/null +++ b/ext/spl/tests/gh14687.phpt @@ -0,0 +1,49 @@ +--TEST-- +GH-14687 segfault on debugging SplObjectStorage instance after __destruct. +--CREDITS-- +YuanchengJiang +--EXTENSIONS-- +phar +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- + +--CLEAN-- + +--EXPECT-- +object(SplObjectStorage)#2 (1) { + ["storage":"SplObjectStorage":private]=> + array(1) { + [0]=> + array(2) { + ["obj"]=> + object(Phar)#1 (3) { + ["pathName":"SplFileInfo":private]=> + string(0) "" + ["glob":"DirectoryIterator":private]=> + bool(false) + ["subPathName":"RecursiveDirectoryIterator":private]=> + string(0) "" + } + ["inf"]=> + object(HasDestructor)#3 (0) { + } + } + } +} diff --git a/ext/spl/tests/gh16477-2.phpt b/ext/spl/tests/gh16477-2.phpt new file mode 100644 index 0000000000000..a51b9408c2d44 --- /dev/null +++ b/ext/spl/tests/gh16477-2.phpt @@ -0,0 +1,19 @@ +--TEST-- +GH-16477-2: Memory leak when calling SplTempFileObject::__constructor() twice +--FILE-- +__construct(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +$obj->__debugInfo(); + +?> +DONE +--EXPECT-- +Error: Cannot call constructor twice +DONE diff --git a/ext/spl/tests/gh16477.phpt b/ext/spl/tests/gh16477.phpt new file mode 100644 index 0000000000000..f35c9538e8556 --- /dev/null +++ b/ext/spl/tests/gh16477.phpt @@ -0,0 +1,19 @@ +--TEST-- +GH-16477: Segmentation fault when calling __debugInfo() after failed SplFileObject::__constructor +--FILE-- +__construct(); +} catch (Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +$obj->__debugInfo(); + +?> +DONE +--EXPECT-- +ArgumentCountError: SplFileObject::__construct() expects at least 1 argument, 0 given +DONE diff --git a/ext/spl/tests/gh16574.phpt b/ext/spl/tests/gh16574.phpt new file mode 100644 index 0000000000000..0bcc6611a22a3 --- /dev/null +++ b/ext/spl/tests/gh16574.phpt @@ -0,0 +1,15 @@ +--TEST-- +GH-16574 (Incorrect error "undefined method" messages) +--CREDITS-- +YuanchengJiang +--FILE-- +doesnotexist("x"); +?> +--EXPECTF-- +Fatal error: Uncaught Error: Call to undefined method CachingIterator::doesnotexist() in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d diff --git a/ext/spl/tests/gh16588.phpt b/ext/spl/tests/gh16588.phpt new file mode 100644 index 0000000000000..6cf668716ac32 --- /dev/null +++ b/ext/spl/tests/gh16588.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-16588 (UAF in Observer->serialize) +--CREDITS-- +chibinz +--FILE-- +removeAll($store); + return []; + } +} + +$store = new SplObjectStorage; +$store[new C] = new stdClass; +var_dump($store->serialize()); + +?> +--EXPECT-- +string(47) "x:i:1;O:1:"C":0:{},O:8:"stdClass":0:{};m:a:0:{}" diff --git a/ext/spl/tests/gh16589.phpt b/ext/spl/tests/gh16589.phpt new file mode 100644 index 0000000000000..7b1452e37a461 --- /dev/null +++ b/ext/spl/tests/gh16589.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-16589 (UAF in SplDoublyLinked->serialize()) +--CREDITS-- +chibinz +--FILE-- +pop(); + return []; + } +} + +$list = new SplDoublyLinkedList; +$list->add(0, new C); +$list->add(1, 1); +var_dump($list->serialize()); + +?> +--EXPECT-- +string(17) "i:0;:O:1:"C":0:{}" diff --git a/ext/spl/tests/gh16604_1.phpt b/ext/spl/tests/gh16604_1.phpt new file mode 100644 index 0000000000000..3eb2ca9211eaf --- /dev/null +++ b/ext/spl/tests/gh16604_1.phpt @@ -0,0 +1,15 @@ +--TEST-- +GH-16604 (Memory leaks in SPL constructors) - recursive iterators +--FILE-- +__construct( $traversable ); + +$obj = new RecursiveTreeIterator( $traversable ); +$obj->__construct( $traversable ); + +?> +--EXPECT-- diff --git a/ext/spl/tests/gh16604_2.phpt b/ext/spl/tests/gh16604_2.phpt new file mode 100644 index 0000000000000..703b37ce87df7 --- /dev/null +++ b/ext/spl/tests/gh16604_2.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-16604 (Memory leaks in SPL constructors) - SplFileObject +--FILE-- +__construct(__DIR__.'/gh16604_2.tmp'); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--CLEAN-- + +--EXPECT-- +Cannot call constructor twice diff --git a/ext/spl/tests/gh16646.phpt b/ext/spl/tests/gh16646.phpt new file mode 100644 index 0000000000000..b6cb503d8ed05 --- /dev/null +++ b/ext/spl/tests/gh16646.phpt @@ -0,0 +1,32 @@ +--TEST-- +GH-16646: Use-after-free in ArrayObject::unset() with destructor +--FILE-- +b = $arg; + } +} + +class C { + function __destruct() { + global $arr; + echo __METHOD__, "\n"; + $arr->exchangeArray([]); + } +} + +$arr = new ArrayObject(new B(new C)); +unset($arr["b"]); +var_dump($arr); + +?> +--EXPECT-- +C::__destruct +object(ArrayObject)#1 (1) { + ["storage":"ArrayObject":private]=> + array(0) { + } +} diff --git a/ext/spl/tests/gh16646_2.phpt b/ext/spl/tests/gh16646_2.phpt new file mode 100644 index 0000000000000..d006583500811 --- /dev/null +++ b/ext/spl/tests/gh16646_2.phpt @@ -0,0 +1,25 @@ +--TEST-- +GH-16646: Use-after-free in ArrayObject::exchangeArray() with destructor +--FILE-- +exchangeArray([]); + } +} + +$arr = new ArrayObject(new C); +$arr->exchangeArray([]); +var_dump($arr); + +?> +--EXPECT-- +C::__destruct +object(ArrayObject)#1 (1) { + ["storage":"ArrayObject":private]=> + array(0) { + } +} diff --git a/ext/standard/array.c b/ext/standard/array.c index 8f6418b032731..73a5f1ee4a328 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -700,9 +700,9 @@ static void php_natsort(INTERNAL_FUNCTION_PARAMETERS, int fold_case) /* {{{ */ ZEND_PARSE_PARAMETERS_END(); if (fold_case) { - zend_hash_sort(Z_ARRVAL_P(array), php_array_natural_case_compare, 0); + zend_array_sort(Z_ARRVAL_P(array), php_array_natural_case_compare, 0); } else { - zend_hash_sort(Z_ARRVAL_P(array), php_array_natural_compare, 0); + zend_array_sort(Z_ARRVAL_P(array), php_array_natural_compare, 0); } RETURN_TRUE; @@ -738,7 +738,7 @@ PHP_FUNCTION(asort) cmp = php_get_data_compare_func(sort_type, 0); - zend_hash_sort(Z_ARRVAL_P(array), cmp, 0); + zend_array_sort(Z_ARRVAL_P(array), cmp, 0); RETURN_TRUE; } @@ -759,7 +759,7 @@ PHP_FUNCTION(arsort) cmp = php_get_data_compare_func(sort_type, 1); - zend_hash_sort(Z_ARRVAL_P(array), cmp, 0); + zend_array_sort(Z_ARRVAL_P(array), cmp, 0); RETURN_TRUE; } @@ -780,7 +780,7 @@ PHP_FUNCTION(sort) cmp = php_get_data_compare_func(sort_type, 0); - zend_hash_sort(Z_ARRVAL_P(array), cmp, 1); + zend_array_sort(Z_ARRVAL_P(array), cmp, 1); RETURN_TRUE; } @@ -801,7 +801,7 @@ PHP_FUNCTION(rsort) cmp = php_get_data_compare_func(sort_type, 1); - zend_hash_sort(Z_ARRVAL_P(array), cmp, 1); + zend_array_sort(Z_ARRVAL_P(array), cmp, 1); RETURN_TRUE; } @@ -899,7 +899,7 @@ static void php_usort(INTERNAL_FUNCTION_PARAMETERS, bucket_compare_func_t compar /* Copy array, so the in-place modifications will not be visible to the callback function */ arr = zend_array_dup(arr); - zend_hash_sort(arr, compare_func, renumber); + zend_array_sort(arr, compare_func, renumber); zval garbage; ZVAL_COPY_VALUE(&garbage, array); @@ -6699,7 +6699,7 @@ PHP_FUNCTION(array_find_key) } /* }}} */ -/* {{{ Search within an array and returns true if an element is found. */ +/* {{{ Checks if at least one array element satisfies a callback function. */ PHP_FUNCTION(array_any) { zval *array = NULL; @@ -6719,7 +6719,7 @@ PHP_FUNCTION(array_any) } /* }}} */ -/* {{{ Search within an array and returns true if an element is found. */ +/* {{{ Checks if all array elements satisfy a callback function. */ PHP_FUNCTION(array_all) { zval *array = NULL; diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index dbbf9896f2b73..af6f3664c6943 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1182,6 +1182,7 @@ PHP_FUNCTION(time_nanosleep) RETURN_TRUE; } else if (errno == EINTR) { array_init(return_value); + MSAN_UNPOISON(php_rem); add_assoc_long_ex(return_value, "seconds", sizeof("seconds")-1, php_rem.tv_sec); add_assoc_long_ex(return_value, "nanoseconds", sizeof("nanoseconds")-1, php_rem.tv_nsec); return; diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 68cc86e7b1fa5..19ece98e05216 100644 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -1858,7 +1858,7 @@ function array_udiff_uassoc(array $array, ...$rest): array {} * @prefer-ref $array * @prefer-ref $rest */ -function array_multisort(&$array, &...$rest): bool {} +function array_multisort(&$array, &...$rest): true {} /** @return int|string|array */ function array_rand(array $array, int $num = 1): int|string|array {} @@ -3276,7 +3276,7 @@ function fdiv(float $num1, float $num2): float {} /** * @compile-time-eval */ -function fpow(float $num1, float $num2): float {} +function fpow(float $num, float $exponent): float {} /* microtime.c */ diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index e429281125053..b84e9f8dd7087 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: 504f4172ac1d64535719234888400063eb37361b */ + * Stub hash: e277d3a5699db6aeedb08642720be841dc37d683 */ 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) @@ -308,7 +308,7 @@ ZEND_END_ARG_INFO() #define arginfo_array_udiff_uassoc arginfo_array_intersect_ukey -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_multisort, 0, 1, _IS_BOOL, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_multisort, 0, 1, IS_TRUE, 0) ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, array) ZEND_ARG_VARIADIC_INFO(ZEND_SEND_PREFER_REF, rest) ZEND_END_ARG_INFO() @@ -1724,7 +1724,10 @@ ZEND_END_ARG_INFO() #define arginfo_fdiv arginfo_fmod -#define arginfo_fpow arginfo_fmod +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_fpow, 0, 2, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, num, IS_DOUBLE, 0) + ZEND_ARG_TYPE_INFO(0, exponent, IS_DOUBLE, 0) +ZEND_END_ARG_INFO() #if defined(HAVE_GETTIMEOFDAY) ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_microtime, 0, 0, MAY_BE_STRING|MAY_BE_DOUBLE) diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index 14eb6cda9735a..54687f6cdf307 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -177,7 +177,19 @@ PHPAPI zend_string *php_crypt(const char *password, const int pass_len, const ch if (!crypt_res || (salt[0] == '*' && salt[1] == '0')) { return NULL; - } else { + } + else if (!strcmp(crypt_res, "*")) { + /* Musl crypt() uses "*" as a failure token rather + * than the "*0" that libxcrypt/PHP use. Our test + * suite in particular looks for "*0" in a few places, + * and it would be annoying to handle both values + * explicitly. It seems wise to abstract this detail + * from the end user: if it's annoying for us, imagine + * how annoying it would be in end-user code; not that + * anyone would think of it. */ + return NULL; + } + else { result = zend_string_init(crypt_res, strlen(crypt_res), 0); return result; } diff --git a/ext/standard/dir.c b/ext/standard/dir.c index 1af6efe211a7e..a2a50eab7f51d 100644 --- a/ext/standard/dir.c +++ b/ext/standard/dir.c @@ -48,10 +48,17 @@ php_dir_globals dir_globals; #endif static zend_class_entry *dir_class_entry_ptr; +static zend_object_handlers dir_class_object_handlers; #define Z_DIRECTORY_PATH_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 0) #define Z_DIRECTORY_HANDLE_P(zv) OBJ_PROP_NUM(Z_OBJ_P(zv), 1) +static zend_function *dir_class_get_constructor(zend_object *object) +{ + zend_throw_error(NULL, "Cannot directly construct Directory, use dir() instead"); + return NULL; +} + #define FETCH_DIRP() \ myself = getThis(); \ if (!myself) { \ @@ -115,6 +122,12 @@ PHP_MINIT_FUNCTION(dir) register_dir_symbols(module_number); dir_class_entry_ptr = register_class_Directory(); + dir_class_entry_ptr->default_object_handlers = &dir_class_object_handlers; + + memcpy(&dir_class_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); + dir_class_object_handlers.get_constructor = dir_class_get_constructor; + dir_class_object_handlers.clone_obj = NULL; + dir_class_object_handlers.compare = zend_objects_not_comparable; #ifdef ZTS ts_allocate_id(&dir_globals_id, sizeof(php_dir_globals), NULL, NULL); diff --git a/ext/standard/dir.stub.php b/ext/standard/dir.stub.php index 6177d9fb590e6..457a965352516 100644 --- a/ext/standard/dir.stub.php +++ b/ext/standard/dir.stub.php @@ -87,7 +87,11 @@ */ const SCANDIR_SORT_NONE = UNKNOWN; -class Directory +/** + * @strict-properties + * @not-serializable + */ +final class Directory { public readonly string $path; @@ -95,19 +99,16 @@ class Directory public readonly mixed $handle; /** - * @tentative-return-type * @implementation-alias closedir */ public function close(): void {} /** - * @tentative-return-type * @implementation-alias rewinddir */ public function rewind(): void {} /** - * @tentative-return-type * @implementation-alias readdir */ public function read(): string|false {} diff --git a/ext/standard/dir_arginfo.h b/ext/standard/dir_arginfo.h index 8440c154e60b9..9b293f3cd753f 100644 --- a/ext/standard/dir_arginfo.h +++ b/ext/standard/dir_arginfo.h @@ -1,12 +1,12 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4b0f093770ff9a6cad9db033e0b62b412408b937 */ + * Stub hash: 069117bab1b9502faf516307aa7e80308f7b7f13 */ -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Directory_close, 0, 0, IS_VOID, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Directory_close, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() #define arginfo_class_Directory_rewind arginfo_class_Directory_close -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_Directory_read, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Directory_read, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_END_ARG_INFO() ZEND_FUNCTION(closedir); @@ -58,7 +58,7 @@ static zend_class_entry *register_class_Directory(void) zend_class_entry ce, *class_entry; INIT_CLASS_ENTRY(ce, "Directory", class_Directory_methods); - class_entry = zend_register_internal_class_with_flags(&ce, NULL, 0); + class_entry = zend_register_internal_class_with_flags(&ce, NULL, ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES|ZEND_ACC_NOT_SERIALIZABLE); zval property_path_default_value; ZVAL_UNDEF(&property_path_default_value); diff --git a/ext/standard/string.c b/ext/standard/string.c index 9f7e0ff60d3a8..944b39224aedd 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -1600,11 +1600,11 @@ PHP_FUNCTION(pathinfo) Z_PARAM_LONG(opt) ZEND_PARSE_PARAMETERS_END(); - have_basename = ((opt & PHP_PATHINFO_BASENAME) == PHP_PATHINFO_BASENAME); + have_basename = (opt & PHP_PATHINFO_BASENAME); array_init(&tmp); - if ((opt & PHP_PATHINFO_DIRNAME) == PHP_PATHINFO_DIRNAME) { + if (opt & PHP_PATHINFO_DIRNAME) { dirname = estrndup(path, path_len); php_dirname(dirname, path_len); if (*dirname) { @@ -1618,7 +1618,7 @@ PHP_FUNCTION(pathinfo) add_assoc_str(&tmp, "basename", zend_string_copy(ret)); } - if ((opt & PHP_PATHINFO_EXTENSION) == PHP_PATHINFO_EXTENSION) { + if (opt & PHP_PATHINFO_EXTENSION) { const char *p; ptrdiff_t idx; @@ -1634,7 +1634,7 @@ PHP_FUNCTION(pathinfo) } } - if ((opt & PHP_PATHINFO_FILENAME) == PHP_PATHINFO_FILENAME) { + if (opt & PHP_PATHINFO_FILENAME) { const char *p; ptrdiff_t idx; diff --git a/ext/standard/tests/array/001.phpt b/ext/standard/tests/array/001.phpt index c88aee367fad7..908f707e4b16d 100644 --- a/ext/standard/tests/array/001.phpt +++ b/ext/standard/tests/array/001.phpt @@ -4,7 +4,7 @@ Test array_merge and array_walk precision=14 --FILE-- null, "NULL" => NULL, "\a" => "\a", "\cx" => "\cx", "\e" => "\e", - "\f" => "\f", "\n" =>"\n", "\r" => "\r", "\t" => "\t", "\xhh" => "\xhh", - "\ddd" => "\ddd", "\v" => "\v" - ), - - // array contains combination of capital/small letters - array ('l' => "lemoN", 'O' => "Orange", 'b' => "banana", 'a' => "apple", 'Te' => "Test", - 'T' => "TTTT", 't' => "ttt", 'w' => "ww", 'x' => "x", 'X' => "X", 'o' => "oraNGe", - 'B' => "BANANA" - ) -); - -$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING); - -$count = 1; -echo "\n-- Testing arsort() by supplying various string arrays --\n"; - -// loop through to test arsort() with different arrays -foreach ($various_arrays as $array) { - echo "\n-- Iteration $count --\n"; - - echo "- With default sort_flag -\n"; - $temp_array = $array; - var_dump(arsort($temp_array) ); // expecting : bool(true) - var_dump($temp_array); - - // loop through $flags array and setting all possible flag values - foreach($flags as $key => $flag){ - echo "- Sort_flag = $key -\n"; - $temp_array = $array; - var_dump(arsort($temp_array, $flag) ); // expecting : bool(true) - var_dump($temp_array); - } - $count++; -} - -echo "Done\n"; -?> ---EXPECT-- -*** Testing arsort() : usage variations *** - --- Testing arsort() by supplying various string arrays -- - --- Iteration 1 -- -- With default sort_flag - -bool(true) -array(12) { - ["\xhh"]=> - string(4) "\xhh" - ["\ddd"]=> - string(4) "\ddd" - ["\cx"]=> - string(3) "\cx" - ["\a"]=> - string(2) "\a" - [""]=> - string(1) "" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - ["null"]=> - NULL - ["NULL"]=> - NULL -} -- Sort_flag = SORT_REGULAR - -bool(true) -array(12) { - ["\xhh"]=> - string(4) "\xhh" - ["\ddd"]=> - string(4) "\ddd" - ["\cx"]=> - string(3) "\cx" - ["\a"]=> - string(2) "\a" - [""]=> - string(1) "" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - ["null"]=> - NULL - ["NULL"]=> - NULL -} -- Sort_flag = SORT_STRING - -bool(true) -array(12) { - ["\xhh"]=> - string(4) "\xhh" - ["\ddd"]=> - string(4) "\ddd" - ["\cx"]=> - string(3) "\cx" - ["\a"]=> - string(2) "\a" - [""]=> - string(1) "" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - ["null"]=> - NULL - ["NULL"]=> - NULL -} - --- Iteration 2 -- -- With default sort_flag - -bool(true) -array(12) { - ["x"]=> - string(1) "x" - ["w"]=> - string(2) "ww" - ["t"]=> - string(3) "ttt" - ["o"]=> - string(6) "oraNGe" - ["l"]=> - string(5) "lemoN" - ["b"]=> - string(6) "banana" - ["a"]=> - string(5) "apple" - ["X"]=> - string(1) "X" - ["Te"]=> - string(4) "Test" - ["T"]=> - string(4) "TTTT" - ["O"]=> - string(6) "Orange" - ["B"]=> - string(6) "BANANA" -} -- Sort_flag = SORT_REGULAR - -bool(true) -array(12) { - ["x"]=> - string(1) "x" - ["w"]=> - string(2) "ww" - ["t"]=> - string(3) "ttt" - ["o"]=> - string(6) "oraNGe" - ["l"]=> - string(5) "lemoN" - ["b"]=> - string(6) "banana" - ["a"]=> - string(5) "apple" - ["X"]=> - string(1) "X" - ["Te"]=> - string(4) "Test" - ["T"]=> - string(4) "TTTT" - ["O"]=> - string(6) "Orange" - ["B"]=> - string(6) "BANANA" -} -- Sort_flag = SORT_STRING - -bool(true) -array(12) { - ["x"]=> - string(1) "x" - ["w"]=> - string(2) "ww" - ["t"]=> - string(3) "ttt" - ["o"]=> - string(6) "oraNGe" - ["l"]=> - string(5) "lemoN" - ["b"]=> - string(6) "banana" - ["a"]=> - string(5) "apple" - ["X"]=> - string(1) "X" - ["Te"]=> - string(4) "Test" - ["T"]=> - string(4) "TTTT" - ["O"]=> - string(6) "Orange" - ["B"]=> - string(6) "BANANA" -} -Done diff --git a/ext/standard/tests/array/asort_variation5.phpt b/ext/standard/tests/array/asort_variation5.phpt deleted file mode 100644 index f39c4829b1758..0000000000000 --- a/ext/standard/tests/array/asort_variation5.phpt +++ /dev/null @@ -1,236 +0,0 @@ ---TEST-- -Test asort() function : usage variations - sort strings ---FILE-- - null, "NULL" => NULL, "\a" => "\a", "\cx" => "\cx", "\e" => "\e", - "\f" => "\f", "\n" =>"\n", "\r" => "\r", "\t" => "\t", "\xhh" => "\xhh", - "\ddd" => "\ddd", "\v" => "\v" - ), - - // array contains combination of capital/small letters - array ('l' => "lemoN", 'O' => "Orange", 'b' => "banana", 'a' => "apple", 'Te' => "Test", - 'T' => "TTTT", 't' => "ttt", 'w' => "ww", 'x' => "x", 'X' => "X", 'o' => "oraNGe", - 'B' => "BANANA" - ) -); - -$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING); - -$count = 1; -echo "\n-- Testing asort() by supplying various string arrays --\n"; - -// loop through to test asort() with different arrays -foreach ($various_arrays as $array) { - echo "\n-- Iteration $count --\n"; - - echo "- With default sort_flag -\n"; - $temp_array = $array; - var_dump(asort($temp_array) ); // expecting : bool(true) - var_dump($temp_array); - - // loop through $flags array and setting all possible flag values - foreach($flags as $key => $flag){ - echo "- Sort_flag = $key -\n"; - $temp_array = $array; - var_dump(asort($temp_array, $flag) ); // expecting : bool(true) - var_dump($temp_array); - } - $count++; -} - -echo "Done\n"; -?> ---EXPECT-- -*** Testing asort() : usage variations *** - --- Testing asort() by supplying various string arrays -- - --- Iteration 1 -- -- With default sort_flag - -bool(true) -array(12) { - ["null"]=> - NULL - ["NULL"]=> - NULL - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [""]=> - string(1) "" - ["\a"]=> - string(2) "\a" - ["\cx"]=> - string(3) "\cx" - ["\ddd"]=> - string(4) "\ddd" - ["\xhh"]=> - string(4) "\xhh" -} -- Sort_flag = SORT_REGULAR - -bool(true) -array(12) { - ["null"]=> - NULL - ["NULL"]=> - NULL - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [""]=> - string(1) "" - ["\a"]=> - string(2) "\a" - ["\cx"]=> - string(3) "\cx" - ["\ddd"]=> - string(4) "\ddd" - ["\xhh"]=> - string(4) "\xhh" -} -- Sort_flag = SORT_STRING - -bool(true) -array(12) { - ["null"]=> - NULL - ["NULL"]=> - NULL - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [""]=> - string(1) "" - ["\a"]=> - string(2) "\a" - ["\cx"]=> - string(3) "\cx" - ["\ddd"]=> - string(4) "\ddd" - ["\xhh"]=> - string(4) "\xhh" -} - --- Iteration 2 -- -- With default sort_flag - -bool(true) -array(12) { - ["B"]=> - string(6) "BANANA" - ["O"]=> - string(6) "Orange" - ["T"]=> - string(4) "TTTT" - ["Te"]=> - string(4) "Test" - ["X"]=> - string(1) "X" - ["a"]=> - string(5) "apple" - ["b"]=> - string(6) "banana" - ["l"]=> - string(5) "lemoN" - ["o"]=> - string(6) "oraNGe" - ["t"]=> - string(3) "ttt" - ["w"]=> - string(2) "ww" - ["x"]=> - string(1) "x" -} -- Sort_flag = SORT_REGULAR - -bool(true) -array(12) { - ["B"]=> - string(6) "BANANA" - ["O"]=> - string(6) "Orange" - ["T"]=> - string(4) "TTTT" - ["Te"]=> - string(4) "Test" - ["X"]=> - string(1) "X" - ["a"]=> - string(5) "apple" - ["b"]=> - string(6) "banana" - ["l"]=> - string(5) "lemoN" - ["o"]=> - string(6) "oraNGe" - ["t"]=> - string(3) "ttt" - ["w"]=> - string(2) "ww" - ["x"]=> - string(1) "x" -} -- Sort_flag = SORT_STRING - -bool(true) -array(12) { - ["B"]=> - string(6) "BANANA" - ["O"]=> - string(6) "Orange" - ["T"]=> - string(4) "TTTT" - ["Te"]=> - string(4) "Test" - ["X"]=> - string(1) "X" - ["a"]=> - string(5) "apple" - ["b"]=> - string(6) "banana" - ["l"]=> - string(5) "lemoN" - ["o"]=> - string(6) "oraNGe" - ["t"]=> - string(3) "ttt" - ["w"]=> - string(2) "ww" - ["x"]=> - string(1) "x" -} -Done diff --git a/ext/standard/tests/array/krsort_variation5.phpt b/ext/standard/tests/array/krsort_variation5.phpt deleted file mode 100644 index 7475805f8d4d5..0000000000000 --- a/ext/standard/tests/array/krsort_variation5.phpt +++ /dev/null @@ -1,225 +0,0 @@ ---TEST-- -Test krsort() function : usage variations - sort strings ---FILE-- - null, NULL => NULL, "\a" => "\a", "\cx" => "\cx", "\e" => "\e", - "\f" => "\f", "\n" =>"\n", "\r" => "\r", "\t" => "\t", "\xhh" => "\xhh", - "\ddd" => "\ddd", "\v" => "\v" - ), - - // array containing different strings with key values - array ( 'Lemon' => "lemoN", 'o' => "Orange", 'B' => "banana", 'Apple' => "apple", 'te' => "Test", - 't' => "TTTT", 'T' => "ttt", 'W' => "ww", 'X' => "x", 'x' => "X", 'O' => "oraNGe", - 'B' => "BANANA" - ) -); - -$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING); - -$count = 1; -echo "\n-- Testing krsort() by supplying various string arrays --\n"; - -// loop through to test krsort() with different arrays -foreach ($various_arrays as $array) { - echo "\n-- Iteration $count --\n"; - - echo "- With default sort flag -\n"; - $temp_array = $array; - var_dump(krsort($temp_array) ); // expecting : bool(true) - var_dump($temp_array); - - // loop through $flags array and call krsort() with all possible sort flag values - foreach($flags as $key => $flag){ - echo "- Sort flag = $key -\n"; - $temp_array = $array; - var_dump(krsort($temp_array, $flag) ); // expecting : bool(true) - var_dump($temp_array); - } - $count++; -} - -echo "Done\n"; -?> ---EXPECT-- -*** Testing krsort() : usage variations *** - --- Testing krsort() by supplying various string arrays -- - --- Iteration 1 -- -- With default sort flag - -bool(true) -array(11) { - ["\xhh"]=> - string(4) "\xhh" - ["\ddd"]=> - string(4) "\ddd" - ["\cx"]=> - string(3) "\cx" - ["\a"]=> - string(2) "\a" - [""]=> - string(1) "" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [""]=> - NULL -} -- Sort flag = SORT_REGULAR - -bool(true) -array(11) { - ["\xhh"]=> - string(4) "\xhh" - ["\ddd"]=> - string(4) "\ddd" - ["\cx"]=> - string(3) "\cx" - ["\a"]=> - string(2) "\a" - [""]=> - string(1) "" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [""]=> - NULL -} -- Sort flag = SORT_STRING - -bool(true) -array(11) { - ["\xhh"]=> - string(4) "\xhh" - ["\ddd"]=> - string(4) "\ddd" - ["\cx"]=> - string(3) "\cx" - ["\a"]=> - string(2) "\a" - [""]=> - string(1) "" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [""]=> - NULL -} - --- Iteration 2 -- -- With default sort flag - -bool(true) -array(11) { - ["x"]=> - string(1) "X" - ["te"]=> - string(4) "Test" - ["t"]=> - string(4) "TTTT" - ["o"]=> - string(6) "Orange" - ["X"]=> - string(1) "x" - ["W"]=> - string(2) "ww" - ["T"]=> - string(3) "ttt" - ["O"]=> - string(6) "oraNGe" - ["Lemon"]=> - string(5) "lemoN" - ["B"]=> - string(6) "BANANA" - ["Apple"]=> - string(5) "apple" -} -- Sort flag = SORT_REGULAR - -bool(true) -array(11) { - ["x"]=> - string(1) "X" - ["te"]=> - string(4) "Test" - ["t"]=> - string(4) "TTTT" - ["o"]=> - string(6) "Orange" - ["X"]=> - string(1) "x" - ["W"]=> - string(2) "ww" - ["T"]=> - string(3) "ttt" - ["O"]=> - string(6) "oraNGe" - ["Lemon"]=> - string(5) "lemoN" - ["B"]=> - string(6) "BANANA" - ["Apple"]=> - string(5) "apple" -} -- Sort flag = SORT_STRING - -bool(true) -array(11) { - ["x"]=> - string(1) "X" - ["te"]=> - string(4) "Test" - ["t"]=> - string(4) "TTTT" - ["o"]=> - string(6) "Orange" - ["X"]=> - string(1) "x" - ["W"]=> - string(2) "ww" - ["T"]=> - string(3) "ttt" - ["O"]=> - string(6) "oraNGe" - ["Lemon"]=> - string(5) "lemoN" - ["B"]=> - string(6) "BANANA" - ["Apple"]=> - string(5) "apple" -} -Done diff --git a/ext/standard/tests/array/ksort_variation5.phpt b/ext/standard/tests/array/ksort_variation5.phpt deleted file mode 100644 index 0538043744228..0000000000000 --- a/ext/standard/tests/array/ksort_variation5.phpt +++ /dev/null @@ -1,225 +0,0 @@ ---TEST-- -Test ksort() function : usage variations - sort strings ---FILE-- - null, NULL => NULL, "\a" => "\a", "\cx" => "\cx", "\e" => "\e", - "\f" => "\f", "\n" =>"\n", "\r" => "\r", "\t" => "\t", "\xhh" => "\xhh", - "\ddd" => "\ddd", "\v" => "\v" - ), - - // array containing different strings with key values - array ( 'Lemon' => "lemoN", 'o' => "Orange", 'B' => "banana", 'Apple' => "apple", 'te' => "Test", - 't' => "TTTT", 'T' => "ttt", 'W' => "ww", 'X' => "x", 'x' => "X", 'O' => "oraNGe", - 'B' => "BANANA" - ) -); - -$flags = array("SORT_REGULAR" => SORT_REGULAR, "SORT_STRING" => SORT_STRING); - -$count = 1; -echo "\n-- Testing ksort() by supplying various string arrays --\n"; - -// loop through to test ksort() with different arrays -foreach ($various_arrays as $array) { - echo "\n-- Iteration $count --\n"; - - echo "- With default sort flag -\n"; - $temp_array = $array; - var_dump(ksort($temp_array) ); // expecting : bool(true) - var_dump($temp_array); - - // loop through $flags array and call ksort() with all possible sort flag values - foreach($flags as $key => $flag){ - echo "- Sort flag = $key -\n"; - $temp_array = $array; - var_dump(ksort($temp_array, $flag) ); // expecting : bool(true) - var_dump($temp_array); - } - $count++; -} - -echo "Done\n"; -?> ---EXPECT-- -*** Testing ksort() : usage variations *** - --- Testing ksort() by supplying various string arrays -- - --- Iteration 1 -- -- With default sort flag - -bool(true) -array(11) { - [""]=> - NULL - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [""]=> - string(1) "" - ["\a"]=> - string(2) "\a" - ["\cx"]=> - string(3) "\cx" - ["\ddd"]=> - string(4) "\ddd" - ["\xhh"]=> - string(4) "\xhh" -} -- Sort flag = SORT_REGULAR - -bool(true) -array(11) { - [""]=> - NULL - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [""]=> - string(1) "" - ["\a"]=> - string(2) "\a" - ["\cx"]=> - string(3) "\cx" - ["\ddd"]=> - string(4) "\ddd" - ["\xhh"]=> - string(4) "\xhh" -} -- Sort flag = SORT_STRING - -bool(true) -array(11) { - [""]=> - NULL - [" "]=> - string(1) " " - [" -"]=> - string(1) " -" - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [" "]=> - string(1) " " - [""]=> - string(1) "" - ["\a"]=> - string(2) "\a" - ["\cx"]=> - string(3) "\cx" - ["\ddd"]=> - string(4) "\ddd" - ["\xhh"]=> - string(4) "\xhh" -} - --- Iteration 2 -- -- With default sort flag - -bool(true) -array(11) { - ["Apple"]=> - string(5) "apple" - ["B"]=> - string(6) "BANANA" - ["Lemon"]=> - string(5) "lemoN" - ["O"]=> - string(6) "oraNGe" - ["T"]=> - string(3) "ttt" - ["W"]=> - string(2) "ww" - ["X"]=> - string(1) "x" - ["o"]=> - string(6) "Orange" - ["t"]=> - string(4) "TTTT" - ["te"]=> - string(4) "Test" - ["x"]=> - string(1) "X" -} -- Sort flag = SORT_REGULAR - -bool(true) -array(11) { - ["Apple"]=> - string(5) "apple" - ["B"]=> - string(6) "BANANA" - ["Lemon"]=> - string(5) "lemoN" - ["O"]=> - string(6) "oraNGe" - ["T"]=> - string(3) "ttt" - ["W"]=> - string(2) "ww" - ["X"]=> - string(1) "x" - ["o"]=> - string(6) "Orange" - ["t"]=> - string(4) "TTTT" - ["te"]=> - string(4) "Test" - ["x"]=> - string(1) "X" -} -- Sort flag = SORT_STRING - -bool(true) -array(11) { - ["Apple"]=> - string(5) "apple" - ["B"]=> - string(6) "BANANA" - ["Lemon"]=> - string(5) "lemoN" - ["O"]=> - string(6) "oraNGe" - ["T"]=> - string(3) "ttt" - ["W"]=> - string(2) "ww" - ["X"]=> - string(1) "x" - ["o"]=> - string(6) "Orange" - ["t"]=> - string(4) "TTTT" - ["te"]=> - string(4) "Test" - ["x"]=> - string(1) "X" -} -Done diff --git a/ext/standard/tests/array/rsort_variation5.phpt b/ext/standard/tests/array/rsort_variation5.phpt deleted file mode 100644 index 6b05443b520bd..0000000000000 --- a/ext/standard/tests/array/rsort_variation5.phpt +++ /dev/null @@ -1,215 +0,0 @@ ---TEST-- -Test rsort() function : usage variations - String values ---FILE-- - SORT_REGULAR, "SORT_STRING" => SORT_STRING); - -$count = 1; -// loop through to test rsort() with different arrays -foreach ($various_arrays as $array) { - echo "\n-- Iteration $count --\n"; - - echo "- With Default sort flag -\n"; - $temp_array = $array; - var_dump(rsort($temp_array) ); - var_dump($temp_array); - - // loop through $flags array and setting all possible flag values - foreach($flags as $key => $flag){ - echo "- Sort flag = $key -\n"; - - $temp_array = $array; - var_dump(rsort($temp_array, $flag) ); - var_dump($temp_array); - } - $count++; -} - -echo "Done"; -?> ---EXPECT-- -*** Testing rsort() : variation *** - --- Iteration 1 -- -- With Default sort flag - -bool(true) -array(11) { - [0]=> - string(4) "\xhh" - [1]=> - string(4) "\ddd" - [2]=> - string(3) "\cx" - [3]=> - string(2) "\a" - [4]=> - string(1) "" - [5]=> - string(1) " " - [6]=> - string(1) " " - [7]=> - string(1) " -" - [8]=> - string(1) " " - [9]=> - NULL - [10]=> - NULL -} -- Sort flag = SORT_REGULAR - -bool(true) -array(11) { - [0]=> - string(4) "\xhh" - [1]=> - string(4) "\ddd" - [2]=> - string(3) "\cx" - [3]=> - string(2) "\a" - [4]=> - string(1) "" - [5]=> - string(1) " " - [6]=> - string(1) " " - [7]=> - string(1) " -" - [8]=> - string(1) " " - [9]=> - NULL - [10]=> - NULL -} -- Sort flag = SORT_STRING - -bool(true) -array(11) { - [0]=> - string(4) "\xhh" - [1]=> - string(4) "\ddd" - [2]=> - string(3) "\cx" - [3]=> - string(2) "\a" - [4]=> - string(1) "" - [5]=> - string(1) " " - [6]=> - string(1) " " - [7]=> - string(1) " -" - [8]=> - string(1) " " - [9]=> - NULL - [10]=> - NULL -} - --- Iteration 2 -- -- With Default sort flag - -bool(true) -array(12) { - [0]=> - string(1) "x" - [1]=> - string(2) "ww" - [2]=> - string(3) "ttt" - [3]=> - string(6) "oraNGe" - [4]=> - string(5) "lemoN" - [5]=> - string(6) "banana" - [6]=> - string(5) "apple" - [7]=> - string(1) "X" - [8]=> - string(4) "Test" - [9]=> - string(4) "TTTT" - [10]=> - string(6) "Orange" - [11]=> - string(6) "BANANA" -} -- Sort flag = SORT_REGULAR - -bool(true) -array(12) { - [0]=> - string(1) "x" - [1]=> - string(2) "ww" - [2]=> - string(3) "ttt" - [3]=> - string(6) "oraNGe" - [4]=> - string(5) "lemoN" - [5]=> - string(6) "banana" - [6]=> - string(5) "apple" - [7]=> - string(1) "X" - [8]=> - string(4) "Test" - [9]=> - string(4) "TTTT" - [10]=> - string(6) "Orange" - [11]=> - string(6) "BANANA" -} -- Sort flag = SORT_STRING - -bool(true) -array(12) { - [0]=> - string(1) "x" - [1]=> - string(2) "ww" - [2]=> - string(3) "ttt" - [3]=> - string(6) "oraNGe" - [4]=> - string(5) "lemoN" - [5]=> - string(6) "banana" - [6]=> - string(5) "apple" - [7]=> - string(1) "X" - [8]=> - string(4) "Test" - [9]=> - string(4) "TTTT" - [10]=> - string(6) "Orange" - [11]=> - string(6) "BANANA" -} -Done diff --git a/ext/standard/tests/array/array_multisort_basic1.phpt b/ext/standard/tests/array/sort/array_multisort_basic1.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_basic1.phpt rename to ext/standard/tests/array/sort/array_multisort_basic1.phpt diff --git a/ext/standard/tests/array/array_multisort_basic2.phpt b/ext/standard/tests/array/sort/array_multisort_basic2.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_basic2.phpt rename to ext/standard/tests/array/sort/array_multisort_basic2.phpt diff --git a/ext/standard/tests/array/array_multisort_case.phpt b/ext/standard/tests/array/sort/array_multisort_case.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_case.phpt rename to ext/standard/tests/array/sort/array_multisort_case.phpt diff --git a/ext/standard/tests/array/array_multisort_error.phpt b/ext/standard/tests/array/sort/array_multisort_error.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_error.phpt rename to ext/standard/tests/array/sort/array_multisort_error.phpt diff --git a/ext/standard/tests/array/array_multisort_incase.phpt b/ext/standard/tests/array/sort/array_multisort_incase.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_incase.phpt rename to ext/standard/tests/array/sort/array_multisort_incase.phpt diff --git a/ext/standard/tests/array/array_multisort_natural.phpt b/ext/standard/tests/array/sort/array_multisort_natural.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_natural.phpt rename to ext/standard/tests/array/sort/array_multisort_natural.phpt diff --git a/ext/standard/tests/array/array_multisort_natural_case.phpt b/ext/standard/tests/array/sort/array_multisort_natural_case.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_natural_case.phpt rename to ext/standard/tests/array/sort/array_multisort_natural_case.phpt diff --git a/ext/standard/tests/array/array_multisort_natural_incase.phpt b/ext/standard/tests/array/sort/array_multisort_natural_incase.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_natural_incase.phpt rename to ext/standard/tests/array/sort/array_multisort_natural_incase.phpt diff --git a/ext/standard/tests/array/array_multisort_stability.phpt b/ext/standard/tests/array/sort/array_multisort_stability.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_stability.phpt rename to ext/standard/tests/array/sort/array_multisort_stability.phpt diff --git a/ext/standard/tests/array/array_multisort_variation1.phpt b/ext/standard/tests/array/sort/array_multisort_variation1.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation1.phpt rename to ext/standard/tests/array/sort/array_multisort_variation1.phpt diff --git a/ext/standard/tests/array/array_multisort_variation10.phpt b/ext/standard/tests/array/sort/array_multisort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation10.phpt rename to ext/standard/tests/array/sort/array_multisort_variation10.phpt diff --git a/ext/standard/tests/array/array_multisort_variation11.phpt b/ext/standard/tests/array/sort/array_multisort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation11.phpt rename to ext/standard/tests/array/sort/array_multisort_variation11.phpt diff --git a/ext/standard/tests/array/array_multisort_variation2.phpt b/ext/standard/tests/array/sort/array_multisort_variation2.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation2.phpt rename to ext/standard/tests/array/sort/array_multisort_variation2.phpt diff --git a/ext/standard/tests/array/array_multisort_variation3.phpt b/ext/standard/tests/array/sort/array_multisort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation3.phpt rename to ext/standard/tests/array/sort/array_multisort_variation3.phpt diff --git a/ext/standard/tests/array/array_multisort_variation4.phpt b/ext/standard/tests/array/sort/array_multisort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation4.phpt rename to ext/standard/tests/array/sort/array_multisort_variation4.phpt diff --git a/ext/standard/tests/array/array_multisort_variation5.phpt b/ext/standard/tests/array/sort/array_multisort_variation5.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation5.phpt rename to ext/standard/tests/array/sort/array_multisort_variation5.phpt diff --git a/ext/standard/tests/array/array_multisort_variation6.phpt b/ext/standard/tests/array/sort/array_multisort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation6.phpt rename to ext/standard/tests/array/sort/array_multisort_variation6.phpt diff --git a/ext/standard/tests/array/array_multisort_variation7.phpt b/ext/standard/tests/array/sort/array_multisort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation7.phpt rename to ext/standard/tests/array/sort/array_multisort_variation7.phpt diff --git a/ext/standard/tests/array/array_multisort_variation8.phpt b/ext/standard/tests/array/sort/array_multisort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation8.phpt rename to ext/standard/tests/array/sort/array_multisort_variation8.phpt diff --git a/ext/standard/tests/array/array_multisort_variation9.phpt b/ext/standard/tests/array/sort/array_multisort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/array_multisort_variation9.phpt rename to ext/standard/tests/array/sort/array_multisort_variation9.phpt diff --git a/ext/standard/tests/array/array_shuffle_basic.phpt b/ext/standard/tests/array/sort/array_shuffle_basic.phpt similarity index 100% rename from ext/standard/tests/array/array_shuffle_basic.phpt rename to ext/standard/tests/array/sort/array_shuffle_basic.phpt diff --git a/ext/standard/tests/array/arsort_basic.phpt b/ext/standard/tests/array/sort/arsort_basic.phpt similarity index 100% rename from ext/standard/tests/array/arsort_basic.phpt rename to ext/standard/tests/array/sort/arsort_basic.phpt diff --git a/ext/standard/tests/array/arsort_object1.phpt b/ext/standard/tests/array/sort/arsort_object1.phpt similarity index 100% rename from ext/standard/tests/array/arsort_object1.phpt rename to ext/standard/tests/array/sort/arsort_object1.phpt diff --git a/ext/standard/tests/array/arsort_object2.phpt b/ext/standard/tests/array/sort/arsort_object2.phpt similarity index 100% rename from ext/standard/tests/array/arsort_object2.phpt rename to ext/standard/tests/array/sort/arsort_object2.phpt diff --git a/ext/standard/tests/array/arsort_variation10.phpt b/ext/standard/tests/array/sort/arsort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation10.phpt rename to ext/standard/tests/array/sort/arsort_variation10.phpt diff --git a/ext/standard/tests/array/arsort_variation11.phpt b/ext/standard/tests/array/sort/arsort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation11.phpt rename to ext/standard/tests/array/sort/arsort_variation11.phpt diff --git a/ext/standard/tests/array/arsort_variation3.phpt b/ext/standard/tests/array/sort/arsort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation3.phpt rename to ext/standard/tests/array/sort/arsort_variation3.phpt diff --git a/ext/standard/tests/array/arsort_variation4.phpt b/ext/standard/tests/array/sort/arsort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation4.phpt rename to ext/standard/tests/array/sort/arsort_variation4.phpt diff --git a/ext/standard/tests/array/sort/arsort_variation5.phpt b/ext/standard/tests/array/sort/arsort_variation5.phpt new file mode 100644 index 0000000000000..08c70d8e07ddb --- /dev/null +++ b/ext/standard/tests/array/sort/arsort_variation5.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test arsort() function : usage variations - sort strings +--FILE-- + "lemoN", + "Orange" => "Orange", + "banana" => "banana", + "apple" => "apple", + "Test" => "Test", + "TTTT" => "TTTT", + "ttt" => "ttt", + "ww" => "ww", + "x" => "x", + "X" => "X", + "oraNGe" => "oraNGe", + "BANANA" => "BANANA", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(arsort($temp_array)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(arsort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(arsort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array); + +?> +--EXPECT-- +Default flag +bool(true) +array(12) { + ["x"]=> + string(1) "x" + ["ww"]=> + string(2) "ww" + ["ttt"]=> + string(3) "ttt" + ["oraNGe"]=> + string(6) "oraNGe" + ["lemoN"]=> + string(5) "lemoN" + ["banana"]=> + string(6) "banana" + ["apple"]=> + string(5) "apple" + ["X"]=> + string(1) "X" + ["Test"]=> + string(4) "Test" + ["TTTT"]=> + string(4) "TTTT" + ["Orange"]=> + string(6) "Orange" + ["BANANA"]=> + string(6) "BANANA" +} +SORT_REGULAR +bool(true) +array(12) { + ["x"]=> + string(1) "x" + ["ww"]=> + string(2) "ww" + ["ttt"]=> + string(3) "ttt" + ["oraNGe"]=> + string(6) "oraNGe" + ["lemoN"]=> + string(5) "lemoN" + ["banana"]=> + string(6) "banana" + ["apple"]=> + string(5) "apple" + ["X"]=> + string(1) "X" + ["Test"]=> + string(4) "Test" + ["TTTT"]=> + string(4) "TTTT" + ["Orange"]=> + string(6) "Orange" + ["BANANA"]=> + string(6) "BANANA" +} +SORT_STRING +bool(true) +array(12) { + ["x"]=> + string(1) "x" + ["ww"]=> + string(2) "ww" + ["ttt"]=> + string(3) "ttt" + ["oraNGe"]=> + string(6) "oraNGe" + ["lemoN"]=> + string(5) "lemoN" + ["banana"]=> + string(6) "banana" + ["apple"]=> + string(5) "apple" + ["X"]=> + string(1) "X" + ["Test"]=> + string(4) "Test" + ["TTTT"]=> + string(4) "TTTT" + ["Orange"]=> + string(6) "Orange" + ["BANANA"]=> + string(6) "BANANA" +} diff --git a/ext/standard/tests/array/arsort_variation6.phpt b/ext/standard/tests/array/sort/arsort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation6.phpt rename to ext/standard/tests/array/sort/arsort_variation6.phpt diff --git a/ext/standard/tests/array/arsort_variation7.phpt b/ext/standard/tests/array/sort/arsort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation7.phpt rename to ext/standard/tests/array/sort/arsort_variation7.phpt diff --git a/ext/standard/tests/array/arsort_variation8.phpt b/ext/standard/tests/array/sort/arsort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation8.phpt rename to ext/standard/tests/array/sort/arsort_variation8.phpt diff --git a/ext/standard/tests/array/arsort_variation9.phpt b/ext/standard/tests/array/sort/arsort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/arsort_variation9.phpt rename to ext/standard/tests/array/sort/arsort_variation9.phpt diff --git a/ext/standard/tests/array/sort/arsort_variation_escape_sequences.phpt b/ext/standard/tests/array/sort/arsort_variation_escape_sequences.phpt new file mode 100644 index 0000000000000..b4a533c42114c --- /dev/null +++ b/ext/standard/tests/array/sort/arsort_variation_escape_sequences.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test arsort() function: sorting escape sequences +--FILE-- + "\xhh", + "\ddd" => "\ddd", + "\cx" => "\cx", + "\a" => "\a", + "\e" => "\e", + "\r" => "\r", + "\f" => "\f", + "\v" => "\v", + "\n" => "\n", + "\t" => "\t", + null => null, +]; + +$array = [ + null => null, + "\a" => "\a", + "\cx" => "\cx", + "\e" => "\e", + "\f" => "\f", + "\n" => "\n", + "\r" => "\r", + "\t" => "\t", + "\xhh" => "\xhh", + "\ddd" => "\ddd", + "\v" => "\v", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(arsort($temp_array)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(arsort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(arsort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +?> +--EXPECT-- +Default flag +bool(true) +bool(true) +SORT_REGULAR +bool(true) +bool(true) +SORT_STRING +bool(true) +bool(true) diff --git a/ext/standard/tests/array/asort_basic.phpt b/ext/standard/tests/array/sort/asort_basic.phpt similarity index 100% rename from ext/standard/tests/array/asort_basic.phpt rename to ext/standard/tests/array/sort/asort_basic.phpt diff --git a/ext/standard/tests/array/asort_object1.phpt b/ext/standard/tests/array/sort/asort_object1.phpt similarity index 100% rename from ext/standard/tests/array/asort_object1.phpt rename to ext/standard/tests/array/sort/asort_object1.phpt diff --git a/ext/standard/tests/array/asort_object2.phpt b/ext/standard/tests/array/sort/asort_object2.phpt similarity index 100% rename from ext/standard/tests/array/asort_object2.phpt rename to ext/standard/tests/array/sort/asort_object2.phpt diff --git a/ext/standard/tests/array/asort_stability.phpt b/ext/standard/tests/array/sort/asort_stability.phpt similarity index 100% rename from ext/standard/tests/array/asort_stability.phpt rename to ext/standard/tests/array/sort/asort_stability.phpt diff --git a/ext/standard/tests/array/asort_variation10.phpt b/ext/standard/tests/array/sort/asort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation10.phpt rename to ext/standard/tests/array/sort/asort_variation10.phpt diff --git a/ext/standard/tests/array/asort_variation11.phpt b/ext/standard/tests/array/sort/asort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation11.phpt rename to ext/standard/tests/array/sort/asort_variation11.phpt diff --git a/ext/standard/tests/array/asort_variation3.phpt b/ext/standard/tests/array/sort/asort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation3.phpt rename to ext/standard/tests/array/sort/asort_variation3.phpt diff --git a/ext/standard/tests/array/asort_variation4.phpt b/ext/standard/tests/array/sort/asort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation4.phpt rename to ext/standard/tests/array/sort/asort_variation4.phpt diff --git a/ext/standard/tests/array/sort/asort_variation5.phpt b/ext/standard/tests/array/sort/asort_variation5.phpt new file mode 100644 index 0000000000000..d5a8930f090c3 --- /dev/null +++ b/ext/standard/tests/array/sort/asort_variation5.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test asort() function : usage variations - sort strings +--FILE-- + "lemoN", + "Orange" => "Orange", + "banana" => "banana", + "apple" => "apple", + "Test" => "Test", + "TTTT" => "TTTT", + "ttt" => "ttt", + "ww" => "ww", + "x" => "x", + "X" => "X", + "oraNGe" => "oraNGe", + "BANANA" => "BANANA", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(asort($temp_array)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(asort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(asort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array); + +?> +--EXPECT-- +Default flag +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +SORT_REGULAR +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +SORT_STRING +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} \ No newline at end of file diff --git a/ext/standard/tests/array/asort_variation6.phpt b/ext/standard/tests/array/sort/asort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation6.phpt rename to ext/standard/tests/array/sort/asort_variation6.phpt diff --git a/ext/standard/tests/array/asort_variation7.phpt b/ext/standard/tests/array/sort/asort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation7.phpt rename to ext/standard/tests/array/sort/asort_variation7.phpt diff --git a/ext/standard/tests/array/asort_variation8.phpt b/ext/standard/tests/array/sort/asort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation8.phpt rename to ext/standard/tests/array/sort/asort_variation8.phpt diff --git a/ext/standard/tests/array/asort_variation9.phpt b/ext/standard/tests/array/sort/asort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/asort_variation9.phpt rename to ext/standard/tests/array/sort/asort_variation9.phpt diff --git a/ext/standard/tests/array/sort/asort_variation_escape_sequences.phpt b/ext/standard/tests/array/sort/asort_variation_escape_sequences.phpt new file mode 100644 index 0000000000000..6de02b66ae0a6 --- /dev/null +++ b/ext/standard/tests/array/sort/asort_variation_escape_sequences.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test asort() function: sorting escape sequences +--FILE-- + null, + "\t" => "\t", + "\n" => "\n", + "\v" => "\v", + "\f" => "\f", + "\r" => "\r", + "\e" => "\e", + "\a" => "\a", + "\cx" => "\cx", + "\ddd" => "\ddd", + "\xhh" => "\xhh", +]; + +$array = [ + null => null, + "\a" => "\a", + "\cx" => "\cx", + "\e" => "\e", + "\f" => "\f", + "\n" => "\n", + "\r" => "\r", + "\t" => "\t", + "\xhh" => "\xhh", + "\ddd" => "\ddd", + "\v" => "\v", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(asort($temp_array)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(asort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(asort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +?> +--EXPECT-- +Default flag +bool(true) +bool(true) +SORT_REGULAR +bool(true) +bool(true) +SORT_STRING +bool(true) +bool(true) diff --git a/ext/standard/tests/array/bug24897.phpt b/ext/standard/tests/array/sort/bug24897.phpt similarity index 100% rename from ext/standard/tests/array/bug24897.phpt rename to ext/standard/tests/array/sort/bug24897.phpt diff --git a/ext/standard/tests/array/bug25359.phpt b/ext/standard/tests/array/sort/bug25359.phpt similarity index 100% rename from ext/standard/tests/array/bug25359.phpt rename to ext/standard/tests/array/sort/bug25359.phpt diff --git a/ext/standard/tests/array/bug33382.phpt b/ext/standard/tests/array/sort/bug33382.phpt similarity index 100% rename from ext/standard/tests/array/bug33382.phpt rename to ext/standard/tests/array/sort/bug33382.phpt diff --git a/ext/standard/tests/array/bug36975.phpt b/ext/standard/tests/array/sort/bug36975.phpt similarity index 100% rename from ext/standard/tests/array/bug36975.phpt rename to ext/standard/tests/array/sort/bug36975.phpt diff --git a/ext/standard/tests/array/bug44929.phpt b/ext/standard/tests/array/sort/bug44929.phpt similarity index 100% rename from ext/standard/tests/array/bug44929.phpt rename to ext/standard/tests/array/sort/bug44929.phpt diff --git a/ext/standard/tests/array/bug50006.phpt b/ext/standard/tests/array/sort/bug50006.phpt similarity index 100% rename from ext/standard/tests/array/bug50006.phpt rename to ext/standard/tests/array/sort/bug50006.phpt diff --git a/ext/standard/tests/array/bug50006_1.phpt b/ext/standard/tests/array/sort/bug50006_1.phpt similarity index 100% rename from ext/standard/tests/array/bug50006_1.phpt rename to ext/standard/tests/array/sort/bug50006_1.phpt diff --git a/ext/standard/tests/array/bug50006_2.phpt b/ext/standard/tests/array/sort/bug50006_2.phpt similarity index 100% rename from ext/standard/tests/array/bug50006_2.phpt rename to ext/standard/tests/array/sort/bug50006_2.phpt diff --git a/ext/standard/tests/array/bug71334.phpt b/ext/standard/tests/array/sort/bug71334.phpt similarity index 100% rename from ext/standard/tests/array/bug71334.phpt rename to ext/standard/tests/array/sort/bug71334.phpt diff --git a/ext/standard/tests/array/bug77395.phpt b/ext/standard/tests/array/sort/bug77395.phpt similarity index 100% rename from ext/standard/tests/array/bug77395.phpt rename to ext/standard/tests/array/sort/bug77395.phpt diff --git a/ext/standard/tests/array/data.inc b/ext/standard/tests/array/sort/data.inc similarity index 100% rename from ext/standard/tests/array/data.inc rename to ext/standard/tests/array/sort/data.inc diff --git a/ext/standard/tests/array/gh9296.phpt b/ext/standard/tests/array/sort/gh9296.phpt similarity index 100% rename from ext/standard/tests/array/gh9296.phpt rename to ext/standard/tests/array/sort/gh9296.phpt diff --git a/ext/standard/tests/array/002.phpt b/ext/standard/tests/array/sort/internal_sorts_basic.phpt similarity index 100% rename from ext/standard/tests/array/002.phpt rename to ext/standard/tests/array/sort/internal_sorts_basic.phpt diff --git a/ext/standard/tests/array/krsort_basic.phpt b/ext/standard/tests/array/sort/krsort_basic.phpt similarity index 100% rename from ext/standard/tests/array/krsort_basic.phpt rename to ext/standard/tests/array/sort/krsort_basic.phpt diff --git a/ext/standard/tests/array/krsort_object.phpt b/ext/standard/tests/array/sort/krsort_object.phpt similarity index 100% rename from ext/standard/tests/array/krsort_object.phpt rename to ext/standard/tests/array/sort/krsort_object.phpt diff --git a/ext/standard/tests/array/krsort_variation10.phpt b/ext/standard/tests/array/sort/krsort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation10.phpt rename to ext/standard/tests/array/sort/krsort_variation10.phpt diff --git a/ext/standard/tests/array/krsort_variation11.phpt b/ext/standard/tests/array/sort/krsort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation11.phpt rename to ext/standard/tests/array/sort/krsort_variation11.phpt diff --git a/ext/standard/tests/array/krsort_variation3.phpt b/ext/standard/tests/array/sort/krsort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation3.phpt rename to ext/standard/tests/array/sort/krsort_variation3.phpt diff --git a/ext/standard/tests/array/krsort_variation4.phpt b/ext/standard/tests/array/sort/krsort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation4.phpt rename to ext/standard/tests/array/sort/krsort_variation4.phpt diff --git a/ext/standard/tests/array/sort/krsort_variation5.phpt b/ext/standard/tests/array/sort/krsort_variation5.phpt new file mode 100644 index 0000000000000..b1fe5897f16c9 --- /dev/null +++ b/ext/standard/tests/array/sort/krsort_variation5.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test krsort() function : usage variations - sort strings +--FILE-- + "lemoN", + "Orange" => "Orange", + "banana" => "banana", + "apple" => "apple", + "Test" => "Test", + "TTTT" => "TTTT", + "ttt" => "ttt", + "ww" => "ww", + "x" => "x", + "X" => "X", + "oraNGe" => "oraNGe", + "BANANA" => "BANANA", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(ksort($temp_array)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(ksort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(ksort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array); + +?> +--EXPECT-- +Default flag +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +SORT_REGULAR +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +SORT_STRING +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} diff --git a/ext/standard/tests/array/krsort_variation6.phpt b/ext/standard/tests/array/sort/krsort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation6.phpt rename to ext/standard/tests/array/sort/krsort_variation6.phpt diff --git a/ext/standard/tests/array/krsort_variation7.phpt b/ext/standard/tests/array/sort/krsort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation7.phpt rename to ext/standard/tests/array/sort/krsort_variation7.phpt diff --git a/ext/standard/tests/array/krsort_variation8.phpt b/ext/standard/tests/array/sort/krsort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation8.phpt rename to ext/standard/tests/array/sort/krsort_variation8.phpt diff --git a/ext/standard/tests/array/krsort_variation9.phpt b/ext/standard/tests/array/sort/krsort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/krsort_variation9.phpt rename to ext/standard/tests/array/sort/krsort_variation9.phpt diff --git a/ext/standard/tests/array/sort/krsort_variation_escape_sequences.phpt b/ext/standard/tests/array/sort/krsort_variation_escape_sequences.phpt new file mode 100644 index 0000000000000..ac56df76ed7ca --- /dev/null +++ b/ext/standard/tests/array/sort/krsort_variation_escape_sequences.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test krsort() function: sorting escape sequences +--FILE-- + "\xhh", + "\ddd" => "\ddd", + "\cx" => "\cx", + "\a" => "\a", + "\e" => "\e", + "\r" => "\r", + "\f" => "\f", + "\v" => "\v", + "\n" => "\n", + "\t" => "\t", + null => null, +]; + +$array = [ + null => null, + "\a" => "\a", + "\cx" => "\cx", + "\e" => "\e", + "\f" => "\f", + "\n" => "\n", + "\r" => "\r", + "\t" => "\t", + "\xhh" => "\xhh", + "\ddd" => "\ddd", + "\v" => "\v", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(krsort($temp_array)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(krsort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(krsort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +?> +--EXPECT-- +Default flag +bool(true) +bool(true) +SORT_REGULAR +bool(true) +bool(true) +SORT_STRING +bool(true) +bool(true) diff --git a/ext/standard/tests/array/ksort_basic.phpt b/ext/standard/tests/array/sort/ksort_basic.phpt similarity index 100% rename from ext/standard/tests/array/ksort_basic.phpt rename to ext/standard/tests/array/sort/ksort_basic.phpt diff --git a/ext/standard/tests/array/ksort_object.phpt b/ext/standard/tests/array/sort/ksort_object.phpt similarity index 100% rename from ext/standard/tests/array/ksort_object.phpt rename to ext/standard/tests/array/sort/ksort_object.phpt diff --git a/ext/standard/tests/array/ksort_variation10.phpt b/ext/standard/tests/array/sort/ksort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation10.phpt rename to ext/standard/tests/array/sort/ksort_variation10.phpt diff --git a/ext/standard/tests/array/ksort_variation11.phpt b/ext/standard/tests/array/sort/ksort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation11.phpt rename to ext/standard/tests/array/sort/ksort_variation11.phpt diff --git a/ext/standard/tests/array/ksort_variation3.phpt b/ext/standard/tests/array/sort/ksort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation3.phpt rename to ext/standard/tests/array/sort/ksort_variation3.phpt diff --git a/ext/standard/tests/array/ksort_variation4.phpt b/ext/standard/tests/array/sort/ksort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation4.phpt rename to ext/standard/tests/array/sort/ksort_variation4.phpt diff --git a/ext/standard/tests/array/sort/ksort_variation5.phpt b/ext/standard/tests/array/sort/ksort_variation5.phpt new file mode 100644 index 0000000000000..f69b0b14d5d05 --- /dev/null +++ b/ext/standard/tests/array/sort/ksort_variation5.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test ksort() function : usage variations - sort strings +--FILE-- + "lemoN", + "Orange" => "Orange", + "banana" => "banana", + "apple" => "apple", + "Test" => "Test", + "TTTT" => "TTTT", + "ttt" => "ttt", + "ww" => "ww", + "x" => "x", + "X" => "X", + "oraNGe" => "oraNGe", + "BANANA" => "BANANA", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(ksort($temp_array)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(ksort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(ksort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array); + +?> +--EXPECT-- +Default flag +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +SORT_REGULAR +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} +SORT_STRING +bool(true) +array(12) { + ["BANANA"]=> + string(6) "BANANA" + ["Orange"]=> + string(6) "Orange" + ["TTTT"]=> + string(4) "TTTT" + ["Test"]=> + string(4) "Test" + ["X"]=> + string(1) "X" + ["apple"]=> + string(5) "apple" + ["banana"]=> + string(6) "banana" + ["lemoN"]=> + string(5) "lemoN" + ["oraNGe"]=> + string(6) "oraNGe" + ["ttt"]=> + string(3) "ttt" + ["ww"]=> + string(2) "ww" + ["x"]=> + string(1) "x" +} diff --git a/ext/standard/tests/array/ksort_variation6.phpt b/ext/standard/tests/array/sort/ksort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation6.phpt rename to ext/standard/tests/array/sort/ksort_variation6.phpt diff --git a/ext/standard/tests/array/ksort_variation7.phpt b/ext/standard/tests/array/sort/ksort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation7.phpt rename to ext/standard/tests/array/sort/ksort_variation7.phpt diff --git a/ext/standard/tests/array/ksort_variation8.phpt b/ext/standard/tests/array/sort/ksort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation8.phpt rename to ext/standard/tests/array/sort/ksort_variation8.phpt diff --git a/ext/standard/tests/array/ksort_variation9.phpt b/ext/standard/tests/array/sort/ksort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/ksort_variation9.phpt rename to ext/standard/tests/array/sort/ksort_variation9.phpt diff --git a/ext/standard/tests/array/sort/ksort_variation_escape_sequences.phpt b/ext/standard/tests/array/sort/ksort_variation_escape_sequences.phpt new file mode 100644 index 0000000000000..e880227b1c9e0 --- /dev/null +++ b/ext/standard/tests/array/sort/ksort_variation_escape_sequences.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test ksort() function: sorting escape sequences +--FILE-- + null, + "\t" => "\t", + "\n" => "\n", + "\v" => "\v", + "\f" => "\f", + "\r" => "\r", + "\e" => "\e", + "\a" => "\a", + "\cx" => "\cx", + "\ddd" => "\ddd", + "\xhh" => "\xhh", +]; + +$array = [ + null => null, + "\a" => "\a", + "\cx" => "\cx", + "\e" => "\e", + "\f" => "\f", + "\n" => "\n", + "\r" => "\r", + "\t" => "\t", + "\xhh" => "\xhh", + "\ddd" => "\ddd", + "\v" => "\v", +]; + +echo "Default flag\n"; +$temp_array = $array; +var_dump(ksort($temp_array)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_REGULAR\n"; +$temp_array = $array; +var_dump(ksort($temp_array, SORT_REGULAR)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +echo "SORT_STRING\n"; +$temp_array = $array; +var_dump(ksort($temp_array, SORT_STRING)); // expecting : bool(true) +var_dump($temp_array === EXPECTED_RESULT); + +?> +--EXPECT-- +Default flag +bool(true) +bool(true) +SORT_REGULAR +bool(true) +bool(true) +SORT_STRING +bool(true) +bool(true) diff --git a/ext/standard/tests/array/locale_sort.phpt b/ext/standard/tests/array/sort/locale_sort.phpt similarity index 100% rename from ext/standard/tests/array/locale_sort.phpt rename to ext/standard/tests/array/sort/locale_sort.phpt diff --git a/ext/standard/tests/array/natcasesort_basic.phpt b/ext/standard/tests/array/sort/natcasesort_basic.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_basic.phpt rename to ext/standard/tests/array/sort/natcasesort_basic.phpt diff --git a/ext/standard/tests/array/natcasesort_object1.phpt b/ext/standard/tests/array/sort/natcasesort_object1.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_object1.phpt rename to ext/standard/tests/array/sort/natcasesort_object1.phpt diff --git a/ext/standard/tests/array/natcasesort_object2.phpt b/ext/standard/tests/array/sort/natcasesort_object2.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_object2.phpt rename to ext/standard/tests/array/sort/natcasesort_object2.phpt diff --git a/ext/standard/tests/array/natcasesort_variation10.phpt b/ext/standard/tests/array/sort/natcasesort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation10.phpt rename to ext/standard/tests/array/sort/natcasesort_variation10.phpt diff --git a/ext/standard/tests/array/natcasesort_variation11.phpt b/ext/standard/tests/array/sort/natcasesort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation11.phpt rename to ext/standard/tests/array/sort/natcasesort_variation11.phpt diff --git a/ext/standard/tests/array/natcasesort_variation2.phpt b/ext/standard/tests/array/sort/natcasesort_variation2.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation2.phpt rename to ext/standard/tests/array/sort/natcasesort_variation2.phpt diff --git a/ext/standard/tests/array/natcasesort_variation3.phpt b/ext/standard/tests/array/sort/natcasesort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation3.phpt rename to ext/standard/tests/array/sort/natcasesort_variation3.phpt diff --git a/ext/standard/tests/array/natcasesort_variation4.phpt b/ext/standard/tests/array/sort/natcasesort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation4.phpt rename to ext/standard/tests/array/sort/natcasesort_variation4.phpt diff --git a/ext/standard/tests/array/natcasesort_variation5.phpt b/ext/standard/tests/array/sort/natcasesort_variation5.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation5.phpt rename to ext/standard/tests/array/sort/natcasesort_variation5.phpt diff --git a/ext/standard/tests/array/natcasesort_variation6.phpt b/ext/standard/tests/array/sort/natcasesort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation6.phpt rename to ext/standard/tests/array/sort/natcasesort_variation6.phpt diff --git a/ext/standard/tests/array/natcasesort_variation7.phpt b/ext/standard/tests/array/sort/natcasesort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation7.phpt rename to ext/standard/tests/array/sort/natcasesort_variation7.phpt diff --git a/ext/standard/tests/array/natcasesort_variation8.phpt b/ext/standard/tests/array/sort/natcasesort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation8.phpt rename to ext/standard/tests/array/sort/natcasesort_variation8.phpt diff --git a/ext/standard/tests/array/natcasesort_variation9.phpt b/ext/standard/tests/array/sort/natcasesort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/natcasesort_variation9.phpt rename to ext/standard/tests/array/sort/natcasesort_variation9.phpt diff --git a/ext/standard/tests/array/natsort_basic.phpt b/ext/standard/tests/array/sort/natsort_basic.phpt similarity index 100% rename from ext/standard/tests/array/natsort_basic.phpt rename to ext/standard/tests/array/sort/natsort_basic.phpt diff --git a/ext/standard/tests/array/004.phpt b/ext/standard/tests/array/sort/natsort_natcasesort_basics.phpt similarity index 100% rename from ext/standard/tests/array/004.phpt rename to ext/standard/tests/array/sort/natsort_natcasesort_basics.phpt diff --git a/ext/standard/tests/array/rsort_basic.phpt b/ext/standard/tests/array/sort/rsort_basic.phpt similarity index 100% rename from ext/standard/tests/array/rsort_basic.phpt rename to ext/standard/tests/array/sort/rsort_basic.phpt diff --git a/ext/standard/tests/array/rsort_object1.phpt b/ext/standard/tests/array/sort/rsort_object1.phpt similarity index 100% rename from ext/standard/tests/array/rsort_object1.phpt rename to ext/standard/tests/array/sort/rsort_object1.phpt diff --git a/ext/standard/tests/array/rsort_object2.phpt b/ext/standard/tests/array/sort/rsort_object2.phpt similarity index 100% rename from ext/standard/tests/array/rsort_object2.phpt rename to ext/standard/tests/array/sort/rsort_object2.phpt diff --git a/ext/standard/tests/array/rsort_variation10.phpt b/ext/standard/tests/array/sort/rsort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation10.phpt rename to ext/standard/tests/array/sort/rsort_variation10.phpt diff --git a/ext/standard/tests/array/rsort_variation11.phpt b/ext/standard/tests/array/sort/rsort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation11.phpt rename to ext/standard/tests/array/sort/rsort_variation11.phpt diff --git a/ext/standard/tests/array/rsort_variation3.phpt b/ext/standard/tests/array/sort/rsort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation3.phpt rename to ext/standard/tests/array/sort/rsort_variation3.phpt diff --git a/ext/standard/tests/array/rsort_variation4.phpt b/ext/standard/tests/array/sort/rsort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation4.phpt rename to ext/standard/tests/array/sort/rsort_variation4.phpt diff --git a/ext/standard/tests/array/sort/rsort_variation5.phpt b/ext/standard/tests/array/sort/rsort_variation5.phpt new file mode 100644 index 0000000000000..c4dd3f6a9ce70 --- /dev/null +++ b/ext/standard/tests/array/sort/rsort_variation5.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test rsort() function : usage variations - String values +--FILE-- + +--EXPECT-- +Default flag +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} +SORT_REGULAR +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} +SORT_STRING +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} diff --git a/ext/standard/tests/array/rsort_variation6.phpt b/ext/standard/tests/array/sort/rsort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation6.phpt rename to ext/standard/tests/array/sort/rsort_variation6.phpt diff --git a/ext/standard/tests/array/rsort_variation7.phpt b/ext/standard/tests/array/sort/rsort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation7.phpt rename to ext/standard/tests/array/sort/rsort_variation7.phpt diff --git a/ext/standard/tests/array/rsort_variation8.phpt b/ext/standard/tests/array/sort/rsort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation8.phpt rename to ext/standard/tests/array/sort/rsort_variation8.phpt diff --git a/ext/standard/tests/array/rsort_variation9.phpt b/ext/standard/tests/array/sort/rsort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/rsort_variation9.phpt rename to ext/standard/tests/array/sort/rsort_variation9.phpt diff --git a/ext/standard/tests/array/sort/rsort_variation_escape_sequences.phpt b/ext/standard/tests/array/sort/rsort_variation_escape_sequences.phpt new file mode 100644 index 0000000000000..57edbe66e1514 --- /dev/null +++ b/ext/standard/tests/array/sort/rsort_variation_escape_sequences.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test rsort() function: sorting escape sequences +--FILE-- + +--EXPECT-- +Default flag +bool(true) +bool(true) +SORT_REGULAR +bool(true) +bool(true) +SORT_STRING +bool(true) +bool(true) diff --git a/ext/standard/tests/array/shuffle_basic1.phpt b/ext/standard/tests/array/sort/shuffle_basic1.phpt similarity index 100% rename from ext/standard/tests/array/shuffle_basic1.phpt rename to ext/standard/tests/array/sort/shuffle_basic1.phpt diff --git a/ext/standard/tests/array/shuffle_basic2.phpt b/ext/standard/tests/array/sort/shuffle_basic2.phpt similarity index 100% rename from ext/standard/tests/array/shuffle_basic2.phpt rename to ext/standard/tests/array/sort/shuffle_basic2.phpt diff --git a/ext/standard/tests/array/shuffle_variation2.phpt b/ext/standard/tests/array/sort/shuffle_variation2.phpt similarity index 100% rename from ext/standard/tests/array/shuffle_variation2.phpt rename to ext/standard/tests/array/sort/shuffle_variation2.phpt diff --git a/ext/standard/tests/array/shuffle_variation3.phpt b/ext/standard/tests/array/sort/shuffle_variation3.phpt similarity index 100% rename from ext/standard/tests/array/shuffle_variation3.phpt rename to ext/standard/tests/array/sort/shuffle_variation3.phpt diff --git a/ext/standard/tests/array/shuffle_variation4.phpt b/ext/standard/tests/array/sort/shuffle_variation4.phpt similarity index 100% rename from ext/standard/tests/array/shuffle_variation4.phpt rename to ext/standard/tests/array/sort/shuffle_variation4.phpt diff --git a/ext/standard/tests/array/shuffle_variation5.phpt b/ext/standard/tests/array/sort/shuffle_variation5.phpt similarity index 100% rename from ext/standard/tests/array/shuffle_variation5.phpt rename to ext/standard/tests/array/sort/shuffle_variation5.phpt diff --git a/ext/standard/tests/array/sort_basic.phpt b/ext/standard/tests/array/sort/sort_basic.phpt similarity index 100% rename from ext/standard/tests/array/sort_basic.phpt rename to ext/standard/tests/array/sort/sort_basic.phpt diff --git a/ext/standard/tests/array/sort_object1.phpt b/ext/standard/tests/array/sort/sort_object1.phpt similarity index 100% rename from ext/standard/tests/array/sort_object1.phpt rename to ext/standard/tests/array/sort/sort_object1.phpt diff --git a/ext/standard/tests/array/sort_object2.phpt b/ext/standard/tests/array/sort/sort_object2.phpt similarity index 100% rename from ext/standard/tests/array/sort_object2.phpt rename to ext/standard/tests/array/sort/sort_object2.phpt diff --git a/ext/standard/tests/array/sort_variation10.phpt b/ext/standard/tests/array/sort/sort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation10.phpt rename to ext/standard/tests/array/sort/sort_variation10.phpt diff --git a/ext/standard/tests/array/sort_variation11.phpt b/ext/standard/tests/array/sort/sort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation11.phpt rename to ext/standard/tests/array/sort/sort_variation11.phpt diff --git a/ext/standard/tests/array/sort_variation3.phpt b/ext/standard/tests/array/sort/sort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation3.phpt rename to ext/standard/tests/array/sort/sort_variation3.phpt diff --git a/ext/standard/tests/array/sort_variation4.phpt b/ext/standard/tests/array/sort/sort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation4.phpt rename to ext/standard/tests/array/sort/sort_variation4.phpt diff --git a/ext/standard/tests/array/sort/sort_variation5.phpt b/ext/standard/tests/array/sort/sort_variation5.phpt new file mode 100644 index 0000000000000..c9e369f4a2807 --- /dev/null +++ b/ext/standard/tests/array/sort/sort_variation5.phpt @@ -0,0 +1,121 @@ +--TEST-- +Test sort() function : usage variations - sort strings +--FILE-- + +--EXPECT-- +Default flag +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} +SORT_REGULAR +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} +SORT_STRING +bool(true) +array(12) { + [0]=> + string(6) "BANANA" + [1]=> + string(6) "Orange" + [2]=> + string(4) "TTTT" + [3]=> + string(4) "Test" + [4]=> + string(1) "X" + [5]=> + string(5) "apple" + [6]=> + string(6) "banana" + [7]=> + string(5) "lemoN" + [8]=> + string(6) "oraNGe" + [9]=> + string(3) "ttt" + [10]=> + string(2) "ww" + [11]=> + string(1) "x" +} diff --git a/ext/standard/tests/array/sort_variation6.phpt b/ext/standard/tests/array/sort/sort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation6.phpt rename to ext/standard/tests/array/sort/sort_variation6.phpt diff --git a/ext/standard/tests/array/sort_variation7.phpt b/ext/standard/tests/array/sort/sort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation7.phpt rename to ext/standard/tests/array/sort/sort_variation7.phpt diff --git a/ext/standard/tests/array/sort_variation8.phpt b/ext/standard/tests/array/sort/sort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation8.phpt rename to ext/standard/tests/array/sort/sort_variation8.phpt diff --git a/ext/standard/tests/array/sort_variation9.phpt b/ext/standard/tests/array/sort/sort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/sort_variation9.phpt rename to ext/standard/tests/array/sort/sort_variation9.phpt diff --git a/ext/standard/tests/array/sort/sort_variation_escape_sequences.phpt b/ext/standard/tests/array/sort/sort_variation_escape_sequences.phpt new file mode 100644 index 0000000000000..e824a6f7e9c9f --- /dev/null +++ b/ext/standard/tests/array/sort/sort_variation_escape_sequences.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test sort() function: sorting escape sequences +--FILE-- + +--EXPECT-- +Default flag +bool(true) +bool(true) +SORT_REGULAR +bool(true) +bool(true) +SORT_STRING +bool(true) +bool(true) diff --git a/ext/standard/tests/array/uasort_basic1.phpt b/ext/standard/tests/array/sort/uasort_basic1.phpt similarity index 100% rename from ext/standard/tests/array/uasort_basic1.phpt rename to ext/standard/tests/array/sort/uasort_basic1.phpt diff --git a/ext/standard/tests/array/uasort_basic2.phpt b/ext/standard/tests/array/sort/uasort_basic2.phpt similarity index 100% rename from ext/standard/tests/array/uasort_basic2.phpt rename to ext/standard/tests/array/sort/uasort_basic2.phpt diff --git a/ext/standard/tests/array/uasort_object1.phpt b/ext/standard/tests/array/sort/uasort_object1.phpt similarity index 100% rename from ext/standard/tests/array/uasort_object1.phpt rename to ext/standard/tests/array/sort/uasort_object1.phpt diff --git a/ext/standard/tests/array/uasort_object2.phpt b/ext/standard/tests/array/sort/uasort_object2.phpt similarity index 100% rename from ext/standard/tests/array/uasort_object2.phpt rename to ext/standard/tests/array/sort/uasort_object2.phpt diff --git a/ext/standard/tests/array/uasort_variation10.phpt b/ext/standard/tests/array/sort/uasort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation10.phpt rename to ext/standard/tests/array/sort/uasort_variation10.phpt diff --git a/ext/standard/tests/array/uasort_variation11.phpt b/ext/standard/tests/array/sort/uasort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation11.phpt rename to ext/standard/tests/array/sort/uasort_variation11.phpt diff --git a/ext/standard/tests/array/uasort_variation3.phpt b/ext/standard/tests/array/sort/uasort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation3.phpt rename to ext/standard/tests/array/sort/uasort_variation3.phpt diff --git a/ext/standard/tests/array/uasort_variation4.phpt b/ext/standard/tests/array/sort/uasort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation4.phpt rename to ext/standard/tests/array/sort/uasort_variation4.phpt diff --git a/ext/standard/tests/array/uasort_variation5.phpt b/ext/standard/tests/array/sort/uasort_variation5.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation5.phpt rename to ext/standard/tests/array/sort/uasort_variation5.phpt diff --git a/ext/standard/tests/array/uasort_variation6.phpt b/ext/standard/tests/array/sort/uasort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation6.phpt rename to ext/standard/tests/array/sort/uasort_variation6.phpt diff --git a/ext/standard/tests/array/uasort_variation7.phpt b/ext/standard/tests/array/sort/uasort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation7.phpt rename to ext/standard/tests/array/sort/uasort_variation7.phpt diff --git a/ext/standard/tests/array/uasort_variation8.phpt b/ext/standard/tests/array/sort/uasort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/uasort_variation8.phpt rename to ext/standard/tests/array/sort/uasort_variation8.phpt diff --git a/ext/standard/tests/array/uksort_basic.phpt b/ext/standard/tests/array/sort/uksort_basic.phpt similarity index 100% rename from ext/standard/tests/array/uksort_basic.phpt rename to ext/standard/tests/array/sort/uksort_basic.phpt diff --git a/ext/standard/tests/array/003.phpt b/ext/standard/tests/array/sort/user_sort_basics.phpt similarity index 100% rename from ext/standard/tests/array/003.phpt rename to ext/standard/tests/array/sort/user_sort_basics.phpt diff --git a/ext/standard/tests/array/usort_basic.phpt b/ext/standard/tests/array/sort/usort_basic.phpt similarity index 100% rename from ext/standard/tests/array/usort_basic.phpt rename to ext/standard/tests/array/sort/usort_basic.phpt diff --git a/ext/standard/tests/array/usort_object1.phpt b/ext/standard/tests/array/sort/usort_object1.phpt similarity index 100% rename from ext/standard/tests/array/usort_object1.phpt rename to ext/standard/tests/array/sort/usort_object1.phpt diff --git a/ext/standard/tests/array/usort_object2.phpt b/ext/standard/tests/array/sort/usort_object2.phpt similarity index 100% rename from ext/standard/tests/array/usort_object2.phpt rename to ext/standard/tests/array/sort/usort_object2.phpt diff --git a/ext/standard/tests/array/usort_stability.phpt b/ext/standard/tests/array/sort/usort_stability.phpt similarity index 100% rename from ext/standard/tests/array/usort_stability.phpt rename to ext/standard/tests/array/sort/usort_stability.phpt diff --git a/ext/standard/tests/array/usort_variation10.phpt b/ext/standard/tests/array/sort/usort_variation10.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation10.phpt rename to ext/standard/tests/array/sort/usort_variation10.phpt diff --git a/ext/standard/tests/array/usort_variation11.phpt b/ext/standard/tests/array/sort/usort_variation11.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation11.phpt rename to ext/standard/tests/array/sort/usort_variation11.phpt diff --git a/ext/standard/tests/array/usort_variation3.phpt b/ext/standard/tests/array/sort/usort_variation3.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation3.phpt rename to ext/standard/tests/array/sort/usort_variation3.phpt diff --git a/ext/standard/tests/array/usort_variation4.phpt b/ext/standard/tests/array/sort/usort_variation4.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation4.phpt rename to ext/standard/tests/array/sort/usort_variation4.phpt diff --git a/ext/standard/tests/array/usort_variation5.phpt b/ext/standard/tests/array/sort/usort_variation5.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation5.phpt rename to ext/standard/tests/array/sort/usort_variation5.phpt diff --git a/ext/standard/tests/array/usort_variation6.phpt b/ext/standard/tests/array/sort/usort_variation6.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation6.phpt rename to ext/standard/tests/array/sort/usort_variation6.phpt diff --git a/ext/standard/tests/array/usort_variation7.phpt b/ext/standard/tests/array/sort/usort_variation7.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation7.phpt rename to ext/standard/tests/array/sort/usort_variation7.phpt diff --git a/ext/standard/tests/array/usort_variation8.phpt b/ext/standard/tests/array/sort/usort_variation8.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation8.phpt rename to ext/standard/tests/array/sort/usort_variation8.phpt diff --git a/ext/standard/tests/array/usort_variation9.phpt b/ext/standard/tests/array/sort/usort_variation9.phpt similarity index 100% rename from ext/standard/tests/array/usort_variation9.phpt rename to ext/standard/tests/array/sort/usort_variation9.phpt diff --git a/ext/standard/tests/array/sort_variation5.phpt b/ext/standard/tests/array/sort_variation5.phpt deleted file mode 100644 index 6c49342df25d8..0000000000000 --- a/ext/standard/tests/array/sort_variation5.phpt +++ /dev/null @@ -1,227 +0,0 @@ ---TEST-- -Test sort() function : usage variations - sort strings ---FILE-- - SORT_REGULAR, "SORT_STRING" => SORT_STRING); - -$count = 1; -echo "\n-- Testing sort() by supplying various string arrays --\n"; - -// loop through to test sort() with different arrays -foreach ($various_arrays as $array) { - echo "\n-- Iteration $count --\n"; - - echo "- With Default sort flag -\n"; - $temp_array = $array; - var_dump(sort($temp_array) ); // expecting : bool(true) - var_dump($temp_array); - - // loop through $flags array and setting all possible flag values - foreach($flags as $key => $flag){ - echo "- Sort flag = $key -\n"; - $temp_array = $array; - var_dump(sort($temp_array, $flag) ); // expecting : bool(true) - var_dump($temp_array); - } - $count++; -} - -echo "Done\n"; -?> ---EXPECT-- -*** Testing sort() : usage variations *** - --- Testing sort() by supplying various string arrays -- - --- Iteration 1 -- -- With Default sort flag - -bool(true) -array(12) { - [0]=> - NULL - [1]=> - NULL - [2]=> - string(1) " " - [3]=> - string(1) " -" - [4]=> - string(1) " " - [5]=> - string(1) " " - [6]=> - string(1) " " - [7]=> - string(1) "" - [8]=> - string(2) "\a" - [9]=> - string(3) "\cx" - [10]=> - string(4) "\ddd" - [11]=> - string(4) "\xhh" -} -- Sort flag = SORT_REGULAR - -bool(true) -array(12) { - [0]=> - NULL - [1]=> - NULL - [2]=> - string(1) " " - [3]=> - string(1) " -" - [4]=> - string(1) " " - [5]=> - string(1) " " - [6]=> - string(1) " " - [7]=> - string(1) "" - [8]=> - string(2) "\a" - [9]=> - string(3) "\cx" - [10]=> - string(4) "\ddd" - [11]=> - string(4) "\xhh" -} -- Sort flag = SORT_STRING - -bool(true) -array(12) { - [0]=> - NULL - [1]=> - NULL - [2]=> - string(1) " " - [3]=> - string(1) " -" - [4]=> - string(1) " " - [5]=> - string(1) " " - [6]=> - string(1) " " - [7]=> - string(1) "" - [8]=> - string(2) "\a" - [9]=> - string(3) "\cx" - [10]=> - string(4) "\ddd" - [11]=> - string(4) "\xhh" -} - --- Iteration 2 -- -- With Default sort flag - -bool(true) -array(12) { - [0]=> - string(6) "BANANA" - [1]=> - string(6) "Orange" - [2]=> - string(4) "TTTT" - [3]=> - string(4) "Test" - [4]=> - string(1) "X" - [5]=> - string(5) "apple" - [6]=> - string(6) "banana" - [7]=> - string(5) "lemoN" - [8]=> - string(6) "oraNGe" - [9]=> - string(3) "ttt" - [10]=> - string(2) "ww" - [11]=> - string(1) "x" -} -- Sort flag = SORT_REGULAR - -bool(true) -array(12) { - [0]=> - string(6) "BANANA" - [1]=> - string(6) "Orange" - [2]=> - string(4) "TTTT" - [3]=> - string(4) "Test" - [4]=> - string(1) "X" - [5]=> - string(5) "apple" - [6]=> - string(6) "banana" - [7]=> - string(5) "lemoN" - [8]=> - string(6) "oraNGe" - [9]=> - string(3) "ttt" - [10]=> - string(2) "ww" - [11]=> - string(1) "x" -} -- Sort flag = SORT_STRING - -bool(true) -array(12) { - [0]=> - string(6) "BANANA" - [1]=> - string(6) "Orange" - [2]=> - string(4) "TTTT" - [3]=> - string(4) "Test" - [4]=> - string(1) "X" - [5]=> - string(5) "apple" - [6]=> - string(6) "banana" - [7]=> - string(5) "lemoN" - [8]=> - string(6) "oraNGe" - [9]=> - string(3) "ttt" - [10]=> - string(2) "ww" - [11]=> - string(1) "x" -} -Done diff --git a/ext/standard/tests/crypt/des_fallback_invalid_salt.phpt b/ext/standard/tests/crypt/des_fallback_invalid_salt.phpt index b0797657d80a2..8b00c81bbd1ce 100644 --- a/ext/standard/tests/crypt/des_fallback_invalid_salt.phpt +++ b/ext/standard/tests/crypt/des_fallback_invalid_salt.phpt @@ -3,8 +3,11 @@ Test DES with invalid fallback --FILE-- --EXPECT-- diff --git a/ext/standard/tests/directory/DirectoryClass_cannot_clone.phpt b/ext/standard/tests/directory/DirectoryClass_cannot_clone.phpt new file mode 100644 index 0000000000000..c149ec4b1c718 --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_cannot_clone.phpt @@ -0,0 +1,26 @@ +--TEST-- +Cannot serialize instance of Directory class constructed via Reflection. +--FILE-- +read()){ + $cloned_files[] = $row; + } + var_dump(count($cloned_files)); + echo "Using original object:\n"; + $original_files = []; + while ($row = $d->read()){ + $original_files[] = $row; + } + var_dump(count($original_files)); +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +Error: Trying to clone an uncloneable object of class Directory diff --git a/ext/standard/tests/directory/DirectoryClass_cannot_construct.phpt b/ext/standard/tests/directory/DirectoryClass_cannot_construct.phpt new file mode 100644 index 0000000000000..c0ae685b8e722 --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_cannot_construct.phpt @@ -0,0 +1,15 @@ +--TEST-- +Cannot directly instantiate Directory class. +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +Error: Cannot directly construct Directory, use dir() instead diff --git a/ext/standard/tests/directory/DirectoryClass_cannot_serialize.phpt b/ext/standard/tests/directory/DirectoryClass_cannot_serialize.phpt new file mode 100644 index 0000000000000..5dc6bbda8eb65 --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_cannot_serialize.phpt @@ -0,0 +1,16 @@ +--TEST-- +Cannot serialize instance of Directory class constructed via Reflection. +--FILE-- +getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +Exception: Serialization of 'Directory' is not allowed diff --git a/ext/standard/tests/directory/DirectoryClass_error_001.phpt b/ext/standard/tests/directory/DirectoryClass_error_001.phpt deleted file mode 100644 index 251c6b64885f5..0000000000000 --- a/ext/standard/tests/directory/DirectoryClass_error_001.phpt +++ /dev/null @@ -1,27 +0,0 @@ ---TEST-- -Changing Directory::$handle property ---FILE-- -handle = "Havoc!"; -} catch (Error $e) { - echo $e->getMessage(), "\n"; -} -var_dump($d->handle); - -$d = dir(getcwd()); -try { - unset($d->handle); -} catch (Error $e) { - echo $e->getMessage(), "\n"; -} -var_dump($d->handle); - -?> ---EXPECTF-- -Cannot modify readonly property Directory::$handle -resource(%d) of type (stream) -Cannot unset readonly property Directory::$handle -resource(%d) of type (stream) diff --git a/ext/standard/tests/directory/DirectoryClass_readonly_handle.phpt b/ext/standard/tests/directory/DirectoryClass_readonly_handle.phpt new file mode 100644 index 0000000000000..f3f70a6b22a16 --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_readonly_handle.phpt @@ -0,0 +1,26 @@ +--TEST-- +Changing Directory::$handle property +--FILE-- +handle = "Havoc!"; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +var_dump($d->handle); + +try { + unset($d->handle); +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +var_dump($d->handle); + +?> +--EXPECTF-- +Error: Cannot modify readonly property Directory::$handle +resource(%d) of type (stream) +Error: Cannot unset readonly property Directory::$handle +resource(%d) of type (stream) diff --git a/ext/standard/tests/directory/DirectoryClass_readonly_path.phpt b/ext/standard/tests/directory/DirectoryClass_readonly_path.phpt new file mode 100644 index 0000000000000..1dcf8ac8e5225 --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_readonly_path.phpt @@ -0,0 +1,26 @@ +--TEST-- +Changing Directory::$handle property +--FILE-- +path = "Havoc!"; +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +var_dump($d->path == __DIR__); + +try { + unset($d->path); +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} +var_dump($d->path == __DIR__); + +?> +--EXPECTF-- +Error: Cannot modify readonly property Directory::$path +bool(true) +Error: Cannot unset readonly property Directory::$path +bool(true) diff --git a/ext/standard/tests/directory/DirectoryClass_reflection_create_instance_no_construct.phpt b/ext/standard/tests/directory/DirectoryClass_reflection_create_instance_no_construct.phpt new file mode 100644 index 0000000000000..35b07591635fd --- /dev/null +++ b/ext/standard/tests/directory/DirectoryClass_reflection_create_instance_no_construct.phpt @@ -0,0 +1,30 @@ +--TEST-- +Cannot use instance of Directory class constructed via Reflection. +--FILE-- +isInstantiable()); +try { + $d = $rc->newInstanceWithoutConstructor(); +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +var_dump($d); +try { + var_dump($d->read()); +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} + +?> +--EXPECT-- +bool(true) +object(Directory)#2 (0) { + ["path"]=> + uninitialized(string) + ["handle"]=> + uninitialized(mixed) +} +Error: Unable to find my handle property diff --git a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt b/ext/standard/tests/directory/DirectoryClass_reflection_structure.phpt similarity index 61% rename from ext/standard/tests/directory/DirectoryClass_basic_001.phpt rename to ext/standard/tests/directory/DirectoryClass_reflection_structure.phpt index c345ea30b84b4..a8052602b4243 100644 --- a/ext/standard/tests/directory/DirectoryClass_basic_001.phpt +++ b/ext/standard/tests/directory/DirectoryClass_reflection_structure.phpt @@ -11,20 +11,10 @@ echo "Structure of Directory class:\n"; $rc = new ReflectionClass("Directory"); echo $rc; -echo "Cannot instantiate a valid Directory directly:\n"; -$d = new Directory(getcwd()); -var_dump($d); - -try { - var_dump($d->read()); -} catch (\Error $e) { - echo $e->getMessage() . "\n"; -} - ?> ---EXPECTF-- +--EXPECT-- Structure of Directory class: -Class [ class Directory ] { +Class [ final class Directory ] { - Constants [0] { } @@ -45,29 +35,21 @@ Class [ class Directory ] { - Parameters [0] { } - - Tentative return [ void ] + - Return [ void ] } Method [ public method rewind ] { - Parameters [0] { } - - Tentative return [ void ] + - Return [ void ] } Method [ public method read ] { - Parameters [0] { } - - Tentative return [ string|false ] + - Return [ string|false ] } } } -Cannot instantiate a valid Directory directly: -object(Directory)#%d (0) { - ["path"]=> - uninitialized(string) - ["handle"]=> - uninitialized(mixed) -} -Unable to find my handle property diff --git a/ext/standard/tests/directory/gh10992.phpt b/ext/standard/tests/directory/gh10992.phpt new file mode 100644 index 0000000000000..99ac8a5ecd290 --- /dev/null +++ b/ext/standard/tests/directory/gh10992.phpt @@ -0,0 +1,16 @@ +--TEST-- +GH-10992 (Improper long path support for relative paths) +--FILE-- + +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/standard/tests/serialize/gh15169.phpt b/ext/standard/tests/serialize/gh15169.phpt index 9249a593fbb20..19c1415b05c8e 100644 --- a/ext/standard/tests/serialize/gh15169.phpt +++ b/ext/standard/tests/serialize/gh15169.phpt @@ -30,6 +30,11 @@ try { } catch (Error $e) { echo $e->getMessage(), "\n"; } + +while ($next = $firstNode->next) { + $firstNode->next = $next->next; +} + ?> --EXPECTF-- Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? diff --git a/ext/standard/tests/strings/crypt_sha256.phpt b/ext/standard/tests/strings/crypt_sha256.phpt index 095e8f1691336..324248294be72 100644 --- a/ext/standard/tests/strings/crypt_sha256.phpt +++ b/ext/standard/tests/strings/crypt_sha256.phpt @@ -39,12 +39,10 @@ $tests = array( 'a short string', '$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/cZKmF/wJvD' ), + + // The "too many rounds" behavior depends on the crypt() + // implementation, but for now everyone agrees on what to do. 8 => array( - '$5$rounds=10$roundstoolow', - 'the number of rounds is too low', - '*0' - ), - 9 => array( '$5$rounds=1000000000$roundstoohigh', 'the number of rounds is too high', '*0' diff --git a/ext/sysvmsg/sysvmsg.c b/ext/sysvmsg/sysvmsg.c index e9898deb11a92..1f4cafd2bce0f 100644 --- a/ext/sysvmsg/sysvmsg.c +++ b/ext/sysvmsg/sysvmsg.c @@ -370,11 +370,19 @@ PHP_FUNCTION(msg_send) php_var_serialize(&msg_var, message, &var_hash); PHP_VAR_SERIALIZE_DESTROY(var_hash); + if (UNEXPECTED(EG(exception))) { + smart_str_free(&msg_var); + RETURN_THROWS(); + } + + + zend_string *str = smart_str_extract(&msg_var); + message_len = ZSTR_LEN(str); /* NB: php_msgbuf is 1 char bigger than a long, so there is no need to * allocate the extra byte. */ - messagebuffer = safe_emalloc(ZSTR_LEN(msg_var.s), 1, sizeof(struct php_msgbuf)); - memcpy(messagebuffer->mtext, ZSTR_VAL(msg_var.s), ZSTR_LEN(msg_var.s) + 1); - message_len = ZSTR_LEN(msg_var.s); + messagebuffer = safe_emalloc(message_len, 1, sizeof(struct php_msgbuf)); + memcpy(messagebuffer->mtext, ZSTR_VAL(str), message_len + 1); + zend_string_release_ex(str, false); smart_str_free(&msg_var); } else { char *p; diff --git a/ext/sysvmsg/tests/gh16592.phpt b/ext/sysvmsg/tests/gh16592.phpt new file mode 100644 index 0000000000000..8490d000f8914 --- /dev/null +++ b/ext/sysvmsg/tests/gh16592.phpt @@ -0,0 +1,19 @@ +--TEST-- +msg_send() segfault when the type does not serialize as expected +--EXTENSIONS-- +sysvmsg +--FILE-- +getMessage(); +} +?> +--EXPECT-- +Test::__serialize() must return an array diff --git a/ext/sysvshm/sysvshm.c b/ext/sysvshm/sysvshm.c index 6cf41caba65c0..332a8b47af1b6 100644 --- a/ext/sysvshm/sysvshm.c +++ b/ext/sysvshm/sysvshm.c @@ -256,6 +256,12 @@ PHP_FUNCTION(shm_put_var) php_var_serialize(&shm_var, arg_var, &var_hash); PHP_VAR_SERIALIZE_DESTROY(var_hash); + if (UNEXPECTED(!shm_list_ptr->ptr)) { + smart_str_free(&shm_var); + zend_throw_error(NULL, "Shared memory block has been destroyed by the serialization function"); + RETURN_THROWS(); + } + /* insert serialized variable into shared memory */ ret = php_put_shm_data(shm_list_ptr->ptr, shm_key, shm_var.s? ZSTR_VAL(shm_var.s) : NULL, shm_var.s? ZSTR_LEN(shm_var.s) : 0); diff --git a/ext/sysvshm/tests/gh16591.phpt b/ext/sysvshm/tests/gh16591.phpt new file mode 100644 index 0000000000000..d3ece7cd796aa --- /dev/null +++ b/ext/sysvshm/tests/gh16591.phpt @@ -0,0 +1,25 @@ +--TEST-- +GH-16591 (Assertion error in shm_put_var) +--EXTENSIONS-- +sysvshm +--FILE-- + 'b']; + } +} + +$mem = shm_attach(1); +try { + shm_put_var($mem, 1, new C); +} catch (Error $e) { + echo $e->getMessage(), "\n"; +} + +?> +--EXPECT-- +Shared memory block has been destroyed by the serialization function diff --git a/ext/zend_test/observer.c b/ext/zend_test/observer.c index d413450bf9dec..d2a91d16840e0 100644 --- a/ext/zend_test/observer.c +++ b/ext/zend_test/observer.c @@ -20,6 +20,7 @@ #include "zend_observer.h" #include "zend_smart_str.h" #include "ext/standard/php_var.h" +#include "zend_generators.h" static zend_observer_fcall_handlers observer_fcall_init(zend_execute_data *execute_data); @@ -163,6 +164,11 @@ static void observer_show_init_backtrace(zend_execute_data *execute_data) zend_execute_data *ex = execute_data; php_printf("%*s + + + + + + + + + +#0 %s(%d): Foo->__destruct() +#1 %s(%d): bar() diff --git a/main/getopt.c b/main/getopt.c index 85871f164020a..65ce94ae9bb05 100644 --- a/main/getopt.c +++ b/main/getopt.c @@ -97,7 +97,7 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char arg_start = 2; /* Check for = */ - if ((pos = php_memnstr(&argv[*optind][arg_start], "=", 1, argv[*optind]+arg_end)) != NULL) { + if ((pos = memchr(&argv[*optind][arg_start], '=', arg_end - arg_start)) != NULL) { arg_end = pos-&argv[*optind][arg_start]; arg_start++; } else { diff --git a/main/php.h b/main/php.h index c00777a1b40a0..a7ff4b6e35bea 100644 --- a/main/php.h +++ b/main/php.h @@ -109,13 +109,6 @@ typedef int pid_t; # endif #endif -#if PHP_DEBUG -#undef NDEBUG -#else -#ifndef NDEBUG -#define NDEBUG -#endif -#endif #include #ifdef HAVE_UNIX_H diff --git a/php.ini-development b/php.ini-development index 6e5064dd44751..5adb11d215697 100644 --- a/php.ini-development +++ b/php.ini-development @@ -915,6 +915,7 @@ default_socket_timeout = 60 ; ;extension=bz2 ;extension=curl +;extension=exif ;extension=ffi ;extension=ftp ;extension=fileinfo @@ -924,7 +925,6 @@ default_socket_timeout = 60 ;extension=intl ;extension=ldap ;extension=mbstring -;extension=exif ; Must be after mbstring as it depends on it ;extension=mysqli ;extension=odbc ;extension=openssl diff --git a/php.ini-production b/php.ini-production index c62faf52b6732..e4ffc1084b13a 100644 --- a/php.ini-production +++ b/php.ini-production @@ -917,6 +917,7 @@ default_socket_timeout = 60 ; ;extension=bz2 ;extension=curl +;extension=exif ;extension=ffi ;extension=ftp ;extension=fileinfo @@ -926,7 +927,6 @@ default_socket_timeout = 60 ;extension=intl ;extension=ldap ;extension=mbstring -;extension=exif ; Must be after mbstring as it depends on it ;extension=mysqli ;extension=odbc ;extension=openssl diff --git a/run-tests.php b/run-tests.php index bd03a7f882a79..7ab158bce5c5c 100755 --- a/run-tests.php +++ b/run-tests.php @@ -784,23 +784,6 @@ function main(): void } } -if (!function_exists("hrtime")) { - /** - * @return array|float|int - */ - function hrtime(bool $as_num = false) - { - $t = microtime(true); - - if ($as_num) { - return $t * 1000000000; - } - - $s = floor($t); - return [0 => $s, 1 => ($t - $s) * 1000000000]; - } -} - function verify_config(string $php): void { if (empty($php) || !file_exists($php)) { @@ -1094,7 +1077,7 @@ function test_sort($a, $b): int } // -// Write the given text to a temporary file, and return the filename. +// Write the given text to a temporary file. // function save_text(string $filename, string $text, ?string $filename_copy = null): void @@ -2883,19 +2866,6 @@ function expectf_to_regex(?string $wanted): string '%0' => '\x00', ]); } - -/** - * @return bool|int - */ -function comp_line(string $l1, string $l2, bool $is_reg) -{ - if ($is_reg) { - return preg_match('/^' . $l1 . '$/s', $l2); - } - - return !strcmp($l1, $l2); -} - /** * Map "Zend OPcache" to "opcache" and convert all ext names to lowercase. */ diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index 2731a1f93738a..941fab1c08d79 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -507,6 +507,9 @@ static void php_cli_usage(char *argv0) " --rz Show information about Zend extension .\n" " --ri Show configuration for extension .\n" "\n" + " --repeat Repeat script execution times.\n" + " For internal purposes only.\n" + "\n" , prog, prog, prog, prog, prog, prog, prog); } /* }}} */ diff --git a/sapi/fpm/fpm/fpm_status.c b/sapi/fpm/fpm/fpm_status.c index cbf8644d99cab..cc3412149c7b5 100644 --- a/sapi/fpm/fpm/fpm_status.c +++ b/sapi/fpm/fpm/fpm_status.c @@ -62,7 +62,8 @@ int fpm_status_export_to_zval(zval *status) /* copy the scoreboard not to bother other processes */ scoreboard = *scoreboard_p; - struct fpm_scoreboard_proc_s procs[scoreboard.nprocs]; + struct fpm_scoreboard_proc_s *procs = safe_emalloc( + sizeof(struct fpm_scoreboard_proc_s), scoreboard.nprocs, 0); struct fpm_scoreboard_proc_s *proc_p; for(i=0; ilen <= stream->buf.size); if (stream->buf.size - stream->len <= str_len && !zlog_stream_buf_alloc_ex(stream, str_len + stream->len)) { return -1; @@ -425,6 +428,7 @@ static inline ssize_t zlog_stream_buf_copy_cstr( static inline ssize_t zlog_stream_buf_copy_char(struct zlog_stream *stream, char c) /* {{{ */ { + ZEND_ASSERT(stream->len <= stream->buf.size); if (stream->buf.size - stream->len < 1 && !zlog_stream_buf_alloc_ex(stream, 1)) { return -1; } @@ -681,6 +685,17 @@ ssize_t zlog_stream_prefix_ex(struct zlog_stream *stream, const char *function, len = zlog_buf_prefix( function, line, stream->flags, stream->buf.data, stream->buf.size, stream->use_syslog); + if (!EXPECTED(len + 1 <= stream->buf.size)) { + /* If the buffer was not large enough, try with a larger buffer. + * Note that this may still truncate if the zlog_limit is reached. */ + len = MIN(len + 1, zlog_limit); + if (!zlog_stream_buf_alloc_ex(stream, len)) { + return -1; + } + zlog_buf_prefix( + function, line, stream->flags, + stream->buf.data, stream->buf.size, stream->use_syslog); + } stream->len = stream->prefix_len = len; if (stream->msg_prefix != NULL) { zlog_stream_buf_copy_cstr(stream, stream->msg_prefix, stream->msg_prefix_len); @@ -692,8 +707,8 @@ ssize_t zlog_stream_prefix_ex(struct zlog_stream *stream, const char *function, } else { char sbuf[1024]; ssize_t written; - len = zlog_buf_prefix(function, line, stream->flags, sbuf, 1024, stream->use_syslog); - written = zlog_stream_direct_write(stream, sbuf, len); + len = zlog_buf_prefix(function, line, stream->flags, sbuf, sizeof(sbuf), stream->use_syslog); + written = zlog_stream_direct_write(stream, sbuf, MIN(len, sizeof(sbuf))); if (stream->msg_prefix != NULL) { written += zlog_stream_direct_write( stream, stream->msg_prefix, stream->msg_prefix_len); diff --git a/sapi/fpm/tests/gh16432-status-high-nprocs.phpt b/sapi/fpm/tests/gh16432-status-high-nprocs.phpt new file mode 100644 index 0000000000000..11f1be262ee23 --- /dev/null +++ b/sapi/fpm/tests/gh16432-status-high-nprocs.phpt @@ -0,0 +1,46 @@ +--TEST-- +FPM: GH-16432 - fpm_get_status segfault on high nprocs +--SKIPIF-- + +--FILE-- +createSourceFileAndScriptName(); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->expectBody('bool(false)'); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- + diff --git a/sapi/fpm/tests/gh16628.phpt b/sapi/fpm/tests/gh16628.phpt new file mode 100644 index 0000000000000..b160bb180ffb1 --- /dev/null +++ b/sapi/fpm/tests/gh16628.phpt @@ -0,0 +1,53 @@ +--TEST-- +GH-16628 (FPM logs are getting corrupted with this log statement) +--EXTENSIONS-- +zend_test +--SKIPIF-- + +--FILE-- +start(extensions: ['zend_test']); +$tester->expectLogStartNotices(); +$tester->request()->expectEmptyBody(); +for ($i = 1; $i < 100; $i++) { + $tester->expectLogNotice("%sPHP message: " . str_repeat("a", $i)); +} +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- + diff --git a/scripts/dev/credits b/scripts/dev/credits index e59cc109b88d7..783bc5f18f79d 100755 --- a/scripts/dev/credits +++ b/scripts/dev/credits @@ -3,7 +3,7 @@ # Generate credits_*.h headers from the ext/*/CREDITS and sapi/*/CREDITS files. # Go to project root directory -cd $(CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P) +cd "$(CDPATH='' cd -- "$(dirname -- "$0")/../../" && pwd -P)" || exit awkprog=' BEGIN { FS = "\n|\r\n|\r"; RS = "" } diff --git a/scripts/dev/genfiles b/scripts/dev/genfiles index 3e6c1271578c9..124a10de34581 100755 --- a/scripts/dev/genfiles +++ b/scripts/dev/genfiles @@ -42,7 +42,7 @@ SED=${SED:-sed} MAKE=${MAKE:-make} # Go to project root. -cd $(CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P) +cd "$(CDPATH='' cd -- "$(dirname -- "$0")/../../" && pwd -P)" || exit # Check required bison version from the configure.ac file. required_bison_version=$($SED -n 's/PHP_PROG_BISON(\[\([0-9\.]*\)\].*/\1/p' configure.ac) diff --git a/scripts/dev/makedist b/scripts/dev/makedist index 48e54cffaaf79..9417515fe1d8b 100755 --- a/scripts/dev/makedist +++ b/scripts/dev/makedist @@ -23,7 +23,7 @@ if [[ $($tar --version) == *"bsdtar"* ]]; then fi # Go to project root directory. -cd $(CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P) +cd "$(CDPATH='' cd -- "$(dirname -- "$0")/../../" && pwd -P)" || exit # Process options and arguments. while :; do diff --git a/tests/classes/abstract_derived.phpt b/tests/classes/abstract_derived.phpt index 11c9125a7724e..7d0ffff5ca0b6 100644 --- a/tests/classes/abstract_derived.phpt +++ b/tests/classes/abstract_derived.phpt @@ -13,4 +13,4 @@ class derived extends base { ?> ===DONE=== --EXPECTF-- -Fatal error: Class derived contains 1 abstract method and must therefore be declared abstract or implement the remaining method (derived::show) in %sabstract_derived.php on line %d +Fatal error: Class derived declares abstract method show() and must therefore be declared abstract in %sabstract_derived.php on line %d diff --git a/tests/classes/abstract_not_declared.phpt b/tests/classes/abstract_not_declared.phpt index 8f899f0e718af..c9ba306a11029 100644 --- a/tests/classes/abstract_not_declared.phpt +++ b/tests/classes/abstract_not_declared.phpt @@ -10,4 +10,4 @@ class fail { echo "Done\n"; // shouldn't be displayed ?> --EXPECTF-- -Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining method (fail::show) in %s on line %d +Fatal error: Class fail declares abstract method show() and must therefore be declared abstract in %s on line %d diff --git a/tests/classes/abstract_redeclare.phpt b/tests/classes/abstract_redeclare.phpt index f8e3d23465244..eb73da571ca45 100644 --- a/tests/classes/abstract_redeclare.phpt +++ b/tests/classes/abstract_redeclare.phpt @@ -16,4 +16,4 @@ class fail extends pass { echo "Done\n"; // Shouldn't be displayed ?> --EXPECTF-- -Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining method (fail::show) in %sabstract_redeclare.php on line %d +Fatal error: Class fail declares abstract method show() and must therefore be declared abstract in %sabstract_redeclare.php on line %d diff --git a/tests/classes/abstract_static.phpt b/tests/classes/abstract_static.phpt index ab13289ab4cd8..15db2f9a03b96 100644 --- a/tests/classes/abstract_static.phpt +++ b/tests/classes/abstract_static.phpt @@ -31,4 +31,4 @@ echo "Done\n"; // shouldn't be displayed --EXPECTF-- Call to function show() -Fatal error: Class fail contains 1 abstract method and must therefore be declared abstract or implement the remaining method (fail::func) in %sabstract_static.php(%d) : eval()'d code on line %d +Fatal error: Class fail declares abstract method func() and must therefore be declared abstract in %sabstract_static.php(%d) : eval()'d code on line %d diff --git a/tests/classes/interface_method_private.phpt b/tests/classes/interface_method_private.phpt index c7a0852ea4a12..d32e3dbdc8e15 100644 --- a/tests/classes/interface_method_private.phpt +++ b/tests/classes/interface_method_private.phpt @@ -4,7 +4,7 @@ ZE2 An interface method cannot be private diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 6735765de748c..dd33e595a2ee9 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -396,3 +396,7 @@ ARG_ENABLE("native-intrinsics", "Comma separated list of intrinsic optimizations might not work properly, if the chosen instruction sets are not available on the target \ processor.", "no"); toolset_setup_intrinsic_cflags(); + +ARG_ENABLE('snapshot-build', 'Build a snapshot: turns on everything it can and ignores build errors', 'no'); + +ARG_ENABLE('vs-link-compat', 'Allow linking of libraries built with compatible versions of VS toolset', 'yes'); diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index bb466cd7f58d3..82b97e1145e97 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -143,3 +143,5 @@ ARG_ENABLE("native-intrinsics", "Comma separated list of intrinsic optimizations might not work properly, if the optimizations are not available on the target \ processor.", "no"); toolset_setup_intrinsic_cflags(); + +ARG_ENABLE('vs-link-compat', 'Allow linking of libraries built with compatible versions of VS toolset', 'yes'); diff --git a/win32/build/confutils.js b/win32/build/confutils.js index c8678792fb075..3623dcf7e25e1 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -2898,9 +2898,6 @@ function PHP_INSTALL_HEADERS(dir, headers_list) // and you can then build everything, ignoring fatal errors within a module // by running "nmake snap" PHP_SNAPSHOT_BUILD = "no"; -if (!MODE_PHPIZE) { - ARG_ENABLE('snapshot-build', 'Build a snapshot; turns on everything it can and ignores build errors', 'no'); -} function toolset_option_handle() { @@ -3432,7 +3429,7 @@ function toolset_setup_common_libs() function toolset_setup_build_mode() { if (PHP_DEBUG == "yes") { - ADD_FLAG("CFLAGS", "/LDd /MDd /Od /D ZEND_DEBUG=1 " + + ADD_FLAG("CFLAGS", "/LDd /MDd /Od /U NDebug /U NDEBUG /D ZEND_DEBUG=1 " + (TARGET_ARCH == 'x86'?"/ZI":"/Zi")); ADD_FLAG("LDFLAGS", "/debug"); // Avoid problems when linking to release libraries that use the release @@ -3766,9 +3763,3 @@ function setup_verbosity() CMD_MOD2 = "@"; } } - -try { - ARG_ENABLE('vs-link-compat', 'Allow linking of libraries built with compatible versions of VS toolset', 'yes'); -} catch (e) { - STDOUT.WriteLine("problem: " + e); -} diff --git a/win32/ioutil.c b/win32/ioutil.c index acd4103c613b1..9c313d6001be1 100644 --- a/win32/ioutil.c +++ b/win32/ioutil.c @@ -281,7 +281,7 @@ PW32IO int php_win32_ioutil_close(int fd) PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode) {/*{{{*/ - size_t path_len; + size_t path_len, dir_len = 0; const wchar_t *my_path; if (!path) { @@ -292,7 +292,16 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode) PHP_WIN32_IOUTIL_CHECK_PATH_W(path, -1, 0) path_len = wcslen(path); - if (path_len < _MAX_PATH && path_len >= _MAX_PATH - 12) { +#ifndef ZTS + if (!PHP_WIN32_IOUTIL_IS_ABSOLUTEW(path, path_len) && !PHP_WIN32_IOUTIL_IS_JUNCTION_PATHW(path, path_len) && !PHP_WIN32_IOUTIL_IS_UNC_PATHW(path, path_len)) { + dir_len = GetCurrentDirectoryW(0, NULL); + if (dir_len == 0) { + return -1; + } + } +#endif + + if (dir_len + path_len < _MAX_PATH && dir_len + path_len >= _MAX_PATH - 12) { /* Special case here. From the doc: "When using an API to create a directory, the specified path cannot be @@ -315,7 +324,7 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode) } if (!PHP_WIN32_IOUTIL_IS_LONG_PATHW(tmp, path_len)) { - wchar_t *_tmp = (wchar_t *) malloc((path_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + 1) * sizeof(wchar_t)); + wchar_t *_tmp = (wchar_t *) malloc((dir_len + path_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + 1) * sizeof(wchar_t)); wchar_t *src, *dst; if (!_tmp) { SET_ERRNO_FROM_WIN32_CODE(ERROR_NOT_ENOUGH_MEMORY); @@ -325,6 +334,18 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode) memmove(_tmp, PHP_WIN32_IOUTIL_LONG_PATH_PREFIXW, PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW * sizeof(wchar_t)); src = tmp; dst = _tmp + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW; +#ifndef ZTS + if (dir_len > 0) { + size_t len = GetCurrentDirectoryW(dir_len, dst); + if (len == 0 || len + 1 != dir_len) { + free(tmp); + free(_tmp); + return -1; + } + dst += len; + *dst++ = PHP_WIN32_IOUTIL_DEFAULT_SLASHW; + } +#endif while (src < tmp + path_len) { if (*src == PHP_WIN32_IOUTIL_FW_SLASHW) { *dst++ = PHP_WIN32_IOUTIL_DEFAULT_SLASHW; @@ -333,7 +354,7 @@ PW32IO int php_win32_ioutil_mkdir_w(const wchar_t *path, mode_t mode) *dst++ = *src++; } } - path_len += PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW; + path_len += PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + dir_len; _tmp[path_len] = L'\0'; free(tmp); tmp = _tmp; diff --git a/win32/ioutil.h b/win32/ioutil.h index 6a7055fc71a77..454efdc353648 100644 --- a/win32/ioutil.h +++ b/win32/ioutil.h @@ -175,18 +175,28 @@ PW32IO php_win32_ioutil_normalization_result php_win32_ioutil_normalize_path_w(w __forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, size_t in_len, size_t *out_len) {/*{{{*/ wchar_t *mb, *ret; - size_t mb_len; + size_t mb_len, dir_len = 0; mb = php_win32_cp_conv_any_to_w(in, in_len, &mb_len); if (!mb) { return NULL; } +#ifndef ZTS + if (!PHP_WIN32_IOUTIL_IS_ABSOLUTEW(mb, mb_len) && !PHP_WIN32_IOUTIL_IS_JUNCTION_PATHW(mb, mb_len) && !PHP_WIN32_IOUTIL_IS_UNC_PATHW(mb, mb_len)) { + dir_len = GetCurrentDirectoryW(0, NULL); + if (dir_len == 0) { + free(mb); + return NULL; + } + } +#endif + /* Only prefix with long if it's needed. */ - if (mb_len >= _MAX_PATH) { + if (dir_len + mb_len >= _MAX_PATH) { size_t new_mb_len; - ret = (wchar_t *) malloc((mb_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + 1) * sizeof(wchar_t)); + ret = (wchar_t *) malloc((dir_len + mb_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + 1) * sizeof(wchar_t)); if (!ret) { free(mb); return NULL; @@ -199,7 +209,7 @@ __forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, siz } if (new_mb_len > mb_len) { - wchar_t *tmp = (wchar_t *) realloc(ret, (new_mb_len + 1) * sizeof(wchar_t)); + wchar_t *tmp = (wchar_t *) realloc(ret, (dir_len + new_mb_len + 1) * sizeof(wchar_t)); if (!tmp) { free(ret); free(mb); @@ -215,6 +225,18 @@ __forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, siz } else { wchar_t *src = mb, *dst = ret + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW; memmove(ret, PHP_WIN32_IOUTIL_LONG_PATH_PREFIXW, PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW * sizeof(wchar_t)); +#ifndef ZTS + if (dir_len > 0) { + size_t len = GetCurrentDirectoryW(dir_len, dst); + if (len == 0 || len + 1 != dir_len) { + free(ret); + free(mb); + return NULL; + } + dst += len; + *dst++ = PHP_WIN32_IOUTIL_DEFAULT_SLASHW; + } +#endif while (src < mb + mb_len) { if (*src == PHP_WIN32_IOUTIL_FW_SLASHW) { *dst++ = PHP_WIN32_IOUTIL_DEFAULT_SLASHW; @@ -223,9 +245,9 @@ __forceinline static wchar_t *php_win32_ioutil_conv_any_to_w(const char* in, siz *dst++ = *src++; } } - ret[mb_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW] = L'\0'; + ret[mb_len + PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + dir_len] = L'\0'; - mb_len += PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW; + mb_len += PHP_WIN32_IOUTIL_LONG_PATH_PREFIX_LENW + dir_len; } free(mb);
Phar: PHP Archive supportenabled
Phar: PHP Archive support enabled
Phar API version 1.1.1
Phar-based phar archives enabled
Tar-based phar archives enabled