mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-12 08:04:02 +02:00
Migrate to GH actions, add phpstan
This commit is contained in:
69
.github/workflows/continuous-integration.yml
vendored
Normal file
69
.github/workflows/continuous-integration.yml
vendored
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
name: "Continuous Integration"
|
||||||
|
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
env:
|
||||||
|
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: "CI"
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php-version:
|
||||||
|
- "5.3"
|
||||||
|
- "5.4"
|
||||||
|
- "5.5"
|
||||||
|
- "5.6"
|
||||||
|
- "7.0"
|
||||||
|
- "7.1"
|
||||||
|
- "7.2"
|
||||||
|
- "7.3"
|
||||||
|
- "7.4"
|
||||||
|
- "8.0"
|
||||||
|
# disabled for now as it leads to PHPUnit installing in a very old 4.3 version due to phpspec/prophecy not allowing 8.1
|
||||||
|
# - "8.1"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "Checkout"
|
||||||
|
uses: "actions/checkout@v2"
|
||||||
|
|
||||||
|
- name: "Install PHP 5"
|
||||||
|
if: "startsWith(matrix.php-version, '5.')"
|
||||||
|
uses: "shivammathur/setup-php@v2"
|
||||||
|
with:
|
||||||
|
coverage: "none"
|
||||||
|
php-version: "${{ matrix.php-version }}"
|
||||||
|
extensions: "mongo"
|
||||||
|
|
||||||
|
- name: "Install PHP 7+"
|
||||||
|
if: "!startsWith(matrix.php-version, '5.')"
|
||||||
|
uses: "shivammathur/setup-php@v2"
|
||||||
|
with:
|
||||||
|
coverage: "none"
|
||||||
|
php-version: "${{ matrix.php-version }}"
|
||||||
|
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composercache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composercache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
|
||||||
|
- name: "Install latest dependencies"
|
||||||
|
run: |
|
||||||
|
# Remove PHPStan as it requires a newer PHP
|
||||||
|
composer remove phpstan/phpstan --dev --no-update
|
||||||
|
composer update ${{ env.COMPOSER_FLAGS }}
|
||||||
|
|
||||||
|
- name: "Run tests"
|
||||||
|
run: "composer test"
|
37
.github/workflows/lint.yml
vendored
Normal file
37
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: "PHP Lint"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: "Lint"
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php-version:
|
||||||
|
- "5.3"
|
||||||
|
- "8.0"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "Checkout"
|
||||||
|
uses: "actions/checkout@v2"
|
||||||
|
|
||||||
|
- name: "Install PHP"
|
||||||
|
uses: "shivammathur/setup-php@v2"
|
||||||
|
with:
|
||||||
|
coverage: "none"
|
||||||
|
extensions: "intl"
|
||||||
|
ini-values: "memory_limit=-1"
|
||||||
|
php-version: "${{ matrix.php-version }}"
|
||||||
|
|
||||||
|
- name: "Lint PHP files on 5.3"
|
||||||
|
if: "matrix.php-version == '5.3'"
|
||||||
|
run: "find src/ -type f -name '*.php' -exclude '*Trait.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
|
||||||
|
|
||||||
|
- name: "Lint PHP files"
|
||||||
|
if: "matrix.php-version != '5.3'"
|
||||||
|
run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f"
|
46
.github/workflows/phpstan.yml
vendored
Normal file
46
.github/workflows/phpstan.yml
vendored
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
name: "PHPStan"
|
||||||
|
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
env:
|
||||||
|
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: "PHPStan"
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php-version:
|
||||||
|
- "8.0"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: "Checkout"
|
||||||
|
uses: "actions/checkout@v2"
|
||||||
|
|
||||||
|
- name: "Install PHP"
|
||||||
|
uses: "shivammathur/setup-php@v2"
|
||||||
|
with:
|
||||||
|
coverage: "none"
|
||||||
|
php-version: "${{ matrix.php-version }}"
|
||||||
|
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composercache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composercache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
|
||||||
|
- name: "Install latest dependencies"
|
||||||
|
run: "composer update ${{ env.COMPOSER_FLAGS }}"
|
||||||
|
|
||||||
|
- name: Run PHPStan
|
||||||
|
run: composer phpstan
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ composer.lock
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
.hg
|
.hg
|
||||||
|
.phpunit.result.cache
|
||||||
|
35
.travis.yml
35
.travis.yml
@@ -1,35 +0,0 @@
|
|||||||
language: php
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
include:
|
|
||||||
- dist: precise
|
|
||||||
php: 5.3
|
|
||||||
env: deps=low
|
|
||||||
- dist: precise
|
|
||||||
php: 5.3
|
|
||||||
- php: 5.4
|
|
||||||
dist: trusty
|
|
||||||
- php: 5.5
|
|
||||||
dist: trusty
|
|
||||||
- php: 5.6
|
|
||||||
dist: xenial
|
|
||||||
- php: 7.0
|
|
||||||
dist: xenial
|
|
||||||
- php: 7.1
|
|
||||||
dist: bionic
|
|
||||||
- php: 7.2
|
|
||||||
dist: bionic
|
|
||||||
- php: 7.3
|
|
||||||
dist: bionic
|
|
||||||
- php: 7.4
|
|
||||||
dist: bionic
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
|
|
||||||
- if [ "$TRAVIS_PHP_VERSION" == "7.4" ]; then echo "error_reporting = E_ALL & ~E_DEPRECATED" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
|
|
||||||
- composer self-update --snapshot
|
|
||||||
- if [ "$deps" == "low" ]; then composer update -n --prefer-dist --prefer-lowest --prefer-stable; fi
|
|
||||||
- if [ "$deps" != "low" ]; then composer update -n --prefer-dist; fi
|
|
||||||
|
|
||||||
script: composer test
|
|
@@ -26,7 +26,7 @@
|
|||||||
"php-amqplib/php-amqplib": "~2.4",
|
"php-amqplib/php-amqplib": "~2.4",
|
||||||
"swiftmailer/swiftmailer": "^5.3|^6.0",
|
"swiftmailer/swiftmailer": "^5.3|^6.0",
|
||||||
"php-console/php-console": "^3.1.3",
|
"php-console/php-console": "^3.1.3",
|
||||||
"php-parallel-lint/php-parallel-lint": "^1.0"
|
"phpstan/phpstan": "^0.12.59"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
||||||
@@ -50,16 +50,9 @@
|
|||||||
"provide": {
|
"provide": {
|
||||||
"psr/log-implementation": "1.0.0"
|
"psr/log-implementation": "1.0.0"
|
||||||
},
|
},
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": [
|
"test": "vendor/bin/phpunit",
|
||||||
"parallel-lint . --exclude vendor --exclude src/Monolog/Handler/FormattableHandlerInterface.php --exclude src/Monolog/Handler/FormattableHandlerTrait.php --exclude src/Monolog/Handler/ProcessableHandlerInterface.php --exclude src/Monolog/Handler/ProcessableHandlerTrait.php",
|
"phpstan": "vendor/bin/phpstan analyse"
|
||||||
"phpunit"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"lock": false
|
"lock": false
|
||||||
}
|
}
|
||||||
|
16
phpstan.neon.dist
Normal file
16
phpstan.neon.dist
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
parameters:
|
||||||
|
level: 3
|
||||||
|
|
||||||
|
paths:
|
||||||
|
- src/
|
||||||
|
# - tests/
|
||||||
|
|
||||||
|
|
||||||
|
ignoreErrors:
|
||||||
|
- '#zend_monitor_|ZEND_MONITOR_#'
|
||||||
|
- '#RollbarNotifier#'
|
||||||
|
- '#Predis\\Client#'
|
||||||
|
- '#^Cannot call method ltrim\(\) on int\|false.$#'
|
||||||
|
- '#^Access to an undefined property Raven_Client::\$context.$#'
|
||||||
|
- '#MongoDB\\(Client|Collection)#'
|
||||||
|
- '#Gelf\\IMessagePublisher#'
|
@@ -62,6 +62,7 @@ class ErrorHandler
|
|||||||
//Forces the autoloader to run for LogLevel. Fixes an autoload issue at compile-time on PHP5.3. See https://github.com/Seldaek/monolog/pull/929
|
//Forces the autoloader to run for LogLevel. Fixes an autoload issue at compile-time on PHP5.3. See https://github.com/Seldaek/monolog/pull/929
|
||||||
class_exists('\\Psr\\Log\\LogLevel', true);
|
class_exists('\\Psr\\Log\\LogLevel', true);
|
||||||
|
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$handler = new static($logger);
|
$handler = new static($logger);
|
||||||
if ($errorLevelMap !== false) {
|
if ($errorLevelMap !== false) {
|
||||||
$handler->registerErrorHandler($errorLevelMap);
|
$handler->registerErrorHandler($errorLevelMap);
|
||||||
|
@@ -77,6 +77,7 @@ class DynamoDbHandler extends AbstractProcessingHandler
|
|||||||
if ($this->version === 3) {
|
if ($this->version === 3) {
|
||||||
$formatted = $this->marshaler->marshalItem($filtered);
|
$formatted = $this->marshaler->marshalItem($filtered);
|
||||||
} else {
|
} else {
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$formatted = $this->client->formatAttributes($filtered);
|
$formatted = $this->client->formatAttributes($filtered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -72,7 +72,7 @@ class FirePHPHandler extends AbstractProcessingHandler
|
|||||||
*
|
*
|
||||||
* @see createHeader()
|
* @see createHeader()
|
||||||
* @param array $record
|
* @param array $record
|
||||||
* @return string
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function createRecordHeader(array $record)
|
protected function createRecordHeader(array $record)
|
||||||
{
|
{
|
||||||
|
@@ -27,7 +27,7 @@ use Monolog\Formatter\GelfMessageFormatter;
|
|||||||
class GelfHandler extends AbstractProcessingHandler
|
class GelfHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Publisher the publisher object that sends the message to the server
|
* @var Publisher|PublisherInterface|IMessagePublisher the publisher object that sends the message to the server
|
||||||
*/
|
*/
|
||||||
protected $publisher;
|
protected $publisher;
|
||||||
|
|
||||||
|
@@ -270,10 +270,10 @@ class HipChatHandler extends SocketHandler
|
|||||||
* will be the highest level from the given records. Datetime will be taken
|
* will be the highest level from the given records. Datetime will be taken
|
||||||
* from the first record.
|
* from the first record.
|
||||||
*
|
*
|
||||||
* @param $records
|
* @param array $records
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function combineRecords($records)
|
private function combineRecords(array $records)
|
||||||
{
|
{
|
||||||
$batchRecord = null;
|
$batchRecord = null;
|
||||||
$batchRecords = array();
|
$batchRecords = array();
|
||||||
|
@@ -50,7 +50,7 @@ class RavenHandler extends AbstractProcessingHandler
|
|||||||
protected $ravenClient;
|
protected $ravenClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var LineFormatter The formatter to use for the logs generated via handleBatch()
|
* @var FormatterInterface The formatter to use for the logs generated via handleBatch()
|
||||||
*/
|
*/
|
||||||
protected $batchFormatter;
|
protected $batchFormatter;
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ class RedisHandler extends AbstractProcessingHandler
|
|||||||
* @param string $key The key name to push records to
|
* @param string $key The key name to push records to
|
||||||
* @param int $level The minimum logging level at which this handler will be triggered
|
* @param int $level The minimum logging level at which this handler will be triggered
|
||||||
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param bool $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
* @param int $capSize Number of entries to limit list size to
|
* @param int|false $capSize Number of entries to limit list size to
|
||||||
*/
|
*/
|
||||||
public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true, $capSize = false)
|
public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true, $capSize = false)
|
||||||
{
|
{
|
||||||
|
@@ -154,7 +154,7 @@ class StreamHandler extends AbstractProcessingHandler
|
|||||||
return dirname(substr($stream, 7));
|
return dirname(substr($stream, 7));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createDir()
|
private function createDir()
|
||||||
|
@@ -522,7 +522,7 @@ class Logger implements LoggerInterface, ResettableInterface
|
|||||||
/**
|
/**
|
||||||
* Converts PSR-3 levels to Monolog ones if necessary
|
* Converts PSR-3 levels to Monolog ones if necessary
|
||||||
*
|
*
|
||||||
* @param string|int Level number (monolog) or name (PSR-3)
|
* @param string|int $level Level number (monolog) or name (PSR-3)
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function toMonologLevel($level)
|
public static function toMonologLevel($level)
|
||||||
|
@@ -168,7 +168,7 @@ class Utils
|
|||||||
* Function converts the input in place in the passed variable so that it
|
* Function converts the input in place in the passed variable so that it
|
||||||
* can be used as a callback for array_walk_recursive.
|
* can be used as a callback for array_walk_recursive.
|
||||||
*
|
*
|
||||||
* @param mixed &$data Input to check and convert if needed
|
* @param mixed $data Input to check and convert if needed, passed by ref
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
public static function detectAndCleanUtf8(&$data)
|
public static function detectAndCleanUtf8(&$data)
|
||||||
|
Reference in New Issue
Block a user