PHP Classes

File: bin/phpdoctor.php

Recommend this page to a friend!
  Classes of Lars Moelleken  >  PHP Doctor  >  bin/phpdoctor.php  >  Download  
File: bin/phpdoctor.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Doctor
Scan PHP to find missing or wrong PHPDoc comments
Author: By
Last change:
Date: 1 year ago
Size: 2,492 bytes
 

Contents

Class file image Download
<?php

/** @noinspection InvertedIfElseConstructsInspection */
/** @noinspection TransitiveDependenciesUsageInspection */

declare(strict_types=1);

namespace
voku\PHPDoctor;

use
Symfony\Component\Console\Application;

(static function () {
   
error_reporting(E_ALL);
   
ini_set('display_errors', 'stderr');
   
gc_disable(); // performance boost

   
\define('__PHPDOCTOR_RUNNING__', true);

   
/** @noinspection UsingInclusionOnceReturnValueInspection */
    /** @noinspection UsingInclusionReturnValueInspection */
   
$devOrPharLoader = require_once __DIR__ . '/../vendor/autoload.php';
   
$devOrPharLoader->unregister();

   
$autoloaderInWorkingDirectory = getcwd() . '/vendor/autoload.php';
   
$autoloaderProjectPaths = [];
    if (
is_file($autoloaderInWorkingDirectory)) {
       
$autoloaderProjectPaths[] = \dirname($autoloaderInWorkingDirectory, 2);

       
/** @noinspection PhpIncludeInspection */
       
require_once $autoloaderInWorkingDirectory;
    }

   
$autoloadProjectAutoloaderFile = static function (string $file) use (&$autoloaderProjectPaths): void {
       
$path = \dirname(__DIR__) . $file;
        if (!\
extension_loaded('phar')) {
            if (
is_file($path)) {
               
$autoloaderProjectPaths[] = \dirname($path, 2);

               
/** @noinspection PhpIncludeInspection */
               
require_once $path;
            }
        } else {
           
$pharPath = \Phar::running(false);
            if (
$pharPath === '') {
                if (\
is_file($path)) {
                   
$autoloaderProjectPaths[] = \dirname($path, 2);

                   
/** @noinspection PhpIncludeInspection */
                   
require_once $path;
                }
            } else {
               
$path = \dirname($pharPath) . $file;
                if (\
is_file($path)) {
                   
$autoloaderProjectPaths[] = \dirname($path, 2);

                   
/** @noinspection PhpIncludeInspection */
                   
require_once $path;
                }
            }
        }
    };

   
$autoloadProjectAutoloaderFile('/../../autoload.php');

   
$devOrPharLoader->register(true);

   
$reversedAutoloaderProjectPaths = array_reverse($autoloaderProjectPaths);

   
$app = new Application('PHPDoctor');

   
/** @noinspection UnusedFunctionResultInspection */
   
$app->add(new \voku\PHPDoctor\CliCommand\PhpDoctorCommand($reversedAutoloaderProjectPaths));

   
/** @noinspection PhpUnhandledExceptionInspection */
   
$app->run();
})();

For more information send a message to info at phpclasses dot org.