Skip to content

Commit cad644e

Browse files
committed
E_NOTICE is now E_WARNING for undefined array key ref https://3v4l.org/okACat
1 parent e908d68 commit cad644e

File tree

6 files changed

+20
-19
lines changed

6 files changed

+20
-19
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,12 @@ Give it a try!
340340

341341
_**Web Access**_
342342

343-
| URl | Preview For |
344-
|---------------------------------------|-----------------|
345-
| http://yourlaminasormezzioapp/error-preview | Exception |
346-
| http://yourlaminasormezzioapp/error-preview/error | Error |
347-
| http://yourlaminasormezzioapp/error-preview/notice | PHP E_NOTICE |
348-
| http://yourlaminasormezzioapp/error-preview/fatal | PHP Fatal Error |
343+
| URl | Preview For |
344+
|-----------------------------------------------------|-----------------|
345+
| http://yourlaminasormezzioapp/error-preview | Exception |
346+
| http://yourlaminasormezzioapp/error-preview/error | Error |
347+
| http://yourlaminasormezzioapp/error-preview/warning | PHP E_WARNING |
348+
| http://yourlaminasormezzioapp/error-preview/fatal | PHP Fatal Error |
349349

350350
You will get the following page if display_errors config is 0:
351351

spec/Fixture/config/autoload-for-enable-display-errors/error-hero-module.local.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
// excluded php errors
6161
'exclude-php-errors' => [
6262
\E_USER_DEPRECATED,
63-
\E_NOTICE,
63+
\E_WARNING,
6464
],
6565

6666
// show or not error

spec/Fixture/config/autoload-for-specific-error-and-exception/error-hero-module.local.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
'exclude-php-errors' => [
5252

5353
// can be specific error with specific message
54-
[\E_NOTICE, 'Undefined offset: 1'],
54+
[\E_WARNING, 'Undefined array key 1'],
5555

5656
],
5757

spec/Handler/Writer/Checker/DbSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
allow($resultSet)->toReceive('current')->andReturn(null);
8686
allow(TableGateway::class)->toReceive('selectWith')->with($select)->andReturn($resultSet);
8787

88-
$actual = $this->writerHandler->isExists('file', 1, 'Undefined offset: 1', 'http://serverUrl/uri', 'E_NOTICE');
88+
$actual = $this->writerHandler->isExists('file', 1, 'Undefined array key 1', 'http://serverUrl/uri', 'E_WARNING');
8989
expect($actual)->toBe(false);
9090

9191
});
@@ -116,7 +116,7 @@
116116
);
117117
allow(TableGateway::class)->toReceive('selectWith')->with($select)->andReturn($resultSet);
118118

119-
$actual = $this->writerHandler->isExists('file', 1, 'Undefined offset: 1', 'http://serverUrl/uri', 'E_NOTICE');
119+
$actual = $this->writerHandler->isExists('file', 1, 'Undefined array key 1', 'http://serverUrl/uri', 'E_WARNING');
120120
expect($actual)->toBe(false);
121121

122122
});
@@ -142,7 +142,7 @@
142142
);
143143
allow(TableGateway::class)->toReceive('selectWith')->with($select)->andReturn($resultSet);
144144

145-
$actual = $this->writerHandler->isExists('file', 1, 'Undefined offset: 1', 'http://serverUrl/uri', 'E_NOTICE');
145+
$actual = $this->writerHandler->isExists('file', 1, 'Undefined array key 1', 'http://serverUrl/uri', 'E_WARNING');
146146
expect($actual)->toBe(true);
147147

148148
});

spec/Integration/IntegrationViaErrorPreviewControllerForSpecificErrorAndExceptionSpec.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,27 @@
5858

5959
});
6060

61-
describe('/error-preview/notice', function() {
61+
describe('/error-preview/warning', function() {
6262

6363
it('empty as rely to original mvc process to handle', function() {
6464

6565
@mkdir(__DIR__ . '/../Fixture/view/error-hero-module/error-preview', 0755, true);
66-
file_put_contents(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/notice.phtml', '');
66+
file_put_contents(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/warning.phtml', '');
6767

6868
$request = $this->application->getRequest();
6969
$request->setMethod('GET');
70-
$request->setUri('http://example.com/error-preview/notice');
71-
$request->setRequestUri('/error-preview/notice');
70+
$request->setUri('http://example.com/error-preview/warning');
71+
$request->setRequestUri('/error-preview/warning');
7272

7373
\ob_start();
7474
$this->application->run();
7575
$content = \ob_get_clean();
7676

7777
expect(\ob_get_clean())->toBe('');
78-
expect($this->application->getResponse()->getStatusCode())->toBe(500);
78+
// yes, excluded E_* error means it ignored, means it passed, means it is 200 status code
79+
expect($this->application->getResponse()->getStatusCode())->toBe(200);
7980

80-
unlink(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/notice.phtml');
81+
unlink(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/warning.phtml');
8182
rmdir(__DIR__ . '/../Fixture/view/error-hero-module/error-preview');
8283
rmdir(__DIR__ . '/../Fixture/view/error-hero-module');
8384

src/Controller/ErrorPreviewController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public function errorAction()
2121
throw new Error('a sample error preview');
2222
}
2323

24-
public function noticeAction()
24+
public function warningAction()
2525
{
2626
$array = [];
27-
$array[1]; // E_NOTICE
27+
$array[1]; // E_WARNING
2828
}
2929

3030
public function fatalAction()

0 commit comments

Comments
 (0)