An alias (%s) was defined for method %s(), but this method does not exist

Description

When importing methods from a trait, it is possible to create a method alias: give a new name to the trait method, when it is inside a class.

PHP checks that the orginal method exists, before allocating the new name. When the original method doesn’t exist, PHP emits this error message.

Example

<?php

trait T {}

class X {
    use T {
        foo as bar;
    }
}
?>

Literal Examples

  • An alias (bar) was defined for method foo(), but this method does not exist

Solutions

  • Check the name of the orginal method for typos.

  • Add the missing method in the trait.

  • Remove the alias.

  • Remove the method with the same name in the class, and remove the alias.