Re: [PHP-DEV] [RFC] Static property asymmetric visibility

2024-11-26 Thread Jonathan Vollebregt
On 11/26/24 9:35 PM, Larry Garfield wrote: Thinking aloud, my expectation would be that it behaves similarly to how final static methods would behave. Which appears to be a syntax error: https://3v4l.org/j8mp0#v8.4.1 So, shouldn't properties do the same? Without final you can still overrid

Re: [PHP-DEV] Adding attributes to compile-time constants

2024-11-26 Thread Larry Garfield
On Tue, Nov 26, 2024, at 2:15 PM, Daniel Scherzer wrote: > Hi internals, > > For the last few weeks, I've been working on a patch[1] that I just > uploaded that adds support for attributes on compile-time non-class > constants (those declared with `const` rather than via `define()`). The > patch

Re: [PHP-DEV] [RFC] Static property asymmetric visibility

2024-11-26 Thread Larry Garfield
On Tue, Nov 26, 2024, at 3:57 AM, Tim Düsterhus wrote: > Hi > > Am 2024-11-25 17:52, schrieb Larry Garfield: >> Static property asymmetric visibility was left out of the original RFC, >> because it seemed like it would be hard and of little use. Turns out, >> Ilija found a way to make it easy.

[PHP-DEV] Adding attributes to compile-time constants

2024-11-26 Thread Daniel Scherzer
Hi internals, For the last few weeks, I've been working on a patch[1] that I just uploaded that adds support for attributes on compile-time non-class constants (those declared with `const` rather than via `define()`). The patch has a memory leak that I have been unable to resolve, but otherwise th

Re: [PHP-DEV] Return When

2024-11-26 Thread Deleu
On Tue, Nov 26, 2024 at 2:18 PM Christoph M. Becker wrote: > What's wrong with > > if (!$result['success']) return $result; > > Christoph > I don't think I'm in favour of the proposal as I think it's high effort for little gain, but to me this "alternative" requires you to mentally parse a condi

RE: [PHP-DEV] Return When

2024-11-26 Thread Juris Evertovskis
Here’s the previous RFC: https://wiki.php.net/rfc/conditional_break_continue_return And the previous discussion: https://externals.io/message/110107

Re: [PHP-DEV] Return When

2024-11-26 Thread Lynn
On Tue, Nov 26, 2024 at 6:18 PM Christoph M. Becker wrote: > On 26.11.2024 at 17:10, Volodymyr Volynets wrote: > > > I have an idea which will save a lot of code. I am proposing to add": > > > > return when [condition], [return value]; > > > > This construct will remove a lot of ifs statements af

Re: [PHP-DEV] Return When

2024-11-26 Thread Anton Smirnov
On 26/11/2024 18:10, Volodymyr Volynets wrote: > I have an idea which will save a lot of code. I am proposing to add": > > return when [condition], [return value]; > > This construct will remove a lot of ifs statements after method calls. > For example: > > $result = Class->method(); > if (!$resul

Re: [PHP-DEV] Return When

2024-11-26 Thread Christoph M. Becker
On 26.11.2024 at 17:10, Volodymyr Volynets wrote: > I have an idea which will save a lot of code. I am proposing to add": > > return when [condition], [return value]; > > This construct will remove a lot of ifs statements after method calls. For > example: > > $result = Class->method(); > if (!$re

[PHP-DEV] Return When

2024-11-26 Thread Volodymyr Volynets
Hi PHP Mailing list, My username is vvolynets. I have an idea which will save a lot of code. I am proposing to add": return when [condition], [return value]; This construct will remove a lot of ifs statements after method calls. For example: $result = Class->method(); if (!$result['success'])

Re: [PHP-DEV] Needs Feedback - Yield without value in reference generator function does not create notice

2024-11-26 Thread Christoph M. Becker
On 26.11.2024 at 12:31, Claude Pache wrote: >> Le 26 nov. 2024 à 01:49, aggelos bellos a écrit : >> >> In this issue #16761 it was >> verified that in the above code it should throw a notice for both yields: >> ``` >> > error_reporting(E_ALL); >> fun

Re: [PHP-DEV] Needs Feedback - Yield without value in reference generator function does not create notice

2024-11-26 Thread Claude Pache
> Le 26 nov. 2024 à 01:49, aggelos bellos a écrit : > > Hello everyone, > > In this issue #16761 it was > verified that in the above code it should throw a notice for both yields: > ``` > error_reporting(E_ALL); > function &y() > { > yield null

Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Marco Pivetta
Hey Tim, On Tue, 26 Nov 2024 at 12:07, Tim Düsterhus wrote: > it was *semantically* identical, > That's the most important bit, thanks! That means that upstream Psalm may translate back/forth from it into a uniform version :-) To Eugene: consider posting this to the Psalm issue tracker. Marco

Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Tim Düsterhus
Hi Am 2024-11-26 12:00, schrieb Marco Pivetta: Is `Traversable|array` an alias of `iterable`? Is it **always** like that? Since PHP 8.2 `iterable` is internally transformed into `Traversable|array` on the engine level: https://github.com/php/php-src/pull/7309. `iterable` no longer exists as

Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Marco Pivetta
Hey Tim, On Tue, 26 Nov 2024 at 10:50, Tim Düsterhus wrote: > Hi > > Am 2024-11-26 10:40, schrieb Eugene Sidelnyk: > > I think it would make sense to change the signature of iterator_count > > to > > accept iterable rather than array|Traversable so that static analysis > > tools > > would pick i

Re: [PHP-DEV] [RFC] Static property asymmetric visibility

2024-11-26 Thread Tim Düsterhus
Hi Am 2024-11-25 17:52, schrieb Larry Garfield: Static property asymmetric visibility was left out of the original RFC, because it seemed like it would be hard and of little use. Turns out, Ilija found a way to make it easy. (Ilija is smart.) So here's a small RFC to add aviz to static prop

Re: [PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Tim Düsterhus
Hi Am 2024-11-26 10:40, schrieb Eugene Sidelnyk: I think it would make sense to change the signature of iterator_count to accept iterable rather than array|Traversable so that static analysis tools would pick it up better That sounds like a bug in Psalm's understanding of union types. PHPSta

[PHP-DEV] iterator_count signature for iterables

2024-11-26 Thread Eugene Sidelnyk
Hello internals! Currently, iterator_count has the following signature: iterator_count(Traversable|array $iterator): int If we try to use iterable type and pass it to iterator_count function, we'd get following static analysis error: Argument 1 of iterator_count expects Traversable|array, but