1 | <?php |
||
27 | trait EntityCreateMethods |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * Handle the add entity request |
||
32 | */ |
||
33 | public function add() |
||
64 | |||
65 | /** |
||
66 | * Get the create successful entity message |
||
67 | * |
||
68 | * @param EntityInterface $entity |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | protected function getCreateSuccessMessage(EntityInterface $entity) |
||
78 | |||
79 | /** |
||
80 | * Get update service |
||
81 | * |
||
82 | * @return EntityUpdateService |
||
83 | */ |
||
84 | abstract public function getUpdateService(); |
||
85 | |||
86 | /** |
||
87 | * @return FormInterface|EntityForm |
||
88 | */ |
||
89 | abstract function getForm(); |
||
90 | |||
91 | /** |
||
92 | * Get invalid form data message |
||
93 | * |
||
94 | * @param \Exception $caught |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | abstract protected function getGeneralErrorMessage(\Exception $caught); |
||
99 | |||
100 | /** |
||
101 | * Get invalid form data message |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | abstract protected function getInvalidFormDataMessage(); |
||
106 | |||
107 | /** |
||
108 | * Sets a value to be used by render |
||
109 | * |
||
110 | * The key argument can be an associative array with values to be set |
||
111 | * or a string naming the passed value. If an array is given then the |
||
112 | * value will be ignored. |
||
113 | * |
||
114 | * Those values must be set in the request attributes so they can be used |
||
115 | * latter by any other middle ware in the stack. |
||
116 | * |
||
117 | * @param string|array $key |
||
118 | * @param mixed $value |
||
119 | * |
||
120 | * @return ControllerInterface |
||
121 | */ |
||
122 | abstract public function set($key, $value = null); |
||
123 | |||
124 | /** |
||
125 | * Redirects the flow to another route/path |
||
126 | * |
||
127 | * @param string $path the route or path to redirect to |
||
128 | * |
||
129 | * @return ControllerInterface|self|$this |
||
130 | */ |
||
131 | abstract public function redirect($path); |
||
132 | |||
133 | /** |
||
134 | * Add an error flash message |
||
135 | * |
||
136 | * @param string $message |
||
137 | * @return self |
||
138 | */ |
||
139 | abstract public function addErrorMessage($message); |
||
140 | |||
141 | /** |
||
142 | * Add a success flash message |
||
143 | * |
||
144 | * @param string $message |
||
145 | * @return self |
||
146 | */ |
||
147 | abstract public function addSuccessMessage($message); |
||
148 | |||
149 | /** |
||
150 | * Returns the translation for the provided message |
||
151 | * |
||
152 | * @param string $message |
||
153 | * @param string $domain |
||
154 | * @param string $locale |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | abstract public function translate( |
||
161 | |||
162 | /** |
||
163 | * Get entity singular name used on controller actions |
||
164 | * |
||
165 | * @return string |
||
166 | */ |
||
167 | abstract protected function getEntityNameSingular(); |
||
168 | } |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.