Skip to content

Commit

Permalink
bug #24571 [PropertyInfo] Add support for the iterable type (dunglas)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.8 branch (closes #24571).

Discussion
----------

[PropertyInfo] Add support for the iterable type

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | reported on Slack
| License       | MIT
| Doc PR        | n/a

Add support for the `iterable` pseudo-type introduced in PHP 7.1.

Commits
-------

a73249d [PropertyInfo] Add support for the iterable type
  • Loading branch information
fabpot committed Oct 16, 2017
2 parents d04c0ea + a73249d commit 6b9850a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Symfony/Component/PropertyInfo/Tests/TypeTest.php
Expand Up @@ -37,6 +37,12 @@ public function testConstruct()
$this->assertEquals(Type::BUILTIN_TYPE_STRING, $collectionValueType->getBuiltinType());
}

public function testIterable()
{
$type = new Type('iterable');
$this->assertSame('iterable', $type->getBuiltinType());
}

/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage "foo" is not a valid PHP type.
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/PropertyInfo/Type.php
Expand Up @@ -27,6 +27,7 @@ class Type
const BUILTIN_TYPE_ARRAY = 'array';
const BUILTIN_TYPE_NULL = 'null';
const BUILTIN_TYPE_CALLABLE = 'callable';
const BUILTIN_TYPE_ITERABLE = 'iterable';

/**
* List of PHP builtin types.
Expand All @@ -43,6 +44,7 @@ class Type
self::BUILTIN_TYPE_ARRAY,
self::BUILTIN_TYPE_CALLABLE,
self::BUILTIN_TYPE_NULL,
self::BUILTIN_TYPE_ITERABLE,
);

/**
Expand Down Expand Up @@ -102,7 +104,7 @@ public function __construct($builtinType, $nullable = false, $class = null, $col
/**
* Gets built-in type.
*
* Can be bool, int, float, string, array, object, resource, null or callback.
* Can be bool, int, float, string, array, object, resource, null, callback or iterable.
*
* @return string
*/
Expand Down

0 comments on commit 6b9850a

Please sign in to comment.