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

No error on class not found #69

Closed
nmsobri opened this issue Dec 6, 2013 · 3 comments
Closed

No error on class not found #69

nmsobri opened this issue Dec 6, 2013 · 3 comments
Assignees

Comments

@nmsobri
Copy link

nmsobri commented Dec 6, 2013

Take from the doc:

class Greeting {
    public static function hello() {
        echo 'hello world!';
    }
}

Flight::route('/', array('Greetings','hello')); #notice the 's' at the end

Flight will output nothing, should have throw error/exception class not found..

@nmsobri
Copy link
Author

nmsobri commented Dec 7, 2013

Possible solution

    #Loader::loadClass
    public static function loadClass($class) {
        $class_file = str_replace('\\', '/', str_replace('_', '/', $class)).'.php';

        foreach (self::$dirs as $dir) {
            $file = $dir.'/'.$class_file;
            if (file_exists($file)) {
                require $file;
                return;
            }
        }
        trigger_error(sprintf('Class %s not found', $class), E_USER_ERROR); #handle class not found
        # throw new \ErrorException(sprintf('Class %s not found', $class), E_USER_ERROR);
    }

@mikecao
Copy link
Collaborator

mikecao commented Dec 8, 2013

Flight intentionally does not throw an error when it can't find a class. This is because PHP class_exists function tries to autoload class by default and throwing an error causes issues with third party libraries. This seems like more of an issue with the router or dispatcher. I'll take a look.

@ghost ghost assigned mikecao Dec 8, 2013
@mikecao
Copy link
Collaborator

mikecao commented Dec 19, 2013

Now fixed in commit 6696c0d. It should now throw an exception for invalid callbacks.

@mikecao mikecao closed this as completed Dec 19, 2013
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