‪TYPO3CMS  ‪main
PropertyPublicMatcher.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PhpParser\Node;
21 use PhpParser\Node\Expr\PropertyFetch;
22 use PhpParser\Node\Identifier;
23 
29 {
35  public function ‪__construct(array ‪$matcherDefinitions)
36  {
37  $this->matcherDefinitions = ‪$matcherDefinitions;
40  }
41 
45  public function ‪enterNode(Node $node): null
46  {
47  // Match property access (not static)
48  if (!$this->‪isFileIgnored($node)
49  && !$this->‪isLineIgnored($node)
50  && $node instanceof PropertyFetch
51  && $node->name instanceof Identifier
52  && array_key_exists($node->name->name, $this->flatMatcherDefinitions)
53  ) {
54  $match = [
55  'restFiles' => [],
56  'line' => $node->getAttribute('startLine'),
57  'message' => 'Fetch of property "' . $node->name->name . '"',
58  'indicator' => 'weak',
59  ];
60 
61  foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
62  $match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
63  }
64  $this->matches[] = $match;
65  }
66  return null;
67  }
68 }
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\isLineIgnored
‪isLineIgnored(Node $node)
Definition: AbstractCoreMatcher.php:175
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\PropertyPublicMatcher\__construct
‪__construct(array $matcherDefinitions)
Definition: PropertyPublicMatcher.php:35
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\PropertyPublicMatcher\enterNode
‪enterNode(Node $node)
Definition: PropertyPublicMatcher.php:45
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher
Definition: AbstractCoreMatcher.php:18
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher
Definition: AbstractCoreMatcher.php:34
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\isFileIgnored
‪isFileIgnored(Node $node)
Definition: AbstractCoreMatcher.php:210
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\validateMatcherDefinitions
‪validateMatcherDefinitions(array $requiredArrayKeys=[])
Definition: AbstractCoreMatcher.php:86
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\PropertyPublicMatcher
Definition: PropertyPublicMatcher.php:29
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\$matcherDefinitions
‪array $matcherDefinitions
Definition: AbstractCoreMatcher.php:41
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\initializeFlatMatcherDefinitions
‪initializeFlatMatcherDefinitions()
Definition: AbstractCoreMatcher.php:132