FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Optimized code for reading contents of php file. by limingxinleo · Pull Request #6804 · hyperf/hyperf · GitHub

/ hyperf Public

Optimized code for reading contents of php file. - #6804

Merged
limingxinleo merged 4 commits into
hyperf:3.2from
limingxinleo:v3.1-di
Mar 7, 2026
Merged

Optimized code for reading contents of php file.#6804
limingxinleo merged 4 commits into
hyperf:3.2from
limingxinleo:v3.1-di

Conversation

Copy link
Copy Markdown
Member

原来的方法会注册一个 error handler,没有必要,默认都有 error_handler 会抛出异常。

就算没有设置 error_handler 的,也会在 parseClassByStmts 的时候直接报错。

    public function getContents(): string
    {
        set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
        try {
            $content = file_get_contents($this->getPathname());
        } finally {
            restore_error_handler();
        }
        if (false === $content) {
            throw new \RuntimeException($error);
        }

        return $content;
    }

limingxinleo added this to the v3.2 milestone May 27, 2024

BadJacky commented Jun 5, 2024

Copy link
Copy Markdown

huangdijia changed the base branch from master to 3.2 February 5, 2025 15:18
limingxinleo merged commit 5c18ea6 into hyperf:3.2 Mar 7, 2026
65 checks passed
limingxinleo deleted the v3.1-di branch March 7, 2026 15:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL