Repository navigation
Add #[Generate] and the refined string and array shape types - #164
Merged
Merged
Conversation
#[Generate] puts a parameter's generator on the parameter itself: an arbitrary built with `new`, or a reference to a static factory returning one. Gen::forParameters() and Gen::forClass() read it after an override and before the docblock, so both adapters' signature-driven modes get it from one change. Gen::forParameters(derive: false) reads only overrides and the attribute — the engine half of an adapter's mode without auto. The docblock reader now understands numeric-string, non-falsy-string, lowercase-string, non-empty-lowercase-string and array shapes with optional, quoted, integer and positional keys, and reads a @PARAM written across lines. Fixes #156 Fixes #160
…cument #[Generate] in the guide
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Fixes #156
Fixes #160
#160 —
#[Generate]Rasuvaeff\PropertyTesting\Generate(@api,TARGET_PARAMETER, not repeatable, no constructor defaults). It takes an arbitrary built withnew, or a reference to a static factory returning one:'method'(declaring class first),'Class::method',[Class::class, 'method'], or an invokable. The reference covers everything an attribute's constant expression cannot hold on PHP 8.3/8.4 (map,filter,flatMap,composite,email,url,json,regex,recursive).ParameterGenerators::forSignature()in this order: override, then the attribute, then@param, then the native type. BothGen::forParameters()andGen::forClass()use it. The attribute is exact: it wins over a disagreeing or unreadable docblock, a?Tparameter is not wrapped innullable, and on a variadic it counts as the override.Gen::forParameters(..., derive: false)reads only overrides and attributes, and refuses a parameter that has neither. The adapters call this withoutauto(follow-up PRs: Read #[Generate] on property parameters, with and without auto property-testing-testo#68, Read #[Generate] on closure parameters, with and without auto() property-testing-phpunit#61).pass an override or #[Generate]. Both adapters assert only thepass an overridesubstring.#156 — refined strings and shapes
What the issue listed did not match the code.
non-empty-list/non-empty-arrayand keyedarray<K, V>already worked. Array shapes were not supported at all, which is a bigger gap than the "optional keys" the issue mentions. Also,0x1Ais not numeric in PHP 8.numeric-string,non-falsy-string/truthy-string,lowercase-stringandnon-empty-lowercase-string.array{a: T, b?: U}, quoted and integer keys, positionalarray{T, U}/list{T, U},array{}, and shapes nested in collections and unions. An optional key is sometimes absent and shrinks towards absent; absent is notnull. Unsealed shapes, double-quoted keys and keyedlist{}are still refused.@paramwritten across several lines is now read. Without this, a shape in its usual multi-line form was refused.phpstan/phpdoc-parser. The work is in the generators, not the parsing, and a dependency risks constraint conflicts for consumers.Also
RedisDsn.php: rector (RemoveAlwaysTrueIfConditionRector) was already red on master, which blockedrelease-check.docs/.api-workspaceare raised to1.2.0. The adapters' current^1.0accepts it, so the job stays green before and after they move to^1.2.llms.txt, SKILL.md, the from-a-class guide page and the regenerated API pages are updated.Verification
composer build: green.SKIPPEDenum-default entries as v1.1.0, nothing new.