Skip to content

Pipeline Fixes #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions .github/workflows/deptrac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: phive
extensions: intl, json, mbstring, xml
coverage: none
Expand Down Expand Up @@ -69,5 +69,7 @@ jobs:

- name: Trace dependencies
run: |
sudo phive --no-progress install --global --trust-gpg-keys B8F640134AB1782E,A98E898BB53EB748 qossmic/deptrac
deptrac analyze --cache-file=build/deptrac.cache
composer require --dev qossmic/deptrac-shim
vendor/bin/deptrac analyze --cache-file=build/deptrac.cache
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/infection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: infection, phpunit
extensions: intl, json, mbstring, gd, xml, sqlite3
coverage: xdebug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpcpd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: phpcpd
extensions: dom, mbstring
coverage: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpcsfixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: json, tokenizer
coverage: none
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['8.2']

steps:
- name: Checkout
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
matrix:
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['8.2']

steps:
- name: Checkout
Expand Down Expand Up @@ -61,12 +61,12 @@ jobs:
fi

- name: Test with PHPUnit
run: vendor/bin/phpunit --verbose --coverage-text
run: vendor/bin/phpunit --coverage-text
env:
TERM: xterm-256color
TACHYCARDIA_MONITOR_GA: enabled

- if: matrix.php-versions == '8.0'
- if: matrix.php-versions == '8.2'
name: Run Coveralls
continue-on-error: true
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: phpstan, phpunit
extensions: intl, json, mbstring, xml
coverage: none
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['8.2']

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unused.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
tools: composer, composer-unused
extensions: intl, json, mbstring, xml
coverage: none
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
autoloader="psalm_autoload.php"
cacheDirectory="build/psalm/"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="src/" />
Expand Down
7 changes: 7 additions & 0 deletions psalm_autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
require __DIR__ . '/vendor/codeigniter4/framework/system/Test/bootstrap.php';

$helperDirs = [
'app/Helpers',
'vendor/codeigniter4/framework/system/Helpers',
];

foreach ($helperDirs as $dir) {
$dir = __DIR__ . '/' . $dir;
if (! is_dir($dir)) {
continue;
}

chdir($dir);

foreach (glob('*_helper.php') as $filename) {
Expand All @@ -18,3 +23,5 @@
require_once $filePath;
}
}

chdir(__DIR__);
9 changes: 2 additions & 7 deletions src/Traits/EntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function __isset(string $key): bool

// Convert the key to table format
$tableName = plural(strtolower($key));

// Check for a matching table
return isset($schema->tables->{$tableName});
}
Expand All @@ -81,7 +82,7 @@ public function __call(string $name, array $arguments)
$verb = false;

foreach ($verbs as $test) {
if (strpos($name, $test) === 0) {
if (str_starts_with($name, $test)) {
$verb = $test;
break;
}
Expand Down Expand Up @@ -242,12 +243,10 @@ protected function _set(string $tableName, ?array $keys = null): bool
switch ($relation->type) {
// WIP - need to decide about adding and detaching
case 'hasMany':

break;

// Delete entries from the pivot table
case 'manyToMany':

// Get the pivot table info
$pivotTable = $relation->pivots[0][2];
$pivotId = $relation->pivots[0][3];
Expand Down Expand Up @@ -297,12 +296,10 @@ protected function _add(string $tableName, array $keys): bool
switch ($relation->type) {
// WIP - need to decide about attaching versus adding
case 'hasMany':

break;

// Add entries to the pivot table
case 'manyToMany':

// Get the pivot table info
$pivotTable = $relation->pivots[0][2];
$pivotId = $relation->pivots[0][3];
Expand Down Expand Up @@ -356,12 +353,10 @@ protected function _remove(string $tableName, array $keys): bool
switch ($relation->type) {
// WIP - need to decide about detaching versus deleting
case 'hasMany':

break;

// Delete entries from the pivot table
case 'manyToMany':

// Get the pivot table info
$pivotTable = $relation->pivots[0][2];
$pivotId = $relation->pivots[0][3];
Expand Down
14 changes: 6 additions & 8 deletions src/Traits/ModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function with($with, bool $overwrite = false)
* Blocks specified tables from being loaded as relations with the next finder.
* Used mostly to prevent nesting loops.
*
* @param string|string[] $tables Table name or array of table names
* @param list<string>|string $tables Table name or array of table names
*
* @return $this
*/
Expand Down Expand Up @@ -143,9 +143,9 @@ public function join(...$params)
return $this;
}

//--------------------------------------------------------------------
// --------------------------------------------------------------------
// FINDERS EXTENSIONS
//--------------------------------------------------------------------
// --------------------------------------------------------------------

/**
* Fetches the row of database from $this->table with a primary key
Expand All @@ -170,21 +170,21 @@ public function find($id = null)
return $this->addRelations($data);
}

//--------------------------------------------------------------------
// --------------------------------------------------------------------
/**
* Works with the current Query Builder instance to return
* all results, while optionally limiting them.
*
* @return array|null
*/
public function findAll(int $limit = null, int $offset = 0)
public function findAll(?int $limit = null, int $offset = 0)
{
$data = parent::findAll($limit, $offset);

return $this->addRelations($data);
}

//--------------------------------------------------------------------
// --------------------------------------------------------------------

/**
* Returns the first row of the result set. Will take any previous
Expand All @@ -206,8 +206,6 @@ public function first()
* Intercepts data from a finder and injects related items
*
* @param array $rows Array of rows from the finder
*
* @return array
*/
protected function addRelations($rows): ?array
{
Expand Down
2 changes: 1 addition & 1 deletion tests/entity/RelationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function testWithDeletedRelations()
$machine1 = new Machine((array) $object);
$this->assertNull($machine1->factory);

$machine2 = new class () extends Machine {
$machine2 = new class () extends Machine {
protected array $withDeletedRelations = ['factories'];
};
$machine2->fill((array) $object);
Expand Down
Loading