Skip to content

Commit ee5a40a

Browse files
committed
Changed class elements order
1 parent 2435719 commit ee5a40a

File tree

9 files changed

+57
-57
lines changed

9 files changed

+57
-57
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"psr/container": "^1.1 || ^2.0"
1717
},
1818
"require-dev": {
19-
"polymorphine/dev": "0.5.*"
19+
"polymorphine/dev": "0.6.*"
2020
},
2121
"autoload": {
2222
"psr-4": {

src/Setup.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@
2323
*/
2424
class Setup
2525
{
26-
private Build $build;
27-
28-
/**
29-
* @param Build|null $build
30-
*/
31-
public function __construct(?Build $build = null)
32-
{
33-
$this->build = $build ?: new Build();
34-
}
35-
3626
/**
3727
* Creates Setup with predefined Record and ContainerInterface entries
3828
* assuming correctness of provided data.
@@ -72,6 +62,16 @@ public static function development(array $records = [], array $containers = []):
7262
return new self(new Build\ValidatedBuild($records, $containers));
7363
}
7464

65+
private Build $build;
66+
67+
/**
68+
* @param Build|null $build
69+
*/
70+
public function __construct(?Build $build = null)
71+
{
72+
$this->build = $build ?: new Build();
73+
}
74+
7575
/**
7676
* Returns immutable Container instance with provided data.
7777
*

tests/CompositeContainerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020

2121
class CompositeContainerTest extends TestCase
2222
{
23-
public static function undefinedEntries(): array
24-
{
25-
return [['foo.something'], ['bar'], ['foo.another'], ['bar.something.else']];
26-
}
27-
2823
public function test_Instantiation()
2924
{
3025
$this->assertInstanceOf(ContainerInterface::class, $this->container());
@@ -127,6 +122,11 @@ public function test_ForContainerWithTrackedRecords_Get_EntryWithUndefinedContai
127122
$container->get('foo');
128123
}
129124

125+
public static function undefinedEntries(): array
126+
{
127+
return [['foo.something'], ['bar'], ['foo.another'], ['bar.something.else']];
128+
}
129+
130130
private function container(array $records = [], array $containers = []): CompositeContainer
131131
{
132132
return new CompositeContainer(new Records($records), $containers);

tests/ConfigContainerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919

2020
class ConfigContainerTest extends TestCase
2121
{
22-
public static function undefinedEntries(): array
23-
{
24-
return [['missing'], ['foo1.undefined'], ['foo1.bar2.missing'], ['foo2.bar.baz.qux'], ['foo3.more']];
25-
}
26-
2722
public function test_Instantiation()
2823
{
2924
$this->assertInstanceOf(ContainerInterface::class, $this->container());
@@ -70,6 +65,11 @@ public function test_Get_ForUndefinedValue_ThrowsException(string $id)
7065
$container->get($id);
7166
}
7267

68+
public static function undefinedEntries(): array
69+
{
70+
return [['missing'], ['foo1.undefined'], ['foo1.bar2.missing'], ['foo2.bar.baz.qux'], ['foo3.more']];
71+
}
72+
7373
private function container(?array &$config = []): ConfigContainer
7474
{
7575
if (!$config) {

tests/Doubles/FakeContainer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717

1818
class FakeContainer implements ContainerInterface
1919
{
20+
public static function new(array $data = []): self
21+
{
22+
return new self($data);
23+
}
24+
2025
public array $data = [];
2126

2227
public function __construct(array $data = [])
2328
{
2429
$this->data = $data;
2530
}
2631

27-
public static function new(array $data = []): self
28-
{
29-
return new self($data);
30-
}
31-
3232
public function get($id)
3333
{
3434
if (!array_key_exists($id, $this->data)) {

tests/Doubles/MockedBuild.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020

2121
class MockedBuild extends Build
2222
{
23-
public ContainerInterface $container;
24-
public Wrapper $wrapper;
25-
public array $setRecords = [];
26-
public array $setContainers = [];
27-
28-
private bool $defined;
29-
3023
public static function defined(): self
3124
{
3225
$build = new self();
@@ -41,6 +34,13 @@ public static function undefined(): self
4134
return $build;
4235
}
4336

37+
public ContainerInterface $container;
38+
public Wrapper $wrapper;
39+
public array $setRecords = [];
40+
public array $setContainers = [];
41+
42+
private bool $defined;
43+
4444
public function container(): ContainerInterface
4545
{
4646
return $this->container = new FakeContainer();

tests/Doubles/MockedRecord.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
class MockedRecord implements Record
1919
{
20+
public static function new($value = 'test'): self
21+
{
22+
return new self($value);
23+
}
24+
2025
public $value;
2126
public ContainerInterface $passedContainer;
2227

@@ -25,11 +30,6 @@ public function __construct($value = null)
2530
$this->value = $value;
2631
}
2732

28-
public static function new($value = 'test'): self
29-
{
30-
return new self($value);
31-
}
32-
3333
public function value(ContainerInterface $container)
3434
{
3535
$this->passedContainer = $container;

tests/Fixtures/ExampleImpl.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414

1515
class ExampleImpl implements Example
1616
{
17+
public static function new(string $string = 'Example'): self
18+
{
19+
return new self(function (string $string) { return $string; }, $string);
20+
}
21+
1722
private string $string;
1823

1924
public function __construct(callable $callback, string $name)
2025
{
2126
$this->string = $callback($name);
2227
}
2328

24-
public static function new(string $string = 'Example'): self
25-
{
26-
return new self(function (string $string) { return $string; }, $string);
27-
}
28-
2929
public function getString(): string
3030
{
3131
return $this->string;

tests/Records/RecordTest.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@
2020

2121
class RecordTest extends TestCase
2222
{
23-
public static function lazyRecords(): array
24-
{
25-
$composed = new Record\ValueRecord('foo');
26-
$composed = new Record\ComposedInstanceRecord(Fixtures\ExampleImpl::class, $composed, 'callback', null);
27-
$composed = new Record\ComposedInstanceRecord(Fixtures\DecoratorExample::class, $composed, null, 'stringA');
28-
29-
return [
30-
[new Record\CallbackRecord(function () { return Fixtures\ExampleImpl::new(); })],
31-
[new Record\InstanceRecord(Fixtures\ExampleImpl::class, 'callback', 'stringA')],
32-
[new Record\ProductRecord('factory', 'create', 'stringA', 'stringB')],
33-
[$composed]
34-
];
35-
}
36-
3723
public function test_Instantiation()
3824
{
3925
$this->assertInstanceOf(Record::class, new Record\ValueRecord('foo'));
@@ -115,4 +101,18 @@ public function test_LazyRecord_ValuesAreCached(Record $record)
115101
]);
116102
$this->assertSame($record->value($container), $record->value($container));
117103
}
104+
105+
public static function lazyRecords(): iterable
106+
{
107+
$composed = new Record\ValueRecord('foo');
108+
$composed = new Record\ComposedInstanceRecord(Fixtures\ExampleImpl::class, $composed, 'callback', null);
109+
$composed = new Record\ComposedInstanceRecord(Fixtures\DecoratorExample::class, $composed, null, 'stringA');
110+
111+
return [
112+
[new Record\CallbackRecord(function () { return Fixtures\ExampleImpl::new(); })],
113+
[new Record\InstanceRecord(Fixtures\ExampleImpl::class, 'callback', 'stringA')],
114+
[new Record\ProductRecord('factory', 'create', 'stringA', 'stringB')],
115+
[$composed]
116+
];
117+
}
118118
}

0 commit comments

Comments
 (0)