Skip to content

Commit dee3e6b

Browse files
authored
Merge pull request #359 from Harfusha/generate-strict-annotations-followup
Generate strict annotations followup
2 parents 49ccd37 + e8a811e commit dee3e6b

File tree

13 files changed

+19
-14
lines changed

13 files changed

+19
-14
lines changed

docs/Annotations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ Tables should annotate their entity related methods, their relations and behavio
7272
A LocationsTable class would then get the following doc block annotations added if not already present:
7373
```php
7474
/**
75-
* @method \App\Model\Entity\Location get($primaryKey, array $options = [])
7675
* @method \App\Model\Entity\Location newEmptyEntity()
7776
* @method \App\Model\Entity\Location newEntity(array $data, array $options = [])
7877
* @method array<\App\Model\Entity\Location> newEntities(array $data, array $options = [])
78+
* @method \App\Model\Entity\Location get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
7979
* @method \App\Model\Entity\Location|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
8080
* @method \App\Model\Entity\Location saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
8181
* @method \App\Model\Entity\Location patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
8282
* @method array<\App\Model\Entity\Location> patchEntities(iterable $entities, array $data, array $options = [])
83-
* @method \App\Model\Entity\Location findOrCreate($search, ?callable $callback = null, array $options = [])
83+
* @method \App\Model\Entity\Location findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = [])
8484
* @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Location>|false saveMany(iterable $entities, array $options = [])
8585
* @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Location> saveManyOrFail(iterable $entities, array $options = [])
8686
* @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Location>|false deleteMany(iterable $entities, array $options = [])

src/Annotator/ControllerAnnotator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,12 @@ protected function getPaginationAnnotations(string $content, ?string $primaryMod
182182

183183
$resultSetInterfaceCollection = GenericString::generate(implode('|', $entities), '\\' . ResultSetInterface::class);
184184

185-
$annotations = [AnnotationFactory::createOrFail(MethodAnnotation::TAG, $resultSetInterfaceCollection, 'paginate($object = null, array $settings = [])')];
185+
$settingsType = 'array';
186+
if (Configure::read('IdeHelper.concreteEntitiesInParam')) {
187+
$settingsType = 'array<string, mixed> ';
188+
}
189+
190+
$annotations = [AnnotationFactory::createOrFail(MethodAnnotation::TAG, $resultSetInterfaceCollection, 'paginate(\Cake\Datasource\RepositoryInterface|\Cake\Datasource\QueryInterface|string|null $object = null, ' . $settingsType . ' $settings = [])')];
186191

187192
return $annotations;
188193
}

src/Annotator/ModelAnnotator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function buildAnnotations(array $associations, string $entity, array $
172172
$annotations[] = "@method {$fullClassNameCollection} newEntities({$dataType} \$data, {$optionsType} \$options = [])";
173173

174174
$annotations[] = "@method {$fullClassName} get(mixed \$primaryKey, array|string \$finder = 'all', \Psr\SimpleCache\CacheInterface|string|null \$cache = null, \Closure|string|null \$cacheKey = null, mixed ...\$args)";
175-
$annotations[] = "@method {$fullClassName} findOrCreate(\$search, ?callable \$callback = null, {$optionsType} \$options = [])";
175+
$annotations[] = "@method {$fullClassName} findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array \$search, ?callable \$callback = null, {$optionsType} \$options = [])";
176176

177177
$annotations[] = "@method {$fullClassName} patchEntity({$entityInterface} \$entity, {$dataType} \$data, {$optionsType} \$options = [])";
178178
$annotations[] = "@method {$fullClassNameCollection} patchEntities({$itterable} \$entities, {$dataType} \$data, {$optionsType} \$options = [])";

src/View/Helper/DocBlockHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function buildTableAnnotations(
172172
$annotations[] = "@method {$class} newEntity({$dataType} \$data, {$optionsType} \$options = [])";
173173
$annotations[] = "@method {$classes} newEntities({$dataType} \$data, {$optionsType} \$options = [])";
174174
$annotations[] = "@method {$class} get(mixed \$primaryKey, array|string \$finder = 'all', \Psr\SimpleCache\CacheInterface|string|null \$cache = null, \Closure|string|null \$cacheKey = null, mixed ...\$args)";
175-
$annotations[] = "@method {$class} findOrCreate(\$search, ?callable \$callback = null, {$optionsType} \$options = [])";
175+
$annotations[] = "@method {$class} findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array \$search, ?callable \$callback = null, {$optionsType} \$options = [])";
176176
$annotations[] = "@method {$class} patchEntity({$classInterface} \$entity, {$dataType} \$data, {$optionsType} \$options = [])";
177177
$annotations[] = "@method {$classes} patchEntities({$itterable} \$entities, {$dataType} \$data, {$optionsType} \$options = [])";
178178
$annotations[] = "@method {$class}|false save({$classInterface} \$entity, {$optionsType} \$options = [])";

tests/test_files/Controller/BarController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @property \TestApp\Model\Table\BarBarsTable $BarBars
77
* @property \MyNamespace\MyPlugin\Controller\Component\MyComponent $My
88
*
9-
* @method \TestApp\Model\Entity\BarBar[]|\Cake\Datasource\ResultSetInterface<\TestApp\Model\Entity\BarBar> paginate($object = null, array $settings = [])
9+
* @method \TestApp\Model\Entity\BarBar[]|\Cake\Datasource\ResultSetInterface<\TestApp\Model\Entity\BarBar> paginate(\Cake\Datasource\RepositoryInterface|\Cake\Datasource\QueryInterface|string|null $object = null, array $settings = [])
1010
*/
1111
class BarController extends AppController {
1212

tests/test_files/Model/Table/BarBarsAbstractTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @method \TestApp\Model\Entity\BarBarsAbstract newEntity(array $data, array $options = [])
1010
* @method \TestApp\Model\Entity\BarBarsAbstract[] newEntities(array $data, array $options = [])
1111
* @method \TestApp\Model\Entity\BarBarsAbstract get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
12-
* @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate($search, ?callable $callback = null, array $options = [])
12+
* @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = [])
1313
* @method \TestApp\Model\Entity\BarBarsAbstract patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
1414
* @method \TestApp\Model\Entity\BarBarsAbstract[] patchEntities(iterable $entities, array $data, array $options = [])
1515
* @method \TestApp\Model\Entity\BarBarsAbstract|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])

tests/test_files/Model/Table/BarBarsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @method \TestApp\Model\Entity\BarBar newEntity(array $data, array $options = [])
1212
* @method \TestApp\Model\Entity\BarBar[] newEntities(array $data, array $options = [])
1313
* @method \TestApp\Model\Entity\BarBar get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
14-
* @method \TestApp\Model\Entity\BarBar findOrCreate($search, ?callable $callback = null, array $options = [])
14+
* @method \TestApp\Model\Entity\BarBar findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = [])
1515
* @method \TestApp\Model\Entity\BarBar patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
1616
* @method \TestApp\Model\Entity\BarBar[] patchEntities(iterable $entities, array $data, array $options = [])
1717
* @method \TestApp\Model\Entity\BarBar|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])

tests/test_files/Model/Table/FooTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @method \TestApp\Model\Entity\Foo saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
1212
* @method \TestApp\Model\Entity\Foo patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
1313
* @method \TestApp\Model\Entity\Foo[] patchEntities($entities, array $data, array $options = [])
14-
* @method \TestApp\Model\Entity\Foo findOrCreate($search, callable $callback = null, array $options = [])
14+
* @method \TestApp\Model\Entity\Foo findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, callable $callback = null, array $options = [])
1515
*
1616
* @mixin \Cake\ORM\Behavior\TimestampBehavior
1717
* @mixin \MyNamespace\MyPlugin\Model\Behavior\MyBehavior

tests/test_files/Model/Table/Specific/BarBarsAbstractTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @method \TestApp\Model\Entity\BarBarsAbstract newEntity(array<mixed> $data, array<string, mixed> $options = [])
1010
* @method \TestApp\Model\Entity\BarBarsAbstract[] newEntities(array<mixed> $data, array<string, mixed> $options = [])
1111
* @method \TestApp\Model\Entity\BarBarsAbstract get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
12-
* @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate($search, ?callable $callback = null, array<string, mixed> $options = [])
12+
* @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array<string, mixed> $options = [])
1313
* @method \TestApp\Model\Entity\BarBarsAbstract patchEntity(\TestApp\Model\Entity\BarBarsAbstract $entity, array<mixed> $data, array<string, mixed> $options = [])
1414
* @method \TestApp\Model\Entity\BarBarsAbstract[] patchEntities(iterable<\TestApp\Model\Entity\BarBarsAbstract> $entities, array<mixed> $data, array<string, mixed> $options = [])
1515
* @method \TestApp\Model\Entity\BarBarsAbstract|false save(\TestApp\Model\Entity\BarBarsAbstract $entity, array<string, mixed> $options = [])

tests/test_files/Model/Table/Specific/BarBarsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @method \TestApp\Model\Entity\BarBar newEntity(array<mixed> $data, array<string, mixed> $options = [])
1212
* @method \TestApp\Model\Entity\BarBar[] newEntities(array<mixed> $data, array<string, mixed> $options = [])
1313
* @method \TestApp\Model\Entity\BarBar get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
14-
* @method \TestApp\Model\Entity\BarBar findOrCreate($search, ?callable $callback = null, array<string, mixed> $options = [])
14+
* @method \TestApp\Model\Entity\BarBar findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array<string, mixed> $options = [])
1515
* @method \TestApp\Model\Entity\BarBar patchEntity(\TestApp\Model\Entity\BarBar $entity, array<mixed> $data, array<string, mixed> $options = [])
1616
* @method \TestApp\Model\Entity\BarBar[] patchEntities(iterable<\TestApp\Model\Entity\BarBar> $entities, array<mixed> $data, array<string, mixed> $options = [])
1717
* @method \TestApp\Model\Entity\BarBar|false save(\TestApp\Model\Entity\BarBar $entity, array<string, mixed> $options = [])

0 commit comments

Comments
 (0)