Skip to content

Commit 96358dd

Browse files
committed
Refactor to php7
1 parent e5dcaaa commit 96358dd

File tree

8 files changed

+72
-54
lines changed

8 files changed

+72
-54
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=5.4.0",
19+
"php": ">=7.0.0",
2020
"symfony/yaml": ">=2.7 <=4.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "<5.0",
23+
"phpunit/phpunit": "^5.0",
2424
"mikey179/vfsStream": "^1.6"
2525
},
2626
"config": {

lib/PhpFlo/Common/DefinitionInterface.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +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-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Common;
1212

1313
/**
@@ -20,52 +20,52 @@ interface DefinitionInterface
2020
{
2121
/**
2222
* @param array $definition
23-
* @return $this
23+
* @return DefinitionInterface
2424
*/
25-
public function definition(array $definition);
25+
public function definition(array $definition) : DefinitionInterface;
2626

2727
/**
2828
* @return array
2929
*/
30-
public function properties();
30+
public function properties() : array;
3131

3232
/**
3333
* @return array
3434
*/
35-
public function initializers();
35+
public function initializers() : array;
3636

3737
/**
3838
* @return array
3939
*/
40-
public function processes();
40+
public function processes() : array;
4141

4242
/**
4343
* @return array
4444
*/
45-
public function connections();
45+
public function connections() : array;
4646

4747
/**
4848
* @return array
4949
*/
50-
public function toArray();
50+
public function toArray() : array;
5151

5252
/**
5353
* @return string
5454
*/
55-
public function toJson();
55+
public function toJson() : string;
5656

5757
/**
5858
* @return string
5959
*/
60-
public function toYaml();
60+
public function toYaml() : string;
6161

6262
/**
6363
* @return string
6464
*/
65-
public function toFbp();
65+
public function toFbp() : string;
6666

6767
/**
6868
* @return string
6969
*/
70-
public function name();
70+
public function name() : string;
7171
}

lib/PhpFlo/Common/FbpDefinitionsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +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-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Common;
1212

1313
/**

lib/PhpFlo/Common/LoaderInterface.php

Lines changed: 2 additions & 1 deletion
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\Common;
1112

1213
use PhpFlo\Exception\LoaderException;
@@ -24,5 +25,5 @@ interface LoaderInterface
2425
* @return DefinitionInterface
2526
* @throws LoaderException
2627
*/
27-
public static function load($file);
28+
public static function load(string $file) : DefinitionInterface;
2829
}

lib/PhpFlo/Fbp/FbpDefinition.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +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-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Fbp;
1212

1313
use PhpFlo\Common\DefinitionInterface;
@@ -47,9 +47,9 @@ public function __construct(array $definition = [])
4747

4848
/**
4949
* @param array $definition
50-
* @return $this
50+
* @return DefinitionInterface
5151
*/
52-
public function definition(array $definition)
52+
public function definition(array $definition) : DefinitionInterface
5353
{
5454
$this->schema = array_replace_recursive(
5555
$this->schema,
@@ -62,71 +62,71 @@ public function definition(array $definition)
6262
/**
6363
* @return array
6464
*/
65-
public function properties()
65+
public function properties() : array
6666
{
6767
return $this->schema[self::PROPERTIES_LABEL];
6868
}
6969

7070
/**
7171
* @return array
7272
*/
73-
public function initializers()
73+
public function initializers() : array
7474
{
7575
return $this->schema[self::INITIALIZERS_LABEL];
7676
}
7777

7878
/**
7979
* @return array
8080
*/
81-
public function processes()
81+
public function processes() : array
8282
{
8383
return $this->schema[self::PROCESSES_LABEL];
8484
}
8585

8686
/**
8787
* @return array
8888
*/
89-
public function connections()
89+
public function connections() : array
9090
{
9191
return $this->schema[self::CONNECTIONS_LABEL];
9292
}
9393

9494
/**
9595
* @return string
9696
*/
97-
public function name()
97+
public function name() : string
9898
{
9999
return $this->schema[self::PROPERTIES_LABEL]['name'];
100100
}
101101

102102
/**
103103
* @return array
104104
*/
105-
public function toArray()
105+
public function toArray() : array
106106
{
107107
return $this->schema;
108108
}
109109

110110
/**
111111
* @return string
112112
*/
113-
public function toJson()
113+
public function toJson() : string
114114
{
115115
return FbpDumper::toJson($this->schema);
116116
}
117117

118118
/**
119119
* @return string
120120
*/
121-
public function toYaml()
121+
public function toYaml() : string
122122
{
123123
return FbpDumper::toYaml($this->schema);
124124
}
125125

126126
/**
127127
* @return string
128128
*/
129-
public function toFbp()
129+
public function toFbp() : string
130130
{
131131
return FbpDumper::toFbp($this->schema);
132132
}

lib/PhpFlo/Fbp/FbpDumper.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +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-
10+
declare(strict_types=1);
1111
namespace PhpFlo\Fbp;
1212

1313
use PhpFlo\Common\FbpDefinitionsInterface;
@@ -31,7 +31,7 @@ final class FbpDumper implements FbpDefinitionsInterface
3131
* @param array $definition
3232
* @return string json
3333
*/
34-
public static function toJson(array $definition)
34+
public static function toJson(array $definition) : string
3535
{
3636
return json_encode($definition, JSON_PRETTY_PRINT);
3737
}
@@ -41,7 +41,7 @@ public static function toJson(array $definition)
4141
* @param int $inline level until inlining starts
4242
* @return string yaml
4343
*/
44-
public static function toYaml(array $definition, $inline = 3)
44+
public static function toYaml(array $definition, int $inline = 3) : string
4545
{
4646
return Yaml::dump($definition, $inline);
4747
}
@@ -50,16 +50,17 @@ public static function toYaml(array $definition, $inline = 3)
5050
* @param array $definition
5151
* @return string
5252
*/
53-
public static function toFbp(array $definition)
53+
public static function toFbp(array $definition) : string
5454
{
5555
return self::createFbp($definition);
5656
}
5757

5858
/**
5959
* @param array $definition
6060
* @return string
61+
* @throws DumperException
6162
*/
62-
private static function createFbp(array $definition)
63+
private static function createFbp(array $definition) : string
6364
{
6465
$fbp = [];
6566

@@ -115,7 +116,7 @@ private static function createFbp(array $definition)
115116
* @param array $connectionTouple
116117
* @return string
117118
*/
118-
private static function examineConnectionTouple(array $connectionTouple)
119+
private static function examineConnectionTouple(array $connectionTouple) : string
119120
{
120121
self::hasElement(self::SOURCE_LABEL, $connectionTouple);
121122
self::hasElement(self::TARGET_LABEL, $connectionTouple);
@@ -132,7 +133,7 @@ private static function examineConnectionTouple(array $connectionTouple)
132133
* @throws DumperException
133134
* @return string
134135
*/
135-
private static function examineProcess($type, array $processPart)
136+
private static function examineProcess(string $type, array $processPart) : string
136137
{
137138
self::hasElement(self::PROCESS_LABEL, $processPart);
138139
self::hasElement(self::PORT_LABEL, $processPart);
@@ -163,8 +164,11 @@ private static function examineProcess($type, array $processPart)
163164
* @param bool $triggerException
164165
* @return bool
165166
*/
166-
private static function hasElement($needle, array $haystack, $triggerException = true)
167-
{
167+
private static function hasElement(
168+
string $needle,
169+
array $haystack,
170+
bool $triggerException = true
171+
) : bool {
168172
if (empty($haystack[$needle])) {
169173
if ($triggerException) {
170174
self::throwDumperException('elmeent', $needle);
@@ -181,7 +185,7 @@ private static function hasElement($needle, array $haystack, $triggerException =
181185
* @param string $targetPort
182186
* @return string
183187
*/
184-
private static function connectPorts($sourcePort, $targetPort)
188+
private static function connectPorts(string $sourcePort, string $targetPort) : string
185189
{
186190
return implode(
187191
" " . self::SOURCE_TARGET_SEPARATOR . " ",
@@ -192,7 +196,12 @@ private static function connectPorts($sourcePort, $targetPort)
192196
);
193197
}
194198

195-
private static function throwDumperException($type, $value)
199+
/**
200+
* @param string $type
201+
* @param string $value
202+
* @throws DumperException
203+
*/
204+
private static function throwDumperException(string $type, string $value)
196205
{
197206
switch ($type) {
198207
case 'element':

0 commit comments

Comments
 (0)