Skip to content

refactor(phar): extract PharCapabilities from PharBuilder (closes #372)#537

Merged
s2x merged 2 commits into
masterfrom
refactor/issue-372-pharbuilder-capabilities-extraction
Jul 1, 2026
Merged

refactor(phar): extract PharCapabilities from PharBuilder (closes #372)#537
s2x merged 2 commits into
masterfrom
refactor/issue-372-pharbuilder-capabilities-extraction

Conversation

@s2x

@s2x s2x commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Description

Closes #372

Extract 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.

Changes

  • New src/Phar/PharCapabilities.php owns the phar.readonly / \Phar extension probes and exposes assertCanBuild() that throws the same RuntimeException messages PharBuilder used to throw inline.
  • PharBuilder constructor accepts an optional PharCapabilities (null → live probe) and delegates the runtime check to it.
  • ServicesConfigurator registers PharCapabilities and injects it into the workerman.phar_builder service.
  • New tests/Phar/PharCapabilitiesTest.php covers the capability checker in isolation (live probe, success, read-only failure, missing-extension failure, both-failing case).
  • New PharBuilderTest cases verify the builder honours an injected capability checker for the success path and both failure paths.
  • CHANGELOG.md receives an entry under [Unreleased] / Changed.

Changelog

### Changed
- Extract the side-effectful phar.readonly INI probe and \Phar extension presence check out of PharBuilder::build() into a new PharCapabilities collaborator. PharBuilder now accepts the capability checker via constructor (defaults to a live PharCapabilities::probe()), making the runtime checks individually testable and stubbable. The DI container registers PharCapabilities and injects it into the workerman.phar_builder service. No behavioural change observable for the build:phar flow (#372)

Code Review

  • Passed subagent code review
  • All review comments addressed (no issues found)

Piotr Hałas 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.
@s2x s2x self-assigned this Jul 1, 2026
@s2x
s2x merged commit 38c853d into master Jul 1, 2026
12 checks passed
@s2x
s2x deleted the refactor/issue-372-pharbuilder-capabilities-extraction branch July 1, 2026 07:21
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.

[Code Quality] PharBuilder mixes side-effectful capability checks into a builder constructor

1 participant