77846[TASK] Make extbase persistence generic (phpstan-wise)
Commit message
Review
-
Code review CR +2 Done
- Christian Kuhn +2
- Oliver Klee +1
- Markus Klein +1
- Torben Hansen +1
-
Verified V +2 Done
- Christian Kuhn +2
- Oliver Klee +1
- Markus Klein +1
- Torben Hansen +1
- core-ci +1 CI
Issues 1
Files 14
- Build/phpstan/phpstan-baseline.neon+7 −7
- Build/Scripts/annotationChecker.php+1 −1
- typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php11+16 −0
- typo3/sysext/extbase/Classes/Persistence/Generic/PersistenceManager.php+3 −0
- typo3/sysext/extbase/Classes/Persistence/Generic/Query.php4+13 −0
- typo3/sysext/extbase/Classes/Persistence/Generic/QueryFactory.php+3 −0
- typo3/sysext/extbase/Classes/Persistence/Generic/QueryFactoryInterface.php+3 −0
- typo3/sysext/extbase/Classes/Persistence/Generic/QueryResult.php7+16 −0
- typo3/sysext/extbase/Classes/Persistence/PersistenceManagerInterface.php+3 −0
- typo3/sysext/extbase/Classes/Persistence/QueryInterface.php2+8 −0
- typo3/sysext/extbase/Classes/Persistence/QueryResultInterface.php2+10 −0
- typo3/sysext/extbase/Classes/Persistence/Repository.php+5 −3
- typo3/sysext/extbase/Classes/Persistence/RepositoryInterface.php+1 −0
- typo3/sysext/extbase/Tests/Unit/Persistence/Generic/QueryResultTest.php+2 −2
Review log 2528
Show 3 earlier messages
-
Alexander Schnitzler uploaded patch set 1 02/13/23, 21:22
-
Alexander Schnitzler marked it work in progress 02/13/23, 21:23
-
Oliver Klee commented on patch set 1 02/13/23, 21:31
DataMapper.php:94more precise (to communicate that the array has subsequent indices starting at 0): list<T>Query.php:64class-string<T>Query.php:229Could we make T[] more specific as list<T> here?QueryResult.php:50Do we know anything about the array keys here?QueryResult.php:136Do we know anything about the array keys here?QueryInterface.php:115Do we know anything about the array keys here?QueryResultInterface.php:54Do we know anything about the array keys here?
-
core-ci voted on patch set 1 V -1 02/13/23, 22:23 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37664
-
Alexander Schnitzler uploaded patch set 2
V -102/14/23, 11:33 -
Alexander Schnitzler commented on patch set 2 02/14/23, 11:36
DataMapper.php:92ReplyAckDataMapper.php:94ReplyDoneQuery.php:64ReplyDoneQuery.php:229ReplyDoneQueryResult.php:50ReplyDoneQueryResult.php:136ReplyDoneQueryInterface.php:115ReplyDoneQueryResultInterface.php:54ReplyDone -
Oliver Klee commented on patch set 2 02/14/23, 11:41
DataMapper.php:157I propose having a method_exists check here. This will actually solve the problem (as a short-term solution), and it will also make PHPStan (rightfully) happy. -
core-ci voted on patch set 2 V +1 02/14/23, 11:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37684
-
Alexander Schnitzler commented on patch set 2 02/14/23, 11:46
QueryResult.php:29One question remains here. Technically, we do receive a `list<TValue>` from the datamapper, hence, `$queryResult` is an `\Iterator` and `\ArrayAccess` with `TKey` being `int`. Question is, if we want to narrow down the type for phpstan without being able to do so via type declarations. `\ArrayAccess::offsetSet()` e.g., has a `mixed` type declaration in the php core we cannot override. But our usage of `offsetSet()` inside the extbase persistence is limited to `TKey` being `int`. Only thing we can do (breaking), is to limit the accepted type inside those methods and throw `\InvalidArgumentException`'s in case `offsetSet()` is called with a `string` as `key` for instance. IMHO, we should try to narrow the type down to `int`, first of all with phpstan annotations and furthermore with `\InvalidArgumentException`'s. Another idea: Limit key to `int|numeric-string` and also allow the external api `findByUid()` behave the same. -
Alexander Schnitzler commented on patch set 2 02/14/23, 11:51
DataMapper.php:157ReplyI'd opt for `is_callable` instead but I get the gist. I'd still argue against if because we'd be calling this inside a loop for each database row that is converted to an object. Might be a small impact in cpu time but we know this code works because of how the framework around is built. I'd rather solve this properly because we already have more ignored phpstan errors surrounding this and similar issues. There are a couple of methods on AbstractDomainObject which are not part of the DomainObjectInterface contract. -
Alexander Schnitzler commented on patch set 2 02/14/23, 11:51
This change is ready for review. -
Oliver Klee commented on patch set 2 02/18/23, 14:45
DataMapper.php:157ReplyI'd be fine either way (method_exists, is_callable or solving this properly) and would prefer the "solving this properly" option. What would that entail? Have DomainObjectInterface extend ObjectMonitoringInterface?QueryResult.php:29ReplyI'd prefer to have this as narrow as possible (int), but would suggest to do this in a separate change to keep the changes relatively small and reduce the impact of each change. -
Alexander Schnitzler commented on patch set 2 02/19/23, 08:29
DataMapper.php:157ReplyYes, that's the easiest way to achieve this. But, can we do it in a separate patch? I will prepare it.QueryResult.php:29ReplyAck -
Oliver Klee commented on patch set 2 02/19/23, 11:05
DataMapper.php:157ReplyYes, that would be perfectly fine with me. Thanks! -
Markus Klein voted on patch set 2 V +1 CR +1 02/24/23, 14:36
-
Oliver Klee voted on patch set 2 CR +1 02/24/23, 14:58
-
Oliver Klee voted on patch set 2 V +1 02/24/23, 14:58
-
Torben Hansen voted on patch set 2 V +1 CR +1 02/28/23, 18:13
-
Christian Kuhn commented on patch set 2 03/01/23, 08:01
DataMapper.php:153@todo -
Christian Kuhn uploaded patch set 3
CR +1V +103/01/23, 08:34 -
Christian Kuhn commented on patch set 2 03/01/23, 08:34
DataMapper.php:153ReplyDone -
Christian Kuhn voted on patch set 3 V +1 CR +1 03/01/23, 08:34
-
Markus Klein voted on patch set 3 V +1 CR +1 03/01/23, 08:39
-
Torben Hansen voted on patch set 3 V +1 CR +1 03/01/23, 08:40
-
Oliver Klee voted on patch set 3 V +1 CR +1 03/01/23, 08:55
-
core-ci voted on patch set 3 V +1 03/01/23, 09:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/38249
-
Christian Kuhn voted on patch set 3 V +2 CR +2 03/01/23, 09:40
-
Christian Kuhn merged patch set 4 03/01/23, 09:40
DataMapper.php:92