Laravel php工匠修补匠抛出ErrorException

If I run php artisan tinker on my console the output is:

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

And if I run php artisan tinker --verbose the output is:

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

Extra:
My Laravel version is 5.1.24.
I've just installed Zizaco/entrust
Other than that, the app is almost blank


EDIT:

Here is the function guilty for the error inside 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;
}

If someone has the same issue, here is how I solved it:

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

Thanks in advance!

dragon321723
dragon321723 Yehp,他们跑完了没有回应,问题仍然存在:(
接近 5 年之前 回复
dsyak22488
dsyak22488 你有没有尝试过composerdump-autoload或phpartisanoptimize?
接近 5 年之前 回复

2个回答



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

展开原文

原文

Check the values on C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php it seems like there is something wrong with those values because when the script calls in_array function doesn't get the correct values

dongzhanjuan5141
dongzhanjuan5141 这是v0.6.0中的回归,修复于v0.6.1。 只是作曲家更新:)
接近 5 年之前 回复
douyi3760
douyi3760 强制in_array的参数为数组及其工作。
接近 5 年之前 回复
duanlan7903
duanlan7903 在数组unshift之后检查strtr的返回值或检查dirs,记住$ dirs应该是一个数组
接近 5 年之前 回复
dongzhonggua4229
dongzhonggua4229 我现在看到错误发生在哪里,但我不知道为什么。 我在问题中添加了这个功能
接近 5 年之前 回复



这也发生在我身上。 </ p>

执行 composer update </ code>并将软件包更新到psy / psysh(v0.6.1)修复了问题。</ p>
</ div>

展开原文

原文

This happened to me as well.

Perform composer update and update the package to psy/psysh (v0.6.1) fixed the problem.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问