=========================================
Parse error when using self as constant
=========================================

<?php
define('self', 'value');
var_dump(self);

---

(program
  (php_tag)
  (expression_statement
    (function_call_expression
      function: (name)
      arguments: (arguments
        (argument (string (string_content)))
        (argument (string (string_content))))))
  (expression_statement
    (function_call_expression
      function: (name)
      arguments: (arguments (argument (name))))))

=========================================
Incorrect precedence for error suppression operator
=========================================

<?php
@trigger_error("a") && trigger_error("b");

---

(program
  (php_tag)
  (expression_statement
    (binary_expression
      left: (error_suppression_expression
        (function_call_expression
          function: (name)
          arguments: (arguments
            (argument
              (encapsed_string
                (string_content))))))
      right: (function_call_expression
        function: (name)
        arguments: (arguments
          (argument
            (encapsed_string
              (string_content))))))))

=========================================
Error when using expressions as named argument
=========================================

<?php
foo(array: null);
foo(bool: null);
foo(callable: null);
foo(false: null);
foo(float: null);
foo(fn: null);
foo(function: null);
foo(int: null);
foo(iterable: null);
foo(match: null);
foo(mixed: null);
foo(namespace: null);
foo(null: null);
foo(numeric: null);
foo(object: null);
foo(parent: null);
foo(self: null);
foo(static: null);
foo(string: null);
foo(throw: null);
foo(true: null);
foo(void: null);

---

(program
  (php_tag)
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null)))))
    (expression_statement
      (function_call_expression
        function: (name)
        arguments: (arguments (argument name: (name) (null))))))

=========================================
Error when closing tag is in a string
=========================================

<?php
$foo = "?>";
$foo = <<<EOF
  ?>
  EOF;
$foo = <<<'EOF'
  ?>
  EOF;
$foo = '?>';

---

(program
  (php_tag)
    (expression_statement
      (assignment_expression
        left: (variable_name (name))
        right: (encapsed_string (string_content))))
    (expression_statement
      (assignment_expression
        left: (variable_name
          (name))
        right: (heredoc
          identifier: (heredoc_start)
          value: (heredoc_body
            (string_content))
          end_tag: (heredoc_end))))
    (expression_statement
      (assignment_expression
        left: (variable_name
          (name))
        right: (nowdoc
          identifier: (heredoc_start)
          value: (nowdoc_body
            (nowdoc_string))
          end_tag: (heredoc_end))))
    (expression_statement
      (assignment_expression
        left: (variable_name (name))
        right: (string (string_content)))))

=========================================
Error with comment inside binary expression
=========================================

<?php
if (
  true
  // this is a comment
  || false
) {}

---

(program
  (php_tag)
  (if_statement
    condition: (parenthesized_expression
      (binary_expression
        left: (boolean)
        (comment)
        right: (boolean)))
    body: (compound_statement)))

=========================================
Class constants can contain primitive types
=========================================

<?php

class Foo {
    public const STRING = 'foo';
}

---

(program
  (php_tag)
  (class_declaration
    (name)
    (declaration_list
      (const_declaration
        (visibility_modifier)
        (const_element
          (name)
          (string
            (string_content)))))))

=========================================
Match expression as cast and clone operand
=========================================

<?php

$a = (int)match($u) { 1 => 1, default => 2 };
$b = (string) match($u) { 1 => 'a', default => 'b' };
$c = clone match($u) { 1 => $x, default => $y };

---

(program
  (php_tag)
  (expression_statement
    (assignment_expression
      (variable_name
        (name))
      (cast_expression
        (cast_type)
        (match_expression
          (parenthesized_expression
            (variable_name
              (name)))
          (match_block
            (match_conditional_expression
              (match_condition_list
                (integer))
              (integer))
            (match_default_expression
              (integer)))))))
  (expression_statement
    (assignment_expression
      (variable_name
        (name))
      (cast_expression
        (cast_type)
        (match_expression
          (parenthesized_expression
            (variable_name
              (name)))
          (match_block
            (match_conditional_expression
              (match_condition_list
                (integer))
              (string
                (string_content)))
            (match_default_expression
              (string
                (string_content))))))))
  (expression_statement
    (assignment_expression
      (variable_name
        (name))
      (clone_expression
        (match_expression
          (parenthesized_expression
            (variable_name
              (name)))
          (match_block
            (match_conditional_expression
              (match_condition_list
                (integer))
              (variable_name
                (name)))
            (match_default_expression
              (variable_name
                (name)))))))))

=========================================
Reserved keywords as class constant names
=========================================

<?php

class Foo {
    const CALLABLE = 1;
    const NAMESPACE = 2;
    const VOID = 3;
    const FALSE = 4;
    const MIXED = 5;
    const TRUE = 6;
    const callable = 1, namespace = 2, void = 3, false = 4, mixed = 5, true = 6;
    public const string VOID = 'void';
}

interface Bar {
    const VOID = 'void';
}

trait Baz {
    const MIXED = 'mixed';
}

enum Qux {
    const TRUE = true;
}

---

(program
  (php_tag)
  (class_declaration
    name: (name)
    body: (declaration_list
      (const_declaration (const_element (name) (integer)))
      (const_declaration (const_element (name) (integer)))
      (const_declaration (const_element (name) (integer)))
      (const_declaration (const_element (name) (integer)))
      (const_declaration (const_element (name) (integer)))
      (const_declaration (const_element (name) (integer)))
      (const_declaration
        (const_element (name) (integer))
        (const_element (name) (integer))
        (const_element (name) (integer))
        (const_element (name) (integer))
        (const_element (name) (integer))
        (const_element (name) (integer)))
      (const_declaration
        (visibility_modifier)
        type: (primitive_type)
        (const_element (name) (string (string_content))))))
  (interface_declaration
    name: (name)
    body: (declaration_list
      (const_declaration (const_element (name) (string (string_content))))))
  (trait_declaration
    name: (name)
    body: (declaration_list
      (const_declaration (const_element (name) (string (string_content))))))
  (enum_declaration
    name: (name)
    body: (enum_declaration_list
      (const_declaration (const_element (name) (boolean))))))

=========================================
Type keywords as global constant names
=========================================

<?php

const VOID = 1, MIXED = 2, ITERABLE = 3;
const void = 1, mixed = 2, iterable = 3;
const bool = 1, float = 2, int = 3, object = 4, string = 5;

---

(program
  (php_tag)
  (const_declaration
    (const_element (name) (integer))
    (const_element (name) (integer))
    (const_element (name) (integer)))
  (const_declaration
    (const_element (name) (integer))
    (const_element (name) (integer))
    (const_element (name) (integer)))
  (const_declaration
    (const_element (name) (integer))
    (const_element (name) (integer))
    (const_element (name) (integer))
    (const_element (name) (integer))
    (const_element (name) (integer))))
