| 
#!/usr/bin/env php<?php
 /**
 * Project scanner for detect unused composer dependencies
 * Usage:
 *  - composer global require insolita/unused-scanner
 *  - prepare config like in example @see scanner_config.example.php
 *  - run 'composer dumpautoload' in project root
 *  - unused_scanner /path/to/scanner_config.php
 **/
 if (file_exists(__DIR__ . '/vendor/autoload.php')) {
 require __DIR__ . '/vendor/autoload.php';
 } else {
 require __DIR__ . '/../../autoload.php';
 }
 
 use insolita\Scanner\Lib\Runner;
 
 $defaultConfigPath = getcwd() . DIRECTORY_SEPARATOR . 'scanner_config.php';
 
 $configPath = $argv[1] ?? null;
 
 if (in_array($configPath, ['--silent', '-s'])) {
 $configPath = null;
 $silentMode = true;
 }
 
 if (!$configPath && file_exists($defaultConfigPath)) {
 $configPath = $defaultConfigPath;
 echo 'Default detected config will be used at ' . $defaultConfigPath . PHP_EOL;
 }
 if (!$configPath) {
 echo 'Missing required argument - path to config' . PHP_EOL;
 exit(Runner::ARGUMENT_ERROR_CODE);
 }
 if (!isset($silentMode)) {
 $silentMode = isset($argv[2]) && in_array($argv[2], ['--silent', '-s']);
 }
 
 $exitCode = (new Runner((string)$configPath, $silentMode))->run();
 
 exit($exitCode);
 
 
 |