Validate use of list assignment.

@throws ParseErrorException if the user used empty with anything but a variable

@param Node $node
353403
public function enterNode(Node $node)
    {
        if (!$node instanceof Assign) {
            return;
        }

        if (!$node->var instanceof Array_ && !$node->var instanceof List_) {
            return;
        }

        if (!$this->atLeastPhp71 && $node->var instanceof Array_) {
            $msg = "syntax error, unexpected '='";
            throw new ParseErrorException($msg, $node->expr->getLine());
        }

        // Polyfill for PHP-Parser 2.x
        $items = isset($node->var->items) ? $node->var->items : $node->var->vars;

        if ($items === [] || $items === [null]) {
            throw new ParseErrorException('Cannot use empty list', $node->var->getLine());
        }

        $itemFound = false;
        foreach ($items as $item) {
            if ($item === null) {
                continue;
            }

            $itemFound = true;

            // List_->$vars in PHP-Parser 2.x is Variable instead of ArrayItem.
            if (!$this->atLeastPhp71 && $item instanceof ArrayItem && $item->key !== null) {
                $msg = 'Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting \',\' or \')\'';
                throw new ParseErrorException($msg, $item->key->getLine());
            }

            if (!self::isValidArrayItem($item)) {
                $msg = 'Assignments can only happen to writable values';
                throw new ParseErrorException($msg, $item->getLine());
            }
        }

        if (!$itemFound) {
            throw new ParseErrorException('Cannot use empty list');
        }
    }
952052
public function removeNode(Node $node)
    {
        $node->setNavigation(null);
        $this->nodes->removeElement($node);
    }
1242269
final public function beforePutItem(array &$item, Node $node): void
    {
        $this->loadIndexes();
        $this->addShardAttributes($item, $node);
        if ($node instanceof Indexed) {
            $item[NodeTable::INDEXED_KEY_NAME] = ['BOOL' => true];
        }

        foreach ($this->gsi as $gsi) {
            $gsi->beforePutItem($item, $node);
        }

        $this->doBeforePutItem($item, $node);
    }
1004170
private function deleteNode( $node ) {
		$this->deleteChildren( $node );
		$parent = $node->parentNode;
		$oldnode = $parent->removeChild( $node );
	}
383423
public function preParseUses(array $nodes, PhpFileModelInterface $parent): void
    {
        foreach ($nodes as $node) {
            if ($node instanceof Use_) {
                $this->useNodeParser->invoke($node, $parent);
            } else {
                if ($node instanceof GroupUse) {
                    $this->groupUseNodeParser->invoke($node, $parent);
                }
            }
        }
    }
763281
public function parse($node, $command)
    {
        if ($node->command() === '+') {
            $topic = synapse()->memory->shortTerm()->get('topic') ?: 'random';
            $topic = synapse()->brain->topic($topic);
            $type  = $this->determineTriggerType($node->value());

            $data = [
                'type'      => $type,
                'responses' => [],
            ];

            $topic->triggers->put($node->value(), $data);

            $topic->triggers = $this->sortTriggers($topic->triggers);

            synapse()->memory->shortTerm()->put('trigger', $node->value());
        }
    }
114949
private function nodeRequiredIfEnabled($node)
    {
        return function ($value) use ($node) {
            if (!$value['enabled']) {
                return false;
            }

            if (isset($value[$node]) && !empty($value[$node])) {
                return false;
            }

            return true;
        };
    }
551360
protected function checkContext(DOMNode $node)
	{
		// Test whether we know in what context this node is used. An <xsl:for-each/> ancestor would // change this node's context
		$xpath     = new DOMXPath($node->ownerDocument);
		$ancestors = $xpath->query('ancestor::xsl:for-each', $node);

		if ($ancestors->length)
		{
			throw new UnsafeTemplateException("Cannot assess context due to '" . $ancestors->item(0)->nodeName . "'", $node);
		}
	}
1115228
protected function removeSpaceAfter(Node $node) {
    $next = $node->nextToken();
    if ($next instanceof WhitespaceNode) {
      $next->remove();
    }
  }
1254794
public static function removeNonPkValues(Node $node) {
    $mapper = $node->getMapper();
    $pkValues = $mapper->getPkNames();
    $valueNames = $node->getValueNames();
    foreach($valueNames as $name) {
      if (!in_array($name, $pkValues)) {
        $node->removeValue($name);
      }
    }
  }
779287
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Expr || ! $parent instanceof VariableLikeInterface) {
            throw new Exception('ValueNodeParser is made to parse a expression node');
        }
    }
380234
public function leaveNode(Node $node)
    {
        if ($node instanceof ClassMethod && $node->name === $this->nodeName) {
            // Build arguments.
            $args = [];
            foreach ($this->args as $arg) {
                $args[] = new Arg(
                    is_string($arg)
                        ? new String_($arg)
                        : (is_float($arg)
                            ? new DNumber($arg)
                            : new LNumber($arg)
                        ) 
                );
            }
            // ADD comment
            $nop = new Nop;
            $nop->setAttribute('comments', [
                new Comment(sprintf('// Ayuco: addition %s', date('Y-m-d h:i a')))
            ]);
            $node->stmts[] = $nop;
            // ADD statement
            $node->stmts[] = new MethodCall(
                empty($this->variable) ? null : new Variable($this->variable),
                $this->methodName,
                $args
            );
        }
    }
1252408
public function enterNode(Node $node)
    {
        if (!$node instanceof FuncCall && !$node instanceof MethodCall && !$node instanceof StaticCall) {
            return;
        }

        foreach ($node->args as $arg) {
            if ($arg->byRef) {
                throw new FatalErrorException(self::EXCEPTION_MESSAGE, 0, E_ERROR, null, $node->getLine());
            }
        }
    }
849716
public function enterNode(PhpParser\Node $node)
    {
        if ($node instanceof PhpParser\Node\Expr\Assign) {
            $left_var_id = ExpressionAnalyzer::getRootVarId($node->var, $this->this_class_name);
            $right_var_id = ExpressionAnalyzer::getRootVarId($node->expr, $this->this_class_name);

            if ($left_var_id) {
                $this->assignment_map[$left_var_id][$right_var_id ?: 'isset'] = true;
            }

            return PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN;
        } elseif ($node instanceof PhpParser\Node\Expr\PostInc
            || $node instanceof PhpParser\Node\Expr\PostDec
            || $node instanceof PhpParser\Node\Expr\PreInc
            || $node instanceof PhpParser\Node\Expr\PreDec
            || $node instanceof PhpParser\Node\Expr\AssignOp
        ) {
            $var_id = ExpressionAnalyzer::getRootVarId($node->var, $this->this_class_name);

            if ($var_id) {
                $this->assignment_map[$var_id][$var_id] = true;
            }

            return PhpParser\NodeTraverser::DONT_TRAVERSE_CHILDREN;
        } elseif ($node instanceof PhpParser\Node\Expr\FuncCall) {
            foreach ($node->args as $arg) {
                $arg_var_id = ExpressionAnalyzer::getRootVarId($arg->value, $this->this_class_name);

                if ($arg_var_id) {
                    $this->assignment_map[$arg_var_id][$arg_var_id] = true;
                }
            }
        } elseif ($node instanceof PhpParser\Node\Stmt\Unset_) {
            foreach ($node->vars as $arg) {
                $arg_var_id = ExpressionAnalyzer::getRootVarId($arg, $this->this_class_name);

                if ($arg_var_id) {
                    $this->assignment_map[$arg_var_id][$arg_var_id] = true;
                }
            }
        }

        return null;
    }
232586
protected function addNodeToResponse(Node $node) {
    $response = $this->getResponse();
    if (!$response->hasValue('list')) {
      $objects = [];
      $response->setValue('list', $objects);
    }

    $objects = $response->getValue('list');
    $objects[] = $node;
    $response->setValue('list', $objects);
  }
977125
public function enterNode(Node $node)
    {
        if ($node instanceof DeclareDeclare && ($node->getLine() === 1 || $node->getLine() === 2)) {
            throw new StrictTypesException();
        }
    }
1364921
protected function assertIsNodeSupported(Node $node): void
    {
        if (!$this->isNodeSupported($node)) {
            $class = ClassUtils::getShortName(static::class);
            throw new InvalidArgumentException(
                "Node [{$node::schema()->getCurie()}] not supported by [{$class}]."
            );
        }
    }