Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix default value unavailable exception for in-build php classes #3070

Closed
wants to merge 1 commit into from

2 participants

@necromant2005

Main trouble: https://bugs.php.net/bug.php?id=50798
Getting Reflection for default value for internal php extension
I caught this in GearmanClient
The best solution is using "isDefaultValueAvailable" method
http://www.php.net/manual/en/reflectionparameter.isdefaultvalueavailable.php

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3070'
Close #3070
f038a45
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3070' into develop
Forward port #3070
a0ebfce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  library/Zend/Di/Definition/RuntimeDefinition.php
@@ -346,7 +346,7 @@ protected function processParams(&$def, Reflection\ClassReflection $rClass, Refl
// set the class name, if it exists
$def['parameters'][$methodName][$fqName][] = $actualParamName;
$def['parameters'][$methodName][$fqName][] = ($p->getClass() !== null) ? $p->getClass()->getName() : null;
- $def['parameters'][$methodName][$fqName][] = !($optional =$p->isOptional());
+ $def['parameters'][$methodName][$fqName][] = !($optional =$p->isOptional() && $p->isDefaultValueAvailable());
$def['parameters'][$methodName][$fqName][] = $optional ? $p->getDefaultValue() : null;
}
View
34 tests/ZendTest/Di/Definition/RuntimeDefinitionTest.php
@@ -59,4 +59,38 @@ public function testIncludesDefaultMethodParameters()
)
);
}
+
+ public function testExceptionDefaultValue()
+ {
+ $definition = new RuntimeDefinition();
+
+ $definition->forceLoadClass('RecursiveIteratorIterator');
+
+ $this->assertSame(
+ array(
+ 'RecursiveIteratorIterator::__construct:0' => array(
+ 'iterator',
+ 'Traversable',
+ true,
+ null,
+ ),
+ 'RecursiveIteratorIterator::__construct:1' => Array (
+ 'mode',
+ null,
+ true,
+ null,
+ ),
+ 'RecursiveIteratorIterator::__construct:2' => Array (
+ 'flags',
+ null,
+ true,
+ null,
+ ),
+ ),
+ $definition->getMethodParameters(
+ 'RecursiveIteratorIterator',
+ '__construct'
+ )
+ );
+ }
}
Something went wrong with that request. Please try again.