Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rector [batch] #26

Merged
merged 10 commits into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/rector.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'psalm.xml'

name: rector

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector.yml@master
with:
os: >-
['ubuntu-latest']
php: >-
['8.0']
9 changes: 4 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

## 1.1.1 under development

- Enh: Add composer require checker into CI

- no changes in this release.

## 1.1.0 May 23, 2022

- Chg #24: Raise the minimum `yiisoft/log` version to `^2.0` and the minimum PHP version to 8.0 (rustamwin)
- Chg #24: Raise the minimum `yiisoft/log` version to `^2.0` and the minimum PHP version to 8.0 (@rustamwin)

## 1.0.2 August 26, 2021

- Bug #20: Remove `Psr\Log\LoggerInterface` definition from configuration for using multiple targets to application (devanych)
- Bug #20: Remove `Psr\Log\LoggerInterface` definition from configuration for using multiple targets to application (@devanych)

## 1.0.1 March 23, 2021

- Chg: Adjust config for new config plugin (samdark)
- Chg: Adjust config for new config plugin (@samdark)

## 1.0.0 February 11, 2021

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"maglnet/composer-require-checker": "^4.2",
"php-mock/php-mock-phpunit": "^2.6",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.15.1",
"roave/infection-static-analysis-plugin": "^1.25",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.2"
Expand Down
27 changes: 27 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

// register a single rule
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
]);
};
44 changes: 10 additions & 34 deletions src/SyslogTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,10 @@
use const LOG_WARNING;

/**
* SyslogTarget writes log to syslog.
* `SyslogTarget` writes log to syslog.
*/
final class SyslogTarget extends Target
{
/**
* @var string The string that is prefixed to each message.
*
* @see https://www.php.net/openlog
*/
private string $identity;

/**
* @var int Bit options to be used when generating a log message.
*
* Defaults to `LOG_ODELAY | LOG_PID`.
*
* @see https://www.php.net/openlog
*/
private int $options;

/**
* @var int Used to specify what type of program is logging the message. This allows you to specify (in your
* machine's syslog configuration) how messages coming from different facilities will be handled.
*
* Defaults to `LOG_USER`.
*
* @see https://www.php.net/openlog
*/
private int $facility;

/**
* @var array Syslog levels.
*/
Expand All @@ -69,14 +43,16 @@ final class SyslogTarget extends Target
/**
* @param string $identity The string that is prefixed to each message.
* @param int $options Bit options to be used when generating a log message.
* @param int $facility Used to specify what type of program is logging the message. This allows you to specify (in your
* machine's syslog configuration) how messages coming from different facilities will be handled.
* @param int $facility Used to specify what type of program is logging the message. This allows you to specify
* (in your machine's syslog configuration) how messages coming from different facilities will be handled.
*
* @link https://www.php.net/openlog
*/
public function __construct(string $identity, int $options = LOG_ODELAY | LOG_PID, int $facility = LOG_USER)
{
$this->identity = $identity;
$this->options = $options;
$this->facility = $facility;
public function __construct(
private string $identity,
private int $options = LOG_ODELAY | LOG_PID,
private int $facility = LOG_USER
) {
parent::__construct();

$this->setFormat(static function (Message $message) {
Expand Down