本文整理汇总了PHP中PHPSA\Context::getEventManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getEventManager方法的具体用法?PHP Context::getEventManager怎么用?PHP Context::getEventManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPSA\Context
的用法示例。
在下文中一共展示了Context::getEventManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->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;
}
示例2: compile
/**
* @param Context $context
* @return boolean|null
*/
public function compile(Context $context)
{
$context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($this->statement, $context));
$this->compiled = true;
$context->scopePointer = $this->getPointer();
/**
* It's not needed to compile empty method via it's abstract
*/
if ($this->isAbstract()) {
/** @var ClassDefinition $scope */
$scope = $context->scope;
if (!$scope->isAbstract()) {
$context->notice('not-abstract-class-with-abstract-method', 'Class must be abstract', $this->statement);
}
return true;
}
if ($this->statement->params) {
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);
}
}
示例3: __construct
/**
* @param Node\Stmt $stmt
* @param Context $context
*/
public function __construct(Node\Stmt $stmt, Context $context)
{
try {
$context->getEventManager()->fire(Event\StatementBeforeCompile::EVENT_NAME, new Event\StatementBeforeCompile($stmt, $context));
if ($stmt instanceof Stmt\Goto_ || $stmt instanceof Stmt\Label || $stmt instanceof Stmt\InlineHTML || $stmt instanceof Stmt\Nop) {
return;
}
$compiler = $this->factory($stmt);
} catch (\Exception $e) {
$context->debug('StatementCompiler is not implemented for ' . get_class($stmt));
return;
}
$compiler->pass($stmt, $context);
}
示例4: 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;
}
示例5: 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;
}