Browse Source

更新命名空间

luolongfei 4 years ago
parent
commit
595a2f5728

+ 3 - 3
app/Console/FreeNom.php

@@ -13,9 +13,9 @@ namespace Luolongfei\App\Console;
 use Luolongfei\App\Exceptions\LlfException;
 use GuzzleHttp\Client;
 use GuzzleHttp\Cookie\CookieJar;
-use Luolongfei\Lib\Log;
-use Luolongfei\Lib\Mail;
-use Luolongfei\Lib\TelegramBot;
+use Luolongfei\Libs\Log;
+use Luolongfei\Libs\Mail;
+use Luolongfei\Libs\TelegramBot;
 
 class FreeNom
 {

+ 6 - 6
app/helpers.php

@@ -8,12 +8,12 @@
  */
 
 use Luolongfei\App\Exceptions\LlfException;
-use Luolongfei\Lib\Argv;
-use Luolongfei\Lib\Config;
-use Luolongfei\Lib\Log;
-use Luolongfei\Lib\Env;
-use Luolongfei\Lib\Lang;
-use Luolongfei\Lib\PhpColor;
+use Luolongfei\Libs\Argv;
+use Luolongfei\Libs\Config;
+use Luolongfei\Libs\Log;
+use Luolongfei\Libs\Env;
+use Luolongfei\Libs\Lang;
+use Luolongfei\Libs\PhpColor;
 
 if (!function_exists('config')) {
     /**

+ 3 - 3
composer.json

@@ -21,13 +21,13 @@
   "authors": [
     {
       "name": "luolongfei",
-      "email": "mybsdc@gmail.com",
-      "homepage": "https://github.com/luolongfei/freenom"
+      "email": "luolongf@gmail.com",
+      "homepage": "https://github.com/luolongfei/next-freenom"
     }
   ],
   "autoload": {
     "psr-4": {
-      "Luolongfei\\Lib\\": "libs",
+      "Luolongfei\\Libs\\": "libs",
       "Luolongfei\\App\\": "app"
     },
     "files": [

+ 1 - 1
libs/Argv.php

@@ -7,7 +7,7 @@
  * @time 16:32
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 class Argv
 {

+ 1 - 1
libs/Config.php

@@ -7,7 +7,7 @@
  * @time 16:41
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 class Config
 {

+ 1 - 1
libs/Env.php

@@ -7,7 +7,7 @@
  * @time 17:28
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 use Dotenv\Dotenv;
 

+ 1 - 1
libs/Lang.php

@@ -7,7 +7,7 @@
  * @time 16:30
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 class Lang
 {

+ 1 - 1
libs/Log.php

@@ -7,7 +7,7 @@
  * @time 12:01
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 use Monolog\Logger;
 use Monolog\Handler\StreamHandler;

+ 1 - 1
libs/Mail.php

@@ -7,7 +7,7 @@
  * @time 16:38
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 use Luolongfei\App\Exceptions\LlfException;
 use PHPMailer\PHPMailer\PHPMailer;

+ 1 - 1
libs/PhpColor.php

@@ -9,7 +9,7 @@
  * @time 10:52
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 use Colors\Color;
 

+ 1 - 1
libs/TelegramBot.php

@@ -7,7 +7,7 @@
  * @time 15:23
  */
 
-namespace Luolongfei\Lib;
+namespace Luolongfei\Libs;
 
 use GuzzleHttp\Client;
 

+ 142 - 15
vendor/composer/ClassLoader.php

@@ -37,57 +37,130 @@ namespace Composer\Autoload;
  *
  * @author Fabien Potencier <[email protected]>
  * @author Jordi Boggiano <[email protected]>
- * @see    http://www.php-fig.org/psr/psr-0/
- * @see    http://www.php-fig.org/psr/psr-4/
+ * @see    https://www.php-fig.org/psr/psr-0/
+ * @see    https://www.php-fig.org/psr/psr-4/
  */
 class ClassLoader
 {
+    /** @var ?string */
+    private $vendorDir;
+
     // PSR-4
+    /**
+     * @var array[]
+     * @psalm-var array<string, array<string, int>>
+     */
     private $prefixLengthsPsr4 = array();
+    /**
+     * @var array[]
+     * @psalm-var array<string, array<int, string>>
+     */
     private $prefixDirsPsr4 = array();
+    /**
+     * @var array[]
+     * @psalm-var array<string, string>
+     */
     private $fallbackDirsPsr4 = array();
 
     // PSR-0
+    /**
+     * @var array[]
+     * @psalm-var array<string, array<string, string[]>>
+     */
     private $prefixesPsr0 = array();
+    /**
+     * @var array[]
+     * @psalm-var array<string, string>
+     */
     private $fallbackDirsPsr0 = array();
 
+    /** @var bool */
     private $useIncludePath = false;
+
+    /**
+     * @var string[]
+     * @psalm-var array<string, string>
+     */
     private $classMap = array();
+
+    /** @var bool */
     private $classMapAuthoritative = false;
+
+    /**
+     * @var bool[]
+     * @psalm-var array<string, bool>
+     */
     private $missingClasses = array();
+
+    /** @var ?string */
     private $apcuPrefix;
 
+    /**
+     * @var self[]
+     */
+    private static $registeredLoaders = array();
+
+    /**
+     * @param ?string $vendorDir
+     */
+    public function __construct($vendorDir = null)
+    {
+        $this->vendorDir = $vendorDir;
+    }
+
+    /**
+     * @return string[]
+     */
     public function getPrefixes()
     {
         if (!empty($this->prefixesPsr0)) {
-            return call_user_func_array('array_merge', $this->prefixesPsr0);
+            return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
         }
 
         return array();
     }
 
+    /**
+     * @return array[]
+     * @psalm-return array<string, array<int, string>>
+     */
     public function getPrefixesPsr4()
     {
         return $this->prefixDirsPsr4;
     }
 
+    /**
+     * @return array[]
+     * @psalm-return array<string, string>
+     */
     public function getFallbackDirs()
     {
         return $this->fallbackDirsPsr0;
     }
 
+    /**
+     * @return array[]
+     * @psalm-return array<string, string>
+     */
     public function getFallbackDirsPsr4()
     {
         return $this->fallbackDirsPsr4;
     }
 
+    /**
+     * @return string[] Array of classname => path
+     * @psalm-var array<string, string>
+     */
     public function getClassMap()
     {
         return $this->classMap;
     }
 
     /**
-     * @param array $classMap Class to filename map
+     * @param string[] $classMap Class to filename map
+     * @psalm-param array<string, string> $classMap
+     *
+     * @return void
      */
     public function addClassMap(array $classMap)
     {
@@ -102,9 +175,11 @@ class ClassLoader
      * Registers a set of PSR-0 directories for a given prefix, either
      * appending or prepending to the ones previously set for this prefix.
      *
-     * @param string       $prefix  The prefix
-     * @param array|string $paths   The PSR-0 root directories
-     * @param bool         $prepend Whether to prepend the directories
+     * @param string          $prefix  The prefix
+     * @param string[]|string $paths   The PSR-0 root directories
+     * @param bool            $prepend Whether to prepend the directories
+     *
+     * @return void
      */
     public function add($prefix, $paths, $prepend = false)
     {
@@ -147,11 +222,13 @@ class ClassLoader
      * Registers a set of PSR-4 directories for a given namespace, either
      * appending or prepending to the ones previously set for this namespace.
      *
-     * @param string       $prefix  The prefix/namespace, with trailing '\\'
-     * @param array|string $paths   The PSR-4 base directories
-     * @param bool         $prepend Whether to prepend the directories
+     * @param string          $prefix  The prefix/namespace, with trailing '\\'
+     * @param string[]|string $paths   The PSR-4 base directories
+     * @param bool            $prepend Whether to prepend the directories
      *
      * @throws \InvalidArgumentException
+     *
+     * @return void
      */
     public function addPsr4($prefix, $paths, $prepend = false)
     {
@@ -195,8 +272,10 @@ class ClassLoader
      * Registers a set of PSR-0 directories for a given prefix,
      * replacing any others previously set for this prefix.
      *
-     * @param string       $prefix The prefix
-     * @param array|string $paths  The PSR-0 base directories
+     * @param string          $prefix The prefix
+     * @param string[]|string $paths  The PSR-0 base directories
+     *
+     * @return void
      */
     public function set($prefix, $paths)
     {
@@ -211,10 +290,12 @@ class ClassLoader
      * Registers a set of PSR-4 directories for a given namespace,
      * replacing any others previously set for this namespace.
      *
-     * @param string       $prefix The prefix/namespace, with trailing '\\'
-     * @param array|string $paths  The PSR-4 base directories
+     * @param string          $prefix The prefix/namespace, with trailing '\\'
+     * @param string[]|string $paths  The PSR-4 base directories
      *
      * @throws \InvalidArgumentException
+     *
+     * @return void
      */
     public function setPsr4($prefix, $paths)
     {
@@ -234,6 +315,8 @@ class ClassLoader
      * Turns on searching the include path for class files.
      *
      * @param bool $useIncludePath
+     *
+     * @return void
      */
     public function setUseIncludePath($useIncludePath)
     {
@@ -256,6 +339,8 @@ class ClassLoader
      * that have not been registered with the class map.
      *
      * @param bool $classMapAuthoritative
+     *
+     * @return void
      */
     public function setClassMapAuthoritative($classMapAuthoritative)
     {
@@ -276,6 +361,8 @@ class ClassLoader
      * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
      *
      * @param string|null $apcuPrefix
+     *
+     * @return void
      */
     public function setApcuPrefix($apcuPrefix)
     {
@@ -296,25 +383,44 @@ class ClassLoader
      * Registers this instance as an autoloader.
      *
      * @param bool $prepend Whether to prepend the autoloader or not
+     *
+     * @return void
      */
     public function register($prepend = false)
     {
         spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+
+        if (null === $this->vendorDir) {
+            return;
+        }
+
+        if ($prepend) {
+            self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
+        } else {
+            unset(self::$registeredLoaders[$this->vendorDir]);
+            self::$registeredLoaders[$this->vendorDir] = $this;
+        }
     }
 
     /**
      * Unregisters this instance as an autoloader.
+     *
+     * @return void
      */
     public function unregister()
     {
         spl_autoload_unregister(array($this, 'loadClass'));
+
+        if (null !== $this->vendorDir) {
+            unset(self::$registeredLoaders[$this->vendorDir]);
+        }
     }
 
     /**
      * Loads the given class or interface.
      *
      * @param  string    $class The name of the class
-     * @return bool|null True if loaded, null otherwise
+     * @return true|null True if loaded, null otherwise
      */
     public function loadClass($class)
     {
@@ -323,6 +429,8 @@ class ClassLoader
 
             return true;
         }
+
+        return null;
     }
 
     /**
@@ -367,6 +475,21 @@ class ClassLoader
         return $file;
     }
 
+    /**
+     * Returns the currently registered loaders indexed by their corresponding vendor directories.
+     *
+     * @return self[]
+     */
+    public static function getRegisteredLoaders()
+    {
+        return self::$registeredLoaders;
+    }
+
+    /**
+     * @param  string       $class
+     * @param  string       $ext
+     * @return string|false
+     */
     private function findFileWithExtension($class, $ext)
     {
         // PSR-4 lookup
@@ -438,6 +561,10 @@ class ClassLoader
  * Scope isolated include.
  *
  * Prevents access to $this/self from included files.
+ *
+ * @param  string $file
+ * @return void
+ * @private
  */
 function includeFile($file)
 {

+ 1 - 0
vendor/composer/autoload_classmap.php

@@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
 $baseDir = dirname($vendorDir);
 
 return array(
+    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
 );

+ 1 - 1
vendor/composer/autoload_psr4.php

@@ -13,7 +13,7 @@ return array(
     'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src/PhpOption'),
     'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'),
     'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
-    'Luolongfei\\Lib\\' => array($baseDir . '/libs'),
+    'Luolongfei\\Libs\\' => array($baseDir . '/libs'),
     'Luolongfei\\App\\' => array($baseDir . '/app'),
     'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
     'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),

+ 7 - 2
vendor/composer/autoload_real.php

@@ -13,19 +13,24 @@ class ComposerAutoloaderInit99b73a665e0d2066a2cb8dd066883cba
         }
     }
 
+    /**
+     * @return \Composer\Autoload\ClassLoader
+     */
     public static function getLoader()
     {
         if (null !== self::$loader) {
             return self::$loader;
         }
 
+        require __DIR__ . '/platform_check.php';
+
         spl_autoload_register(array('ComposerAutoloaderInit99b73a665e0d2066a2cb8dd066883cba', 'loadClassLoader'), true, true);
-        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
+        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
         spl_autoload_unregister(array('ComposerAutoloaderInit99b73a665e0d2066a2cb8dd066883cba', 'loadClassLoader'));
 
         $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
         if ($useStaticLoader) {
-            require_once __DIR__ . '/autoload_static.php';
+            require __DIR__ . '/autoload_static.php';
 
             call_user_func(\Composer\Autoload\ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba::getInitializer($loader));
         } else {

+ 7 - 2
vendor/composer/autoload_static.php

@@ -34,7 +34,7 @@ class ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba
         ),
         'L' => 
         array (
-            'Luolongfei\\Lib\\' => 15,
+            'Luolongfei\\Libs\\' => 16,
             'Luolongfei\\App\\' => 15,
         ),
         'G' => 
@@ -83,7 +83,7 @@ class ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba
         array (
             0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
         ),
-        'Luolongfei\\Lib\\' => 
+        'Luolongfei\\Libs\\' => 
         array (
             0 => __DIR__ . '/../..' . '/libs',
         ),
@@ -127,12 +127,17 @@ class ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba
         ),
     );
 
+    public static $classMap = array (
+        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
+    );
+
     public static function getInitializer(ClassLoader $loader)
     {
         return \Closure::bind(function () use ($loader) {
             $loader->prefixLengthsPsr4 = ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba::$prefixLengthsPsr4;
             $loader->prefixDirsPsr4 = ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba::$prefixDirsPsr4;
             $loader->prefixesPsr0 = ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba::$prefixesPsr0;
+            $loader->classMap = ComposerStaticInit99b73a665e0d2066a2cb8dd066883cba::$classMap;
 
         }, null, ClassLoader::class);
     }

+ 26 - 0
vendor/composer/platform_check.php

@@ -0,0 +1,26 @@
+<?php
+
+// platform_check.php @generated by Composer
+
+$issues = array();
+
+if (!(PHP_VERSION_ID >= 70100)) {
+    $issues[] = 'Your Composer dependencies require a PHP version ">= 7.1.0". You are running ' . PHP_VERSION . '.';
+}
+
+if ($issues) {
+    if (!headers_sent()) {
+        header('HTTP/1.1 500 Internal Server Error');
+    }
+    if (!ini_get('display_errors')) {
+        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
+            fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
+        } elseif (!headers_sent()) {
+            echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
+        }
+    }
+    trigger_error(
+        'Composer detected issues in your platform: ' . implode(' ', $issues),
+        E_USER_ERROR
+    );
+}