-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I ran into an issue where phpnsc incorrectly detects a string as being a class.
Code:
<?php
namespace App\Service;
use App\Entity\Order;
use RuntimeException;
class TestService
{
public function updateOrderStatus(Order $order)
{
$class = '\\App\Importer\\' . ucfirst($order->getVendor()->getName());
if ($order->getStatus() != 'new') {
throw new RuntimeException("Cannot update order");
}
$order->setClass($class);
$order->setStatus('pending');
}
}
Here's my phpnsc.json:
{
"vendor" : "App",
"folders" : {
"root" : "./src/",
"include" : [""],
"exclude" : []
},
"filetypes" : {
"include" : [".php"],
"exclude" : [".config.php"]
},
"output" : [{
"class": "rg\\tools\\phpnsc\\CheckstyleOutput",
"parameter": "/tmp/phpnsc.xml"
},{
"class": "rg\\tools\\phpnsc\\ConsoleOutput",
"parameter": ""
}]
}
Result:
$ vendor/rg/phpnsc/phpnsc run phpnsc.json
Got 62 files
Collect entities...
............................................................ 60/62
.. 62/62
Got 60 defined entities
Check namespaces...
............................................................ 60/62
.. 62/62
Errors found:
/home/dave-barnes/test-project/src/Service/TestService.php (17): Class pending was referenced relatively but not defined
Time: 76 ms, Memory: 8.00MB
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels