Hello! This is just a question, hope you don't get mad I'm posting this as an issue.
Is it possible to disable a check with inline comments, like ESLint does? Example: https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments
ESLint:
/* eslint-disable */
alert('foo');
/* eslint-enable */
Intelephense?
/* intelephense-disable */
echo "<p>Hello $world</p>";
/* intelephense-enable */
If not, could it be a feature request? Thanks in advance. =]
No, and I don't know if it's even considered in near-ish future.
There are some tricks with phpdoc to suppress some of them. If you provide error, we can try to work something out.
@KapitanOczywisty Thanks for replying it! At Laravel, DB::connection()->getPdo() is showing like an error. You can see it here, I tried to send a PR to the framework (laravel/framework#31736) but @taylorotwell closed it suggesting to add an annotation to the DB facade but I may be not understanding what he's meaning, since DB facade it's already relating the connection static method to the ConnectionInterface. I can also try to talk with the laravel-ide-helper team to see what they say about it.
For now I could solve it on my app doing something similar to this:
<?php
namespace App\Providers;
use DB;
use Exception;
use Illuminate\Support\ServiceProvider;
use PDOException;
class AppServiceProvider extends ServiceProvider
{
/**
* Return current database connection.
*
* @return \Illuminate\Database\Connection
*/
private function getConnection() {
return DB::connection();
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if ( ! $this->app->runningInConsole()) {
try {
$this->getConnection()->getPdo();
} catch (Exception $e) {
abort($e instanceof PDOException ? 503 : 500);
}
}
}
}
Since I've specified my own method setting that it returns \Illuminate\Database\Connection, I could not worry about the Intelephense error but thought it'd be good to help the community solve it too.
@giovannipds you could also add some metadata to your workspace to overcome this.
namespace PHPSTORM_META {
override(\DB::connection(0), map(['' => \Illuminate\Database\Connection::class]));
}
Closing this and tracking disabling of diagnostics in #568 .
@bmewburn just to be sure, where am I suppose to insert this?
@giovannipds just in a file in your workspace that does not get executed as part of your application.
@bmewburn thanks!