mirror of
https://github.com/danog/psalm-plugin-symfony.git
synced 2024-11-30 04:29:10 +01:00
Add FileLocator::locate stub and test
This commit is contained in:
parent
75798144a3
commit
d545c4d671
13
src/Stubs/common/FileLocator.stubphp
Normal file
13
src/Stubs/common/FileLocator.stubphp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Symfony\Component\Config;
|
||||||
|
|
||||||
|
class FileLocator implements FileLocatorInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @psalm-template TFirst as bool
|
||||||
|
* @psalm-param TFirst $first
|
||||||
|
* @psalm-return (TFirst is true ? string : array)
|
||||||
|
*/
|
||||||
|
public function locate(string $name, string $currentPath = null, bool $first = true) {}
|
||||||
|
}
|
33
tests/acceptance/acceptance/FileLocator.feature
Normal file
33
tests/acceptance/acceptance/FileLocator.feature
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
@symfony-common
|
||||||
|
Feature: FileLocator locate
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given I have Symfony plugin enabled
|
||||||
|
|
||||||
|
Scenario: FileLocator locate method return type should be `string` when third argument is true
|
||||||
|
Given I have the following code
|
||||||
|
"""
|
||||||
|
<?php
|
||||||
|
function test(): string
|
||||||
|
{
|
||||||
|
$locator = new \Symfony\Component\Config\FileLocator(__DIR__);
|
||||||
|
|
||||||
|
return $locator->locate(__FILE__);
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
When I run Psalm
|
||||||
|
Then I see no errors
|
||||||
|
|
||||||
|
Scenario: FileLocator locate method return type should be `array` when third argument is false
|
||||||
|
Given I have the following code
|
||||||
|
"""
|
||||||
|
<?php
|
||||||
|
function test(): array
|
||||||
|
{
|
||||||
|
$locator = new \Symfony\Component\Config\FileLocator(__DIR__);
|
||||||
|
|
||||||
|
return $locator->locate(__FILE__, null, false);
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
When I run Psalm
|
||||||
|
Then I see no errors
|
Loading…
Reference in New Issue
Block a user