eclipse-pdt / pdt

PHP Development Tools project (PDT)
https://eclipse.org/pdt
Eclipse Public License 2.0
189 stars 46 forks source link

PHP 8.4 future release and support to property hooks #279

Open peregrinodeti opened 3 months ago

peregrinodeti commented 3 months ago

Is your feature request related to a problem? Please describe. PHP 8.4 it's schedule to be release at november 2024. But your alpha's will be release in July. It's any planning to support property hooks at Eclipse 2024-09 release or to build nights to current version?

Is this feature require new UI elements or modify existing? No.

Describe the solution you'd like One of the most anticipated features of PHP 8.4 is property hooks. This feature allows developers to define custom "get" and "set" behaviors of class properties. Inspired by languages like Kotlin and Swift, property hooks simplify the creation of accessors and mutators, reducing boilerplate code and making the codebase cleaner and more maintainable.

Example:

class Foo
{
    private int $runs = 0;

    public function getRuns(): int { return $this->runs; }

    public function setRuns(int $runs): void
    {
      if ($runs <= 0) throw new Exception();
      $this->runs = $runs;
    }
}

$f = new Foo();

$f->setRuns($f->getRuns() + 1);

Describe alternatives you've considered Implement support this language feature, in next or actual Eclipse version. If need help to test or something @zulus please let me know.

Additional context Reference about this feature in this RFC: https://wiki.php.net/rfc/property-hooks

peregrinodeti commented 3 months ago

Well, PHP 8.4 Alpha 1 was released last week. I tried to use it in Eclipse PDT 2024-06, but when you go to the Eclipse IDE menu: Window -> Preferences -> Installed PHPs and try to point to the new PHP 8.4, the IDE throws an exception (Selected location doesn't refer to a valid PHP executable). The problem is not the location of the file, but the new version of PHP. I test on Windows 11. PHP 8.3.9 works fine when using the same directory name; in my case, c:\php. In both cases, the PHP executable stays in the same directory, but 8.4 doesn't work at the IDE, the IDE does not recognize the new version of the PHP executable.

If not difficult, I suggest a new IDE UI option to generate property hooks, like get and set. When you click on the source code and a sub-menu appears, go to the source option and put the new option: "Property Hooks Get and Set", for example. 

@zulus If you need any help to testing this new feature, let me know. And thanks for your great work at IDE.