Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cb68bf3

Browse filesBrowse files
minor #53670 [Config] Provide more precise phpdoc for FileLocatorInterface::locate() (VincentLanglet)
This PR was merged into the 6.4 branch. Discussion ---------- [Config] Provide more precise phpdoc for `FileLocatorInterface::locate()` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | ? | New feature? | ? | Deprecations? | no | Issues | Fix #... | License | MIT When working with psalm/phpstan, they believe `$locator->locate('...');` returns possibly an array which is not true. This can be defined with ``@psalm`-return` annotation that Symfony started to integrate in the code base. Commits ------- b2afd32 Provide more precise phpdoc for FileLocatorInterface::locate
2 parents 89d3197 + b2afd32 commit cb68bf3
Copy full SHA for cb68bf3

File tree

2 files changed

+6
-2
lines changed
Filter options

2 files changed

+6
-2
lines changed

‎src/Symfony/Component/Config/FileLocator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/FileLocator.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public function __construct(string|array $paths = [])
3131
}
3232

3333
/**
34-
* @return string|array
34+
* @return string|string[]
35+
*
36+
* @psalm-return ($first is true ? string : string[])
3537
*/
3638
public function locate(string $name, ?string $currentPath = null, bool $first = true)
3739
{

‎src/Symfony/Component/Config/FileLocatorInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/FileLocatorInterface.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ interface FileLocatorInterface
2525
* @param string|null $currentPath The current path
2626
* @param bool $first Whether to return the first occurrence or an array of filenames
2727
*
28-
* @return string|array The full path to the file or an array of file paths
28+
* @return string|string[] The full path to the file or an array of file paths
2929
*
3030
* @throws \InvalidArgumentException If $name is empty
3131
* @throws FileLocatorFileNotFoundException If a file is not found
32+
*
33+
* @psalm-return ($first is true ? string : string[])
3234
*/
3335
public function locate(string $name, ?string $currentPath = null, bool $first = true);
3436
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.