php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80133 Allow reserved word 'list' to be used for namespaces (and classnames)
Submitted: 2020-09-22 14:55 UTC Modified: 2020-09-30 13:39 UTC
From: flexjoly at vfweb dot nl Assigned: cmb (profile)
Status: Closed Package: Class/Object related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: flexjoly at vfweb dot nl
New email:
PHP Version: OS:

 

 [2020-09-22 14:55 UTC] flexjoly at vfweb dot nl
Description:
------------
Hi,

That 'list' is a reserved word is understandable. But also very annoying. For you need it a lot. Almost any crud has one or more lists.

I have (abstract base) classes like:
\data\data\Data
\data\data\DataInterface
\data\data\DataFactory

\data\record\Record
\data\record\RecordInterface
\data\record\RecordFactory

and I need:
\data\list\List (or \data\list\ListData)
\data\list\ListInterface
\data\list\ListFactory

But those are impossible.....
So instead of list we now use: listdata\ListData
Which is not consistent in our way of naming.

Now I wanted to make:
\import\list\ImportList

But even this is impossible. 


https://www.php.net/manual/en/reserved.keywords.php
Since 7.0 many "keywords are allowed as property, constant, and method names".

It would be so nice if they would also be allowed as namespace. 

Greetz, flexjoly









Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-22 15:04 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2020-09-22 15:04 UTC] cmb@php.net
You can use `list` as part of a namespace name as of PHP 8.0.0[1].
Using the keyword as standalone classname can't be supported,
though.

[1] <https://3v4l.org/hkth0>
 [2020-09-25 12:48 UTC] flexjoly at vfweb dot nl
-Summary: Allow reserved word 'list' to be used for namespaces (and classnames) +Summary: Please add late-defining for class constants -PHP Version: Next Minor Version +PHP Version: Irrelevant
 [2020-09-25 12:48 UTC] flexjoly at vfweb dot nl
That is great news!
Thanks!
 [2020-09-30 13:39 UTC] flexjoly at vfweb dot nl
-Summary: Please add late-defining for class constants +Summary: Allow reserved word 'list' to be used for namespaces (and classnames) -Package: *General Issues +Package: Class/Object related
 [2020-09-30 13:39 UTC] flexjoly at vfweb dot nl
Title and package were wrongly changed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 03:01:27 2024 UTC