Skip to content

Commit 02344c8

Browse files
committed
update
1 parent b4d62a0 commit 02344c8

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

.github/workflows/phpci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ jobs:
1919
with:
2020
php-version: '8.4'
2121

22-
- name: PHP Security Checker
23-
uses: StephaneBour/[email protected]
24-
2522
- name: Setup project
2623
run: make setup
2724

src/graphs.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* // 'E' => ['C'],
3030
* // ]
3131
*/
32-
function makeJoints(array $tree)
32+
function makeJoints(array $tree): array
3333
{
3434
$iter = function ($tree, $acc, $parent) use (&$iter) {
3535
$leaf = $tree[0];
@@ -80,7 +80,7 @@ function makeJoints(array $tree)
8080
* // ]],
8181
* // ]];
8282
*/
83-
function buildTreeFromLeaf(array $joints, string $leaf)
83+
function buildTreeFromLeaf(array $joints, string $leaf): array
8484
{
8585
$iter = function ($current, $acc) use (&$iter, $joints) {
8686

@@ -128,7 +128,7 @@ function buildTreeFromLeaf(array $joints, string $leaf)
128128
* // E: ['C'],
129129
* // ]
130130
*/
131-
function sortJoints(array $joints)
131+
function sortJoints(array $joints): array
132132
{
133133
$sortedJoints = [];
134134
foreach ($joints as $node => $neighbors) {
@@ -169,7 +169,7 @@ function sortJoints(array $joints)
169169
* // ]],
170170
* // ]];
171171
*/
172-
function map(callable $func, array $tree)
172+
function map(callable $func, array $tree): array
173173
{
174174
$children = $tree[1] ?? null;
175175
$updatedName = $func($tree);
@@ -221,7 +221,7 @@ function map(callable $func, array $tree)
221221
* // E6, 'E',
222222
* // ]
223223
*/
224-
function makeAssociations(array $uniqueTree, array $tree)
224+
function makeAssociations(array $uniqueTree, array $tree): array
225225
{
226226
$uniqueLeafs = collect($uniqueTree)->flatten();
227227
$leafs = collect($tree)->flatten();
@@ -270,7 +270,7 @@ function makeAssociations(array $uniqueTree, array $tree)
270270
* // ['D'],
271271
* // ]];
272272
*/
273-
function sortTree(array $tree)
273+
function sortTree(array $tree): array
274274
{
275275
$uniqueTree = map(fn($node) => uniqid($node[0]), $tree);
276276
$associations = makeAssociations($uniqueTree, $tree);

tests/GraphsTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class GraphsTest extends TestCase
1414
{
15-
public function testMakeJoints()
15+
public function testMakeJoints(): void
1616
{
1717
$tree = ['A', [
1818
['C', [
@@ -39,28 +39,28 @@ public function testMakeJoints()
3939
]];
4040

4141
$expected = [
42-
'A' => ['C', 'B', null],
43-
'C' => ['F', 'G', 'A'],
44-
'F' => ['J', 'I', 'C'],
45-
'J' => ['O', 'N', 'F'],
46-
'O' => ['J'],
47-
'N' => ['J'],
48-
'I' => ['M', 'F'],
49-
'M' => ['I'],
50-
'G' => ['K', 'L', 'C'],
51-
'K' => ['G'],
52-
'L' => ['G'],
53-
'B' => ['E', 'D', 'A'],
54-
'E' => ['B'],
55-
'D' => ['H', 'B'],
56-
'H' => ['D']
42+
'A' => ['C', 'B', null],
43+
'C' => ['F', 'G', 'A'],
44+
'F' => ['J', 'I', 'C'],
45+
'J' => ['O', 'N', 'F'],
46+
'O' => ['J'],
47+
'N' => ['J'],
48+
'I' => ['M', 'F'],
49+
'M' => ['I'],
50+
'G' => ['K', 'L', 'C'],
51+
'K' => ['G'],
52+
'L' => ['G'],
53+
'B' => ['E', 'D', 'A'],
54+
'E' => ['B'],
55+
'D' => ['H', 'B'],
56+
'H' => ['D']
5757
];
5858

5959
$actual = makeJoints($tree);
6060
$this->assertEquals($expected, $actual);
6161
}
6262

63-
public function testBuildTreeFromLeaf()
63+
public function testBuildTreeFromLeaf(): void
6464
{
6565
$joints = [
6666
'B' => ['D', 'A'],
@@ -86,7 +86,7 @@ public function testBuildTreeFromLeaf()
8686
$this->assertEquals($expected, $actual);
8787
}
8888

89-
public function testSortJoints()
89+
public function testSortJoints(): void
9090
{
9191
$joints = [
9292
'B' => ['D', 'A'],
@@ -111,7 +111,7 @@ public function testSortJoints()
111111
$this->assertEquals($expected, $actual);
112112
}
113113

114-
public function testMap()
114+
public function testMap(): void
115115
{
116116
$tree = ['A', [
117117
['C', [
@@ -169,7 +169,7 @@ public function testMap()
169169
$this->assertEquals($expected, $actual);
170170
}
171171

172-
public function testSortTree()
172+
public function testSortTree(): void
173173
{
174174
$tree = ['B', [
175175
['D'],

0 commit comments

Comments
 (0)