Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 16 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
php-version: '8.5'
- uses: ramsey/composer-install@v3
- run: composer phpstan
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
},
"autoload": {
"psr-4": {
"Respect\\": "library/Respect"
"Respect\\Relational\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Respect\\Relational\\": "tests/"
}
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<arg value="p" />
<arg value="s" />

<file>library/</file>
<file>src/</file>
<file>tests/</file>

<rule ref="Respect" />
Expand Down
10 changes: 7 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</testsuites>
<source>
<include>
<directory>library/</directory>
<directory>src/</directory>
</include>
</source>
</phpunit>
2 changes: 2 additions & 0 deletions library/Respect/Relational/Db.php → src/Db.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Relational;

use PDO;
Expand Down
9 changes: 8 additions & 1 deletion library/Respect/Relational/Mapper.php → src/Mapper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Relational;

use Exception;
Expand Down Expand Up @@ -452,6 +454,10 @@ protected function parseCollection(

protected function hasComposition($entity, $next, $parent)
{
if ($next === null || $parent === null) {
return false;
}

$s = $this->getStyle();

return $entity === $s->composed($parent, $next)
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion library/Respect/Relational/Sql.php → src/Sql.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Relational;

class Sql
Expand Down Expand Up @@ -224,7 +226,7 @@ protected function normalizeParts($parts, $raw = false)
array_walk_recursive($parts, function ($value, $key) use (&$newParts, &$params, &$raw) {
if ($value instanceof Sql) {
$params = array_merge($params, $value->getParams());
if (0 !== stripos($value, '(')) {
if (0 !== stripos((string) $value, '(')) {
$value = Sql::enclose($value);
}
$newParts[$key] = $value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Relational;

class DbTest extends \PHPUnit\Framework\TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Relational;

use PDO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Relational;

class SqlTest extends \PHPUnit\Framework\TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Data\Styles;

class AbstractStyleTest extends \PHPUnit\Framework\TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Data\Styles\CakePHP;

use PDO,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Data\Styles\NorthWind;

use PDO,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Data\Styles\Plural;

use PDO,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Data\Styles\Sakila;

use PDO,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Respect\Data\Styles;

class StandardTest extends \PHPUnit\Framework\TestCase
Expand Down
Loading