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] Fatal error: During class fetch / Missing Warnings #2435

Open
Fenikkusu opened this issue Aug 22, 2024 · 0 comments
Open

[BUG] Fatal error: During class fetch / Missing Warnings #2435

Fenikkusu opened this issue Aug 22, 2024 · 0 comments

Comments

@Fenikkusu
Copy link
Contributor

Fenikkusu commented Aug 22, 2024

use Statements are not getting checked for existence during the Generation step. This can create issues where you will get a fatal error During class fetch. I noticed this specifically when working with error exceptions.

namespace My\Stuff;

use Throwable;
use Phalcon\Views\Exception as ViewException // Note the misspelling
use Phalcon\Di\Injectable;
use Phalcon\Events\EventInterface;
use Phalcon\Dispatcher\DispatcherInterface;

class Listener extends Injectable
{
    public function beforeException(<EventInterface> event, <DispatcherInterface> dispatcher, <Throwable> exception)
    {
        try {
            throw exception;
        } catch ViewException {
            throw new \Exception("Reached");
        } catch Error {
           // Never Reached
        }
    }
}

In the psudo code above, I am referencing the wrong path for the exception (note the extra 's'). When the throw occurs in the beforeException method, it will cause the fatal error During class fetch with no other details. Normally I would not bother creating an issue for this, except that I have no warnings in the Generate step indicating that the Class doesn't exist at compile time. It took me the better part of several hours to understand what was the issue and a lot of commenting out of code sections.

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

1 participant