# Implicit Arrays and E_STRICT

- Thread: https://externals.io/message/9715
- Original archive: https://news-web.php.net/php.internals/9715
- Started by Sara Golemon on 2004-05-07T21:05:15+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9715 — Sara Golemon — 2004-05-07T21:05:15+00:00

URL: https://externals.io/message/9715#9715

This topic got quietly dropped last week, but I'd like to make one last
plea.  I'd like to see Zend throw an `E_STRICT` when arrays are implicitly
created.  I know there were objections to E_NOTICE, but did anyone have
violent objections to E_STRICT?

-Sara

---

## #9716 — Christian Schneider — 2004-05-07T22:26:06+00:00

URL: https://externals.io/message/9715#9716 · In reply to: #9715

Sara Golemon wrote:
> plea.  I'd like to see Zend throw an `E_STRICT` when arrays are implicitly
> created.  I know there were objections to E_NOTICE, but did anyone have
> violent objections to E_STRICT?

I guess the question is whether we want to deprecate the automatic array 
creation at some point as `E_STRICT` is meant for that case. Otherwise we 
are abusing `E_STRICT` and might render it unusable to some degree.

(From the description in the php.ini file `E_NOTICE` seems more 
appropriate as people who auto-init arrays probably also use 
uninitialized variables and thus don't use `E_NOTICE` anyway.)

My .02,
- Chris

---

## #9717 — Marcus Boerger — 2004-05-07T22:43:08+00:00

URL: https://externals.io/message/9715#9717 · In reply to: #9715

Hello Sara,

i like to see one of those too and i have no preference for one of them.

marcus

Friday, May 7, 2004, 11:05:15 PM, you wrote:

> This topic got quietly dropped last week, but I'd like to make one last
> plea.  I'd like to see Zend throw an `E_STRICT` when arrays are implicitly
> created.  I know there were objections to E_NOTICE, but did anyone have
> violent objections to E_STRICT?

> -Sara




-- 
Best regards,
 Marcus                            mailto:helly@php.net

---

## #9718 — John Coggeshall — 2004-05-07T23:08:56+00:00

URL: https://externals.io/message/9715#9718 · In reply to: #9716

> I guess the question is whether we want to deprecate the automatic array 
> creation at some point as `E_STRICT` is meant for that case. Otherwise we 
> are abusing `E_STRICT` and might render it unusable to some degree.

I was also under the impression that `E_STRICT` was for depreciated items.
If there is some sort of agreement that automagic array construction is
a bad thing*, then I believe it should be E_NOTICE.

John

* - Personally, I tend to disagree that there is a need for a warning,
it just seems like another difference between PHP 4 and PHP 5 that
really doesn't buy people much.


-- 
-=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=-
John Coggeshall                   http://www.coggeshall.org/
The PHP Developer's Handbook    http://www.php-handbook.com/
-=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=--=~=

---

## #9719 — Jason Garber — 2004-05-08T00:25:54+00:00

URL: https://externals.io/message/9715#9719 · In reply to: #9715

I would view implicit array creation as a slightly negative thing, similar 
to accessing the value of a variable that does not exist.

We run in `E_ALL` mode and write our code to avoid all E_NOTICEs.  For 
instance, before using an array, I always initialize it using $aItems = 
array();

I'm in favor of issuing an `E_NOTICE` in response to this.

~Jason

At 5/8/2004 12:43 AM +0200, Marcus Boerger wrote:
>Hello Sara,
>
>i like to see one of those too and i have no preference for one of them.
>
>marcus
>
>Friday, May 7, 2004, 11:05:15 PM, you wrote:
>
> > […]
>
> > […]
>
>
>
>
>--
>Best regards,
>  Marcus                            mailto:helly@php.net

---

## #9720 — Jevon Wright — 2004-05-08T01:25:48+00:00

URL: https://externals.io/message/9715#9720 · In reply to: #9719

Won't you then have to recursively initialise multiple dimension arrays?

$a = array();
$a[0] = array();

Otherwise, isn't this implicitly creating arrays? (I didn't quite understand
the last time)

Jevon

----- Original Message ----- 
From: "Jason Garber" <jason@ionzoft.com>
To: <internals@lists.php.net>
Sent: Saturday, May 08, 2004 12:25 PM
Subject: Re: [PHP-DEV] Implicit Arrays and `E_STRICT` 


> I would view implicit array creation as a slightly negative thing, similar
> to accessing the value of a variable that does not exist.
>
> We run in `E_ALL` mode and write our code to avoid all E_NOTICEs.  For
> instance, before using an array, I always initialize it using $aItems =
> array();
>
> I'm in favor of issuing an `E_NOTICE` in response to this.
>
> ~Jason
>
> At 5/8/2004 12:43 AM +0200, Marcus Boerger wrote:
> > […]
last
> > […]
implicitly
> > […]
have
> > […]

---

## #9722 — Sara Golemon — 2004-05-08T01:39:20+00:00

URL: https://externals.io/message/9715#9722 · In reply to: #9719

> > […]
last
> > […]
implicitly
> > […]
have
> > […]
> I would view implicit array creation as a slightly negative thing, similar
> to accessing the value of a variable that does not exist.
>
> We run in `E_ALL` mode and write our code to avoid all E_NOTICEs.  For
> instance, before using an array, I always initialize it using $aItems =
> array();
>
> I'm in favor of issuing an `E_NOTICE` in response to this.
>
As Andi stated in the earlier incarnation of this thread (I think it was
Andi), making an `E_NOTICE` will cause sudden errror generation in previously
 `E_ALL` safe code.

While I *personally* would rather see `E_NOTICE` used, I can certainly
understand the desire to tread lightly on what has long been considered a
"feature" of PHP.  That's why I think that `E_STRICT` qualifies as an
effective compromise between encouraging good coding practices and avoiding
BC breaking changes which add little to actual scrript execution.

-Sarra

---

## #9729 — Andi Gutmans — 2004-05-08T07:12:26+00:00

URL: https://externals.io/message/9715#9729 · In reply to: #9719

Hi Sara,

I don't think any error message should be thrown during implicit array 
creation. Not having to define your variables is one of the main principles 
of the PHP language. I definitely don't think this should be changed. I 
also don't see how this differs very much from a regular assignment to an 
undefined variable (e.g. $var = 2; ).

I think making this an error, even an `E_STRICT` is a very bad move.
Andi

At 06:39 PM 5/7/2004 -0700, Sara Golemon wrote:
> > […]
>last
> > […]
>implicitly
> > […]
>have
> > […]
>As Andi stated in the earlier incarnation of this thread (I think it was
>Andi), making an `E_NOTICE` will cause sudden errror generation in previously
>E_ALL safe code.
>
>While I *personally* would rather see `E_NOTICE` used, I can certainly
>understand the desire to tread lightly on what has long been considered a
>"feature" of PHP.  That's why I think that `E_STRICT` qualifies as an
>effective compromise between encouraging good coding practices and avoiding
>BC breaking changes which add little to actual scrript execution.
>
>-Sarra

---

## #9737 — Sara Golemon — 2004-05-08T16:42:50+00:00

URL: https://externals.io/message/9715#9737 · In reply to: #9729

> I don't think any error message should be thrown during implicit array
> creation. Not having to define your variables is one of the main
principles
> of the PHP language. I definitely don't think this should be changed. I
> also don't see how this differs very much from a regular assignment to an
> undefined variable (e.g. $var = 2; ).
>
It differs in that if $var is already defined, doing $var = 2; COMPLETELY
overwrites it.  However if $array is already defined, then $array[] ADDS to
it.  I see implicit array creation as "bad" in the same way that
register_globals is "bad".

That is to say, it's not inherently evil, just prone to unexpected behavior
when not used correctly.

> I think making this an error, even an `E_STRICT` is a very bad move.
>

Then we differ on that.  Because I think it would be a useful tool for
helping the conscientious scripter avoid little, but potentially harmful
mistakes.

-Sara
