php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78508 PHP does not emit a warning when some types are accessed with an index
Submitted: 2019-09-07 09:06 UTC Modified: 2019-09-07 09:10 UTC
From: michael dot vorisek at email dot cz Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 7.3.9 OS: Linux
Private report: No CVE-ID: None
 [2019-09-07 09:06 UTC] michael dot vorisek at email dot cz
Description:
------------
I found out that current PHP does not emit warnings at least for the following expressions:

a) if boolean is accessed with index:
  false['x']

b) if null is accessed with index:
  null['x']

in contrary with string type, which emits the following message:
Warning: Illegal string offset 'x'...
Notice: Uninitialized string offset: 0

I would expect PHP to emit at least Notice warning.

Is this a bug which needs to be addressed or is this an intended behaviour for some use case/backcompatibility that requires no warning?

Test script:
---------------
see desc.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-07 09:10 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2019-09-07 09:10 UTC] nikic@php.net
A notice for this has already been added in PHP 7.4.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC