Skip to content

Language: PHP 8.4 Range value object — Range::from() foreach (#17427)#17433

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-17427-range-from-84
Jul 8, 2026
Merged

Language: PHP 8.4 Range value object — Range::from() foreach (#17427)#17433
PurHur merged 1 commit into
masterfrom
agent/issue-17427-range-from-84

Conversation

@PurHur

@PurHur PurHur commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Register Range as a PHP 8.4 forward-profile builtin class implementing IteratorAggregate.
  • Range::from(1, 3) and Range::from('a', 'c') iterate inclusive int/string intervals via reused VmRange logic + ArrayIterator.
  • class_exists('Range') remains false on the 8.2 reference profile; compliance + unit guards added.

php-src reference

  • ext/standard/range.c — Range value object semantics (PHP 8.4 forward profile)

PHP implementation

  • ext/standard/RangeBuiltin.php — VM registration, from() factory, getIterator() via VmRange + ArrayIteratorBuiltin
  • lib/CompilerVersion.phpsupportsRange() gated like other 8.4 builtins
  • ext/standard/BuiltinClasses.php — profile-gated registration

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_PROFILE=8.4
php bin/vm.php test/repro/maintainer_gap_range_from_84.php'
# ok

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_PROFILE=8.4
vendor/bin/phpunit --filter RangeBuiltinTest'
# OK (1 test)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_PROFILE=8.4
vendor/bin/phpunit --filter range_from_84 test/compliance/VMTest.php'
# OK (1 test)

env -u PHP_COMPILER_PROFILE php bin/vm.php -r "echo class_exists(\"Range\", false) ? \"fail\\n\" : \"ok\\n\";"
# ok (phantom gate)

php script/bootstrap-inventory.php --check
# OK 4283/4283

php script/check-selfhost-spine-coverage-sync.php
# OK

Closes #17427

Made with Cursor

)

Implement Range as IteratorAggregate on the 8.4 forward profile, reusing
VmRange interval logic and ArrayIterator for foreach. Gate phantom class on
8.2 reference profile; sync spine/inventory for RangeBuiltin.php.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 763e196 into master Jul 8, 2026
@PurHur PurHur deleted the agent/issue-17427-range-from-84 branch July 8, 2026 17:08
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: Range value object missing — Range::from() foreach fails on 8.4 profile (ext/standard/range.c)

1 participant