Issues (789)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

app/presenters/RegistrationPresenter.php (22 issues)

Upgrade to new PHP Analysis Engine

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 DateTime;
6
use Exception;
7
use App\Entities\VisitorEntity;
8
use App\Models\MeetingModel;
9
use App\Models\MealModel;
10
use App\Services\SkautIS\UserService;
11
use App\Services\Emailer;
12
use App\Repositories\VisitorRepository;
13
use App\Repositories\ProgramRepository;
14
use App\Components\Forms\RegistrationForm;
15
use App\Components\Forms\Factories\IRegistrationFormFactory;
16
use App\Services\SkautIS\EventService;
17
use Nette\Utils\ArrayHash;
18
use Skautis\Wsdl\WsdlException;
19
use App\Models\SettingsModel;
20
21
/**
22
 * Registration controller
23
 *
24
 * This file handles the registration of visitors
25
 *
26
 * @author Tomas Litera
27
 * @copyright 2013-06-12 <[email protected]>
28
 * @package srazvs
29
 */
30
class RegistrationPresenter extends VisitorPresenter
31
{
32
33
	/**
34
	 * @var UserService
35
	 */
36
	private $userService;
37
38
	/**
39
	 * @var SettingsModel
40
	 */
41
	protected $settingsModel;
42
43
	/**
44
	 * @var boolean
45
	 */
46
	private $disabled = false;
47
48
	/**
49
	 * @var IRegistrationFormFactory
50
	 */
51
	private $registrationFormFactory;
52
53
	/**
54
	 * @var EventService
55
	 */
56
	protected $skautisEventService;
57
58
    /**
59
     * @var MealModel
60
     */
61
	private $mealModel;
62
63
    /**
64
     * @var ProgramRepository
65
     */
66
	private $programRepository;
67
68
    protected $error = FALSE;
69
    protected $hash = NULL;
70
    private $user;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
71
    private $event;
72
73
	/**
74
	 * @param MeetingModel       $meetingModel
75
	 * @param UserService        $userService
76
	 * @param MealModel          $mealModel
77
	 * @param ProgramRepository  $programRepository
78
	 * @param VisitorRepository  $visitorRepository
79
	 * @param SettingsModel      $settingsModel
80
	 */
81
	public function __construct(
82
		MeetingModel $meetingModel,
83
		UserService $userService,
84
		MealModel $mealModel,
85
		Emailer $emailer,
86
		VisitorRepository $visitorRepository,
87
		ProgramRepository $programRepository,
88
		EventService $skautisEvent,
89
		SettingsModel $settingsModel
90
	) {
91
		$this->setMeetingModel($meetingModel);
92
		$this->setUserService($userService);
93
		$this->setMealModel($mealModel);
94
		$this->setEmailer($emailer);
95
		$this->setVisitorRepository($visitorRepository);
96
		$this->setProgramRepository($programRepository);
97
		$this->setEventService($skautisEvent);
98
		$this->setSettingsModel($settingsModel);
99
	}
100
101
	/**
102
	 * @return IRegistrationFormFactory
103
	 */
104
	public function getRegistrationFormFactory(): IRegistrationFormFactory
105
	{
106
		return $this->registrationFormFactory;
107
	}
108
109
	/**
110
     * Injector
111
     *
112
     * @param  IRegistrationFormFactory $factory
113
     */
114
	public function injectRegistrationFormFactory(IRegistrationFormFactory $factory)
115
	{
116
		$this->registrationFormFactory = $factory;
117
	}
118
119
	/**
120
	 * @return void
121
	 */
122
	public function startup()
123
	{
124
		parent::startup();
125
126
		$this->getMeetingModel()->setMeetingId($this->getMeetingId());
127
128
		if($this->getDebugMode() || $this->getSettingsModel()->findDebugRegime()) {
129
			$this->getMeetingModel()->setRegistrationHandlers(1);
130
			$this->setMeetingId(1);
131
		} else {
132
			$this->getMeetingModel()->setRegistrationHandlers($this->getMeetingId());
133
		}
134
135
		//$this->user = $this->container->getService('userService');
136
		//$this->event = $this->container->getService('eventService');
137
138
		$template = $this->getTemplate();
139
140
		$template->page_title = "Registrace srazu VS";
0 ignored issues
show
Accessing page_title 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
141
		$template->meeting_heading = $this->getMeetingModel()->getRegHeading();
0 ignored issues
show
Accessing meeting_heading 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
142
		$template->isRegistrationOpen = $this->getMeetingModel()->isRegOpen($this->getDebugMode());
0 ignored issues
show
Accessing isRegistrationOpen 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
143
	}
144
145
	/**
146
	 * Process data from form
147
	 *
148
	 * @return void
149
	 */
150
	public function actionCreate($visitor)
151
	{
152
		try {
153
			$guid = $this->getVisitorRepository()->create($visitor);
154
			$result = $this->sendRegistrationSummary($visitor, $guid);
155
156
			$this->logInfo('Creation of registration(%s) successfull, result: %s', [
157
				$guid,
158
				json_encode($result),
159
			]);
160
			$this->flashSuccess("Registrace({$guid}) byla úspěšně založena.");
161
		} catch(Exception $e) {
162
			$this->logError('Creation of registration failed, result: %s', [
163
				$e->getMessage(),
164
			]);
165
			$this->flashError('Uložení účastníka selhalo, chyba: ' . $e->getMessage());
166
		}
167
168
		return $guid;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $guid; (string) is incompatible with the return type of the parent method App\Presenters\VisitorPresenter::actionCreate of type boolean.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
169
	}
170
171
	/**
172
	 * @param  string  $guid
173
	 * @return void
174
	 */
175
	public function actionUpdate($guid, $visitor)
176
	{
177
		try {
178
			$result = $this->getVisitorRepository()->updateByGuid($guid, $visitor);
179
			$result = $this->sendRegistrationSummary($visitor, $guid);
180
181
			$this->logInfo('Modification of registration(%s) successfull, result: %s', [
182
				$guid,
183
				json_encode($result),
184
			]);
185
			$this->flashSuccess("Registrace({$guid}) byla úspěšně upravena.");
186
		} catch(Exception $e) {
187
			$this->logError('Modification of registration(%s) failed, result: %s', [
188
				$guid,
189
				$e->getMessage(),
190
			]);
191
			$this->flashError('Uložení účastníka selhalo, chyba: ' . $e->getMessage());
192
			$result = false;
0 ignored issues
show
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
193
		}
194
195
		return $guid;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $guid; (string) is incompatible with the return type of the parent method App\Presenters\VisitorPresenter::actionUpdate of type boolean.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
196
	}
197
198
	/**
199
	 * Renders default template
200
	 */
201
	public function renderDefault()
202
	{
203
		$template = $this->getTemplate();
204
		$disabled = $this->getMeetingModel()->isRegOpen($this->getDebugMode()) ? "" : "disabled";
205
		$template->disabled = $disabled;
0 ignored issues
show
Accessing disabled 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
206
		$template->loggedIn = $this->getUserService()->isLoggedIn();
0 ignored issues
show
Accessing loggedIn 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
207
208
		if($this->getUserService()->isLoggedIn()) {
209
			$this['registrationForm']->setDefaults(($this->useLoggedVisitor())->toArray());
210
		}
211
	}
212
213
	/**
214
	 * Renders new template
215
	 */
216
	public function renderNew()
217
	{
218
		$template = $this->getTemplate();
219
		$disabled = $this->getMeetingModel()->isRegOpen($this->getDebugMode()) ? "" : "disabled";
220
		$template->disabled = $disabled;
0 ignored issues
show
Accessing disabled 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
221
		$template->loggedIn = false;
0 ignored issues
show
Accessing loggedIn 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
222
	}
223
224
	/**
225
	 * @param  string  $guid
226
	 * @return void
227
	 */
228
	public function renderCheck($guid)
229
	{
230
		$visitor = $this->getVisitorRepository()->findByGuid($guid);
231
232
		$this->getMeetingModel()->setRegistrationHandlers($visitor->meeting);
233
234
		$template = $this->getTemplate();
235
		$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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
236
		$template->visitor = $visitor;
0 ignored issues
show
Accessing visitor 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
237
		$template->meetingId = $visitor->meeting;
0 ignored issues
show
Accessing meetingId 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
238
		$template->meals = ArrayHash::from($this->getMealModel()->findByVisitorId($visitor->id));
0 ignored issues
show
Accessing meals 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
239
		$template->province = $this->getMeetingModel()->getProvinceNameById($visitor->province);
0 ignored issues
show
Accessing province 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
240
		$template->programs = $this->getProgramRepository()->findByVisitorId($visitor->id);
0 ignored issues
show
Accessing programs 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
241
	}
242
243
	/**
244
	 * @param  string $guid
245
	 * @return void
246
	 */
247
	public function renderEdit($guid)
248
	{
249
		$visitor = $this->getVisitorRepository()->findExpandedByGuid($guid);
250
		$meetingId = $visitor['meeting'];
251
252
		$this->getMeetingModel()->setRegistrationHandlers($meetingId);
253
254
		$template = $this->getTemplate();
255
		$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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
256
		$template->meetingId = $meetingId;
0 ignored issues
show
Accessing meetingId 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
257
		$template->loggedIn = $this->getUserService()->isLoggedIn();
0 ignored issues
show
Accessing loggedIn 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
258
		$template->disabled = $this->getMeetingModel()->isRegOpen($this->getDebugMode()) ? "" : "disabled";
0 ignored issues
show
Accessing disabled 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

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
259
260
		$this['registrationForm']->setDefaults($visitor);
261
	}
262
263
	/**
264
	 * @return RegistrationFormControl
265
	 */
266
	protected function createComponentRegistrationForm(): RegistrationForm
267
	{
268
		$control = $this->registrationFormFactory->create();
269
		$control->setMeetingId($this->getMeetingId());
270
		$control->onRegistrationSave[] = function(RegistrationForm $control, $visitor) {
271
		    $guid = $this->getParameter('guid');
272
273
			if($guid) {
274
				$guid = $this->actionUpdate($guid, $visitor);
275
			} else {
276
				$guid = $this->actionCreate($visitor);
277
			}
278
/*
279
				if($this->getUserService()->isLoggedIn() && $this->getMeetingModel()->findCourseId()) {
280
					$this->getEventService()->insertEnroll(
281
						$this->getUserService()->getSkautis()->getUser()->getLoginId(),
282
						$this->getMeetingModel()->findCourseId(),
283
						// TODO: get real phone number
284
						'123456789'
285
					);
286
				}
287
*/
288
			$this->redirect('Registration:check', $guid);
289
		};
290
291
		return $control;
292
	}
293
294
	/**
295
	 * @return VisitorEntity
296
	 */
297
	protected function useLoggedVisitor(): VisitorEntity
298
	{
299
		$userDetail = $this->getUserService()->getUserDetail();
300
		$skautisUser = $this->getUserService()->getPersonalDetail($userDetail->ID_Person);
301
		$membership = $this->getUserService()->getPersonUnitDetail($userDetail->ID_Person);
302
303
		if(!preg_match('/^[1-9]{1}[0-9a-zA-Z]{2}\.[0-9a-zA-Z]{1}[0-9a-zA-Z]{1}$/', $membership->RegistrationNumber)) {
304
			$skautisUserUnit = $this->getUserService()->getParentUnitDetail($membership->ID_Unit)[0];
305
		} else {
306
			$skautisUserUnit = $this->getUserService()->getUnitDetail($membership->ID_Unit);
307
		}
308
309
		$visitor = new VisitorEntity;
310
		$visitor->name = $skautisUser->FirstName;
311
		$visitor->surname = $skautisUser->LastName;
312
		$visitor->nick = $skautisUser->NickName;
313
		$visitor->email = $skautisUser->Email;
314
		$visitor->street = $skautisUser->Street;
315
		$visitor->city = $skautisUser->City;
316
		$visitor->postal_code = preg_replace('/\s+/', '', $skautisUser->Postcode);
317
		$visitor->birthday = (new DateTime($skautisUser->Birthday))->format('d. m. Y');
318
		$visitor->group_name = $skautisUserUnit->DisplayName;
319
		$visitor->group_num = $skautisUserUnit->RegistrationNumber;
320
		if(isset($membership->Unit)) {
321
			$visitor->troop_name = $membership->Unit;
322
		}
323
324
		return $visitor;
325
	}
326
327
	/**
328
	 * @return MealModel
329
	 */
330
	protected function getMealModel()
331
	{
332
		return $this->mealModel;
333
	}
334
335
	/**
336
	 * @param  MealModel $model
337
	 * @return $this
338
	 */
339
	protected function setMealModel(MealModel $model)
340
	{
341
		$this->mealModel = $model;
342
343
		return $this;
344
	}
345
346
	/**
347
	 * @return MeetingModel
348
	 */
349
	protected function getMeetingModel()
350
	{
351
		return $this->meetingModel;
352
	}
353
354
	/**
355
	 * @param  MeetingModel $model
356
	 * @return $this
357
	 */
358
	protected function setMeetingModel(MeetingModel $model)
359
	{
360
		$this->meetingModel = $model;
361
362
		return $this;
363
	}
364
365
	/**
366
	 * @return UserService
367
	 */
368
	protected function getUserService()
369
	{
370
		return $this->userService;
371
	}
372
373
	/**
374
	 * @param  UserService $service
375
	 * @return $this
376
	 */
377
	protected function setUserService(UserService $service)
378
	{
379
		$this->userService = $service;
380
381
		return $this;
382
	}
383
384
	/**
385
	 * @return EventService
386
	 */
387
	protected function getEventService(): EventService
388
	{
389
		return $this->skautisEventService;
390
	}
391
392
	/**
393
	 * @param EventService $skautisEvent
0 ignored issues
show
There is no parameter named $skautisEvent. Was it maybe removed?

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 $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
394
	 *
395
	 * @return self
396
	 */
397
	protected function setEventService(EventService $service): self
398
	{
399
		$this->skautisEventService = $service;
400
401
		return $this;
402
	}
403
404
405
	/**
406
	 * @return SettingsModel
407
	 */
408
	protected function getSettingsModel(): SettingsModel
409
	{
410
		return $this->settingsModel;
411
	}
412
413
	/**
414
	 * @param SettingsModel $model
415
	 *
416
	 * @return self
417
	 */
418
	protected function setSettingsModel(SettingsModel $model): self
419
	{
420
		$this->settingsModel = $model;
421
422
		return $this;
423
	}
424
425
    /**
426
     * @return ProgramRepository
427
     */
428
    protected function getProgramRepository(): ProgramRepository
429
    {
430
        return $this->programRepository;
431
    }
432
433
    /**
434
     * @param  ProgramRepository $repository
435
     * @return RegistrationPresenter
436
     */
437
    protected function setProgramRepository(ProgramRepository $repository): self
438
    {
439
        $this->programRepository = $repository;
440
441
        return $this;
442
    }
443
444
}
445