|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2021-01-13 05:08 UTC] fazedoutofturn at hotmail dot com
 Description: ------------ 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. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 23:00:01 2025 UTC | 
@requinix 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). ------ <?php 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> print_r($authors); ------ 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.