Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
44 | function edit_entry_fix_hidden_fields( $fields ) { |
||
45 | |||
46 | /** @var GF_Field $field */ |
||
47 | foreach( $fields as &$field ) { |
||
48 | if ( 'uid' === $field->type ) { |
||
49 | |||
50 | // Replace GF_Field with GF_Field_Text, copying all the data from $field |
||
51 | $field = new GF_Field_Text( $field ); |
||
52 | |||
53 | // Everything is copied from $field, so we need to manually set the type |
||
54 | $field->type = 'text'; |
||
55 | } |
||
56 | } |
||
57 | |||
58 | return $fields; |
||
59 | } |
||
60 | |||
64 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.