Skip to content

Missing deprecation warning for backtick operator #22544

Closed

Description

@thomas-0816

Description

https://wiki.php.net/rfc/deprecations_php_8_5

The following code:

        <?php
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
        $output = `cat /proc/cmdline`;
        echo "<pre>$output</pre>";
        $a = [null => 1];

Resulted in this output:

<pre>BOOT_IMAGE=/vmlinuz-6.17.0-35-generic root=UUID=...
</pre>PHP Deprecated:  Using null as an array offset is deprecated, use an empty string instead in /tmp/test3.php on line 6

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /tmp/test3.php on line 6

But I expected this output instead:

2 deprecation warnings:
- 1 for backtick operator
- 1 for null as array-key

reproduce with docker:

# docker build --no-cache --progress plain -f Dockerfile.backtick -t pdo_duckdb_backtick .

FROM debian:trixie-slim AS base
ENV LC_ALL="C.UTF-8"
RUN <<EOF
    apt-get -y update
    apt-get -y --no-install-recommends install apt-transport-https curl ca-certificates
    echo "deb https://packages.sury.org/php/ trixie main" >/etc/apt/sources.list.d/ondrej-php.list
    curl -s https://packages.sury.org/php/apt.gpg >/etc/apt/trusted.gpg.d/php.gpg
    apt-get -y update
    apt-get -y --no-install-recommends install php8.5-cli
    php <<'EOP'
        <?php
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
        $output = `cat /proc/cmdline`;
        echo "<pre>$output</pre>";
        $a = [null => 1];
EOP
EOF

docker output:

#5 26.57 Processing triggers for php8.5-cli (8.5.7-1+0~20260606.19+debian13~1.gbp741f99) ...
#5 26.64         <pre>BOOT_IMAGE=/vmlinuz-6.17.0-35-generic root=UUID=13b8fd11-c4f8-46ab-bbd2-317d909fc124 ro cryptdevice=UUID=aaf0af4f-19c6-4471-af11-e3dcbbdf0898:luks-aaf0af4f-19c6-4471-af11-e3dcbbdf0898 root=/dev/mapper/luks-aaf0af4f-19c6-4471-af11-e3dcbbdf0898 usbcore.autosuspend=-1 amd_iommu=off amdgpu.gttsize=28672 ttm.pages_limit=7340032 quiet
#5 26.64 </pre>
#5 26.64 Deprecated: Using null as an array offset is deprecated, use an empty string instead in Standard input code on line 6
#5 26.64 PHP Deprecated:  Using null as an array offset is deprecated, use an empty string instead in Standard input code on line 6
#5 DONE 26.7s

=> no deprecation warning for backtick operator

PHP Version

php -v
PHP 8.5.7 (cli) (built: Jun  6 2026 05:36:56) (NTS)
Copyright (c) The PHP Group
Built by Ubuntu
Zend Engine v4.5.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.7, Copyright (c), by Zend Technologies

Operating System

Ubuntu 24.04

Activity

  1. TimWolla commented on Jul 2, 2026

    @TimWolla
    Member

    This is a compile-time deprecation, changing error_reporting and display_errors at runtime will not have an effect on it. Please check the error-related settings in your php.ini.

  2. thomas-0816 commented on Jul 2, 2026

    @thomas-0816
    Author

    Thanks for the explanation. I retested with "-derror_reporting=30719":

    php -derror_reporting=30719 /tmp/test3.php 
    PHP Deprecated:  The backtick (`) operator is deprecated, use shell_exec() instead in /tmp/test3.php on line 4
    <pre>BOOT_IMAGE=/vmlinuz-6.17.0-35-generic root=UUID=...
    </pre>PHP Deprecated:  Using null as an array offset is deprecated, use an empty string instead in /tmp/test3.php on line 6
    
    Deprecated: Using null as an array offset is deprecated, use an empty string instead in /tmp/test3.php on line 6
    
  3. thomas-0816 commented on Jul 2, 2026

    @thomas-0816
    Author

    This mostly affects users using the package default error reporting and let frameworks or libraries change it.

    In practice most projects don't log deprecations by default (e.g. Laravel). So I think we can leave the current behavior as it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions