Declare Only in Constructors:
Constructor Property Promotion only works within the constructor. You cannot use this syntax outside the constructor method.
No Duplicates Allowed:
Each property can only be promoted once within a class. Multiple attempts to promote the same property more than once will result in an error.
Untyped Properties Are Allowed:
Unlike traditional property declarations, Constructor Property Promotion allows you to omit the type of declaration, creating untyped properties. While this provides flexibility, it may lead to potential issues if types are not explicitly specified.
New Class Declaration Not Allowed as Property Value:
Constructor Property Promotion does not support initializing properties with new class instances directly in the constructor parameters.
Promoted and Normal Properties Not Allowed Together:
You cannot mix Constructor Property Promotion with traditional property declarations within the same class.
Var Is Not Supported:
The var keyword is not supported in Constructor Property Promotion. It would help to use public, protected, or private for visibility.
Access Promoted Properties from the Constructor Body:
You cannot directly access promoted properties from the constructor body. They should be accessed through $this.
Doc Comments on Promoted Properties:
Doc comments for properties must be placed on the property declaration line. They cannot be added within the constructor parameters.
Uses in Traits:
Constructor Property Promotion can be used in traits, but the traits should be aware of the abovementioned limitations.