Skip to content

Commit

Permalink
another function call optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jul 5, 2017
1 parent 762bb04 commit 7e229d7
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/Controller/ErrorPreviewConsoleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Zend\Mvc\Controller\AbstractConsoleController;

if (! class_exists('Zend\Mvc\Controller\AbstractConsoleController')) {
class_alias(
if (! \class_exists('Zend\Mvc\Controller\AbstractConsoleController')) {
\class_alias(
'Zend\Mvc\Console\Controller\AbstractConsoleController',
'Zend\Mvc\Controller\AbstractConsoleController'
);
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Formatter/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function format($event)
$event['timestamp'] = $event['timestamp']->format($this->getDateTimeFormat());
}

return str_replace(
return \str_replace(
'\n',
PHP_EOL,
json_encode($event, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
\json_encode($event, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
);
}
}
2 changes: 1 addition & 1 deletion src/Handler/Logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private function getRequestData()
? $this->request->getPost()->toArray()
: [];
$raw_data = $this->request->getContent();
$raw_data = str_replace(PHP_EOL, '', $raw_data);
$raw_data = \str_replace(PHP_EOL, '', $raw_data);
$files_data = $this->request->getFiles()->toArray();

$request_data = [
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/LoggingFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public function __invoke($container)
$requestUri = $request->getRequestUri();
}
} else {
$serverUrl = php_uname('n');
$serverUrl = \php_uname('n');
$request = new ConsoleRequest();
$requestUri = ':'. basename(getcwd()) .' ' . get_current_user() . '$ php ' . $request->getScriptName() . ' ' . $request->toString();
$requestUri = ':'. \basename(\getcwd()) .' ' . \get_current_user() . '$ php ' . $request->getScriptName() . ' ' . $request->toString();
}

$config = $container->get('config');
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/Writer/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function isExists($errorFile, $errorLine, $errorMessage, $errorUrl)
}

$first = $result->current()[$timestamp];
$last = date('Y-m-d H:i:s');
$last = \date('Y-m-d H:i:s');

$diff = \strtotime($last) - \strtotime($first);
if ($diff <= $this->configLoggingSettings['same-error-log-time-range']) {
Expand Down
10 changes: 5 additions & 5 deletions src/Handler/Writer/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public function shutdown()
$body->addPart($mimePart);

foreach ($this->requestData['files_data'] as $key => $row) {
if (key($row) === 'name') {
if (\key($row) === 'name') {
// single upload
$mimePart = new MimePart(fopen($row['tmp_name'], 'r'));
$mimePart = new MimePart(\fopen($row['tmp_name'], 'r'));
$mimePart->type = $row['type'];
$mimePart->filename = $row['name'];
$mimePart->disposition = Mime::DISPOSITION_ATTACHMENT;
Expand All @@ -80,7 +80,7 @@ public function shutdown()
} else {
// collection upload
foreach ($row as $multiple => $upload) {
$mimePart = new MimePart(fopen($upload['tmp_name'], 'r'));
$mimePart = new MimePart(\fopen($upload['tmp_name'], 'r'));
$mimePart->type = $upload['type'];
$mimePart->filename = $upload['name'];
$mimePart->disposition = Mime::DISPOSITION_ATTACHMENT;
Expand All @@ -105,11 +105,11 @@ public function shutdown()
try {
$this->transport->send($this->mail);
} catch (Exception $e) {
trigger_error(
\trigger_error(
"unable to send log entries via email; " .
"message = {$e->getMessage()}; " .
"code = {$e->getCode()}; " .
"exception class = " . get_class($e),
"exception class = " . \get_class($e),
E_USER_WARNING
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/HeroTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait HeroTrait
*/
public function execOnShutdown()
{
$error = error_get_last();
$error = \error_get_last();
if ($error && $error['type']) {
$this->phpErrorHandler($error['type'], $error['message'], $error['file'], $error['line']);
}
Expand All @@ -58,8 +58,8 @@ public function phpErrorHandler($errorType, $errorMessage, $errorFile, $errorLin
}

if (! $this->errorHeroModuleConfig['display-settings']['display_errors']) {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 0);
\error_reporting(E_ALL | E_STRICT);
\ini_set('display_errors', 0);
}

if (\in_array($errorType, $this->errorHeroModuleConfig['display-settings']['exclude-php-errors'])) {
Expand Down
6 changes: 3 additions & 3 deletions src/Listener/Mvc.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function attach(EventManagerInterface $events, $priority = 1)
*/
public function phpError(Event $e)
{
register_shutdown_function([$this, 'execOnShutdown']);
set_error_handler([$this, 'phpErrorHandler']);
\register_shutdown_function([$this, 'execOnShutdown']);
\set_error_handler([$this, 'phpErrorHandler']);
}

/**
Expand All @@ -79,7 +79,7 @@ public function exceptionError(Event $e)
return;
}

$exceptionClass = get_class($exception);
$exceptionClass = \get_class($exception);
if (isset($this->errorHeroModuleConfig['display-settings']['exclude-exceptions']) &&
\in_array($exceptionClass, $this->errorHeroModuleConfig['display-settings']['exclude-exceptions'])) {
// rely on original mvc process
Expand Down
6 changes: 3 additions & 3 deletions src/Middleware/Expressive.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
*/
public function phpError()
{
register_shutdown_function([$this, 'execOnShutdown']);
set_error_handler([$this, 'phpErrorHandler']);
\register_shutdown_function([$this, 'execOnShutdown']);
\set_error_handler([$this, 'phpErrorHandler']);
}

/**
Expand All @@ -81,7 +81,7 @@ public function phpError()
*/
public function exceptionError($e, $request)
{
$exceptionClass = get_class($e);
$exceptionClass = \get_class($e);
if (isset($this->errorHeroModuleConfig['display-settings']['exclude-exceptions']) &&
\in_array($exceptionClass, $this->errorHeroModuleConfig['display-settings']['exclude-exceptions'])
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/Routed/Preview/ErrorPreviewAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
throw new \Exception('a sample error preview');
}

if ($action === 'php7error' && class_exists(\Error::class)) {
if ($action === 'php7error' && \class_exists(\Error::class)) {
throw new \Error('error of php 7');
}

Expand Down

0 comments on commit 7e229d7

Please sign in to comment.