-
Notifications
You must be signed in to change notification settings - Fork 59
Incorrect type handling of 'self' in 'traits' #1201
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
<?php
trait TrainA {
private ?string $name = null;
public function name(string $name): self {
$this->name = $name;
return $this;
}
}
class ClassA {
use TrainA;
private ?string $description = null;
public function description(string $description): self {
$this->description = $description;
return $this;
}
public function __toString(): string {
return "name: " . $this->name . PHP_EOL .
"description: " . $this->description . PHP_EOL;
}
}
function main() {
$a = (new ClassA())
->name("name")
->description("description");
echo $a;
}
main();Actual Behavior:
<critical> ERROR undefinedMethod: Call to undefined method {\TrainA}->description() at index.php:33
->description("description");
^^^^^^^^^^^
Expected Behavior:
No error
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working