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


PHP Context::setFilepath方法代码示例

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


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

示例1: compile

 /**
  * Compile function to check it
  *
  * @param Context $context
  * @return bool
  */
 public function compile(Context $context)
 {
     if ($this->compiled) {
         return true;
     }
     $context->setFilepath($this->filepath);
     $this->compiled = true;
     $context->clearSymbols();
     $context->scopePointer = $this->getPointer();
     $context->setScope(null);
     if (count($this->statement->stmts) == 0) {
         return $context->notice('not-implemented-function', sprintf('Closure %s() is not implemented', $this->name), $this->statement);
     }
     if (count($this->statement->params) > 0) {
         /** @var  Node\Param $parameter */
         foreach ($this->statement->params as $parameter) {
             $type = CompiledExpression::UNKNOWN;
             if ($parameter->type) {
                 if (is_string($parameter->type)) {
                     $type = Types::getType($parameter->type);
                 } elseif ($parameter->type instanceof Node\Name) {
                     $type = CompiledExpression::OBJECT;
                 }
             }
             $context->addVariable(new Parameter($parameter->name, null, $type, $parameter->byRef));
         }
     }
     foreach ($this->statement->stmts as $st) {
         \PHPSA\nodeVisitorFactory($st, $context);
     }
     return true;
 }
开发者ID:ovr,项目名称:phpsa,代码行数:38,代码来源:ClosureDefinition.php

示例2: compile

 /**
  * Compile function to check it
  *
  * @param Context $context
  * @return bool
  */
 public function compile(Context $context)
 {
     if ($this->compiled) {
         return true;
     }
     $context->setFilepath($this->filepath);
     $this->compiled = true;
     $context->scopePointer = $this->getPointer();
     $context->setScope(null);
     $context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($this->statement, $context));
     if (count($this->statement->params) > 0) {
         /** @var  Node\Param $parameter */
         foreach ($this->statement->params as $parameter) {
             $type = CompiledExpression::UNKNOWN;
             if ($parameter->type) {
                 if (is_string($parameter->type)) {
                     $type = Types::getType($parameter->type);
                 } elseif ($parameter->type instanceof Node\Name) {
                     $type = CompiledExpression::OBJECT;
                 }
             }
             $context->addVariable(new Parameter($parameter->name, null, $type, $parameter->byRef));
         }
     }
     foreach ($this->statement->stmts as $st) {
         \PHPSA\nodeVisitorFactory($st, $context);
     }
     return true;
 }
开发者ID:ovr,项目名称:phpsa,代码行数:35,代码来源:FunctionDefinition.php

示例3: parserFile

 /**
  * @param string $filepath
  * @param Context $context
  * @throws RuntimeException when filepath is not readable
  */
 public function parserFile($filepath, Context $context)
 {
     $context->setFilepath($filepath);
     try {
         if (!is_readable($filepath)) {
             throw new RuntimeException('File ' . $filepath . ' is not readable');
         }
         $context->debug('<comment>Precompile: ' . $filepath . '.</comment>');
         $code = file_get_contents($filepath);
         $astTree = $this->parser->parse($code);
         $this->nodeTraverser->traverse($astTree);
         $context->aliasManager = new AliasManager();
         $namespace = null;
         /**
          * Step 1 Precompile
          */
         foreach ($astTree as $topStatement) {
             if ($topStatement instanceof Node\Stmt\Namespace_) {
                 /**
                  * Namespace block can be created without NS name
                  */
                 if ($topStatement->name) {
                     $namespace = $topStatement->name->toString();
                     $context->aliasManager->setNamespace($namespace);
                 }
                 if ($topStatement->stmts) {
                     $this->parseTopDefinitions($topStatement->stmts, $context->aliasManager, $filepath);
                 }
             } else {
                 if (is_array($topStatement)) {
                     $this->parseTopDefinitions($topStatement, $context->aliasManager, $filepath);
                 } else {
                     $this->parseTopDefinitions($astTree, $context->aliasManager, $filepath);
                 }
             }
         }
         $context->clear();
     } catch (\PhpParser\Error $e) {
         $context->syntaxError($e, $filepath);
     } catch (Exception $e) {
         $context->output->writeln("<error>{$e->getMessage()}</error>");
     }
 }
开发者ID:ovr,项目名称:phpsa,代码行数:48,代码来源:FileParser.php

示例4: compile

 /**
  * Compile function to check it
  *
  * @param Context $context
  * @return bool
  */
 public function compile(Context $context)
 {
     $context->setFilepath($this->filepath);
     $this->compiled = true;
     $context->scopePointer = $this->getPointer();
     $context->setScope(null);
     if (count($this->statement->stmts) == 0) {
         return $context->notice('not-implemented-function', sprintf('Function %s() is not implemented', $this->name), $this->statement);
     }
     if (count($this->statement->params) > 0) {
         /** @var  Node\Param $parameter */
         foreach ($this->statement->params as $parameter) {
             $context->addSymbol($parameter->name);
         }
     }
     foreach ($this->statement->stmts as $st) {
         \PHPSA\nodeVisitorFactory($st, $context);
     }
     return true;
 }
开发者ID:sekjun9878,项目名称:phpsa,代码行数:26,代码来源:FunctionDefinition.php

示例5: compile

 /**
  * Compile the definition
  *
  * @param Context $context
  * @return boolean
  */
 public function compile(Context $context)
 {
     $context->setFilepath($this->filepath);
     $context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($this->statement, $context));
     return true;
 }
开发者ID:ovr,项目名称:phpsa,代码行数:12,代码来源:TraitDefinition.php

示例6: compile

 /**
  * @param Context $context
  * @return $this
  */
 public function compile(Context $context)
 {
     $context->setFilepath($this->filepath);
     $context->setScope($this);
     foreach ($this->methods as $method) {
         $context->clearSymbols();
         if (!$method->isStatic()) {
             $thisPtr = new Variable('this', $this, CompiledExpression::OBJECT);
             $thisPtr->incGets();
             $context->addVariable($thisPtr);
         }
         $method->compile($context);
         $symbols = $context->getSymbols();
         if (count($symbols) > 0) {
             foreach ($symbols as $name => $variable) {
                 if ($variable->isUnused()) {
                     $context->warning('unused-' . $variable->getSymbolType(), sprintf('Unused ' . $variable->getSymbolType() . ' $%s in method %s()', $variable->getName(), $method->getName()));
                 }
             }
         }
     }
     return $this;
 }
开发者ID:sekjun9878,项目名称:phpsa,代码行数:27,代码来源:ClassDefinition.php

示例7: parserFile

 /**
  * @param string $filepath
  * @param Parser $parser
  * @param Context $context
  */
 protected function parserFile($filepath, Parser $parser, Context $context)
 {
     $context->setFilepath($filepath);
     $astTraverser = new \PhpParser\NodeTraverser();
     $astTraverser->addVisitor(new \PhpParser\NodeVisitor\NameResolver());
     try {
         if (!is_readable($filepath)) {
             throw new RuntimeException('File ' . $filepath . ' is not readable');
         }
         $context->debug('<comment>Precompile: ' . $filepath . '.</comment>');
         $code = file_get_contents($filepath);
         $astTree = $parser->parse($code);
         $astTraverser->traverse($astTree);
         $aliasManager = new AliasManager();
         $namespace = null;
         /**
          * Step 1 Precompile
          */
         foreach ($astTree as $topStatement) {
             if ($topStatement instanceof Node\Stmt\Namespace_) {
                 /**
                  * Namespace block can be created without NS name
                  */
                 if ($topStatement->name) {
                     $namespace = $topStatement->name->toString();
                     $aliasManager->setNamespace($namespace);
                 }
                 if ($topStatement->stmts) {
                     $this->parseTopDefinitions($topStatement->stmts, $aliasManager, $filepath);
                 }
             } else {
                 $this->parseTopDefinitions($topStatement, $aliasManager, $filepath);
             }
         }
         /**
          * Another Traverser to handler Analyzer Passe(s)
          */
         $analyzeTraverser = new AstTraverser([new \PHPSA\Node\Visitor\FunctionCall()], $context);
         $analyzeTraverser->traverse($astTree);
         $context->clear();
     } catch (\PhpParser\Error $e) {
         $context->sytaxError($e, $filepath);
     } catch (Exception $e) {
         $context->output->writeln("<error>{$e->getMessage()}</error>");
     }
 }
开发者ID:sekjun9878,项目名称:phpsa,代码行数:51,代码来源:CheckCommand.php

示例8: compile

 /**
  * @param Context $context
  * @return $this
  */
 public function compile(Context $context)
 {
     if ($this->compiled) {
         return true;
     }
     $this->compiled = true;
     $context->setFilepath($this->filepath);
     $context->setScope($this);
     $context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($this->statement, $context));
     // Compile event for properties
     foreach ($this->properties as $property) {
         if (!$property->default) {
             continue;
         }
         // fire expression event for property default
         $context->getEventManager()->fire(Event\ExpressionBeforeCompile::EVENT_NAME, new Event\ExpressionBeforeCompile($property->default, $context));
     }
     // Compile event for PropertyProperty
     foreach ($this->properties as $property) {
         $context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($property, $context));
     }
     // Compile event for constants
     foreach ($this->constants as $const) {
         $context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($const, $context));
     }
     // Compiler event for property statements
     foreach ($this->propertyStatements as $prop) {
         $context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($prop, $context));
     }
     // Compile each method
     foreach ($this->methods as $method) {
         $context->clearSymbols();
         if (!$method->isStatic()) {
             $thisPtr = new Variable('this', $this, CompiledExpression::OBJECT);
             $thisPtr->incGets();
             $context->addVariable($thisPtr);
         }
         $method->compile($context);
         $symbols = $context->getSymbols();
         if (count($symbols) > 0) {
             foreach ($symbols as $name => $variable) {
                 if ($variable->isUnused()) {
                     $context->warning('unused-' . $variable->getSymbolType(), sprintf('Unused ' . $variable->getSymbolType() . ' $%s in method %s()', $variable->getName(), $method->getName()));
                 }
             }
         }
     }
     return $this;
 }
开发者ID:ovr,项目名称:phpsa,代码行数:53,代码来源:ClassDefinition.php


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