Skip to content

Language: enum self-typed param default self::CASE compile (#22085) - #22093

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-22085-enum-self-default
Jul 22, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-22085-enum-self-default

Conversation

@PurHur

@PurHur PurHur commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Resolve self/static parameter type hints to the declaring enum class before compile-time default validation in assertCompileTimeDefaultMatchesDeclaredType.
  • Adds compliance guard enum_self_type_default_parameter.phpt for instance/static enum methods with self $e = self::CASE defaults.

Closes #22085

php-src reference

Zend/zend_compile.c — default value validation with self in enum scope.

Verification

php bin/vm.php /tmp/enum_self_default.php
# A|B

./vendor/bin/phpunit test/compliance/EnumVMTest.php --filter 'enum_self_type_default_parameter'
# OK (1 test, 1 assertion)

Issue repro script:

cat >/tmp/enum_self_default.php <<'P'
<?php
enum E {
  case A;
  case B;
  public function other(self $e = self::A): string { return $e->name; }
  public static function make(self $e = self::B): string { return $e->name; }
}
echo E::A->other(), "|", E::make(), "\n";
P
php bin/vm.php /tmp/enum_self_default.php

Made with Cursor

Resolve self/static type hints to the declaring enum before compile-time default validation so enum case defaults match Zend.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 0fd8386 into master Jul 22, 2026
@PurHur
PurHur deleted the agent/issue-22085-enum-self-default branch July 22, 2026 07:54
PurHur added a commit that referenced this pull request Jul 22, 2026
…0533) (#22096)

Emergency stamp: lib/ext moved after the last fingerprint stamp,
re-breaking north-star5-fast step 4f-m (manifest 4eb2f7c9… vs live e6ac403e…).
Honest blob rebuild still deferred; driver sha256 unchanged.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: enum method/static param default self $e = self::A compile-rejects (re-#9715, Zend/zend_compile.c)

1 participant