当前位置: 首页>>代码示例>>PHP>>正文


PHP Method::from方法代码示例

本文整理汇总了PHP中Method::from方法的典型用法代码示例。如果您正苦于以下问题:PHP Method::from方法的具体用法?PHP Method::from怎么用?PHP Method::from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Method的用法示例。


在下文中一共展示了Method::from方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getConstructor

 /**
  * @return Method|NULL
  */
 public function getConstructor()
 {
     return ($ref = parent::getConstructor()) ? Method::from($this->getName(), $ref->getName()) : NULL;
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:7,代码来源:ClassType.php

示例2: generateClassBaseCase

 /**
  * Generates SK ITCBundle Command Code Generator PHPUnit Abstract Generator Generator Class Base Case
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 public function generateClassBaseCase(InputInterface $input, OutputInterface $output)
 {
     $cases = $this->getTestConfig()->getTestsCase();
     $this->writeNotice("Generating Class Tests Base Case: " . count($cases));
     foreach ($cases as $configName => $configClass) {
         print $configName . "\n";
     }
     return;
     foreach ($configCase as $configName => $configClass) {
         $classService = Arrays::get($configServices, $configName);
         $classType = Arrays::get($classService, 'class');
         $classReflection = ReflectionClassType::from($classType);
         $classGenerator = PhpGeneratorClassType::from($classType);
         $classAnnotations = $classReflection->getAnnotations();
         $classAnnotationsSwitch = Arrays::get($classAnnotations, 'no-test', FALSE);
         if (FALSE !== $classAnnotationsSwitch) {
             continue;
         }
         $className = $classGenerator->getName() . "Base";
         if ('interface' == $classGenerator->getType() || $classGenerator->isAbstract()) {
             continue;
         }
         $classParent = "BaseCase";
         $dependencies = array('\\ITC\\Tests\\BaseCase' => 'BaseCase');
         $classGenerator->setName($className);
         $classGenerator->setExtends($classParent);
         $classGenerator->setImplements(array());
         $classGenerator->setProperties(array());
         $classGenerator->setMethods(array());
         $classGenerator->setConsts(array());
         $classNameProperty = $classGenerator->addProperty("className", $configName);
         $classNameProperty->setVisibility('protected');
         // $classGenerator->addDocument("@runInSeparateProcess");
         $classProviderData = array();
         foreach ($configClass as $configClassMethod => $paramametersConfig) {
             $methodReflection = $classReflection->getMethod($configClassMethod);
             $methodGenerator = Method::from($methodReflection);
             $methodAnnotations = $methodReflection->getAnnotations();
             $methodAnnotationsReturn = Arrays::get($methodAnnotations, 'return', NULL);
             $methodAnnotationsSwitch = Arrays::get($methodAnnotations, 'no-test', FALSE);
             if (FALSE !== $methodAnnotationsSwitch) {
                 continue;
             }
             if ($methodReflection->isAbstract()) {
                 continue;
             }
             if ('__construct' == $methodReflection->getName()) {
                 continue;
             }
             if (!is_callable(array($classReflection->getName(), $methodReflection->getName()))) {
                 continue;
             }
             $providerName = $methodReflection->getName() . "Provider";
             $provider = $classGenerator->addMethod($providerName);
             $permutationOffset = array();
             $parametersPermutations = new Permutation($paramametersConfig);
             foreach ($parametersPermutations as $permutation) {
                 $permutationOffset[] = $permutation;
             }
             $classProviderData[$methodReflection->getName()] = $permutationOffset;
             $provider->setBody(sprintf('return $this->getProviderData("%s");', $methodReflection->getName()));
         }
         $providerData = $classGenerator->addProperty("providerData", $classProviderData);
         $providerData->setVisibility('protected');
         $classInfo = new \SplFileInfo(dirname(str_replace($this->getRootDir(), $this->getDest(), $classReflection->getFileName())) . DIRECTORY_SEPARATOR . $classGenerator->getName() . ".php");
         $classDependency = "";
         foreach ($dependencies as $dependency => $dependencyClass) {
             $classDependency .= "\nuse " . $dependency;
             if ('' == $dependencyClass) {
                 $classDependency .= " as " . $dependencyClass;
             }
             $classDependency .= ";";
         }
         $classCode = sprintf("<?php\nnamespace %s;\n%s\n%s", $classReflection->getNamespaceName(), $classDependency, $classGenerator);
         $this->saveClass($classCode, $classInfo);
     }
 }
开发者ID:slavomirkuzma,项目名称:itc-bundle,代码行数:83,代码来源:PHPUnitGenerator.php


注:本文中的Method::from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。