[PHP-DEV] [RFC] Nullable Casting

2019-04-06 Thread Guilliam Xavier
ubsections (hopefully "None" to all) as well as a review of the proposed implementation: https://github.com/php/php-src/pull/3764 Thank you, -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Wiki RFC karma request

2019-03-11 Thread Guilliam Xavier
On Mon, Mar 11, 2019 at 11:47 AM Nikita Popov wrote: > > Hi, > > I've granted you rfc karma on the wiki. Please check if it works. Yes, now I can edit pages under /rfc, thank you :) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Wiki RFC karma request

2019-03-10 Thread Guilliam Xavier
Hello, I'd like to do some work on the Nullable Casting RFC (encouraged by its author). Could someone grant the wiki user guilliamxavier the necessary karma? Thanks in advance. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-11 Thread Guilliam Xavier
r bugs to fix), and people seem to expect different things from a new "(?type)" cast syntax (not to speak of the existing "(type)" cast) as how to handle those "failures"... Honestly as a newbie here I'm feeling more tired than I had expected and I'm not sure if we'll

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-09 Thread Guilliam Xavier
this thread (who hasn't had the time to answer questions yet, sorry), I would ask everyone to please try to avoid sarcasm and provocation (intentional or not), especially if you actually like the idea =( Thank you in advance -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-09 Thread Guilliam Xavier
t;, "nullable_strval()" etc. but we're missing "arrayval()" and "objectval()"...) Best regards, -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Strict operators directive

2019-06-25 Thread Guilliam Xavier
; > [Arnold Daniels - Chat @ > Spike](https://www.spikenow.com/?ref=spike-organic-signature&_ts=1mzl6) > [1mzl6] Hello, thanks for the impressive work... I have just one interrogation: why disallow `~` for strings? (e.g. currently `~"\x00\x01\x02"` gives `"

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-10 Thread Guilliam Xavier
ing $x) { var_dump($x); })($obj); // TypeError var_dump((function ($x): string { return $x; })($obj)); // TypeError var_dump((function ($x): ?string { return $x; })($obj)); // TypeError var_dump((string) $obj); // Recoverable fatal error var_dump((?string) $obj); // would you want it to print

Re: [PHP-DEV] [RFC] Nullable Casting

2019-04-10 Thread Guilliam Xavier
On Wed, Apr 10, 2019 at 12:52 PM Nikita Popov wrote: > > I'm a bit concerned that there are two possible semantics for what (?int) > does: > > 1. What I would intuitively expect: A fallible integer cast. I.e. try to > cast to integer and if not possible return null. So (?int) "foobar" becomes >

[PHP-DEV] Re: [RFC] Nullable Casting

2019-04-21 Thread Guilliam Xavier
On Sat, Apr 6, 2019 at 9:52 AM Guilliam Xavier wrote: > > Hello internals, > > David and I would like to open the discussion on our joint RFC: > > https://wiki.php.net/rfc/nullable-casting > > Mainly, it would enable to use e.g. `(?int)$x` besides `(int)$x`. > >

Re: [PHP-DEV] Stop replacing dots with underscores in query, post and cookie parameters for PHP 8?

2019-07-16 Thread Guilliam Xavier
pi-platform/core/issues/509 - https://github.com/api-platform/core/blob/v2.4.5/src/Util/RequestParser.php -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Let's allow eval() to be turned off in PHP 8

2019-11-26 Thread Guilliam Xavier
For the record, a few months ago, https://github.com/php/php-src/pull/4084 (extending `disable_functions` to handle `eval`) was first merged but finally reverted (requested by Xdebug), and the feature request https://bugs.php.net/bug.php?id=62397 was closed (with an explanation). -- Guilliam

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Guilliam Xavier
e function. > > Or have ::function to return the name of the function and provide a syntax > something like ${myfunc} to return a closure, which has been suggested later > in this thread. That might deserve consideration indeed... -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [RFC] "arrayable" pseudo type hint

2020-02-04 Thread Guilliam Xavier
s (the same way you cannot declare an `interface Iterable` because of the `iterable` reserved word, <https://3v4l.org/Fhqar>), so you would need another name (if you want the alias) -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Warn when declaring required parameter after optional one

2020-02-05 Thread Guilliam Xavier
y further concerns about this > change? Can you please just clarify which of the following will emit a deprecation? function f1($a = null, $b) {} function f2(A $a = null, $b) {} function f3(?A $a = null, $b) {} (I think f1 will, f2 won't, but f3?) Thanks > > Regards, > Nikita > -- Guilliam Xavier

Re: [PHP-DEV] [VOTE] declare(function_and_const_lookup='global')

2020-01-30 Thread Guilliam Xavier
n that the leading backslash be required to avoid relative resolution, but `use Ns\Klass;` is already absolute. And for strings, `\Ns\Klass::class` (or `get_class(new \Ns\Klass())`) is equal to `'Ns\Klass'`, not `'\Ns\Klass'`. -- Guilliam Xavier

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Guilliam Xavier
tent. Actually PHP 7.4's short closures / array functions use `fn`, not `func`. But `::fn` would look... weird. I agree with Diogo that `::function` would be more consistent. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Adding a "Stringable" interface to PHP 8

2020-02-11 Thread Guilliam Xavier
On Tue, Feb 11, 2020 at 2:11 PM Michał Brzuchalski wrote: > > wt., 11 lut 2020 o 13:59 Guilliam Xavier > napisał(a): >> >> On Tue, Feb 11, 2020 at 1:12 PM Nicolas Grekas >> wrote: >> > >> > > >> > > Just so some

Re: [PHP-DEV] [RFC] Adding a "Stringable" interface to PHP 8

2020-02-11 Thread Guilliam Xavier
r, which this ones also is. But one could argue that "string" is not a verb like "traverse", "serialize", "count", "throw" etc. Potential alternatives would be Stringifyable (or Stringifiable?), StringCastable, StringConvertible... (Even though I personal

Re: [PHP-DEV] Proposal for a new basic function: str_contains

2020-02-16 Thread Guilliam Xavier
tr_{starts,ends}_with` even more (without case-insensitive nor multibyte variants)] -- Guilliam Xavier On Fri, Feb 14, 2020 at 11:14 AM G. P. B. wrote: > > On Fri, 14 Feb 2020 at 10:58, Aegir Leet wrote: > > > I generally like the idea, but it seems many (most?) real-world > &g

Re: [PHP-DEV] [RFC] Static return type

2020-01-14 Thread Guilliam Xavier
` in addition to the check. I'm -1 for `: fluent` or `fluent function` as an alternative to `: $this`. I'm -0.5 for `: new` / `: clone`. About "what comes out is the same type as what goes in", I would wait for generics. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mail

Re: [PHP-DEV] [RFC] Allow ::class on objects

2020-01-10 Thread Guilliam Xavier
ciative too but `!$x === 42` is evaluated as `(!$x) === 42` (not as `!($x === 42)`). According to the docs, associativity only matters for operators of equal precedence, e.g. `4 - 3 - 2` is evaluated as `(4 - 3) - 2`, and `4 ** 3 ** 2` is evaluated as `4 ** (3 ** 2)`. -- Guilliam Xavier --

Re: [PHP-DEV] What to do with "$array[foobar]"?

2020-01-10 Thread Guilliam Xavier
[qux]' "$array[arr][bar]" // $array['arr'] . '[bar]' "$array[obj]->qux" // $array['obj'] . '->qux' In any case, I'm +1 for deprecating "$array[key]", and "$array[0]" to avoid introducing another inconsistency. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [RFC] Allow trailing comma in parameter lists

2020-04-09 Thread Guilliam Xavier
till exceed 120 columns if on a single line (with e.g. descriptive names, [union] type declarations for parameters and/or return, and/or a class constant as default value for the last parameter, that's not so uncommon)... Just my two cents ;) Best regards, -- Guilliam Xavier -- PHP Inte

Re: [PHP-DEV] Type hints in array destructuring expressions

2020-04-16 Thread Guilliam Xavier
a similar: ``` $years = ["now" => 2020, "future" => 2021]; foreach ($years as string $description => int $year) { ``` or: ``` $foos = [new Foo("one"), new Foo("two")]; foreach ($foos as Foo $foo) { ``` Now I remember this has already been requested (e

Re: [PHP-DEV] [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed

2020-04-16 Thread Guilliam Xavier
`array` and a `string` (when called), but why not check their signature (if typed) at *compile time* too (i.e. make https://3v4l.org/ZPrVi an error)? Regards, -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [RFC] Attributes v2

2020-04-18 Thread Guilliam Xavier
attribute, untyped equivalent to respectively: function ( <> \B $x ) function ( <> $x ) which permit whitespace (unambiguous because delimited): function ( << A >> \ B $x ) function ( << A \ B >> $x ) (although I've never seen code with

Re: [PHP-DEV] [RFC] Mixed type

2020-04-20 Thread Guilliam Xavier
ry code path of] the implementation returns a value. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Mixed type

2020-04-21 Thread Guilliam Xavier
l/en/function.is-scalar.php). -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Mixed type

2020-04-20 Thread Guilliam Xavier
on types. All the more reason to standardize those "aliases" in core? -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PHP 7.4.5 Released!

2020-04-16 Thread Guilliam Xavier
ion guide: <http://php.net/manual/migration74.php> > > Many thanks to all the contributors and supporters! Thanks, just noticed the "Release Announcement" link is dead, the working one is: <http://php.net/releases/7_4_5.php> -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC][DISCUSSION] Change var_export() array syntax touse short hand arrays

2020-04-08 Thread Guilliam Xavier
) would be BC-compliant...) Moreover the RFC currently says that var_export([1, 2, 3]) produces ``` array(1, 2, 3) ``` but it actually produces ``` array ( 0 => 1, 1 => 2, 2 => 3, ) ``` Regards, -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] [VOTE] str_contains is accepted

2020-03-16 Thread Guilliam Xavier
e str_starts_with and str_ends_with in PHP 8 too? -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [VOTE] Userspace operator overloading

2020-03-26 Thread Guilliam Xavier
eful). I fear that "hint" notice could break Symfony apps... Couldn't you just not trigger it in this case? -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Allow trailing comma in parameter lists

2020-03-30 Thread Guilliam Xavier
characters ;) Maybe the RFC could include an example? But I am curious too about why it failed last time. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] RFC Raised for str_starts_with and str_ends_with

2020-03-26 Thread Guilliam Xavier
error-prone, hard to understand...) plus how they handle empty strings. (And also probably shorten the introduction ^^ or move parts into a new subsection) PS: you could also add a link to the str_contains RFC Best regards, -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [RFC] [DISCUSSION] Locale-independent float to string cast

2020-04-22 Thread Guilliam Xavier
d %g/%G (and possible %H)? -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Function pipe operator

2020-04-22 Thread Guilliam Xavier
hor defines a custom `-:` operator such that `x -: f` desugars to `f x` (equivalent to how `$x |> $f` would desugar to `$f($x)` with the RFC), which allows to write e.g. `xs -: sort -: reverse` instead of `reverse (sort xs)` or `(reverse . sort) xs`. -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Function pipe operator

2020-04-23 Thread Guilliam Xavier
https://repl.it/repls/KindLightsalmonApplicationserver Ah, thanks for the intel! (I see it was added in 2015, i.e. a few years after the publication of LYAHFGG in 2011) -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: [PHP-DEV] [RFC] Mixed type

2020-04-23 Thread Guilliam Xavier
he currently-impossible-to-write union of all primitive types, including resource and null [but not void that is not a data type]) is LSP-conformant. Regards, -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: Re: [PHP-DEV] [RFC] Mixed type

2020-04-23 Thread Guilliam Xavier
Hi Christoph and Rowan (your replies kind of overlap), On Thu, Apr 23, 2020 at 12:21 PM Christoph M. Becker wrote: > > On 23.04.2020 at 11:26, Guilliam Xavier wrote: > > > On Wed, Apr 22, 2020 at 11:10 PM Barney Laurance > > wrote: > > > >> Taking a rand

Re: [PHP-DEV] [RFC] [DISCUSSION] Ensure correct magic methods' signatures when typed

2020-04-14 Thread Guilliam Xavier
4l.org/0VmYQ. Actually there are ways to use integers as property names, but they are converted to strings on creation: https://3v4l.org/0k4LS and https://3v4l.org/HhPZP (also https://3v4l.org/Ts42B). ArrayAccess doesn't use magic __isset(string $name) but interface offsetExists(mixed $offset

Re: [PHP-DEV] [VOTE] Voting opens for str_starts_with and ends_with functions

2020-03-20 Thread Guilliam Xavier
r the next PHP 8.0 (<https://externals.io/message/109050>). Would you be willing to reboot your RFC with just str_starts_with and str_ends_with (and a stronger case of how people keep implementing them using the inefficient and/or error-prone currently available alternatives)? Best regards, -- Guilliam Xavier -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Putting the match expression in constant expressions in PHP 8.0 or 8.1

2020-08-08 Thread Guilliam Xavier
}; > } > ``` > > https://github.com/php/php-src/pull/5951 implements the main part of the > change. > Hi, thanks, just noticed that your examples should use `===` not `==`. Regards -- Guilliam Xavier

Re: [PHP-DEV][RFC] Rename T_PAAMAYIM_NEKUDOTAYIM to T_DOUBLE_COLON

2020-06-12 Thread Guilliam Xavier
> So please, let the parser tell me not only the line of the error, but also the colum. > Other information currently missing from the message - e.g. column > number, hints about unclosed blocks - is likely to be far more useful >> a) Character count (at line 456, character 23) > >> > >> b)

Re: [PHP-DEV] [RFC] Draft - Closure self reference

2020-11-20 Thread Guilliam Xavier
know if that would be a problem, because today we can have it > "function(): Type use($x)", so "Type use($x)"? > No we can't, try it (Parse error). The correct order is "function() use($x): Type". -- Guilliam Xavier

Re: [PHP-DEV] Re: [RFC] var_representation() : readable alternative to var_export()

2021-02-04 Thread Guilliam Xavier
still cause newlines in the output" part is obsolete (since `\r` and `\n` are escaped now). Apart from that, since var_export (and var_dump) can't really be "fixed" for BC reasons, I'm +1 for the new function. Thanks -- Guilliam Xavier

Re: [PHP-DEV] Re: [RFC] Under Discussion: Add Random class and RandomNumberGenerator interface

2021-06-14 Thread Guilliam Xavier
ist = $random->shuffleArray($list);` etc. I think this is well-consistent with the "pure design" described by Nikita, and I personally find it both flexible/extensible and easy-to-use =) (Just beware that the namespace question will probably pop up again.) PS: I feel like my numerous questions/suggestions (in this thread and the previous ones) may also have caused some deviations, so I hope that I won't need more and that other participants will reach a consensus... Best regards, -- Guilliam Xavier

Re: [PHP-DEV] Re: [RFC] Under Discussion: Add Random class and RandomNumberGenerator interface

2021-06-09 Thread Guilliam Xavier
> > Couldn't the Random class simply implement `public function __clone(): > void` (that would internally do like `$this->algo = clone $this->algo;`)? > Sorry I meant like `$this->rng = clone $this->rng;`. PS: Please don't reply to this erratum, but rather to the previous message ;)

Re: [PHP-DEV] Re: [RFC] Under Discussion: Add Random class and RandomNumberGenerator interface

2021-06-09 Thread Guilliam Xavier
getrandmax() is no longer provided. > Great! > > > > > uint64 & right-shift > > > > This is a specification of the RNG implementation. PHP does not have > > unsigned integers, but RNG handles unsigned integers (to be precise, even > > the sign bit is random). > > > > As mentioned above, PHP does not have unsigned integers, which means that > > using the results generated by RNGs may cause compatibility problems in > the > > future. To avoid this, a 1-bit right shift is always required (similar to > > mt_rand()). > Good to know, thanks. Regards, -- Guilliam Xavier

Re: [PHP-DEV] Re: [RFC] Under Discussion: Add Random class and RandomNumberGenerator interface

2021-06-09 Thread Guilliam Xavier
[...] which means that the code loses compatibility with the result of running on a 64-bit machine"? And you asked if throwing an exception would be preferable? Anyway, I personally don't care about 32-bit (but other people may). > Regards, > Go Kudo > Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Partial Function Application, take 2

2021-06-10 Thread Guilliam Xavier
ped parameter `?Foo $foo`)? Related, for `$null === null`, is `$c = $null->bar(?);` / `$c = $null::baz(?);` an immediate error, or only later when calling `$c($arg)`? Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Partial Function Application, take 2

2021-06-10 Thread Guilliam Xavier
On Thu, Jun 10, 2021 at 7:32 PM Guilliam Xavier wrote: > > Since `$null?->whatever(1, 'a')` currently always returns null without > error, shouldn't `$null?->whatever(?, 'a')` return a closure (with a > signature built from the placeholders only) that will return null

Re: [PHP-DEV] [RFC] Partial Function Application, take 2

2021-06-10 Thread Guilliam Xavier
On Thu, Jun 10, 2021 at 4:34 PM Larry Garfield wrote: > On Thu, Jun 10, 2021, at 3:17 AM, Guilliam Xavier wrote: > > On Wed, Jun 2, 2021 at 7:47 PM Larry Garfield > > wrote: > > > > > https://wiki.php.net/rfc/partial_function_application > > > >

Re: [PHP-DEV] Re: [RFC] is_literal

2021-06-18 Thread Guilliam Xavier
imit` even if $limit doesn't come from a "static" value (e.g. random_int() or even `$_GET['limit']`) -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Name issue - is_literal/is_trusted

2021-06-23 Thread Guilliam Xavier
be a one-liner `implode(array_map(fn ($c) => ['0','1','2','3','4','5','6','7','8','9','-'=>'-'][$c], str_split((string)$int)))`), so that those `implode(',', [1,2,3])` could use `implode(',', array_map('to_literal', [1,2,3]))`? Regards, -- Guilliam Xavier

Re: [PHP-DEV] Introduce str_left/right In 8.1

2021-06-23 Thread Guilliam Xavier
I misunderstanding what these proposed functions should do, or am I > underestimating the difficulty of typing a zero or negative sign on certain > keyboards? > I think that's more about "semantics" ("conveying intent to readers") than typing... That said, I tend to agree with George (but maybe I'm "too" used to seeing substr()?) Regards, -- Guilliam Xavier

Re: [PHP-DEV] [Vote] make Reflection*#setAccessible() no-op

2021-06-23 Thread Guilliam Xavier
Meanwhile, if anybody knows why the RFC isn't listed on `/rfc`, lemme know > :D > You have to add it manually, cf https://wiki.php.net/rfc/howto 3.4 (yeah...) Cheers -- Guilliam Xavier

Re: [PHP-DEV] Introduce str_left/right In 8.1

2021-06-24 Thread Guilliam Xavier
take the > leftmost part of the string. > True, I can also imagine bikeshed like "str_leftmost", "str_start", "str_first[_n]" (and same for rightmost/end/last)... > Don't take it the wrong way, but I think it's a waste of time to implement > a function that doesn't even need a polyfill in the userland. > > Regards, > Kamil > -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Pipe Operator, take 2

2021-06-08 Thread Guilliam Xavier
is also trivially free. A PFA-based optimization would entail significant overhead relative to simple function calls, unless special optimization for the pipe operator usage is introduced (which may not be possible, depending on precise semantics). """ Could you (or Nikita) expand a bit on this (esp. the advantages of the PFA approach / disadvantages of Hack's approach)? Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC][DISCUSSION] Match expression v2

2021-06-18 Thread Guilliam Xavier
lism. > Before going to vote, I think the RFC should be updated to at least mention the strict-VS-loose comparison choice (for things like `match { preg_match(/*...*/) => /*...*/ }`). Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Pipe Operator, take 2

2021-06-08 Thread Guilliam Xavier
On Tue, Jun 8, 2021 at 4:09 PM Larry Garfield wrote: > On Tue, Jun 8, 2021, at 5:41 AM, Guilliam Xavier wrote: > > > you forgot to update one > > `explode(?)` to `str_split(?)`, and also, the first `fn($v) => > > 'strtoupper'` should be just `'strtoupper'`. > >

Re: [PHP-DEV] [RFC] Partial Function Application, take 2

2021-06-11 Thread Guilliam Xavier
r, and `$boo = $baz(...);` makes the subsequent `$boo(5);` throw a "not enough arguments ..." Error) (weird, looks like `$bar = $foo(2, ...);` and/or `$baz = $bar(3, ...);` dropped too many params) Regards, -- Guilliam Xavier

Re: [PHP-DEV] Trait constants

2021-05-12 Thread Guilliam Xavier
gt; > * Constants mustn't be accessible directly on the trait, i.e. > TraitName::FOOBAR throws. > Sorry for asking so late, but: why? Note that currently both TraitName::$foobar and TraitName::foobar() work: https://3v4l.org/eGlYm Thanks, -- Guilliam Xavier

Re: [PHP-DEV] Re: [RFC] [Discussion] Final constants

2021-05-18 Thread Guilliam Xavier
riel, see https://wiki.php.net/rfc/final_class_const#reflection > A `ReflectionClassConstant::isFinal()` method is added in order to be able to retrieve if a constant is final. Regards =) -- Guilliam Xavier

Re: [PHP-DEV] Trait constants

2021-05-19 Thread Guilliam Xavier
e discussion. Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC][Draft] Body-less __construct

2021-05-10 Thread Guilliam Xavier
er explicitly declared so in a class, or implicitly in an interface). Granted, property promotion is already special (cannot be used in an abstract constructor), but it can also be mixed with non-promoted parameters and body, so I feat that your proposed alternative syntax would bring more confusion than convenience :s Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Partial function application

2021-05-17 Thread Guilliam Xavier
hout any arg). Here we had to add a `?` only for "technical" reasons. More generally I also agree that `?` having two different meanings/behaviors in e.g. `f(?, 2)` [or `f(1, ?, 3)`] vs `f(1, ?)` -- namely: "exactly 1 arg" vs "0+ args" -- is confusing. I think I too would prefer `?` to only mean "exactly 1 arg", and - either have another token for "0+ args" (e.g.: `f(?, 2)` [and `f(1, ?, 3)`] vs `f(1, ...)`, and also `noParam(...)` and `threeParams(1, 2, 3, ...)` ) - or have another syntax like Hossein first suggested (e.g.: `*f(?, 2)` [and `*f(1, ?, 3)`] vs `*f(1)`, and also `*noParam()` and `*threeParams(1, 2, 3)`). Unless there are compelling (or at least convincing) reasons against? Thanks, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Partial function application

2021-05-17 Thread Guilliam Xavier
On Mon, May 17, 2021 at 5:16 PM Mike Schinkel wrote: > > > On May 17, 2021, at 10:50 AM, Guilliam Xavier > wrote: > > > > On Mon, May 17, 2021 at 6:58 AM Mike Schinkel wrote: > >> > >> > Well, I was thinking that by changing the proposed syn

Re: [PHP-DEV] [RFC] Partial function application

2021-05-17 Thread Guilliam Xavier
ter, e.g.: ``` function f($a, $b, $c, $d, $e) {/*...*/} /* We want to bind value 4 to param "d" */ // with current syntax: $p = f(?, d: 4); /* or f(?, ?, ?, 4) */ // with another hypothetical syntax: $p = *f(d: 4); ``` Anyway, looking forward to your update =) Thanks, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Partial function application

2021-05-17 Thread Guilliam Xavier
On Mon, May 17, 2021 at 5:47 PM Alexandru Pătrănescu wrote: > > On Mon, May 17, 2021 at 6:36 PM Guilliam Xavier > wrote: > >> On Mon, May 17, 2021 at 5:01 PM Levi Morrison < >> levi.morri...@datadoghq.com> >> wrote: >> >> > Joe Watkins has

Re: [PHP-DEV] [RFC][Draft] Body-less __construct

2021-05-11 Thread Guilliam Xavier
MyLibraryException; > > > class DefaultMyLibraryException extends \RuntimeException implements > MyLibraryException; > > ``` > > Is an excellent use case for this! > > I'm probably biased by my C++ background but to me this looks like "forward declarations" (i.e. just declares types but doesn't *define* them) :/ Regards, -- Guilliam Xavier

[PHP-DEV] Re: [RFC] [Draft] Add Randomizer class (before: Add RNG extension)

2021-05-26 Thread Guilliam Xavier
n?) or some other solution someone can think of? Ah that made me think: should some methods better be `final`? Finally, the current "Open Issues" section should probably renamed to "Discussion" or even "FAQ" here? Regards, -- Guilliam Xavier

Re: [PHP-DEV] Disable autovivification on false

2021-05-26 Thread Guilliam Xavier
/* ... */ } } } ``` All other cases I can remember were arguably bugs (missing initialization). That said, deprecating it on false would already be a +1. Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] First-class callable syntax

2021-05-25 Thread Guilliam Xavier
later (or in PFA). Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] First-class callable syntax

2021-05-25 Thread Guilliam Xavier
ake PFA code a lot easier to understand even if > someone is not that familiar with it yet. > FWIW: In this context, ? and * remind me of shell wildcards (used by glob() and fnmatch()), which makes sense too. Also, at least one person is opposed to "...". -- Guilliam Xavier

Re: [PHP-DEV] Consensus Gathering: is_initialized

2021-05-26 Thread Guilliam Xavier
uninitialized something other than "your constructor is bad and you > should feel bad." > I think you said the word: serialization. And especially *deserialization*, e.g. from a JSON payload into a typed DTO *without* calling the constructor (then the DTO is passed through validation, which must handle uninitialized typed properties "gracefully"). -- Guilliam Xavier

Re: [PHP-DEV] [RFC] [Draft] Add RNG extension and deprecate mt_srand()

2021-05-20 Thread Guilliam Xavier
$max args), I assume that $max defaults to PHP_INT_MAX, but does $min default to PHP_INT_MIN or actually 0 [if it's like [mt_]rand() I guess that the answer is probably 0, but that could be written clear in the RFC]? > > Thanks for the detailed remarks. Based on these, I would like to clean up > the RFC. > > Regards, > Go Kudo > Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] First-class callable syntax

2021-05-20 Thread Guilliam Xavier
ble and not performing a call. > Hi, several other syntaxes have been proposed to consideration in the PFA thread, and I wouldn't want to start new bikeshedding here; is there a place that would be more appropriate to gather the possibilities (like a kind of updatable list)? Thanks, -- Guilliam Xavier

Re: [PHP-DEV] Consensus Gathering: is_initialized

2021-05-27 Thread Guilliam Xavier
, akin to isset); but the PR was only proposing `is_initialized($foo, 'bar')` (regular function, akin to property_exists). Anyway, that's a "Wont fix". (PS about previous messages: I actually don't write custom serializers myself) -- Guilliam Xavier

Re: [PHP-DEV] json_encode indent parameter

2021-06-03 Thread Guilliam Xavier
That said, I wouldn't mind a new indent parameter (but note that allowing an arbitrary string [not limited to whitespace] might result in invalid JSON). Regards, -- Guilliam Xavier

Re: [PHP-DEV] Re: Injection vulnerabilities

2021-05-24 Thread Guilliam Xavier
t; parts and quote/escape the dynamic parameters)? Regards, -- Guilliam Xavier

[PHP-DEV] Re: [RFC] [Draft] Add Randomizer class (before: Add RNG extension)

2021-05-24 Thread Guilliam Xavier
)... Ideally it should be distinct `(array $value): array` and `(string $value): string`, but that probably requires two distinct names? - For internal implementation, isn't there a signed/unsigned "mismatch" between PHP `function next(): int` and C `uint64_t (*next)(void)` return types? Regards, -- Guilliam Xavier

Re: [PHP-DEV] Introduce str_left/right In 8.1

2021-06-24 Thread Guilliam Xavier
plete: there's also iconv_substr() (but with the same result as mb_substr()), and here are two links to compare: https://3v4l.org/kU9D5 vs https://3v4l.org/pAvB0 Regards, -- Guilliam Xavier

Re: [PHP-DEV] Introduce str_left/right In 8.1

2021-06-24 Thread Guilliam Xavier
polyfills clear =) Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Name issue - is_literal/is_trusted

2021-06-24 Thread Guilliam Xavier
ask basically the same [with different names] a few days ago ("why can't we have both?"), but then remembered https://externals.io/message/114835#114951 , esp. the end: """ And to support having 2 functions, we would need 2 flags on strings. These flags are limited, and

Re: [PHP-DEV] [Vote] Partial Function Application

2021-06-29 Thread Guilliam Xavier
different syntax (e.g. with a prefix operator) would result in a simpler implementation? Regards, -- Guilliam Xavier

Re: [PHP-DEV] [Vote] Partial Function Application

2021-06-29 Thread Guilliam Xavier
ught up in the discussion. > > Finally found where I read that, it’s in an other RFC: > > https://wiki.php.net/rfc/first_class_callable_syntax#partial_function_application > For the record, Larry replied on this subject: https://externals.io/message/114770#114785 (second part). Note that for `$$->foo(/*whatever*/)` the signature couldn't be extracted (because the class of $$ is unknown). Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Guilliam Xavier
nowdoc [VS heredoc].) As for the proposal, overall I agree with Rowan -- well, that would not be exactly like single quotes (regarding [not] escaping them), but still "yet another way" to write a nowdoc string literal. PS: "amusingly", the code samples are hard to understand after

Re: [PHP-DEV] [Vote] Partial Function Application

2021-06-30 Thread Guilliam Xavier
On Tue, Jun 29, 2021 at 10:32 PM Levi Morrison via internals < internals@lists.php.net> wrote: > On Tue, Jun 29, 2021 at 12:05 PM Larry Garfield > wrote: > > > > On Tue, Jun 29, 2021, at 1:00 PM, Larry Garfield wrote: > > > On Tue, Jun 29, 2021, a

Re: [PHP-DEV] [VOTE] Deprecations for PHP 8.1

2021-07-05 Thread Guilliam Xavier
p#errorfunc.constants.errorlevels.e-deprecated-error (*emphasis* mine) E_DEPRECATED: Run-time notices. Enable this to receive warnings about code that *will not work in future versions*. As for "significant BC breakage", isn't that what major versions are for? (and with the current release plan, 9.0 would be for end 2025, i.e. 4 years after 8.1) Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC] [Draft] Add RNG extension and deprecate mt_srand()

2021-05-19 Thread Guilliam Xavier
ns (which itself could be split between [mt_]srand and [mt_]rand), and the change of internal RNG for shuffle/str_shuffle/array_rand. Best regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC][Draft] Sealed Classes

2021-04-27 Thread Guilliam Xavier
(which seems legit), only with None made final (which... could be debated, but unrelated to the RFC at hand). Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC][Draft] Sealed Classes

2021-04-27 Thread Guilliam Xavier
ss is to replace `@internal` phpDoc). I'm not saying that this RFC is bad, but probably not as convincing as it could be. Regards, -- Guilliam Xavier

Re: [PHP-DEV] [RFC][Draft] Sealed Classes

2021-04-28 Thread Guilliam Xavier
Forwarding to the list, and answering: On Wed, Apr 28, 2021 at 9:51 AM Tony Marston wrote: > On 27/04/2021 17:22, Guilliam Xavier wrote: > > On Sat, Apr 24, 2021 at 12:55 PM Saif Eddin Gmati > > > wrote: > > > > > > To me the first sentence of the RF

Re: [PHP-DEV] [RFC][Draft] Sealed Classes

2021-04-29 Thread Guilliam Xavier
On Wed, Apr 28, 2021 at 10:18 PM Dan Ackroyd wrote: > On Wed, 28 Apr 2021 at 14:30, Guilliam Xavier > wrote: > > > > Forwarding to the list, and answering: > > > > Please don't do that. > > He was blocked from the list for repeatedly derailing conversation

Re: [PHP-DEV] [RFC][Draft] Sealed Classes

2021-04-28 Thread Guilliam Xavier
Re-forwarding to the list (please stop replying to me in private, thanks). Also re-answering but I will stop there because that's too much digression for a partial quote of my initial message. On Wed, Apr 28, 2021 at 5:30 PM Tony Marston wrote: > On 28/04/2021 14:30, Guilliam Xavier wr

Re: [PHP-DEV] Interaction between finally blocks and exit()

2021-02-08 Thread Guilliam Xavier
.0.0 because of an unexpected interaction of those two things? (adding Nikita to the CC list) -- Guilliam Xavier

Re: [PHP-DEV] [VOTE] PHP\iterable\any() and all() on iterables

2021-02-10 Thread Guilliam Xavier
cated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero */ echo json_encode($list); // [4,3,2,1] ``` (That's probably because PHP user comparison functions were modelled from C (e.g. strcmp()), not C++ (e.g. std::less).) Of course here the "correct" thing is to return `$a <=> $b` (or `$b <=> $a` for descending order), but you can also return `$a - $b` (not necessarily in [-1,0,1]), or even a string `"foo"` still without any warning in 8.0.2 (just a certainly wrong result)... Anyway, to me it feels natural that any()/all() would "work" like array_filter(). @Tyson by the way, in the any()/all() case (vs the any_value()/all_values() and potential any_key()/all_keys() etc.), wouldn't it be preferable to add the optional `int $flags = 0` (or "$mode") parameter right from the start (even if not used yet), as adding it in a later release would apparently pose some BC concerns (ArgumentCountError, polyfills etc.)? -- Guilliam Xavier

Re: [PHP-DEV] [RFC] Short functions, take 2

2021-03-25 Thread Guilliam Xavier
ss A { function method($arg1) { expr($arg1); } } ``` i.e. I initially forgot the "return " (and had to go back and add it). I would surely not have this problem anymore with this: ``` class A { function method($arg1) => expr($arg1); } ``` (It also seems I don't have this problem when writing a return on its own line :/) Regards, -- Guilliam Xavier

  1   2   >