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

Type hinting doesn’t work #2928

Closed
kinglozzer opened this issue Mar 6, 2014 · 4 comments
Closed

Type hinting doesn’t work #2928

kinglozzer opened this issue Mar 6, 2014 · 4 comments

Comments

@kinglozzer
Copy link
Member

Am I going mad?

Something.php

class Something {

    public function setFoo(array $foo) {
        var_dump($foo);die;
    }

}

Page.php

class Page_Controller extends ContentController {

    public function init() {
        $something = new Something();
        $something->setFoo('a string');
    }

}

Expected: fatal error. Actual: no error. If I try this outside of a SilverStripe install it errors as expected. Am I being incredibly dumb here?

@tractorcow
Copy link
Contributor

Silverstripe doesn't report E_RECOVERABLE_ERROR

See http://www.php.net/manual/en/errorfunc.constants.php

Not sure if this is desirable behaviour though; Certainly in a strict / dev environment, these should probably bubble up.

@kinglozzer
Copy link
Member Author

Thanks for the explanation @tractorcow, definitely think these should be visible in dev environments. If I’m understanding those PHP docs correctly, we should be passing this to Debug::fatalHandler(), right? As without an error handler to catch them, they’d be treated as an E_ERROR.

Is this just a simple patch here?

@micmania1
Copy link
Contributor

@kinglozzer that looks right.

@tractorcow Should we not have a default catch-all for any unrecognized errors? At the moment it looks like they would just be ignored (as is the case here).

kinglozzer added a commit to kinglozzer/sapphire that referenced this issue Mar 13, 2014
@simonwelsh
Copy link
Contributor

Fixed by 4544129

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

No branches or pull requests

4 participants