Skip to content

Commit eb2994e

Browse files
committed
Merge branch 'sync'
2 parents c0ca6b1 + 10d55c6 commit eb2994e

Some content is hidden

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

52 files changed

+944
-740
lines changed

docs/Containers.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## Services
2+
3+
Consider the following scenario:
4+
5+
- `Faculty` is a `SyncEntity` subclass and therefore implements `IProvidable`
6+
- `CustomFaculty` is a subclass of `Faculty`
7+
- `CustomFaculty` is bound to the service container as `Faculty`:
8+
```php
9+
$this->App->bind(Faculty::class, CustomFaculty::class);
10+
```
11+
- `$provider` implements `FacultyProvider`
12+
- A `Faculty` object is requested from `$provider` for faculty #1:
13+
```php
14+
$faculty = $provider->with(Faculty::class)->get(1);
15+
```
16+
17+
`$faculty` is now a `Faculty` service and an instance of `CustomFaculty`, so
18+
this code:
19+
20+
```php
21+
print_r([
22+
'class' => get_class($faculty),
23+
'service' => $faculty->service(),
24+
]);
25+
```
26+
27+
will produce the following output:
28+
29+
```
30+
Array
31+
(
32+
[class] => CustomFaculty
33+
[service] => Faculty
34+
)
35+
```
36+

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,18 +339,18 @@ protected function run(string ...$args)
339339
$code = [sprintf(
340340
'%sstatic::getInstance()->%s(%s);',
341341
$return,
342-
$_method->name,
342+
$_method->getName(),
343343
implode(', ', array_map(
344344
fn(ReflectionParameter $p) =>
345-
($p->isVariadic() ? '...' : '') . "\${$p->name}",
345+
($p->isVariadic() ? '...' : '') . '$' . $p->getName(),
346346
$_params
347347
))
348348
)];
349349

350350
array_push(
351351
$lines,
352352
'',
353-
...$this->generateMethod($_method->name, $code, $_params, $_method->getReturnType(), $docBlock)
353+
...$this->generateMethod($_method->getName(), $code, $_params, $_method->getReturnType(), $docBlock)
354354
);
355355
}
356356

phpstan-baseline.neon

Lines changed: 0 additions & 245 deletions
Original file line numberDiff line numberDiff line change
@@ -380,231 +380,6 @@ parameters:
380380
count: 1
381381
path: src/Support/SqlQuery.php
382382

383-
-
384-
message: "#^Method Lkrms\\\\Sync\\\\Concept\\\\DbSyncProvider\\:\\:getDbDefinition\\(\\) return type with generic class Lkrms\\\\Sync\\\\Support\\\\DbSyncDefinition does not specify its types\\: TEntity, TProvider$#"
385-
count: 1
386-
path: src/Sync/Concept/DbSyncProvider.php
387-
388-
-
389-
message: "#^Method Lkrms\\\\Sync\\\\Concept\\\\SyncProvider\\:\\:__call\\(\\) has no return type specified\\.$#"
390-
count: 1
391-
path: src/Sync/Concept/SyncProvider.php
392-
393-
-
394-
message: "#^Method Lkrms\\\\Sync\\\\Concept\\\\SyncProvider\\:\\:__call\\(\\) has parameter \\$arguments with no value type specified in iterable type array\\.$#"
395-
count: 1
396-
path: src/Sync/Concept/SyncProvider.php
397-
398-
-
399-
message: "#^Method Lkrms\\\\Sync\\\\Concept\\\\SyncProvider\\:\\:pipeline\\(\\) return type with generic interface Lkrms\\\\Contract\\\\IPipeline does not specify its types\\: TInput, TOutput, TArgument$#"
400-
count: 1
401-
path: src/Sync/Concept/SyncProvider.php
402-
403-
-
404-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncContext\\:\\:maybeApplyFilterPolicy\\(\\) has parameter \\$empty with no type specified\\.$#"
405-
count: 1
406-
path: src/Sync/Contract/ISyncContext.php
407-
408-
-
409-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:create\\(\\) has parameter \\$args with no type specified\\.$#"
410-
count: 1
411-
path: src/Sync/Contract/ISyncEntityProvider.php
412-
413-
-
414-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:createList\\(\\) has parameter \\$args with no type specified\\.$#"
415-
count: 1
416-
path: src/Sync/Contract/ISyncEntityProvider.php
417-
418-
-
419-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:createListA\\(\\) has parameter \\$args with no type specified\\.$#"
420-
count: 1
421-
path: src/Sync/Contract/ISyncEntityProvider.php
422-
423-
-
424-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:delete\\(\\) has parameter \\$args with no type specified\\.$#"
425-
count: 1
426-
path: src/Sync/Contract/ISyncEntityProvider.php
427-
428-
-
429-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:deleteList\\(\\) has parameter \\$args with no type specified\\.$#"
430-
count: 1
431-
path: src/Sync/Contract/ISyncEntityProvider.php
432-
433-
-
434-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:deleteListA\\(\\) has parameter \\$args with no type specified\\.$#"
435-
count: 1
436-
path: src/Sync/Contract/ISyncEntityProvider.php
437-
438-
-
439-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:get\\(\\) has parameter \\$args with no type specified\\.$#"
440-
count: 1
441-
path: src/Sync/Contract/ISyncEntityProvider.php
442-
443-
-
444-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:getList\\(\\) has parameter \\$args with no type specified\\.$#"
445-
count: 1
446-
path: src/Sync/Contract/ISyncEntityProvider.php
447-
448-
-
449-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:getListA\\(\\) has parameter \\$args with no type specified\\.$#"
450-
count: 1
451-
path: src/Sync/Contract/ISyncEntityProvider.php
452-
453-
-
454-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:run\\(\\) has parameter \\$args with no type specified\\.$#"
455-
count: 1
456-
path: src/Sync/Contract/ISyncEntityProvider.php
457-
458-
-
459-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:runA\\(\\) has parameter \\$args with no type specified\\.$#"
460-
count: 1
461-
path: src/Sync/Contract/ISyncEntityProvider.php
462-
463-
-
464-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:update\\(\\) has parameter \\$args with no type specified\\.$#"
465-
count: 1
466-
path: src/Sync/Contract/ISyncEntityProvider.php
467-
468-
-
469-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:updateList\\(\\) has parameter \\$args with no type specified\\.$#"
470-
count: 1
471-
path: src/Sync/Contract/ISyncEntityProvider.php
472-
473-
-
474-
message: "#^Method Lkrms\\\\Sync\\\\Contract\\\\ISyncEntityProvider\\:\\:updateListA\\(\\) has parameter \\$args with no type specified\\.$#"
475-
count: 1
476-
path: src/Sync/Contract/ISyncEntityProvider.php
477-
478-
-
479-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncContext\\:\\:maybeApplyFilterPolicy\\(\\) has parameter \\$empty with no type specified\\.$#"
480-
count: 1
481-
path: src/Sync/Support/SyncContext.php
482-
483-
-
484-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityFuzzyResolver\\:\\:compareUncertainty\\(\\) has parameter \\$e1 with no value type specified in iterable type array\\.$#"
485-
count: 1
486-
path: src/Sync/Support/SyncEntityFuzzyResolver.php
487-
488-
-
489-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityFuzzyResolver\\:\\:compareUncertainty\\(\\) has parameter \\$e2 with no value type specified in iterable type array\\.$#"
490-
count: 1
491-
path: src/Sync/Support/SyncEntityFuzzyResolver.php
492-
493-
-
494-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityFuzzyResolver\\:\\:loadEntities\\(\\) has no return type specified\\.$#"
495-
count: 1
496-
path: src/Sync/Support/SyncEntityFuzzyResolver.php
497-
498-
-
499-
message: "#^Property Lkrms\\\\Sync\\\\Support\\\\SyncEntityFuzzyResolver\\:\\:\\$Cache has no type specified\\.$#"
500-
count: 1
501-
path: src/Sync/Support/SyncEntityFuzzyResolver.php
502-
503-
-
504-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:_run\\(\\) has parameter \\$args with no type specified\\.$#"
505-
count: 1
506-
path: src/Sync/Support/SyncEntityProvider.php
507-
508-
-
509-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:create\\(\\) has parameter \\$args with no type specified\\.$#"
510-
count: 1
511-
path: src/Sync/Support/SyncEntityProvider.php
512-
513-
-
514-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:createList\\(\\) has parameter \\$args with no type specified\\.$#"
515-
count: 1
516-
path: src/Sync/Support/SyncEntityProvider.php
517-
518-
-
519-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:createListA\\(\\) has parameter \\$args with no type specified\\.$#"
520-
count: 1
521-
path: src/Sync/Support/SyncEntityProvider.php
522-
523-
-
524-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:delete\\(\\) has parameter \\$args with no type specified\\.$#"
525-
count: 1
526-
path: src/Sync/Support/SyncEntityProvider.php
527-
528-
-
529-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:deleteList\\(\\) has parameter \\$args with no type specified\\.$#"
530-
count: 1
531-
path: src/Sync/Support/SyncEntityProvider.php
532-
533-
-
534-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:deleteListA\\(\\) has parameter \\$args with no type specified\\.$#"
535-
count: 1
536-
path: src/Sync/Support/SyncEntityProvider.php
537-
538-
-
539-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:get\\(\\) has parameter \\$args with no type specified\\.$#"
540-
count: 1
541-
path: src/Sync/Support/SyncEntityProvider.php
542-
543-
-
544-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:getFuzzyResolver\\(\\) return type with generic class Lkrms\\\\Sync\\\\Support\\\\SyncEntityFuzzyResolver does not specify its types\\: TEntity$#"
545-
count: 1
546-
path: src/Sync/Support/SyncEntityProvider.php
547-
548-
-
549-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:getList\\(\\) has parameter \\$args with no type specified\\.$#"
550-
count: 1
551-
path: src/Sync/Support/SyncEntityProvider.php
552-
553-
-
554-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:getListA\\(\\) has parameter \\$args with no type specified\\.$#"
555-
count: 1
556-
path: src/Sync/Support/SyncEntityProvider.php
557-
558-
-
559-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:getResolver\\(\\) return type with generic class Lkrms\\\\Sync\\\\Support\\\\SyncEntityResolver does not specify its types\\: TEntity$#"
560-
count: 1
561-
path: src/Sync/Support/SyncEntityProvider.php
562-
563-
-
564-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:run\\(\\) has parameter \\$args with no type specified\\.$#"
565-
count: 1
566-
path: src/Sync/Support/SyncEntityProvider.php
567-
568-
-
569-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:runA\\(\\) has parameter \\$args with no type specified\\.$#"
570-
count: 1
571-
path: src/Sync/Support/SyncEntityProvider.php
572-
573-
-
574-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:update\\(\\) has parameter \\$args with no type specified\\.$#"
575-
count: 1
576-
path: src/Sync/Support/SyncEntityProvider.php
577-
578-
-
579-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:updateList\\(\\) has parameter \\$args with no type specified\\.$#"
580-
count: 1
581-
path: src/Sync/Support/SyncEntityProvider.php
582-
583-
-
584-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncEntityProvider\\:\\:updateListA\\(\\) has parameter \\$args with no type specified\\.$#"
585-
count: 1
586-
path: src/Sync/Support/SyncEntityProvider.php
587-
588-
-
589-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncErrorCollection\\:\\:jsonSerialize\\(\\) return type has no value type specified in iterable type array\\.$#"
590-
count: 1
591-
path: src/Sync/Support/SyncErrorCollection.php
592-
593-
-
594-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncErrorCollection\\:\\:toSummary\\(\\) return type has no value type specified in iterable type array\\.$#"
595-
count: 1
596-
path: src/Sync/Support/SyncErrorCollection.php
597-
598-
-
599-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncIntrospector\\:\\:getIntrospectionClass\\(\\) return type with generic class Lkrms\\\\Sync\\\\Support\\\\SyncIntrospectionClass does not specify its types\\: TClass$#"
600-
count: 1
601-
path: src/Sync/Support/SyncIntrospector.php
602-
603-
-
604-
message: "#^Method Lkrms\\\\Sync\\\\Support\\\\SyncIntrospector\\:\\:getSyncOperationMethod\\(\\) has parameter \\$entity with generic class Lkrms\\\\Sync\\\\Support\\\\SyncIntrospector but does not specify its types\\: TClass, TIntrospectionClass$#"
605-
count: 1
606-
path: src/Sync/Support/SyncIntrospector.php
607-
608383
-
609384
message: "#^Method Lkrms\\\\Utility\\\\Assertions\\:\\:notEmpty\\(\\) has parameter \\$value with no type specified\\.$#"
610385
count: 1
@@ -935,26 +710,6 @@ parameters:
935710
count: 1
936711
path: tests/fixtures/Concept/TypedCollection/MyClass.php
937712

938-
-
939-
message: "#^Method Lkrms\\\\Tests\\\\Sync\\\\CustomEntity\\\\Post\\:\\:_setUserId\\(\\) has no return type specified\\.$#"
940-
count: 1
941-
path: tests/fixtures/Sync/CustomEntity/Post.php
942-
943-
-
944-
message: "#^Method Lkrms\\\\Tests\\\\Sync\\\\CustomEntity\\\\Post\\:\\:_setUserId\\(\\) has parameter \\$value with no type specified\\.$#"
945-
count: 1
946-
path: tests/fixtures/Sync/CustomEntity/Post.php
947-
948-
-
949-
message: "#^Method Lkrms\\\\Tests\\\\Sync\\\\CustomEntity\\\\User\\:\\:_setId\\(\\) has no return type specified\\.$#"
950-
count: 1
951-
path: tests/fixtures/Sync/CustomEntity/User.php
952-
953-
-
954-
message: "#^Method Lkrms\\\\Tests\\\\Sync\\\\CustomEntity\\\\User\\:\\:_setId\\(\\) has parameter \\$value with no type specified\\.$#"
955-
count: 1
956-
path: tests/fixtures/Sync/CustomEntity/User.php
957-
958713
-
959714
message: "#^Method Lkrms\\\\Tests\\\\Sync\\\\Provider\\\\JsonPlaceholderApi\\:\\:getPosts\\(\\) return type has no value type specified in iterable type iterable\\.$#"
960715
count: 1

src/Concern/TProvidable.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ final public function provider(): ?IProvider
6060
return $this->Provider;
6161
}
6262

63+
/**
64+
* @return TProvider
65+
*/
66+
final public function requireProvider(): IProvider
67+
{
68+
if (!$this->Provider) {
69+
throw new LogicException('Provider required');
70+
}
71+
return $this->Provider;
72+
}
73+
6374
/**
6475
* @param TProviderContext $context
6576
* @return $this
@@ -80,12 +91,12 @@ final public function context(): ?IProviderContext
8091
}
8192

8293
/**
83-
* @param class-string $id
94+
* @param class-string $service
8495
* @return $this
8596
*/
86-
final public function setService(string $id)
97+
final public function setService(string $service)
8798
{
88-
$this->Service = $id;
99+
$this->Service = $service;
89100

90101
return $this;
91102
}

0 commit comments

Comments
 (0)