-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from zfegg/develop
Refactor v2.
- Loading branch information
Showing
15 changed files
with
250 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: qa | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
jobs: | ||
qa: | ||
name: QA (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
operating-system: [ubuntu-latest] | ||
php-versions: ['7.4', '8.0', '8.1'] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
coverage: xdebug #optional | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache composer dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
# Use composer.json for key, if composer.lock is not committed. | ||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
|
||
- name: Install Composer dependencies | ||
run: composer install --no-progress --prefer-dist --optimize-autoloader | ||
|
||
- name: CS Check | ||
if: ${{ matrix.php-versions == '8.0' }} | ||
run: ./vendor/bin/phpcs | ||
|
||
- name: Run Tests | ||
run: ./vendor/bin/phpunit --coverage-text | ||
|
||
- name: Upload coverage to coveralls.io | ||
if: ${{ matrix.php-versions == '8.0' }} | ||
env: | ||
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
composer require php-coveralls/php-coveralls --dev -q | ||
./vendor/bin/phpunit --coverage-clover build/logs/clover.xml | ||
./vendor/bin/php-coveralls -v |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,57 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Zend Framework Coding Standard"> | ||
<rule ref="./vendor/laminas/laminas-coding-standard/ruleset.xml"/> | ||
|
||
<ruleset name="Coding Standard"> | ||
<!-- Paths to check --> | ||
<file>src</file> | ||
<file>test</file> | ||
</ruleset> | ||
|
||
<!-- display progress --> | ||
<arg value="p"/> | ||
<arg name="no-colors"/> | ||
|
||
<!-- inherit rules from: --> | ||
<rule ref="PSR2"/> | ||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/> | ||
<rule ref="Generic.Formatting.SpaceAfterNot"/> | ||
<rule ref="Squiz.WhiteSpace.OperatorSpacing"> | ||
<properties> | ||
<property name="ignoreNewlines" value="true"/> | ||
</properties> | ||
</rule> | ||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"> | ||
<properties> | ||
<property name="ignoreBlankLines" value="false"/> | ||
</properties> | ||
</rule> | ||
<rule ref="Squiz.NamingConventions.ValidVariableName"> | ||
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/> | ||
</rule> | ||
|
||
<rule ref="Squiz.Strings.ConcatenationSpacing" > | ||
<properties> | ||
<property name="spacing" value="1" /> | ||
<property name="ignoreNewlines" value="true" /> | ||
</properties> | ||
</rule> | ||
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing" /> | ||
|
||
<config name="installed_paths" value="vendor/slevomat/coding-standard/SlevomatCodingStandard"/> | ||
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" /> | ||
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" /> | ||
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint" > | ||
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" /> | ||
<properties> | ||
<property name="enableUnionTypeHint" value="false" /> | ||
<property name="enableMixedTypeHint" value="false" /> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint" /> | ||
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint"> | ||
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" /> | ||
<properties> | ||
<property name="enableUnionTypeHint" value="false" /> | ||
<property name="enableMixedTypeHint" value="false" /> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses" /> | ||
|
||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
<phpunit bootstrap="./vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Coding Tests"> | ||
<directory>./test</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"> | ||
<coverage includeUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Tests"> | ||
<directory>./test</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Zfegg\Stratigility\LoggingError; | ||
|
||
use Laminas\Stratigility\Middleware\ErrorHandler; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class LoggingErrorDelegator | ||
{ | ||
public function __invoke( | ||
ContainerInterface $container, | ||
string $serviceName, | ||
callable $callback | ||
): ErrorHandler { | ||
$listener = $container->get(LoggingErrorListener::class); | ||
|
||
$errorHandler = $callback(); | ||
$errorHandler->attachListener($listener); | ||
return $errorHandler; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Zfegg\Stratigility\LoggingError; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Psr\Log\LoggerInterface; | ||
use Psr\Log\NullLogger; | ||
use Laminas\Stratigility\Middleware\ErrorHandler; | ||
|
||
class LoggingErrorListenerFactory | ||
{ | ||
public function __invoke( | ||
ContainerInterface $container, | ||
$serviceName, | ||
callable $callback | ||
) : ErrorHandler { | ||
$logger = $container->has(LoggerInterface::class) ? | ||
$container->get(LoggerInterface::class) : | ||
new NullLogger(); | ||
public function __invoke(ContainerInterface $container): LoggingErrorListener | ||
{ | ||
$config = ($container->has('config') ? $container->get('config') : [])[LoggingErrorListener::class] ?? []; | ||
$logger = isset($config['logger']) | ||
? $container->get($config['logger']) | ||
: ($container->has(LoggerInterface::class) ? $container->get(LoggerInterface::class) : new NullLogger()); | ||
$message = $config['message'] ?? '%s "%s %s": <<<%s<<<'; | ||
|
||
$listener = new LoggingErrorListener($logger); | ||
|
||
$errorHandler = $callback(); | ||
$errorHandler->attachListener($listener); | ||
return $errorHandler; | ||
return new LoggingErrorListener($logger, $message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.