dongnan4571 2015-11-12 03:17
浏览 51
已采纳

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!

  • 写回答

2条回答 默认 最新

  • dqcuq4138 2015-11-12 03:58
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮