On Wed, Feb 12, 2025 at 10:44 PM Jorg Sowa <jorg.s...@gmail.com> wrote:
> I must agree with Kamil. I don't see practical benefits of this feature > that would surpass the implications it has for the language. We already > have static analysis handling such cases and it can be extended even to > non-pure functions. Moreover, syntax (void) adds additional complexity to > beginners' understanding of the typing system. The second option with $_ is > BC on the other hand, so both options are unsatisfying. And honestly, I > don't have good ideas for it. > > Kind regards, > Jorg Sowa > Hi Jorg, To be clear: There is no BC break with $_. Opcache doesn't discard variables containing objects, so there is no observable change in behavior from what we're proposing. It doesn't change the variable semantics at all. Or am I misunderstanding what you're referring to? In addition, I reached out to see if Ondřej (Creator of PHPStan) had an opinion: https://phpc.social/@OndrejMirtes/114040888791921128 - So on top of our previous arguments that PHP shouldn't depend on 3rd party tools for everything, there is also at least interest in having this in core from the tool creators. > @edorian It already exists for PHPStan as a 3rd party extension: https://github.com/DaveLiddament/phpstan-php-language-extensions (MustUseResult) > Additionally, PHPStan itself reports this if you call a @phpstan-pure method or function and not use its result. > This attribute would be valuable for functions that aren’t pure but you’re still supposed to read the returned value. Kind regards, Volker -- Volker Dusch Head of Engineering Tideways GmbH Königswinterer Str. 116 53227 Bonn https://tideways.io/imprint Sitz der Gesellschaft: Bonn Geschäftsführer: Benjamin Außenhofer (geb. Eberlei) Registergericht: Amtsgericht Bonn, HRB 22127