Reported automatically by a code-commandments agent.
|
|
| Prophet |
WideUnionType |
| Location |
src/Pipeline/Contracts/ConditionalPipe.php:18 |
What's wrong
False-positive pattern: WideUnionType flags deliberate poly-form contracts that have NO single narrower supertype. Representative cases across the codebase: ConditionalPipe::condition returns Closure(TContext):bool|class-string|bool (a decision expressed as a literal bool, a predicate closure, OR a predicate class-string); PipelineDefinition::define and SingleSubPipelineAdapter return (Closure(TContext):T)|T (lazy-or-eager); provider clients take string|array $toolChoice (a mode token or a structured selection); InputSocket::select takes array|string $options (a choice list or a backed-enum class-string). These are intentional union APIs — the members share no narrower type and collapsing them would remove the affordance. Request a carve-out so WideUnionType does not flag documented multi-form contracts (closure-or-value, literal|closure|class-string predicates, provider-shape unions).
Flagged code
* @return Closure(TContext): bool|class-string|bool
For the fixer
Decide whether this is a false positive (tighten/guard the prophet), a wrong rule (adjust the rule or its config), or correct-but-unclear (improve the message/scripture). Add a fixture from the flagged code above.
Reported automatically by a code-commandments agent.
WideUnionTypesrc/Pipeline/Contracts/ConditionalPipe.php:18What's wrong
False-positive pattern: WideUnionType flags deliberate poly-form contracts that have NO single narrower supertype. Representative cases across the codebase: ConditionalPipe::condition returns Closure(TContext):bool|class-string|bool (a decision expressed as a literal bool, a predicate closure, OR a predicate class-string); PipelineDefinition::define and SingleSubPipelineAdapter return (Closure(TContext):T)|T (lazy-or-eager); provider clients take string|array $toolChoice (a mode token or a structured selection); InputSocket::select takes array|string $options (a choice list or a backed-enum class-string). These are intentional union APIs — the members share no narrower type and collapsing them would remove the affordance. Request a carve-out so WideUnionType does not flag documented multi-form contracts (closure-or-value, literal|closure|class-string predicates, provider-shape unions).
Flagged code
* @return Closure(TContext): bool|class-string|boolFor the fixer
Decide whether this is a false positive (tighten/guard the prophet), a wrong rule (adjust the rule or its config), or correct-but-unclear (improve the message/scripture). Add a fixture from the flagged code above.