Giter Club home page Giter Club logo

Comments (12)

Wirone avatar Wirone commented on June 12, 2024 2

The problem is in imports (Request class and request function), not in variable name. I believe this will be fixed with #7704 / #7705 (depending on the chosen implementation), because imports will be sorted by kind. Now all the imports are collected into one list, which makes the matching inaccurate (last one is used). However, in terms of ::class it will always be somehow inaccurate, because we're probably going to treat all these usages related to class imports (because Fixer is rather unable to determine proper context).

from php-cs-fixer.

kubawerlos avatar kubawerlos commented on June 12, 2024 1

@soyuka #7749 should fix the 1st change in your example.

from php-cs-fixer.

Wirone avatar Wirone commented on June 12, 2024 1

@soyuka as @kubawerlos said, 1st is already fixed.

As for the 2nd: clear bug, fixer should not prefer relative FQNs over short names. As far as I see, OperationMetadataFactoryInterface is from the same namespace as OperationMetadataFactory so it's not in imports and is treated like something that should be compared with the existing imports. Since there's also use ApiPlatform\Metadata\Operation;, which is a class with FQCN which is a substring of OperationMetadataFactoryInterface's FQCN, it was wrongly replaced with relative reference. Fix in #7752.

I'll take a look at 3rd one too 🙂.

from php-cs-fixer.

soyuka avatar soyuka commented on June 12, 2024 1

No way my bad on the third one I thought that php-cs-fixer changed my Type to TYPE I must have then misread. Thanks! I've tested the patch at #7752 and it works.

from php-cs-fixer.

dkrnl avatar dkrnl commented on June 12, 2024

similar bug with namespace -- replaced lower case to upper case

 controllers/AbstractController.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/controllers/AbstractController.php b/controllers/AbstractController.php
index d589486e..7b238d0e 100644
--- a/controllers/AbstractController.php
+++ b/controllers/AbstractController.php
@@ -9,7 +9,7 @@ use Yii;
  *
  */
-abstract class AbstractController extends \yii\web\Controller
+abstract class AbstractController extends Yii\web\Controller
 {
     /**
      * {@inheritdoc}

from php-cs-fixer.

Wirone avatar Wirone commented on June 12, 2024

@dkrnl your case is rather related to #7721, as FQCN was shortened using relative name based on use Yii;.

from php-cs-fixer.

limenet avatar limenet commented on June 12, 2024

A similar issue (though I'm not sure if the root cause is the same) occurs in this case. Note how the property name now starts with a capital letter (like the class name that's being imported).

Foo.php (fully_qualified_strict_types)
---
use Bar\LanguageService;

    public function __construct(
        private readonly LanguageService $languageService,
    ) {
    }

-        $locale = $this->languageService::get(
+        $locale = $this->LanguageService::get(

Apologies for the redacted diff/excerpt.

from php-cs-fixer.

soyuka avatar soyuka commented on June 12, 2024

HI @Wirone do you want me to test these patches? Note that this is happening in more then one case I took the simplest one, see https://github.com/api-platform/core/actions/runs/7534511533/job/20509019181.

from php-cs-fixer.

Wirone avatar Wirone commented on June 12, 2024

@soyuka if you're so kind and verify if these PRs fix the problem then would be great 🙂.

from php-cs-fixer.

Wirone avatar Wirone commented on June 12, 2024

Quick fix was provided, proper support for import kinds will land later.

from php-cs-fixer.

soyuka avatar soyuka commented on June 12, 2024

Indeed it fixes some of my issues, I ran #7705 and #7704 but I still have issues with uppercases.

20240116_11h15m57s_grim

Should I open new issues for these?

from php-cs-fixer.

Wirone avatar Wirone commented on June 12, 2024

@soyuka the 3rd one looks like an actual fix 😅. In DoctrineExtractorTest you have use Symfony\Component\PropertyInfo\Type; and there are many Type::BUILTIN_TYPE_* usages, but that one TYPE::BUILTIN_TYPE_INT has wrong casing. Was it there on purpose and should remain like this? Because otherwise IMHO it's good that the casing was fixed.

from php-cs-fixer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.