Skip to content

Commit edef842

Browse files
committed
update composer.json to add phpstan as a dev dependency and define test scripts; refactor GitHub Actions workflow to use new test commands; modify PersistenceInterface and attribute classes to change readonly properties to mutable
1 parent 76b6197 commit edef842

6 files changed

Lines changed: 28 additions & 13 deletions

File tree

.github/workflows/test.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ jobs:
88
with:
99
php-version: '8.3'
1010
- uses: php-actions/composer@v6
11-
- run: ./vendor/bin/phpunit --group unit
11+
- run: composer test:unit
12+
13+
test-phpstan:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: '8.3'
20+
- uses: php-actions/composer@v6
21+
- run: composer test:phpstan
1222

1323
test-database:
1424
runs-on: ubuntu-latest
@@ -41,4 +51,6 @@ jobs:
4151
with:
4252
php-version: '8.3'
4353
- uses: php-actions/composer@v6
44-
- run: DATABASE_URL=${{ matrix.database.database_url }} ./vendor/bin/phpunit --group database
54+
- run: composer test:database
55+
env:
56+
DATABASE_URL: ${{ matrix.database.database_url }}

composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
},
88
"require-dev": {
99
"phpunit/phpunit": "^11.1",
10-
"spatie/phpunit-snapshot-assertions": "^5.1"
10+
"spatie/phpunit-snapshot-assertions": "^5.1",
11+
"phpstan/phpstan": "^2.1.17"
1112
},
1213
"repositories": [
1314
{
@@ -26,5 +27,10 @@
2627
"DataAccessKit\\": "data-access-kit/test/",
2728
"DataAccessKit\\Symfony\\": "data-access-kit-symfony/test/"
2829
}
30+
},
31+
"scripts": {
32+
"test:unit": "./vendor/bin/phpunit --group unit",
33+
"test:database": "./vendor/bin/phpunit --group database",
34+
"test:phpstan": "./vendor/bin/phpstan analyse data-access-kit/src data-access-kit-symfony/src --memory-limit=512M"
2935
}
3036
}

data-access-kit/src/Attribute/Column.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[Attribute(Attribute::TARGET_PROPERTY)]
99
class Column
1010
{
11-
public readonly ReflectionProperty $reflection;
11+
public ReflectionProperty $reflection;
1212

1313
public function __construct(
1414
public ?string $name = null,

data-access-kit/src/Attribute/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#[Attribute(Attribute::TARGET_CLASS)]
99
class Table
1010
{
11-
public readonly ReflectionClass $reflection;
11+
public ReflectionClass $reflection;
1212

1313
/** @var Column[] */
14-
public readonly array $columns;
14+
public array $columns;
1515

1616
public function __construct(
1717
public ?string $name = null,

data-access-kit/src/PersistenceInterface.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ public function execute(string $sql, array $parameters = []): int;
3636
/**
3737
* Insert data into the database.
3838
*
39-
* @template T
40-
* @param T|T[] $data
39+
* @param object|array $data
4140
*/
4241
public function insert(object|array $data): void;
4342

4443
/**
4544
* Insert or update data in the database.
4645
*
47-
* @template T
48-
* @param T|T[] $data
46+
* @param object|array $data
4947
*/
5048
public function upsert(object|array $data, ?array $columns = null): void;
5149

@@ -57,8 +55,7 @@ public function update(object $data, ?array $columns = null): void;
5755
/**
5856
* Delete data from the database based on its primary key.
5957
*
60-
* @template T
61-
* @param T|T[] $data
58+
* @param object|array $data
6259
*/
6360
public function delete(object|array $data): void;
6461

data-access-kit/src/Repository/ResultMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class ResultMethod implements Stringable
1212
{
1313

14-
public readonly ReflectionMethod $reflection;
14+
public ReflectionMethod $reflection;
1515

1616
private string $visibility = "public";
1717
/** @var array<string, ResultParameter> */

0 commit comments

Comments
 (0)