Skip to content

Commit 4dd1155

Browse files
feat: improve code quality and fix runtime argument passing bugs
- Add PHPStan static analysis and PHP CS Fixer for code quality - Fix FunctionValue::call method to use proper callable invocation - Correct ObjectValue built-in functions to accept $args array pattern - Fix method name inconsistencies (evaluateAsBool → asBool) across RuntimeValue classes - Add proper type validation and error handling in built-in functions - Establish consistent argument passing pattern for all RuntimeValue methods - Add GitHub Actions workflow for automated code quality checks - Support PHP 8.4 in CI/CD pipeline
1 parent 2f4cf5b commit 4dd1155

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+5163
-2697
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,13 @@ jobs:
99
strategy:
1010
fail-fast: true
1111
matrix:
12-
php: [ 8.1, 8.2, 8.3 ]
13-
dependency-version: [ prefer-lowest, prefer-stable ]
12+
php: [ 8.1, 8.2, 8.3, 8.4 ]
1413

15-
name: Tests on PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}
14+
name: Tests on PHP ${{ matrix.php }}
1615

1716
steps:
1817
- name: Checkout
19-
uses: actions/checkout@v3
20-
21-
- name: Cache dependencies
22-
uses: actions/cache@v3
23-
with:
24-
path: ~/.composer/cache/files
25-
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
18+
uses: actions/checkout@v5
2619

2720
- name: Setup PHP
2821
uses: shivammathur/setup-php@v2
@@ -32,7 +25,34 @@ jobs:
3225
coverage: none
3326

3427
- name: Install Composer dependencies
35-
run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist
28+
uses: "ramsey/composer-install@v3"
3629

3730
- name: Run tests
38-
run: composer test
31+
run: composer test
32+
33+
qa:
34+
runs-on: ubuntu-latest
35+
name: Code Quality
36+
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v5
40+
41+
- name: Setup PHP
42+
uses: shivammathur/setup-php@v2
43+
with:
44+
php-version: 8.1
45+
extensions: dom, mbstring, zip
46+
coverage: none
47+
48+
- name: Validate composer.json and composer.lock
49+
run: composer validate --strict
50+
51+
- name: Install Composer dependencies
52+
uses: "ramsey/composer-install@v3"
53+
54+
- name: Check code style
55+
run: vendor/bin/php-cs-fixer fix --dry-run --diff --verbose
56+
57+
- name: Check code quality
58+
run: vendor/bin/phpstan analyze

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
vendor
2-
.idea
2+
.idea
3+
.claude
4+
.php-cs-fixer.cache

.php-cs-fixer.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$finder = PhpCsFixer\Finder::create()
6+
->in(__DIR__ . '/src')
7+
->in(__DIR__ . '/tests');
8+
9+
$config = new PhpCsFixer\Config();
10+
11+
$parallelConfig = PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect();
12+
13+
return $config
14+
->setRules([
15+
'@PSR12' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'explicit_string_variable' => true,
18+
])
19+
->setParallelConfig($parallelConfig)
20+
->setFinder($finder);

composer.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
},
88
"require-dev": {
99
"symfony/var-dumper": "^6.3|^7.0",
10-
"pestphp/pest": "^2.34"
10+
"pestphp/pest": "^2.36.0|^3.5.0",
11+
"friendsofphp/php-cs-fixer": "^3.89",
12+
"phpstan/phpstan": "^2.1"
1113
},
1214
"license": "MIT",
1315
"autoload": {
@@ -31,6 +33,18 @@
3133
},
3234
"scripts": {
3335
"test": "vendor/bin/pest",
34-
"test:coverage": "XDEBUG_MODE=coverage ./vendor/bin/pest --coverage"
36+
"test:coverage": "XDEBUG_MODE=coverage ./vendor/bin/pest --coverage",
37+
"cs-fix": "vendor/bin/php-cs-fixer fix",
38+
"cs-check": "vendor/bin/php-cs-fixer fix --dry-run --diff --verbose",
39+
"phpstan": "vendor/bin/phpstan analyze",
40+
"phpstan-baseline": "vendor/bin/phpstan analyze --generate-baseline",
41+
"qa": [
42+
"@cs-check",
43+
"@phpstan"
44+
],
45+
"qa-fix": [
46+
"@cs-fix",
47+
"@phpstan"
48+
]
3549
}
3650
}

0 commit comments

Comments
 (0)