Welcome Guest, Not a member yet? Register   Sign In
CI coding style - help
#1

[eluser]Unknown[/eluser]
ello

i'am trying to keep CI nice coding style, but i have no idea what to do with constructions like this:

Code:
function set_form($data)
    {
        $_form_data['name']            = $data['name'];
        $_form_data['label']        = $data['label'];
        $_form_data['action']         = (isset($data['action']))     ? $data['value']     : NULL;
        $_form_data['id']             = (isset($data['id']))         ? $data['id']         : $data['name'];
        $_form_data['type']            = (isset($data['type']))     ? $data['type']        : NULL;
        $_form_data['method']        = (isset($data['method']))     ? $data['method']    : 'post';
        $_form_data['class']        = (isset($data['class']))     ? $data['class']    : NULL;
    }

how would you format code like above one??

is there a CI code style manual?? If not it could be a good idea to create one - a nice coding style 9formating text etc..) (like Ci) is also very important.
#2

[eluser]Derek Allard[/eluser]
You bet.

I wrote about EllisLab Developer guidelines once upon a time. The direct link is http://expressionengine.com/docs/develop...index.html.
#3

[eluser]Unknown[/eluser]
niceSmile this covers planty of issues of CI coding, but still my question remains.
#4

[eluser]thomas.ernest[/eluser]
There is no rule related to the ternary operator as far as I know. But there are for control structure like if/else. They have to use something similar to the Allman style indenting [ci-style-if].

I'm used to develop with PHP_CodeSniffer [phpcs] to check the coding convention of my php code.

However, it doesn't support Code Igniter style guide [ci-style] natively. So, I've developed something. It doesn't check all standard requirements, but already more than nothing.

Feel free to give a try and share your feedbacks.

[ci-style-if] http://ellislab.com/codeigniter/user-gui..._indenting
[phpcs] http://pear.php.net/package/PHP_CodeSniffer/
[ci-style] http://ellislab.com/codeigniter/user-gui...guide.html
[ci4php-cs] https://github.com/thomas-ernest/CodeIgn...odeSniffer




Theme © iAndrew 2016 - Forum software by © MyBB