Skip to content

Commit 3f558c7

Browse files
authored
Enforce FQCN. (#41171)
1 parent c0f3ee8 commit 3f558c7

10 files changed

+21
-11
lines changed

src/Illuminate/Routing/Router.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use JsonSerializable;
2525
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
2626
use ReflectionClass;
27+
use stdClass;
2728
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
2829
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
2930

@@ -826,7 +827,7 @@ public static function toResponse($request, $response)
826827
$response instanceof Jsonable ||
827828
$response instanceof ArrayObject ||
828829
$response instanceof JsonSerializable ||
829-
$response instanceof \stdClass ||
830+
$response instanceof stdClass ||
830831
is_array($response))) {
831832
$response = new JsonResponse($response);
832833
} elseif (! $response instanceof SymfonyResponse) {

tests/Integration/Database/DatabaseEloquentBroadcastingTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Tests\Integration\Database;
44

5+
use Closure;
56
use Illuminate\Broadcasting\BroadcastEvent;
67
use Illuminate\Contracts\Broadcasting\Broadcaster;
78
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
@@ -191,7 +192,7 @@ public function testBroadcastPayloadCanBeDefined()
191192
});
192193
}
193194

194-
private function assertHandldedBroadcastableEvent(BroadcastableModelEventOccurred $event, \Closure $closure)
195+
private function assertHandldedBroadcastableEvent(BroadcastableModelEventOccurred $event, Closure $closure)
195196
{
196197
$broadcaster = m::mock(Broadcaster::class);
197198
$broadcaster->shouldReceive('broadcast')->once()

tests/Integration/Http/JsonResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\JsonResponse;
66
use Illuminate\Support\Facades\Route;
7+
use JsonSerializable;
78
use Orchestra\Testbench\TestCase;
89

910
class JsonResponseTest extends TestCase
@@ -14,7 +15,7 @@ public function testResponseWithInvalidJsonThrowsException()
1415
$this->expectExceptionMessage('Malformed UTF-8 characters, possibly incorrectly encoded');
1516

1617
Route::get('/response', function () {
17-
return new JsonResponse(new class implements \JsonSerializable
18+
return new JsonResponse(new class implements JsonSerializable
1819
{
1920
public function jsonSerialize(): string
2021
{

tests/Integration/Http/ResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Http\Response;
66
use Illuminate\Support\Facades\Route;
7+
use JsonSerializable;
78
use Orchestra\Testbench\TestCase;
89

910
class ResponseTest extends TestCase
@@ -14,7 +15,7 @@ public function testResponseWithInvalidJsonThrowsException()
1415
$this->expectExceptionMessage('Malformed UTF-8 characters, possibly incorrectly encoded');
1516

1617
Route::get('/response', function () {
17-
return (new Response())->setContent(new class implements \JsonSerializable
18+
return (new Response())->setContent(new class implements JsonSerializable
1819
{
1920
public function jsonSerialize(): string
2021
{

tests/Integration/Support/MultipleInstanceManagerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Tests\Integration\Support\Fixtures\MultipleInstanceManager;
66
use Orchestra\Testbench\TestCase;
7+
use RuntimeException;
78

89
class MultipleInstanceManagerTest extends TestCase
910
{
@@ -25,7 +26,7 @@ public function test_configurable_instances_can_be_resolved()
2526

2627
public function test_unresolvable_isntances_throw_errors()
2728
{
28-
$this->expectException(\RuntimeException::class);
29+
$this->expectException(RuntimeException::class);
2930

3031
$manager = new MultipleInstanceManager($this->app);
3132

tests/Validation/ValidationPasswordRuleTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Illuminate\Tests\Validation;
44

55
use Illuminate\Container\Container;
6+
use Illuminate\Contracts\Validation\Rule as RuleContract;
67
use Illuminate\Support\Facades\Facade;
78
use Illuminate\Translation\ArrayLoader;
89
use Illuminate\Translation\Translator;
@@ -277,7 +278,7 @@ public function testPassesWithCustomRules()
277278
}
278279
};
279280

280-
$ruleObject = new class implements \Illuminate\Contracts\Validation\Rule
281+
$ruleObject = new class implements RuleContract
281282
{
282283
public function passes($attribute, $value)
283284
{

tests/Validation/ValidationRequiredIfTest.php

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

33
namespace Illuminate\Tests\Validation;
44

5+
use Exception;
56
use Illuminate\Validation\Rules\RequiredIf;
7+
use InvalidArgumentException;
68
use PHPUnit\Framework\TestCase;
79

810
class ValidationRequiredIfTest extends TestCase
@@ -36,14 +38,14 @@ public function testItOnlyCallableAndBooleanAreAcceptableArgumentsOfTheRule()
3638

3739
$rule = new RequiredIf(true);
3840

39-
$this->expectException(\InvalidArgumentException::class);
41+
$this->expectException(InvalidArgumentException::class);
4042

4143
$rule = new RequiredIf('phpinfo');
4244
}
4345

4446
public function testItReturnedRuleIsNotSerializable()
4547
{
46-
$this->expectException(\Exception::class);
48+
$this->expectException(Exception::class);
4749

4850
$rule = serialize(new RequiredIf(function () {
4951
return true;

tests/Validation/ValidationValidatorTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use InvalidArgumentException;
2929
use Mockery as m;
3030
use PHPUnit\Framework\TestCase;
31+
use RuntimeException;
3132
use stdClass;
3233
use Symfony\Component\HttpFoundation\File\File;
3334
use Symfony\Component\HttpFoundation\File\UploadedFile;
@@ -678,7 +679,7 @@ public function testCustomExceptionMustExtendValidationException()
678679
$this->expectException(InvalidArgumentException::class);
679680
$this->expectExceptionMessage('Exception [RuntimeException] is invalid. It must extend [Illuminate\Validation\ValidationException].');
680681

681-
$v->setException(\RuntimeException::class);
682+
$v->setException(RuntimeException::class);
682683
}
683684

684685
public function testValidationDotCustomDotAnythingCanBeTranslated()

tests/View/Blade/BladeComponentTagCompilerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ public function testAttributesTreatedAsPropsAreRemovedFromFinalAttributes()
420420

421421
$attributes = new ComponentAttributeBag(['userId' => 'bar', 'other' => 'ok']);
422422

423-
$component = m::mock(\Illuminate\View\Component::class);
423+
$component = m::mock(Component::class);
424424
$component->shouldReceive('withName', 'test');
425425
$component->shouldReceive('shouldRender')->andReturn(true);
426426
$component->shouldReceive('resolveView')->andReturn('');

tests/View/Blade/BladeComponentsTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Tests\View\Blade;
44

5+
use Illuminate\View\Component;
56
use Illuminate\View\ComponentAttributeBag;
67
use Mockery as m;
78

@@ -56,7 +57,7 @@ public function testPropsAreExtractedFromParentAttributesCorrectlyForClassCompon
5657
{
5758
$attributes = new ComponentAttributeBag(['foo' => 'baz', 'other' => 'ok']);
5859

59-
$component = m::mock(\Illuminate\View\Component::class);
60+
$component = m::mock(Component::class);
6061
$component->shouldReceive('withName', 'test');
6162
$component->shouldReceive('shouldRender')->andReturn(false);
6263

0 commit comments

Comments
 (0)