Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I used php_strip_whitespace to compress my PHP code, this library didn't work as expected. #72

Closed
dreamncn opened this issue Jul 26, 2023 · 2 comments

Comments

@dreamncn
Copy link

Serializable Closure Version

1.3.1

PHP Version

8.2.0

Description

When I used php_strip_whitespace to compress my PHP code, this library didn't work as expected. Is a bug?

Steps To Reproduce

  1. I defined a function go to use this Library.
function go(Closure $function, int $timeout = 300)
{
    if (App::$cli) return null;
    return MyCustomClass::start($function, $timeout);
}
  1. In this method start, I used
serialize(new SerializableClosure($function));

and I saved it to a cache file.

  1. When I used the function go:

     public static function start($bool): void
        {
            if ($bool) {
               go(function () {
                       //some functions...
                    }, 0);
            } else {
                Log::record("Error");
            }
        }
  2. If I used php_strip_whitespace to compress my code, it means my code will display like this:

     public static function start($bool): void{if($bool){go(function(){}, 0);} else {Log::record("Error");}}

    It will cache the code:

    if($bool){go(function(){}, 0);} else {Log::record("Error");

    But if I don't compress my code, it will cache the code:

    function(){}

    When only uncompressed, it meet expectations. Is this a bug?

@driesvints
Copy link
Member

Heya, thanks for reporting.

We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up.

laravel new bug-report --github="--public"

Please do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue.

Thanks!

@dreamncn
Copy link
Author

Embarrassingly, when I tried to create a demo, I found that it worked normally. Obviously, part of my code affected it.
I will temporarily close the issue, and then reopen the issue after I find out the problem.

@dreamncn dreamncn closed this as not planned Won't fix, can't repro, duplicate, stale Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants