We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 8 | trait ColumnsProtectedMethods |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * The only REALLY MANDATORY attribute for a column is the 'name'. |
||
| 12 | * Everything else, Backpack can probably guess. |
||
| 13 | * |
||
| 14 | * This method checks that all necessary attributes are set. |
||
| 15 | * If not, it tries to guess them. |
||
| 16 | * |
||
| 17 | * @param string|array $column The column definition array OR column name as string. |
||
| 18 | * @return array Proper column definition array. |
||
| 19 | */ |
||
| 20 | protected function makeSureColumnHasNeededAttributes($column) |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Add a column to the current operation, using the Setting API. |
||
| 41 | * |
||
| 42 | * @param array $column Column definition array. |
||
| 43 | */ |
||
| 44 | protected function addColumnToOperationSettings($column) |
||
| 60 | |||
| 61 | /** |
||
| 62 | * If the field definition array is actually a string, it means the programmer was lazy |
||
| 63 | * and has only passed the name of the column. Turn that into a proper array. |
||
| 64 | * |
||
| 65 | * @param array $column Column definition array. |
||
| 66 | * @return array Proper array defining the column. |
||
| 67 | */ |
||
| 68 | protected function makeSureColumnHasName($column) |
||
| 80 | |||
| 81 | /** |
||
| 82 | * If a column array is missing the "label" attribute, an ugly error would be show. |
||
| 83 | * So we add the field Name as a label - it's better than nothing. |
||
| 84 | * |
||
| 85 | * @param array $column Column definition array. |
||
| 86 | * @return array Proper array defining the column. |
||
| 87 | */ |
||
| 88 | protected function makeSureColumnHasLabel($column) |
||
| 96 | |||
| 97 | /** |
||
| 98 | * If a column definition is missing the type, set a default. |
||
| 99 | * |
||
| 100 | * @param array $column Column definition array. |
||
| 101 | * @return array Column definition array with type. |
||
| 102 | */ |
||
| 103 | protected function makeSureColumnHasType($column) |
||
| 111 | |||
| 112 | /** |
||
| 113 | * If a column definition is missing the key, set the default. |
||
| 114 | * The key is used when storing all columns using the Settings API, |
||
| 115 | * it is used as the "key" of the associative array that holds all columns. |
||
| 116 | * |
||
| 117 | * @param array $column Column definition array. |
||
| 118 | * @return array Column definition array with key. |
||
| 119 | */ |
||
| 120 | protected function makeSureColumnHasKey($column) |
||
| 128 | |||
| 129 | /** |
||
| 130 | * If an entity has been defined for the column, but no model, |
||
| 131 | * determine the model from that relationship. |
||
| 132 | * |
||
| 133 | * @param array $column Column definition array. |
||
| 134 | * @return array Column definition array with model. |
||
| 135 | */ |
||
| 136 | protected function makeSureColumnHasModel($column) |
||
| 146 | |||
| 147 | /** |
||
| 148 | * Move the most recently added column before or after the given target column. Default is before. |
||
| 149 | * |
||
| 150 | * @param string|array $targetColumn The target column name or array. |
||
| 151 | * @param bool $before If true, the column will be moved before the target column, otherwise it will be moved after it. |
||
| 152 | */ |
||
| 153 | protected function moveColumn($targetColumn, $before = true) |
||
| 172 | |||
| 173 | /** |
||
| 174 | * Check if the column exists in the database, as a DB column. |
||
| 175 | * |
||
| 176 | * @param string $table |
||
| 177 | * @param string $name |
||
| 178 | * |
||
| 179 | * @return bool |
||
| 180 | */ |
||
| 181 | protected function hasColumn($table, $name) |
||
| 197 | } |
||
| 198 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.