com php-langspec: Add the `iterable` pseudo-type.: spec/09-lexical-structure.md spec/13-functions.md spec/19-grammar.md

From: Date: Fri, 02 Dec 2016 16:23:54 +0000
Subject: com php-langspec: Add the `iterable` pseudo-type.: spec/09-lexical-structure.md spec/13-functions.md spec/19-grammar.md
Groups: php.standards.cvs 
Request: Send a blank email to standards--cvs+get-371@lists.php.net to get a copy of this message
Commit: 248ec2865a64827570a6894c732f5e6b481e0d95 Author: Ivan Enderlin <ivan.enderlin@hoa-project.net> Fri, 2 Dec 2016 09:13:57 +0100 Committer: Nikita Popov <nikic@php.net> Fri, 2 Dec 2016 17:23:54 +0100 Parents: ae3a7639a05fae1cd1690ef28213bfebcb7d3af0 Branches: master Link: http://git.php.net/?p=php-langspec.git;a=commitdiff;h=248ec2865a64827570a6894c732f5e6b481e0d95 Log: Add the iterable pseudo-type. See https://wiki.php.net/rfc/iterable. Changed paths: M spec/09-lexical-structure.md M spec/13-functions.md M spec/19-grammar.md Diff: diff --git a/spec/09-lexical-structure.md b/spec/09-lexical-structure.md index ae8d4a2..7d11b77 100644 --- a/spec/09-lexical-structure.md +++ b/spec/09-lexical-structure.md @@ -355,7 +355,7 @@ Unless stated otherwise ([functions](13-functions.md#function-definitions), Names beginning with two underscores (__) are reserved by the PHP language and should not be defined by the user code. -The following names cannot be used as the names of classes, interfaces, or traits: bool, FALSE, float, int, NULL, string, TRUE, and void. +The following names cannot be used as the names of classes, interfaces, or traits: bool, FALSE, float, int, NULL, string, TRUE, iterable, and void. The following names are reserved for future use and should not be used as the names of classes, interfaces, or traits: mixed, numeric, object, and resource. diff --git a/spec/13-functions.md b/spec/13-functions.md index 4311b04..1d3ff81 100644 --- a/spec/13-functions.md +++ b/spec/13-functions.md @@ -79,6 +79,7 @@ return-type: type-declaration: 'array' 'callable' + 'iterable' scalar-type qualified-name @@ -124,6 +125,7 @@ default-argument-specifier: <i id="grammar-type-declaration">type-declaration:</i> array callable + iterable <i><a href="#grammar-scalar-type">scalar-type</a></i> <i><a href="09-lexical-structure.md#grammar-qualified-name">qualified-name</a></i> @@ -193,10 +195,12 @@ By default, a parameter will accept an argument of any type. However, by specifying a *type-declaration*, the types of argument accepted can be restricted. By specifying array, only an argument of the array type is accepted. By specifying callable, only an argument designating a -function (see below) is accepted. By specifying *qualified-name*, only an instance -of a class having that type, or being derived from that type, are -accepted, or only an instance of a class that implements that interface -type directly or indirectly is accepted. The check is the same as for [instanceof operator](10-expressions.md#instanceof-operator). +function (see below) is accepted. By specifying iterable, only an argument that +is of type array or an object implementing the Traversable interface is accepted. +By specifying *qualified-name*, only an instance of a class having that type, +or being derived from that type, are accepted, or only an instance of a class that +implements that interface type directly or indirectly is accepted. The check is the +same as for [instanceof operator](10-expressions.md#instanceof-operator). callable pseudo-type accepts the following: * A string value containing the name of a function defined at the moment of the call. diff --git a/spec/19-grammar.md b/spec/19-grammar.md index 53ec956..1975070 100644 --- a/spec/19-grammar.md +++ b/spec/19-grammar.md @@ -931,6 +931,7 @@ The grammar notation is described in [Grammars section](09-lexical-structure.md# <i id="grammar-type-declaration">type-declaration:</i> array callable + iterable <i><a href="#grammar-scalar-type">scalar-type</a></i> <i><a href="#grammar-qualified-name">qualified-name</a></i>

« previous php.standards.cvs (#371) next »