On Tue, Sep 25, 2018 at 1:50 AM Stanislav Malyshev <smalys...@gmail.com> wrote: > > I want to do RFS proposal for new language concept - Class extension > > functions. > > > > Syntax will looks like: > > > > function DateTime->localTime() { > > return $this->format('H:i'); > > } > > I feel this is inviting trouble. If you need additional functionality, > why not extend the class? Or write a function that accepts DateTime as > an argument? This encourages a style of programming where you never know > which object does what. Even in JS, as far as I know, it's not exactly > the recommended style. But in PHP I don't think we should be doing this. > I've been back-burnering this for a few days and I'm with Stas. I don't like this proposal because it adds complexity with relatively little benefit.
If I wanted to add utility functions, I could create a proxy class which encapsulates the target and has a getter for passing into typehinted interfaces. You get all the functionality in any existing version of PHP without the added parser/engine complexity. Even static properties (which sadly lack get/set accessors) could be proxied using references so long as you know the statics ahead of time. -Sara -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php