<?php
class Request {}
class Route {}
// Before: docs only: array|string|\Stringable|null
/*
interface FooInterface {
public function getTitle(Request $request, Route $route);
}
*/
// If we use native typehints instead
interface FooInterface {
public function getTitle(Request $request, Route $route): null|array|string|\Stringable;
}
// This is an implementation written against the original, i.e. with no return types specified. We should not break it.
class SomeFoo implements FooInterface {
public function getTitle(Request $request, Route $route) {
return 'yay';
}
}
$test = new SomeFoo();
var_dump($test->getTitle(new Request(), new Route()));
Fatal error: Declaration of SomeFoo::getTitle(Request $request, Route $route) must be compatible with FooInterface::getTitle(Request $request, Route $route): Stringable|array|string|null in /in/WYop7 on line 18
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Parse error: syntax error, unexpected '|', expecting ';' or '{' in /in/WYop7 on line 13
Process exited with code 255.