Change record status: 
Project: 
Introduced in branch: 
10.2.x
Introduced in version: 
10.2.0
Description: 

A new service is provided for checking permissions, Drupal\Core\Session\PermissionChecker.

Previously, code to check permissions was duplicated in User::hasPermission() and UserSession::hasPermission(). That code has been moved to the new permission_checker service.

The service is swappable, allowing the Drupal's permission checking behavior to change according to your needs.

For example, to check an account's access
Before

$account->hasPermission('access content');

You still can do this.
After

\Drupal::service('permission_checker')->hasPermission('access content', $account);

Where you would use dependency injection where possible to inject the new service.

Impacts: 
Module developers