Add FileLocator::locate stub and test

This commit is contained in:
andyexeter 2021-07-21 13:07:34 +01:00
parent 75798144a3
commit d545c4d671
2 changed files with 46 additions and 0 deletions

View 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) {}
}

View 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