diff --git a/docs/Annotations.md b/docs/Annotations.md index f06f9a88..005f28f6 100644 --- a/docs/Annotations.md +++ b/docs/Annotations.md @@ -72,15 +72,15 @@ Tables should annotate their entity related methods, their relations and behavio A LocationsTable class would then get the following doc block annotations added if not already present: ```php /** - * @method \App\Model\Entity\Location get($primaryKey, array $options = []) * @method \App\Model\Entity\Location newEmptyEntity() * @method \App\Model\Entity\Location newEntity(array $data, array $options = []) * @method array<\App\Model\Entity\Location> newEntities(array $data, array $options = []) + * @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) * @method \App\Model\Entity\Location|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) * @method \App\Model\Entity\Location saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) * @method \App\Model\Entity\Location patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method array<\App\Model\Entity\Location> patchEntities(iterable $entities, array $data, array $options = []) - * @method \App\Model\Entity\Location findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \App\Model\Entity\Location findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = []) * @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Location>|false saveMany(iterable $entities, array $options = []) * @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Location> saveManyOrFail(iterable $entities, array $options = []) * @method \Cake\Datasource\ResultSetInterface<\App\Model\Entity\Location>|false deleteMany(iterable $entities, array $options = []) diff --git a/src/Annotator/ControllerAnnotator.php b/src/Annotator/ControllerAnnotator.php index 8b184be0..95024e12 100644 --- a/src/Annotator/ControllerAnnotator.php +++ b/src/Annotator/ControllerAnnotator.php @@ -182,7 +182,12 @@ protected function getPaginationAnnotations(string $content, ?string $primaryMod $resultSetInterfaceCollection = GenericString::generate(implode('|', $entities), '\\' . ResultSetInterface::class); - $annotations = [AnnotationFactory::createOrFail(MethodAnnotation::TAG, $resultSetInterfaceCollection, 'paginate($object = null, array $settings = [])')]; + $settingsType = 'array'; + if (Configure::read('IdeHelper.concreteEntitiesInParam')) { + $settingsType = 'array '; + } + + $annotations = [AnnotationFactory::createOrFail(MethodAnnotation::TAG, $resultSetInterfaceCollection, 'paginate(\Cake\Datasource\RepositoryInterface|\Cake\Datasource\QueryInterface|string|null $object = null, ' . $settingsType . ' $settings = [])')]; return $annotations; } diff --git a/src/Annotator/ModelAnnotator.php b/src/Annotator/ModelAnnotator.php index 0f5633e2..1da92eee 100644 --- a/src/Annotator/ModelAnnotator.php +++ b/src/Annotator/ModelAnnotator.php @@ -172,7 +172,7 @@ protected function buildAnnotations(array $associations, string $entity, array $ $annotations[] = "@method {$fullClassNameCollection} newEntities({$dataType} \$data, {$optionsType} \$options = [])"; $annotations[] = "@method {$fullClassName} get(mixed \$primaryKey, array|string \$finder = 'all', \Psr\SimpleCache\CacheInterface|string|null \$cache = null, \Closure|string|null \$cacheKey = null, mixed ...\$args)"; - $annotations[] = "@method {$fullClassName} findOrCreate(\$search, ?callable \$callback = null, {$optionsType} \$options = [])"; + $annotations[] = "@method {$fullClassName} findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array \$search, ?callable \$callback = null, {$optionsType} \$options = [])"; $annotations[] = "@method {$fullClassName} patchEntity({$entityInterface} \$entity, {$dataType} \$data, {$optionsType} \$options = [])"; $annotations[] = "@method {$fullClassNameCollection} patchEntities({$itterable} \$entities, {$dataType} \$data, {$optionsType} \$options = [])"; diff --git a/src/View/Helper/DocBlockHelper.php b/src/View/Helper/DocBlockHelper.php index 3710f0dc..fa6992b2 100644 --- a/src/View/Helper/DocBlockHelper.php +++ b/src/View/Helper/DocBlockHelper.php @@ -172,7 +172,7 @@ public function buildTableAnnotations( $annotations[] = "@method {$class} newEntity({$dataType} \$data, {$optionsType} \$options = [])"; $annotations[] = "@method {$classes} newEntities({$dataType} \$data, {$optionsType} \$options = [])"; $annotations[] = "@method {$class} get(mixed \$primaryKey, array|string \$finder = 'all', \Psr\SimpleCache\CacheInterface|string|null \$cache = null, \Closure|string|null \$cacheKey = null, mixed ...\$args)"; - $annotations[] = "@method {$class} findOrCreate(\$search, ?callable \$callback = null, {$optionsType} \$options = [])"; + $annotations[] = "@method {$class} findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array \$search, ?callable \$callback = null, {$optionsType} \$options = [])"; $annotations[] = "@method {$class} patchEntity({$classInterface} \$entity, {$dataType} \$data, {$optionsType} \$options = [])"; $annotations[] = "@method {$classes} patchEntities({$itterable} \$entities, {$dataType} \$data, {$optionsType} \$options = [])"; $annotations[] = "@method {$class}|false save({$classInterface} \$entity, {$optionsType} \$options = [])"; diff --git a/tests/test_files/Controller/BarController.php b/tests/test_files/Controller/BarController.php index 6da371b6..b4e7578e 100644 --- a/tests/test_files/Controller/BarController.php +++ b/tests/test_files/Controller/BarController.php @@ -6,7 +6,7 @@ * @property \TestApp\Model\Table\BarBarsTable $BarBars * @property \MyNamespace\MyPlugin\Controller\Component\MyComponent $My * - * @method \TestApp\Model\Entity\BarBar[]|\Cake\Datasource\ResultSetInterface<\TestApp\Model\Entity\BarBar> paginate($object = null, array $settings = []) + * @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 = []) */ class BarController extends AppController { diff --git a/tests/test_files/Model/Table/BarBarsAbstractTable.php b/tests/test_files/Model/Table/BarBarsAbstractTable.php index f3c09c5e..409c0135 100644 --- a/tests/test_files/Model/Table/BarBarsAbstractTable.php +++ b/tests/test_files/Model/Table/BarBarsAbstractTable.php @@ -9,7 +9,7 @@ * @method \TestApp\Model\Entity\BarBarsAbstract newEntity(array $data, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract[] newEntities(array $data, array $options = []) * @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) - * @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract[] patchEntities(iterable $entities, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) diff --git a/tests/test_files/Model/Table/BarBarsTable.php b/tests/test_files/Model/Table/BarBarsTable.php index 8d74960d..7ce2c896 100644 --- a/tests/test_files/Model/Table/BarBarsTable.php +++ b/tests/test_files/Model/Table/BarBarsTable.php @@ -11,7 +11,7 @@ * @method \TestApp\Model\Entity\BarBar newEntity(array $data, array $options = []) * @method \TestApp\Model\Entity\BarBar[] newEntities(array $data, array $options = []) * @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) - * @method \TestApp\Model\Entity\BarBar findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\BarBar findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = []) * @method \TestApp\Model\Entity\BarBar patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBar[] patchEntities(iterable $entities, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBar|false save(\Cake\Datasource\EntityInterface $entity, array $options = []) diff --git a/tests/test_files/Model/Table/FooTable.php b/tests/test_files/Model/Table/FooTable.php index f0fa62fa..7be2da05 100644 --- a/tests/test_files/Model/Table/FooTable.php +++ b/tests/test_files/Model/Table/FooTable.php @@ -11,7 +11,7 @@ * @method \TestApp\Model\Entity\Foo saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = []) * @method \TestApp\Model\Entity\Foo patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\Foo[] patchEntities($entities, array $data, array $options = []) - * @method \TestApp\Model\Entity\Foo findOrCreate($search, callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\Foo findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, callable $callback = null, array $options = []) * * @mixin \Cake\ORM\Behavior\TimestampBehavior * @mixin \MyNamespace\MyPlugin\Model\Behavior\MyBehavior diff --git a/tests/test_files/Model/Table/Specific/BarBarsAbstractTable.php b/tests/test_files/Model/Table/Specific/BarBarsAbstractTable.php index 61fdd94a..f3685056 100644 --- a/tests/test_files/Model/Table/Specific/BarBarsAbstractTable.php +++ b/tests/test_files/Model/Table/Specific/BarBarsAbstractTable.php @@ -9,7 +9,7 @@ * @method \TestApp\Model\Entity\BarBarsAbstract newEntity(array $data, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract[] newEntities(array $data, array $options = []) * @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) - * @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\BarBarsAbstract findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract patchEntity(\TestApp\Model\Entity\BarBarsAbstract $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract[] patchEntities(iterable<\TestApp\Model\Entity\BarBarsAbstract> $entities, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBarsAbstract|false save(\TestApp\Model\Entity\BarBarsAbstract $entity, array $options = []) diff --git a/tests/test_files/Model/Table/Specific/BarBarsTable.php b/tests/test_files/Model/Table/Specific/BarBarsTable.php index 1d3ea118..60624399 100644 --- a/tests/test_files/Model/Table/Specific/BarBarsTable.php +++ b/tests/test_files/Model/Table/Specific/BarBarsTable.php @@ -11,7 +11,7 @@ * @method \TestApp\Model\Entity\BarBar newEntity(array $data, array $options = []) * @method \TestApp\Model\Entity\BarBar[] newEntities(array $data, array $options = []) * @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) - * @method \TestApp\Model\Entity\BarBar findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\BarBar findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = []) * @method \TestApp\Model\Entity\BarBar patchEntity(\TestApp\Model\Entity\BarBar $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBar[] patchEntities(iterable<\TestApp\Model\Entity\BarBar> $entities, array $data, array $options = []) * @method \TestApp\Model\Entity\BarBar|false save(\TestApp\Model\Entity\BarBar $entity, array $options = []) diff --git a/tests/test_files/Model/Table/Specific/FooTable.php b/tests/test_files/Model/Table/Specific/FooTable.php index c427f393..4ff606fb 100644 --- a/tests/test_files/Model/Table/Specific/FooTable.php +++ b/tests/test_files/Model/Table/Specific/FooTable.php @@ -11,7 +11,7 @@ * @method \TestApp\Model\Entity\Foo saveOrFail(\TestApp\Model\Entity\Foo $entity, array $options = []) * @method \TestApp\Model\Entity\Foo patchEntity(\TestApp\Model\Entity\Foo $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\Foo[] patchEntities($entities, array $data, array $options = []) - * @method \TestApp\Model\Entity\Foo findOrCreate($search, callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\Foo findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, callable $callback = null, array $options = []) * * @mixin \Cake\ORM\Behavior\TimestampBehavior * @mixin \MyNamespace\MyPlugin\Model\Behavior\MyBehavior diff --git a/tests/test_files/Model/Table/Specific/WheelsTable.php b/tests/test_files/Model/Table/Specific/WheelsTable.php index fd9f8e9a..2dd6f3fc 100644 --- a/tests/test_files/Model/Table/Specific/WheelsTable.php +++ b/tests/test_files/Model/Table/Specific/WheelsTable.php @@ -9,7 +9,7 @@ * @method \TestApp\Model\Entity\Wheel newEmptyEntity() * @method \TestApp\Model\Entity\Wheel[] newEntities(array $data, array $options = []) * @method \TestApp\Model\Entity\Wheel get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) - * @method \TestApp\Model\Entity\Wheel findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\Wheel findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = []) * @method \TestApp\Model\Entity\Wheel patchEntity(\TestApp\Model\Entity\Wheel $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\Wheel[] patchEntities(iterable<\TestApp\Model\Entity\Wheel> $entities, array $data, array $options = []) * @method \TestApp\Model\Entity\Wheel|false save(\TestApp\Model\Entity\Wheel $entity, array $options = []) diff --git a/tests/test_files/Model/Table/WheelsTable.php b/tests/test_files/Model/Table/WheelsTable.php index 43a59f7a..3f6c0070 100644 --- a/tests/test_files/Model/Table/WheelsTable.php +++ b/tests/test_files/Model/Table/WheelsTable.php @@ -9,7 +9,7 @@ * @method \TestApp\Model\Entity\Wheel newEmptyEntity() * @method \TestApp\Model\Entity\Wheel[] newEntities(array $data, array $options = []) * @method \TestApp\Model\Entity\Wheel get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args) - * @method \TestApp\Model\Entity\Wheel findOrCreate($search, ?callable $callback = null, array $options = []) + * @method \TestApp\Model\Entity\Wheel findOrCreate(\Cake\ORM\Query\SelectQuery|callable|array $search, ?callable $callback = null, array $options = []) * @method \TestApp\Model\Entity\Wheel patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) * @method \TestApp\Model\Entity\Wheel[] patchEntities(iterable $entities, array $data, array $options = []) * @method \TestApp\Model\Entity\Wheel|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])