From d578dc1905cfab18660ea24408cd20197a7f9dc7 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 17:41:18 +0900 Subject: [PATCH 1/8] drop support version php 5.x --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4afe803..a51ef3c 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,16 @@ } ], "require": { - "php": ">=5.4.0", + "php": ">=7.0.0", "pear-pear.php.net/pear": "^1.10" }, "require-dev": { "phpunit/phpunit": "^4.8", "doctrine/instantiator": "~1.0.5" }, + "autoload": { + "files": ["/Panda.php", "/Panda/"] + }, "include-path": [ "./" ], From 4d5d720f360481fb373ae1a2b0aaa8bb42ffec0f Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 17:41:40 +0900 Subject: [PATCH 2/8] remove deprecate function create_function --- Panda/vendors/debuglib.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Panda/vendors/debuglib.php b/Panda/vendors/debuglib.php index fa7318e..281f15a 100644 --- a/Panda/vendors/debuglib.php +++ b/Panda/vendors/debuglib.php @@ -378,14 +378,9 @@ public static function trim_leading_tabs( $string, $tab_padding = NULL ) { public static function _handle_whitespace( $string ) { // replace 2 or more spaces with nobreaks (for special markup) - $string = preg_replace_callback( - '/ {2,}/', - create_function( - '$matches', - 'return str_repeat(" ", strlen($matches[0]));' - ), - $string - ); + $string = preg_replace_callback('/ {2,}/', function($matches) { + return str_repeat(" ", strlen($matches[0])); + }, $string); $string = preg_replace(array('/ $/', '/^ /'), ' ', $string); # mark spaces at the start/end of the string with red underscores $string = str_replace("\t", '   ', $string); # replace tabulators with ' ยป' From 16019a547c1e9748cc0414256c0bbdaab7f49890 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 17:42:15 +0900 Subject: [PATCH 3/8] catch FatalError --- Panda.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Panda.php b/Panda.php index 17d8c54..fb70e08 100644 --- a/Panda.php +++ b/Panda.php @@ -469,7 +469,7 @@ public static function onPearError(PEAR_Error $error) $userInfo = $error->getUserInfo(); $trace = ($error->getBackTrace()); $info = array('Error Type' => $error->getType(), - 'Debug Info' => $error->getUserInfo()); + 'Debug Info' => ''); //$error->getUserInfo() if ($debugInfo !== $userInfo) { $info['User Info'] = $userInfo; } @@ -603,8 +603,11 @@ public static function onLivePhpError($code, $message, $file, $line, array $errc * * @return void */ - public static function onException(Exception $e, $httpScreenOutput = true) + public static function onException($e, $httpScreenOutput = true) { + if (! $e instanceof Exception) { + throw $e; + } try { $class = get_class($e); $body = null; From c44d761169895e0cb4dc8ebaecef483f3bad613f Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 19:24:42 +0900 Subject: [PATCH 4/8] update autoload --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a51ef3c..efa7464 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "doctrine/instantiator": "~1.0.5" }, "autoload": { - "files": ["/Panda.php", "/Panda/"] + "classmap": ["Panda"], + "files": ["./Panda.php"] }, "include-path": [ "./" From 405625dd57aeb934c06e9b4b8453d636f527c895 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 19:32:38 +0900 Subject: [PATCH 5/8] remove no testmethod --- tests/Test/Panda/PandaTest.php | 243 --------------------------------- 1 file changed, 243 deletions(-) diff --git a/tests/Test/Panda/PandaTest.php b/tests/Test/Panda/PandaTest.php index 9820c80..eb9aa80 100644 --- a/tests/Test/Panda/PandaTest.php +++ b/tests/Test/Panda/PandaTest.php @@ -1,22 +1,7 @@ assertTrue(isset($config[Panda::CONFIG_DEBUG])); } - /** - * @runInSeparateProcess - * @todo Implement testInit(). - */ public function testInit() { $config = Panda::getConfig(); @@ -65,50 +46,6 @@ public function testInit() $this->assertTrue($config[Panda::CONFIG_DEBUG] === true); } - /** - * @runInSeparateProcess - * @todo Implement testRestoreHandler(). - */ - public function testRestoreHandler() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOnAssert(). - */ - public function testOnAssert() - { - // $config = Panda::getConfig(); - // $config[Panda::CONFIG_DEBUG] = true; - // Panda::init($config); - //assert(false); - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOnStackError(). - */ - public function testOnStackError() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOnPearError(). - */ public function testOnPearError() { if (version_compare(PHP_VERSION, '5.5', '>=')) { @@ -118,184 +55,4 @@ public function testOnPearError() } } - /** - * @runInSeparateProcess - * @todo Implement testOnDebugPhpError(). - */ - public function testOnDebugPhpError() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOnLivePhpError(). - */ - public function testOnLivePhpError() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOnException(). - */ - public function testOnException() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testIsValidPath(). - */ - public function testIsValidPath() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testIsCliOutput(). - */ - public function testIsCliOutput() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testError(). - */ - public function testError() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testMessage(). - */ - public function testMessage() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement test_getFileSummary(). - */ - public function test_getFileSummary() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testGetEditorLink(). - */ - public function testGetEditorLink() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOnFatalError(). - */ - public function testOnFatalError() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOnStrictError(). - */ - public function testOnStrictError() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testOutputHttpStatus(). - */ - public function testOutputHttpStatus() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testGetErrorStat(). - */ - public function testGetErrorStat() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testGetTempDir(). - */ - public function testGetTempDir() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } - - /** - * @runInSeparateProcess - * @todo Implement testGetOuterPathErrors(). - */ - public function testGetOuterPathErrors() - { - // Remove the following lines when you implement this test. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); - } } -?> From 482fcfb4fe33fc14d04fb6dd0855e349d258b222 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 19:32:47 +0900 Subject: [PATCH 6/8] update composer.json --- composer.json | 60 ++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/composer.json b/composer.json index efa7464..76d25ce 100644 --- a/composer.json +++ b/composer.json @@ -1,35 +1,31 @@ { - "name": "bearsaturday/panda", - "description": "Panda is a PHP error handler.", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Akihito Koriyama", - "email": "akihito.koriyama@gmail.com" + "name": "bearsaturday/panda", + "description": "Panda is a PHP error handler.", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Akihito Koriyama", + "email": "akihito.koriyama@gmail.com" + } + ], + "repositories": [ + { + "type": "pear", + "url": "http://pear.php.net" + } + ], + "require": { + "php": ">=7.0.0", + "pear-pear.php.net/pear": "^1.10" + }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, + "autoload": { + "classmap": ["Panda"], + "files": ["./Panda.php"] + }, + "config":{ + "secure-http" : false } - ], - "repositories": [ - { - "type": "pear", - "url": "http://pear.php.net" - } - ], - "require": { - "php": ">=7.0.0", - "pear-pear.php.net/pear": "^1.10" - }, - "require-dev": { - "phpunit/phpunit": "^4.8", - "doctrine/instantiator": "~1.0.5" - }, - "autoload": { - "classmap": ["Panda"], - "files": ["./Panda.php"] - }, - "include-path": [ - "./" - ], - "config":{ - "secure-http" : false - } } From e31f3777d2e783db138988a8fb2cf9340abf288f Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 19:32:57 +0900 Subject: [PATCH 7/8] drop php5.x support --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b765a07..b3f4f49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: php sudo: false php: - - 5.4 - - 5.5 - - 5.6 - 7 - 7.1 - 7.2 From b7dbe7f75098d76be2429cd73a09b6ba13be2170 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Mon, 4 Jun 2018 19:53:03 +0900 Subject: [PATCH 8/8] update test --- phpunit.xml.dist | 8 ----- tests/Test/Panda/PandaTest.php | 58 +++++++++------------------------- 2 files changed, 15 insertions(+), 51 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 19787fa..45ec1c7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -4,12 +4,4 @@ tests - - - src - - - - - diff --git a/tests/Test/Panda/PandaTest.php b/tests/Test/Panda/PandaTest.php index eb9aa80..43f7206 100644 --- a/tests/Test/Panda/PandaTest.php +++ b/tests/Test/Panda/PandaTest.php @@ -4,55 +4,27 @@ class PandaTest extends PHPUnit_Framework_TestCase { protected function setUp() { - error_reporting(E_ALL & ~E_DEPRECATED); - require_once 'PEAR.php'; - $config = array(Panda::CONFIG_DEBUG => false, - Panda::CONFIG_VALID_PATH => array('/'), - Panda::CONFIG_LOG_PATH => '/tmp', - Panda::CONFIG_ON_ERROR_FIRED => false, - Panda::CONFIG_ON_FATAL_ERROR => 'Panda/template/fatal.html', - Panda::CONFIG_ENABLE_FIREPHP => true, - Panda::CONFIG_FATAL_HTML => 'Panda/template/fatal.html', - Panda::CONFIG_HTTP_TPL => 'Panda/template/http.php', - Panda::CONFIG_CATCH_FATAL => false, - Panda::CONFIG_CATCH_STRICT => true, - Panda::CONFIG_PANDA_PATH => '/', - Panda::CONFIG_EDITOR => 0); + $config = [ + Panda::CONFIG_DEBUG => false, + Panda::CONFIG_VALID_PATH => ['/'], + Panda::CONFIG_LOG_PATH => '/tmp', + Panda::CONFIG_ON_ERROR_FIRED => false, + Panda::CONFIG_ON_FATAL_ERROR => 'Panda/template/fatal.html', + Panda::CONFIG_ENABLE_FIREPHP => true, + Panda::CONFIG_FATAL_HTML => 'Panda/template/fatal.html', + Panda::CONFIG_HTTP_TPL => 'Panda/template/http.php', + Panda::CONFIG_CATCH_FATAL => false, + Panda::CONFIG_CATCH_STRICT => true, + Panda::CONFIG_PANDA_PATH => '/', + Panda::CONFIG_EDITOR => 0 + ]; Panda::init($config); } - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } - - /** - */ public function testGetConfig() { $config = Panda::getConfig(); $this->assertTrue(isset($config[Panda::CONFIG_DEBUG])); + $this->assertFalse($config[Panda::CONFIG_DEBUG]); } - - public function testInit() - { - $config = Panda::getConfig(); - $config[Panda::CONFIG_DEBUG] = true; - Panda::init($config); - $config = Panda::getConfig(); - $this->assertTrue($config[Panda::CONFIG_DEBUG] === true); - } - - public function testOnPearError() - { - if (version_compare(PHP_VERSION, '5.5', '>=')) { - $last_handler = set_exception_handler(null); - $this->assertSame('Panda', $last_handler[0]); - $this->assertSame('onException', $last_handler[1]); - } - } - }