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
Problem with custom attribute #5533
Comments
As a workaround, perhaps use annotations for now? |
Unfortunately this is not possible for the |
The workaround would be to remove the attribute and change the type hint to |
I checked this, but unfortunately: #[CurrentUser] ?UserInterface $user = null nor #[CurrentUser] ?UserInterface $user nor #[CurrentUser] UserInterface $user = null are working @derrabus 🤔 |
No, but this works:
|
You mean without the attribute? 🤔 |
@OskarStark , thanks for raising the concern. also, pls share the configuration ruleset that you are using, to help reproducing the issue |
You are welcome, thanks for your hard work on this tool 👍
Unfortunately I am not so deep ion this topic and have a lot of work on my desk 😢
Is there a way I can dump the used config? |
@OskarStark Usually, your project has a |
I've managed to reproduce this bug with the following code: <?php
function test(#[Attribute] ?User $user) {} The problem is in TernaryToElvisOperatorFixer. Nullable type hint is treated as a part of a ternary operator.
Then inside Unfortunately, I don't know how to fix this, but I hope this will help you. |
@OskarStark, @derrabus, @jrmajor I've made a fix ☝🏼 - do not hesitate and drop a review there, please. |
Please reopen this issue and see my comment in the referenced PR. The PR which closed this issue is not solving the issue. Thanks |
@OskarStark can you check if your problem is present in |
@OskarStark can you share the config or output when running with |
Sure, will come back tomorrow 👍 |
This PR was squashed before being merged into the 2.18 branch. Discussion ---------- Tokens - fix for checking block edges Found this when investigating #5533. [This loop](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.18.4/src/Fixer/Operator/TernaryToElvisOperatorFixer.php#L210) was problematic, `)` was passed to `findBlockEnd` and it was returning index of `(` and thus loop was infinitive. See separate commits for better understanding if needed. Commits ------- eb4a86b Tokens - fix for checking block edges
Running produces:
This is my config: <?php
declare(strict_types=1);
use Datana\PhpCsFixer;
$config = PhpCsFixer\Config\Factory::fromRuleSet(new PhpCsFixer\Config\RuleSet\Php74(''), [
'php_unit_internal_class' => false,
]);
$config->getFinder()
->in('build')
->in('migrations')
->in('src')
->in('tests')
->in('tools')
;
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/.php_cs.cache');
return $config; this is the ruleset: Anything else I can do? |
can you share minimum code sample that reproduces the issue? or it's the same as in first msg in this thread? |
It is the same I mentioned |
Failing test (and soon hopefully a fix): #5665 |
Thanks |
Bug report
Code:
leads to:
Changing to:
ends up in a non ending process and my macbook starts to explode 🤔
Changing to:
Cs-fixer can fix and lint it, but my code is not working anymore 😄
cc @localheinz @derrabus
The text was updated successfully, but these errors were encountered: