Skip to content

3.4.0 broke class constants defaults in methods parameters when using PHP 8.1+ #983

@kissifrot

Description

@kissifrot

Hello,

Looks like a45d437 broke default values using other other references in method parameters:
A class such as

// App\AnotherNamespace\DataType class
<?php
namespace App\AnotherNamespace;

class DataType {
const DAY = 'day';
}


// App\Entity\MyEntity class
<?php
namespace App\Entity;

use App\AnotherNamespace\DataType;
class MyEntity {
public function doSomething(string $dataType = DataType::DAY) {
// Do something
}

With 3.3.1:

// App\Entity\MyEntity class
<?php
class MyEntity extends \App\Entity\MyEntity implements \Doctrine\ORM\Proxy\Proxy
public function doSomething(string $dataType = 'day'): void {
}

With 3.4.0:

// App\Entity\MyEntity class
<?php
class MyEntity extends \App\Entity\MyEntity implements \Doctrine\ORM\Proxy\Proxy
public function doSomething(string $dataType = App\AnotherNamespace\DataType::DAY): void {
}

Which leads to a Class "App\AnotherNamespace\DataType" does not exist error, as namespace imports aren't used, or neither global namespace is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions