Fatal error: During inheritance of ArrayAccess (only in dev environment)

In the stage environment, this is not happening. But in the dev environment which I am currently setting up, I receive following error:

Fatal error: During inheritance of ArrayAccess: Uncaught ErrorException: Return type of SlimEnvironment::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/api/lib/slim/Slim/Environment.php:186

Both environments have the same PHP version 8.1.12 (cli). I assume that it might be a configuration issue. But by comparing the phpinfo, I can’t say which setting might be responsible for this inconsistent behavior.

I breaked it down with following tests:

test-plain.php

<?php

class Foo implements ArrayAccess
{
    public function offsetExists(mixed $offset): bool
    {
    }

    public function offsetGet(mixed $offset): mixed
    {
    }

    public function offsetSet(mixed $offset, mixed $value): void
    {
    }

    public function offsetUnset(mixed $offset): void
    {
    }
}

$object = new Foo();
var_dump($object);

Both environments outputs the same. So the implementation of ArrayAccess actually works.

object(Foo)#1 (0) { }

test-slim.php

<?php
require 'lib/slim/Slim/Slim.php';

SlimSlim::registerAutoloader();
$app = new SlimSlim();
$app->run();

Stage environment shows a clean framework specific “404 Page Not Found” error page.
Dev environment breaks with the fatal error above.

Any idea why this behaves differently? Again, both environments have the same PHP version 8.1.12 (cli).