예제 #1
0
 public function testGetInvalidTypeException()
 {
     $metadataClass = new MetadataClass('standalone', 'Asset\\StandaloneClass');
     $metadataMethod = new MetadataMethod('__construct');
     $metadataMethod->addArgument('unknown', 'param1');
     $metadataMethod->addArgument(MetadataMethod::PRIMITIVE_TYPE, 'param2');
     $metadataClass->registerInvoke($metadataMethod);
     $metadataMethod = new MetadataMethod('setParam3');
     $metadataMethod->addArgument(MetadataMethod::PRIMITIVE_TYPE, 'data');
     $metadataClass->registerInvoke($metadataMethod);
     $di = new DependencyInjection();
     $di->register($metadataClass);
     $exception = null;
     try {
         $di->get('standalone');
     } catch (\Exception $e) {
         $exception = $e;
     }
     $this->assertInstanceOf(InvalidTypeException::class, $exception);
 }
예제 #2
0
파일: Root.php 프로젝트: itephp/framework
 /**
  *
  * @param Config $methodNode
  * @return MetadataMethod
  */
 private function getMetadataDependencyMethod(Config $methodNode)
 {
     $metadataMethod = new MetadataMethod($methodNode->getAttribute('name'));
     foreach ($methodNode->getNodes('argument') as $argumentNode) {
         /**
          * @var Config $argumentNode
          */
         $metadataMethod->addArgument($argumentNode->getAttribute('type'), $argumentNode->getAttribute('value'));
     }
     return $metadataMethod;
 }