-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Psalm level 5 #2408
Psalm level 5 #2408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome 🎉
@@ -571,7 +571,7 @@ private function addIndex(ClassMetadata $class, SimpleXMLElement $xmlIndex): voi | |||
} | |||
|
|||
/** | |||
* @return array<string, array<string, mixed>|scalar> | |||
* @return array<string, array<string, mixed>|scalar|null> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
doesn't look like an acceptable value for the array but I guess it comes from convertXMLElementValue
so let's live with that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, exactly
* @psalm-return ( | ||
* $arrayAccess is false | ||
* ? T|null | ||
* : T|null|true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh boy, now we're programming in comments :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬 this can be really interesting when adding generics for example to Query
, that depending on the hydrate
value, maybe we change the return type of Query::execute()
to just Iterator<TDocument>
which would mean removing quite assert
calls.
@@ -27,13 +26,6 @@ public function getRealClass(string $class): string | |||
return $this->resolveClassName($class); | |||
} | |||
|
|||
/** | |||
* @psalm-param class-string<RealClassName>|class-string<ProxyInterface<RealClassName>> $className |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are not needed anymore or just problematic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting, we were getting:
ERROR: MoreSpecificImplementedParamType - lib/Doctrine/ODM/MongoDB/Proxy/Resolver/ProxyManagerClassNameResolver.php:37:45 - Argument 1 of Doctrine\ODM\MongoDB\Proxy\Resolver\ProxyManagerClassNameResolver::resolveClassName has the more specific type 'class-string<ProxyManager\Proxy\ProxyInterface<RealClassName>>|(class-string<RealClassName:fn-doctrine\odm\mongodb\proxy\resolver\proxymanagerclassnameresolver::resolveclassname as object>)', expecting 'class-string<Doctrine\Persistence\Proxy<T>>|(class-string<T:fn-doctrine\persistence\mapping\proxyclassnameresolver::resolveclassname as object>)' as defined by Doctrine\Persistence\Mapping\ProxyClassNameResolver::resolveClassName (see https://psalm.dev/140)
public function resolveClassName(string $className): string
so I've removed it, but didn't pay attention that in doctrine/persistence
, the interface is using Proxy
:
<?php
namespace Doctrine\Persistence\Mapping;
use Doctrine\Persistence\Proxy;
interface ProxyClassNameResolver
{
/**
* @psalm-param class-string<Proxy<T>>|class-string<T> $className
*
* @psalm-return class-string<T>
*
* @template T of object
*/
public function resolveClassName(string $className): string;
}
we are usingocramius/proxy-manager
, so I'll leave it and ignore it since it adds the correct type.
It adds a baseline to reach level 5
04b7e5b
to
946ff86
Compare
I think I've removed correct checks from the list of required ones, let's hope next PRs can be merged not only by me 👍 |
Summary
Replaces #2329
Since it's quite difficult and time consuming to fix all possible issues found by static analysis, I think it's better if we use a baseline to ignore some of the issues for now and we set a higher level so new code has to comply with that level.
I've targeted
2.3.x
since there are some phpdoc fixed and it's not adding new features.