literat /
srazvs
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
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 App\Presenters; |
||
| 4 | |||
| 5 | use App\Components\Forms\AnnotationForm; |
||
| 6 | use App\Components\Forms\Factories\IAnnotationFormFactory; |
||
| 7 | use App\Models\MeetingModel; |
||
| 8 | use App\Services\AnnotationService; |
||
| 9 | use \Exception; |
||
| 10 | |||
| 11 | class AnnotationPresenter extends BasePresenter |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var IAnnotationFormFactory |
||
| 16 | */ |
||
| 17 | private $annotationFormFactory; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var AnnotationService |
||
| 21 | */ |
||
| 22 | private $annotationService; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var MeetingModel |
||
| 26 | */ |
||
| 27 | private $meetingModel; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param AnnotationService $service |
||
| 31 | * @param MeetingModel $model |
||
| 32 | */ |
||
| 33 | public function __construct(AnnotationService $service, MeetingModel $model) |
||
| 34 | { |
||
| 35 | $this->setAnnotationService($service); |
||
| 36 | $this->setMeetingModel($model); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param IAnnotationFormFactory $factory |
||
| 41 | */ |
||
| 42 | public function injectAnnotationFormFactory(IAnnotationFormFactory $factory) |
||
| 43 | { |
||
| 44 | $this->annotationFormFactory = $factory; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $id |
||
|
0 ignored issues
–
show
|
|||
| 49 | * @param string $type |
||
| 50 | */ |
||
| 51 | public function renderEdit(string $guid, string $type) |
||
| 52 | { |
||
| 53 | $template = $this->getTemplate(); |
||
| 54 | |||
| 55 | $annotation = $this->getAnnotationService()->findByType($guid, $type); |
||
| 56 | |||
| 57 | $template->guid = $guid; |
||
|
0 ignored issues
–
show
Accessing
guid on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 58 | $template->annotation = $annotation; |
||
|
0 ignored issues
–
show
Accessing
annotation on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 59 | $template->meeting = $this->getMeetingModel()->find($this->getMeetingId()); |
||
|
0 ignored issues
–
show
Accessing
meeting on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
|
|||
| 60 | $template->program = $this->getAnnotationService()->findParentProgram($annotation); |
||
|
0 ignored issues
–
show
Accessing
program on the interface Nette\Application\UI\ITemplate suggest that you code against a concrete implementation. How about adding an instanceof check?
If you access a property on an interface, you most likely code against a concrete implementation of the interface. Available Fixes
Loading history...
$annotation is of type object<Nette\Database\Table\IRow>|false, but the function expects a object<Nette\Database\Table\ActiveRow>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 61 | |||
| 62 | $this['annotationForm']->setDefaults($annotation->toArray()); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @return AnnotationFormControl |
||
| 67 | */ |
||
| 68 | protected function createComponentAnnotationForm(): AnnotationForm |
||
| 69 | { |
||
| 70 | $control = $this->annotationFormFactory->create(); |
||
| 71 | $control->setMeetingId($this->getMeetingId()); |
||
| 72 | $type = $this->getParameter('type'); |
||
| 73 | $control->onAnnotationSave[] = function(AnnotationForm $control, $annotation) use ($type) { |
||
| 74 | try { |
||
| 75 | $result = $this->getAnnotationService()->updateByType($type, $annotation); |
||
| 76 | |||
| 77 | $this->logInfo('Modification of annotation id %s with data %s successfull, result: %s', [ |
||
| 78 | $annotation->guid, |
||
| 79 | json_encode($annotation), |
||
| 80 | json_encode($result), |
||
| 81 | ]); |
||
| 82 | |||
| 83 | $this->flashSuccess('Položka byla úspěšně upravena'); |
||
| 84 | } catch(Exception $e) { |
||
| 85 | $this->logError("Modification of annotation id {$annotation->guid} failed, result: {$e->getMessage()}"); |
||
| 86 | |||
| 87 | $this->flashError("Modification of annotation id {$annotation->guid} failed, result: {$e->getMessage()}"); |
||
| 88 | } |
||
| 89 | }; |
||
| 90 | |||
| 91 | return $control; |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @return AnnotationService |
||
| 96 | */ |
||
| 97 | public function getAnnotationService(): AnnotationService |
||
| 98 | { |
||
| 99 | return $this->annotationService; |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @param AnnotationService $annotationService |
||
| 104 | * |
||
| 105 | * @return self |
||
| 106 | */ |
||
| 107 | public function setAnnotationService(AnnotationService $annotationService): self |
||
| 108 | { |
||
| 109 | $this->annotationService = $annotationService; |
||
| 110 | |||
| 111 | return $this; |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @return MeetingModel |
||
| 116 | */ |
||
| 117 | public function getMeetingModel(): MeetingModel |
||
| 118 | { |
||
| 119 | return $this->meetingModel; |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @param MeetingModel $meetingModel |
||
| 124 | * |
||
| 125 | * @return self |
||
| 126 | */ |
||
| 127 | public function setMeetingModel(MeetingModel $meetingModel): self |
||
| 128 | { |
||
| 129 | $this->meetingModel = $meetingModel; |
||
| 130 | |||
| 131 | return $this; |
||
| 132 | } |
||
| 133 | |||
| 134 | } |
||
| 135 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.