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

Updates, Release 2.0.0 #17

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
vendor/
composer.phar
composer.lock
phpspec.yml
phpunit.xml
.idea
.phpunit.result.cache
24 changes: 15 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
dist: trusty

language: php

php:
- 5.6
- 7.0
- 7.1
- hhvm
- 7.3
- 7.4
# - hhvm
# - nightly

matrix:
allow_failures:
- php: hhvm
# - php: hhvm
# - php: nightly
include:
- php: 5.6
- php: 7.3
env:
- COMPOSER_FLAGS="--prefer-lowest --prefer-stable"
- COMPOSER_FLAGS=" --prefer-stable"
- COVERAGE=true
- PHPSPEC_FLAGS="--config phpspec.yml.ci"
- PHPUNIT_FLAGS="--coverage-clover=coverage.clover"

install:
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction

before_script:
- export XDEBUG_MODE=coverage

script:
- vendor/bin/phpspec run ${PHPSPEC_FLAGS}
- phpdbg -qrr vendor/bin/phpspec run

after_script:
- if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
Expand Down
23 changes: 15 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
],
"support": {
"issues": "https://github.com/portphp/portphp/issues",
"source": "https://github.com/portphp/boilerplate",
"source": "https://github.com/portphp/steps",
"docs": "https://portphp.readthedocs.org"
},
"require": {
"php": ">=5.6.0",
"portphp/portphp": "^1.0.0",
"php": ">=7.3",
"portphp/portphp": "^2.0.0",
"seld/signal-handler": "^1.0",
"symfony/property-access": "^2.3 || ^3.0 || ^4.0 || ^5.0",
"symfony/validator": "^2.5 || ^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"phpunit/phpunit": "^9.2.0",
"phpspec/phpspec": "^7.0",
"friends-of-phpspec/phpspec-code-coverage": "^5.0"
},
"autoload": {
"psr-4": {
"Port\\Steps\\": "src/"
Expand All @@ -37,10 +42,6 @@
"conflict": {
"symfony/validator": "<2.5"
},
"require-dev": {
"phpspec/phpspec": "^2.2",
"henrikbjorn/phpspec-code-coverage" : "^1.0"
},
"suggest": {
"symfony/property-access": "Used in MappingStep",
"symfony/validator": "Used in ValidatorStep"
Expand All @@ -49,5 +50,11 @@
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/klodoma/portphp-portphp"
}
]
}
7 changes: 6 additions & 1 deletion phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
suites:
step_suite:
library_suite:
namespace: Port\Steps
psr4_prefix: Port\Steps
extensions:
FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension: ~
formatter.name: pretty
code_coverage:
format: clover
output: build/phpspec.coverage.xml
7 changes: 4 additions & 3 deletions spec/Step/ValidatorStepSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace spec\Port\Steps\Step;

use Port\Steps\Step;
use stdClass;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;
Expand Down Expand Up @@ -117,7 +118,7 @@ function it_validates_an_item_from_metadata(
) {
$next = function() {};
$list->count()->willReturn(1);
$item = new \stdClass();
$item = new stdClass();
$validator->validate($item)->willReturn($list);

$this->process(
Expand All @@ -136,15 +137,15 @@ function it_validates_multiple_items_from_metadata(
$numberOfCalls = 3;
$next = function() {};
$list->count()->willReturn(1);
$item = new \stdClass();
$item = new stdClass();
$validator->validate($item)->willReturn($list);

for ($i = 0; $i < $numberOfCalls; $i++) {
$this->process($item, $next);
}

$this->getViolations()->shouldReturn(array_fill(1, $numberOfCalls, $list));
}
}

function it_tracks_lines_when_exceptions_are_thrown_during_process(
Step $step,
Expand Down
4 changes: 3 additions & 1 deletion src/Step/ArrayCheckStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace Port\Steps\Step;

use ArrayAccess;
use Port\Exception\UnexpectedTypeException;
use Port\Steps\Step;
use Traversable;

/**
* @author Márk Sági-Kazár <[email protected]>
Expand All @@ -15,7 +17,7 @@ class ArrayCheckStep implements Step
*/
public function process($item, callable $next)
{
if (!is_array($item) && !($item instanceof \ArrayAccess && $item instanceof \Traversable)) {
if (!is_array($item) && !($item instanceof ArrayAccess && $item instanceof Traversable)) {
throw new UnexpectedTypeException($item, 'array');
}

Expand Down
5 changes: 3 additions & 2 deletions src/Step/FilterStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
namespace Port\Steps\Step;

use Port\Steps\Step;
use SplPriorityQueue;

/**
* @author Markus Bachmann <[email protected]>
*/
class FilterStep implements Step
{
/**
* @var \SplPriorityQueue
* @var SplPriorityQueue
*/
private $filters;

public function __construct()
{
$this->filters = new \SplPriorityQueue();
$this->filters = new SplPriorityQueue();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Step/ValidatorStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ public function process($item, callable $next)
if (0 === count($list)) {
return $next($item);
}

return null;
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/StepAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Port\Steps;

use DateTime;
use Port\Exception;
use Port\Reader;
use Port\Result;
Expand All @@ -12,6 +13,7 @@
use Psr\Log\LoggerAwareTrait;
use Psr\Log\NullLogger;
use Seld\Signal\SignalHandler;
use SplObjectStorage;

/**
* A mediator between a reader and one or more writers and converters
Expand Down Expand Up @@ -100,8 +102,8 @@ public function addWriter(Writer $writer)
public function process()
{
$count = 0;
$exceptions = new \SplObjectStorage();
$startTime = new \DateTime;
$exceptions = new SplObjectStorage();
$startTime = new DateTime;

$signal = SignalHandler::create(['SIGTERM', 'SIGINT'], $this->logger);

Expand Down Expand Up @@ -137,7 +139,7 @@ public function process()
$writer->finish();
}

return new Result($this->name, $startTime, new \DateTime, $count, $exceptions);
return new Result($this->name, $startTime, new DateTime, $count, $exceptions);
}

/**
Expand Down