Skip to content

Commit dccf13e

Browse files
authored
Avoid FQCN in code. (#40789)
1 parent 770ff2c commit dccf13e

File tree

8 files changed

+23
-13
lines changed

8 files changed

+23
-13
lines changed

src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php

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

55
use Carbon\CarbonImmutable;
66
use Carbon\CarbonInterface;
7+
use DateTimeImmutable;
78
use DateTimeInterface;
89
use Illuminate\Contracts\Database\Eloquent\Castable;
910
use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes;
@@ -1345,7 +1346,7 @@ protected function asTimestamp($value)
13451346
*/
13461347
protected function serializeDate(DateTimeInterface $date)
13471348
{
1348-
return $date instanceof \DateTimeImmutable ?
1349+
return $date instanceof DateTimeImmutable ?
13491350
CarbonImmutable::instance($date)->toJSON() :
13501351
Carbon::instance($date)->toJSON();
13511352
}

src/Illuminate/Routing/RouteDependencyResolverTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use ReflectionFunctionAbstract;
88
use ReflectionMethod;
99
use ReflectionParameter;
10+
use stdClass;
1011

1112
trait RouteDependencyResolverTrait
1213
{
@@ -42,7 +43,7 @@ public function resolveMethodDependencies(array $parameters, ReflectionFunctionA
4243

4344
$values = array_values($parameters);
4445

45-
$skippableValue = new \stdClass;
46+
$skippableValue = new stdClass;
4647

4748
foreach ($reflector->getParameters() as $key => $parameter) {
4849
$instance = $this->transformDependency($parameter, $parameters, $skippableValue);

tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php

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

55
use BadMethodCallException;
6+
use Exception;
67
use Illuminate\Database\Capsule\Manager as DB;
78
use Illuminate\Database\Eloquent\Model as Eloquent;
89
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -212,7 +213,7 @@ public function testForceDeleteDoesntUpdateExistsPropertyIfFailed()
212213
public function newModelQuery()
213214
{
214215
return Mockery::spy(parent::newModelQuery(), function (Mockery\MockInterface $mock) {
215-
$mock->shouldReceive('forceDelete')->andThrow(new \Exception());
216+
$mock->shouldReceive('forceDelete')->andThrow(new Exception());
216217
});
217218
}
218219
};
@@ -221,7 +222,7 @@ public function newModelQuery()
221222

222223
try {
223224
$user->forceDelete();
224-
} catch (\Exception $exception) {
225+
} catch (Exception $exception) {
225226
}
226227

227228
$this->assertTrue($user->exists);

tests/Foundation/Testing/DatabaseMigrationsTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use Illuminate\Contracts\Console\Kernel;
66
use Illuminate\Foundation\Testing\DatabaseMigrations;
77
use Illuminate\Foundation\Testing\RefreshDatabaseState;
8+
use Mockery;
89
use PHPUnit\Framework\TestCase;
10+
use ReflectionMethod;
911

1012
class DatabaseMigrationsTest extends TestCase
1113
{
@@ -20,7 +22,7 @@ protected function setUp(): void
2022
'beforeApplicationDestroyed',
2123
]);
2224

23-
$kernelObj = \Mockery::mock();
25+
$kernelObj = Mockery::mock();
2426
$kernelObj->shouldReceive('setArtisan')
2527
->with(null);
2628

@@ -31,7 +33,7 @@ protected function setUp(): void
3133

3234
private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName)
3335
{
34-
$migrateFreshUsingReflection = new \ReflectionMethod(
36+
$migrateFreshUsingReflection = new ReflectionMethod(
3537
get_class($this->traitObject),
3638
$methodName
3739
);

tests/Foundation/Testing/RefreshDatabaseTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use Illuminate\Contracts\Console\Kernel;
66
use Illuminate\Foundation\Testing\RefreshDatabase;
77
use Illuminate\Foundation\Testing\RefreshDatabaseState;
8+
use Mockery;
89
use PHPUnit\Framework\TestCase;
10+
use ReflectionMethod;
911

1012
class RefreshDatabaseTest extends TestCase
1113
{
@@ -20,7 +22,7 @@ protected function setUp(): void
2022
'beginDatabaseTransaction',
2123
]);
2224

23-
$kernelObj = \Mockery::mock();
25+
$kernelObj = Mockery::mock();
2426
$kernelObj->shouldReceive('setArtisan')
2527
->with(null);
2628

@@ -31,7 +33,7 @@ protected function setUp(): void
3133

3234
private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName)
3335
{
34-
$migrateFreshUsingReflection = new \ReflectionMethod(
36+
$migrateFreshUsingReflection = new ReflectionMethod(
3537
get_class($this->traitObject),
3638
$methodName
3739
);

tests/Foundation/Testing/Traits/CanConfigureMigrationCommandsTest.php

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

55
use Illuminate\Foundation\Testing\Traits\CanConfigureMigrationCommands;
66
use PHPUnit\Framework\TestCase;
7+
use ReflectionMethod;
78

89
class CanConfigureMigrationCommandsTest extends TestCase
910
{
@@ -16,7 +17,7 @@ protected function setup(): void
1617

1718
private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName)
1819
{
19-
$migrateFreshUsingReflection = new \ReflectionMethod(
20+
$migrateFreshUsingReflection = new ReflectionMethod(
2021
get_class($this->traitObject),
2122
$methodName
2223
);

tests/Integration/Database/EloquentStrictLoadingTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Schema\Blueprint;
99
use Illuminate\Support\Facades\Event;
1010
use Illuminate\Support\Facades\Schema;
11+
use RuntimeException;
1112

1213
class EloquentStrictLoadingTest extends DatabaseTestCase
1314
{
@@ -134,7 +135,7 @@ public function testStrictModeWithCustomCallbackOnLazyLoading()
134135

135136
public function testStrictModeWithOverriddenHandlerOnLazyLoading()
136137
{
137-
$this->expectException(\RuntimeException::class);
138+
$this->expectException(RuntimeException::class);
138139
$this->expectExceptionMessage('Violated');
139140

140141
EloquentStrictLoadingTestModel1WithCustomHandler::create();
@@ -171,7 +172,7 @@ public function modelTwos()
171172

172173
protected function handleLazyLoadingViolation($key)
173174
{
174-
throw new \RuntimeException("Violated {$key}");
175+
throw new RuntimeException("Violated {$key}");
175176
}
176177
}
177178

tests/Support/SupportHelpersTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use LogicException;
1313
use Mockery as m;
1414
use PHPUnit\Framework\TestCase;
15+
use ReflectionClass;
1516
use RuntimeException;
1617
use stdClass;
1718
use Traversable;
@@ -377,11 +378,11 @@ public function testStr()
377378
$this->assertTrue($stringable->isEmpty());
378379

379380
$strAccessor = str();
380-
$this->assertTrue((new \ReflectionClass($strAccessor))->isAnonymous());
381+
$this->assertTrue((new ReflectionClass($strAccessor))->isAnonymous());
381382
$this->assertSame($strAccessor->limit('string-value', 3), 'str...');
382383

383384
$strAccessor = str();
384-
$this->assertTrue((new \ReflectionClass($strAccessor))->isAnonymous());
385+
$this->assertTrue((new ReflectionClass($strAccessor))->isAnonymous());
385386
$this->assertSame((string) $strAccessor, '');
386387
}
387388

0 commit comments

Comments
 (0)