‪TYPO3CMS  10.4
ArrayGlobalMatcher.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\ArrayDimFetch;
22 use PhpParser\Node\Expr\Variable;
23 use PhpParser\Node\Scalar\String_;
24 
31 {
37  public function ‪__construct(array ‪$matcherDefinitions)
38  {
39  $this->matcherDefinitions = ‪$matcherDefinitions;
41  }
42 
48  public function ‪enterNode(Node $node)
49  {
50  if (!$this->‪isFileIgnored($node)
51  && !$this->‪isLineIgnored($node)
52  && $node instanceof ArrayDimFetch
53  && $node->var instanceof Variable
54  && $node->var->name === 'GLOBALS'
55  && $node->dim instanceof String_
56  && array_key_exists('$GLOBALS[\'' . $node->dim->value . '\']', $this->matcherDefinitions)
57  ) {
58  $this->matches[] = [
59  'restFiles' => $this->matcherDefinitions['‪$GLOBALS[\'' . $node->dim->value . '\']']['restFiles'],
60  'line' => $node->getAttribute('startLine'),
61  'message' => 'Access to array global array "' . $node->dim->value . '"',
62  'indicator' => 'strong',
63  ];
64  }
65  }
66 }
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher
Definition: AbstractCoreMatcher.php:18
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\isLineIgnored
‪bool isLineIgnored(Node $node)
Definition: AbstractCoreMatcher.php:181
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher
Definition: AbstractCoreMatcher.php:34
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\validateMatcherDefinitions
‪validateMatcherDefinitions(array $requiredArrayKeys=[])
Definition: AbstractCoreMatcher.php:88
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\isFileIgnored
‪bool isFileIgnored(Node $node)
Definition: AbstractCoreMatcher.php:214
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\AbstractCoreMatcher\$matcherDefinitions
‪array $matcherDefinitions
Definition: AbstractCoreMatcher.php:41
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\ArrayGlobalMatcher
Definition: ArrayGlobalMatcher.php:31
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\ArrayGlobalMatcher\enterNode
‪enterNode(Node $node)
Definition: ArrayGlobalMatcher.php:48
‪TYPO3\CMS\Install\ExtensionScanner\Php\Matcher\ArrayGlobalMatcher\__construct
‪__construct(array $matcherDefinitions)
Definition: ArrayGlobalMatcher.php:37