Type hinting doesn’t work #2928

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

Comments

Projects
None yet
4 participants
Owner

kinglozzer commented Mar 6, 2014

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?

Contributor

tractorcow commented Mar 6, 2014

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.

Owner

kinglozzer commented Mar 7, 2014

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?

Member

micmania1 commented Mar 7, 2014

@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 simonwelsh added the master label Mar 15, 2014

Contributor

simonwelsh commented Mar 15, 2014

Fixed by 4544129

@simonwelsh simonwelsh closed this Mar 15, 2014

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