| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * (c) Lukasz D. Tulikowski <[email protected]> |
||
| 5 | * |
||
| 6 | * For the full copyright and license information, please view the LICENSE |
||
| 7 | * file that was distributed with this source code. |
||
| 8 | */ |
||
| 9 | |||
| 10 | declare(strict_types=1); |
||
| 11 | |||
| 12 | namespace App\Service\Form; |
||
| 13 | |||
| 14 | use Symfony\Component\Form\FormInterface; |
||
| 15 | |||
| 16 | class FormErrorsSerializer |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | protected $errors; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @param FormInterface $form |
||
| 25 | * |
||
| 26 | * @return array |
||
| 27 | */ |
||
| 28 | 4 | public function serialize(FormInterface $form): array |
|
| 29 | { |
||
| 30 | 4 | $this->errors = $this->serializeErrors($form); |
|
| 31 | |||
| 32 | 4 | return $this->errors; |
|
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param FormInterface $form |
||
| 37 | * |
||
| 38 | * @return array |
||
| 39 | */ |
||
| 40 | 4 | protected function serializeErrors(FormInterface $form): array |
|
| 41 | { |
||
| 42 | 4 | $errors = []; |
|
| 43 | 4 | foreach ($form->getErrors() as $error) { |
|
| 44 | 4 | $errors[] = $error->getMessage(); |
|
|
0 ignored issues
–
show
|
|||
| 45 | } |
||
| 46 | |||
| 47 | 4 | foreach ($form->all() as $childForm) { |
|
| 48 | 4 | if ($childForm instanceof FormInterface) { |
|
| 49 | 4 | if ($childErrors = $this->serializeErrors($childForm)) { |
|
| 50 | 4 | $errors[$childForm->getName()] = $childErrors; |
|
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | 4 | return $errors; |
|
| 56 | } |
||
| 57 | } |
||
| 58 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.