Skip to content
This repository was archived by the owner on Jan 23, 2019. It is now read-only.

Commit 990112a

Browse files
committed
some update
1 parent 6e3b39d commit 990112a

File tree

7 files changed

+28
-16
lines changed

7 files changed

+28
-16
lines changed

src/Helpers/AssertHelper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
*/
1515
class AssertHelper
1616
{
17-
1817
/**
1918
* 检查字符串是否是正确的变量名
2019
* @param $string

src/Helpers/Json.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: inhere
5+
* Date: 2017-10-25
6+
* Time: 9:41
7+
*/
8+
9+
namespace Inhere\Library\Helpers;
10+
11+
/**
12+
* Class Json
13+
* @package Inhere\Library\Helpers
14+
*/
15+
class Json extends JsonHelper
16+
{
17+
18+
}

src/Helpers/JsonHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class JsonHelper
2323
*/
2424
public static function encode($data): string
2525
{
26-
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
26+
if (PHP_VERSION_ID >= 50400) {
2727
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
2828
}
2929

src/Helpers/PhpError.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PhpError
2020
/**
2121
* $lastError = error_get_last();
2222
* @param array $lastError
23+
* @param null|string $catcher
2324
* @return array
2425
*/
2526
public static function toArray(array $lastError, $catcher = null)

src/Helpers/PhpException.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,7 @@ public static function toHtml($e, $getTrace = true, $catcher = null, $clearHtml
4848
);
4949
}
5050

51-
if ($clearHtml) {
52-
$message = strip_tags($message);
53-
} else {
54-
$message = "<div class=\"exception-box\">{$message}</div>";
55-
}
56-
57-
return $message;
51+
return $clearHtml ? strip_tags($message) : "<div class=\"exception-box\">{$message}</div>";
5852
}
5953

6054
/**

src/Helpers/ProcessHelper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static function fork($id = 0, callable $childHandler = null)
9797
$pid = getmypid();
9898

9999
if ($childHandler) {
100-
call_user_func($childHandler, $id, $pid);
100+
$childHandler($id, $pid);
101101
}
102102

103103
} else {
@@ -122,7 +122,7 @@ public static function wait(callable $onExit)
122122
while (($pid = pcntl_waitpid(-1, $status, WNOHANG)) >= 0) {
123123
if ($pid) {
124124
// ... (callback, pid, exitCode, status)
125-
call_user_func($onExit, $pid, pcntl_wexitstatus($status), $status);
125+
$onExit($pid, pcntl_wexitstatus($status), $status);
126126
} else {
127127
usleep(50000);
128128
}
@@ -357,21 +357,21 @@ public static function afterDo($s, callable $handler)
357357
pcntl_alarm(-1);
358358
}
359359
});*/
360-
self::signal(SIGALRM, $handler);
360+
self::installSignal(SIGALRM, $handler);
361361

362362
// self::alarm($s);
363363
pcntl_alarm($s);
364364
}
365365

366366
/**
367367
* install signal
368-
* @param int $sigal e.g: SIGTERM SIGINT(Ctrl+C) SIGUSR1 SIGUSR2 SIGHUP
368+
* @param int $signal e.g: SIGTERM SIGINT(Ctrl+C) SIGUSR1 SIGUSR2 SIGHUP
369369
* @param callable $handler
370370
* @return bool
371371
*/
372-
public static function installSignal($sigal, callable $handler)
372+
public static function installSignal($signal, callable $handler)
373373
{
374-
return pcntl_signal($sigal, $handler, false);
374+
return pcntl_signal($signal, $handler, false);
375375
}
376376

377377
/**

src/Helpers/Str.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static function has(string $needle, $string)
5252
}
5353

5454
if (is_array($string)) {
55-
foreach ($string as $item) {
55+
foreach ((array)$string as $item) {
5656
if (stripos($item, $needle) !== false) {
5757
return true;
5858
}

0 commit comments

Comments
 (0)