Skip to content

Commit

Permalink
Merge pull request #27 from code418/master
Browse files Browse the repository at this point in the history
PHP 8 Support
  • Loading branch information
baibaratsky authored Jan 7, 2023
2 parents 5b36210 + 30d9519 commit edace56
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
8 changes: 7 additions & 1 deletion ErrorHandlerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ trait ErrorHandlerTrait
*/
public $payloadDataCallback;

/**
* @return void
*/
public function logException($exception)
{
$this->logExceptionRollbar($exception);
Expand Down Expand Up @@ -51,7 +54,7 @@ private function getPayloadData($exception)
return $payloadData;
}

private function payloadCallback()
private function payloadCallback(): array|null
{
if (!isset($this->payloadDataCallback)) {
return null;
Expand All @@ -70,6 +73,9 @@ private function payloadCallback()
return $payloadData;
}

/**
* @return void
*/
protected function logExceptionRollbar($exception)
{
foreach (Yii::$app->get($this->rollbarComponentName)->ignoreExceptions as $ignoreRecord) {
Expand Down
16 changes: 13 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@
}
],
"require": {
"php": ">=7.1",
"yiisoft/yii2": "^2.0.15",
"rollbar/rollbar": "^2.1"
"php": ">=8.0",
"yiisoft/yii2": "^2.0",
"rollbar/rollbar": "^3.1"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"baibaratsky\\yii\\rollbar\\": ""
}
},
"config": {
"allow-plugins": {
"yiisoft/yii2-composer": true
}
},
"require-dev": {
"vimeo/psalm": "^5.1"
}
}
8 changes: 7 additions & 1 deletion log/Target.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ class Target extends \yii\log\Target
{
protected $requestId;

/**
* @return void
*/
public function init()
{
$this->requestId = uniqid(gethostname(), true);
parent::init();
}

/**
* @return void
*/
public function export()
{
foreach ($this->messages as $message) {
Expand All @@ -28,7 +34,7 @@ public function export()
}
}

protected static function getLevelName($level)
protected static function getLevelName($level): string
{
if (in_array($level,
[Logger::LEVEL_PROFILE, Logger::LEVEL_PROFILE_BEGIN, Logger::LEVEL_PROFILE_END, Logger::LEVEL_TRACE])) {
Expand Down
20 changes: 20 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="5"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="console" />
<directory name="log" />
<directory name="web" />
<file name="ErrorHandlerTrait.php" />
<file name="Rollbar.php" />
<file name="WithPayload.php" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>

0 comments on commit edace56

Please sign in to comment.