‪TYPO3CMS  ‪main
ClassNameMatcher.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\Name\FullyQualified;
22 
28 {
34  public function ‪__construct(array ‪$matcherDefinitions)
35  {
36  $this->matcherDefinitions = ‪$matcherDefinitions;
38  }
39 
45  public function ‪enterNode(Node $node): null
46  {
47  if (!$this->‪isFileIgnored($node)
48  && !$this->‪isLineIgnored($node)
49  && $node instanceof FullyQualified
50  ) {
51  $fullyQualifiedClassName = $node->toString();
52  if (array_key_exists($fullyQualifiedClassName, $this->matcherDefinitions)) {
53  $this->matches[] = [
54  'restFiles' => $this->matcherDefinitions[$fullyQualifiedClassName]['restFiles'],
55  'line' => $node->getAttribute('startLine'),
56  'message' => 'Usage of class "' . $fullyQualifiedClassName . '"',
57  'indicator' => 'strong',
58  ];
59  }
60  }
61  return null;
62  }
63 }
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\isLineIgnored
‪isLineIgnored(Node $node)
Definition: AbstractCoreMatcher.php:175
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher
Definition: AbstractCoreMatcher.php:18
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\ClassNameMatcher\__construct
‪__construct(array $matcherDefinitions)
Definition: ClassNameMatcher.php:34
‪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\ClassNameMatcher
Definition: ClassNameMatcher.php:28
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\validateMatcherDefinitions
‪validateMatcherDefinitions(array $requiredArrayKeys=[])
Definition: AbstractCoreMatcher.php:86
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\$matcherDefinitions
‪array $matcherDefinitions
Definition: AbstractCoreMatcher.php:41
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\ClassNameMatcher\enterNode
‪enterNode(Node $node)
Definition: ClassNameMatcher.php:45