Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
Last active August 29, 2015 14:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AmyStephen/dabf07f6c787211e3b94 to your computer and use it in GitHub Desktop.
PHP Storm Formatting and PSR-2 Violations
<?php
/**
* When the Exception message is too long for a single line, I split it up into pieces or
* format it like below. Up until a recent PHP Storm update, that seemed to work.
*
* @param string $code
*
* @return string
* @since 1.0.0
* @throws \CommonApi\Exception\UnexpectedValueException
*/
protected function getMessageTemplate($code)
{
if (isset($this->message_templates[ $code ])) {
return $this->message_templates[ $code ];
}
throw new UnexpectedValueException
('Fieldhandler Message getMessageTemplate Method: Do not have template: ' . $code);
}
/**
* PHP Storm formats the message above like this example -- which creates a problem.
* According to Scrutinizer PSR-2 testing, a "space before opening parenthesis of
* function call (is) prohibited."
*
* Not sure how to deal with this other than to define a $message value and then
* use that as the function input -- but -- it would be prefered if PHPStorm and
* Scrutinizer interpretted PSR-2 in the same way.
*
* Have you had this problem? Ideas?
*
* @param string $code
*
* @return string
* @since 1.0.0
* @throws \CommonApi\Exception\UnexpectedValueException
*/
protected function getMessageTemplate($code)
{
if (isset($this->message_templates[ $code ])) {
return $this->message_templates[ $code ];
}
throw new UnexpectedValueException
(
'Fieldhandler Message getMessageTemplate Method: Do not have template: ' . $code
);
}
@pmjones
Copy link

pmjones commented May 8, 2014

throw new UnexpectedValueException(
    'Fieldhandler Message getMessageTemplate Method: Do not have template: ' . $code
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment