}
/**
- * @return int
+ * Getter for total count
+ *
+ * @return int Total count
*/
- public function getTotalCount()
+ public function getTotalCount(): int
{
return $this->totalCount;
}
* @return array
* @see array_column()
*/
- public function column($column, $index_key = null)
+ public function column(string $column, $index_key = null): array
{
return array_column($this->getArrayCopy(true), $column, $index_key);
}
* @return BaseCollection
* @see array_map()
*/
- public function map(callable $callback)
+ public function map(callable $callback): BaseCollection
{
return new static(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
}
* @return BaseCollection
* @see array_filter()
*/
- public function filter(callable $callback = null, int $flag = 0)
+ public function filter(callable $callback = null, int $flag = 0): BaseCollection
{
return new static(array_filter($this->getArrayCopy(), $callback, $flag));
}
}
/**
- * @param $name
+ * @param mixed $name
* @return bool
* @throws HTTPException\InternalServerErrorException
*/
- public function __isset($name)
+ public function __isset($name): bool
{
if (!property_exists($this, $name)) {
- throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
+ throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class);
}
return !empty($this->$name);
* - $model->field (outside of class)
* - $this->field (inside of class)
*
- * @param $name
+ * @param string $name Name of data to fetch
* @return mixed
* @throws HTTPException\InternalServerErrorException
*/
- public function __get($name)
+ public function __get(string $name)
{
$this->checkValid();
* Actually, important actions should not be triggered by Links / GET-Requests at all, but sometimes they still are,
* so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types).
*/
- public static function getFormSecurityToken($typename = '')
+ public static function getFormSecurityToken(string $typename = '')
{
$user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']);
$timestamp = time();
return $timestamp . '.' . $sec_hash;
}
- public static function checkFormSecurityToken($typename = '', $formname = 'form_security_token')
+ /**
+ * Checks if form's security (CSRF) token is valid.
+ *
+ * @param string $typename ???
+ * @param string $formname Name of form/field (???)
+ * @return bool Whether it is valid
+ */
+ public static function checkFormSecurityToken(string $typename = '', string $formname = 'form_security_token'): bool
{
$hash = null;
return ($sec_hash == $x[1]);
}
- public static function getFormSecurityStandardErrorMessage()
+ public static function getFormSecurityStandardErrorMessage(): string
{
return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL;
}
- public static function checkFormSecurityTokenRedirectOnError($err_redirect, $typename = '', $formname = 'form_security_token')
+ public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token')
{
if (!self::checkFormSecurityToken($typename, $formname)) {
Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
}
}
- public static function checkFormSecurityTokenForbiddenOnError($typename = '', $formname = 'form_security_token')
+ public static function checkFormSecurityTokenForbiddenOnError(string $typename = '', string $formname = 'form_security_token')
{
if (!self::checkFormSecurityToken($typename, $formname)) {
Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
* @param string $file_path
* @throws \Exception
*/
- private function setModuleFile($file_path)
+ private function setModuleFile(string $file_path)
{
if (!is_readable($file_path)) {
throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path));
* @return string
* @throws \Exception
*/
- private function runModuleFunction(string $function_suffix)
+ private function runModuleFunction(string $function_suffix): string
{
$function_name = $this->moduleName . '_' . $function_suffix;