Re: Is it a good idea to have a "strict" mode?

From: Date: Fri, 30 Jan 2015 10:46:28 +0000
Subject: Re: Is it a good idea to have a "strict" mode?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-81421@lists.php.net to get a copy of this message
On Fri, Jan 30, 2015 at 6:16 AM, César Rodas <cesar@rodas.me> wrote: > Hi! > > I'm wondering if it would be a good idea to have a strict > mode in PHP. > Many language have them and it is a good idea. > > I think it should be a bit different in PHP, it should encourage the > following things: > > - Avoid deprecated things, it should throw an exception. > - Avoid explicit conversions of undefined constants to strings. > - Anything else that could make run-time slower *or* bad practice. > > ```php > "use strict"; > > var_dump(FOOBAR); // should throw an exception, undefined constant. > ``` > > Good idea? > This has already been debated. Use error_reporting instead. If you write "use strict;" in PHP, you'll hit a meaningful error message btw ;-) Also, syntax checks, etc... is the job of your IDE. Mine already tells me many things about unused variables, etc... Julien P

« previous php.internals (#81421) next »