Skip to content

Commit 8129cc6

Browse files
Compatibility fixes for new versions of PHPStan and Nette
1 parent f8ef20f commit 8129cc6

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"require": {
88
"php": ">=7.4 <8.4",
99
"ext-json": "*",
10-
"ext-random": "*",
1110
"phpstan/phpstan": "^1.12.13",
1211
"phpstan/phpstan-nette": "^1.2.6",
1312
"latte/latte": "^2.11.6 | ^3.0.4",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ parameters:
7272
path: src/Compiler/Compiler/AbstractCompiler.php
7373

7474
-
75-
message: '#^Parameter \#1 \$value of static method PhpParser\\BuilderHelpers\:\:normalizeValue\(\) expects array\|bool\|float\|int\|PhpParser\\Node\\Expr\|string\|UnitEnum\|null, mixed given\.$#'
75+
message: '#^Parameter \#1 \$value of static method PhpParser\\BuilderHelpers\:\:normalizeValue\(\) expects .*, mixed given\.$#'
7676
path: src/LinkProcessor/LinkParamsProcessor.php
7777
-
7878
messages:

src/Compiler/NodeVisitor/LinkNodeVisitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use PhpParser\Node\Expr\PropertyFetch;
2121
use PhpParser\Node\Expr\StaticCall;
2222
use PhpParser\Node\Name;
23-
use PhpParser\Node\Scalar\LNumber;
23+
use PhpParser\Node\Scalar\String_;
2424
use PhpParser\Node\Stmt\Echo_;
2525
use PhpParser\Node\Stmt\If_;
2626
use PhpParser\NodeVisitorAbstract;
@@ -143,7 +143,7 @@ private function prepareNodes(MethodCall $methodCall, array $attributes): ?array
143143
}
144144

145145
return [
146-
new If_(new Identical(new FuncCall(new Name('mt_rand')), new LNumber(0)), [
146+
new If_(new Identical(new FuncCall(new Name('uniqid')), new String_('random')), [
147147
'stmts' => $expressions,
148148
], $attributes),
149149
];

src/Error/ErrorBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ final class ErrorBuilder
5353
'/Cannot call method endTag\(\) on Nette\\\\Utils\\\\Html\|string\./', // nette/forms error https://github.com/nette/forms/issues/308
5454
'/Variable .* on left side of \?\?= is never defined./',
5555
'/Variable .* on left side of \?\?= always exists and is not nullable./',
56+
'/Property Latte\\\\Runtime\\\\Template::\$parentName .* does not accept mixed./',
5657
];
5758

5859
/** @var string[] */

tests/Rule/LatteTemplatesRule/PresenterWithoutModule/Fixtures/VariablesPresenter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function actionDefault(): void
5252
$this->template->someOtherVariableWithDefault = 'value from presenter';
5353

5454
$this->template->nullOrUrl = null;
55-
if (mt_rand()) {
55+
if (uniqid() == 'random') {
5656
$this->template->nullOrUrl = 'https://example.org';
5757
}
5858
}

tests/Rule/LatteTemplatesRule/PresenterWithoutModule/LatteTemplatesRuleForPresenterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ public function testFilters(): void
978978
} else {
979979
$expectedErrors[] = [
980980
'Syntax error, unexpected \')\'',
981-
2,
981+
-1,
982982
'translate_new.latte',
983983
];
984984

0 commit comments

Comments
 (0)