Pure Attribute

February 25, 2024 ยท View on GitHub

This attribute is the equivalent of the @pure annotation for class methods and functions.

Arguments

The attribute accepts no arguments.

Example usage

<?php

use PhpStaticAnalysis\Attributes\Pure;

class PureExample
{
    #[Pure] // this function is pure
    public static function add(int $left, int $right) : int 
    {
        return $left + $right;
    }
    
  ...
}