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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michael dot vorisek at email dot cz
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Sun Apr 11 05:01:24 2021 UTC