Boris Veriga
Boris Veriga

Reputation: 197

Class that extends itself. Symfony docs

Few mounts ago I decided to learn PHP and Symfony framework,so I'm quite new in this language and instrument. I know all basic principles of OOP-principles, PHP syntax and another different interesting stuff. When I started to read Symfony docs, about Profiler->Data Collectors, here is the URL: https://symfony.com/doc/current/service_container/tags.html. After a few minutes of reading, I meet code like this :

// src/Kernel.php
class Kernel extends Kernel
{
    // ...

    protected function build(ContainerBuilder $container)
    {
        $container->registerForAutoconfiguration(CustomInterface::class)
            ->addTag('app.custom_tag')
        ;
    }
}

As I know inheritance prohibit extending like this. So when I trying to wrote this code in PhpStorm, he gives out next error: "Class should extend dby itself". How can one class extend by himself? And why do I need this opportunity?Or it's just mistake in docs?

Upvotes: 1

Views: 108

Answers (1)

Misbah
Misbah

Reputation: 36

I think,that just mistake, maybe he want to write like this

use Symfony\Component\HttpKernel\Kernel as BaseKernel;

class Kernel extends BaseKernel
{
    //....
}

Upvotes: 2

Related Questions