potievdev /
slim-rbac
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Potievdev\SlimRbac\Component\Config; |
||||
| 4 | |||||
| 5 | use Potievdev\SlimRbac\Exception\ConfigNotFoundException; |
||||
| 6 | use Symfony\Component\Config\Definition\Processor; |
||||
| 7 | use Symfony\Component\Config\FileLocator; |
||||
| 8 | use Symfony\Component\Yaml\Yaml; |
||||
| 9 | |||||
| 10 | class RbacConfigLoader |
||||
| 11 | { |
||||
| 12 | /** |
||||
| 13 | * @throws ConfigNotFoundException |
||||
| 14 | */ |
||||
| 15 | public static function loadConfigs(): array |
||||
| 16 | { |
||||
| 17 | $configDirectories = [ |
||||
| 18 | __DIR__ . '/../../../config', |
||||
| 19 | __DIR__ . '/../../../../../', |
||||
| 20 | __DIR__ . '/../../../../../config', |
||||
| 21 | ]; |
||||
| 22 | |||||
| 23 | $fileLocator = new FileLocator($configDirectories); |
||||
| 24 | $fileName = $fileLocator->locate('sr_config.yaml'); |
||||
| 25 | |||||
| 26 | if ($fileName === null) { |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 27 | throw ConfigNotFoundException::configFileNotFound($configDirectories); |
||||
| 28 | } |
||||
| 29 | |||||
| 30 | return (new Processor()) |
||||
| 31 | ->processConfiguration(new RbacConfigStructure(), Yaml::parseFile($fileName)); |
||||
|
0 ignored issues
–
show
It seems like
$fileName can also be of type string[]; however, parameter $filename of Symfony\Component\Yaml\Yaml::parseFile() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 32 | } |
||||
| 33 | |||||
| 34 | } |