original_string: protected function filterItemPermissions($user, array $items)
      {
          if (!$user) {
              return $items;
          }
  
          $items = array_filter($items, function ($item) use ($user) {
              if (!$item->permissions || !count($item->permissions)) {
                  return true;
              }
  
              return $user->hasAnyAccess($item->permissions);
          });
  
          return $items;
      }
code: protected function filterItemPermissions($user, array $items)
      {
          if (!$user) {
              return $items;
          }
  
          $items = array_filter($items, function ($item) use ($user) {
              if (!$item->permissions || !count($item->permissions)) {
                  return true;
              }
  
              return $user->hasAnyAccess($item->permissions);
          });
  
          return $items;
      }
code_tokens: protected function filterItemPermissions ( $ user , array $ items ) { if ( ! $ user ) { return $ items ; } $ items = array_filter ( $ items , function ( $ item ) use ( $ user ) { if ( ! $ item -> permissions || ! count ( $ item -> permissions ) ) { return true ; } return $ user -> hasAnyAccess ( $ item -> permissions ) ; } ) ; return $ items ; }
docstring: Removes menu items from an array if the supplied user lacks permission.
  @param User $user A user object
  @param array $items A collection of menu items
  @return array The filtered menu items
docstring_tokens: Removes menu items from an array if the supplied user lacks permission .