當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Node\ClassNode類代碼示例

本文整理匯總了PHP中Prophecy\Doubler\Generator\Node\ClassNode的典型用法代碼示例。如果您正苦於以下問題:PHP ClassNode類的具體用法?PHP ClassNode怎麽用?PHP ClassNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ClassNode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

 /**
  *
  * @param \Prophecy\Doubler\Generator\Node\ClassNode $class        	
  * @param \Prophecy\Doubler\Generator\Node\MethodNode $method        	
  * @param \Prophecy\Doubler\Generator\Node\ArgumentNode $arg1        	
  * @param \Prophecy\Doubler\Generator\Node\ArgumentNode $arg2        	
  */
 function it_makes_all_newInstance_arguments_optional($class, $method, $arg1, $arg2)
 {
     $class->getMethod('newInstance')->willReturn($method);
     $method->getArguments()->willReturn(array($arg1));
     $arg1->setDefault(null)->shouldBeCalled();
     $this->apply($class);
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:14,代碼來源:ReflectionClassNewInstancePatchSpec.php

示例2: MethodNode

 /**
  * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  */
 function it_discovers_api_using_phpdoc_from_extended_parent_interfaces($node)
 {
     $node->getParentClass()->willReturn('spec\\Prophecy\\Doubler\\ClassPatch\\MagicalApiImplementedExtended');
     $node->getInterfaces()->willReturn(array());
     $node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled();
     $this->apply($node);
 }
開發者ID:phpspec,項目名稱:prophecy,代碼行數:10,代碼來源:MagicCallPatchSpec.php

示例3: MethodNode

 /**
  *
  * @param \Prophecy\Doubler\Generator\Node\ClassNode $node        	
  */
 function it_ignores_existing_methods($node)
 {
     $node->getParentClass()->willReturn('spec\\Prophecy\\Doubler\\ClassPatch\\MagicalApiExtended');
     $node->addMethod(new MethodNode('undefinedMethod'))->shouldBeCalled();
     $node->addMethod(new MethodNode('definedMethod'))->shouldNotBeCalled();
     $this->apply($node);
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:11,代碼來源:MagicCallPatchSpec.php

示例4:

 /**
  * @param \Prophecy\Doubler\Generator\Node\ClassNode  $node
  * @param \Prophecy\Doubler\Generator\Node\MethodNode $method
  */
 function it_updates_existing_method_if_found($node, $method)
 {
     $node->hasMethod('__construct')->willReturn(true);
     $node->getMethod('__construct')->willReturn($method);
     $method->setCode(Argument::any())->shouldBeCalled();
     $this->apply($node);
 }
開發者ID:mawaha,項目名稱:tracker,代碼行數:11,代碼來源:SplFileInfoPatchSpec.php

示例5: apply

 /**
  * Remove methods that clash with php keywords
  *
  * @param ClassNode $node
  */
 public function apply(ClassNode $node)
 {
     $methodNames = array_keys($node->getMethods());
     $methodsToRemove = array_intersect($methodNames, $this->getKeywords());
     foreach ($methodsToRemove as $methodName) {
         $node->removeMethod($methodName);
     }
 }
開發者ID:mawaha,項目名稱:tracker,代碼行數:13,代碼來源:KeywordPatch.php

示例6: apply

 /**
  * Removes special exception static methods from the doubled methods.
  *
  * @param ClassNode $node
  *
  * @return void
  */
 public function apply(ClassNode $node)
 {
     if ($node->hasMethod('setTraceOptions')) {
         $node->getMethod('setTraceOptions')->useParentCode();
     }
     if ($node->hasMethod('getTraceOptions')) {
         $node->getMethod('getTraceOptions')->useParentCode();
     }
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:16,代碼來源:HhvmExceptionPatch.php

示例7: strpos

 function it_should_supply_a_file_for_a_spl_file_object(ClassNode $node, MethodNode $method)
 {
     $node->hasMethod('__construct')->willReturn(true);
     $node->getMethod('__construct')->willReturn($method);
     $node->getParentClass()->willReturn('SplFileObject');
     $method->setCode(Argument::that(function ($value) {
         return strpos($value, '.php') !== false;
     }))->shouldBeCalled();
     $this->apply($node);
 }
開發者ID:phpspec,項目名稱:prophecy,代碼行數:10,代碼來源:SplFileInfoPatchSpec.php

示例8: strpos

 /**
  * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  * @param \Prophecy\Doubler\Generator\Node\MethodNode $method
  */
 function it_should_not_supply_a_file_for_a_directory_iterator($node, $method)
 {
     $node->hasMethod('__construct')->willReturn(true);
     $node->getMethod('__construct')->willReturn($method);
     $node->getParentClass()->willReturn('DirectoryIterator');
     $method->setCode(Argument::that(function ($value) {
         return strpos($value, '.php') === false;
     }))->shouldBeCalled();
     $this->apply($node);
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:14,代碼來源:SplFileInfoPatchSpec.php

示例9:

 function it_will_remove_echo_and_eval_methods(ClassNode $node, MethodNode $method1, MethodNode $method2, MethodNode $method3)
 {
     $node->removeMethod('eval')->shouldBeCalled();
     $node->removeMethod('echo')->shouldBeCalled();
     $method1->getName()->willReturn('echo');
     $method2->getName()->willReturn('eval');
     $method3->getName()->willReturn('notKeyword');
     $node->getMethods()->willReturn(array('echo' => $method1, 'eval' => $method2, 'notKeyword' => $method3));
     $this->apply($node);
 }
開發者ID:phpspec,項目名稱:prophecy,代碼行數:10,代碼來源:KeywordPatchSpec.php

示例10: apply

 /**
  * Updated constructor code to call parent one with dummy file argument.
  *
  * @param ClassNode $node
  */
 public function apply(ClassNode $node)
 {
     if ($node->hasMethod('__construct')) {
         $constructor = $node->getMethod('__construct');
     } else {
         $constructor = new MethodNode('__construct');
         $node->addMethod($constructor);
     }
     $constructor->setCode('return parent::__construct("' . __FILE__ . '");');
 }
開發者ID:burimshala,項目名稱:numbertowords,代碼行數:15,代碼來源:SplFileInfoPatch.php

示例11: apply

    /**
     * Apply Prophecy functionality to class node.
     *
     * @param ClassNode $node
     */
    public function apply(ClassNode $node)
    {
        $node->addInterface('Prophecy\\Prophecy\\ProphecySubjectInterface');
        $node->addProperty('objectProphecy', 'private');
        foreach ($node->getMethods() as $name => $method) {
            if ('__construct' === strtolower($name)) {
                continue;
            }
            $method->setCode('return $this->getProphecy()->makeProphecyMethodCall(__FUNCTION__, func_get_args());');
        }
        $prophecySetter = new MethodNode('setProphecy');
        $prophecyArgument = new ArgumentNode('prophecy');
        $prophecyArgument->setTypeHint('Prophecy\\Prophecy\\ProphecyInterface');
        $prophecySetter->addArgument($prophecyArgument);
        $prophecySetter->setCode('$this->objectProphecy = $prophecy;');
        $prophecyGetter = new MethodNode('getProphecy');
        $prophecyGetter->setCode('return $this->objectProphecy;');
        if ($node->hasMethod('__call')) {
            $__call = $node->getMethod('__call');
        } else {
            $__call = new MethodNode('__call');
            $__call->addArgument(new ArgumentNode('name'));
            $__call->addArgument(new ArgumentNode('arguments'));
            $node->addMethod($__call);
        }
        $__call->setCode(<<<PHP
throw new \\Prophecy\\Exception\\Doubler\\MethodNotFoundException(
    sprintf('Method `%s::%s()` not found.', get_class(\$this), func_get_arg(0)),
    \$this->getProphecy(), func_get_arg(0)
);
PHP
);
        $node->addMethod($prophecySetter);
        $node->addMethod($prophecyGetter);
    }
開發者ID:Ceciceciceci,項目名稱:MySJSU-Class-Registration,代碼行數:40,代碼來源:ProphecySubjectPatch.php

示例12: apply

 /**
  * Discover Magical API
  *
  * @param ClassNode $node
  */
 public function apply(ClassNode $node)
 {
     $parentClass = $node->getParentClass();
     $reflectionClass = new \ReflectionClass($parentClass);
     $phpdoc = new DocBlock($reflectionClass->getDocComment());
     $tagList = $phpdoc->getTagsByName('method');
     foreach ($tagList as $tag) {
         $methodNode = new MethodNode($tag->getMethodName());
         $methodNode->setStatic($tag->isStatic());
         $node->addMethod($methodNode);
     }
 }
開發者ID:mawaha,項目名稱:tracker,代碼行數:17,代碼來源:MagicCallPatch.php

示例13: apply

 /**
  * Discover Magical API
  *
  * @param ClassNode $node
  */
 public function apply(ClassNode $node)
 {
     $parentClass = $node->getParentClass();
     $reflectionClass = new \ReflectionClass($parentClass);
     $tagList = $this->tagRetriever->getTagList($reflectionClass);
     foreach ($tagList as $tag) {
         $methodName = $tag->getMethodName();
         if (empty($methodName)) {
             continue;
         }
         if (!$reflectionClass->hasMethod($methodName)) {
             $methodNode = new MethodNode($methodName);
             $methodNode->setStatic($tag->isStatic());
             $node->addMethod($methodNode);
         }
     }
 }
開發者ID:drickferreira,項目名稱:rastreador,代碼行數:22,代碼來源:MagicCallPatch.php

示例14: apply

    /**
     * Makes all class constructor arguments optional.
     *
     * @param ClassNode $node
     */
    public function apply(ClassNode $node)
    {
        if (!$node->hasMethod('__construct')) {
            $node->addMethod(new MethodNode('__construct', ''));
            return;
        }
        $constructor = $node->getMethod('__construct');
        foreach ($constructor->getArguments() as $argument) {
            $argument->setDefault(null);
        }
        $constructor->setCode(<<<PHP
if (0 < func_num_args()) {
    call_user_func_array(array('parent', '__construct'), func_get_args());
}
PHP
);
    }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:22,代碼來源:DisableConstructorPatch.php

示例15: apply

 /**
  * Forces class to implement Iterator interface.
  *
  * @param ClassNode $node
  */
 public function apply(ClassNode $node)
 {
     $node->addInterface('Iterator');
     $node->addMethod(new MethodNode('current'));
     $node->addMethod(new MethodNode('key'));
     $node->addMethod(new MethodNode('next'));
     $node->addMethod(new MethodNode('rewind'));
     $node->addMethod(new MethodNode('valid'));
 }
開發者ID:mrbadao,項目名稱:api-official,代碼行數:14,代碼來源:TraversablePatch.php


注:本文中的Prophecy\Doubler\Generator\Node\ClassNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。