Created
May 20, 2020 22:05
-
-
Save BogdanUngureanu/579ed6387e5c873fa2a3e9d4feb41da8 to your computer and use it in GitHub Desktop.
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 | |
/// a built-in interface | |
interface TargetAttribute { | |
public function validate($target): boolean; | |
} | |
interface NonFooInterface { | |
} | |
<<PhpAttribute>> | |
class SingleArgument implements TargetAttribute { | |
public function __construct($argumentValue) { | |
} | |
public function validate(NonFooInterface $target): boolean { | |
return true; // you could add some complex logic here as well. | |
} | |
} | |
<<SingleArgument>> /// this would fail since the target, in this case Foo, doesn't implement the NonFooInterface | |
class Foo { | |
public __construct(string <<SingleArgument>> $prop) // this would also fail because it passes a string. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment