1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #2890 - phpstorm.meta.php scanner should be insensitive to method names

This commit is contained in:
Matthew Brown 2020-03-01 17:11:44 -05:00
parent f44c3488eb
commit 2e6fe993a8
3 changed files with 80 additions and 34 deletions

View File

@ -83,7 +83,7 @@ class PhpStormMetaScanner
) {
$meta_fq_classlike_name = implode('\\', $identifier->class->parts);
$meta_method_name = $identifier->name->name;
$meta_method_name = strtolower($identifier->name->name);
if ($map) {
$offset = $identifier->args[0]->value->value;

View File

@ -75,7 +75,9 @@ class StubTest extends TestCase
Config::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -97,7 +99,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -144,7 +148,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<stubs>
<file name="./tests/../tests/fixtures/stubs/systemclass.php" />
</stubs>
@ -166,7 +172,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
$runDir,
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<stubs>
<file name="' . $runDir . '/tests/fixtures/stubs/systemclass.php" />
</stubs>
@ -187,7 +195,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -224,7 +234,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -283,19 +295,19 @@ class StubTest extends TestCase
*/
function bar(array $a) {}
$a1 = (new \Ns\MyClass)->create("object");
$a2 = (new \Ns\MyClass)->create("exception");
$a1 = (new \Ns\MyClass)->creAte("object");
$a2 = (new \Ns\MyClass)->creaTe("exception");
$b1 = \create("object");
$b2 = \create("exception");
$b1 = \Create("object");
$b2 = \cReate("exception");
$e2 = \create(\LogicException::class);
$e2 = \creAte(\LogicException::class);
$c1 = (new \Ns\MyClass)->foo(5);
$c2 = (new \Ns\MyClass)->bar(["hello"]);
$d1 = \foo(5);
$d2 = \bar(["hello"]);
$d1 = \foO(5);
$d2 = \baR(["hello"]);
}'
);
@ -312,7 +324,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -350,7 +364,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -382,7 +398,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -416,7 +434,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -450,7 +470,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -573,7 +595,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -606,7 +630,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -642,7 +668,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -670,7 +698,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -702,7 +732,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -734,7 +766,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -782,7 +816,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -814,7 +850,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -863,7 +901,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -901,7 +941,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -947,7 +989,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>
@ -989,7 +1033,9 @@ class StubTest extends TestCase
TestConfig::loadFromXML(
dirname(__DIR__),
'<?xml version="1.0"?>
<psalm>
<psalm
errorLevel="1"
>
<projectFiles>
<directory name="src" />
</projectFiles>

View File

@ -1,7 +1,7 @@
<?php
namespace PHPSTORM_META {
override(\Ns\MyClass::create(0), map([
override(\Ns\MyClass::crEate(0), map([
'' => '@',
'exception' => \Exception::class,
'object' => \stdClass::class,
@ -12,8 +12,8 @@ namespace PHPSTORM_META {
'object' => \stdClass::class,
]));
override(\Ns\MyClass::foo(0), type(0));
override(\Ns\MyClass::bar(0), elementType(0));
override(\Ns\MyClass::foO(0), type(0));
override(\Ns\MyClass::Bar(0), elementType(0));
override(\foo(0), type(0));
override(\bar(0), elementType(0));
}