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: improve error message in BaseExceptionHandler #8766

Merged
merged 2 commits into from
Apr 12, 2024
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
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
@@ -4121,11 +4121,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/Seeder.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/BaseExceptionHandler.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\BaseExceptionHandler\\:\\:collectVars\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
10 changes: 8 additions & 2 deletions system/Debug/BaseExceptionHandler.php
Original file line number Diff line number Diff line change
@@ -245,8 +245,14 @@ protected static function highlightFile(string $file, int $lineNumber, int $line
*/
protected function render(Throwable $exception, int $statusCode, $viewFile = null): void
{
if (empty($viewFile) || ! is_file($viewFile)) {
echo 'The error view files were not found. Cannot render exception trace.';
if ($viewFile === null) {
echo 'The error view file was not specified. Cannot display error view.';

exit(1);
}

if (! is_file($viewFile)) {
echo 'The error view file "' . $viewFile . '" was not found. Cannot display error view.';

exit(1);
}

Unchanged files with check annotations Beta

};
}
public function testNoFormatterJSON(): void

Check warning on line 137 in tests/system/API/ResponseTraitTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 3.4615s from 0.5000s limit to run CodeIgniter\\API\\ResponseTraitTest::testNoFormatterJSON
{
$this->formatter = null;
$controller = $this->makeController(
$this->assertSame('', $this->getStreamFilterBuffer());
}
public function testRun(): void

Check warning on line 71 in tests/system/CLI/ConsoleTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.8245s from 0.5000s limit to run CodeIgniter\\CLI\\ConsoleTest::testRun
{
$this->initCLI();
$this->assertSame(0, Fabricator::getCount('giants'));
}
public function testUniqueSetsOutUniqueFieldValues(): void

Check warning on line 496 in tests/system/Test/FabricatorTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.6806s from 0.5000s limit to run CodeIgniter\\Test\\FabricatorTest::testUniqueSetsOutUniqueFieldValues
{
$model = new class () extends Model {
protected $allowedFields = ['email'];
);
}
public function testValidSetsOutValidValuesUsingCallback(): void

Check warning on line 531 in tests/system/Test/FabricatorTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.6522s from 0.5000s limit to run CodeIgniter\\Test\\FabricatorTest::testValidSetsOutValidValuesUsingCallback
{
$model = new class () extends Model {
protected $allowedFields = ['digit'];
$this->assertSame(exif_imagetype($this->root . 'ci-logo.png'), IMAGETYPE_PNG);
}
public function testImageReorientLandscape(): void

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

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.5483s 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 473 in tests/system/Images/ImageMagickHandlerTest.php

GitHub Actions / Others (8.2) / Sanity Tests

Took 0.5256s from 0.5000s limit to run CodeIgniter\\Images\\ImageMagickHandlerTest::testImageReorientPortrait
{
for ($i = 0; $i <= 8; $i++) {
$source = $this->origin . 'EXIFsamples/portrait_' . $i . '.jpg';
$this->assertNull($this->handler->getMetaData(self::$dummy));
}
public function testGetMetaData(): void

Check warning on line 35 in tests/system/Cache/Handlers/AbstractHandlerTestCase.php

GitHub Actions / CacheLive (8.2) / Cache Live Tests

Took 3.3013s from 0.5000s limit to run CodeIgniter\\Cache\\Handlers\\MemcachedHandlerTest::testGetMetaData
{
$time = Time::now()->getTimestamp();
$this->handler->save(self::$key1, 'value');
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 4.6431s 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, OCI8, 8.0) / tests

Took 3.5897s 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 4.6687s 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 4.5606s 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 4.9957s from 0.5000s limit to run CodeIgniter\\Commands\\CreateDatabaseTest::testCreateDatabase
{
if ($this->connection instanceof OCI8Connection) {
$this->markTestSkipped('Needs to run on non-OCI8 drivers.');
CLI::init();
}
public function testMigrateAllWithWithTwoNamespaces(): void

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

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

Took 0.7232s 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, OCI8, 8.0) / tests

Took 2.5800s 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, Postgre, 8.0) / tests

Took 0.7207s 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, SQLite3, 8.0) / tests

Took 0.9732s 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.8488s from 0.5000s limit to run CodeIgniter\\Commands\\Database\\MigrateStatusTest::testMigrateAllWithWithTwoNamespaces
{
command('migrate --all');
$this->resetStreamFilterBuffer();
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 4.0541s from 0.5000s limit to run CodeIgniter\\Commands\\GenerateKeyTest::testGenerateKeyShowsEncodedKey
{
command('key:generate --show');
$this->assertStringContainsString('hex2bin:', $this->getBuffer());
$this->assertNull(model(UnexsistenceClass::class));
}
public function testModelExistsBasename(): void

Check warning on line 417 in tests/system/CommonFunctionsTest.php

GitHub Actions / SeparateProcess (8.2) / tests

Took 0.5216s from 0.5000s limit to run CodeIgniter\\CommonFunctionsTest::testModelExistsBasename
{
$this->assertInstanceOf(JobModel::class, model('JobModel'));
}
$this->forge->dropTable('', true);
}
public function testForeignKey(): void

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

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

Took 2.8061s 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 1233 in tests/system/Database/Live/ForgeTest.php

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

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

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

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

Took 1.4441s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ForgeTest::testProcessIndexes
{
// make sure tables don't exist
$this->forge->dropTable('actions', true);
$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.0905s from 0.5000s limit to run CodeIgniter\\Database\\Live\\ConnectTest::testConnectWithFailover
{
$this->tests['failover'][] = $this->tests;
unset($this->tests['failover'][0]['failover']);
protected $refresh = true;
public function testCreateAddsToDatabase(): void

Check warning on line 34 in tests/system/Database/Live/FabricatorLiveTest.php

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

Took 0.9296s from 0.5000s limit to run CodeIgniter\\Database\\Live\\FabricatorLiveTest::testCreateAddsToDatabase
{
$fabricator = new Fabricator(UserModel::class);
$this->assertStringContainsString('upsertone@test.com', $sql);
}
public function testUpsertBatchWithQuery(): void

Check warning on line 714 in tests/system/Database/Live/UpsertTest.php

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

Took 0.9169s from 0.5000s limit to run CodeIgniter\\Database\\Live\\UpsertTest::testUpsertBatchWithQuery
{
$this->forge = Database::forge($this->DBGroup);
$this->seeInDatabase('job', ['name' => 'Grocery Sales']);
}
public function testInsertBatch(): void

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

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

Took 0.8852s 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.8392s from 0.5000s limit to run CodeIgniter\\Models\\InsertModelTest::testInsertBatchSuccess
{
$jobData = [
[