Commit d5095df8 authored by Stefan Neufeind's avatar Stefan Neufeind Committed by Christian Kuhn
Browse files

[TASK] Update composer-dep nikic/php-parser to 4.0.1

Command used:
composer require nikic/php-parser ^4.0

Resolves: #84237
Releases: master
Change-Id: I7eed5bbc31f2be6084356d86b35231d93bc6ecb2
Reviewed-on: https://review.typo3.org/56128


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 4eccdabd
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "d5997be140aa762b2cb664fccaba94fe",
"content-hash": "ed7b3b2d40814c9c50fbd22ec9c5e085",
"packages": [
{
"name": "cogpowered/finediff",
......@@ -817,24 +817,24 @@
},
{
"name": "nikic/php-parser",
"version": "v3.1.1",
"version": "v4.0.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "a1e8e1a30e1352f118feff1a8481066ddc2f234a"
"reference": "e4a54fa90a5cd8e8dd3fb4099942681731c5cdd3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a1e8e1a30e1352f118feff1a8481066ddc2f234a",
"reference": "a1e8e1a30e1352f118feff1a8481066ddc2f234a",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/e4a54fa90a5cd8e8dd3fb4099942681731c5cdd3",
"reference": "e4a54fa90a5cd8e8dd3fb4099942681731c5cdd3",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": ">=5.5"
"php": ">=7.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0|~5.0"
"phpunit/phpunit": "^6.5 || ^7.0"
},
"bin": [
"bin/php-parse"
......@@ -842,7 +842,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
"dev-master": "4.0-dev"
}
},
"autoload": {
......@@ -864,7 +864,7 @@
"parser",
"php"
],
"time": "2017-09-02T17:10:46+00:00"
"time": "2018-03-25T17:35:16+00:00"
},
{
"name": "psr/container",
......
......@@ -24,7 +24,7 @@
"doctrine/instantiator": "~1.0.4",
"guzzlehttp/guzzle": "^6.3.0",
"mso/idna-convert": "^1.1.0",
"nikic/php-parser": "^3.1",
"nikic/php-parser": "^4.0",
"psr/container": "^1.0",
"psr/http-message": "~1.0",
"psr/http-server-middleware": "^1.0",
......
......@@ -42,7 +42,7 @@ class GeneratorClassesResolver extends NodeVisitorAbstract
if ($node instanceof StaticCall
&& $node->class instanceof FullyQualified
&& $node->class->toString() === 'TYPO3\CMS\Core\Utility\GeneralUtility'
&& $node->name === 'makeInstance'
&& $node->name->name === 'makeInstance'
&& isset($node->args[0]->value)
&& $node->args[0]->value instanceof String_
) {
......
......@@ -58,11 +58,11 @@ class InterfaceMethodChangedMatcher extends AbstractCoreMatcher
// Match method name of a class, must be public, wouldn't make sense as interface if protected/private
if ($node instanceof ClassMethod
&& in_array($node->name, array_keys($this->matcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->matcherDefinitions), true)
&& $node->flags & Class_::MODIFIER_PUBLIC // public
&& ($node->flags & Class_::MODIFIER_STATIC) !== Class_::MODIFIER_STATIC // not static
) {
$methodName = $node->name;
$methodName = $node->name->name;
$numberOfUsedArguments = 0;
if (isset($node->params) && is_array($node->params)) {
$numberOfUsedArguments = count($node->params);
......@@ -80,9 +80,9 @@ class InterfaceMethodChangedMatcher extends AbstractCoreMatcher
// Match method call (not static) with number of arguments
if ($node instanceof MethodCall
&& in_array($node->name, array_keys($this->matcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->matcherDefinitions), true)
) {
$methodName = $node->name;
$methodName = $node->name->name;
$numberOfUsedArguments = 0;
if (isset($node->args) && is_array($node->args)) {
$numberOfUsedArguments = count($node->args);
......
......@@ -50,7 +50,7 @@ class MethodArgumentDroppedMatcher extends AbstractCoreMatcher
if (!$this->isFileIgnored($node)
&& !$this->isLineIgnored($node)
&& $node instanceof MethodCall
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
......@@ -62,14 +62,14 @@ class MethodArgumentDroppedMatcher extends AbstractCoreMatcher
$numberOfArguments = count($node->args);
$isPossibleMatch = false;
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
// A method call is considered a match if it is not called with argument unpacking
// and number of used arguments is higher than maximumNumberOfArguments
if (!$isArgumentUnpackingUsed
&& $numberOfArguments > $candidate['maximumNumberOfArguments']
) {
$isPossibleMatch = true;
$match['message'] = 'Method "' . $node->name . '()" supports only ' . $candidate['maximumNumberOfArguments'] . ' arguments.';
$match['message'] = 'Method "' . $node->name->name . '()" supports only ' . $candidate['maximumNumberOfArguments'] . ' arguments.';
$match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
}
}
......
......@@ -55,7 +55,7 @@ class MethodArgumentDroppedStaticMatcher extends AbstractCoreMatcher
if ($node->class instanceof FullyQualified) {
// 'Foo\Bar::aMethod()' -> strong match
$fqdnClassWithMethod = $node->class->toString() . '::' . $node->name;
$fqdnClassWithMethod = $node->class->toString() . '::' . $node->name->name;
if (!$isArgumentUnpackingUsed
&& in_array($fqdnClassWithMethod, array_keys($this->matcherDefinitions), true)
&& count($node->args) > $this->matcherDefinitions[$fqdnClassWithMethod]['maximumNumberOfArguments']
......@@ -63,14 +63,14 @@ class MethodArgumentDroppedStaticMatcher extends AbstractCoreMatcher
$this->matches[] = [
'restFiles' => $this->matcherDefinitions[$fqdnClassWithMethod]['restFiles'],
'line' => $node->getAttribute('startLine'),
'message' => 'Method "' . $node->name . '()" supports only '
'message' => 'Method "' . $node->name->name . '()" supports only '
. $this->matcherDefinitions[$fqdnClassWithMethod]['maximumNumberOfArguments']
. ' arguments.',
'indicator' => 'strong',
];
}
} elseif ($node->class instanceof Variable
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
......@@ -80,14 +80,14 @@ class MethodArgumentDroppedStaticMatcher extends AbstractCoreMatcher
$numberOfArguments = count($node->args);
$isPossibleMatch = false;
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
// A method call is considered a match if it is not called with argument unpacking
// and number of used arguments is higher than maximumNumberOfArguments
if (!$isArgumentUnpackingUsed
&& $numberOfArguments > $candidate['maximumNumberOfArguments']
) {
$isPossibleMatch = true;
$match['message'] = 'Method "' . $node->name . '()" supports only '
$match['message'] = 'Method "' . $node->name->name . '()" supports only '
. $candidate['maximumNumberOfArguments'] . ' arguments.';
$match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
}
......
......@@ -49,7 +49,7 @@ class MethodArgumentRequiredMatcher extends AbstractCoreMatcher
if (!$this->isFileIgnored($node)
&& !$this->isLineIgnored($node)
&& $node instanceof MethodCall
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
......@@ -61,7 +61,7 @@ class MethodArgumentRequiredMatcher extends AbstractCoreMatcher
$numberOfArguments = count($node->args);
$isPossibleMatch = false;
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
// A method call is considered a match if it is not called with argument unpacking
// and number of used arguments is lower than numberOfMandatoryArguments
if (!$isArgumentUnpackingUsed
......@@ -69,7 +69,7 @@ class MethodArgumentRequiredMatcher extends AbstractCoreMatcher
&& $numberOfArguments <= $candidate['maximumNumberOfArguments']
) {
$isPossibleMatch = true;
$match['message'] = 'Method ' . $node->name . '() needs at least ' . $candidate['numberOfMandatoryArguments'] . ' arguments.';
$match['message'] = 'Method ' . $node->name->name . '() needs at least ' . $candidate['numberOfMandatoryArguments'] . ' arguments.';
$match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
}
}
......
......@@ -55,7 +55,7 @@ class MethodArgumentRequiredStaticMatcher extends AbstractCoreMatcher
if ($node->class instanceof FullyQualified) {
// 'Foo\Bar::aMethod()' -> strong match
$fqdnClassWithMethod = $node->class->toString() . '::' . $node->name;
$fqdnClassWithMethod = $node->class->toString() . '::' . $node->name->name;
$numberOfArguments = count($node->args);
if (!$isArgumentUnpackingUsed
&& in_array($fqdnClassWithMethod, array_keys($this->matcherDefinitions), true)
......@@ -66,14 +66,14 @@ class MethodArgumentRequiredStaticMatcher extends AbstractCoreMatcher
$this->matches[] = [
'restFiles' => $this->matcherDefinitions[$fqdnClassWithMethod]['restFiles'],
'line' => $node->getAttribute('startLine'),
'message' => 'Method "' . $node->name . '()" needs at least '
'message' => 'Method "' . $node->name->name . '()" needs at least '
. $this->matcherDefinitions[$fqdnClassWithMethod]['numberOfMandatoryArguments']
. ' arguments.',
'indicator' => 'strong',
];
}
} elseif ($node->class instanceof Variable
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
......@@ -83,7 +83,7 @@ class MethodArgumentRequiredStaticMatcher extends AbstractCoreMatcher
$numberOfArguments = count($node->args);
$isPossibleMatch = false;
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
// A method call is considered a match if it is not called with argument unpacking
// and number of used arguments is lesser than numberOfMandatoryArguments
if (!$isArgumentUnpackingUsed
......@@ -92,7 +92,7 @@ class MethodArgumentRequiredStaticMatcher extends AbstractCoreMatcher
&& $numberOfArguments <= $candidate['maximumNumberOfArguments']
) {
$isPossibleMatch = true;
$match['message'] = 'Method "' . $node->name . '()" needs at least '
$match['message'] = 'Method "' . $node->name->name . '()" needs at least '
. $candidate['numberOfMandatoryArguments'] . ' arguments.';
$match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
}
......
......@@ -51,7 +51,7 @@ class MethodArgumentUnusedMatcher extends AbstractCoreMatcher
if (!$this->isFileIgnored($node)
&& !$this->isLineIgnored($node)
&& $node instanceof MethodCall
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
......@@ -63,18 +63,18 @@ class MethodArgumentUnusedMatcher extends AbstractCoreMatcher
$numberOfArguments = count($node->args);
$isPossibleMatch = false;
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
foreach ($candidate['unusedArgumentNumbers'] as $droppedArgumentNumber) {
// A method call is considered a match if name matches, unpacking is not used
// and the registered argument is not given as null.
if (!$isArgumentUnpackingUsed
&& $numberOfArguments >= $droppedArgumentNumber
&& !($node->args[$droppedArgumentNumber - 1]->value instanceof ConstFetch)
&& (!isset($node->args[$droppedArgumentNumber - 1]->value->name->parts[0])
|| $node->args[$droppedArgumentNumber - 1]->value->name->parts[0] !== null)
&& (!isset($node->args[$droppedArgumentNumber - 1]->value->name->name->parts[0])
|| $node->args[$droppedArgumentNumber - 1]->value->name->name->parts[0] !== null)
) {
$isPossibleMatch = true;
$match['message'] = 'Call to method "' . $node->name . '()" with'
$match['message'] = 'Call to method "' . $node->name->name . '()" with'
. ' argument ' . $droppedArgumentNumber . ' not given as null.';
$match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
}
......
......@@ -49,12 +49,12 @@ class MethodCallMatcher extends AbstractCoreMatcher
if (!$this->isFileIgnored($node)
&& !$this->isLineIgnored($node)
&& $node instanceof MethodCall
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
'line' => $node->getAttribute('startLine'),
'message' => 'Call to method "' . $node->name . '()"',
'message' => 'Call to method "' . $node->name->name . '()"',
'indicator' => 'weak',
];
......@@ -62,7 +62,7 @@ class MethodCallMatcher extends AbstractCoreMatcher
$isArgumentUnpackingUsed = $this->isArgumentUnpackingUsed($node->args);
$isPossibleMatch = false;
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
// A method call is considered a match if it is called with argument unpacking, or
// if the number of given arguments is within range of mandatory / max number of arguments
if ($isArgumentUnpackingUsed
......
......@@ -61,7 +61,7 @@ class MethodCallStaticMatcher extends AbstractCoreMatcher
) {
if ($node->class instanceof FullyQualified) {
// 'Foo\Bar::deprecated()' -> strong match
$fqdnClassWithMethod = $node->class->toString() . '::' . $node->name;
$fqdnClassWithMethod = $node->class->toString() . '::' . $node->name->name;
if (in_array($fqdnClassWithMethod, array_keys($this->matcherDefinitions), true)) {
$this->matches[] = [
'restFiles' => $this->matcherDefinitions[$fqdnClassWithMethod]['restFiles'],
......@@ -71,12 +71,12 @@ class MethodCallStaticMatcher extends AbstractCoreMatcher
];
}
} elseif ($node->class instanceof Variable
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
'line' => $node->getAttribute('startLine'),
'message' => 'Use of static class method call "' . $node->name . '()"',
'message' => 'Use of static class method call "' . $node->name->name . '()"',
'indicator' => 'weak',
];
......@@ -84,7 +84,7 @@ class MethodCallStaticMatcher extends AbstractCoreMatcher
$isArgumentUnpackingUsed = $this->isArgumentUnpackingUsed($node->args);
$isPossibleMatch = false;
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
// A method call is considered a match if it is called with argument unpacking, or
// if the number of given arguments is within range of mandatory / max number of arguments
if ($isArgumentUnpackingUsed
......
......@@ -47,13 +47,13 @@ class PropertyExistsStaticMatcher extends AbstractCoreMatcher
&& $node instanceof Property
&& $node->isStatic()
&& !$node->isPrivate()
&& in_array($node->props[0]->name, array_keys($this->matcherDefinitions), true)
&& in_array($node->props[0]->name->name, array_keys($this->matcherDefinitions), true)
) {
$propertyName = $node->props[0]->name;
$propertyName = $node->props[0]->name->name;
$match = [
'restFiles' => $this->matcherDefinitions[$propertyName]['restFiles'],
'line' => $node->getAttribute('startLine'),
'message' => 'Use of property "' . $node->props[0]->name . '"',
'message' => 'Use of property "' . $node->props[0]->name->name . '"',
'indicator' => 'weak',
];
$this->matches[] = $match;
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\ExtensionScanner\Php\Matcher;
use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Identifier;
/**
* Find usages of properties which have been made protected and are
......@@ -46,17 +47,18 @@ class PropertyProtectedMatcher extends AbstractCoreMatcher
if (!$this->isFileIgnored($node)
&& !$this->isLineIgnored($node)
&& $node instanceof PropertyFetch
&& $node->name instanceof Identifier
&& $node->var->name !== 'this'
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
'line' => $node->getAttribute('startLine'),
'message' => 'Fetch of property "' . $node->name . '"',
'message' => 'Fetch of property "' . $node->name->name . '"',
'indicator' => 'weak',
];
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
$match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
}
$this->matches[] = $match;
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Install\ExtensionScanner\Php\Matcher;
use PhpParser\Node;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Identifier;
/**
* Find usages of properties which were removed / deprecated.
......@@ -46,16 +47,17 @@ class PropertyPublicMatcher extends AbstractCoreMatcher
if (!$this->isFileIgnored($node)
&& !$this->isLineIgnored($node)
&& $node instanceof PropertyFetch
&& in_array($node->name, array_keys($this->flatMatcherDefinitions), true)
&& $node->name instanceof Identifier
&& in_array($node->name->name, array_keys($this->flatMatcherDefinitions), true)
) {
$match = [
'restFiles' => [],
'line' => $node->getAttribute('startLine'),
'message' => 'Fetch of property "' . $node->name . '"',
'message' => 'Fetch of property "' . $node->name->name . '"',
'indicator' => 'weak',
];
foreach ($this->flatMatcherDefinitions[$node->name]['candidates'] as $candidate) {
foreach ($this->flatMatcherDefinitions[$node->name->name]['candidates'] as $candidate) {
$match['restFiles'] = array_unique(array_merge($match['restFiles'], $candidate['restFiles']));
}
$this->matches[] = $match;
......
......@@ -40,8 +40,8 @@ EOC;
$traverser = new NodeTraverser();
$traverser->addVisitor(new GeneratorClassesResolver());
$statements = $traverser->traverse($statements);
$this->assertInstanceOf(FullyQualified::class, $statements[0]->args[0]->value);
$this->assertEquals([ 'TYPO3', 'CMS', 'Does', 'Not', 'Exist'], $statements[0]->args[0]->value->parts);
$this->assertInstanceOf(FullyQualified::class, $statements[0]->expr->args[0]->value);
$this->assertEquals(['TYPO3', 'CMS', 'Does', 'Not', 'Exist'], $statements[0]->expr->args[0]->value->parts);
}
/**
......@@ -58,6 +58,6 @@ EOC;
$traverser = new NodeTraverser();
$traverser->addVisitor(new GeneratorClassesResolver());
$statements = $traverser->traverse($statements);
$this->assertNotInstanceOf(FullyQualified::class, $statements[0]->args[0]->value);
$this->assertNotInstanceOf(FullyQualified::class, $statements[0]->expr->args[0]->value);
}
}
......@@ -13,7 +13,7 @@
"sort-packages": true
},
"require": {
"nikic/php-parser": "^3.1",
"nikic/php-parser": "^4.0",
"symfony/finder": "^2.7 || ^3.0 || ^4.0",
"typo3/cms-core": "9.3.*@dev",
"typo3/cms-extbase": "9.3.*@dev",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment