Fix Relative class names are not converted to fully-qualified class names (FQCNs) (#1005)

* Fix https://github.com/barryvdh/laravel-ide-helper/issues/627

* Fix codestyle

* Init

* composer fix-style

* Actualize

* Fix

* normalize composer.json

* Fix

* composer fix-style

* Replace NamespaceUses with UsesResolver

* Add UsesResolver tests

* Add MethodTest::testClassAliases

* Fix code style

* Get rid of laravel support helpers

* Make class UsesResolver stateless, update tests for it

* composer fix-style

Co-authored-by: Andrii Savluk <[email protected]>
Co-authored-by: laravel-ide-helper <[email protected]>
Co-authored-by: SavKS <[email protected]>
Co-authored-by: Taras Fomin <[email protected]>
This commit is contained in:
SavKS
2021-03-15 07:45:23 +01:00
committed by GitHub
co-authored by Andrii Savluk laravel-ide-helper SavKS Taras Fomin
parent 6c4dcd9049
commit c5e18beff1
7 changed files with 240 additions and 11 deletions
+39
View File
@@ -97,6 +97,37 @@ DOC;
$this->assertSame('$chars = \'$\\\'\\\\\'', $method->getParamsWithDefault(true));
$this->assertSame(['$chars = \'$\\\'\\\\\''], $method->getParamsWithDefault(false));
}
/**
* Test the output of a class when using class aliases for it
*/
public function testClassAliases()
{
$reflectionClass = new \ReflectionClass(ExampleClass::class);
$reflectionMethod = $reflectionClass->getMethod('getApplication');
$method = new Method($reflectionMethod, 'Example', $reflectionClass, null, [], [
'Application' => '\\Illuminate\\Foundation\\Application',
]);
$output = <<<'DOC'
/**
*
*
* @return \Illuminate\Foundation\Application
* @static
*/
DOC;
$this->assertSame($output, $method->getDocComment(''));
$this->assertSame('getApplication', $method->getName());
$this->assertSame('\\' . ExampleClass::class, $method->getDeclaringClass());
$this->assertSame('', $method->getParams(true));
$this->assertSame([], $method->getParams(false));
$this->assertSame('', $method->getParamsWithDefault(true));
$this->assertSame([], $method->getParamsWithDefault(false));
$this->assertTrue($method->shouldReturn());
}
}
class ExampleClass
@@ -115,4 +146,12 @@ class ExampleClass
{
return;
}
/**
* @return Application
*/
public function getApplication()
{
return;
}
}