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

Unexpected exception when class wasn't loaded #3

Open
elicwhite opened this issue Apr 21, 2012 · 1 comment
Open

Unexpected exception when class wasn't loaded #3

elicwhite opened this issue Apr 21, 2012 · 1 comment

Comments

@elicwhite
Copy link
Contributor

So this is one of those cases where PHP is just plain weird / annoying.

In \Spot\Entity::fields($entityName) you have the check:

if(!is_subclass_of($entityName, '\Spot\Entity')) {
throw new \Spot\Exception($entityName . " must be subclass of '\Spot\Entity'.");
}

however, is_subclass_of() returns false if the class hasn't been loaded. I don't know if you care about this case, or how many different checks you'd have to add in all over the code to support it, but I just ran into this issue while trying to fix my autoloader's 5.3 support.

@vlucas
Copy link
Owner

vlucas commented Apr 23, 2012

Interesting. Definitely not the expected behavior, although it kinda makes sense - PHP can't know the class structure or parents until the class is loaded/included because of it's shared-nothing nature. I could add an additional check to see if the class has been loaded, but like you said -- I'm not sure how many other places I would have to add the check also. I'll think about it and take a look at the existing code a bit.

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