These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminListBundle\AdminList; |
||
4 | |||
5 | use Symfony\Component\PropertyAccess\PropertyAccess; |
||
6 | |||
7 | /** |
||
8 | * Field |
||
9 | */ |
||
10 | class Field |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $header; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $name; |
||
22 | |||
23 | /** |
||
24 | * @var bool |
||
25 | */ |
||
26 | private $sort; |
||
27 | |||
28 | /** |
||
29 | * @var null|string |
||
30 | */ |
||
31 | private $template; |
||
32 | |||
33 | /** |
||
34 | * @var null|FieldAlias |
||
35 | */ |
||
36 | private $alias; |
||
37 | |||
38 | /** |
||
39 | * @param string $name The name |
||
40 | * @param string $header The header |
||
41 | * @param bool $sort Sort or not |
||
42 | * @param string $template The template |
||
43 | * @param FieldAlias $alias The alias |
||
0 ignored issues
–
show
|
|||
44 | */ |
||
45 | public function __construct($name, $header, $sort = false, $template = null, FieldAlias $alias = null) |
||
46 | { |
||
47 | $this->name = $name; |
||
48 | $this->header = $header; |
||
49 | $this->sort = $sort; |
||
50 | $this->template = $template; |
||
51 | $this->alias = $alias; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getName() |
||
58 | { |
||
59 | return $this->name; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | public function getHeader() |
||
66 | { |
||
67 | return $this->header; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return bool |
||
72 | */ |
||
73 | public function isSortable() |
||
74 | { |
||
75 | return $this->sort; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getTemplate() |
||
82 | { |
||
83 | return $this->template; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @return FieldAlias|null |
||
88 | */ |
||
89 | public function getAlias() |
||
90 | { |
||
91 | return $this->alias; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function hasAlias() |
||
98 | { |
||
99 | if (is_null($this->alias)) { |
||
100 | return false; |
||
101 | } |
||
102 | |||
103 | return true; |
||
104 | } |
||
105 | |||
106 | public function getAliasObj($item) |
||
107 | { |
||
108 | $relation = $this->alias->getRelation(); |
||
109 | $accessor = PropertyAccess::createPropertyAccessor(); |
||
110 | |||
111 | if ($accessor->isReadable($item, $relation)) { |
||
112 | $item = $accessor->getValue($item, $relation); |
||
113 | } |
||
114 | |||
115 | return $item; |
||
116 | } |
||
117 | |||
118 | public function getColumnName($column) |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a
Loading history...
|
|||
119 | { |
||
120 | $abbr = $this->alias->getAbbr().'.'; |
||
121 | |||
122 | if (strpos($column, $abbr) !== false) { |
||
123 | $column = str_replace($abbr, '', $column); |
||
124 | } else { |
||
125 | throw new \Exception(" '".$abbr."' can not be found in your column name: '".$column."' "); |
||
126 | } |
||
127 | |||
128 | return $column; |
||
129 | } |
||
130 | } |
||
131 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.