arkitect
arkitect copied to clipboard
Check doc blocks at functions
Feature Request
I'm not sure if it is a bug. I'm using "phparkitect/phparkitect": "^0.2.32",
Please implement rule to check if docblock at function contains string.
Summary
I tried to implement rule
// exception rule
$rules[] = Rule::allClasses()
->that(new ResideInOneOfTheseNamespaces('App'))
->should(new DocBlockNotContains('@throws Exception'))
->because('we don\'t want simple exceptions - use custom instead');
but it checks only docblock at classes, not at functions so when I have functions like this, I need to check it.
/**
* @throws Exception
* @throws ItemNotFoundException
*/
public function handleTitleCreate(TitleCreateParameters $parameters): Title
The same problem is when I want to check that entity doesn't use repository (IE: #[ORM\Entity(repositoryClass: ProductRepository::class)]
So when I use:
// entity docblock doesn't contain repository $rules[] = Rule::allClasses() ->that(new ResideInOneOfTheseNamespaces('App\Entity')) ->should(new DocBlockContains('#[ORM\Entity(repositoryClass:')) ->because('we don\'t want to use repository class in our entities');
It doesn't work.
thanks a lot :) Michal
Hi @Mysak007, we only analyze the docblock on the class and not for every function. So we can try to analyze the function's docblock.
@AlessandroMinoccheri Thanks a lot that would be great :)
@Mysak007 we released the new version 0.3.0
Pay attention, we changed rules for docBlock in: ContainDocBlockLike
and NotContainDocBlockLike
Feel free to open new issue about this topic, at the moment I consider closed this issue :)
Thanks!