-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Description
Feature request
It'd be nice to be able to achieve friend functions with PHPStan. An example of such usage that just popped up in our project:
class Product
{
public function addCategory(Category $category): void;
}
class Category
{
/**
* @internal
* @see Product::addCategory
*/
public function addProduct(Product $product): void;
}
Category::addProduct should never be called directly but needs to be public so it might be called from Product::addCategory. It would be amazing to have a rule that forbids calls to methods marked as @internal unless a @friend FQCN::method (or something alike) is specified and the call is made from specified context.
What do you think?
Reactions are currently unavailable