enter example

namespace Symfony\Bridge\Twig\Tests\NodeVisitor;

use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Twig\NodeVisitor\Scope;

class ScopeTest extends TestCase
{
    public function testScopeInitiation()
    {
        $scope = new Scope();
        $scope->enter();
        $this->assertNull($scope->get('test'));
    }
}
private $name;
    private $type;
    private $starts = [];
    private $ends = [];
    private $profiles = [];

    public function __construct(string $template = 'main', string $type = self::ROOT, string $name = 'main')
    {
        $this->template = $template;
        $this->type = $type;
        $this->name = 0 === strpos($name, '__internal_') ? 'INTERNAL' : $name;
        $this->enter();
    }

    public function getTemplate(): string
    {
        return $this->template;
    }

    public function getType(): string
    {
        return $this->type;
    }

    
$this->stopwatch = $stopwatch;
        $this->events = new \SplObjectStorage();
    }

    public function enter(Profile $profile): void
    {
        if ($this->stopwatch && $profile->isTemplate()) {
            $this->events[$profile] = $this->stopwatch->start($profile->getName(), 'template');
        }

        parent::enter($profile);
    }

    public function leave(Profile $profile): void
    {
        parent::leave($profile);

        if ($this->stopwatch && $profile->isTemplate()) {
            $this->events[$profile]->stop();
            unset($this->events[$profile]);
        }
    }
}


        if (!$approvedTransitions) {
            throw new NotEnabledTransitionException($subject$transitionName$this$bestTransitionBlockerList$context);
        }

        foreach ($approvedTransitions as $transition) {
            $this->leave($subject$transition$marking$context);

            $context = $this->transition($subject$transition$marking$context);

            $this->enter($subject$transition$marking$context);

            $this->markingStore->setMarking($subject$marking$context);

            $this->entered($subject$transition$marking$context);

            $this->completed($subject$transition$marking$context);

            $this->announce($subject$transition$marking$context);
        }

        $marking->setContext($context);

        

    private Scope $scope;

    public function __construct()
    {
        $this->scope = new Scope();
    }

    protected function doEnterNode(Node $node, Environment $env): Node
    {
        if ($node instanceof BlockNode || $node instanceof ModuleNode) {
            $this->scope = $this->scope->enter();
        }

        if ($node instanceof TransDefaultDomainNode) {
            if ($node->getNode('expr') instanceof ConstantExpression) {
                $this->scope->set('domain', $node->getNode('expr'));

                return $node;
            } else {
                $var = $this->getVarName();
                $name = new AssignNameExpression($var$node->getTemplateLine());
                $this->scope->set('domain', new NameExpression($var$node->getTemplateLine()));

                
Home | Imprint | This part of the site doesn't use cookies.