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

Probable memory leak #3702

Closed
genesiscz opened this issue Aug 3, 2020 · 7 comments
Closed

Probable memory leak #3702

genesiscz opened this issue Aug 3, 2020 · 7 comments

Comments

@genesiscz
Copy link

Posted previously here: rectorphp/rector#3836

Any insight about it? I can provide as much info as possible if necessary to help nail down this bug.

@ondrejmirtes
Copy link
Member

How big is the _ide_loader.php file? I'd suggest you don't provide it to PHPStan/Rector. There's Larastan (https://github.com/nunomaduro/larastan) which should also work for Laravel-based projects.

@genesiscz
Copy link
Author

genesiscz commented Aug 3, 2020

How big is the _ide_loader.php file? I'd suggest you don't provide it to PHPStan/Rector. There's Larastan (https://github.com/nunomaduro/larastan) which should also work for Laravel-based projects.

22 000 originally, but reproduced & issue created with just 10 lines example. The problem is that the vendor class Model includes @mixin Eloquent in PHPDoc which is being examined by PHPstan and crashing/leaking for that reason. I can't just not included it because it screams to me that Eloquent doesn't exist if I don't load that file.

@ondrejmirtes
Copy link
Member

Could you explain this more clearly? First you're talking about a memory leak and then only about a trivial "class not found" message.

I'd need a minimal reproducing repo with this problem in order to understand it.

/cc @canvural does this ring a bell? Why isn't class Eloquent defined? Could it be defined as a class alias using these steps? https://phpstan.org/user-guide/discovering-symbols#class-aliases

@canvural
Copy link
Contributor

canvural commented Aug 3, 2020

Eloquent is just an alias to Illuminate\Database\Eloquent\Model, so yes I think it should be defined as class alias in PHPStan bootstrap file.

(Larastan actually boots the Laravel app up to some point in PHPStan bootstrap, so aliases are registered. Therefore I didn't see any error like this before.)

@ondrejmirtes
Copy link
Member

Yeah, this is clearly running PHPStan on an installation without Larastan.

@genesiscz
Copy link
Author

You both rock! I wasn't sure if Rector is being able to run with it if used like this.
The things that are currently not clear:

  • Configured larastan with the default example
  • Ran vendor/bin/phpstan analyse app
  • I get hundreds of these
------ -----------------------------------------------------------------------------------
  Line   Services/PaymentService.php                                                       
 ------ -----------------------------------------------------------------------------------
  174    Access to an undefined property Illuminate\Database\Eloquent\Model::$order_id.
  175    Access to an undefined property Illuminate\Database\Eloquent\Model::$reference.
  176    Access to an undefined property Illuminate\Database\Eloquent\Model::$token.
  177    Access to an undefined property Illuminate\Database\Eloquent\Model::$price.
  178    Access to an undefined property Illuminate\Database\Eloquent\Model::$price_tax.
  179    Access to an undefined property Illuminate\Database\Eloquent\Model::$status.
  180    Access to an undefined property Illuminate\Database\Eloquent\Model::$description.
  181    Access to an undefined property Illuminate\Database\Eloquent\Model::$paid_at.
  182    Access to an undefined property Illuminate\Database\Eloquent\Model::$origin.

on this code.

        $payment = Payment::where("reference", "=", $reference)->first();
        if (!$payment) {
            $payment = new Payment();
        }
        $payment->order_id = $order->id ?? null;
        $payment->reference = $reference;
        $payment->token = $reference;
        $payment->price = $price;
        $payment->price_tax = $price;
        $payment->status = $status;
        $payment->description = $description;
        $payment->paid_at = $paid_at;
        $payment->origin = $origin;
        $payment->save();

I understand how this happens, obviously, because that's exactly why we do have ide helper to save us from this hell, but I suppose this is exactly the case larastan should solve, isn't it? I don't get what happened because before I switched from my Mac to Windows PC, these errors weren't present.

I guess @canvural will for sure be more competent to reply here.

I am truly sorry if this is the wrongest place to discuss such things, we can move elsewhere, if you want to provide with some help, just let me know!

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants