Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Martin Scotta
It seems that there are no consensus about this feature so... *if in doubt, leave it out.* Martin Scotta On Mon, Apr 11, 2011 at 5:09 PM, Chris Stockton wrote: > Hello, > > On Mon, Apr 11, 2011 at 11:47 AM, Matthew Weier O'Phinney > wrote: > > On 2011-04-11, Stas Malyshev wrote: > >> > I m

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Chris Stockton
Hello, On Mon, Apr 11, 2011 at 11:47 AM, Matthew Weier O'Phinney wrote: > On 2011-04-11, Stas Malyshev wrote: >> > I might come off rather crumudgeonly here, but these last few >> > threads I've seen going across to silence notices have a common >> > theme - "I wanna be a lazier coder." My sugg

Re: [PHP-DEV] Avoiding "Undefined index" notices

2011-04-11 Thread Etienne Kneuss
On Apr 11 12:08:15, Todd Ruth wrote: > I'm not arguing whether the following code fragment is good > or bad (it's certainly less than ideal), but given the recent > threads, I thought I'd show how I feel I've been encourage by > php to code: > > $x = array(); > $y = 'something'; > $temp =& $x[$

Re: [PHP-DEV] Avoiding "Undefined index" notices

2011-04-11 Thread Etienne Kneuss
On Apr 11 14:14:40, Matt Wilson wrote: > Something I've been doing for a long time is similar, but in my opinion a > much better practice. > > function coalesce(&$val, $ifnull = false) > { > return empty($val) ? $ifnull : $val; > } > > Add whatever restrictive logic you wish here, if empty

Re: [PHP-DEV] Avoiding "Undefined index" notices

2011-04-11 Thread Matt Wilson
Something I've been doing for a long time is similar, but in my opinion a much better practice. function coalesce(&$val, $ifnull = false) { return empty($val) ? $ifnull : $val; } Add whatever restrictive logic you wish here, if empty() isn't good enough for your purposes. $_GET['might

[PHP-DEV] Avoiding "Undefined index" notices

2011-04-11 Thread Todd Ruth
I'm not arguing whether the following code fragment is good or bad (it's certainly less than ideal), but given the recent threads, I thought I'd show how I feel I've been encourage by php to code: I'm not sure where (if anywhere) that technique is documented or even if it should be documented,

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Matthew Weier O'Phinney
On 2011-04-11, Stas Malyshev wrote: > > I might come off rather crumudgeonly here, but these last few > > threads I've seen going across to silence notices have a common > > theme - "I wanna be a lazier coder." > > Laziness is a virtue for a coder :) At least, when it goes to avoid > unnecessary w

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Stas Malyshev
Hi! I might come off rather crumudgeonly here, but these last few threads I've seen going across to silence notices have a common theme - "I wanna be a lazier coder." Laziness is a virtue for a coder :) At least, when it goes to avoid unnecessary work - in this example, boilerplate code. W

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Pascal COURTOIS
Le 11/04/2011 19:17, Michael Morris a écrit : > But don't ask the engine to be rewritten to encourage bad coding practices > which failing to properly initialize variables is a prime example of. It's > this sort of thinking that got register_globals and magic_quotes put into > the language no doub

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Michael Morris
I might come off rather crumudgeonly here, but these last few threads I've seen going across to silence notices have a common theme - "I wanna be a lazier coder." Which is fine - set the PHP error level to not show them. But don't ask the engine to be rewritten to encourage bad coding practices w

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Etienne Kneuss
On Apr 10 21:22:58, D. Dante Lorenso wrote: > The problem with implementing "ifsetor", "filled", or "??" in userland > is that the "not set" or "undefined" warning is fired before the > variable is passed to the underlying function/method. > > Is it possible to add a modifier that turns off warn

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Ben Schmidt
If doing the suppression of undefined notices be better if the ? was put after the opening square bracket, thereby removing the ambiguity (which I think would be more troublesome than you think)? $array[?"foo"] I suppose a non-array-specific version would be to put it after the $. $?variable $

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Ben Schmidt
I think another problem with using @ is that it is done by the caller, not the callee, so it doesn't allow functions like issetor() to be implemented in userland without expecting every caller to do pass the variable while silencing errors. I also don't think the inconvenience is restricted to ar

Re: [PHP-DEV] proposed access modifier "silent" ... was: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator

2011-04-11 Thread Hannes Landeholm
@ is not convenient since it turns off error reporting for all errors. I don't know how many times I've silenced a notice and got a blank page in my face as a "thank you for accidentally silencing that fatal error too". "Silent" is reserved for the purpose of the silence operator though @ so using