File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -133,8 +133,15 @@ public function describe(VerbosityLevel $level): string
133133 $ joinTypes = static function (array $ types ) use ($ level ): string {
134134 $ typeNames = [];
135135 foreach ($ types as $ type ) {
136- if ($ type instanceof IntersectionType || $ type instanceof ClosureType || $ type instanceof CallableType) {
136+ if ($ type instanceof ClosureType || $ type instanceof CallableType) {
137137 $ typeNames [] = sprintf ('(%s) ' , $ type ->describe ($ level ));
138+ } elseif ($ type instanceof IntersectionType) {
139+ $ intersectionDescription = $ type ->describe ($ level );
140+ if (strpos ($ intersectionDescription , '& ' ) !== false ) {
141+ $ typeNames [] = sprintf ('(%s) ' , $ type ->describe ($ level ));
142+ } else {
143+ $ typeNames [] = $ intersectionDescription ;
144+ }
138145 } else {
139146 $ typeNames [] = $ type ->describe ($ level );
140147 }
Original file line number Diff line number Diff line change 55use PHPStan \Reflection \Native \NativeParameterReflection ;
66use PHPStan \Reflection \PassedByReference ;
77use PHPStan \TrinaryLogic ;
8+ use PHPStan \Type \Accessory \AccessoryNumericStringType ;
89use PHPStan \Type \Constant \ConstantArrayType ;
910use PHPStan \Type \Constant \ConstantBooleanType ;
1011use PHPStan \Type \Constant \ConstantFloatType ;
@@ -576,6 +577,17 @@ public function dataDescribe(): array
576577 'array()|array( \'foooo \' => \'barrr \') ' ,
577578 'array<string, string> ' ,
578579 ],
580+ [
581+ TypeCombinator::union (
582+ new IntegerType (),
583+ new IntersectionType ([
584+ new StringType (),
585+ new AccessoryNumericStringType (),
586+ ]),
587+ ),
588+ 'int|(string&numeric) ' ,
589+ 'int|string ' ,
590+ ],
579591 ];
580592 }
581593
You can’t perform that action at this time.
0 commit comments