Skip to content

Commit ea20318

Browse files
update
1 parent b745883 commit ea20318

File tree

5 files changed

+44
-40
lines changed

5 files changed

+44
-40
lines changed

bootstrap/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
//declare(strict_types=1);
3+
// declare(strict_types=1);
44

55
namespace App;
66

bootstrap/index.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
<?php
2+
23
define('ROOT_PATH', __DIR__);
34

4-
require_once(__DIR__."/vendor/autoload.php");
5+
require_once __DIR__.'/vendor/autoload.php';
56

67
spl_autoload_register(function ($class) {
7-
$file = ROOT_PATH . '/'. str_replace("\\", '/', $class) . '.php';
8+
$file = ROOT_PATH.'/'.str_replace('\\', '/', $class).'.php';
89

910
if (file_exists($file)) {
1011
require_once $file;
1112
} else {
1213
$msg = throw new Exception("This page not found: $file");
13-
error_log($msg, 3, 'Exception.txt');
14+
error_log($msg, 3, 'Exception.txt');
1415

1516
}
1617
});
@@ -20,6 +21,5 @@
2021

2122
use App\Config\Config;
2223

23-
$config = new Config();
24+
$config = new Config;
2425
$pdo = $config->getConnection(__DIR__);
25-

config/ErrorHandler.php

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
11
<?php
2+
23
namespace App;
4+
35
// Turn on all errors and log them (no output on screen)
46
error_reporting(E_ALL);
57
ini_set('display_errors', '0');
68
ini_set('log_errors', '1');
7-
ini_set('error_log', __DIR__ . '/logs/error_log.txt');
9+
ini_set('error_log', __DIR__.'/logs/error_log.txt');
810

911
// Ensure the logs directory exists
10-
if (!is_dir(__DIR__ . '/logs')) {
11-
mkdir(__DIR__ . '/logs', 0777, true);
12+
if (! is_dir(__DIR__.'/logs')) {
13+
mkdir(__DIR__.'/logs', 0777, true);
1214
}
1315

1416
// Custom error handler
1517
function errorHandler(string $errNo, string $errStr, string $errFile, string $errLine): mixed
1618
{
1719
$errorTypes = [
18-
E_ERROR => 'Error',
19-
E_WARNING => 'Warning',
20-
E_PARSE => 'Parse Error',
21-
E_NOTICE => 'Notice',
22-
E_CORE_ERROR => 'Core Error',
23-
E_CORE_WARNING => 'Core Warning',
24-
E_COMPILE_ERROR => 'Compile Error',
25-
E_COMPILE_WARNING => 'Compile Warning',
26-
E_USER_ERROR => 'User Error',
27-
E_USER_WARNING => 'User Warning',
28-
E_USER_NOTICE => 'User Notice',
29-
E_STRICT => 'Strict',
20+
E_ERROR => 'Error',
21+
E_WARNING => 'Warning',
22+
E_PARSE => 'Parse Error',
23+
E_NOTICE => 'Notice',
24+
E_CORE_ERROR => 'Core Error',
25+
E_CORE_WARNING => 'Core Warning',
26+
E_COMPILE_ERROR => 'Compile Error',
27+
E_COMPILE_WARNING => 'Compile Warning',
28+
E_USER_ERROR => 'User Error',
29+
E_USER_WARNING => 'User Warning',
30+
E_USER_NOTICE => 'User Notice',
31+
E_STRICT => 'Strict',
3032
E_RECOVERABLE_ERROR => 'Recoverable Error',
31-
E_DEPRECATED => 'Deprecated',
32-
E_USER_DEPRECATED => 'User Deprecated',
33+
E_DEPRECATED => 'Deprecated',
34+
E_USER_DEPRECATED => 'User Deprecated',
3335
];
3436

3537
$type = $errorTypes[$errNo] ?? 'Unknown Error';
3638
$timestamp = date('Y-m-d H:i:s');
37-
$message = "[$timestamp] $type: $errStr in $errFile on line $errLine" . PHP_EOL;
39+
$message = "[$timestamp] $type: $errStr in $errFile on line $errLine".PHP_EOL;
40+
41+
error_log($message, 3, __DIR__.'/logs/error_log.txt');
3842

39-
error_log($message, 3, __DIR__ . '/logs/error_log.txt');
4043
return true; // Prevent PHP internal handler
4144
}
4245

4346
// Custom exception handler
4447
function exceptionHandler(Throwable $exception): void
4548
{
4649
$timestamp = date('Y-m-d H:i:s');
47-
$message = "[$timestamp] Uncaught Exception: " . $exception->getMessage() .
48-
" in " . $exception->getFile() .
49-
" on line " . $exception->getLine() . PHP_EOL .
50-
$exception->getTraceAsString() . PHP_EOL;
50+
$message = "[$timestamp] Uncaught Exception: ".$exception->getMessage().
51+
' in '.$exception->getFile().
52+
' on line '.$exception->getLine().PHP_EOL.
53+
$exception->getTraceAsString().PHP_EOL;
5154

52-
error_log($message, 3, __DIR__ . '/logs/error_log.txt');
55+
error_log($message, 3, __DIR__.'/logs/error_log.txt');
5356
}
5457

5558
set_error_handler('errorHandler');

public/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="description" content="Auth Project, PHP Project">
88
<meta name="robots" content="index, follow">
99
<link rel="icon" type="image/png" href="/icon.png">
10-
<title><?= $title ?? 'Auth Project';?></title>
10+
<title><?= $title ?? 'Auth Project'; ?></title>
1111

1212
<link rel="stylesheet" href="./css/app.css" />
1313
</head>

tests/ExampleTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
namespace Tests;
66

77
use PHPUnit\Framework\TestCase;
8-
//use App\App;
8+
9+
// use App\App;
910

1011
final class ExampleTest extends TestCase
1112
{
1213
private $app;
1314

14-
/*
15-
public function setUp(): void
16-
{
17-
$this->app = new App("sushil");
18-
// $this->app->getName();
19-
}
20-
*/
15+
/*
16+
public function setUp(): void
17+
{
18+
$this->app = new App("sushil");
19+
// $this->app->getName();
20+
}
21+
*/
2122

22-
public function testTwoNumbersAreSame(): void
23+
public function test_two_numbers_are_same(): void
2324
{
2425
$this->assertSame(1, 1);
2526
}

0 commit comments

Comments
 (0)