php-mode
php-mode copied to clipboard
PSR2 indentation inside a method
if ($productData->getVendorId()) {
$vendorVariant->setVendor(
$this->entityManager
->getReference(Vendor::class, $productData->getVendorId())
);
}
Should be:
if ($productData->getVendorId()) {
$vendorVariant->setVendor(
$this->entityManager
->getReference(Vendor::class, $productData->getVendorId())
);
}
@ahonnecke There is now a branch called fix-psr2-indent-inside-methods
. Could you please do me the favor of fetching the latest code and testing out that change? I do not have a large codebase on hand that is meant to adhere to the PSR2 style, and so I do not want to merge that change into master
without first making sure it doesn't break anything else---God knows that wouldn't be the first time that happened in a patch fixing an indentation problem, heh.
If everything seems to work ok with the version on that branch then I will further document the patch and merge it. But again, I would greatly appreciate you (or anyone) first testing it on a large set of PHP code meant to adhere to PSR2, to see if anything else is now incorrectly indented as a result.
Thanks for the bug report and thank you in advanced for any help with testing.
Thanks! It looks like it fixed the code I pasted, but had the side effect of indenting other code that should not be indented.
protected function resetEntityManager()
{
$this->entityManager = $this->getEntityManager()->create(
$this->getEntityManager()->getConnection(),
$this->getEntityManager()->getConfiguration()
);
}
Should be:
protected function resetEntityManager()
{
$this->entityManager = $this->getEntityManager()->create(
$this->getEntityManager()->getConnection(),
$this->getEntityManager()->getConfiguration()
);
}
...but had the side effect of indenting other code that should not be indented.
Yeah, that's exactly what I was worried would happen, heh. Thank you for testing it and posting the new code that now does not indent correctly; that will help me figure out a better solution. I am sorry this is causing you problems and apologize that I (probably) will not have a quick fix, and will want your help testing again, but thank you again for both being patient and providing very helpful examples I can use for testing purposes.
Absolutely regarding helping. No worries :) I'm happy to help any way I can my lisp is pretty rusty but if there's a spot where it would be helpful for me to iterate on something I'd be happy to give it a shot.
Just to provide a simple update, I am going to attempt to fix this simultaneously along with the recently reported #371 issue, since there is a reasonable chance they are related in one way or another.
Resolved in https://github.com/emacs-php/php-mode/pull/703