Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Dec 19, 2022
1 parent b029a1b commit d3ff07d
Show file tree
Hide file tree
Showing 23 changed files with 109 additions and 93 deletions.
3 changes: 1 addition & 2 deletions src/Illuminate/Auth/EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public function retrieveByToken($identifier, $token)

$rememberToken = $retrievedModel->getRememberToken();

return $rememberToken && hash_equals($rememberToken, $token)
? $retrievedModel : null;
return $rememberToken && hash_equals($rememberToken, $token) ? $retrievedModel : null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1706,8 +1706,8 @@ public static function __callStatic($method, $parameters)
protected static function registerMixin($mixin, $replace)
{
$methods = (new ReflectionClass($mixin))->getMethods(
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
);
ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED
);

foreach ($methods as $method) {
if ($replace || ! static::hasGlobalMacro($method->name)) {
Expand Down
6 changes: 2 additions & 4 deletions src/Illuminate/Foundation/Auth/EmailVerificationRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ class EmailVerificationRequest extends FormRequest
*/
public function authorize()
{
if (! hash_equals((string) $this->user()->getKey(),
(string) $this->route('id'))) {
if (! hash_equals((string) $this->user()->getKey(), (string) $this->route('id'))) {
return false;
}

if (! hash_equals(sha1($this->user()->getEmailForVerification()),
(string) $this->route('hash'))) {
if (! hash_equals(sha1($this->user()->getEmailForVerification()), (string) $this->route('hash'))) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Console/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ protected function serverCommand()
*/
protected function host()
{
[$host, ] = $this->getHostAndPort();
[$host] = $this->getHostAndPort();

return $host;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/Console/ClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function handle()
// connection being run for the queue operation currently being executed.
$queueName = $this->getQueue($connection);

$queue = ($this->laravel['queue'])->connection($connection);
$queue = $this->laravel['queue']->connection($connection);

if ($queue instanceof ClearableQueue) {
$count = $queue->clear($queueName);
Expand Down
11 changes: 6 additions & 5 deletions src/Illuminate/Queue/Console/WorkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ public function handle()
*/
protected function runWorker($connection, $queue)
{
return $this->worker->setName($this->option('name'))
->setCache($this->cache)
->{$this->option('once') ? 'runNextJob' : 'daemon'}(
$connection, $queue, $this->gatherWorkerOptions()
);
return $this->worker
->setName($this->option('name'))
->setCache($this->cache)
->{$this->option('once') ? 'runNextJob' : 'daemon'}(
$connection, $queue, $this->gatherWorkerOptions()
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Redis/Connectors/PhpRedisConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected function establishConnection($client, array $config)
}
}

$client->{($persistent ? 'pconnect' : 'connect')}(...$parameters);
$client->{$persistent ? 'pconnect' : 'connect'}(...$parameters);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Facades/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @method static \Illuminate\Cache\TaggedCache tags(array|mixed $names)
* @method static \Illuminate\Contracts\Cache\Lock lock(string $name, int $seconds = 0, mixed $owner = null)
* @method static \Illuminate\Contracts\Cache\Lock restoreLock(string $name, string $owner)
* @method static \Illuminate\Contracts\Cache\Repository store(string|null $name = null)
* @method static \Illuminate\Contracts\Cache\Repository store(string|null $name = null)
* @method static \Illuminate\Contracts\Cache\Store getStore()
* @method static bool add(string $key, $value, \DateTimeInterface|\DateInterval|int $ttl = null)
* @method static bool flush()
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Testing/PendingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ protected function verifyExpectations()
protected function mockConsoleOutput()
{
$mock = Mockery::mock(OutputStyle::class.'[askQuestion]', [
(new ArrayInput($this->parameters)), $this->createABufferedOutputMock(),
new ArrayInput($this->parameters), $this->createABufferedOutputMock(),
]);

foreach ($this->test->expectedQuestions as $i => $question) {
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Testing/TestComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function assertSee($value, $escape = true)
*/
public function assertSeeInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
$values = $escape ? array_map('e', $values) : $values;

PHPUnit::assertThat($values, new SeeInOrder($this->rendered));

Expand Down Expand Up @@ -93,7 +93,7 @@ public function assertSeeText($value, $escape = true)
*/
public function assertSeeTextInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
$values = $escape ? array_map('e', $values) : $values;

PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->rendered)));

Expand Down
12 changes: 6 additions & 6 deletions src/Illuminate/Testing/TestResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ public function assertSee($value, $escape = true)
{
$value = Arr::wrap($value);

$values = $escape ? array_map('e', ($value)) : $value;
$values = $escape ? array_map('e', $value) : $value;

foreach ($values as $value) {
PHPUnit::assertStringContainsString((string) $value, $this->getContent());
Expand All @@ -593,7 +593,7 @@ public function assertSee($value, $escape = true)
*/
public function assertSeeInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
$values = $escape ? array_map('e', $values) : $values;

PHPUnit::assertThat($values, new SeeInOrder($this->getContent()));

Expand All @@ -611,7 +611,7 @@ public function assertSeeText($value, $escape = true)
{
$value = Arr::wrap($value);

$values = $escape ? array_map('e', ($value)) : $value;
$values = $escape ? array_map('e', $value) : $value;

tap(strip_tags($this->getContent()), function ($content) use ($values) {
foreach ($values as $value) {
Expand All @@ -631,7 +631,7 @@ public function assertSeeText($value, $escape = true)
*/
public function assertSeeTextInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
$values = $escape ? array_map('e', $values) : $values;

PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->getContent())));

Expand All @@ -649,7 +649,7 @@ public function assertDontSee($value, $escape = true)
{
$value = Arr::wrap($value);

$values = $escape ? array_map('e', ($value)) : $value;
$values = $escape ? array_map('e', $value) : $value;

foreach ($values as $value) {
PHPUnit::assertStringNotContainsString((string) $value, $this->getContent());
Expand All @@ -669,7 +669,7 @@ public function assertDontSeeText($value, $escape = true)
{
$value = Arr::wrap($value);

$values = $escape ? array_map('e', ($value)) : $value;
$values = $escape ? array_map('e', $value) : $value;

tap(strip_tags($this->getContent()), function ($content) use ($values) {
foreach ($values as $value) {
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Testing/TestView.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function assertSee($value, $escape = true)
*/
public function assertSeeInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
$values = $escape ? array_map('e', $values) : $values;

PHPUnit::assertThat($values, new SeeInOrder($this->rendered));

Expand Down Expand Up @@ -94,7 +94,7 @@ public function assertSeeText($value, $escape = true)
*/
public function assertSeeTextInOrder(array $values, $escape = true)
{
$values = $escape ? array_map('e', ($values)) : $values;
$values = $escape ? array_map('e', $values) : $values;

PHPUnit::assertThat($values, new SeeInOrder(strip_tags($this->rendered)));

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ protected function checkDateTimeOrder($format, $first, $second, $operator)
$secondDate = $this->getDateTimeWithOptionalFormat($format, $second);
}

return ($firstDate && $secondDate) && ($this->compare($firstDate, $secondDate, $operator));
return ($firstDate && $secondDate) && $this->compare($firstDate, $secondDate, $operator);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Cookie/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function test_cookie_is_sent_back_with_proper_expire_time_when_should_exp

$response = $this->get('/');
$this->assertCount(2, $response->headers->getCookies());
$this->assertEquals(0, ($response->headers->getCookies()[1])->getExpiresTime());
$this->assertEquals(0, $response->headers->getCookies()[1]->getExpiresTime());
}

public function test_cookie_is_sent_back_with_proper_expire_time_with_respect_to_lifetime()
Expand All @@ -39,7 +39,7 @@ public function test_cookie_is_sent_back_with_proper_expire_time_with_respect_to
Carbon::setTestNow(Carbon::now());
$response = $this->get('/');
$this->assertCount(2, $response->headers->getCookies());
$this->assertEquals(Carbon::now()->getTimestamp() + 60, ($response->headers->getCookies()[1])->getExpiresTime());
$this->assertEquals(Carbon::now()->getTimestamp() + 60, $response->headers->getCookies()[1]->getExpiresTime());
}

protected function getEnvironmentSetUp($app)
Expand Down
3 changes: 1 addition & 2 deletions tests/Integration/Events/QueuedClosureListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Events\CallQueuedListener;
use Illuminate\Events\InvokeQueuedClosure;
use function Illuminate\Events\queueable;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Event;
use Orchestra\Testbench\TestCase;
Expand All @@ -15,7 +14,7 @@ public function testAnonymousQueuedListenerIsQueued()
{
Bus::fake();

Event::listen(queueable(function (TestEvent $event) {
Event::listen(\Illuminate\Events\queueable(function (TestEvent $event) {
//
})->catch(function (TestEvent $event) {
//
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Http/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ public function work()
'Mohamed',
$this->mergeWhen(false, ['Adam', 'Matt']),
'Jeffrey',
$this->mergeWhen(false, (['Abigail', 'Lydia'])),
$this->mergeWhen(false, ['Abigail', 'Lydia']),
]);
}
};
Expand Down
60 changes: 39 additions & 21 deletions tests/Pagination/LengthAwarePaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,50 +74,68 @@ public function testLengthAwarePaginatorCanGenerateUrls()
$this->p->setPath('http://website.com');
$this->p->setPageName('foo');

$this->assertSame('http://website.com',
$this->p->path());

$this->assertSame('http://website.com?foo=2',
$this->p->url($this->p->currentPage()));

$this->assertSame('http://website.com?foo=1',
$this->p->url($this->p->currentPage() - 1));

$this->assertSame('http://website.com?foo=1',
$this->p->url($this->p->currentPage() - 2));
$this->assertSame(
'http://website.com',
$this->p->path()
);

$this->assertSame(
'http://website.com?foo=2',
$this->p->url($this->p->currentPage())
);

$this->assertSame(
'http://website.com?foo=1',
$this->p->url($this->p->currentPage() - 1)
);

$this->assertSame(
'http://website.com?foo=1',
$this->p->url($this->p->currentPage() - 2)
);
}

public function testLengthAwarePaginatorCanGenerateUrlsWithQuery()
{
$this->p->setPath('http://website.com?sort_by=date');
$this->p->setPageName('foo');

$this->assertSame('http://website.com?sort_by=date&foo=2',
$this->p->url($this->p->currentPage()));
$this->assertSame(
'http://website.com?sort_by=date&foo=2',
$this->p->url($this->p->currentPage())
);
}

public function testLengthAwarePaginatorCanGenerateUrlsWithoutTrailingSlashes()
{
$this->p->setPath('http://website.com/test');
$this->p->setPageName('foo');

$this->assertSame('http://website.com/test?foo=2',
$this->p->url($this->p->currentPage()));
$this->assertSame(
'http://website.com/test?foo=2',
$this->p->url($this->p->currentPage())
);

$this->assertSame('http://website.com/test?foo=1',
$this->p->url($this->p->currentPage() - 1));
$this->assertSame(
'http://website.com/test?foo=1',
$this->p->url($this->p->currentPage() - 1)
);

$this->assertSame('http://website.com/test?foo=1',
$this->p->url($this->p->currentPage() - 2));
$this->assertSame(
'http://website.com/test?foo=1',
$this->p->url($this->p->currentPage() - 2)
);
}

public function testLengthAwarePaginatorCorrectlyGenerateUrlsWithQueryAndSpaces()
{
$this->p->setPath('http://website.com?key=value%20with%20spaces');
$this->p->setPageName('foo');

$this->assertSame('http://website.com?key=value%20with%20spaces&foo=2',
$this->p->url($this->p->currentPage()));
$this->assertSame(
'http://website.com?key=value%20with%20spaces&foo=2',
$this->p->url($this->p->currentPage())
);
}

public function testItRetrievesThePaginatorOptions()
Expand Down
21 changes: 8 additions & 13 deletions tests/Pagination/PaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PaginatorTest extends TestCase
{
public function testSimplePaginatorReturnsRelevantContextInformation()
{
$p = new Paginator($array = ['item3', 'item4', 'item5'], 2, 2);
$p = new Paginator(['item3', 'item4', 'item5'], 2, 2);

$this->assertEquals(2, $p->currentPage());
$this->assertTrue($p->hasPages());
Expand All @@ -33,40 +33,35 @@ public function testSimplePaginatorReturnsRelevantContextInformation()

public function testPaginatorRemovesTrailingSlashes()
{
$p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2,
['path' => 'http://website.com/test/']);
$p = new Paginator(['item1', 'item2', 'item3'], 2, 2, ['path' => 'http://website.com/test/']);

$this->assertSame('http://website.com/test?page=1', $p->previousPageUrl());
}

public function testPaginatorGeneratesUrlsWithoutTrailingSlash()
{
$p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2,
['path' => 'http://website.com/test']);
$p = new Paginator(['item1', 'item2', 'item3'], 2, 2, ['path' => 'http://website.com/test']);

$this->assertSame('http://website.com/test?page=1', $p->previousPageUrl());
}

public function testItRetrievesThePaginatorOptions()
{
$p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2,
$options = ['path' => 'http://website.com/test']);
$p = new Paginator(['item1', 'item2', 'item3'], 2, 2, ['path' => 'http://website.com/test']);

$this->assertSame($p->getOptions(), $options);
$this->assertSame(['path' => 'http://website.com/test'], $p->getOptions());
}

public function testPaginatorReturnsPath()
{
$p = new Paginator($array = ['item1', 'item2', 'item3'], 2, 2,
['path' => 'http://website.com/test']);
$p = new Paginator(['item1', 'item2', 'item3'], 2, 2, ['path' => 'http://website.com/test']);

$this->assertSame($p->path(), 'http://website.com/test');
$this->assertSame('http://website.com/test', $p->path());
}

public function testCanTransformPaginatorItems()
{
$p = new Paginator($array = ['item1', 'item2', 'item3'], 3, 1,
['path' => 'http://website.com/test']);
$p = new Paginator(['item1', 'item2', 'item3'], 3, 1, ['path' => 'http://website.com/test']);

$p->through(function ($item) {
return substr($item, 4, 1);
Expand Down
Loading

0 comments on commit d3ff07d

Please sign in to comment.