Skip to content

VM/JIT: runtime __DIR__ and __FILE__ on include stack (#707)#709

Merged
PurHur merged 1 commit into
masterfrom
issue-707-magic-dir-runtime
May 22, 2026
Merged

VM/JIT: runtime __DIR__ and __FILE__ on include stack (#707)#709
PurHur merged 1 commit into
masterfrom
issue-707-magic-dir-runtime

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 22, 2026

Summary

  • Add TYPE_SCRIPT_MAGIC so __DIR__ / __FILE__ resolve from the current script path (VM ScriptStack push/pop on TYPE_INCLUDE; JIT uses per-unit Block::scriptPath()).
  • php-cfg/php-types patches: MagicScriptConst CFG expr instead of compile-time dirname literals.
  • Extend ConstStringFolder to fold __DIR__ . '/literal' for lint when preprocessor clears concat original.
  • Compliance PHPT magic_dir_nested (+ JIT variant); capabilities-syntax rows for Docs: capabilities-syntax rows for __DIR__, __FILE__, __LINE__ (#85) #706.

Test plan

  • php bin/vm.php test/compliance/cases/language/magic_dir_nested/entry.php
  • ConstStringFolderTest, IncludeLiteralTest, CapabilitySyntaxTest (Docker)
  • ./script/ci-local.sh --filter magic_dir_nested (full gate on merge host)

Closes #707. Closes #706.

Made with Cursor

Resolve __DIR__/__FILE__ at runtime from the executing script path instead
of baking dirname at parse time only. Push/pop ScriptStack on TYPE_INCLUDE,
add TYPE_SCRIPT_MAGIC opcode, and extend ConstStringFolder for lint folding.

Closes #707. Documents rows in capabilities-syntax (#706).

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: VM/JIT runtime __DIR__/__FILE__ on include stack (#85) Docs: capabilities-syntax rows for __DIR__, __FILE__, __LINE__ (#85)

1 participant