Created
January 1, 2012 13:50
-
-
Save ezzatron/1547377 to your computer and use it in GitHub Desktop.
Situation where serialized attributes might be necessary in Typhoon
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 | |
/** | |
* My awesome function that does amazing things | |
*/ | |
function doSomeAwesomeStuff($foo) | |
{ | |
// creating a custom type for the foo attribute | |
// passing some special matcher object which does the validation work | |
$fooType = new CustomType(array( | |
'matcher' => new Matcher, | |
)); | |
// assert it with Typhoon | |
Typhoon::assert($fooType, $foo); | |
// now assume it fails... | |
// we need to throw a nice exception message | |
// something like Unexpected value of type 'string' - expected 'CustomType(matcher: '%O:7:"Matcher":0:{}%')' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment