Skip to content

Fix PHAR scoping of trigger_deprecation(), remove stale scoper patchers - #6857

Merged
ondrejmirtes merged 1 commit into
2.3.xfrom
scoper-cleanup
Oct 26, 2026
Merged

ondrejmirtes merged 1 commit into
2.3.xfrom
scoper-cleanup

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

Audit of the current phpstan.phar (all references, including vendor) against scoper.inc.php.

Fixes

  • symfony/deprecation-contracts declares \_PHPStan_*\trigger_deprecation, but symfony/console, finder and service-contracts call trigger_deprecation() unqualified, which falls back to a global function that doesn't exist. E.g. Helper::strlen() fails with Call to undefined function _PHPStan_…\Symfony\Component\Console\Helper\trigger_deprecation() unless the analysed project defines it. expose-functions makes Box add a global alias in vendor/autoload.php, the same as for ctype_*.
  • Composer\Autoload\ClassLoader and Composer\InstalledVersions are now in exclude-classes instead of a per-file patcher. This also fixes the prefixed reference in nette/bootstrap's Configurator.
  • The use PhpParser; fix now applies to every file. This fixes nette/php-generator's Extractor.

Removed patchers that no longer change any file: nette Compiler.php |Nette\DI\Statement, ComposerHelper InstalledVersions, Core/Core_d.php, the php-parser prefix strip (already covered by use PhpParser;), and better-reflection PropertyHookType.

Verification: I re-scoped every file with php-scoper 0.18.19 using the old and new configs. Apart from the three intended fixes, the output is identical. A full Box compile with the new config produced trigger_deprecation in vendor/autoload.php, and Helper::strlen() now works. The PHAR analyses code normally, including in parallel.

- Expose trigger_deprecation() so Symfony's unqualified calls reach it
  (they called a nonexistent function unless the analysed project
  defined it)
- Exclude Composer ClassLoader and InstalledVersions via exclude-classes
  instead of a per-file patcher (also fixes nette/bootstrap)
- Apply the use PhpParser; fix to all files (fixes nette/php-generator)
- Remove patchers that no longer change anything

Amp-Thread-ID: https://ampcode.com/threads/T-01a179f8-e6bb-7020-8500-cfc35a10dfc5
@ondrejmirtes
ondrejmirtes merged commit 12cebb3 into 2.3.x Oct 26, 2026
101 checks passed
@ondrejmirtes
ondrejmirtes deleted the scoper-cleanup branch October 26, 2026 21:28
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