fix: resolve PHP 8.4/8.5 deprecations in HttpAsset and BasePhpFormulaLoader#47
Merged
LukeTowers merged 2 commits intoJun 4, 2026
Merged
Conversation
…Loader
A full PHPUnit run under PHP 8.4 and 8.5 (error_reporting=-1) surfaced two
deprecations originating in the library's own src/:
- HttpAsset::getLastModified() — the predefined locally scoped
$http_response_header variable is deprecated in PHP 8.5. The existing
function_exists('http_get_last_response_headers') shim does not suppress it:
the notice is emitted at compile time from the bare variable read (verified
via `php -l`, which executes nothing yet still emits it), so a runtime guard
can never silence it. Reading it through the null-coalescing operator
(`$http_response_header ?? []`) compiles to a non-deprecated fetch, keeping
the pre-8.4 fallback working while emitting nothing on 8.5. `?? []` (not null)
keeps the subsequent foreach safe. composer still pins php ^7.3 || ^8.0, so
the legacy branch cannot be removed outright yet.
- BasePhpFormulaLoader::processCall() — shell_exec() returns string|false|null,
and passing null to unserialize()'s non-nullable string parameter is
deprecated in PHP 8.4+. Guard with is_string(); the array() fallback is
behaviour-identical to the previous unserialize(false) === false path.
Also add the missing `use Assetic\Contracts\Filter\FilterInterface;` to
CssImportFilter so the constructor's ?FilterInterface type hint resolves to the
real interface instead of a non-existent Assetic\Filter\FilterInterface (a
latent Error on any PHP version when a non-null filter is passed).
Verified: zero project-src deprecations on PHP 8.4.14 and 8.5.5; the test suite
remains green (HttpAsset, FormulaLoader and CssImportFilter tests all pass).
jaxwilko
reviewed
Jun 4, 2026
Co-authored-by: Jack Wilkinson <31214002+jaxwilko@users.noreply.github.com>
LukeTowers
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A full PHPUnit run under PHP 8.4.14 and PHP 8.5.5 with
error_reporting=-1surfaced two deprecations originating in the library's ownsrc/(everything else came fromtwig/scssphpinvendor/). This PR fixes both, plus one latent type-hint bug found along the way.1.
HttpAsset::getLastModified()—$http_response_headerdeprecated (PHP 8.5)The predefined locally scoped
$http_response_headervariable is deprecated in 8.5. The existingfunction_exists('http_get_last_response_headers')shim does not suppress it: the notice is emitted at compile time from the bare variable read — verified withphp -l, which executes nothing yet still emits it — so a runtime guard can never silence it.Reading it through the null-coalescing operator (
$http_response_header ?? []) compiles to a non-deprecated fetch, so the pre-8.4 fallback keeps working while 8.5 emits nothing.?? [](not?? null) keeps the subsequentforeachsafe.composer.jsonstill pinsphp: ^7.3 || ^8.0, so the legacy branch can't be dropped outright yet — the comment notes when it can.2.
BasePhpFormulaLoader::processCall()—nulltounserialize()(PHP 8.4 & 8.5)shell_exec()returnsstring|false|null; passingnulltounserialize()'s non-nullablestringparameter is deprecated in 8.4+. Guarded withis_string(). Thearray()fallback is behaviour-identical to the previousunserialize(false) === falsepath (the downstreamisset($args[0..2])checks readfalseon an empty array).3.
CssImportFilter— missinguse(latent, any PHP version)The constructor's
?FilterInterfacehint resolved to a non-existentAssetic\Filter\FilterInterfaceinstead of the realAssetic\Contracts\Filter\FilterInterface(no matching import) — a latentErrorwhenever a non-null filter is passed. Added the missinguse.