Cannot use ‘readonly’ as method modifier

Description

readonly is an option for properties, and it is not available for methods nor constants.

Example

<?php

class x {
     private readonly function foo() {}
}

?>

Solutions

  • Remove the option from the method signature.