Repository navigation
PhpDeal 2.0: PHP 8.4, Go! AOP 4 and native attributes - #70
Merged
Merged
Conversation
PhpDeal 2.0 replaces Doctrine annotations with native attributes (#[Verify], #[Ensure], #[Invariant], #[Inherit]) and runs on Go! AOP 4. - Rewrite the aspects on top of a shared ContractFetcher (cached, inheritance-aware) and ContractEvaluator (expressions compiled once) - Evaluate parent contracts in their own class scope, check inherited preconditions before the body, support static methods, check invariants after the constructor and guard against recursion - Add PreconditionViolation, PostconditionViolation, InvariantViolation and InvalidContractException with clearer messages and locations - Ship a PHPStan extension so members used only by contracts are not reported as unused - Replace the test suite with unit and functional tests on PHPUnit 13, analyse everything with PHPStan level 10 and strict rules, and use PHP-CS-Fixer (PER-CS 2.0) - Replace Travis CI and Scrutinizer with GitHub Actions - Rewrite the README with badges, add UPGRADE-2.0.md and CHANGELOG.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1DtML6BuKT7iikmqSb
Describes the commands, layout, contract semantics, conventions and testing tips, and excludes the file from the distributed package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1DtML6BuKT7iikmqSb
On a fresh checkout tests/cache and demo/cache do not exist yet, and PHPStan rejects missing exclude paths unless they are marked with (?). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1DtML6BuKT7iikmqSb
lisachenko
marked this pull request as ready for review
November 10, 2026 16:57
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
Modernizes PhpDeal for PHP 8.4+ on top of Go! AOP 4. Contracts are now native attributes instead of Doctrine annotations:
Core
PhpDeal\Attributenamespace:#[Verify],#[Ensure],#[Invariant](repeatable) and#[Inherit].ContractFetchercollects contracts across parents and interfaces, with caching.ContractEvaluatorcompiles each expression into a closure once.ContractApplication::registerAspects()lets apps that already have a Go! AOP kernel turn contracts on.Behaviour improvements
$__oldis cloned only when a contract actually uses it.#[Inherit]now also inherits method contracts, which is what the docs always described.Exceptions
PreconditionViolation,PostconditionViolationandInvariantViolationall extendContractViolation, so existingcatchblocks keep working.InvalidContractExceptionis new: it covers syntax errors, non-boolean results, and$thisused in a static method.Tooling and quality
src,testsanddemo. It analyses for PHP 8.4–8.5.composer audit.Docs
UPGRADE-2.0.mdandCHANGELOG.md.AGENTS.mdfor AI coding agents: commands, layout, how contracts work, conventions and testing tips. It is excluded from the distributed package.Breaking changes
This is a major release; see
UPGRADE-2.0.md.AbstractContractAspect,InheritCheckerAspectand theContract\Fetcher\Parent\*classes are removed.InvalidContractExceptioninstead of being wrapped intoContractViolation.Testing
Run locally on PHP 8.5:
php-cs-fixer check: clean.composer demoruns. Every README example was also run against woven classes and behaves as documented.PHP 8.4 and the lowest-dependency set were not available locally; the CI matrix covers them.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FxhC1DtML6BuKT7iikmqSb