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


PHP FileGenerator::fromReflectedFileName方法代码示例

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


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

示例1: addToConfigObjects

 private function addToConfigObjects($objectName, $objectHandlerName, $objectHandlerFactoryName)
 {
     $conf = (include $this->confPath);
     $fileGenerator = FileGenerator::fromReflectedFileName($this->confPath);
     $conf['service_manager']['factories'][$objectHandlerName] = $objectHandlerFactoryName;
     $conf['tactician']['handler-map'][$objectName] = $objectHandlerName;
     $body = sprintf('return %s;', var_export($conf, TRUE));
     $newFile = new FileGenerator();
     $newFile->setUses($fileGenerator->getUses());
     $newFile->setBody($body);
     file_put_contents($this->confPath, $newFile->generate());
 }
开发者ID:Code-Mine-Development,项目名称:CommandQueryGenerator,代码行数:12,代码来源:ConfigService.php

示例2: handle

 /**
  * @param string $className
  * @return \Zend\Code\Generator\ClassGenerator
  */
 public function handle(string $className)
 {
     if (!preg_match(static::MATCH_PATTERN, $className, $matches)) {
         return null;
     }
     $baseName = $matches[1];
     $namespace = $this->deriveNamespaceFromClassName($className);
     $class = FileGenerator::fromReflectedFileName(__DIR__ . DIRECTORY_SEPARATOR . "templates" . DIRECTORY_SEPARATOR . "factory.php")->getClass("Factory");
     $class->setNamespaceName($namespace)->setName("{$baseName}Factory");
     $createMethod = $class->getMethod("create");
     $createMethod->setBody('return $this->diContainer->newInstance(' . $baseName . '::class, $params);')->setReturnType("{$namespace}\\{$baseName}");
     return $class;
 }
开发者ID:djmattyg007,项目名称:autocodeloader,代码行数:17,代码来源:FactoryGenerator.php

示例3: expectedPathForPsr4

 private function expectedPathForPsr4(array $filePaths, $namespace)
 {
     foreach ($filePaths as $file) {
         $generator = FileGenerator::fromReflectedFileName($file);
         $phpClassName = $generator->getClass()->getName();
         $fileClassName = pathinfo($file, PATHINFO_FILENAME);
         $phpClassNamespace = $generator->getClass()->getNamespaceName();
         if (false === strpos($namespace, $phpClassName)) {
             throw new \Exception(sprintf("File '%s' namespace is not valid.\nExpected to be under the '%s' namespace, found '%s'.", $file, $namespace, $phpClassNamespace));
         }
     }
     print_r(func_get_args());
     die;
 }
开发者ID:nilportugues,项目名称:php-namespace-checker,代码行数:14,代码来源:Namespacer.php

示例4: __invoke

 /**
  * @inheritDoc
  */
 public function __invoke($fcqn, $namespace, $commandName)
 {
     $commandName = ucfirst($commandName);
     $reflectionClass = new ClassReflection($fcqn);
     $fileGenerator = FileGenerator::fromReflectedFileName($reflectionClass->getFileName());
     $fileGenerator->setFilename($reflectionClass->getFileName());
     $fileGenerator->setUse(ltrim($namespace, '\\') . '\\' . $commandName);
     $classGenerator = $fileGenerator->getClass();
     // workaround for import namespace
     if ($classToExtend = $classGenerator->getExtendedClass()) {
         $classGenerator->setExtendedClass(substr($classToExtend, strrpos($classToExtend, '\\') + 1));
     }
     $classGenerator->addMethodFromGenerator($this->methodWhenEvent($commandName));
     return $fileGenerator;
 }
开发者ID:sandrokeil,项目名称:prooph-cli,代码行数:18,代码来源:AddEventToAggregate.php

示例5: hasActionMethod

 /**
  * hasActionMethod()
  *
  * @param string $controllerPath
  * @param string $actionName
  * @return bool
  */
 public static function hasActionMethod($controllerPath, $actionName)
 {
     if (!file_exists($controllerPath)) {
         return false;
     }
     $controllerCodeGenFile = FileGenerator::fromReflectedFileName($controllerPath, true, true);
     return $controllerCodeGenFile->getClass()->hasMethod($actionName . 'Action');
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:15,代码来源:ActionMethod.php

示例6: getCodeGenerator

 /**
  * getCodeGenerator()
  *
  * @return \Zend\Code\Generator\FileGenerator
  */
 public function getCodeGenerator()
 {
     $codeGenFile = FileGenerator::fromReflectedFileName($this->getPath());
     $codeGenFileClasses = $codeGenFile->getClasses();
     $class = array_shift($codeGenFileClasses);
     return $class;
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:12,代码来源:ControllerFile.php

示例7: testGeneratedClassesHaveUses

 public function testGeneratedClassesHaveUses()
 {
     $generator = FileGenerator::fromReflectedFileName(__DIR__ . '/TestAsset/ClassWithUses.php');
     $class = $generator->getClass();
     $expectedUses = array('ZendTest\\Code\\Generator\\TestAsset\\ClassWithNamespace');
     $this->assertEquals($expectedUses, $class->getUses());
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:7,代码来源:FileGeneratorTest.php

示例8: removeBackslashes

 public function removeBackslashes($path)
 {
     $generator = $this->fileGenerator->fromReflectedFileName($path);
     $source = explode("\n", $generator->getSourceContent());
     $tokens = token_get_all(file_get_contents($path));
 }
开发者ID:nilportugues,项目名称:php_backslasher,代码行数:6,代码来源:FileEditor.php

示例9: patchExistingFile

 /**
  * This method tries to patch an existing type class.
  *
  * @param TypeGenerator   $generator
  * @param Type            $type
  * @param string          $path
  *
  * @return bool
  */
 protected function patchExistingFile(TypeGenerator $generator, Type $type, $path)
 {
     try {
         $this->filesystem->createBackup($path);
         $file = FileGenerator::fromReflectedFileName($path);
         $this->generateType($file, $generator, $type, $path);
     } catch (\Exception $e) {
         $this->output->writeln('<fg=red>' . $e->getMessage() . '</fg=red>');
         $this->filesystem->removeBackup($path);
         return false;
     }
     return true;
 }
开发者ID:phpro,项目名称:soap-client,代码行数:22,代码来源:GenerateTypesCommand.php

示例10: getFiles

 /**
  *
  * @return FileCollection
  */
 public function getFiles(Settings $settings = NULL)
 {
     if (NULL !== $settings) {
         $this->setSettings($settings);
     }
     if (null === $this->files) {
         $reflections = parent::getFiles();
         $files = [];
         foreach ($reflections as $reflection) {
             $files[] = \Zend\Code\Generator\FileGenerator::fromReflectedFileName($reflection->getName());
         }
         $this->setFiles(new FileCollection($files));
     }
     return $this->files;
 }
开发者ID:slavomirkuzma,项目名称:itc-bundle,代码行数:19,代码来源:Generator.php

示例11: setClientMethodDocblocks

 /**
  * @return array
  */
 protected function setClientMethodDocblocks()
 {
     $client = new \SoapClient(__DIR__ . '/../../Resources/wsdl/services.wsdl');
     $functions = $client->__getFunctions();
     sort($functions);
     $functions = array_map(function ($function) {
         return preg_replace("~^[a-z]+\\s([a-z]+) ?\\(.+\\)\$~i", "\$1", $function);
     }, $functions);
     $exchangeWebServicesReflection = new ClassReflection(ExchangeWebServices::class);
     $fileGen = Generator\FileGenerator::fromReflectedFileName($exchangeWebServicesReflection->getFileName());
     $fileGen->setFilename($exchangeWebServicesReflection->getFileName());
     $exchangeWebServicesClass = Generator\ClassGenerator::fromReflection($exchangeWebServicesReflection);
     $docblock = $exchangeWebServicesClass->getDocBlock();
     $reflection = new \ReflectionClass($docblock);
     $property = $reflection->getProperty('tags');
     $property->setAccessible(true);
     $property->setValue($docblock, []);
     $docblock->setWordWrap(false);
     $tags = [];
     $tags[] = new Generator\DocBlock\Tag\GenericTag('@package php-ews\\Client');
     $tags[] = new EmptyDocblockTag();
     foreach ($functions as $function) {
         $tag = new MethodWIthRequestTag($function, ['Type']);
         $tags[] = $tag;
     }
     $docblock->setTags($tags);
     $exchangeWebServicesClass->getDocBlock()->setSourceDirty(true);
     $fileGen->setClass($exchangeWebServicesClass);
     $fileGen->write();
 }
开发者ID:garethp,项目名称:php-ews,代码行数:33,代码来源:ConvertToPHP.php

示例12: getClassTemplate

 /**
  * @return ClassGenerator
  */
 protected function getClassTemplate() : ClassGenerator
 {
     return FileGenerator::fromReflectedFileName(__DIR__ . DIRECTORY_SEPARATOR . "templates" . DIRECTORY_SEPARATOR . "shared_proxy.php")->getClass("SharedProxy");
 }
开发者ID:djmattyg007,项目名称:autocodeloader,代码行数:7,代码来源:SharedProxyGenerator.php

示例13: fileCreate

 public function fileCreate($filename, $classGenerator)
 {
     if (file_exists($this->getFilePath())) {
         $content = file_get_contents($this->getFilePath());
         //Get protected code
         $protectedPos = strpos($content, PROTECTED_ZONE);
         $protectedCode = '';
         if ($protectedPos !== false) {
             $protectedCode = explode(PROTECTED_ZONE, $content);
             $this->setProtectedCode($protectedCode[1]);
         }
         $generator = FileGenerator::fromReflectedFileName($this->getFilePath());
         $generator->setClass($classGenerator);
         $content = $generator->generate();
         // Insert the protected code into the new string
         $this->insertString($content, '}', $this->buildProtectedZone());
         //            print_r($content);exit;
     } else {
         $generator = new FileGenerator();
         $generator->setClass($classGenerator);
         $content = $generator->generate();
         $this->insertString($content, '}', $this->buildProtectedZone());
     }
     $this->filePutContents($filename, $content);
 }
开发者ID:jaguevara1978,项目名称:ZF2_REST_OAuth2_Postgres_Backend,代码行数:25,代码来源:BaseGenerator.php


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