diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 757d47a..c02b873 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,30 +6,24 @@ on:
pull_request:
jobs:
- test:
+ tests:
+ name: Tests
runs-on: ubuntu-latest
- strategy:
- matrix:
- php: [ '8.5' ]
steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
+ - uses: actions/checkout@v6
+ - uses: shivammathur/setup-php@v2
with:
- php-version: ${{ matrix.php }}
+ php-version: '8.5'
+ - uses: ramsey/composer-install@v3
+ - run: composer phpunit
- - name: Get composer cache
- uses: actions/cache@v4
+ static-analysis:
+ name: Static Analysis
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ - uses: shivammathur/setup-php@v2
with:
- path: ~/.cache/composer
- key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- restore-keys: |
- ${{ runner.os }}-composer-
-
- - name: Install dependencies
- run: composer install --no-progress --prefer-dist --no-interaction
-
- - name: Run PHPUnit
- run: vendor/bin/phpunit --configuration phpunit.xml.dist
\ No newline at end of file
+ php-version: '8.5'
+ - uses: ramsey/composer-install@v3
+ - run: composer phpstan
diff --git a/composer.json b/composer.json
index 6e131c8..22f2251 100644
--- a/composer.json
+++ b/composer.json
@@ -32,7 +32,12 @@
},
"autoload": {
"psr-4": {
- "Respect\\": "library/Respect"
+ "Respect\\Relational\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Respect\\Relational\\": "tests/"
}
},
"scripts": {
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 0572243..1219d48 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -11,7 +11,7 @@
- library/
+ src/
tests/
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 6250649..94b4829 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -1,11 +1,15 @@
parameters:
- level: 1
+ level: 2
paths:
- - library/
+ - src/
- tests/
ignoreErrors:
- - message: '/Call to an undefined static method Respect\\Relational\\Sql::\w+\(\)\./'
+ - message: '/Call to an undefined (static )?method Respect\\Relational\\(Sql|Db|Mapper)::\w+\(\)\./'
- message: '/Call to an undefined static method Respect\\Data\\Collections\\(Collection|Filtered|Mix|Typed)::\w+\(\)\./'
+ - message: '/Access to an undefined property Respect\\Relational\\Mapper::\$\w+\./'
- message: '/Unsafe usage of new static\(\)\./'
- message: '/Cannot unset property .+ because it might have hooks in a subclass\./'
- message: '/Array has \d+ duplicate keys/'
+ -
+ message: '/unknown class/'
+ path: tests/Styles/
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 7c4d0df..da3a218 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -11,7 +11,7 @@
- library/
+ src/
diff --git a/library/Respect/Relational/Db.php b/src/Db.php
similarity index 99%
rename from library/Respect/Relational/Db.php
rename to src/Db.php
index 54402dd..ee53fc2 100644
--- a/library/Respect/Relational/Db.php
+++ b/src/Db.php
@@ -1,5 +1,7 @@
getStyle();
return $entity === $s->composed($parent, $next)
@@ -647,7 +653,8 @@ protected function getAllProperties($object)
$cols = get_object_vars($object);
$ref = new \ReflectionClass($object);
foreach ($ref->getProperties() as $prop) {
- if (preg_match('/@Relational\\\isNotColumn/', $prop->getDocComment())) {
+ $docComment = $prop->getDocComment();
+ if ($docComment !== false && preg_match('/@Relational\\\isNotColumn/', $docComment)) {
continue;
}
$cols[$prop->name] = $prop->getValue($object);
diff --git a/library/Respect/Relational/Sql.php b/src/Sql.php
similarity index 98%
rename from library/Respect/Relational/Sql.php
rename to src/Sql.php
index 2b9d3a4..b933fc1 100644
--- a/library/Respect/Relational/Sql.php
+++ b/src/Sql.php
@@ -1,5 +1,7 @@
getParams());
- if (0 !== stripos($value, '(')) {
+ if (0 !== stripos((string) $value, '(')) {
$value = Sql::enclose($value);
}
$newParts[$key] = $value;
diff --git a/tests/library/Respect/Relational/DbTest.php b/tests/DbTest.php
similarity index 99%
rename from tests/library/Respect/Relational/DbTest.php
rename to tests/DbTest.php
index d374c9c..aa7e85d 100644
--- a/tests/library/Respect/Relational/DbTest.php
+++ b/tests/DbTest.php
@@ -1,5 +1,7 @@