for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Nexendrie\Menu;
use Nette\Security\User;
/**
* ConditionUserLoggedIn
*
* @author Jakub Konečný
*/
class ConditionUserLoggedIn extends BaseCondition {
use \Nette\SmartObject;
/** @var User */
protected $user;
/** @var string */
protected $name = "loggedIn";
public function __construct(User $user) {
$this->user = $user;
}
* @param bool $parameter
$parameter
boolean|null
This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.
@param
It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.
* @throws \InvalidArgumentException
public function isAllowed($parameter = NULL): bool {
if(is_null($parameter)) {
return true;
} elseif(!is_bool($parameter)) {
throw new \InvalidArgumentException("Method " . static::class . "::isAllowed expects boolean as parameter.");
return ($parameter === $this->user->isLoggedIn());
?>
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.