Skip to content

Commit 876903a

Browse files
committed
Repository version updated and the minimum required PHP version
1 parent 41eb614 commit 876903a

File tree

9 files changed

+35
-28
lines changed

9 files changed

+35
-28
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## 1.1.0 - 2017-01-30
4+
* Compatible with PHP 5.6 or higher.
5+
6+
## 1.0.0-v - 2017-01-30
7+
* Compatible only with PHP 7.0 or higher. In the next versions, the library will be modified to make it compatible with PHP 5.6 or higher.
8+
39
## 1.0.0 - 2016-12-14
410
* Added `Josantonius\ErrorHandler\ErrorHandler` class.
511
* Added `Josantonius\ErrorHandler\ErrorHandler->__construct()` method.

README-ES.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ Para instalar PHP ErrorHandler library, simplemente escribe:
3232

3333
### Requisitos
3434

35-
Esta ĺibrería es soportada por versiones de PHP 7.0 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
36-
37-
Para utilizar esta librería en HHVM (HipHop Virtual Machine) tendrás que activar los tipos escalares. Añade la siguiente ĺínea "hhvm.php7.scalar_types = true" en tu "/etc/hhvm/php.ini".
35+
Esta ĺibrería es soportada por versiones de PHP 5.6 o superiores y es compatible con versiones de HHVM 3.0 o superiores.
3836

3937
### Cómo empezar y ejemplos
4038

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ To install PHP ErrorHandler library, simply:
3232

3333
### Requirements
3434

35-
This library is supported by PHP versions 7.0 or higher and is compatible with HHVM versions 3.0 or higher.
36-
37-
To use this library in HHVM (HipHop Virtual Machine) you will have to activate the scalar types. Add the following line "hhvm.php7.scalar_types = true" in your "/etc/hhvm/php.ini".
35+
This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.
3836

3937
### Quick Start and Examples
4038

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "josantonius/errorhandler",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"type": "library",
55
"description": "PHP library for handling exceptions and errors.",
66
"keywords": [
@@ -25,7 +25,7 @@
2525
"minimum-stability": "dev",
2626
"prefer-stable" : true,
2727
"require": {
28-
"php" : ">=7.0"
28+
"php" : ">=5.6"
2929
},
3030
"autoload": {
3131
"psr-4": {

src/ErrorHandler.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* PHP library for handling exceptions and errors.
44
*
@@ -8,9 +8,9 @@
88
* @author Josantonius - info@josantonius.com
99
* @copyright Copyright (c) 2016 JST PHP Framework
1010
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
11+
* @version 1.1.0
1212
* @link https://github.com/Josantonius/PHP-ErrorHandler
13-
* @since File available since 1.0.0 - Update: 2016-12-19
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\ErrorHandler;
@@ -91,7 +91,7 @@ public function catchException(Exception $e) {
9191
* @param int $file → error file
9292
* @param int $line → error line
9393
*/
94-
public function catchError(int $code, string $msg, string $file, int $line) {
94+
public function catchError($code, $msg, $file, $line) {
9595

9696
static::$stack = [
9797
'type' => $this->getErrorType($code),
@@ -131,9 +131,9 @@ public function prepareException($e) {
131131

132132
static::$stack = [
133133
'type' => 'Exception',
134-
'message' => $e->getMessage() ?? '',
135-
'file' => $e->getFile() ?? 0,
136-
'line' => $e->getLine() ?? 0,
134+
'message' => (isset($e->getMessage())) ? $e->getMessage() : '',
135+
'file' => (isset($e->getFile())) ? $e->getFile() : 0,
136+
'line' => (isset($e->getLine())) ? $e->getLine() : 0,
137137
'code' => $e->getCode() ? "[" . $e->getCode() . "]" : "",
138138
'trace' => '',
139139
];
@@ -145,12 +145,14 @@ public function prepareException($e) {
145145
foreach ($e->getTrace() as $key => $value) {
146146

147147
$tab .= "· · · · ";
148+
149+
$statusCode = (isset($e->statusCode)) ? $e->statusCode : 0;
148150

149151
static::$stack['trace'] = "\r\n\r\n<hr>" .
150152

151153
$tab . " [Trace " . ($key + 1) . "]" .
152154
$tab . " FILE: " . $value['file'] .
153-
$tab . " HTTP CODE: " . ($e->statusCode ?? 0) .
155+
$tab . " HTTP CODE: " . $statusCode .
154156
$tab . " FUNCTION: " . $value['function'] .
155157
$tab . " CLASS: " . $value['class'] .
156158
$tab . " ARGS: " . json_encode($value['args']) .
@@ -171,7 +173,7 @@ public function prepareException($e) {
171173
*
172174
* @return string → error type
173175
*/
174-
protected function getErrorType(int $code): string {
176+
protected function getErrorType($code) {
175177

176178
switch($code) {
177179

@@ -227,10 +229,13 @@ protected function show() {
227229

228230
ob_start();
229231

230-
static::$stack['css'] ?? static::$stack['css'] = require($css);
232+
if (!isset(static::$stack['css'])) {
233+
234+
static::$stack['css'] = require($css);
235+
}
231236

232237
require(__DIR__ . '/resources/view.php');
233238

234239
ob_end_flush();
235240
}
236-
}
241+
}

src/Exception/ErrorHandlerException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22
/**
33
* PHP library for handling exceptions and errors.
44
*
@@ -35,7 +35,7 @@ class ErrorHandlerException extends \Exception {
3535
* @param int $error → error code (Optional)
3636
* @param int $status → HTTP response status code (Optional)
3737
*/
38-
public function __construct(string $msg = '', int $error = 0, int $status = 0) {
38+
public function __construct($msg = '', $error = 0, $status = 0) {
3939

4040
$this->message = $msg;
4141
$this->code = $error;

src/resources/styles.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* @author Josantonius - info@josantonius.com
88
* @copyright Copyright (c) 2016 JST PHP Framework
99
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
10-
* @version 1.0.0
10+
* @version 1.1.0
1111
* @link https://github.com/Josantonius/ErrorHandler
12-
* @since Class available since 1.0.0 - Update: Dec 05, 2016
12+
* @since File available since 1.0.0 - Update: 2017-01-30
1313
*/
1414
?>
1515
<style type="text/css">

src/resources/view.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* @author Josantonius - info@josantonius.com
88
* @copyright Copyright (c) 2016 JST PHP Framework
99
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
10-
* @version 1.0.0
10+
* @version 1.1.0
1111
* @link https://github.com/Josantonius/ErrorHandler
12-
* @since Class available since 1.0.0 - Update: Nov 19, 2016
12+
* @since File available since 1.0.0 - Update: 2017-01-30
1313
*/
1414
?>
1515
<div class="jst-alert Default <?= static::$stack['type'] ?>">

tests/ErrorHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* @author Josantonius - info@josantonius.com
99
* @copyright Copyright (c) 2016 JST PHP Framework
1010
* @license https://opensource.org/licenses/MIT - The MIT License (MIT)
11-
* @version 1.0.0
11+
* @version 1.1.0
1212
* @link https://github.com/Josantonius/PHP-ErrorHandler
13-
* @since File available since 1.0.0 - Update: 2016-12-14
13+
* @since File available since 1.0.0 - Update: 2017-01-30
1414
*/
1515

1616
namespace Josantonius\ErrorHandler\Tests;
@@ -91,4 +91,4 @@ public function testSProvokeUserWarning() {
9191
trigger_error("This is a user-level warning message", E_USER_WARNING)
9292
);
9393
}
94-
}
94+
}

0 commit comments

Comments
 (0)