arkitect icon indicating copy to clipboard operation
arkitect copied to clipboard

Check doc blocks at functions

Open Mysak007 opened this issue 1 year ago • 2 comments

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

Mysak007 avatar Oct 18 '22 11:10 Mysak007

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 avatar Oct 18 '22 14:10 AlessandroMinoccheri

@AlessandroMinoccheri Thanks a lot that would be great :)

Mysak007 avatar Oct 19 '22 08:10 Mysak007

@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!

AlessandroMinoccheri avatar Oct 30 '22 12:10 AlessandroMinoccheri