Skip to content

Language: read property on null must throw Error not E_WARNING (PHP 8.0+, zend_execute.c) #7431

Closed

Description

@PurHur

Category

language · runtime

Problem

Since PHP 8.0, reading an instance property on null ($null->prop) throws a catchable Error, not E_WARNING with execution continuing. This compiler emits a warning and returns an empty value, so catch (Error $e) never runs.

Verified on master (2026-06-07):

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro-maintainer/parity_null_property_read_error.php'

VM today: PHP Warning: Attempt to read property "prop" on null then prints no throw.

Zend/php-src: Error: Attempt to read property "prop" on null — catchable, no continuation.

Distinct from #4851 (undefined method dispatch fatals) and #4980 (nullsafe ?-> short-circuit).

php-src reference

Repro

test/repro-maintainer/parity_null_property_read_error.php:

<?php
try {
    $x = null;
    $y = $x->prop;
    echo "no throw\n";
} catch (Error $e) {
    echo $e::class, ': ', $e->getMessage(), "\n";
}
Engine Output
Zend Error: Attempt to read property "prop" on null
VM Warning + no throw

Also verify echo $null->prop and $null->prop++ throw (not warn).

Scope (this repo)

Layer Path
VM property fetch on null base in lib/VM.php / lib/VM/PropertyAccess.php — throw Error via VM exception path
JIT/AOT mirror in property fetch lowering
Tests test/compliance/cases/language/null_property_read_error.phpt

PHP-in-PHP — shrink warning-only C paths if any.

Done when

  • Repro prints catchable Error on VM
  • No E_WARNING for this path under default error reporting
  • JIT/AOT .phpt green
  • ./script/ci-fast.sh --filter null_property_read green

Related

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 7, 2026
  2. PurHur commented on Jun 7, 2026

    @PurHur
    OwnerAuthor

    Maintainer repro script: test/repro-maintainer/ — see issue body; VM-verified 2026-06-07 on master.

  3. PurHur commented on Jun 7, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-a — starting this run

  4. PurHur commented on Jun 7, 2026

    @PurHur
    OwnerAuthor

    Merged via #7445.

    Verification
    ```bash
    ./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro-maintainer/parity_null_property_read_error.php'

    Error: Attempt to read property "prop" on null

    ./script/docker-exec.sh -- bash -lc 'vendor/bin/phpunit --filter null_property_read'

    OK (3 tests, 3 assertions)

    ```

    VM: $null->prop / echo $null->prop / $null->prop++ throw catchable Error (inc/dec uses Zend increment/decrement message). JIT: uncaught path fatal via ErrorRaise; try/catch catchable path uses TryCatchHelper (VM phpt skipped in umbrella JITTest until MCJIT dispatch stable #98).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions