Skip to content

Cannot override final method ReflectionMethod::toString() #3053

@mnapoli

Description

@mnapoli

I think this is a Zend incompatibility.

interface MyReflectionInterface
{
    public function toString();
}

class MyReflectionMethod extends ReflectionMethod implements ReflectionInterface
{
    public function toString()
    {
        return parent::__toString();
    }
}

I get:

Fatal error: Cannot override final method ReflectionMethod::toString()

If I remove the toString() implementation, then both Zend PHP and HHVM fail:

  • HHVM: "Fatal error: Access level to MyMethodReflection::toString() must be public"
  • PHP: "Fatal error: Class Zend\Code\Reflection\MethodReflection contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Zend\Code\Reflection\ReflectionInterface::toString)"

This is an issue in Zend Framework 2: zendframework/zendframework#6418

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions