/** * Test to see if we can introspect explicit classes */ public function testExplicitClassesStillGetProccessedByIntrospectionStrategy() { $className = 'ZendTest\\Di\\TestAsset\\ConstructorInjection\\OptionalParameters'; $explicitClasses = array($className => true); $definition = new RuntimeDefinition(null, $explicitClasses); $this->assertTrue($definition->hasClass($className)); $this->assertSame(array("__construct" => 3), $definition->getMethods($className)); }
/** * {@inheritDoc} */ protected function processClass($class) { static $jsonFlags = null; $classLower = strtolower($class); $className = $this->getRealClassName($classLower); $storage = $this->getCacheStorageAvailable(); if ($storage) { $success = false; $count = $this->cacheStorageCount; $key = str_replace('\\', '-', $classLower); $hit = $storage->incrementItem('hit-' . $key, 1) ?: 0; $definition = $storage->getItem('def-' . $key, $success); if ($success) { $this->classes[$className] = json_decode($definition, true); return; } } parent::processClass($className); if ($storage && $this->getCacheMinCount() <= $count && $this->getCacheMinHitrate() <= $hit / $count) { if (null === $jsonFlags) { $jsonFlags = 0; if (defined('JSON_UNESCAPED_SLASHES')) { $jsonFlags |= JSON_UNESCAPED_SLASHES; } if (defined('JSON_UNESCAPED_UNICODE')) { $jsonFlags |= JSON_UNESCAPED_UNICODE; } } $storage->setItem('def-' . $key, json_encode($this->classes[$className], $jsonFlags)); } }
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')); }
public function testIncludesDefaultMethodParameters() { $definition = new RuntimeDefinition(); $definition->forceLoadClass('ZendTest\\Di\\TestAsset\\ConstructorInjection\\OptionalParameters'); $this->assertSame(array('ZendTest\\Di\\TestAsset\\ConstructorInjection\\OptionalParameters::__construct:0' => array('a', null, false, null), 'ZendTest\\Di\\TestAsset\\ConstructorInjection\\OptionalParameters::__construct:1' => array('b', null, false, 'defaultConstruct'), 'ZendTest\\Di\\TestAsset\\ConstructorInjection\\OptionalParameters::__construct:2' => array('c', null, false, array())), $definition->getMethodParameters('ZendTest\\Di\\TestAsset\\ConstructorInjection\\OptionalParameters', '__construct')); }