Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6029947
IterableType.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
IterableType.php
View Options
<?php
declare
(
strict_types
=
1
);
/*
* This file is part of sebastian/type.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
SebastianBergmann\Type
;
use
function
assert
;
use
function
class_exists
;
use
function
is_iterable
;
use
ReflectionClass
;
use
ReflectionException
;
final
class
IterableType
extends
Type
{
/**
* @var bool
*/
private
$allowsNull
;
public
function
__construct
(
bool
$nullable
)
{
$this
->
allowsNull
=
$nullable
;
}
/**
* @throws RuntimeException
*/
public
function
isAssignable
(
Type
$other
):
bool
{
if
(
$this
->
allowsNull
&&
$other
instanceof
NullType
)
{
return
true
;
}
if
(
$other
instanceof
self
)
{
return
true
;
}
if
(
$other
instanceof
SimpleType
)
{
return
is_iterable
(
$other
->
value
());
}
if
(
$other
instanceof
ObjectType
)
{
$className
=
$other
->
className
()->
qualifiedName
();
assert
(
class_exists
(
$className
));
try
{
return
(
new
ReflectionClass
(
$className
))->
isIterable
();
// @codeCoverageIgnoreStart
}
catch
(
ReflectionException
$e
)
{
throw
new
RuntimeException
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
(),
$e
);
// @codeCoverageIgnoreEnd
}
}
return
false
;
}
public
function
name
():
string
{
return
'iterable'
;
}
public
function
allowsNull
():
bool
{
return
$this
->
allowsNull
;
}
/**
* @psalm-assert-if-true IterableType $this
*/
public
function
isIterable
():
bool
{
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 4 2026, 17:40 (5 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
67/12/aa083952f242180834b538c53956
Default Alt Text
IterableType.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment