Skip to content

Commit

Permalink
E_NOTICE is now E_WARNING for undefined array key ref https://3v4l.or…
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jun 25, 2021
1 parent e908d68 commit cad644e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ Give it a try!

_**Web Access**_

| URl | Preview For |
|---------------------------------------|-----------------|
| http://yourlaminasormezzioapp/error-preview | Exception |
| http://yourlaminasormezzioapp/error-preview/error | Error |
| http://yourlaminasormezzioapp/error-preview/notice | PHP E_NOTICE |
| http://yourlaminasormezzioapp/error-preview/fatal | PHP Fatal Error |
| URl | Preview For |
|-----------------------------------------------------|-----------------|
| http://yourlaminasormezzioapp/error-preview | Exception |
| http://yourlaminasormezzioapp/error-preview/error | Error |
| http://yourlaminasormezzioapp/error-preview/warning | PHP E_WARNING |
| http://yourlaminasormezzioapp/error-preview/fatal | PHP Fatal Error |

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
// excluded php errors
'exclude-php-errors' => [
\E_USER_DEPRECATED,
\E_NOTICE,
\E_WARNING,
],

// show or not error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
'exclude-php-errors' => [

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

],

Expand Down
6 changes: 3 additions & 3 deletions spec/Handler/Writer/Checker/DbSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
allow($resultSet)->toReceive('current')->andReturn(null);
allow(TableGateway::class)->toReceive('selectWith')->with($select)->andReturn($resultSet);

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

});
Expand Down Expand Up @@ -116,7 +116,7 @@
);
allow(TableGateway::class)->toReceive('selectWith')->with($select)->andReturn($resultSet);

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

});
Expand All @@ -142,7 +142,7 @@
);
allow(TableGateway::class)->toReceive('selectWith')->with($select)->andReturn($resultSet);

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

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,27 @@

});

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

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

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

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

\ob_start();
$this->application->run();
$content = \ob_get_clean();

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

unlink(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/notice.phtml');
unlink(__DIR__ . '/../Fixture/view/error-hero-module/error-preview/warning.phtml');
rmdir(__DIR__ . '/../Fixture/view/error-hero-module/error-preview');
rmdir(__DIR__ . '/../Fixture/view/error-hero-module');

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/ErrorPreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public function errorAction()
throw new Error('a sample error preview');
}

public function noticeAction()
public function warningAction()
{
$array = [];
$array[1]; // E_NOTICE
$array[1]; // E_WARNING
}

public function fatalAction()
Expand Down

0 comments on commit cad644e

Please sign in to comment.