Sign inSign up

wyg27/laravel42-php8

By wyg27

•Updated over 4 years ago

Image
1

897

wyg27/laravel42-php8 repository overview

PHP 8.0.0 的两处变化导致 Laravel 4.2 无法正常运行,它们是:

⁠变化1

The mbstring.func_overload directive has been removed. The related MB_OVERLOAD_MAIL, MB_OVERLOAD_STRING, and MB_OVERLOAD_REGEX constants have also been removed. Finally, the "func_overload" and "func_overload_list" entries in mb_get_info() have been removed.

⁠变化2

For call_user_func_array(), this behavior constitutes a minor backwards-compatibility break: Previously, array keys were completely ignored by this function. Now, string keys will be interpreted as parameter names.

必须修改如下两个部分:

⁠修改1

文件:vendor/laravel/framework/src/Illuminate/Routing/Route.php

找到:

public function run()
{
    $parameters = array_filter($this->parameters(), function($p) { return isset($p); });

    return call_user_func_array($this->action['uses'], $parameters);
}

改为:

public function run()
{
    $parameters = array_filter($this->parameters(), function($p) { return isset($p); });

    return call_user_func_array($this->action['uses'], array_values($parameters) ); // 这里增加了 array_values()
}

⁠修改2

在 vendor 目录中搜索 MB_OVERLOAD_STRING 常量,将所有的用例替换为数字 “2”。

目前为止,只发现了这2处兼容性问题。

⚠️ 这个修改似乎不是必须的

⁠修改3

编辑 vendor/laravel/framework/src/Illuminate/Exception/Handler.php,行 328,找到

protected function formatException(\Exception $e)

改为

protected function formatException(\Throwable $e) // Throwable 是 Exception 的 interface

⁠修改4

编辑 vendor/laravel/framework/src/Illuminate/Routing/Controller.php,找到

public function callAction($method, $parameters)
        {
                $this->setupLayout();

                $response = call_user_func_array(array($this, $method), $parameters);

改为

public function callAction($method, $parameters)
        {
                $this->setupLayout();

                $response = call_user_func_array(array($this, $method), array_values($parameters)); // 这里增加 array_values()

Tag summary

Content type

Image

Digest

Size

155.9 MB

Last updated

almost 6 years ago

docker pull wyg27/laravel42-php8