The documented return type of several access functions is bool|\Drupal\Core\Access\AccessResultInterface, but static analysis tools (phpstan, phpstorm, etc) don't know when it's bool and when it's AccessResultInterface.
This is easily rectified with conditional return types.
Note this doesn't matter for core until phpstan level 7, but plenty of contrib and custom projects are affected.
Can verify this solves some issues by counting number of errors on HEAD vs this branch:
./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --error-format=raw --level=7 | wc -l
Before: 48100
After: 48071
@return ($return_as_object is true ? \Drupal\Core\Access\AccessResultInterface : bool)
Active
11.0 🔥
base system