Laravel php artisan 修补程序抛出 ErrorException

Laravel php artisan tinker throwing ErrorException

如果我 运行 php artisan tinker 在我的控制台上输出是:

[ErrorException]
in_array() expects parameter 2 to be array, string given

如果我 运行 php artisan tinker --verbose 输出是:

Exception trace:
 () at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:161
 Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
 in_array() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:161
 Psy\ConfigPaths::getDirNames() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:35
 Psy\ConfigPaths::getConfigDirs() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:89
 Psy\ConfigPaths::getConfigFiles() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\Configuration.php:146
 Psy\Configuration->getConfigFile() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\Configuration.php:117
 Psy\Configuration->init() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\Configuration.php:98
 Psy\Configuration->__construct() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Foundation\Console\TinkerCommand.php:44
 Illuminate\Foundation\Console\TinkerCommand->fire() at n/a:n/a
 call_user_func_array() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Container\Container.php:503
 Illuminate\Container\Container->call() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Console\Command.php:150
 Illuminate\Console\Command->execute() at C:\wamp\www\store\vendor\symfony\console\Command\Command.php:256
 Symfony\Component\Console\Command\Command->run() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Console\Command.php:136
 Illuminate\Console\Command->run() at C:\wamp\www\store\vendor\symfony\console\Application.php:838
 Symfony\Component\Console\Application->doRunCommand() at C:\wamp\www\store\vendor\symfony\console\Application.php:189
 Symfony\Component\Console\Application->doRun() at C:\wamp\www\store\vendor\symfony\console\Application.php:120
 Symfony\Component\Console\Application->run() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:107
 Illuminate\Foundation\Console\Kernel->handle() at C:\wamp\www\store\artisan:36

额外:
我的 Laravel 版本是 5.1.24.
我刚刚安装 Zizaco/entrust
除此之外,应用程序几乎是空白


编辑:

这里是 ConfigPaths.php:

内部错误的函数
private static function getDirNames(array $baseDirs) {
    $dirs = array_map(function ($dir) {
        return strtr($dir, '\', '/') . '/psysh';
    }, $baseDirs);

    // Add ~/.psysh
    if ($home = getenv('HOME')) {
        $dirs[] = strtr($home, '\', '/') . '/.psysh';
    }

    // Add some Windows specific ones :)
    if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
        if ($appData = getenv('APPDATA')) {
            // AppData gets preference
            array_unshift($dirs, strtr($appData, '\', '/') . '/PsySH');
        }

        $dir = strtr(getenv('HOMEDRIVE') . '/' . getenv('HOMEPATH'), '\', '/') . '/.psysh';
        if (!in_array($dirs, $dir)) {
            $dirs[] = $dir;
        }
    }

    return $dirs;
}

如果有人遇到同样的问题,我是这样解决的:

# add (array) before $dir
if (!in_array($dirs, (array)$dir)) {
    $dirs[] = $dir;
}

提前致谢!

检查 C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php 上的值,这些值似乎有问题,因为当脚本调用 in_array 函数没有得到正确的值

这也发生在我身上。

执行 composer update 并将程序包更新到 psy/psysh (v0.6.1) 解决了问题。