Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
<?php | |
use FooBar\Test\Mock; | |
// In the sample below, $mock expects the method "sayHelloTo" to be called one time | |
// with the parameter $name equals "Alexandre" and return "Hello Alexandre" | |
$mock = (new Mock)([ | |
'sayHelloTo' => function($name="Alexandre") { | |
return "Hello Alexandre"; |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.