Skip to content

ReflectionUnionType in PHP 8 #247

@kozaktomas

Description

@kozaktomas

Version: nette/di master, PHP 8

Bug Description

There is an issue with ReflectionUnionType in PHP 8. When a function uses union type for return && the function is used in config file => it doesn't work as expected because nette counts with ReflectionNamedType, but ReflectionUnionType is returned. Unfortunately ReflectionUnionType doesn't have getName() method

See screenshot with error and call stack:

image

Steps To Reproduce

Just create simple TestClass and put these lines to neon config

parameters:
    test: ::getenv("TEST") # reflection for getenv returns ReflectionUnionType

services:
	router: App\Router\RouterFactory::createRouter
	- App\Model\TestClass(%test%)

Possible Solution

  1. Check for reflection type. BC break? ¯_(ツ)_/¯
  2. Maybe it's PHP bug. But I couldn't find any bug report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions