PHP code example of sirbrillig / phpcs-import-detection

1. Go to this page and download the library: Download sirbrillig/phpcs-import-detection library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sirbrillig / phpcs-import-detection example snippets


namespace Vehicles;
use Registry;
use function Vehicles\startCar;
use Chocolate; // this will be a warning because `Chocolate` is never used
class Car {
  public function drive() {
    startCar(); // this is fine because `startCar` is imported
    Registry\registerCar($this); // this is fine because `Registry` is imported
    \DrivingTracker\registerDrive($this); // this is fine because it's fully-qualified
    goFaster(); // this will be a warning because `goFaster` was not imported
  }
}



$instance = new MyGlobalClass(); // phpcs:ignore ImportDetection.Imports.RequireImports.Symbol -- this class is global
$instance->doSomething();


// phpcs:disable ImportDetection.Imports.RequireImports.Symbol

$instance = new MyGlobalClass();
$instance->doSomething();