-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
PHPStan level 6 with AuditReader
not generic
#488
PHPStan level 6 with AuditReader
not generic
#488
Conversation
phpstan.neon.dist
Outdated
@@ -12,3 +12,5 @@ parameters: | |||
checkMissingIterableValueType: true | |||
checkMissingVarTagTypehint: true | |||
checkMissingTypehints: true | |||
ignoreErrors: | |||
- '#Test::(data|provide)[a-zA-Z0-9_]+\(\) return type has no value type specified in iterable type#' |
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.
Just a less greedy suggestion:
- '#Test::(data|provide)[a-zA-Z0-9_]+\(\) return type has no value type specified in iterable type#' | |
- '#^Method SimpleThings\\EntityAudit\\Tests\\[a-zA-Z0-9_\\]+Test::(data|provide)[a-zA-Z0-9_]+\(\) return type has no value type specified in iterable type [a-zA-Z0-9_]+\.$#' |
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.
Glad to see you back @phansys!
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.
Is there a lot of dataprovider to fix ?
src/AuditReader.php
Outdated
@@ -788,6 +791,8 @@ protected function getEntityPersister($className) | |||
* | |||
* @phpstan-param class-string<T> $className | |||
* @phpstan-return T|null | |||
* | |||
* @template T of object |
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.
IMO, we should declare the template before its uses.
Removing the template would create issues for the sonata compatibility since there is one in the SonataAdmin interface I wonder if we shouldn't have both
This way we can define an AuditReader<Foo|Bar>, but then WDYT ? We should update https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Model/AuditReaderInterface.php phpdoc then and the same could be done for the ModelManager https://github.com/sonata-project/SonataAdminBundle/blob/4.x/src/Model/ModelManagerInterface.php#L55 |
IMHO that seems overcomplicated. I understand that |
For SonataAdmin, it's considered as a repository, and the AuditManager would be the EntityManager But I think the generic part of the AuditReader of this project can be removed, |
To reach level 6 of PHPStan
fce92ae
to
ff60726
Compare
* @param int|string $revision | ||
* @template T of object | ||
* | ||
* @param string $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.
isnt this a class-string?
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, all these parameters are defined below as @phpstan-param
* @param int|string $revision | ||
* @template T of object | ||
* | ||
* @param string $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.
isnt this a class-string?
@@ -566,15 +566,15 @@ public function findRevisions($className, $id) | |||
* NEXT_MAJOR: Add NoRevisionFoundException as possible exception. | |||
* Gets the current revision of the entity with given ID. | |||
* | |||
* @param string $className | |||
* @param int|string|array $id | |||
* @param string $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.
Another class-string?
@@ -508,15 +508,15 @@ public function findRevision($revision) | |||
/** | |||
* Find all revisions that were made of entity class with given id. | |||
* | |||
* @param string $className | |||
* @param int|string|array $id | |||
* @param string $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.
And another one
Thanks @franmomu |
Subject
Alternative to #487 making
AuditReader
not generic.Raising PHPStan level after this to level 7 shows 23 errors.
I am targeting this branch, because this is BC.
Changelog