Doc #77323 [NEW]: Since 7.1 $var[] = 'entry'; throws Fatal. This is unclear in the docs.

From: Date: Thu, 20 Dec 2018 10:43:50 +0000
Subject: Doc #77323 [NEW]: Since 7.1 $var[] = 'entry'; throws Fatal. This is unclear in the docs.
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16223@lists.php.net to get a copy of this message
From:             powtac at gmx dot de
Operating system: linux
PHP version:      7.1.25
Package:          Documentation problem
Bug Type:         Documentation Problem
Bug description:Since 7.1 $var[] = 'entry'; throws Fatal. This is unclear in the docs.

Description:
------------
---
From manual page: https://php.net/function.array-push
---

Despite the note in the documentation "Note: array_push() will raise a
warning if the first argument is not an array. This differs from the
$var[] behaviour where a new array is created.",  this is not correct
for PHP >= 7.1 where a Fatal Error is thrown when the variable is a
empty string.

See https://3v4l.org/SPBA6

Test script:
---------------
$var = '';
$var[] = 'make me an array';

Expected result:
----------------
According to the docs a new array should be created. 

Actual result:
--------------
Fatal error: Uncaught Error: [] operator not supported for strings in
/in/SPBA6:5 Stack trace: #0 {main} thrown in /in/SPBA6 on line 5
Process exited with code 255.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=77323&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=77323&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=77323&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=77323&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=77323&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=77323&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=77323&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=77323&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=77323&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=77323&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=77323&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=77323&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=77323&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=77323&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77323&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=77323&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=77323&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=77323&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77323&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=77323&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=77323&r=mysqlcfg



Thread (4 messages)

« previous php.doc.bugs (#16223) next »