Review main Merged

97166[TASK] Improve extension scanner

Simon Schaufelberger CR +2 V +2 Hard +411 −267 updated 10/28/26, 13:29

Commit message

Rework the PHP extension scanner of EXT:install:

- CodeScannerInterface now extends PhpParser\NodeVisitor, so every
  matcher is a parser visitor by contract and MatcherFactory only
  needs one instance check instead of two
- Move the pure node visitors CodeStatistics and
  GeneratorClassesResolver to the new namespace
  ExtensionScanner\Php\Visitor
- Add native property/parameter/return types and precise PHPDoc array
  shapes to the matchers, and use the typed node accessors
  (getStartLine(), getComments(), ->name) instead of generic
  attribute access
- Check for an ignored file before inspecting the node, so
  @extensionScannerIgnoreFile now also takes effect in
  MethodAnnotationMatcher and PropertyAnnotationMatcher
- Replace isset() chains on call arguments with explicit Arg and
  scalar node checks via getRawArgs(), and make the $this receiver
  check in PropertyProtectedMatcher explicit; both keep the existing
  behaviour and are covered by additional fixture lines
- Ignore class constant fetches with an expression name like
  Foo::{$bar} in ClassConstantMatcher: building the lookup key from
  them threw an object-to-string error and aborted the scan
- Use early returns in matcher conditions and improve a few
  error messages

All improvements come from the standalone Extension Scanner and raising
the Phpstan level to 8. The standalone Extension Scanner is now almost
in sync with the TYPO3 Core.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 45

Show 25 more files

Review log 1823

  1. Simon Schaufelberger uploaded patch set 1 10/26/26, 16:17

  2. core-ci voted on patch set 1 V +1 10/26/26, 16:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112598

  3. Oliver Klee voted on patch set 1 V +1 10/26/26, 18:11

  4. Oli Bartsch commented on patch set 1 CR -1 10/26/26, 21:12

    AbstractCoreMatcher.php:36

    This needs to be removed in the backport.

    AbstractCoreMatcher.php:175

    php-parser 5.7/5.8 has no `Node\ArgPlaceholder`, so the PHPDoc and comment reference a class that doesn't exist and the runtime behavior is unchanged. Please remove those references and the commit message bullet until Core requires a version that ships it.

    AbstractMethodImplementationMatcher.php:133

    This still uses `getAttribute('startLine')` while the rest was switched. Please use `$method->getStartLine()`.

    MethodAnnotationMatcher.php:47

    Moving this before the `ClassMethod`/`Property` check means `@extensionScannerIgnoreFile` now takes effect in `MethodAnnotationMatcher` and `PropertyAnnotationMatcher`. That's a good fix, but it changes results while the commit message calls it a refactoring. Please mention it there and add ignore-file tests for both matchers.

    MethodCallArgumentValueMatcher.php:58

    The comment now sits above the `StaticCall` branch and says the opposite of the code. Please drop it or move it to the `MethodCall` branch.

    MethodCallArgumentValueMatcher.php:122

    The `isset()` guard is replaced by a direct index read on `getArgs()`. Calls with fewer arguments than `argumentIndex` (e.g. `configurePlugin()` with 4 args, index 5) and first-class callables now raise "Undefined array key" or an `AssertionError`. Please use `$node->getRawArgs()[$argumentMatchArray['argumentIndex']] ?? null` and require `$argument instanceof Node\Arg` before checking `String_`/`Int_`/`Float_`. Fixture lines with too few arguments and a first-class callable would cover it.

    PropertyProtectedMatcher.php:55

    This drops receivers like `$this->dataHandler->prop`, `$GLOBALS['X']->prop` and `$foo->bar()->prop`, which the old `($node->var->name ?? '') !== 'this'` check matched. Please exclude only a variable named `this`: `&& !($node->var instanceof Variable && $node->var->name === 'this')`. Please also add fixture lines for those three receivers.
  5. Simon Schaufelberger commented on patch set 1 10/26/26, 21:59

    AbstractCoreMatcher.php:175 Reply

    Done

    AbstractMethodImplementationMatcher.php:133 Reply

    Done
  6. Simon Schaufelberger uploaded patch set 2 CR -1 V +1 10/26/26, 22:13

  7. Simon Schaufelberger commented on patch set 2 10/26/26, 22:19

    MethodAnnotationMatcher.php:47 Reply

    Done

    MethodCallArgumentValueMatcher.php:58 Reply

    Done

    MethodCallArgumentValueMatcher.php:122 Reply

    Done

    PropertyProtectedMatcher.php:55 Reply

    Done
  8. Simon Schaufelberger updated the commit message in patch set 3 10/26/26, 22:23

  9. core-ci voted on patch set 3 V +1 10/26/26, 22:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112619

  10. Simon Schaufelberger uploaded patch set 4 V +1 10/26/26, 22:51

  11. core-ci voted on patch set 4 V +1 10/26/26, 22:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112620

  12. Oliver Klee voted on patch set 4 V +1 10/27/26, 10:50

  13. Garvin Hicking commented on patch set 4 CR +1 V +1 10/27/26, 11:29

    Thanks for that work. Minor commit message comments only! 😊 Waiting for feedback of @bo@cedev.de before proceeding with a merge though.
    I think this bullet no longer applies, don't add differences from PS1 to PS4.
    I think this bullet no longer applies, don't add differences from PS1 to PS4.

    ClassConstantMatcher.php:55

    This bugfix here could be noted in the commit message's bullet (optional for me)
  14. Simon Schaufelberger updated the commit message in patch set 5 CR +1 V +1 10/27/26, 17:28

  15. Simon Schaufelberger commented on patch set 4 10/27/26, 17:28

    Reply

    This refers to `\TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\MethodCallArgumentValueMatcher::isArgumentMatched`

    Reply

    this refers to `\TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\PropertyProtectedMatcher::enterNode`

    ClassConstantMatcher.php:55 Reply

    Done
  16. Garvin Hicking commented on patch set 5 CR +1 V +1 10/27/26, 17:46

    Reply

    Acknowledged

    Reply

    Acknowledged
  17. core-ci voted on patch set 5 V +1 10/27/26, 18:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112652

  18. Oli Bartsch uploaded patch set 6 CR +1 V +1 10/28/26, 10:22

  19. Oli Bartsch voted on patch set 6 CR +1 V +1 10/28/26, 10:24

  20. core-ci voted on patch set 6 V +1 10/28/26, 10:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112702

  21. Garvin Hicking voted on patch set 6 CR +1 V +1 10/28/26, 12:02

  22. Oli Bartsch commented on patch set 6 CR +2 V +2 10/28/26, 13:29

    AbstractCoreMatcher.php:36 Reply

    Done
  23. Oli Bartsch merged patch set 7 10/28/26, 13:29