Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Call to member function isAbstract on null in mappedEventSubscriber doctrine:generate:entities #177

Closed
manticorp opened this issue Sep 7, 2016 · 2 comments

Comments

@manticorp
Copy link

Please prefix your issue with one of the following: [BUG] [PROPOSAL] [QUESTION].

Package version, Laravel version

1.2
5.3

Expected behaviour

Generates entities

Actual behaviour

Throws up the error in title

Steps to reproduce the behaviour

run php artisan doctrine:generate:entities

This seems to be related to the following issue filed on the doctrine github:

doctrine/orm#4459

and the following pull request:

doctrine/orm#1345

The generate:entities command uses the DisconnectedClassMetadataFactory and so getReflectionClass isn't guaranteed to return anything and can be null, as such the following lines in LaravelDoctrine\ACL\Mappings\Subscribers\MappedEventSubscriber should be changed:

From:

    /**
     * A MappedSuperClass or Abstract class cannot be instantiated.
     *
     * @param ClassMetadata $metadata
     *
     * @return bool
     */
    protected function isInstantiable(ClassMetadata $metadata)
    {
        if ($metadata->isMappedSuperclass) {
            return false;
        }

        if ($metadata->getReflectionClass()->isAbstract()) {
            return false;
        }

        return true;
    }

To:

    /**
     * A MappedSuperClass or Abstract class cannot be instantiated.
     *
     * @param ClassMetadata $metadata
     *
     * @return bool
     */
    protected function isInstantiable(ClassMetadata $metadata)
    {
        if ($metadata->isMappedSuperclass) {
            return false;
        }

        if (!$metadata->getReflectionClass() || $metadata->getReflectionClass()->isAbstract()) {
            return false;
        }

        return true;
    }

I've tried it and it seems to work fine after that - but I don't know if this will affect anything else internally.

@patrickbrouwers
Copy link
Contributor

Could you do those changes in a PR, that's easier for me to look at it / test it. Thanks.

@manticorp
Copy link
Author

Ack really sorry, this was meant for acl not orm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants