allebb / netbeans-psr-formatting

NetBeans configuration settings for PSR 1&2
MIT License
150 stars 16 forks source link

Incorrect formatting #13

Closed springimport closed 7 years ago

springimport commented 7 years ago

Please, fix this.

Example:

    /**
     * Constructor
     * 
     * @param \Magento\Framework\App\Helper\Context $context
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     * @param \Magento\Customer\Model\Session $customerSession
     */
    public function __construct(
    \Magento\Framework\App\Helper\Context $context, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Customer\Model\Session $customerSession
    )
    {
        $this->_scopeConfig = $scopeConfig;
        $this->customerSession = $customerSession;
        $this->isEnabled = $this->_scopeConfig->getValue(self::XML_CONFIG_ENABLE);
        parent::__construct($context);
    }

    /**
     * Constructor
     * 
     * @param \Magento\Framework\App\Helper\Context $context
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     * @param \Magento\Customer\Model\Session $customerSession
     */
    public function __construct(
        \Magento\Framework\App\Helper\Context $context,
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
        \Magento\Customer\Model\Session $customerSession
    ) {
        $this->_scopeConfig = $scopeConfig;
        $this->customerSession = $customerSession;
        $this->isEnabled = $this->_scopeConfig->getValue(self::XML_CONFIG_ENABLE);
        parent::__construct($context);
    }

PSR:

<?php
namespace Vendor\Package;

class ClassName
{
    public function aVeryLongMethodName(
        ClassTypeHint $arg1,
        &$arg2,
        array $arg3 = []
    ) {
        // method body
    }
}

When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them.

http://www.php-fig.org/psr/psr-2/#method-arguments

allebb commented 7 years ago

I'm pretty sure that this is a limitation of NetBeans... If however, they've recently fixed it in 8.2 and you've been able to manually specify the option please could you let me know which one and I will be able to add it to the package.

Otherwise I'll get round to doing further investigation when I'm back from my holiday. - Happy to accept any PR's too :)

shawe commented 7 years ago

@springimport Seems that also you are not using http://www.php-fig.org/psr/psr-2/#namespace-and-use-declarations

When present, all use declarations MUST go after the namespace declaration.

 * @param \Magento\Framework\App\Helper\Context $context
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
 * @param \Magento\Customer\Model\Session $customerSession

And you are putting it on phpdoc block, where is not needed if you put it as expected.

allebb commented 7 years ago

👍

Closing issue as I cannot reproduce, the advice offered by @shawe seems to do the trick.

shawe commented 7 years ago

@allebb for me using PhpStorm, yes, do the trick, but NetBeans seems to have a very poor support respecting for PSR1/PSR2 rules.