incGets() public method

Increases the read counter.
public incGets ( ) : integer
return integer
Exemplo n.º 1
0
 public function testIncGets()
 {
     $variable = new Variable('a', null, CompiledExpression::UNKNOWN);
     static::assertSame(0, $variable->getGets());
     $variable->incGets();
     static::assertSame(1, $variable->getGets());
     $variable->incGets();
     static::assertSame(2, $variable->getGets());
     $variable->incGets();
     $variable->incGets();
     static::assertSame(4, $variable->getGets());
 }
Exemplo n.º 2
0
 /**
  * Compile methods to check it
  *
  * @param Context $context
  */
 public function compile(Context $context)
 {
     $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', sprintf('Unused variable $%s in method %s()', $variable->getName(), $method->getName()));
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * @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;
 }