Hey Pedro,

On Fri, 25 Sept 2026 at 21:59, Pedro Veloso <[email protected]>
wrote:

> ```php
> class Ha {
>     private int $a = 1;
>
>     #[Pure]
>     public function getA(): int {
>         return $this->a;
>     }
> }
>
> new Ha()->getA(); // Fatal error: pure method Ha::getA() accesses $this.
> ```
>

Overall, I would also like to see functional purity in PHP, but a n
instance method is just a function with an implicit additional `$this`
argument, and it is pure if it causes no state mutation.

Marco Pivetta

https://mastodon.social/@ocramius

https://ocramius.github.io/

Reply via email to