note 127506 added to language.oop5.traits

From: Date: Wed, 17 Aug 2022 08:19:02 +0000
Subject: note 127506 added to language.oop5.traits
Groups: php.notes 
Request: Send a blank email to php-notes+get-219444@lists.php.net to get a copy of this message
It is truly and deeply disappointing to see this page say: "As of PHP 8.1.0, calling a static method, or accessing a static property directly on a trait is deprecated. Static methods and properties should only be accessed on a class using the trait." This frankly removes about 1/3 of the usefulness of traits. Since traits are essentially copy/paste -- you really should be able to access, override and assert anything. The using scope is all that should matter. That said, specifically in the case of static methods and properties -- how ridiculous. You can't even have a simple AutoIncrement trait for object id's ? That's not only absurd, it goes against having traits at all. The ability to call static properties and functions with -> should be preserved across the board, not only for traits. Instances carry scope and the language should not decide for me how much of that scope I want to see. Rather than forcing it at the language level if folks really think that people need guiderails; make another MyTraitValidator trait and use all Abstract Trait Members. This way the PHP project can define when something needs to be strict in a PHP standard library. IMO there are so many great gains with PHP 8 that open up possibilities, yet this constraint mentality is counter-productive. Same reasoning that operator overloading was shot down, very depressing to see as a company that uses PHP. Type constraints are fine as the developer can control them, but constraints in what PHP will or wont "allow" devs to access, even though the variables are in an execution context -- that needs to be expressed at a different layer than the language. Big time. ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.173 (proxied: 199.167.134.86) ---- Manual Page -- https://php.net/manual/en/language.oop5.traits.php Edit -- https://main.php.net/note/edit/127506 Del: integrated -- https://main.php.net/note/delete/127506/integrated Del: useless -- https://main.php.net/note/delete/127506/useless Del: bad code -- https://main.php.net/note/delete/127506/bad+code Del: spam -- https://main.php.net/note/delete/127506/spam Del: non-english -- https://main.php.net/note/delete/127506/non-english Del: in docs -- https://main.php.net/note/delete/127506/in+docs Del: other reasons-- https://main.php.net/note/delete/127506 Reject -- https://main.php.net/note/reject/127506 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#219444) next »