class ReflectionClassNewInstancePatch
ReflectionClass::newInstance patch. Makes first argument of newInstance optional, since it works but signature is misleading
@author Florian Klein <florian.klein@free.fr>
Hierarchy
- class \Prophecy\Doubler\ClassPatch\ReflectionClassNewInstancePatch implements \Prophecy\Doubler\ClassPatch\ClassPatchInterface
Expanded class hierarchy of ReflectionClassNewInstancePatch
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ ClassPatch/ ReflectionClassNewInstancePatch.php, line 22
Namespace
Prophecy\Doubler\ClassPatchView source
class ReflectionClassNewInstancePatch implements ClassPatchInterface {
/**
* Supports ReflectionClass
*
* @param ClassNode $node
*
* @return bool
*/
public function supports(ClassNode $node) {
return 'ReflectionClass' === $node->getParentClass();
}
/**
* Updates newInstance's first argument to make it optional
*
* @param ClassNode $node
*/
public function apply(ClassNode $node) {
$method = $node->getMethod('newInstance');
\assert($method !== null);
foreach ($method->getArguments() as $argument) {
$argument->setDefault(null);
}
}
/**
* Returns patch priority, which determines when patch will be applied.
*
* @return int Priority number (higher = earlier)
*/
public function getPriority() {
return 50;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
ReflectionClassNewInstancePatch::apply | public | function | Updates newInstance's first argument to make it optional | Overrides ClassPatchInterface::apply |
ReflectionClassNewInstancePatch::getPriority | public | function | Returns patch priority, which determines when patch will be applied. | Overrides ClassPatchInterface::getPriority |
ReflectionClassNewInstancePatch::supports | public | function | Supports ReflectionClass | Overrides ClassPatchInterface::supports |