Skip to content
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

refactor: Fix phpstan greaterOrEqual.invalid #9370

Merged
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
32 changes: 15 additions & 17 deletions system/Images/Handlers/BaseHandler.php
Original file line number Diff line number Diff line change
@@ -396,23 +396,6 @@ public function flip(string $dir = 'vertical')
*/
abstract protected function _flip(string $direction);

/**
* Overlays a string of text over the image.
*
* Valid options:
*
* - color Text Color (hex number)
* - shadowColor Color of the shadow (hex number)
* - hAlign Horizontal alignment: left, center, right
* - vAlign Vertical alignment: top, middle, bottom
* - hOffset
* - vOffset
* - fontPath
* - fontSize
* - shadowOffset
*
* @return $this
*/
public function text(string $text, array $options = [])
{
$options = array_merge($this->textDefaults, $options);
@@ -427,6 +410,21 @@ public function text(string $text, array $options = [])
/**
* Handler-specific method for overlaying text on an image.
*
* @param array{
* color?: string,
* shadowColor?: string,
* hAlign?: string,
* vAlign?: string,
* hOffset?: int,
* vOffset?: int,
* fontPath?: string,
* fontSize?: int,
* shadowOffset?: int,
* opacity?: float,
* padding?: int,
* withShadow?: bool|string
* } $options
*
* @return void
*/
abstract protected function _text(string $text, array $options = []);
2 changes: 0 additions & 2 deletions system/Images/Handlers/ImageMagickHandler.php
Original file line number Diff line number Diff line change
@@ -329,8 +329,6 @@ protected function supportedFormatCheck()
/**
* Handler-specific method for overlaying text on an image.
*
* @return void
*
* @throws Exception
*/
protected function _text(string $text, array $options = [])
20 changes: 15 additions & 5 deletions system/Images/ImageHandlerInterface.php
Original file line number Diff line number Diff line change
@@ -117,11 +117,21 @@ public function fit(int $width, int $height, string $position);
* - shadowColor Color of the shadow (hex number)
* - hAlign Horizontal alignment: left, center, right
* - vAlign Vertical alignment: top, middle, bottom
* - hOffset
* - vOffset
* - fontPath
* - fontSize
* - shadowOffset
*
* @param array{
* color?: string,
* shadowColor?: string,
* hAlign?: string,
* vAlign?: string,
* hOffset?: int,
* vOffset?: int,
* fontPath?: string,
* fontSize?: int,
* shadowOffset?: int,
* opacity?: float,
* padding?: int,
* withShadow?: bool|string
* } $options
*
* @return $this
*/
8 changes: 0 additions & 8 deletions utils/phpstan-baseline/greaterOrEqual.invalid.neon

This file was deleted.

1 change: 0 additions & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ includes:
- function.inner.neon
- generator.returnType.neon
- generator.valueType.neon
- greaterOrEqual.invalid.neon
- isset.offset.neon
- isset.property.neon
- method.alreadyNarrowedType.neon
22 changes: 1 addition & 21 deletions utils/phpstan-baseline/missingType.iterableValue.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 1685 errors
# total 1681 errors

parameters:
ignoreErrors:
@@ -4687,11 +4687,6 @@ parameters:
count: 1
path: ../../system/Images/Handlers/BaseHandler.php

-
message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:_text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/Images/Handlers/BaseHandler.php

-
message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:calcAspectRatio\(\) return type has no value type specified in iterable type array\.$#'
count: 1
@@ -4702,11 +4697,6 @@ parameters:
count: 1
path: ../../system/Images/Handlers/BaseHandler.php

-
message: '#^Method CodeIgniter\\Images\\Handlers\\BaseHandler\:\:text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/Images/Handlers/BaseHandler.php

-
message: '#^Property CodeIgniter\\Images\\Handlers\\BaseHandler\:\:\$supportTransparency type has no value type specified in iterable type array\.$#'
count: 1
@@ -4717,11 +4707,6 @@ parameters:
count: 1
path: ../../system/Images/Handlers/BaseHandler.php

-
message: '#^Method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:_text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/Images/Handlers/ImageMagickHandler.php

-
message: '#^Method CodeIgniter\\Images\\Handlers\\ImageMagickHandler\:\:process\(\) return type has no value type specified in iterable type array\.$#'
count: 1
@@ -4732,11 +4717,6 @@ parameters:
count: 1
path: ../../system/Images/Image.php

-
message: '#^Method CodeIgniter\\Images\\ImageHandlerInterface\:\:text\(\) has parameter \$options with no value type specified in iterable type array\.$#'
count: 1
path: ../../system/Images/ImageHandlerInterface.php

-
message: '#^Method CodeIgniter\\Language\\Language\:\:formatMessage\(\) has parameter \$message with no value type specified in iterable type array\.$#'
count: 1

Unchanged files with check annotations Beta

$this->assertSame(200, $this->handler->getHeight());
}
public function testImageCreation(): void

Check warning on line 356 in tests/system/Images/ImageMagickHandlerTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.9071s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageCreation
{
foreach (['gif', 'jpeg', 'png', 'webp'] as $type) {
if ($type === 'webp' && ! in_array('WEBP', Imagick::queryFormats(), true)) {
$this->assertSame(exif_imagetype($this->root . 'ci-logo.png'), IMAGETYPE_PNG);
}
public function testImageReorientLandscape(): void

Check warning on line 453 in tests/system/Images/ImageMagickHandlerTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.5535s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientLandscape
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/landscape_' . $i . '.jpg';
}
}
public function testImageReorientPortrait(): void

Check warning on line 472 in tests/system/Images/ImageMagickHandlerTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.5277s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientPortrait
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg';
unset($_ENV['encryption.key'], $_SERVER['encryption.key']);
}
public function testGenerateKeyShowsEncodedKey(): void

Check warning on line 77 in tests/system/Commands/GenerateKeyTest.php

GitHub Actions / SeparateProcess (8.2) / tests

Took 0.5375s from 0.5000s limit to run CodeIgniter\\Commands\\GenerateKeyTest::testGenerateKeyShowsEncodedKey
{
command('key:generate --show');
$this->assertStringContainsString('hex2bin:', $this->getBuffer());
return $this->getStreamFilterBuffer();
}
public function testCreateDatabase(): void

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, MySQLi, 8.0) / tests

Took 0.6073s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, Postgre, 8.0) / tests

Took 0.7442s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, SQLite3, 8.0) / tests

Took 0.5519s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase

Check warning on line 72 in tests/system/Commands/CreateDatabaseTest.php

GitHub Actions / DatabaseLive (8.2, SQLSRV, 8.0) / tests

Took 0.8544s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase
{
if ($this->connection instanceof OCI8Connection) {
$this->markTestSkipped('Needs to run on non-OCI8 drivers.');
$this->forge->dropTable('', true);
}
public function testForeignKey(): void

Check warning on line 494 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 2.7871s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testForeignKey
{
$this->forge->dropTable('forge_test_invoices', true);
$this->forge->dropTable('forge_test_users', true);
$this->forge->dropTable('forge_test_1', true);
}
public function testSetKeyNames(): void

Check warning on line 1236 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.0059s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testSetKeyNames
{
$this->forge->dropTable('forge_test_1', true);
$this->forge->dropTable('forge_test_four', true);
}
public function testDropKey(): void

Check warning on line 1583 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.8027s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testDropKey
{
$this->forge->dropTable('key_test_users', true);
$keyName = 'key_test_users_id';
$this->forge->dropTable('forge_test_users', true);
}
public function testProcessIndexes(): void

Check warning on line 1676 in tests/system/Database/Live/ForgeTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.3654s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testProcessIndexes
{
// make sure tables don't exist
$this->forge->dropTable('actions', true);
CLI::init();
}
public function testMigrateAllWithWithTwoNamespaces(): void

Check warning on line 77 in tests/system/Commands/Database/MigrateStatusTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.1422s from 0.5000s limit to run CodeIgniter\\Commands\\Database\\MigrateStatusTest::testMigrateAllWithWithTwoNamespaces

Check warning on line 77 in tests/system/Commands/Database/MigrateStatusTest.php

GitHub Actions / DatabaseLive (8.2, SQLSRV, 8.0) / tests

Took 0.6358s from 0.5000s limit to run CodeIgniter\\Commands\\Database\\MigrateStatusTest::testMigrateAllWithWithTwoNamespaces
{
command('migrate --all');
$this->resetStreamFilterBuffer();
$this->assertSame('MySQLi', $this->getPrivateProperty($db1, 'DBDriver'));
}
public function testConnectWithFailover(): void

Check warning on line 97 in tests/system/Database/Live/ConnectTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 1.0923s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ConnectTest::testConnectWithFailover
{
$this->tests['failover'][] = $this->tests;
unset($this->tests['failover'][0]['failover']);
#[Group('DatabaseLive')]
final class WhenWhenNotModelTest extends LiveModelTestCase
{
public function testWhenWithTrueCondition(): void

Check warning on line 25 in tests/system/Models/WhenWhenNotModelTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.8489s from 0.5000s limit to run CodeIgniter\\Models\\WhenWhenNotModelTest::testWhenWithTrueCondition
{
$secondaryData = [
[
$this->seeInDatabase('job', ['name' => 'Grocery Sales']);
}
public function testInsertBatch(): void

Check warning on line 53 in tests/system/Database/Live/InsertTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.8279s from 0.5000s limit to run CodeIgniter\\Database\\Live\\InsertTest::testInsertBatch
{
$table = 'type_test';
]);
}
public function testInsertBatchSuccess(): void

Check warning on line 52 in tests/system/Models/InsertModelTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.8129s from 0.5000s limit to run CodeIgniter\\Models\\InsertModelTest::testInsertBatchSuccess
{
$jobData = [
[
$this->createModel(UserModel::class)->insert([]);
}
public function testInsertPermitInsertNoData(): void

Check warning on line 239 in tests/system/Models/InsertModelTest.php

GitHub Actions / DatabaseLive (8.2, OCI8, 8.0) / tests

Took 0.7259s from 0.5000s limit to run CodeIgniter\\Models\\InsertModelTest::testInsertPermitInsertNoData
{
$forge = Database::forge();
$forge->addField([