File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55namespace Psalm \PhpUnitPlugin \Hooks ;
66
7+ use Error ;
78use PhpParser \Comment \Doc ;
89use PhpParser \Node \Stmt \ClassLike ;
910use PhpParser \Node \Stmt \ClassMethod ;
@@ -167,10 +168,10 @@ public static function afterStatementAnalysis(AfterClassLikeAnalysisEvent $event
167168 }
168169
169170 foreach ($ specials ['dataProvider ' ] as $ line => $ provider ) {
170- if (VersionUtils:: packageVersionIs ( ' vimeo/psalm ' , ' <= ' , ' 4.99 ' )) {
171+ try {
171172 $ provider_docblock_location = clone $ method_storage ->location ;
172173 $ provider_docblock_location ->setCommentLine ($ line );
173- } else {
174+ } catch ( Error $ _ ) {
174175 /** @var CodeLocation */
175176 $ provider_docblock_location = $ method_storage ->location ->setCommentLine ($ line );
176177 }
@@ -337,12 +338,12 @@ static function (
337338 $ provider_docblock_location
338339 ): void {
339340 if ($ is_optional ) {
340- if (VersionUtils::packageVersionIs ('vimeo/psalm ' , '<= ' , '4.99 ' )) {
341- $ param_type = clone $ param_type ;
342- $ param_type ->possibly_undefined = true ;
343- } else {
341+ if (method_exists ($ param_type , 'setPossiblyUndefined ' )) {
344342 /** @var Union */
345343 $ param_type = $ param_type ->setPossiblyUndefined (true );
344+ } else {
345+ $ param_type = clone $ param_type ;
346+ $ param_type ->possibly_undefined = true ;
346347 }
347348 }
348349 if ($ codebase ->isTypeContainedByType ($ potential_argument_type , $ param_type )) {
You can’t perform that action at this time.
0 commit comments