[PHP-DEV] Pre RFC - Additions to the randomizer

2022-10-05 Thread Joshua Rüsweg via internals
Hi I would like to introduce a new method for the new Randomizer class [1]. I would like to have a function that generates a random string for me based on a given alphabet. This function is useful as a building block, as many use cases require generating random strings with a specified list o

Re: [PHP-DEV] Sanitize filters

2022-10-05 Thread David Gebler
On Tue, Oct 4, 2022 at 11:34 AM Rowan Tommins wrote: > The "notorious" thing I know is that validating e-mail addresses is next > to impossible because of multiple overlapping standards, and a huge > number of esoteric variations that might or might not actually be > deliverable in practice. If y

Re: [PHP-DEV] Union type casts

2022-10-05 Thread Rowan Tommins
On 5 October 2022 14:42:57 BST, juan carlos morales wrote: >Are you facing a situation where manual union type cast is needed? I can't think of any examples for full union types off the top of my head, but nullable casts would frequently be useful, e.g. when you have a value that is either a n

Re: [PHP-DEV] Union type casts

2022-10-05 Thread Claude Pache
> Le 5 oct. 2022 à 19:53, Eugene Sidelnyk a écrit : > > I used to have an awkward feeling when it was necessary to convert the > nullable integer into a nullable string. It would be kind of ternary operator > anyway. Either `$b = (null !== $a) ? (string)$a : null;` or `$b = (string)$a > ?: nu

Re: [PHP-DEV] Union type casts

2022-10-05 Thread Marco Pivetta
On Wed, 5 Oct 2022 at 19:53, Eugene Sidelnyk wrote: > I used to have an awkward feeling when it was necessary to convert the > nullable integer into a nullable string. It would be kind of ternary > operator anyway. Either `$b = (null !== $a) ? (string)$a : null;` or `$b = > (string)$a ?: null;`.

Re: [PHP-DEV] Union type casts

2022-10-05 Thread Eugene Sidelnyk
I used to have an awkward feeling when it was necessary to convert the nullable integer into a nullable string. It would be kind of ternary operator anyway. Either `$b = (null !== $a) ? (string)$a : null;` or `$b = (string)$a ?: null;`. A lot easier to read would it be if written this way: `$b = (

Re: [PHP-DEV] Experimental features

2022-10-05 Thread Rowan Tommins
On Wed, 5 Oct 2022 at 18:07, David Rodrigues wrote: > Another advantage in this sense is that it would be possible to have a > single development branch for PHP 8.1 (current version) and 8.2 > (development version), for example, with the difference of some definitions > in the code that activate

Re: [PHP-DEV] Experimental features

2022-10-05 Thread David Rodrigues
Thank you all for participating in this discussion! Regarding the experimental features "disappearing" in a release, therefore, its use is not reliable, in reality the idea is that this is the exception of the exception (when, for example, the feature itself proves to be extremely unfeasible for p

Re: [PHP-DEV] Experimental features

2022-10-05 Thread Christian Schneider
Am 05.10.2022 um 15:38 schrieb Alex Wells : > Advantages of experimental features over extensions: > - they allow changes to the parser > - they are universally supported (by IDE's, parsers etc) because they are > part of a stable language release, not an unpopular/unknown extension > - usages of t

Re: [PHP-DEV] Union type casts

2022-10-05 Thread juan carlos morales
There is a difference is declaring a function parameter of different types ... because before hand, when the code calls the function, we might not be sure about what kind if data the function will receive, so the function could expect different types, and work the parameter correctly internally

Re: [PHP-DEV] Experimental features

2022-10-05 Thread Alex Wells
Hey. Experimental features have been briefly discussed before in https://github.com/PHPGenerics/php-generics-rfc/issues/49. I believe this is a good starting point to understand how it's different to extensions or otherwise different builds of PHP. Advantages of experimental features over extensi

Re: [PHP-DEV] Experimental features

2022-10-05 Thread Flávio Heleno
On Wed, Oct 5, 2022 at 8:16 AM Deleu wrote: > On Wed, Oct 5, 2022, 7:54 AM juan carlos morales < > dev.juan.mora...@gmail.com> > wrote: > > > > > Apply a PECL strategy to try experimental features might not be the > > convenient way always, for example, if we create a new ... sensitive > > ... in

Re: [PHP-DEV] Experimental features

2022-10-05 Thread Deleu
On Wed, Oct 5, 2022, 7:54 AM juan carlos morales wrote: > > Apply a PECL strategy to try experimental features might not be the > convenient way always, for example, if we create a new ... sensitive > ... ini setting that affects the behavior of PHP somehow, then ... > maybe applying the PECL str

Re: [PHP-DEV] Experimental features

2022-10-05 Thread juan carlos morales
My small contribution to this First of all, nice you picked "json_validate()" for your example, thanks for this, somehow, support! :) Second... Apply a PECL strategy to try experimental features might not be the convenient way always, for example, if we create a new ... sensitive ... ini se

Re: [PHP-DEV] Union type casts

2022-10-05 Thread Claude Pache
> Le 5 oct. 2022 à 06:46, Eugene Sidelnyk a écrit : > > I assume the behavior should be the same as if we called the function > having respective parameter type-hint (with a remark that strict types are > disabled): Hi, Function parameters are more restrictive than explicit cast in what it ac