Skip to content

Commit 437578a

Browse files
committed
strict fixes
1 parent 30e76bc commit 437578a

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/PhpGenerator/Dumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function dumpArray(array &$var, array $parents, int $level, int $column)
110110
if (empty($var)) {
111111
return '[]';
112112

113-
} elseif ($level > $this->maxDepth || in_array($var, $parents ?? [], true)) {
113+
} elseif ($level > $this->maxDepth || in_array($var, $parents, true)) {
114114
throw new Nette\InvalidArgumentException('Nesting level too deep or recursive dependency.');
115115
}
116116

@@ -170,7 +170,7 @@ private function dumpObject($var, array $parents, int $level): string
170170
$arr = (array) $var;
171171
$space = str_repeat($this->indentation, $level);
172172

173-
if ($level > $this->maxDepth || in_array($var, $parents ?? [], true)) {
173+
if ($level > $this->maxDepth || in_array($var, $parents, true)) {
174174
throw new Nette\InvalidArgumentException('Nesting level too deep or recursive dependency.');
175175
}
176176

src/PhpGenerator/Extractor.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ public function extractAll(): PhpFile
164164
$phpFile = new PhpFile;
165165
$namespace = '';
166166
$visitor = new class extends PhpParser\NodeVisitorAbstract {
167+
public $callback;
168+
169+
167170
public function enterNode(Node $node)
168171
{
169172
return ($this->callback)($node);
@@ -399,7 +402,7 @@ private function setupFunction($function, Node\FunctionLike $node): void
399402
{
400403
$function->setReturnReference($node->returnsByRef());
401404
$function->setReturnType($node->getReturnType() ? $this->toPhp($node->getReturnType()) : null);
402-
foreach ($node->params as $item) {
405+
foreach ($node->getParams() as $item) {
403406
$param = $function->addParameter($item->var->name);
404407
$param->setType($item->type ? $this->toPhp($item->type) : null);
405408
$param->setReference($item->byRef);
@@ -412,8 +415,8 @@ private function setupFunction($function, Node\FunctionLike $node): void
412415
}
413416

414417
$this->addCommentAndAttributes($function, $node);
415-
if ($node->stmts) {
416-
$function->setBody($this->getReformattedContents($node->stmts, 2));
418+
if ($node->getStmts()) {
419+
$function->setBody($this->getReformattedContents($node->getStmts(), 2));
417420
}
418421
}
419422

src/PhpGenerator/Helpers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ final class Helpers
3737
'endforeach' => 1, 'declare' => 1, 'enddeclare' => 1, 'as' => 1, 'try' => 1, 'catch' => 1, 'finally' => 1,
3838
'throw' => 1, 'use' => 1, 'insteadof' => 1, 'global' => 1, 'var' => 1, 'unset' => 1, 'isset' => 1, 'empty' => 1,
3939
'continue' => 1, 'goto' => 1, 'function' => 1, 'const' => 1, 'return' => 1, 'print' => 1, 'yield' => 1, 'list' => 1,
40-
'switch' => 1, 'endswitch' => 1, 'case' => 1, 'default' => 1, 'break' => 1, 'array' => 1, 'callable' => 1,
40+
'switch' => 1, 'endswitch' => 1, 'case' => 1, 'default' => 1, 'break' => 1,
4141
'extends' => 1, 'implements' => 1, 'namespace' => 1, 'trait' => 1, 'interface' => 1, 'class' => 1, '__CLASS__' => 1,
4242
'__TRAIT__' => 1, '__FUNCTION__' => 1, '__METHOD__' => 1, '__LINE__' => 1, '__FILE__' => 1, '__DIR__' => 1,
43-
'__NAMESPACE__' => 1, 'fn' => 1, 'match' => 1, 'enum' => 1, 'static' => 1, 'abstract' => 1, 'final' => 1,
43+
'__NAMESPACE__' => 1, 'fn' => 1, 'match' => 1, 'enum' => 1, 'abstract' => 1, 'final' => 1,
4444
'private' => 1, 'protected' => 1, 'public' => 1, 'readonly' => 1,
4545

4646
// additional reserved class names

0 commit comments

Comments
 (0)