Req #69914 [Nab->Opn]: Not possible to specify array type as a return type

[email protected]
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=69914&edit=1

 ID:                 69914
 Updated by:         [email protected]
 Reported by:        tim dot bezhashvyly at gmail dot com
 Summary:            Not possible to specify array type as a return type
-Status:             Not a bug
+Status:             Open
 Type:               Feature/Change Request
 Package:            PHP Language Specification
 Operating System:   Debian GNU/Linux 8
-PHP Version:        7.0.0alpha1
+PHP Version:        7.1+
 Block user comment: N
 Private report:     N

 New Comment:

Hi Tim!

Sadly this was not covered by the Return Types RFC: https://wiki.php.net/rfc/return_types

It is too late to cover for 7.0 now, hence the updated 'version' field in this report. I suggest you mail the internals mailing list for some debate or create an RFC for this once 7.0 have been released and developments began to focus 7.1


Previous Comments:
------------------------------------------------------------------------
[2015-06-23 19:09:40] [email protected]

There is no such thing as a typed array.

------------------------------------------------------------------------
[2015-06-23 19:04:51] tim dot bezhashvyly at gmail dot com

Description:
------------
Specifying specific array type as a return type of a method/function produces a syntax error.

Test script:
---------------
function foo(): string[]
{
    return ['bar'];
}

Actual result:
--------------
Parse error: syntax error, unexpected '[', expecting ';' or '{' in ...


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69914&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.