Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Cannot use ‘readonly’ as method modifier

Description

readonly is reserved for properties, and cannot be used with methods, constants, enumeration cases or static properties.

Example

<?php

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

?>

Alternatives

  • Remove the option from the method signature.