{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/coding-standards/issues/119","labels_url":"https://api.github.com/repos/joomla/coding-standards/issues/119/labels{/name}","comments_url":"https://api.github.com/repos/joomla/coding-standards/issues/119/comments","events_url":"https://api.github.com/repos/joomla/coding-standards/issues/119/events","html_url":"https://github.com/joomla/coding-standards/issues/119","id":102921249,"number":119,"title":"Ternery operators","user":{"login":"photodude","id":10253980,"avatar_url":"https://avatars.githubusercontent.com/u/10253980?v=3","gravatar_id":"","url":"https://api.github.com/users/photodude","html_url":"https://github.com/photodude","followers_url":"https://api.github.com/users/photodude/followers","following_url":"https://api.github.com/users/photodude/following{/other_user}","gists_url":"https://api.github.com/users/photodude/gists{/gist_id}","starred_url":"https://api.github.com/users/photodude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/photodude/subscriptions","organizations_url":"https://api.github.com/users/photodude/orgs","repos_url":"https://api.github.com/users/photodude/repos","events_url":"https://api.github.com/users/photodude/events{/privacy}","received_events_url":"https://api.github.com/users/photodude/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-25T00:36:27Z","updated_at":"2015-08-25T00:37:19Z","closed_at":null,"body":"@mbabker Rased a question [in this PR](https://github.com/joomla/jissues/pull/680) About Ternery operators and allowing or disallowing multi-line use.\r\n\r\nI think multi-line ternary operators could have a benefit, if they improve the readability of the code. I would definitely suggest disallowing nested or stacked ternary operators as those situations just create a mess for code readability and maintenance. \r\n\r\nWith that said; based on some [things I have recently read](http://fabien.potencier.org/the-php-ternary-operator-fast-or-not.html), I question even allowing ternary operators. Or at least we should be strongly discouraging them.   \r\n\r\nIn general I think if a code standard or code style guidelines achieve the following then they are probably something that should be considered for adoption. \r\n- Does it improve code consistency?\r\n- Does it improve code readability?\r\n- Does it improve future maintainability?\r\n- Does it improve code portability?\r\n- Does it improve code performance?\r\n- Does it improve code security?\r\n\r\nSo applying those questions to ternary operators:\r\n- They are a deviation from standard if/else, thus creating a question of consistency. \r\n- They generally reduce readability\r\n- They generally reduce maintainability \r\n- They can reduce performance (since ternary operators do a copy operation, as such larger data sets will cause more performance issues)\r\n- As for portability, and security I don't know of any pros or cons. \r\n\r\nI would also say that there are places where short hand code is discouraged or not allowed in the existing standard (PHP tags for instance). So this maybe another area where the short hand operators may not be the best choice, and should be disallowed or strongly discouraged."},"comment":{"url":"https://api.github.com/repos/joomla/coding-standards/issues/comments/134426103","html_url":"https://github.com/joomla/coding-standards/issues/119#issuecomment-134426103","issue_url":"https://api.github.com/repos/joomla/coding-standards/issues/119","id":134426103,"user":{"login":"photodude","id":10253980,"avatar_url":"https://avatars.githubusercontent.com/u/10253980?v=3","gravatar_id":"","url":"https://api.github.com/users/photodude","html_url":"https://github.com/photodude","followers_url":"https://api.github.com/users/photodude/followers","following_url":"https://api.github.com/users/photodude/following{/other_user}","gists_url":"https://api.github.com/users/photodude/gists{/gist_id}","starred_url":"https://api.github.com/users/photodude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/photodude/subscriptions","organizations_url":"https://api.github.com/users/photodude/orgs","repos_url":"https://api.github.com/users/photodude/repos","events_url":"https://api.github.com/users/photodude/events{/privacy}","received_events_url":"https://api.github.com/users/photodude/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T00:37:19Z","updated_at":"2015-08-25T00:37:19Z","body":"The same \"short hand use\" question applies to short hand array declarations `someArray = [];` is a B/C issue for all packages still supporting PHP 5.3, those packages still need `someArray = array();`"}}