Created
December 20, 2011 19:31
-
-
Save fzaninotto/1502867 to your computer and use it in GitHub Desktop.
Catch Interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface Bar {} | |
class Foo extends Exception implements Bar {} | |
try | |
{ | |
throw new Foo(); | |
} catch (Bar $e) { | |
echo "good!\n"; | |
} |
Then it's not a new idea :(
Wonder if you can do this with Traits in PHP 5.4.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony2 components are using this way, at least the Serializer: https://github.com/symfony/symfony/tree/master/src/Symfony/Component/Serializer/Exception