Role based access control of ZF2

Code
<?php

use Zend\Permissions\Rbac\Role;
use 
Zend\Permissions\Rbac\Rbac;

define('R''read');
define('W''write');

// create roles
$roleAdmin = new Role('Admin');
$roleUser = new Role('User');
$roleAnonymous = new Role('Anonymous');

// permissions
$roleAdmin->addPermission(W);
$roleUser->addPermission(R);

// add child roles / hierarchy
$roleUser->addChild($roleAnonymous);
$roleAdmin->addChild($roleUser);

$rbac = new Rbac();
$rbac->addRole($roleUser);
$rbac->addRole($roleAdmin);
$rbac->addRole($roleAnonymous);

if (
$rbac->isGranted($roleAdminR)) {
    echo 
'Admin has access and read permission from User role.' PHP_EOL;
}

if (
$rbac->isGranted($roleUserW)) {
    echo 
'User has access and write permission.' PHP_EOL;
}
Result
Admin has access and read permission from User role.
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6