=========================
Type names
=========================

<?php
function a(): A {}
function b(): A\B {}

---

(program
  (php_tag)
  (function_definition
    (name) (formal_parameters)
    (union_type (named_type (name)))
    (compound_statement))
  (function_definition
    (name) (formal_parameters)
    (union_type
      (named_type (qualified_name (namespace_name_as_prefix (namespace_name (name))) (name)))
    )
    (compound_statement)))

=========================
Primitive types
=========================

<?php
function a(): int {}
function b(): callable {}
function c(): iterable {}

---

(program
  (php_tag)
  (function_definition
    (name) (formal_parameters)
    (union_type (primitive_type))
    (compound_statement))
  (function_definition
    (name) (formal_parameters)
    (union_type (primitive_type))
    (compound_statement))
  (function_definition
    (name) (formal_parameters)
    (union_type (primitive_type))
    (compound_statement)))

=======================
Optional types
=======================

<?php

function a(): ?array {}
function b(): ?Something {}

---

(program
  (php_tag)
  (function_definition
    (name) (formal_parameters)
    (union_type
      (optional_type (primitive_type))
    )
    (compound_statement))
  (function_definition
    (name) (formal_parameters)
    (union_type
      (optional_type (named_type (name)))
    )
    (compound_statement)))


==========================
Union types
==========================

<?php

function a(int|string|null $var) : ?int|MyClass {}

---

(program
  (php_tag)
  (function_definition
    name: (name)
    parameters: (formal_parameters
      (simple_parameter
        type: (union_type
          (primitive_type)
          (primitive_type)
          (primitive_type)
        )
        name: (variable_name (name))
      )
    )
    return_type: (union_type
      (optional_type
        (primitive_type)
      )
      (named_type (name))
    )
    body: (compound_statement)
  )
)

==========================
Mixed type
==========================

<?php

function a(mixed|string $var) : mixed {

}
---

(program
  (php_tag)
  (function_definition
    (name)
    (formal_parameters
      (simple_parameter
        (union_type
          (primitive_type)
          (primitive_type)
        )
        (variable_name (name))
      )
    )
    (union_type (primitive_type))
    (compound_statement)
  )
)

==========================
Static type
==========================

<?php

function a(string $var) : static {

}
---

(program
  (php_tag)
  (function_definition
    (name)
    (formal_parameters
      (simple_parameter
        (union_type
          (primitive_type)
        )
        (variable_name (name))
      )
    )
    (union_type (primitive_type))
    (compound_statement)
  )
)