<?php
namespace A {
class T {}
}
namespace {
class Test
{
public function first(string $str) : Closure
{
return function() use ($str) : int {
return strlen($str);
};
}
public function second(): self
{
return self;
}
}
$t = new Test;
echo ($t->second()->first("hello"))();
}
Fatal error: Uncaught Error: Undefined constant "self" in /in/mToOC:19
Stack trace:
#0 /in/mToOC(24): Test->second()
#1 {main}
thrown in /in/mToOC on line 19
Process exited with code 255.
Warning: Use of undefined constant self - assumed 'self' (this will throw an Error in a future version of PHP) in /in/mToOC on line 19
Fatal error: Uncaught TypeError: Return value of Test::second() must be an instance of Test, string returned in /in/mToOC:19
Stack trace:
#0 /in/mToOC(24): Test->second()
#1 {main}
thrown in /in/mToOC on line 19
Process exited with code 255.
Output for 7.0.0 - 7.0.31, 7.1.0 - 7.1.23
Notice: Use of undefined constant self - assumed 'self' in /in/mToOC on line 19
Fatal error: Uncaught TypeError: Return value of Test::second() must be an instance of Test, string returned in /in/mToOC:19
Stack trace:
#0 /in/mToOC(24): Test->second()
#1 {main}
thrown in /in/mToOC on line 19
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/mToOC on line 10
Process exited with code 255.