Voting

: max(five, four)?
(Example: nine)

The Note You're Voting On

flancer64 at gmail dot com
8 years ago
Annotated methods that are implemented using PHP magic methods are not recognized by "hasMethod".

<?php
/**
* @method void annotatedMethod()
*/
class SomeClass
{
public function
__call($name, $arguments)
{
echo
"this is magic method: $name.\n";
}

public function
codedMethod()
{
echo
"this is coded method.\n";
}
}

$obj = new \SomeClass();
$obj->codedMethod();
$obj->annotatedMethod();

$ref = new ReflectionClass(\SomeClass::class);
echo
"SomeClass has 'codedMethod': " . json_encode($ref->hasMethod('codedMethod')) . ".\n";
echo
"SomeClass has 'annotatedMethod': " . json_encode($ref->hasMethod('annotatedMethod')) . ".\n";
?>

Output:

this is coded method.
this is magic method: annotatedMethod.
SomeClass has 'codedMethod': true.
SomeClass has 'annotatedMethod': false.

<< Back to user notes page

To Top