-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Use a dedicated exception in the file locator #19511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* | ||
* @author Leo Feyer <https://github.com/leofeyer> | ||
*/ | ||
class FileLocatorFileNotFoundException extends \InvalidArgumentException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply FileNotFoundException
? The current name is verbose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the other exception classes also use a prefix: https://github.com/symfony/symfony/tree/master/src/Symfony/Component/Config/Exception
Just wanted to keep things consistent.
In some way this can be a BC break, while your example works fine, but what happens if someone do something like this: |
You would normally check |
@@ -86,7 +87,7 @@ public function testLocate() | |||
} | |||
|
|||
/** | |||
* @expectedException \InvalidArgumentException | |||
* @expectedException FileLocatorFileNotFoundException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpunit doesn't handle use statements, should be Symfony\Component\Config\Exception\FileLocatorFileNotFoundException
(same below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the PR accordingly. However, use
statements seem to work in phpunit under PHP 5.6 and PHP 7. Is this a known issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP 7 requires a phpunit 5.* whereas phpunit 4.8 is the only option for PHP5.3 to 5.5.
Maybe phpunit 5.* handles use
, but since we still support PHP 5.3, we can't use them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That cannot be true. I am using PhpUnit 4.8 with PHP 7.0.
leofeyer:core-bundle$ vendor/bin/phpunit --version
PHPUnit 4.8.27 by Sebastian Bergmann and contributors.
leofeyer:core-bundle$ php -v
PHP 7.0.9 (cli) (built: Jul 21 2016 14:50:47) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.9, Copyright (c) 1999-2016, by Zend Technologies
with blackfire v1.11.1, https://blackfire.io, by Blackfireio Inc.
Status: reviewed |
👍 |
Thank you @leofeyer. |
This PR adds a dedicated
FileLocatorFileNotFoundException
class to the file locator, so it is possible to catch file locator exceptions separately from invalid argument exceptions.With the dedicated exceptions, we could do this: