Skip to content

Commit bf7574b

Browse files
feature #31310 [DependencyInjection] Added option ignore_errors: not_found for imported config files (pulzarraider)
This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection] Added option `ignore_errors: not_found` for imported config files | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | symfony/symfony-docs#11647 If someone want to add optional config file. The only available choice was to add `ignore_errors: true` option e.g. ``` imports: - { resource: parameters.yml, ignore_errors: true } ``` But this will hide all errors in imported file. We ran in many situations that broke our Symfony applications because we had a typo in this imported files. This PR introduce new possible value `not_found` for `ignore_errors` option. It can be used for optional config files like the `ignore_errors: true`, but it will ignore only the file non-existence, not the possible syntax errors inside. Usage: ``` imports: - { resource: parameters.yml, ignore_errors: not_found} ``` Commits ------- e0ee01c10d [DependencyInjection] Added option `ignore_errors: not_found` while importing config files
2 parents a771502 + 79e639e commit bf7574b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Loader/FileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getLocator()
7373
*/
7474
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null/*, $exclude = null*/)
7575
{
76-
if (\func_num_args() < 5 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
76+
if (\func_num_args() < 5 && __CLASS__ !== \get_class($this) && 0 !== strpos(\get_class($this), 'Symfony\Component\\') && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
7777
@trigger_error(sprintf('The "%s()" method will have a new "$exclude = null" argument in version 5.0, not defining it is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED);
7878
}
7979
$exclude = \func_num_args() >= 5 ? func_get_arg(4) : null;

0 commit comments

Comments
 (0)