Skip to content

Commit

Permalink
[7.x] Fixes database offset value with non numbers (#39656)
Browse files Browse the repository at this point in the history
* Fixes database offset value with non numbers (#37164)

* Apply fixes from StyleCI

Co-authored-by: Nuno Maduro <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2021
1 parent 46130d0 commit afb0c03
Show file tree
Hide file tree
Showing 40 changed files with 116 additions and 81 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Events/ScheduledTaskFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class ScheduledTaskFailed
/**
* Create a new event instance.
*
* @param \Illuminate\Console\Scheduling\Event $task
* @param \Throwable $exception
* @param \Illuminate\Console\Scheduling\Event $task
* @param \Throwable $exception
*/
public function __construct(Event $task, Throwable $exception)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ protected function pingCallback($url)
return function (Container $container, HttpClient $http) use ($url) {
try {
$http->request('GET', $url);
} catch (ClientExceptionInterface | TransferException $e) {
} catch (ClientExceptionInterface|TransferException $e) {
$container->make(ExceptionHandler::class)->report($e);
}
};
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@ protected function fireAfterResolvingCallbacks($abstract, $object)
* @param string $abstract
* @param object $object
* @param array $callbacksPerType
*
* @return array
*/
protected function getCallbacksForType($abstract, $object, array $callbacksPerType)
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Contracts/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ public function basePath($path = '');
/**
* Get the path to the bootstrap directory.
*
* @param string $path Optionally, a path to append to the bootstrap path
* @param string $path Optionally, a path to append to the bootstrap path
* @return string
*/
public function bootstrapPath($path = '');

/**
* Get the path to the application configuration files.
*
* @param string $path Optionally, a path to append to the config path
* @param string $path Optionally, a path to append to the config path
* @return string
*/
public function configPath($path = '');

/**
* Get the path to the database directory.
*
* @param string $path Optionally, a path to append to the database path
* @param string $path Optionally, a path to append to the database path
* @return string
*/
public function databasePath($path = '');
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class BelongsTo extends Relation
* @param string $foreignKey
* @param string $ownerKey
* @param string $relationName
*
* @return void
*/
public function __construct(Builder $query, Model $child, $foreignKey, $ownerKey, $relationName)
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ public function offset($value)
{
$property = $this->unions ? 'unionOffset' : 'offset';

$this->$property = max(0, $value);
$this->$property = max(0, (int) $value);

return $this;
}
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ protected function typeDateTime(Fluent $column)
* Create the column definition for a date-time (with time zone) type.
*
* Note: "SQLite does not have a storage class set aside for storing dates and/or times."
*
* @link https://www.sqlite.org/datatype3.html
*
* @param \Illuminate\Support\Fluent $column
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function useAppPath($path)
/**
* Get the base path of the Laravel installation.
*
* @param string $path Optionally, a path to append to the base path
* @param string $path Optionally, a path to append to the base path
* @return string
*/
public function basePath($path = '')
Expand All @@ -355,7 +355,7 @@ public function basePath($path = '')
/**
* Get the path to the bootstrap directory.
*
* @param string $path Optionally, a path to append to the bootstrap path
* @param string $path Optionally, a path to append to the bootstrap path
* @return string
*/
public function bootstrapPath($path = '')
Expand All @@ -366,7 +366,7 @@ public function bootstrapPath($path = '')
/**
* Get the path to the application configuration files.
*
* @param string $path Optionally, a path to append to the config path
* @param string $path Optionally, a path to append to the config path
* @return string
*/
public function configPath($path = '')
Expand All @@ -377,7 +377,7 @@ public function configPath($path = '')
/**
* Get the path to the database directory.
*
* @param string $path Optionally, a path to append to the database path
* @param string $path Optionally, a path to append to the database path
* @return string
*/
public function databasePath($path = '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ protected function withoutExceptionHandling(array $except = [])
$this->originalExceptionHandler = app(ExceptionHandler::class);
}

$this->app->instance(ExceptionHandler::class, new class($this->originalExceptionHandler, $except) implements ExceptionHandler {
$this->app->instance(ExceptionHandler::class, new class($this->originalExceptionHandler, $except) implements ExceptionHandler
{
protected $except;
protected $originalHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ public function withoutMiddleware($middleware = null)
}

foreach ((array) $middleware as $abstract) {
$this->app->instance($abstract, new class {
$this->app->instance($abstract, new class
{
public function handle($request, $next)
{
return $next($request);
Expand Down
9 changes: 0 additions & 9 deletions src/Illuminate/Log/LogManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ public function forgetChannel($driver = null)
*
* @param string $message
* @param array $context
*
* @return void
*/
public function emergency($message, array $context = [])
Expand All @@ -510,7 +509,6 @@ public function emergency($message, array $context = [])
*
* @param string $message
* @param array $context
*
* @return void
*/
public function alert($message, array $context = [])
Expand All @@ -525,7 +523,6 @@ public function alert($message, array $context = [])
*
* @param string $message
* @param array $context
*
* @return void
*/
public function critical($message, array $context = [])
Expand All @@ -539,7 +536,6 @@ public function critical($message, array $context = [])
*
* @param string $message
* @param array $context
*
* @return void
*/
public function error($message, array $context = [])
Expand All @@ -555,7 +551,6 @@ public function error($message, array $context = [])
*
* @param string $message
* @param array $context
*
* @return void
*/
public function warning($message, array $context = [])
Expand All @@ -568,7 +563,6 @@ public function warning($message, array $context = [])
*
* @param string $message
* @param array $context
*
* @return void
*/
public function notice($message, array $context = [])
Expand All @@ -583,7 +577,6 @@ public function notice($message, array $context = [])
*
* @param string $message
* @param array $context
*
* @return void
*/
public function info($message, array $context = [])
Expand All @@ -596,7 +589,6 @@ public function info($message, array $context = [])
*
* @param string $message
* @param array $context
*
* @return void
*/
public function debug($message, array $context = [])
Expand All @@ -610,7 +602,6 @@ public function debug($message, array $context = [])
* @param mixed $level
* @param string $message
* @param array $context
*
* @return void
*/
public function log($level, $message, array $context = [])
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Mail/PendingMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function send(MailableContract $mailable)
*
* @param \Illuminate\Contracts\Mail\Mailable $mailable
* @return mixed
*
* @deprecated Use send() instead.
*/
public function sendNow(MailableContract $mailable)
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Pagination/LengthAwarePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LengthAwarePaginator extends AbstractPaginator implements Arrayable, Array
* @param int $total
* @param int $perPage
* @param int|null $currentPage
* @param array $options (path, query, fragment, pageName)
* @param array $options (path, query, fragment, pageName)
* @return void
*/
public function __construct($items, $total, $perPage, $currentPage = null, array $options = [])
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Paginator extends AbstractPaginator implements Arrayable, ArrayAccess, Cou
* @param mixed $items
* @param int $perPage
* @param int|null $currentPage
* @param array $options (path, query, fragment, pageName)
* @param array $options (path, query, fragment, pageName)
* @return void
*/
public function __construct($items, $perPage, $currentPage = null, array $options = [])
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/SerializableClosure.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SerializableClosure extends OpisSerializableClosure
/**
* Transform the use variables before serialization.
*
* @param array $data The Closure's use variables
* @param array $data The Closure's use variables
* @return array
*/
protected function transformUseVariables($data)
Expand All @@ -26,7 +26,7 @@ protected function transformUseVariables($data)
/**
* Resolve the use variables after unserialization.
*
* @param array $data The Closure's transformed use variables
* @param array $data The Closure's transformed use variables
* @return array
*/
protected function resolveUseVariables($data)
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Routing/CompiledRouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function match(Request $request)
if ($result = $matcher->matchRequest($trimmedRequest)) {
$route = $this->getByName($result['_route']);
}
} catch (ResourceNotFoundException | MethodNotAllowedException $e) {
} catch (ResourceNotFoundException|MethodNotAllowedException $e) {
try {
return $this->routes->match($request);
} catch (NotFoundHttpException $e) {
Expand All @@ -136,7 +136,7 @@ public function match(Request $request)
if (! $dynamicRoute->isFallback) {
$route = $dynamicRoute;
}
} catch (NotFoundHttpException | MethodNotAllowedHttpException $e) {
} catch (NotFoundHttpException|MethodNotAllowedHttpException $e) {
//
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ public function prepend($value, $key = null)
/**
* Push one or more items onto the end of the collection.
*
* @param mixed $values [optional]
* @param mixed $values [optional]
* @return $this
*/
public function push(...$values)
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Support/Testing/Fakes/PendingMailFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function send(Mailable $mailable)
*
* @param \Illuminate\Contracts\Mail\Mailable $mailable
* @return mixed
*
* @deprecated Use send() instead.
*/
public function sendNow(Mailable $mailable)
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Traits/ForwardsCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function forwardCallTo($object, $method, $parameters)
{
try {
return $object->{$method}(...$parameters);
} catch (Error | BadMethodCallException $e) {
} catch (Error|BadMethodCallException $e) {
$pattern = '~^Call to undefined method (?P<class>[^:]+)::(?P<method>[^\(]+)\(\)$~';

if (! preg_match($pattern, $e->getMessage(), $matches)) {
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Testing/Constraints/ArraySubset.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function evaluate($other, string $description = '', bool $returnResult =
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*
* @return string
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString(): string
{
Expand Down Expand Up @@ -224,9 +224,9 @@ public function evaluate($other, string $description = '', bool $returnResult =
/**
* Returns a string representation of the constraint.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*
* @return string
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public function toString(): string
{
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,6 @@ protected function isSameType($first, $second)
*
* @param string $attribute
* @param string $rule
*
* @return void
*/
protected function shouldBeNumeric($attribute, $rule)
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ protected function shouldBeExcluded($attribute)
* Remove the given attribute.
*
* @param string $attribute
*
* @return void
*/
protected function removeAttribute($attribute)
Expand Down
3 changes: 2 additions & 1 deletion tests/Auth/AuthenticatableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public function testItReturnsStringAsRememberTokenWhenItWasSetToTrue()

public function testItReturnsNullWhenRememberTokenNameWasSetToEmpty()
{
$user = new class extends User {
$user = new class extends User
{
public function getRememberTokenName()
{
return '';
Expand Down
1 change: 1 addition & 0 deletions tests/Cache/CacheRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public function dataProviderTestGetSeconds()

/**
* @dataProvider dataProviderTestGetSeconds
*
* @param mixed $duration
*/
public function testGetSeconds($duration)
Expand Down
3 changes: 2 additions & 1 deletion tests/Console/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function testCallingClassCommandResolveCommandViaApplicationResolution()

public function testGettingCommandArgumentsAndOptionsByClass()
{
$command = new class extends Command {
$command = new class extends Command
{
public function handle()
{
}
Expand Down
8 changes: 5 additions & 3 deletions tests/Database/DatabaseEloquentCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,17 +465,19 @@ public function testQueueableCollectionImplementationThrowsExceptionOnMultipleMo
public function testQueueableRelationshipsReturnsOnlyRelationsCommonToAllModels()
{
// This is needed to prevent loading non-existing relationships on polymorphic model collections (#26126)
$c = new Collection([new class {
$c = new Collection([new class
{
public function getQueueableRelations()
{
return ['user'];
}
}, new class {
}, new class
{
public function getQueueableRelations()
{
return ['user', 'comments'];
}
}]);
}, ]);

$this->assertEquals(['user'], $c->getQueueableRelations());
}
Expand Down
Loading

0 comments on commit afb0c03

Please sign in to comment.