[RFC] E_NOTICE for invalid array container

From: Date: Sun, 31 Jul 2016 19:31:16 +0000
Subject: [RFC] E_NOTICE for invalid array container
Groups: php.internals 
Request: Send a blank email to internals+get-94768@lists.php.net to get a copy of this message
Hi All, I'm attempting to get involved and hack away at some internals; I figured the best method to do this would be to pick up a bug and do my best at it. So I grabbed #37676. The issue asks to implement an E_(NOTICE|WARNING) when attempting to access scalar values as arrays. cmb alerted me to a long thread that came up last year ( http://marc.info/?t=143379796900001&r=1&w=2). I've read over it and the couple of other PR's that attempted to resolve this issue. As I read, the couple of major complaints about adding an E_NOTICE were that multiple-accesses in a set (i.e. $a=false;$a[1][2][3];) would produce too many errors. Matt <http://marc.info/?l=php-internals&m=143384434418881&w=2> raised this issue, in addition to it only being raised for non-null issues; having NULL be an 'identity' of sort that any array access on a NULL is NULL. I agree with him in part, and oppose in others. I think that original access to a NULL should be treated as accessing any scalar value, however I do agree that multiple notices would be bad. Rowan <http://marc.info/?l=php-internals&m=143385309121593&w=2> has also presented his thoughts to the same, and this implementation takes into account his solution where we don't raise much. Christoph <http://marc.info/?l=php-internals&m=143385339521672&w=2> countered that: ``$o->foo->bar`` would itself raise two notices rather than one. I would present that that behavior should be pruned itself. Object access on a null should alert, but subsequent calls ought not to (I don't know how to prevent that, but then again I haven't learned). So I want to solicit for more discussion given previous talks. My first-attempt RFC for this is at: https://wiki.php.net/rfc/notice-for-non-valid-array-container -- Dave ps: this is my first attempt here at an RFC solo, and preemptively apologize if anything deviates from the norm too far, did my best to follow all them how-to's.

« previous php.internals (#94768) next »