diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml new file mode 100644 index 0000000..adacd73 --- /dev/null +++ b/.github/workflows/rector.yml @@ -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'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 14bbd02..7ffcdb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/composer.json b/composer.json index f03a8e5..d7acc52 100644 --- a/composer.json +++ b/composer.json @@ -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" diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..f55daae --- /dev/null +++ b/rector.php @@ -0,0 +1,27 @@ +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, + ]); +}; diff --git a/src/SyslogTarget.php b/src/SyslogTarget.php index 30da4c4..6bdcf04 100644 --- a/src/SyslogTarget.php +++ b/src/SyslogTarget.php @@ -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. */ @@ -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) {