laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.
https://laravel.com/docs/pint
MIT License
2.79k stars 144 forks source link

Pint Removes Partial Imports #198

Closed BrandonSurowiec closed 1 year ago

BrandonSurowiec commented 1 year ago

Pint Version

1.10.5

PHP Version

8.1.18

Description

I have a partial namespace that I've imported in my local project, Slate\Fields. Pint thinks it is not in use and removes it, but I have many partial references like Fields\Html, which is perfectly valid PHP. I import partial namespaces to prevents me from having to import every FQCN like Slate\Fields\HTML. (I know, use an IDE to import them all...) Pint does not agree that it is in use. 😅

image

Steps To Reproduce

<?php

namespace App;

use Illuminate\Support;

class Example
{
    function example()
    {
        return Support\Str::studly('pint');
    }
}

Run pint.

driesvints commented 1 year ago

Heya. I can't reproduce this with latest pint. The example file stays the same for me.

BrandonSurowiec commented 1 year ago

@driesvints You're right.. I'm a noob. I need to remember that on the root namespace, any partial non-imported namespace inherits the root namespace so it expands just fine.. (Note to self, don't file bug reports in the middle of the night, go to sleep instead. 😂)

driesvints commented 1 year ago

@BrandonSurowiec don't worry about it 🙂