-
Notifications
You must be signed in to change notification settings - Fork 144
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
Add rule: yoda_style
to Laravel
#210
Conversation
Can you give some examples? |
Or even better: add some tests :) |
- if (null === $this->input->getOption('format')) {
+ if ($this->input->getOption('format') === null) {
$this->progress->subscribe();
} |
I'm not sure if it's a "bug" as much as my lack of understanding. So I am asking it here... After upgrading today, the following conditional was changed. -if (count($failed_tasks) === (count($tasks) - intval(isset($tasks['composer/install'])))) {
+if ((count($tasks) - intval(isset($tasks['composer/install']))) === count($failed_tasks)) { I didn't think the existing conditional was a "yoda style" conditional. At least not a traditional one. It seems the I'm sure this change works at inverting "yoda style" conditionals, but my concern would be it swaps all conditionals. Ideally, it would leave non-yoda conditionals alone. |
Some more examples where I don't think it should be changed: - if (! $referrer || $request->path() == $pattern) {
+ if (! $referrer || $pattern == $request->path()) { - return $this->guard === $guard && (int) $this->user_id === $userId;
+ return $this->guard === $guard && $userId === (int) $this->user_id; - Http::assertSent(fn (Request $request) => $request->url() === "https://testapi.multisafepay.com/v1/json/orders/{$payment->hash}/");
+ Http::assertSent(fn (Request $request) => "https://testapi.multisafepay.com/v1/json/orders/{$payment->hash}/" === $request->url()); - return array_values($array) !== $array;
+ return $array !== array_values($array); |
I agree with @jasonmccreary -
Can we get this set to false? |
Fixed: https://github.com/laravel/pint/releases/tag/v1.13.1. Next time create an issue folks, because this type of discussions get lost with the other bazillion GitHub notifications we have. |
I rarely add some criticism over open source projects since I believe in the hard work of the maintainers and respect their dedication. The above said. I recently had to do a lot of digging in order to understand why my style tests were failing or why my project changes were adding a lot of code style changes. Yes, it is quite easy to overwrite the setting by adding an entry to my |
PHP-CS-Fixer Rule: yoda_style
This PR enfoce non-yoda-style