Re: [PHP-DEV] Static (factory) methods in attributes and initializers

2021-10-04 Thread Nikita Popov
On Mon, Sep 27, 2021 at 5:58 PM Andreas Hennings wrote: > Hello list, > > currently, the default mode for attributes is to create a new class. > For general initializers, with > https://wiki.php.net/rfc/new_in_initializers we get the option to call > 'new C()' for parameter default values, attrib

Re: [PHP-DEV] Static (factory) methods in attributes and initializers

2021-09-27 Thread Andreas Hennings
Hello Levi, I thought it was clear. By static "factory" method I just mean any static method that returns an object. Don't interpret too much into the term :) So to clarify, here is an example: class OtherAttribute {} class MyAttribute { public function __construct(string $name) {..} #[Attr

Re: [PHP-DEV] Static (factory) methods in attributes and initializers

2021-09-27 Thread Levi Morrison via internals
I'm not exactly sure what you are proposing. However, it's always worth noting other languages which have something in the feature space, and Dart has both named constructors and factory constructors. You should start with researching what they do, and what other languages may have the same as _lan

[PHP-DEV] Static (factory) methods in attributes and initializers

2021-09-27 Thread Andreas Hennings
Hello list, currently, the default mode for attributes is to create a new class. For general initializers, with https://wiki.php.net/rfc/new_in_initializers we get the option to call 'new C()' for parameter default values, attribute arguments, etc. Personally I find class construction to be limit