Skip to content

Commit d0714e3

Browse files
authored
Fix badly formatted doc for Url::access and add tests (#898)
* Fix badly formatted doc from (#896) * and a test
1 parent 7e019f7 commit d0714e3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

stubs/Drupal/Core/Url.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Url implements TrustedCallbackInterface {
1313
}
1414

1515
/**
16-
* @return ($return_as_object ? \Drupal\Core\Access\AccessResultInterface : bool)
16+
* @return ($return_as_object is true ? \Drupal\Core\Access\AccessResultInterface : bool)
1717
*/
1818
public function access(?\Drupal\Core\Session\AccountInterface $account = NULL, bool $return_as_object = FALSE): \Drupal\Core\Access\AccessResultInterface|bool {
1919
}

tests/src/Type/data/url.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DrupalUrl;
44

5+
use Drupal\Core\Access\AccessResultInterface;
56
use Drupal\Core\Url;
67
use Symfony\Component\HttpFoundation\Request;
78
use function PHPStan\Testing\assertType;
@@ -24,3 +25,6 @@
2425
assertType('Drupal\Core\GeneratedUrl', Url::fromUri('the_uri')->toString(TRUE));
2526
assertType('Drupal\Core\GeneratedUrl', Url::fromUserInput('user_input')->toString(TRUE));
2627
assertType('Drupal\Core\GeneratedUrl', Url::createFromRequest(new Request())->toString(TRUE));
28+
assertType('bool', (new Url('route_name'))->access());
29+
assertType(AccessResultInterface::class, (new Url())->access(return_as_object: TRUE));
30+
assertType('bool', (new Url())->access(return_as_object: FALSE));

0 commit comments

Comments
 (0)