Skip to content

Instantly share code, notes, and snippets.

@iggyvolz

iggyvolz/README Secret

Last active Jun 22, 2021
Embed
What would you like to do?
Run php b.php; returns:
Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../b.php on line 19
Should return something like:
Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../b.php on line 5
Or:
Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../myTrait.php on line 19
Or:
Fatal error: Declaration of myTrait::foo(): string must be compatible with a::foo(): int in .../b.php on line 5, from trait on .../myTrait.php on line 19
<?php
class a {
public function foo(): int {return 2;}
}
<?php
require_once "a.php";
require_once "myTrait.php";
class b extends a {
use myTrait;
}
<?php
// there
// are
// some
// lines
// here
// to
// show
// that
// the
// error
// uses
// this
// file's
// line
// number
trait myTrait
{
public function foo(): string {return "oops";}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment