function Node::assertArrayOf
Asserts that the given value is an array of defined type
@codeCoverageIgnore
Parameters
mixed $params Value to check:
string|array $classes Class or array of classes to check against:
bool $allowNull If true, null values are allowed:
Return value
void
23 calls to Node::assertArrayOf()
- ArrayExpression::setElements in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ ArrayExpression.php - Sets array elements
- ArrayPattern::setElements in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ ArrayPattern.php - Sets array elements
- BlockStatement::setBody in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ BlockStatement.php - Sets block's body
- CallExpression::setArguments in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ CallExpression.php - Sets the arguments array
- ClassBody::setBody in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ ClassBody.php - Sets class methods and properties
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Node/ Node.php, line 219
Class
- Node
- Base class for all the nodes generated by Peast.
Namespace
Peast\Syntax\NodeCode
protected function assertArrayOf($params, $classes, $allowNull = false) {
if (!is_array($classes)) {
$classes = array(
$classes,
);
}
if (!is_array($params)) {
$this->typeError($params, $classes, $allowNull, true);
}
else {
foreach ($params as $param) {
foreach ($classes as $class) {
if ($param === null && $allowNull) {
continue 2;
}
else {
$c = "Peast\\Syntax\\Node\\{$class}";
if ($param instanceof $c) {
continue 2;
}
}
}
$this->typeError($param, $classes, $allowNull, true, true);
}
}
}