refactor(phar): extract PharCapabilities from PharBuilder (closes #372)#537
Merged
s2x merged 2 commits intoJul 1, 2026
Merged
Conversation
added 2 commits
July 1, 2026 09:15
Move the side-effectful phar.readonly INI probe and \Phar extension presence check out of PharBuilder::build() into a dedicated PharCapabilities collaborator. PharBuilder now accepts the capability checker via constructor (defaults to a live probe), making the runtime checks individually testable and stubbable. - New src/Phar/PharCapabilities.php owns the probes and exposes assertCanBuild() that throws the same RuntimeException messages PharBuilder used to throw inline. - ServicesConfigurator registers PharCapabilities and injects it into the workerman.phar_builder service. - New tests/Phar/PharCapabilitiesTest.php covers the capability checker in isolation (read-only on/off, extension present/absent). - New PharBuilderTest cases verify the builder honours an injected capability checker for both the success path and the two failure paths. No behavioural change observable for the build:phar flow.
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.
Description
Closes #372
Extract the side-effectful
phar.readonlyINI probe and\Pharextension presence check out ofPharBuilder::build()into a dedicatedPharCapabilitiescollaborator.PharBuildernow accepts the capability checker via constructor (defaults to a live probe), making the runtime checks individually testable and stubbable.Changes
src/Phar/PharCapabilities.phpowns thephar.readonly/\Pharextension probes and exposesassertCanBuild()that throws the sameRuntimeExceptionmessagesPharBuilderused to throw inline.PharBuilderconstructor accepts an optionalPharCapabilities(null → live probe) and delegates the runtime check to it.ServicesConfiguratorregistersPharCapabilitiesand injects it into theworkerman.phar_builderservice.tests/Phar/PharCapabilitiesTest.phpcovers the capability checker in isolation (live probe, success, read-only failure, missing-extension failure, both-failing case).PharBuilderTestcases verify the builder honours an injected capability checker for the success path and both failure paths.CHANGELOG.mdreceives an entry under [Unreleased] / Changed.Changelog
Code Review