Skip to content

Commit 56d8262

Browse files
authored
Convert Url toString return type extension to stub (#572)
1 parent 1422ca1 commit 56d8262

File tree

6 files changed

+32
-53
lines changed

6 files changed

+32
-53
lines changed

extension.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,6 @@ services:
273273
-
274274
class: mglaman\PHPStanDrupal\Type\EntityQuery\EntityQueryAccessCheckDynamicReturnTypeExtension
275275
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
276-
-
277-
class: mglaman\PHPStanDrupal\Type\UrlToStringDynamicReturnTypeExtension
278-
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]
279276
-
280277
class: mglaman\PHPStanDrupal\Type\EntityAccessControlHandlerReturnTypeExtension
281278
tags: [phpstan.broker.dynamicMethodReturnTypeExtension]

src/Type/UrlToStringDynamicReturnTypeExtension.php

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Drupal\Core;
4+
5+
use Drupal\Core\Render\BubbleableMetadata;
6+
7+
class GeneratedUrl extends BubbleableMetadata {
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Drupal\Core\Security;
4+
5+
interface TrustedCallbackInterface {
6+
7+
}

stubs/Drupal/Core/Url.stub

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Drupal\Core;
4+
5+
use Drupal\Core\Security\TrustedCallbackInterface;
6+
7+
class Url implements TrustedCallbackInterface {
8+
9+
/**
10+
* @return ($collect_bubbleable_metadata is true ? \Drupal\Core\GeneratedUrl : string)
11+
*/
12+
public function toString(bool $collect_bubbleable_metadata = FALSE) {
13+
}
14+
15+
}

tests/src/Type/UrlDynamicReturnTypeTest.php renamed to tests/src/Type/UrlToStringTypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
use mglaman\PHPStanDrupal\Tests\AdditionalConfigFilesTrait;
66
use PHPStan\Testing\TypeInferenceTestCase;
77

8-
final class UrlDynamicReturnTypeTest extends TypeInferenceTestCase
8+
final class UrlToStringTypeTest extends TypeInferenceTestCase
99
{
1010
use AdditionalConfigFilesTrait;
1111

1212
public function dataFileAsserts(): iterable
1313
{
14-
yield from $this->gatherAssertTypes(__DIR__ . '/data/url.php');
14+
yield from self::gatherAssertTypes(__DIR__ . '/data/url.php');
1515
}
1616

1717
/**

0 commit comments

Comments
 (0)