Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from spaceonfire/php8
Browse files Browse the repository at this point in the history
chore: support installation on PHP 8
  • Loading branch information
hustlahusky authored Feb 19, 2021
2 parents bf287c0 + 46e57f6 commit 2a8b88a
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 29 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ jobs:
COMPOSER_CACHE_KEY: 'composer-7.2'
with:
path: vendor
key: ${{ env.COMPOSER_CACHE_KEY }}
key: ${{ env.COMPOSER_CACHE_KEY }}-${{ hashFiles('composer.json') }}
restore-keys: ${{ env.COMPOSER_CACHE_KEY }}

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
run: |
/opt/spaceonfire/bin/select-composer.sh v2
composer install --prefer-dist --no-progress
- name: Check coding standard
run: vendor/bin/ecs check --no-progress-bar --no-interaction
Expand All @@ -58,12 +59,13 @@ jobs:
COMPOSER_CACHE_KEY: 'composer-7.2'
with:
path: vendor
key: ${{ env.COMPOSER_CACHE_KEY }}
key: ${{ env.COMPOSER_CACHE_KEY }}-${{ hashFiles('composer.json') }}
restore-keys: ${{ env.COMPOSER_CACHE_KEY }}

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
run: |
/opt/spaceonfire/bin/select-composer.sh v2
composer install --prefer-dist --no-progress
- name: PHPStan
run: vendor/bin/phpstan analyse --no-progress --no-interaction
Expand All @@ -76,6 +78,7 @@ jobs:
- '7.2'
- '7.3'
- '7.4'
- '8.0'
container: spaceonfire/nginx-php-fpm:latest-${{ matrix.php-version }}
steps:
- name: Checkout
Expand All @@ -88,18 +91,19 @@ jobs:
COMPOSER_CACHE_KEY: 'composer-${{ matrix.php-version }}'
with:
path: vendor
key: ${{ env.COMPOSER_CACHE_KEY }}
key: ${{ env.COMPOSER_CACHE_KEY }}-${{ hashFiles('composer.json') }}
restore-keys: ${{ env.COMPOSER_CACHE_KEY }}

- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest
run: |
/opt/spaceonfire/bin/select-composer.sh v2
composer install --prefer-dist --no-progress
- name: PHPUnit
run: |
apk update
docker-php-ext-enable xdebug
vendor/bin/phpunit --no-interaction
php -d xdebug.mode=coverage vendor/bin/phpunit --no-interaction
cat build/coverage.txt
- name: PHPUnit Artifacts
Expand All @@ -109,5 +113,5 @@ jobs:
path: build/

- name: Generate coverage badge
if: matrix.php-version == '7.2' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
if: matrix.php-version == '7.2' && github.event_name == 'push' && github.ref == 'refs/heads/master'
run: php bin/coverage-badge ${{ github.repository }}.json ${{ secrets.COVERAGE_GIST_ID }} ${{ secrets.COVERAGE_GIST_TOKEN }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,12 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
- Nothing
-->

## [1.0.1] - 2020-02-19

### Added

- First release

## [1.0.0] - 2020-10-05

- First release
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.2|^8.0",
"laminas/laminas-hydrator": "^2.4|^3.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^8.5|^9.5",
"phpspec/prophecy-phpunit": "^1.1|^2.0",
"roave/security-advisories": "dev-master",
"symplify/easy-coding-standard-prefixed": "^8.3",
"symplify/easy-coding-standard-prefixed": "^8.3|^9.1",
"spaceonfire/type": "^1.1"
},
"suggest": {
Expand All @@ -43,7 +44,7 @@
}
},
"scripts": {
"test": "phpunit",
"test": "@php -d xdebug.mode=coverage `which phpunit`",
"codestyle": "ecs check --ansi",
"lint": "phpstan analyze --memory-limit=512M --ansi"
},
Expand Down
4 changes: 2 additions & 2 deletions src/StdClassHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
use Laminas\Hydrator\AbstractHydrator;

/**
* Class StdClassHydrator
* Class StdClassHydrator.
*
* Attention: You should not extend this class because it will become final in the next major release
* after the backward compatibility aliases are removed.
*
* @package spaceonfire\LaminasHydratorBridge
* @final
*/
class StdClassHydrator extends AbstractHydrator
{
Expand Down
16 changes: 7 additions & 9 deletions src/Strategy/BooleanStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
use Laminas\Hydrator\Strategy\StrategyInterface;

/**
* Class BooleanStrategy
* Class BooleanStrategy.
*
* Attention: You should not extend this class because it will become final in the next major release
* after the backward compatibility aliases are removed.
*
* @package spaceonfire\LaminasHydratorBridge\Strategy
* @final
*/
class BooleanStrategy implements StrategyInterface
{
Expand Down Expand Up @@ -52,13 +52,7 @@ private function prepareInputValue($inputValue, string $argument): array
{
$result = [];

$isIterable = is_iterable($inputValue);

if ($isIterable && count($inputValue) === 0) {
throw new InvalidArgumentException(sprintf('Argument %s cannot be empty iterable', $argument));
}

foreach ($isIterable ? $inputValue : [$inputValue] as $value) {
foreach (is_iterable($inputValue) ? $inputValue : [$inputValue] as $value) {
if (!is_int($value) && !is_string($value)) {
throw new InvalidArgumentException(sprintf(
'Argument %s expected to be int, string or iterable or int or string. Got: %s',
Expand All @@ -70,6 +64,10 @@ private function prepareInputValue($inputValue, string $argument): array
$result[] = $value;
}

if (count($result) === 0) {
throw new InvalidArgumentException(sprintf('Argument %s cannot be empty iterable', $argument));
}

return $result;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Strategy/NullableStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Attention: You should not extend this class because it will become final in the next major release
* after the backward compatibility aliases are removed.
*
* @package spaceonfire\LaminasHydratorBridge\Strategy
* @final
*/
class NullableStrategy implements StrategyInterface
{
Expand Down
18 changes: 18 additions & 0 deletions tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace spaceonfire\LaminasHydratorBridge;

use PHPUnit\Framework\TestCase;

if (trait_exists('\Prophecy\PhpUnit\ProphecyTrait')) {
abstract class AbstractTestCase extends TestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
}
} else {
abstract class AbstractTestCase extends TestCase
{
}
}
4 changes: 2 additions & 2 deletions tests/Strategy/NullableStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
namespace spaceonfire\LaminasHydratorBridge\Strategy;

use Laminas\Hydrator\Strategy\StrategyInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use spaceonfire\LaminasHydratorBridge\AbstractTestCase;

class NullableStrategyTest extends TestCase
class NullableStrategyTest extends AbstractTestCase
{
/**
* @return StrategyInterface
Expand Down

0 comments on commit 2a8b88a

Please sign in to comment.