php - How to lint Namespace based on folder's name?

I know PHP CS Fixer and Psalm to lint PHP. I've been using both of them. But I can't find a way to lint / validate my namespace name based on the folder.
For example, in folderTests/Controllers/V1
, I haveMyControllerTest.php
, and it has the following codes:
<?php
// I should have correct namespace based on folder name not V2 but V1
namespace Tests\Controllers\V2;
.. ... my code
How can I lint the above code with correct namespace?
NOTE: I am using PHP 7.3.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: method illuminate\database\eloquent\collection::paginate does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.