Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make method annotations more strict #1010

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/View/Helper/DocBlockHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,23 @@ public function buildTableAnnotations(
}
}
}

$entityPath = "\\{$namespace}\\Model\\Entity\\{$entity}";

// phpcs:disable
$annotations[] = "@method \\{$namespace}\\Model\\Entity\\{$entity} newEmptyEntity()";
$annotations[] = "@method \\{$namespace}\\Model\\Entity\\{$entity} newEntity(array \$data, array \$options = [])";
$annotations[] = "@method array<\\{$namespace}\\Model\\Entity\\{$entity}> newEntities(array \$data, array \$options = [])";
$annotations[] = "@method \\{$namespace}\\Model\\Entity\\{$entity} get(mixed \$primaryKey, array|string \$finder = 'all', \\Psr\\SimpleCache\\CacheInterface|string|null \$cache = null, \Closure|string|null \$cacheKey = null, mixed ...\$args)";
$annotations[] = "@method \\{$namespace}\\Model\\Entity\\{$entity} findOrCreate(\$search, ?callable \$callback = null, array \$options = [])";
$annotations[] = "@method \\{$namespace}\\Model\\Entity\\{$entity} patchEntity(\\Cake\\Datasource\\EntityInterface \$entity, array \$data, array \$options = [])";
$annotations[] = "@method array<\\{$namespace}\\Model\\Entity\\{$entity}> patchEntities(iterable \$entities, array \$data, array \$options = [])";
$annotations[] = "@method \\{$namespace}\\Model\\Entity\\{$entity}|false save(\\Cake\\Datasource\\EntityInterface \$entity, array \$options = [])";
$annotations[] = "@method \\{$namespace}\\Model\\Entity\\{$entity} saveOrFail(\\Cake\\Datasource\\EntityInterface \$entity, array \$options = [])";
$annotations[] = "@method iterable<\\{$namespace}\\Model\\Entity\\{$entity}>|\Cake\Datasource\ResultSetInterface<\\{$namespace}\\Model\\Entity\\{$entity}>|false saveMany(iterable \$entities, array \$options = [])";
$annotations[] = "@method iterable<\\{$namespace}\\Model\\Entity\\{$entity}>|\Cake\Datasource\ResultSetInterface<\\{$namespace}\\Model\\Entity\\{$entity}> saveManyOrFail(iterable \$entities, array \$options = [])";
$annotations[] = "@method iterable<\\{$namespace}\\Model\\Entity\\{$entity}>|\Cake\Datasource\ResultSetInterface<\\{$namespace}\\Model\\Entity\\{$entity}>|false deleteMany(iterable \$entities, array \$options = [])";
$annotations[] = "@method iterable<\\{$namespace}\\Model\\Entity\\{$entity}>|\Cake\Datasource\ResultSetInterface<\\{$namespace}\\Model\\Entity\\{$entity}> deleteManyOrFail(iterable \$entities, array \$options = [])";
$annotations[] = "@method $entityPath newEmptyEntity()";
$annotations[] = "@method $entityPath newEntity(array<mixed> \$data, array<string, mixed> \$options = [])";
$annotations[] = "@method array<$entityPath> newEntities(array<mixed> \$data, array<string, mixed> \$options = [])";
$annotations[] = "@method $entityPath get(mixed \$primaryKey, array<mixed>|string \$finder = 'all', \\Psr\\SimpleCache\\CacheInterface|string|null \$cache = null, \Closure|string|null \$cacheKey = null, mixed ...\$args)";
Harfusha marked this conversation as resolved.
Show resolved Hide resolved
$annotations[] = "@method $entityPath findOrCreate(\$search, ?callable \$callback = null, array<string, mixed> \$options = [])";
$annotations[] = "@method $entityPath patchEntity(\\Cake\\Datasource\\EntityInterface \$entity, array<mixed> \$data, array<string, mixed> \$options = [])";
$annotations[] = "@method array<$entityPath> patchEntities(iterable<\\Cake\\Datasource\\EntityInterface> \$entities, array<mixed> \$data, array<string, mixed> \$options = [])";
$annotations[] = "@method $entityPath|false save(\\Cake\\Datasource\\EntityInterface \$entity, array<string, mixed> \$options = [])";
$annotations[] = "@method $entityPath saveOrFail(\\Cake\\Datasource\\EntityInterface \$entity, array<string, mixed> \$options = [])";
$annotations[] = "@method iterable<$entityPath>|\Cake\Datasource\ResultSetInterface<$entityPath>|false saveMany(iterable<\\Cake\\Datasource\\EntityInterface> \$entities, array<string, mixed> \$options = [])";
$annotations[] = "@method iterable<$entityPath>|\Cake\Datasource\ResultSetInterface<$entityPath> saveManyOrFail(iterable<\\Cake\\Datasource\\EntityInterface> \$entities, array<string, mixed> \$options = [])";
$annotations[] = "@method iterable<$entityPath>|\Cake\Datasource\ResultSetInterface<$entityPath>|false deleteMany(iterable<\\Cake\\Datasource\\EntityInterface> \$entities, array<string, mixed> \$options = [])";
$annotations[] = "@method iterable<$entityPath>|\Cake\Datasource\ResultSetInterface<$entityPath> deleteManyOrFail(iterable<\\Cake\\Datasource\\EntityInterface> \$entities, array<string, mixed> \$options = [])";
// phpcs:enable
foreach ($behaviors as $behavior => $behaviorData) {
$className = App::className($behavior, 'Model/Behavior', 'Behavior');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
* @property \Bake\Test\App\Model\Table\ProductsTable&\Cake\ORM\Association\BelongsTo $Products
*
* @method \Bake\Test\App\Model\Entity\CategoriesProduct newEmptyEntity()
* @method \Bake\Test\App\Model\Entity\CategoriesProduct newEntity(array $data, array $options = [])
* @method array<\Bake\Test\App\Model\Entity\CategoriesProduct> newEntities(array $data, array $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \Bake\Test\App\Model\Entity\CategoriesProduct findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\Bake\Test\App\Model\Entity\CategoriesProduct> patchEntities(iterable $entities, array $data, array $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct> deleteManyOrFail(iterable $entities, array $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct newEntity(array<mixed> $data, array<string, mixed> $options = [])
* @method array<\Bake\Test\App\Model\Entity\CategoriesProduct> newEntities(array<mixed> $data, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct get(mixed $primaryKey, array<mixed>|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \Bake\Test\App\Model\Entity\CategoriesProduct findOrCreate($search, ?callable $callback = null, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct patchEntity(\Cake\Datasource\EntityInterface $entity, array<mixed> $data, array<string, mixed> $options = [])
* @method array<\Bake\Test\App\Model\Entity\CategoriesProduct> patchEntities(iterable<\Cake\Datasource\EntityInterface> $entities, array<mixed> $data, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct|false save(\Cake\Datasource\EntityInterface $entity, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\CategoriesProduct saveOrFail(\Cake\Datasource\EntityInterface $entity, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct>|false saveMany(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct> saveManyOrFail(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct>|false deleteMany(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\CategoriesProduct>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\CategoriesProduct> deleteManyOrFail(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
*/
class CategoriesProductsTable extends Table
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
* @property \Bake\Test\App\Model\Table\ProductsTable&\Cake\ORM\Association\BelongsToMany $Products
*
* @method \Bake\Test\App\Model\Entity\Category newEmptyEntity()
* @method \Bake\Test\App\Model\Entity\Category newEntity(array $data, array $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> newEntities(array $data, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \Bake\Test\App\Model\Entity\Category findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> patchEntities(iterable $entities, array $data, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> deleteManyOrFail(iterable $entities, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category newEntity(array<mixed> $data, array<string, mixed> $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> newEntities(array<mixed> $data, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\Category get(mixed $primaryKey, array<mixed>|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \Bake\Test\App\Model\Entity\Category findOrCreate($search, ?callable $callback = null, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\Category patchEntity(\Cake\Datasource\EntityInterface $entity, array<mixed> $data, array<string, mixed> $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> patchEntities(iterable<\Cake\Datasource\EntityInterface> $entities, array<mixed> $data, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\Category|false save(\Cake\Datasource\EntityInterface $entity, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\Category saveOrFail(\Cake\Datasource\EntityInterface $entity, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false saveMany(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> saveManyOrFail(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false deleteMany(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> deleteManyOrFail(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
* @property \Bake\Test\App\Model\Table\ProductsTable&\Cake\ORM\Association\BelongsToMany $Products
*
* @method \Bake\Test\App\Model\Entity\Category newEmptyEntity()
* @method \Bake\Test\App\Model\Entity\Category newEntity(array $data, array $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> newEntities(array $data, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category newEntity(array<mixed> $data, array<string, mixed> $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> newEntities(array<mixed> $data, array<string, mixed> $options = [])
* @method \Bake\Test\App\Model\Entity\Category get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, mixed ...$args)
* @method \Bake\Test\App\Model\Entity\Category findOrCreate($search, ?callable $callback = null, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> patchEntities(iterable $entities, array $data, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category|false save(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category saveOrFail(\Cake\Datasource\EntityInterface $entity, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false saveMany(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> saveManyOrFail(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false deleteMany(iterable $entities, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> deleteManyOrFail(iterable $entities, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category patchEntity(\Bake\Test\App\Model\Entity\Category $entity, array $data, array $options = [])
* @method array<\Bake\Test\App\Model\Entity\Category> patchEntities(iterable<\Cake\Datasource\EntityInterface> $entities, array $data, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category|false save(\Bake\Test\App\Model\Entity\Category $entity, array $options = [])
* @method \Bake\Test\App\Model\Entity\Category saveOrFail(\Bake\Test\App\Model\Entity\Category $entity, array $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false saveMany(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> saveManyOrFail(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category>|false deleteMany(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
* @method iterable<\Bake\Test\App\Model\Entity\Category>|\Cake\Datasource\ResultSetInterface<\Bake\Test\App\Model\Entity\Category> deleteManyOrFail(iterable<\Cake\Datasource\EntityInterface> $entities, array<string, mixed> $options = [])
*
* @mixin \Cake\ORM\Behavior\TimestampBehavior
*/
Expand Down
Loading
Loading