2 declare(strict_types = 1);
19 use PhpParser\Node\Stmt\Class_;
20 use PhpParser\NodeVisitorAbstract;
94 foreach ($this->matcherDefinitions as $key => $matcherDefinition) {
102 if (empty($matcherDefinition[
'restFiles'])) {
103 throw new \InvalidArgumentException(
104 'Each configuration must have at least one referenced "restFiles" entry. Offending key: ' . $key,
108 foreach ($matcherDefinition[
'restFiles'] as $file) {
110 throw new \InvalidArgumentException(
111 'Empty restFiles definition',
117 $sharedArrays = array_intersect(array_keys($matcherDefinition), $requiredArrayKeys);
118 if (count($sharedArrays) !== count($requiredArrayKeys)) {
119 $missingKeys = array_diff($requiredArrayKeys, array_keys($matcherDefinition));
120 throw new \InvalidArgumentException(
121 'Required matcher definitions missing: ' . implode(
', ', $missingKeys) .
' offending key: ' . $key,
140 $methodNameArray = [];
141 foreach ($this->matcherDefinitions as $classAndMethod => $details) {
142 $method = GeneralUtility::trimExplode(
'::', $classAndMethod);
143 if (count($method) !== 2) {
144 $method = GeneralUtility::trimExplode(
'->', $classAndMethod);
146 if (count($method) !== 2) {
147 throw new \RuntimeException(
148 'Keys in $this->matcherDefinitions must have a Class\Name->method or Class\Name::method structure',
152 $method = $method[1];
153 if (!array_key_exists($method, $methodNameArray)) {
154 $methodNameArray[$method][
'candidates'] = [];
156 $methodNameArray[$method][
'candidates'][] = $details;
158 $this->flatMatcherDefinitions = $methodNameArray;
170 foreach ($arguments as $arg) {
171 if ($arg->unpack ===
true) {
188 $startLineOfNode = $node->getAttribute(
'startLine');
189 if ($startLineOfNode === $this->currentCodeLine) {
193 $currentLineIsIgnored =
false;
194 if ($startLineOfNode !== $this->currentCodeLine) {
195 $this->currentCodeLine = $startLineOfNode;
197 $comments = $node->getAttribute(
'comments');
198 if (!empty($comments)) {
199 foreach ($comments as $comment) {
200 if (strstr($comment->getText(),
'@extensionScannerIgnoreLine') !==
false) {
201 $this->isCurrentLineIgnored =
true;
202 $currentLineIsIgnored =
true;
208 return $currentLineIsIgnored;
220 if ($this->isFullFileIgnored) {
223 $currentFileIsIgnored =
false;
224 if ($node instanceof Class_) {
225 $comments = $node->getAttribute(
'comments');
226 if (!empty($comments)) {
227 foreach ($comments as $comment) {
228 if (strstr($comment->getText(),
'@extensionScannerIgnoreFile') !==
false) {
229 $this->isFullFileIgnored =
true;
230 $currentFileIsIgnored =
true;
236 return $currentFileIsIgnored;