|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80620 feature request - List data types
Submitted: 2021-01-13 05:08 UTC Modified: 2021-01-13 23:29 UTC
From: fazedoutofturn at hotmail dot com Assigned:
Status: Not a bug Package: *Programming Data Structures
PHP Version: Next Major Version OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: fazedoutofturn at hotmail dot com
New email:
PHP Version: OS:


 [2021-01-13 05:08 UTC] fazedoutofturn at hotmail dot com
This is my first time requesting for a PHP feature or using this report system. But since PHP 8 has been released, could we get List data types? We already have scalar data type declarations now. It would be nice to have other data types that other languages has as well. Arrays are nice, but having Lists would make PHP head towards a more consistent OOP language.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-13 06:54 UTC]
-Status: Open +Status: Not a bug
 [2021-01-13 06:54 UTC]
See the proposal for the "array_is_list" function, and related messages on the internal mailing list.
 [2021-01-13 23:07 UTC] fazedoutofturn at hotmail dot com

Well, what I mean is an actual List data type or a List object data type. Reading the link you gave me, it pertains to just arrays. So basically pluralizing objects. What I am talking about is something like this as an example (not working for obvious reasons).


class Author {

	public function __construct(public string $first_name = '', public string $middle_name = '', public string $last_name = '') {



List<Author> $authors = new List<Author>();
$authors->add(new Author('Courtney', '', 'Peppernell'));
$authors->add(new Author('William', '', 'Shakespeare'));
$authors->add(new Author('Claudia', '', 'Rankine'));
$authors->add(new Author('Jacqueline', '', 'Woodson'));
$authors->add(new Author('Edgar', 'Allan', 'Poe'));

// Would give you a list of authors as such
// List <Courtney Peppernell>, <William Shakespeare>, <Claudia Rankine>, <Jacqueline Woodson>, <Edgar Allan Poe>


Since PHP has already adopted "some" of Java's OOP, why can't we just adopt everything? Most languages have List data types so why can't PHP? I know people will say arrays are enough, but having a consistency in OOP would help people move around languages to languages more. Plus, it sort of seems PHP is heading that way anyways where everything is more strictly typed.
 [2021-01-13 23:29 UTC]
Sounds like you want SplDoublyLinkedList.

Queue or Stack could be more appropriate for your use case.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 19 06:01:29 2024 UTC