Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix phpstan, psalm and rector
  • Loading branch information
michalsn committed Oct 10, 2025
commit 045127c832d25ea52a5facee36a895173d768525
5 changes: 4 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ parameters:
allRules: false
disallowedLooseComparison: true
booleansInConditions: true
disallowedConstructs: true
disallowedBacktick: true
disallowedEmpty: true
disallowedImplicitArrayCreation: true
disallowedShortTernary: true
matchingInheritedMethodNames: true

5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
cacheDirectory="build/psalm/"
findUnusedBaselineEntry="true"
findUnusedCode="false"
ensureOverrideAttribute="false"
>
<projectFiles>
<directory name="src/" />
<directory name="tests/" />
<ignoreFiles>
<directory name="vendor" />
<file name="src/Compatibility/SignalTrait.php" />
</ignoreFiles>
</projectFiles>
<stubs>
<file name="stubs/SignalTrait.phpstub" />
</stubs>
</psalm>
10 changes: 7 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
use Rector\Php81\Rector\ClassMethod\NewInInitializerRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector;
use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertEmptyNullableObjectToAssertInstanceofRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
use Rector\Set\ValueObject\LevelSetList;
Expand Down Expand Up @@ -95,8 +96,11 @@
// Supported from PHPUnit 10
DataProviderAnnotationToAttributeRector::class,

NewInInitializerRector::class => [
'src/Payloads/Payload.php',
AssertEmptyNullableObjectToAssertInstanceofRector::class,

// Skip onInterruption method - called dynamically via reflection in SignalTrait
RemoveUnusedPrivateMethodRector::class => [
__DIR__ . '/src/Commands/QueueWork.php',
],
]);

Expand Down
1 change: 1 addition & 0 deletions src/Payloads/ChainBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function dispatch(): QueuePushResult
}

// Set chained jobs for the next job
// @phpstan-ignore greater.alwaysTrue
if ($this->payloads->count() > 0) {
$current->setChainedJobs($this->payloads);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Models/QueueJobModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function testSkipLocked(): void
if ($model->db->DBDriver === 'SQLite3') {
$this->assertSame($sql, $result);
} elseif ($model->db->DBDriver === 'SQLSRV') {
$this->assertStringContainsString('WITH (ROWLOCK,UPDLOCK,READPAST) WHERE', $result);
$this->assertStringContainsString('WITH (ROWLOCK,UPDLOCK,READPAST) WHERE', (string) $result);
} else {
$this->assertStringContainsString('FOR UPDATE SKIP LOCKED', $result);
$this->assertStringContainsString('FOR UPDATE SKIP LOCKED', (string) $result);
}
}

Expand Down
1 change: 1 addition & 0 deletions tests/Payloads/PayloadMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public function testFromArrayWithChainedJobs(): void
$this->assertCount(2, $chainedJobs);

$job1 = $chainedJobs->shift();
$this->assertInstanceOf(Payload::class, $job1);
$this->assertSame('job1', $job1->getJob());
$this->assertSame(['key1' => 'value1'], $job1->getData());
$this->assertSame('queue1', $job1->getQueue());
Expand Down
2 changes: 2 additions & 0 deletions tests/Payloads/PayloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ public function testFromArrayWithChainedJobs(): void
$this->assertTrue($payload->hasChainedJobs());
$chainedJobs = $payload->getChainedJobs();
$this->assertCount(1, $chainedJobs);
$this->assertInstanceOf(PayloadCollection::class, $chainedJobs);

$nextJob = $chainedJobs->shift();
$this->assertInstanceOf(Payload::class, $nextJob);
$this->assertSame('nextJob', $nextJob->getJob());
$this->assertSame(['nextKey' => 'nextValue'], $nextJob->getData());
$this->assertSame('nextQueue', $nextJob->getQueue());
Expand Down
1 change: 0 additions & 1 deletion tests/RabbitMQHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use CodeIgniter\Exceptions\CriticalError;
use CodeIgniter\Queue\Entities\QueueJob;
use CodeIgniter\Queue\Enums\Status;
use CodeIgniter\Queue\Exceptions\QueueException;
use CodeIgniter\Queue\Handlers\RabbitMQHandler;
use CodeIgniter\Queue\QueuePushResult;
Expand Down
4 changes: 4 additions & 0 deletions tests/RedisHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ public function testFailedAndDontKeepJob(): void
'queue' => 'queue1',
]);
}

public function testDone(): void
{
$handler = new RedisHandler($this->config);
Expand All @@ -314,6 +315,7 @@ public function testDone(): void
$this->assertTrue($result);
$this->assertFalse($redis->hExists('queues:queue1::reserved', (string) $queueJob->id));
}

public function testClear(): void
{
$handler = new RedisHandler($this->config);
Expand All @@ -327,6 +329,7 @@ public function testClear(): void
$result = $handler->clear('queue1');
$this->assertTrue($result);
}

public function testClearAll(): void
{
$handler = new RedisHandler($this->config);
Expand All @@ -340,6 +343,7 @@ public function testClearAll(): void
$result = $handler->clear();
$this->assertTrue($result);
}

public function testRetry(): void
{
$handler = new RedisHandler($this->config);
Expand Down