Skip to content

Runtime: Undefined array/superglobal key — Zend notice parity #273

Description

@PurHur

Problem

Shipped examples/001-SimpleWeb/example.php does:

$name = $_GET['name'];

On stock PHP 8 with E_ALL, a request without name emits:

Warning: Undefined array key "name"

The compiler may throw, return null, or behave inconsistently across VM / JIT / AOT for missing hashtable keys — especially superglobals populated by lib/Web/Superglobals.php.

MiniWebApp routing (#67, #210) and forms need predictable behavior before ?? (#99) is implemented everywhere.

Goal

Define, document, and test missing-key semantics for $_GET, $_POST, and ordinary arrays so web apps can rely on the same policy as PHP 8.x (or a deliberate subset documented in README).

Scope

Acceptance criteria

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  ./phpc run examples/001-SimpleWeb/example.php

Behavior is documented and covered by a PHPT (pass or explicit XFAIL with issue link until fixed).

With ?? implemented (#99), the same script with ?? 'Guest' runs without notices on both Zend and compiler.

Verification (local only)

No GitHub Actions required. Use Docker command above and ./script/ci-local.sh --filter undefined.

Dependencies

Links

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions