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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 10:01:32 2024 UTC