Skip to content

PHP 8.4: allow Traits & Class defining same (compatible) properties #17812

Open
@procodix

Description

@procodix

Description

This is considered an error now, but should be possible, the same way it works with methods, so that also the new property hooks would work.

trait TestTrait {
	public int $Var = 1;
	public function Func():int {return 1;}
}

class TestClass {
	use TestTrait;
	
	public int $Var = 2; // this is not allowed
	public function Func():int {return 2;} // this is ok
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions