[PHP-DEV] Re: RFC Concept: "Import" of simplied string manipulation and other instructions from ASP Classic

2021-09-27 Thread Daniele B via internals
Hello again, Further than going to the PHP School of Rowan, I'm truly interested to know - talking about PHP as software project - if appending these kind of simplification process to the project - on basic string manipulation and data&time instructions - is something that find any support from

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

Re: [PHP-DEV] Allowing `(object)['key' => 'value']` in initializers?

2021-09-27 Thread Lynn
On Mon, Sep 27, 2021 at 3:15 PM Sara Golemon wrote: > I think for consistency's sake, we'd want to provide a base constructor to > stdClass to take an associative array that maps into dynamic properties, > e.g. > > class stdClass { > public function __construct(array $props) { > foreach ($p

Re: [PHP-DEV] Allowing `(object)['key' => 'value']` in initializers?

2021-09-27 Thread Sara Golemon
On Sat, Sep 25, 2021 at 10:45 AM tyson andre wrote: > In PHP 8.1, it is possible to allow constructing any class name in an > initializer, after the approval of > https://wiki.php.net/rfc/new_in_initializers > > ``` > php > static $x1 = new ArrayObject(['key' => 'value']); > php > static $x2 = ne

Re: [PHP-DEV] Proposal: Shorthand initialization and destructuring of associative arrays

2021-09-27 Thread Lynn
On Mon, Sep 27, 2021 at 11:27 AM Konrad Baumgart wrote: > I was recently developing with js/ts and I liked the ease of returning > multiple items from a function as an object, while still preserving > their name. > I recently encountered this as well in Typescript. I believe the syntax is someth

[PHP-DEV] Proposal: Shorthand initialization and destructuring of associative arrays

2021-09-27 Thread Konrad Baumgart
Hi everyone, I'd like to propose 2 syntactic sugars: $array = [ => $data]; // the same as $array = ['data' => $data] and [ => $data] = $array; // the same as ['data' => $data] = $array My biggest use-case for this would be conveniently returning multiple things from a function, like: function ge