Skip to content

Commit 64f0193

Browse files
authored
Merge pull request #1 from phpflo/feature/php7_migration
Feature/php7 migration
2 parents 4736685 + 97d3873 commit 64f0193

File tree

11 files changed

+127
-52
lines changed

11 files changed

+127
-52
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/vendor/
2+
/bin
3+
composer.lock

composer.json

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
{
2-
"name": "phpflo/phpflo-core",
3-
"description": "Collection of base components for usage with phpflo",
4-
"type": "library",
5-
"keywords": ["fbp", "flow"],
6-
"license": "MIT",
7-
"authors": [
8-
{
9-
"name": "Henri Bergius",
10-
"email": "henri.bergius@iki.fi",
11-
"homepage": "http://bergie.iki.fi/"
12-
},
13-
{
14-
"name": "Marc Aschmann",
15-
"email": "maschmann@gmail.com"
16-
}
17-
],
18-
"require": {
19-
"php": ">=5.4.0"
2+
"name": "phpflo/phpflo-core",
3+
"description": "Collection of base components for usage with phpflo",
4+
"type": "library",
5+
"keywords": ["fbp", "flow"],
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Henri Bergius",
10+
"email": "henri.bergius@iki.fi",
11+
"homepage": "http://bergie.iki.fi/"
2012
},
21-
"require-dev": {
22-
"phpunit/phpunit": "<5.0"
23-
},
24-
"autoload": {
25-
"psr-4": {
26-
"": "lib/"
27-
}
28-
},
29-
"autoload-dev": {
30-
"psr-4": { "Tests\\": "tests/" }
13+
{
14+
"name": "Marc Aschmann",
15+
"email": "maschmann@gmail.com"
16+
}
17+
],
18+
"require": { "php": ">=7.0.0" },
19+
"require-dev": {
20+
"phpflo/phpflo": "^2.0.0",
21+
"phpunit/phpunit": "^5.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"PhpFlo\\": "lib/PhpFlo/",
26+
"Test\\": "lib/Test/"
3127
}
28+
},
29+
"config": { "bin-dir": "bin" },
30+
"autoload-dev": {
31+
"psr-4": { "Tests\\": "tests/" }
32+
}
3233
}

lib/PhpFlo/Component/Counter.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Component;
1212

13-
use PhpFlo\Component;
13+
use PhpFlo\Common\ComponentInterface;
14+
use PhpFlo\Common\ComponentTrait;
1415

1516
/**
1617
* Class Counter
1718
*
1819
* @package PhpFlo\Component
1920
* @author Henri Bergius <henri.bergius@iki.fi>
2021
*/
21-
class Counter extends Component
22+
class Counter implements ComponentInterface
2223
{
24+
use ComponentTrait;
25+
2326
/**
2427
* @var null
2528
*/

lib/PhpFlo/Component/Output.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Component;
1212

13-
use PhpFlo\Component;
13+
use PhpFlo\Common\ComponentInterface;
14+
use PhpFlo\Common\ComponentTrait;
1415

1516
/**
1617
* Class Output
1718
*
1819
* @package PhpFlo\Component
1920
* @author Henri Bergius <henri.bergius@iki.fi>
2021
*/
21-
class Output extends Component
22+
class Output implements ComponentInterface
2223
{
24+
use ComponentTrait;
25+
2326
public function __construct()
2427
{
2528
$this->inPorts()->add('in', ['datatype' => 'all', 'addressable' => true]);

lib/PhpFlo/Component/Queue.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Component;
1212

13-
use PhpFlo\Component;
13+
use PhpFlo\Common\ComponentInterface;
14+
use PhpFlo\Common\ComponentTrait;
1415

1516
/**
1617
* Component for creating a simple queue of messages.
@@ -25,8 +26,10 @@
2526
*
2627
* @author Marijn Huizendveld <marijn@pink-tie.com>
2728
*/
28-
class Queue extends Component
29+
class Queue implements ComponentInterface
2930
{
31+
use ComponentTrait;
32+
3033
/**
3134
* @var integer
3235
*/

lib/PhpFlo/Component/ReadFile.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Component;
1212

13-
use PhpFlo\Component;
13+
use PhpFlo\Common\ComponentInterface;
14+
use PhpFlo\Common\ComponentTrait;
1415

1516
/**
1617
* Class ReadFile
1718
*
1819
* @package PhpFlo\Component
1920
* @author Henri Bergius <henri.bergius@iki.fi>
2021
*/
21-
class ReadFile extends Component
22+
class ReadFile implements ComponentInterface
2223
{
24+
use ComponentTrait;
25+
2326
public function __construct()
2427
{
2528
$this->inPorts()->add('source', ['datatype' => 'string']);

lib/PhpFlo/Component/SplitStr.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Component;
1212

13-
use PhpFlo\Component;
13+
use PhpFlo\Common\ComponentInterface;
14+
use PhpFlo\Common\ComponentTrait;
1415

1516
/**
1617
* Class SplitStr
1718
*
1819
* @package PhpFlo\Component
1920
* @author Henri Bergius <henri.bergius@iki.fi>
2021
*/
21-
class SplitStr extends Component
22+
class SplitStr implements ComponentInterface
2223
{
24+
use ComponentTrait;
25+
2326
/**
2427
* @var string
2528
*/
@@ -48,15 +51,15 @@ public function __construct()
4851
/**
4952
* @param string $data
5053
*/
51-
public function setDelimiter($data)
54+
public function setDelimiter(string $data)
5255
{
5356
$this->delimiterString = $data;
5457
}
5558

5659
/**
5760
* @param string $data
5861
*/
59-
public function appendString($data)
62+
public function appendString(string $data)
6063
{
6164
$this->string .= $data;
6265
}

lib/PhpFlo/Test/ComponentTestHelperTrait.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10+
declare(strict_types=1);
1011
namespace PhpFlo\Test;
1112

1213
use PhpFlo\Common\ComponentInterface;
@@ -31,7 +32,7 @@ trait ComponentTestHelperTrait
3132
* @param ComponentInterface $component
3233
* @return ComponentInterface
3334
*/
34-
protected function connectInPorts(ComponentInterface $component)
35+
protected function connectInPorts(ComponentInterface $component) : ComponentInterface
3536
{
3637
foreach ($component->inPorts() as $alias => $inPort) {
3738
$inPort->attach($this->stub(InternalSocket::class));
@@ -46,7 +47,7 @@ protected function connectInPorts(ComponentInterface $component)
4647
* @param ComponentInterface $component
4748
* @return ComponentInterface
4849
*/
49-
protected function connectOutPorts(ComponentInterface $component)
50+
protected function connectOutPorts(ComponentInterface $component) : ComponentInterface
5051
{
5152
$this->outPortSockets = [];
5253
foreach ($component->outPorts() as $port) {
@@ -61,7 +62,7 @@ protected function connectOutPorts(ComponentInterface $component)
6162
->willReturnCallback(
6263
\Closure::bind(
6364
function ($data) {
64-
$this->data = $data;
65+
$this->data[] = $data;
6566
},
6667
$socket
6768
)
@@ -75,11 +76,23 @@ function ($data) {
7576
return $component;
7677
}
7778

79+
/**
80+
* @param ComponentInterface $component
81+
* @return ComponentInterface
82+
*/
83+
public function connectPorts(ComponentInterface $component) : ComponentInterface
84+
{
85+
$this->connectInPorts($component);
86+
$this->connectOutPorts($component);
87+
88+
return $component;
89+
}
90+
7891
/**
7992
* @param string $port
8093
* @return array|mixed
8194
*/
82-
protected function getOutPortData($port = '')
95+
protected function getOutPortData(string $port = '')
8396
{
8497
if ('' !== $port) {
8598
if (array_key_exists($port, $this->outPortSockets)) {
@@ -94,7 +107,7 @@ protected function getOutPortData($port = '')
94107
* @param string $port
95108
* @return bool
96109
*/
97-
protected function wasCalled($port)
110+
protected function wasCalled(string $port) : bool
98111
{
99112
return !empty($this->outPortSockets[$port]);
100113
}

lib/PhpFlo/Test/StubTrait.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ trait StubTrait
3232
* @param bool $forceMethods
3333
* @return \PHPUnit_Framework_MockObject_MockObject
3434
*/
35-
protected function stub($class, array $methods = [], $className = '', $forceMethods = false)
36-
{
35+
protected function stub(
36+
string $class,
37+
array $methods = [],
38+
string $className = '',
39+
bool $forceMethods = false
40+
) : \PHPUnit_Framework_MockObject_MockObject {
3741
$builder = $this->getMockBuilder($class)
3842
->disableOriginalConstructor();
3943

tests/PhpFlo/Component/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)