Skip to content

Commit cc7d94b

Browse files
committed
#84 - Workaround PHPStan 2.x bug: Remove readonly from factory property
1 parent 8145b05 commit cc7d94b

2 files changed

Lines changed: 7 additions & 23 deletions

File tree

.github/workflows/phpstan.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ jobs:
4747
php-version: "8.4"
4848
extensions: mbstring, intl, gd, xml, soap, zip, bcmath, pdo_mysql, curl, sockets
4949
tools: composer:v2
50-
ini-values: short_open_tag=Off, display_errors=On
51-
52-
- name: Check PHP Configuration
53-
run: |
54-
php -v
55-
php -i | grep "short_open_tag"
56-
php --ri tokenizer | head -20
5750

5851
- name: Cache Composer packages
5952
id: composer-cache
@@ -124,12 +117,4 @@ jobs:
124117
- name: Run PHPStan
125118
working-directory: magento2
126119
run: |
127-
echo "PHPStan Version:"
128-
vendor/bin/phpstan --version
129-
echo "Clearing PHPStan cache..."
130-
vendor/bin/phpstan clear-result-cache -c vendor/openforgeproject/mageforge/phpstan.neon
131-
echo "=== Checking actual file content in vendor ==="
132-
cat vendor/openforgeproject/mageforge/src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php | grep -A 20 "public function create"
133-
echo "=== End of file content check ==="
134-
echo "Running PHPStan Analysis with verbose output..."
135-
vendor/bin/phpstan analyse -vvv --no-progress -c vendor/openforgeproject/mageforge/phpstan.neon vendor/openforgeproject/mageforge/src
120+
vendor/bin/phpstan analyse -c vendor/openforgeproject/mageforge/phpstan.neon vendor/openforgeproject/mageforge/src

src/Model/TemplateEngine/Decorator/InspectorHintsFactory.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
*/
1414
class InspectorHintsFactory
1515
{
16-
public function __construct(
17-
private readonly Random $random
18-
) {
16+
private Random $random;
17+
18+
public function __construct(Random $random)
19+
{
20+
$this->random = $random;
1921
}
2022

2123
/**
@@ -35,13 +37,10 @@ public function create(array $data = []): InspectorHints
3537
);
3638
}
3739

38-
// Create instance - property access extracted to help PHPStan recognize the read
39-
$randomGenerator = $this->random;
40-
4140
return new InspectorHints(
4241
$subject,
4342
(bool)$showBlockHints,
44-
$randomGenerator
43+
$this->random
4544
);
4645
}
4746
}

0 commit comments

Comments
 (0)