Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Suggestion: Base Class Extending #94

@Garethp

Description

@Garethp

One of the modifications I made in my code, that I thought might be a good idea in general, was a way to have a base class for all items. So I put this at the top of ClassGenerator::generate()

        if (!($extends = $type->getExtends()) && class_exists($type->getNamespace())) {
            $extendNamespace = $type->getNamespace();
            $extendNamespace = explode('\\', $extendNamespace);
            $extendClass = array_pop($extendNamespace);
            $extendNamespace = implode('\\', $extendNamespace);

            $extends = new PHPClass();
            $extends->setName($extendClass);
            $extends->setNamespace($extendNamespace);

            $class->setExtendedClass($extends);
        }

So basically if I'm putting all of my elements in the \Some\Namespace\Types\ namespace, and the class \Some\Namespace\Type exists, then all classes generated should extend from that in one way or another. I don't know if you want to incorporate this idea in some way, but I found it a nice thing for myself

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions