We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 8 |
Paths | 12 |
Total Lines | 31 |
Code Lines | 14 |
Lines | 3 |
Ratio | 9.68 % |
Changes | 0 |
1 | <?php |
||
11 | public function getFakeColumnsAsArray($form = 'create') |
||
12 | { |
||
13 | $fake_field_columns_to_encode = []; |
||
14 | |||
15 | // get the right fields according to the form type (create/update) |
||
16 | $fields = $this->getFields($form); |
||
|
|||
17 | |||
18 | foreach ($fields as $k => $field) { |
||
19 | // if it's a fake field |
||
20 | if (isset($fields[$k]['fake']) && $fields[$k]['fake'] == true) { |
||
21 | // add it to the request in its appropriate variable - the one defined, if defined |
||
22 | if (isset($fields[$k]['store_in'])) { |
||
23 | View Code Duplication | if (! in_array($fields[$k]['store_in'], $fake_field_columns_to_encode, true)) { |
|
24 | array_push($fake_field_columns_to_encode, $fields[$k]['store_in']); |
||
25 | } |
||
26 | } else { |
||
27 | //otherwise in the one defined in the $crud variable |
||
28 | |||
29 | if (! in_array('extras', $fake_field_columns_to_encode, true)) { |
||
30 | array_push($fake_field_columns_to_encode, 'extras'); |
||
31 | } |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 | |||
36 | if (! count($fake_field_columns_to_encode)) { |
||
37 | return ['extras']; |
||
38 | } |
||
39 | |||
40 | return $fake_field_columns_to_encode; |
||
41 | } |
||
42 | } |
||
43 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.