Skip to content

Commit

Permalink
Enforce FQCN. (#41171)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored Feb 22, 2022
1 parent c0f3ee8 commit 3f558c7
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use JsonSerializable;
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
use ReflectionClass;
use stdClass;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;

Expand Down Expand Up @@ -826,7 +827,7 @@ public static function toResponse($request, $response)
$response instanceof Jsonable ||
$response instanceof ArrayObject ||
$response instanceof JsonSerializable ||
$response instanceof \stdClass ||
$response instanceof stdClass ||
is_array($response))) {
$response = new JsonResponse($response);
} elseif (! $response instanceof SymfonyResponse) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Integration\Database;

use Closure;
use Illuminate\Broadcasting\BroadcastEvent;
use Illuminate\Contracts\Broadcasting\Broadcaster;
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory;
Expand Down Expand Up @@ -191,7 +192,7 @@ public function testBroadcastPayloadCanBeDefined()
});
}

private function assertHandldedBroadcastableEvent(BroadcastableModelEventOccurred $event, \Closure $closure)
private function assertHandldedBroadcastableEvent(BroadcastableModelEventOccurred $event, Closure $closure)
{
$broadcaster = m::mock(Broadcaster::class);
$broadcaster->shouldReceive('broadcast')->once()
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/Http/JsonResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Route;
use JsonSerializable;
use Orchestra\Testbench\TestCase;

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

Route::get('/response', function () {
return new JsonResponse(new class implements \JsonSerializable
return new JsonResponse(new class implements JsonSerializable
{
public function jsonSerialize(): string
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/Http/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Http\Response;
use Illuminate\Support\Facades\Route;
use JsonSerializable;
use Orchestra\Testbench\TestCase;

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

Route::get('/response', function () {
return (new Response())->setContent(new class implements \JsonSerializable
return (new Response())->setContent(new class implements JsonSerializable
{
public function jsonSerialize(): string
{
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/Support/MultipleInstanceManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Tests\Integration\Support\Fixtures\MultipleInstanceManager;
use Orchestra\Testbench\TestCase;
use RuntimeException;

class MultipleInstanceManagerTest extends TestCase
{
Expand All @@ -25,7 +26,7 @@ public function test_configurable_instances_can_be_resolved()

public function test_unresolvable_isntances_throw_errors()
{
$this->expectException(\RuntimeException::class);
$this->expectException(RuntimeException::class);

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

Expand Down
3 changes: 2 additions & 1 deletion tests/Validation/ValidationPasswordRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Tests\Validation;

use Illuminate\Container\Container;
use Illuminate\Contracts\Validation\Rule as RuleContract;
use Illuminate\Support\Facades\Facade;
use Illuminate\Translation\ArrayLoader;
use Illuminate\Translation\Translator;
Expand Down Expand Up @@ -277,7 +278,7 @@ public function testPassesWithCustomRules()
}
};

$ruleObject = new class implements \Illuminate\Contracts\Validation\Rule
$ruleObject = new class implements RuleContract
{
public function passes($attribute, $value)
{
Expand Down
6 changes: 4 additions & 2 deletions tests/Validation/ValidationRequiredIfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Illuminate\Tests\Validation;

use Exception;
use Illuminate\Validation\Rules\RequiredIf;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

class ValidationRequiredIfTest extends TestCase
Expand Down Expand Up @@ -36,14 +38,14 @@ public function testItOnlyCallableAndBooleanAreAcceptableArgumentsOfTheRule()

$rule = new RequiredIf(true);

$this->expectException(\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);

$rule = new RequiredIf('phpinfo');
}

public function testItReturnedRuleIsNotSerializable()
{
$this->expectException(\Exception::class);
$this->expectException(Exception::class);

$rule = serialize(new RequiredIf(function () {
return true;
Expand Down
3 changes: 2 additions & 1 deletion tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use InvalidArgumentException;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use stdClass;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
Expand Down Expand Up @@ -678,7 +679,7 @@ public function testCustomExceptionMustExtendValidationException()
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Exception [RuntimeException] is invalid. It must extend [Illuminate\Validation\ValidationException].');

$v->setException(\RuntimeException::class);
$v->setException(RuntimeException::class);
}

public function testValidationDotCustomDotAnythingCanBeTranslated()
Expand Down
2 changes: 1 addition & 1 deletion tests/View/Blade/BladeComponentTagCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public function testAttributesTreatedAsPropsAreRemovedFromFinalAttributes()

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

$component = m::mock(\Illuminate\View\Component::class);
$component = m::mock(Component::class);
$component->shouldReceive('withName', 'test');
$component->shouldReceive('shouldRender')->andReturn(true);
$component->shouldReceive('resolveView')->andReturn('');
Expand Down
3 changes: 2 additions & 1 deletion tests/View/Blade/BladeComponentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\View\Blade;

use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;
use Mockery as m;

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

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

Expand Down

0 comments on commit 3f558c7

Please sign in to comment.