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,
Nette\Utils\Strings;
/**
* ConditionPermission
*
* @author Jakub Konečný
*/
class ConditionPermission extends BaseCondition {
/** @var User */
protected $user;
/** @var string */
protected $name = "acl";
public function __construct(User $user) {
$this->user = $user;
}
* @param string $parameter
$parameter
string|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
* @throws \OutOfBoundsException
public function isAllowed($parameter = NULL): bool {
if(!is_string($parameter)) {
throw new \InvalidArgumentException("Method " . static::class . "::isAllowed expects string as parameter.");
} elseif(!Strings::contains($parameter, ":")) {
throw new \OutOfBoundsException("Method " . static::class . "::isAllowed expects parameter in format resource:privilege.");
return $this->user->isAllowed(Strings::before($parameter, ":"), Strings::after($parameter, ":"));
?>
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.