Unknown hook “%s” for property %s::$%s, expected “get” or “set”

Description

Property hooks can only be named ‘get’ or ‘set’, as of PHP 8.4. In the future, there may be new ones, but not in that version. Also, case is not important.

Example

<?php

class X
{
    public string $property {
        got {
            $this->name = $value;
        }
    }
}

?>

Literal Examples

  • Unknown hook “got” for property X::$property, expected “get” or “set”

Solutions

  • Use ‘set’ or ‘get’ as the name of the hook.

  • Wait for a future version of PHP.