Skip to content

Commit 2b0d3c0

Browse files
committed
Merge branch 'sync'
2 parents a57eca6 + 51a08b6 commit 2b0d3c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1114
-591
lines changed

lib/lk-util/Command/Generate/GenerateFacade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function run(string ...$args)
157157
$summary = "Load and return an instance of the underlying $classClass class";
158158
unset($facadeMethods[0]);
159159
} else {
160-
if ($phpDoc->TagsByName['deprecated'] ?? null) {
160+
if (isset($phpDoc->TagsByName['deprecated'])) {
161161
continue;
162162
}
163163
$method = $methodName;

phpstan-baseline.neon

Lines changed: 27 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ parameters:
1010
count: 1
1111
path: lib/lk-util/Command/Http/SendHttpRequest.php
1212

13+
-
14+
message: "#^Property Lkrms\\\\Cli\\\\CliOption\\:\\:\\$BindTo is never read, only written\\.$#"
15+
count: 1
16+
path: src/Cli/CliOption.php
17+
1318
-
1419
message: "#^Method Lkrms\\\\Concept\\\\Builder\\:\\:__call\\(\\) has no return type specified\\.$#"
1520
count: 1
@@ -80,6 +85,11 @@ parameters:
8085
count: 1
8186
path: src/Container/Application.php
8287

88+
-
89+
message: "#^Property Lkrms\\\\Container\\\\Container\\:\\:\\$ContextStack is never read, only written\\.$#"
90+
count: 1
91+
path: src/Container/Container.php
92+
8393
-
8494
message: "#^Method Lkrms\\\\Contract\\\\IPipe\\:\\:handle\\(\\) has parameter \\$pipeline with generic interface Lkrms\\\\Contract\\\\IPipeline but does not specify its types\\: TInput, TOutput, TArgument$#"
8595
count: 1
@@ -90,31 +100,6 @@ parameters:
90100
count: 1
91101
path: src/Contract/IProvider.php
92102

93-
-
94-
message: "#^Interface Lkrms\\\\Contract\\\\IProviderContext extends generic interface Lkrms\\\\Contract\\\\ReturnsContainer but does not specify its types\\: T$#"
95-
count: 1
96-
path: src/Contract/IProviderContext.php
97-
98-
-
99-
message: "#^Method Lkrms\\\\Contract\\\\IProviderContext\\:\\:get\\(\\) has no return type specified\\.$#"
100-
count: 1
101-
path: src/Contract/IProviderContext.php
102-
103-
-
104-
message: "#^Method Lkrms\\\\Contract\\\\IProviderContext\\:\\:getStack\\(\\) return type with generic interface Lkrms\\\\Contract\\\\IProvidable does not specify its types\\: TProvider, TProviderContext$#"
105-
count: 1
106-
path: src/Contract/IProviderContext.php
107-
108-
-
109-
message: "#^Method Lkrms\\\\Contract\\\\IProviderContext\\:\\:push\\(\\) has parameter \\$entity with generic interface Lkrms\\\\Contract\\\\IProvidable but does not specify its types\\: TProvider, TProviderContext$#"
110-
count: 1
111-
path: src/Contract/IProviderContext.php
112-
113-
-
114-
message: "#^Method Lkrms\\\\Contract\\\\IProviderContext\\:\\:set\\(\\) has parameter \\$value with no type specified\\.$#"
115-
count: 1
116-
path: src/Contract/IProviderContext.php
117-
118103
-
119104
message: "#^Method Lkrms\\\\Contract\\\\IReadable\\:\\:__get\\(\\) has no return type specified\\.$#"
120105
count: 1
@@ -265,6 +250,11 @@ parameters:
265250
count: 1
266251
path: src/Curler/CurlerFile.php
267252

253+
-
254+
message: "#^Property Lkrms\\\\Curler\\\\CurlerHeaders\\:\\:\\$Trailers is never read, only written\\.$#"
255+
count: 1
256+
path: src/Curler/CurlerHeaders.php
257+
268258
-
269259
message: "#^Property Lkrms\\\\Curler\\\\Pager\\\\QueryPager\\:\\:\\$Query type has no value type specified in iterable type array\\.$#"
270260
count: 1
@@ -305,6 +295,16 @@ parameters:
305295
count: 1
306296
path: src/Curler/Support/CurlerPage.php
307297

298+
-
299+
message: "#^Parameter \\#2 \\$value of method ADOConnection\\:\\:setConnectionParameter\\(\\) expects string, bool given\\.$#"
300+
count: 1
301+
path: src/Db/DbConnector.php
302+
303+
-
304+
message: "#^Parameter \\#2 \\$value of method ADOConnection\\:\\:setConnectionParameter\\(\\) expects string, int given\\.$#"
305+
count: 1
306+
path: src/Db/DbConnector.php
307+
308308
-
309309
message: "#^Method Lkrms\\\\Store\\\\CacheStore\\:\\:get\\(\\) has no return type specified\\.$#"
310310
count: 1
@@ -326,69 +326,9 @@ parameters:
326326
path: src/Store/TrashStore.php
327327

328328
-
329-
message: "#^Method Lkrms\\\\Support\\\\ProviderContext\\:\\:get\\(\\) has no return type specified\\.$#"
330-
count: 1
331-
path: src/Support/ProviderContext.php
332-
333-
-
334-
message: "#^Method Lkrms\\\\Support\\\\ProviderContext\\:\\:getStack\\(\\) return type with generic interface Lkrms\\\\Contract\\\\IProvidable does not specify its types\\: TProvider, TProviderContext$#"
335-
count: 1
336-
path: src/Support/ProviderContext.php
337-
338-
-
339-
message: "#^Method Lkrms\\\\Support\\\\ProviderContext\\:\\:push\\(\\) has parameter \\$entity with generic interface Lkrms\\\\Contract\\\\IProvidable but does not specify its types\\: TProvider, TProviderContext$#"
340-
count: 1
341-
path: src/Support/ProviderContext.php
342-
343-
-
344-
message: "#^Method Lkrms\\\\Support\\\\ProviderContext\\:\\:set\\(\\) has parameter \\$value with no type specified\\.$#"
345-
count: 1
346-
path: src/Support/ProviderContext.php
347-
348-
-
349-
message: "#^Property Lkrms\\\\Support\\\\ProviderContext\\:\\:\\$Stack with generic interface Lkrms\\\\Contract\\\\IProvidable does not specify its types\\: TProvider, TProviderContext$#"
350-
count: 1
351-
path: src/Support/ProviderContext.php
352-
353-
-
354-
message: "#^Method Lkrms\\\\Support\\\\SqlQuery\\:\\:addNextParam\\(\\) has parameter \\$value with no type specified\\.$#"
355-
count: 1
356-
path: src/Support/SqlQuery.php
357-
358-
-
359-
message: "#^Method Lkrms\\\\Support\\\\SqlQuery\\:\\:addParam\\(\\) has parameter \\$value with no type specified\\.$#"
360-
count: 1
361-
path: src/Support/SqlQuery.php
362-
363-
-
364-
message: "#^Method Lkrms\\\\Support\\\\SqlQuery\\:\\:buildWhere\\(\\) has no return type specified\\.$#"
365-
count: 1
366-
path: src/Support/SqlQuery.php
367-
368-
-
369-
message: "#^Method Lkrms\\\\Support\\\\SqlQuery\\:\\:buildWhere\\(\\) has parameter \\$where with no value type specified in iterable type array\\.$#"
370-
count: 1
371-
path: src/Support/SqlQuery.php
372-
373-
-
374-
message: "#^Method Lkrms\\\\Support\\\\SqlQuery\\:\\:getWhere\\(\\) has parameter \\$values with no value type specified in iterable type array\\.$#"
375-
count: 1
376-
path: src/Support/SqlQuery.php
377-
378-
-
379-
message: "#^Method Lkrms\\\\Support\\\\SqlQuery\\:\\:where\\(\\) has parameter \\$clause with no value type specified in iterable type array\\.$#"
380-
count: 1
381-
path: src/Support/SqlQuery.php
382-
383-
-
384-
message: "#^Method Lkrms\\\\Support\\\\SqlQuery\\:\\:whereValueInList\\(\\) has parameter \\$value with no type specified\\.$#"
385-
count: 1
386-
path: src/Support/SqlQuery.php
387-
388-
-
389-
message: "#^Property Lkrms\\\\Support\\\\SqlQuery\\:\\:\\$Where type has no value type specified in iterable type array\\.$#"
329+
message: "#^Property Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:\\$Offline is never read, only written\\.$#"
390330
count: 1
391-
path: src/Support/SqlQuery.php
331+
path: src/Sync/Support/SyncEntityProvider.php
392332

393333
-
394334
message: "#^Method Lkrms\\\\Utility\\\\Assertions\\:\\:notEmpty\\(\\) has parameter \\$value with no type specified\\.$#"

phpstan.neon.dist

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,3 @@ parameters:
1414
ignoreErrors:
1515
- "#^Property Lkrms\\\\.+\\\\Command\\\\.+\\:\\:\\$[a-zA-Z0-9_]+ is never written, only read\\.$#"
1616
- "#^Method Lkrms\\\\Tests\\\\(.+Test|TestCase)\\:\\:.+\\(\\) has no return type specified\\.$#"
17-
-
18-
message: "#^Property Lkrms\\\\Cli\\\\CliOption\\:\\:\\$BindTo is never read, only written\\.$#"
19-
path: src/Cli/CliOption.php
20-
21-
-
22-
message: "#^Property Lkrms\\\\Container\\\\Container\\:\\:\\$Context(Stack)? is never read, only written\\.$#"
23-
path: src/Container/Container.php
24-
25-
-
26-
message: "#^Property Lkrms\\\\Curler\\\\CurlerHeaders\\:\\:\\$Trailers is never read, only written\\.$#"
27-
path: src/Curler/CurlerHeaders.php
28-
29-
-
30-
message: "#^Parameter \\#2 \\$value of method ADOConnection\\:\\:setConnectionParameter\\(\\) expects string, [a-z]+ given\\.$#"
31-
path: src/Db/DbConnector.php
32-
33-
-
34-
message: "#^Property Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:\\$GetFromSyncStore is never read, only written\\.$#"
35-
path: src/Sync/Support/SyncEntityProvider.php

src/Concept/Facade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ final public static function isLoaded(): bool
8181
*/
8282
final public static function load()
8383
{
84-
if (self::$Instances[static::class] ?? null) {
84+
if (isset(self::$Instances[static::class])) {
8585
throw new RuntimeException(static::class . ' already loaded');
8686
}
8787

src/Concept/Provider.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
use Lkrms\Contract\IContainer;
66
use Lkrms\Contract\IProvider;
7+
use Lkrms\Contract\IProviderContext;
78
use Lkrms\Exception\MethodNotImplementedException;
89
use Lkrms\Support\DateFormatter;
10+
use Lkrms\Support\ProviderContext;
911
use Lkrms\Utility\Env;
1012

1113
/**
@@ -46,6 +48,20 @@ public function description(): ?string
4648
return null;
4749
}
4850

51+
/**
52+
* @inheritDoc
53+
*/
54+
public function getContext(?IContainer $container = null): IProviderContext
55+
{
56+
if (!$container) {
57+
$container = $this->App;
58+
}
59+
60+
return $container
61+
->bindIf(IProviderContext::class, ProviderContext::class)
62+
->get(IProviderContext::class, [$this]);
63+
}
64+
4965
/**
5066
* @inheritDoc
5167
*/

src/Concept/ReflectiveEnumeration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private static function loadMaps(): void
6363

6464
final public static function fromName(string $name)
6565
{
66-
if ((self::$ValueMaps[static::class] ?? null) === null) {
66+
if (!isset(self::$ValueMaps[static::class])) {
6767
self::loadMaps();
6868
}
6969
if (($value = self::$ValueMaps[static::class][$name]
@@ -78,7 +78,7 @@ final public static function fromName(string $name)
7878

7979
final public static function toName($value): string
8080
{
81-
if ((self::$NameMaps[static::class] ?? null) === null) {
81+
if (!isset(self::$NameMaps[static::class])) {
8282
self::loadMaps();
8383
}
8484
if (($name = self::$NameMaps[static::class][$value] ?? null) === null) {
@@ -91,7 +91,7 @@ final public static function toName($value): string
9191

9292
final public static function cases(): array
9393
{
94-
if ((self::$ValueMaps[static::class] ?? null) === null) {
94+
if (!isset(self::$ValueMaps[static::class])) {
9595
self::loadMaps();
9696
}
9797
return self::$ValueMaps[static::class];

src/Concern/HasParent.php

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,20 @@
22

33
namespace Lkrms\Concern;
44

5-
use Lkrms\Contract\IHierarchy;
5+
use Lkrms\Contract\ITreeable;
6+
use Lkrms\Support\Introspector;
67
use LogicException;
78

89
/**
9-
* Implements IHierarchy
10+
* Implements ITreeable
1011
*
11-
* @see IHierarchy
12+
* @see ITreeable
1213
*/
1314
trait HasParent
1415
{
15-
/**
16-
* Get the name of the object's declared or magic parent property
17-
*
18-
*/
19-
abstract protected static function getParentProperty(): string;
16+
abstract public static function getParentProperty(): string;
2017

21-
/**
22-
* Get the name of the object's declared or magic child array property
23-
*
24-
*/
25-
abstract protected static function getChildrenProperty(): string;
18+
abstract public static function getChildrenProperty(): string;
2619

2720
/**
2821
* @var array<class-string<self>,string>
@@ -36,22 +29,24 @@ abstract protected static function getChildrenProperty(): string;
3629

3730
private static function loadHierarchyProperties(): void
3831
{
39-
if (!property_exists(
40-
static::class, $parentProperty = static::getParentProperty()
41-
) || !property_exists(
42-
static::class, $childrenProperty = static::getChildrenProperty()
43-
)) {
32+
$introspector = Introspector::get(static::class);
33+
34+
if (!$introspector->IsTreeable) {
4435
throw new LogicException(
4536
sprintf(
46-
'Undefined property: %s::$%s',
37+
'%s does not implement %s or does not return valid parent/child properties',
4738
static::class,
48-
$childrenProperty ?? $parentProperty
39+
ITreeable::class,
4940
)
5041
);
5142
}
5243

53-
self::$_ParentProperties[static::class] = $parentProperty;
54-
self::$_ChildrenProperties[static::class] = $childrenProperty;
44+
self::$_ParentProperties[static::class] =
45+
$introspector->Properties[$introspector->ParentProperty]
46+
?? $introspector->ParentProperty;
47+
self::$_ChildrenProperties[static::class] =
48+
$introspector->Properties[$introspector->ChildrenProperty]
49+
?? $introspector->ChildrenProperty;
5550
}
5651

5752
/**
@@ -79,11 +74,11 @@ final public function getChildren(): array
7974

8075
$_children = self::$_ChildrenProperties[static::class];
8176

82-
return $this->{$_children} ?: [];
77+
return $this->{$_children} ?? [];
8378
}
8479

8580
/**
86-
* @param (IHierarchy&static)|null $parent
81+
* @param (ITreeable&static)|null $parent
8782
* @return $this
8883
*/
8984
final public function setParent($parent)

src/Concern/TConstructible.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Lkrms\Container\Container;
66
use Lkrms\Contract\IContainer;
7-
use Lkrms\Contract\IHierarchy;
7+
use Lkrms\Contract\ITreeable;
88
use Lkrms\Support\Catalog\ArrayKeyConformity;
99
use Lkrms\Support\IntrospectionClass;
1010
use Lkrms\Support\Introspector;
@@ -31,9 +31,9 @@ trait TConstructible
3131
*
3232
* @param mixed[] $data
3333
* @param IContainer|null $container Used to create the instance if set.
34-
* @param (IHierarchy&static)|null $parent If the class implements
35-
* {@see IHierarchy}, pass `$parent` to the instance via
36-
* {@see IHierarchy::setParent()}.
34+
* @param (ITreeable&static)|null $parent If the class implements
35+
* {@see ITreeable}, pass `$parent` to the instance via
36+
* {@see ITreeable::setParent()}.
3737
* @return static
3838
*/
3939
final public static function construct(array $data, ?IContainer $container = null, $parent = null)
@@ -53,11 +53,11 @@ final public static function construct(array $data, ?IContainer $container = nul
5353
*
5454
* @param iterable<mixed[]> $list
5555
* @param ArrayKeyConformity::* $conformity Use `COMPLETE` or `PARTIAL`
56-
* wherever possible to improve performance.
56+
* wherever possible to improve performance.
5757
* @param IContainer|null $container Used to create each instance if set.
58-
* @param (IHierarchy&static)|null $parent If the class implements
59-
* {@see IHierarchy}, pass `$parent` to each instance via
60-
* {@see IHierarchy::setParent()}.
58+
* @param (ITreeable&static)|null $parent If the class implements
59+
* {@see ITreeable}, pass `$parent` to each instance via
60+
* {@see ITreeable::setParent()}.
6161
* @return Generator<static>
6262
*/
6363
final public static function constructList(

0 commit comments

Comments
 (0)