Skip to content

Stdlib: floatval, boolval, gettype(null) and expanded PHPT specs - #5

Merged
PurHur merged 1 commit into
masterfrom
stdlib-floatval-boolval
May 17, 2026
Merged

Stdlib: floatval, boolval, gettype(null) and expanded PHPT specs#5
PurHur merged 1 commit into
masterfrom
stdlib-floatval-boolval

Conversation

@PurHur

@PurHur PurHur commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add floatval() and boolval() builtins with VM and JIT implementations for supported scalar types (int/float for floatval; null, int, float, bool, string for boolval).
  • Extend gettype() JIT path for null and improve is_* JIT handling for boolean and null operands.
  • Add compliance PHPT specs (floatval, boolval, gettype_null) plus integration tests (stdlib_casts, extended stdlib_digest).

Test plan

  • Compliance PHPT cases for each new builtin
  • Integration tests chaining casts with existing stdlib
  • CI: make test (VM + JIT via CircleCI)

Made with Cursor

Add floatval and boolval builtins with VM and JIT paths for supported
scalar types. Extend gettype and is_* JIT handling for null and boolean
operands. Add compliance and integration PHPT coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit d4ea8f6 into master May 17, 2026
@PurHur
PurHur deleted the stdlib-floatval-boolval branch May 17, 2026 08:34
PurHur added a commit that referenced this pull request May 31, 2026
apply_php_cfg_enum_overlay copies the flags-bearing Enum_.php overlay
then may return early without updating Parser.php, leaving vendor in a
state where Op\Stmt\Enum_ expects int $flags but parseStmt_Enum passes
attributes as argument #5. Add php_cfg_sync_enum_flags_parser() and
invoke it from enum overlay paths and the early chain.

Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request May 31, 2026
apply_php_cfg_enum_overlay copies the flags-bearing Enum_.php overlay
then may return early without updating Parser.php, leaving vendor in a
state where Op\Stmt\Enum_ expects int $flags but parseStmt_Enum passes
attributes as argument #5. Add php_cfg_sync_enum_flags_parser() and
invoke it from enum overlay paths and the early chain.

Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request May 31, 2026
* Language: BackedEnum::from() and tryFrom() VM lowering (#3114)

Implement zend_enum_from_case-style lookup for backed enums, enum case
values with name/value properties, and clear callArgEntries after internal
handlers so chained static calls receive the correct arguments.

Co-authored-by: Cursor <cursoragent@cursor.com>

* test #3114: expect VM uncaught Exception for invalid BackedEnum::from()

Internal handlers route ValueError through executeInternalHandler →
raiseUncaughtException (Exception), matching other runtime builtins until
native ValueError propagation lands (#195).

Co-authored-by: Cursor <cursoragent@cursor.com>

* test #3114: int-backed BackedEnum::from()/tryFrom() compliance PHPT

Guards int backing type lookup alongside existing string enum_from/try_from
cases. php-src: Zend/zend_enum.c zend_enum_from_case().

Co-authored-by: Cursor <cursoragent@cursor.com>

* Language: Zend-parity ValueError message for BackedEnum::from() (#3114)

Match php-src zend_enum.c message format (enum name unquoted) and add
enum_from_invalid.phpt plus caught ValueError unit coverage.

php-src: Zend/zend_enum.c — zend_enum_from_case()
Co-authored-by: Cursor <cursoragent@cursor.com>

* Language: BackedEnum from/tryFrom backing-value coercion (#3114)

Normalize int-backed numeric strings and scalar coercions before case
lookup so Level::from('1') matches Zend; reject non-numeric strings with
TypeError. Adds unit coverage for int string acceptance and bad input.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs #3114: note BackedEnum::from/tryFrom VM parity in capability matrix

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix enum parser flags when apply-patches exits early (#3114)

Run enum overlay chain before typed-class-const so Op\Stmt\Enum_ receives
int $flags before attributes. Tighten abstract-patch skip detection and
guard with ApplyPatchesTest.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix apply-patches enum early chain when parser path omitted (#3114)

apply_php_cfg_enum_class_method_parser_fix() is invoked without an
argument from apply_php_cfg_enum_early_chain(); default to vendor
Parser.php like sibling helpers to avoid set -u unbound $1 abort.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Self-host: sync Enum_.php flags ctor with parseStmt_Enum (#3114)

apply_php_cfg_enum_overlay copies the flags-bearing Enum_.php overlay
then may return early without updating Parser.php, leaving vendor in a
state where Op\Stmt\Enum_ expects int $flags but parseStmt_Enum passes
attributes as argument #5. Add php_cfg_sync_enum_flags_parser() and
invoke it from enum overlay paths and the early chain.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Language: uncaught ValueError/TypeError preserve native type (#3114)

Map materialized VM Throwable objects to native PHP exceptions in
raiseUncaughtException so BackedEnum::from() invalid values throw
ValueError (not generic Exception) per Zend parity.

php-src: Zend/zend_enum.c — zend_enum_from_case()
Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur added a commit that referenced this pull request Jun 29, 2026
…13426)

php-src rejects negative $length before algorithm resolution; reorder guards so VM/JIT emit Argument #5 ValueError instead of mis-attributed algo error.

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.

1 participant