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.
"use strict";
var_dump(FOOBAR); // should throw an exception, undefined constant.
Good idea?
Cheers,
César D. Rodas
Open Source developer
+595-983-161124
PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6
Hi Cesar,
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.
"use strict"; var_dump(FOOBAR); // should throw an exception, undefined constant.
We have error_reporting INI for this purpose.
Users may be strict or lazy for errors by the INI setting.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi Cesar,
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.
"use strict"; var_dump(FOOBAR); // should throw an exception, undefined constant.
We have error_reporting INI for this purpose.
Users may be strict or lazy for errors by the INI setting.
I don't think it's a good idea to have a strict mode at all. I'd prefer
any language to be strict and unambiguous enough from the start. Adding
strict mode after the fact is just a band aid. PHP's error reporting
level isn't that bad, but if you're ignoring legacy code there's hardly
a reason not to develop to the strictest standard possible.
~Florian
Hi,
Hi Cesar,
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.
"use strict"; var_dump(FOOBAR); // should throw an exception, undefined constant.
We have error_reporting INI for this purpose.
Users may be strict or lazy for errors by the INI setting.I don't think it's a good idea to have a strict mode at all. I'd prefer
any language to be strict and unambiguous enough from the start. Adding
strict mode after the fact is just a band aid. PHP's error reporting
level isn't that bad, but if you're ignoring legacy code there's hardly
a reason not to develop to the strictest standard possible.~Florian
--
I agree. Use error handlers.
--
Andrea Faulds
http://ajf.me/
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.
"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