The following generates an error from devsense
<?php
require_once 'vendor/autoload.php';
use Carbon\Carbon as BaseCarbon;
class MyCarbon extends BaseCarbon {
public static function createFromFormat($format, $time, $timezone = null): ?static
{
return parent::createFromFormat($format, $time, $timezone);
}
}
Error:
Declaration of MyCarbon::createFromFormat($format, $time, $timezone = null): static must be compatible with Carbon::createFromFormat($format, $time, $timezone = null): mixed|null
however, this error seems to be incorrect, both php index.php show no error as well as PHP Intelephense from Ben Mewburn.
Changing the return type to an incorrect one produces a real php error, i.e. : ?int
Fatal error: Declaration of MyCarbon::createFromFormat($format, $time, $timezone = null): ?int must be compatible with Carbon\Carbon::createFromFormat($format, $time, $timezone = null): ?Carbon\Carbon in index.php on line 8
The following generates an error from devsense
Error:
however, this error seems to be incorrect, both
php index.phpshow no error as well asPHP Intelephensefrom Ben Mewburn.Changing the return type to an incorrect one produces a real php error, i.e.
: ?int